{"record":{"id":"1f6151cd79c794fb","repo":"hibernate/hibernate-orm","slug":"the-jpa-specification-does-not-support-functions-i","errorCode":null,"errorMessage":"The JPA specification does not support functions in the from clause. Please disable the JPA query compliance if you want to use this feature.","messagePattern":"The JPA specification does not support functions in the from clause\\. Please disable the JPA query compliance if you want to use this feature\\.","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/query/sqm/tree/spi/domain/AbstractSqmFrom.java","lineNumber":835,"sourceCode":"\t@Nonnull\n\t@Override\n\tpublic <X> JpaFunctionJoin<X> joinArrayCollection(\n\t\t\t@Nonnull SingularAttribute<? super T, ? extends Collection<X>> collectionAttribute,\n\t\t\t@Nonnull SqmJoinType joinType) {\n\t\treturn join( nodeBuilder().unnestCollection( get( collectionAttribute ) ), joinType, true );\n\t}\n\n\tprivate void validateComplianceFromSubQuery() {\n\t\tif ( nodeBuilder().isJpaQueryComplianceEnabled() ) {\n\t\t\tthrow new IllegalStateException(\n\t\t\t\t\t\"The JPA specification does not support subqueries in the from clause. \"\n\t\t\t\t\t+ \"Please disable the JPA query compliance if you want to use this feature.\" );\n\t\t}\n\t}\n\n\tprivate void validateComplianceFromFunction() {\n\t\tif ( nodeBuilder().isJpaQueryComplianceEnabled() ) {\n\t\t\tthrow new IllegalStateException(\n\t\t\t\t\t\"The JPA specification does not support functions in the from clause. \"\n\t\t\t\t\t+ \"Please disable the JPA query compliance if you want to use this feature.\" );\n\t\t}\n\t}\n\n\t@Nonnull\n\t@Override\n\tpublic <X> JpaCrossJoin<T, X> crossJoin(@Nonnull Class<X> entityJavaType) {\n\t\treturn crossJoin( nodeBuilder().getDomainModel().entity( entityJavaType ) );\n\t}\n\n\t@Nonnull\n\t@Override\n\tpublic <X> JpaCrossJoin<T, X> crossJoin(@Nonnull EntityDomainType<X> entity) {\n\t\t@SuppressWarnings(\"unchecked\")\n\t\tfinal var root = (SqmRoot<T>) findRoot();\n\t\tfinal SqmCrossJoin<T, X> crossJoin =\n\t\t\t\tnew SqmCrossJoin<>( (SqmEntityDomainType<X>) entity, generateAlias(), root );","sourceCodeStart":817,"sourceCodeEnd":853,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/spi/domain/AbstractSqmFrom.java#L817-L853","documentation":"AbstractSqmFrom.validateComplianceFromFunction guards Hibernate's function-in-FROM features: joins of table-valued/generating functions such as generateSeries(), unnest/collection-unnest and the joinArray/joinArrayCollection entry points (join(JpaFunction...) path). With JPA query compliance enabled it throws IllegalStateException since the JPA specification has no function joins in the FROM clause.","triggerScenarios":"query.from(cb.generateSeries(1, 10)), root.join(function), root.joinArray(\"arrayAttr\"), root.joinArrayCollection(collectionAttr) while hibernate.jpa.compliance.query=true.","commonSituations":"Enabling JPA query compliance in a project already using PostgreSQL-style generate_series/unnest joins or array joins; upgrading Hibernate and adopting these Hibernate 6+ features in a certified/compliant persistence unit.","solutions":["Disable hibernate.jpa.compliance.query for that persistence unit.","Replace the function join with a native/HQL query for that use case.","Keep compliance on and restructure: expand the function values via a values list or a regular association join where possible."],"exampleFix":"// before (compliance on)\nroot.joinArray( \"favoriteNumbers\" ); // IllegalStateException\n// after\n// persistence.xml: <property name=\"hibernate.jpa.compliance.query\" value=\"false\"/>\nroot.joinArray( \"favoriteNumbers\" );","handlingStrategy":"validation","validationCode":"if ( cb.isJpaQueryComplianceEnabled() ) {\n    // portable alternative or skip the feature\n} else {\n    root.joinArray( \"favoriteNumbers\" );\n}","typeGuard":"static boolean functionJoinAllowed(HibernateCriteriaBuilder cb) {\n    return !cb.isJpaQueryComplianceEnabled();\n}","tryCatchPattern":null,"preventionTips":["Do not mix generate_series/unnest/array joins into persistence units marked JPA-compliant.","Gating these calls on isJpaQueryComplianceEnabled() keeps shared code usable in both configurations.","Consider HQL or native SQL for function-driven FROM clauses in compliant units."],"tags":["hibernate","criteria-api","function-join","from-clause","jpa-compliance"],"backgroundTag":"jpa-compliance-violation","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}