hibernate/hibernate-orm · error · IllegalSelectQueryException

SelectionSpecification only supports HQL or criteria query r

Error message

SelectionSpecification only supports HQL or criteria query references: {}

What it means

Error "SelectionSpecification only supports HQL or criteria query references: {}" thrown in hibernate/hibernate-orm.

Source

Thrown at hibernate-core/src/main/java/org/hibernate/query/specification/internal/SelectionSpecificationImpl.java:388

					sqmMemento.getHqlString()
			);
		}
	}

	@Nonnull
	private static <T> NamedSqmQueryMemento<T> resolveSqmSelectionMemento(
			@Nonnull TypedQueryReference<? super T> typedQueryReference,
			@Nonnull QueryEngine queryEngine) {
		final NamedQueryMemento<T> namedMemento =
				queryEngine.getNamedObjectRepository()
						//FIXME: unchecked cast
						.getQueryMementoByName( typedQueryReference.getName(), false );
		if ( namedMemento instanceof NamedSelectionMemento<T>
				&& namedMemento instanceof NamedSqmQueryMemento<T> sqmMemento ) {
			return sqmMemento;
		}
		else {
			throw new IllegalSelectQueryException(
					"SelectionSpecification only supports HQL or criteria query references: "
							+ typedQueryReference.getName()
			);
		}
	}

	/**
	 * Used during construction. Mainly used to group extracting and
	 * validating the root.
	 */
	@Nonnull
	private SqmRoot<? extends T> extractRoot(
			@Nonnull SqmSelectStatement<T> sqmStatement,
			@Nonnull Class<T> resultType,
			@Nonnull String hql) {
		final var sqmRoots = sqmStatement.getQuerySpec().getRoots();
		if ( sqmRoots.isEmpty() ) {
			throw new QueryException( "Query did not define any roots", hql );

View on GitHub (pinned to fad1729dce)

Solutions

  1. SelectionSpecification only supports HQL or criteria query references. Pass an HQL or criteria selection reference.

When it happens

Trigger: A Specification is given a statement of the wrong kind: SelectionSpecification only supports HQL or criteria query references: <value>

Common situations: Passing a select statement to MutationSpecification or a mutation statement to SelectionSpecification.


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