hibernate/hibernate-orm · error · IllegalStateException

The JPA specification does not support functions in the from

Error message

The JPA specification does not support functions in the from clause. Please disable the JPA query compliance if you want to use this feature.

What it means

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.

Source

Thrown at hibernate-core/src/main/java/org/hibernate/query/sqm/tree/spi/domain/AbstractSqmFrom.java:835

	@Nonnull
	@Override
	public <X> JpaFunctionJoin<X> joinArrayCollection(
			@Nonnull SingularAttribute<? super T, ? extends Collection<X>> collectionAttribute,
			@Nonnull SqmJoinType joinType) {
		return join( nodeBuilder().unnestCollection( get( collectionAttribute ) ), joinType, true );
	}

	private void validateComplianceFromSubQuery() {
		if ( nodeBuilder().isJpaQueryComplianceEnabled() ) {
			throw new IllegalStateException(
					"The JPA specification does not support subqueries in the from clause. "
					+ "Please disable the JPA query compliance if you want to use this feature." );
		}
	}

	private void validateComplianceFromFunction() {
		if ( nodeBuilder().isJpaQueryComplianceEnabled() ) {
			throw new IllegalStateException(
					"The JPA specification does not support functions in the from clause. "
					+ "Please disable the JPA query compliance if you want to use this feature." );
		}
	}

	@Nonnull
	@Override
	public <X> JpaCrossJoin<T, X> crossJoin(@Nonnull Class<X> entityJavaType) {
		return crossJoin( nodeBuilder().getDomainModel().entity( entityJavaType ) );
	}

	@Nonnull
	@Override
	public <X> JpaCrossJoin<T, X> crossJoin(@Nonnull EntityDomainType<X> entity) {
		@SuppressWarnings("unchecked")
		final var root = (SqmRoot<T>) findRoot();
		final SqmCrossJoin<T, X> crossJoin =
				new SqmCrossJoin<>( (SqmEntityDomainType<X>) entity, generateAlias(), root );

View on GitHub (pinned to fad1729dce)

Solutions

  1. Disable hibernate.jpa.compliance.query for that persistence unit.
  2. Replace the function join with a native/HQL query for that use case.
  3. Keep compliance on and restructure: expand the function values via a values list or a regular association join where possible.

Example fix

// before (compliance on)
root.joinArray( "favoriteNumbers" ); // IllegalStateException
// after
// persistence.xml: <property name="hibernate.jpa.compliance.query" value="false"/>
root.joinArray( "favoriteNumbers" );
Defensive patterns

Strategy: validation

Validate before calling

if ( cb.isJpaQueryComplianceEnabled() ) {
    // portable alternative or skip the feature
} else {
    root.joinArray( "favoriteNumbers" );
}

Type guard

static boolean functionJoinAllowed(HibernateCriteriaBuilder cb) {
    return !cb.isJpaQueryComplianceEnabled();
}

Prevention

When it happens

Trigger: query.from(cb.generateSeries(1, 10)), root.join(function), root.joinArray("arrayAttr"), root.joinArrayCollection(collectionAttr) while hibernate.jpa.compliance.query=true.

Common situations: 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.

Related errors


AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22). Data as JSON: /api/errors/1f6151cd79c794fb. Report an issue: GitHub.