{"record":{"id":"cdf245cbc20bad9b","repo":"hibernate/hibernate-orm","slug":"polymorphic-query-group-is-unsupported","errorCode":null,"errorMessage":"Polymorphic query group is unsupported","messagePattern":"Polymorphic query group is unsupported","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/query/hql/internal/QuerySplitter.java","lineNumber":64,"sourceCode":"\t\tfor ( EntityDomainType<?> mappedDescriptor : implementors ) {\n\t\t\texpanded[i++] = copyStatement( statement, unmappedPolymorphicReference, mappedDescriptor );\n\t\t}\n\t\treturn expanded;\n\t}\n\n\tprivate static SqmRoot<?> findUnmappedPolymorphicReference(SqmQueryPart<?> queryPart) {\n\t\tif ( queryPart instanceof SqmQuerySpec<?> sqmQuerySpec ) {\n\t\t\treturn sqmQuerySpec.getRoots()\n\t\t\t\t\t.stream()\n\t\t\t\t\t.filter( sqmRoot -> sqmRoot.getReferencedPathSource() instanceof SqmPolymorphicRootDescriptor )\n\t\t\t\t\t.findFirst()\n\t\t\t\t\t.orElse( null );\n\t\t}\n\t\telse {\n\t\t\tfinal SqmQueryGroup<?> queryGroup = (SqmQueryGroup<?>) queryPart;\n\t\t\tfinal SqmRoot<?> root = findUnmappedPolymorphicReference( queryGroup.getQueryParts().get( 0 ) );\n\t\t\tif ( root != null ) {\n\t\t\t\tthrow new UnsupportedOperationException( \"Polymorphic query group is unsupported\" );\n\t\t\t}\n\t\t\treturn null;\n\t\t}\n\t}\n\n\t@SuppressWarnings( { \"unchecked\", \"rawtypes\" } )\n\tprivate static <S extends SqmStatement<?>> S copyStatement(\n\t\t\tS statement,\n\t\t\tSqmRoot unmappedPolymorphicReference,\n\t\t\tEntityDomainType<?> mappedDescriptor) {\n\t\t// We never want to copy parameters when splitting polymorphic queries, as that\n\t\t// would cause losing their binding information as that's stored by instance,\n\t\t// so we always return the original object instead\n\t\tfinal SqmCopyContext context = SqmCopyContext.noParamCopyContext();\n\t\t// Copy the statement replacing the root's unmapped polymorphic reference with\n\t\t// the concrete mapped descriptor entity domain type.\n\t\tfinal var path = context.registerCopy(\n\t\t\t\tunmappedPolymorphicReference,","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/query/hql/internal/QuerySplitter.java#L46-L82","documentation":"Error \"Polymorphic query group is unsupported\" thrown in hibernate/hibernate-orm.","triggerScenarios":"A runtime precondition of the Hibernate API is violated.","commonSituations":"Occurs when application code or configuration does not satisfy the documented contract of the API being called.","solutions":["Split the polymorphic query into per-type queries explicitly.","Query the concrete entity types separately."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}