hibernate/hibernate-orm · error · IllegalSelectQueryException

Not a NamedSelectionMemento

Error message

Not a NamedSelectionMemento

What it means

Error "Not a NamedSelectionMemento" thrown in hibernate/hibernate-orm.

Source

Thrown at hibernate-core/src/main/java/org/hibernate/query/named/internal/NativeMutationMementoImpl.java:95

		return new NativeQueryImpl( this, session );
	}

	@Nonnull
	@Override
	public NativeQueryImplementor<T> toQuery(@Nonnull SharedSessionContractImplementor session) {
		return toMutationQuery( session );
	}

	@Nonnull
	@Override
	public <X> NativeQueryImplementor<X> toQuery(@Nonnull SharedSessionContractImplementor session, @Nullable Class<X> resultType) {
		return toMutationQuery( session, resultType );
	}

	@Nonnull
	@Override
	public <X> NativeQueryImplementor<X> toQuery(@Nonnull SharedSessionContractImplementor session, @Nullable String resultSetMapping) {
		throw new IllegalSelectQueryException( "Not a NamedSelectionMemento", sqlString );
	}

	@Override
	public void validate(@Nonnull QueryEngine queryEngine) {
		// nothing to do
	}

	@Nonnull
	@Override
	public NamedNativeQueryMemento<T> makeCopy(@Nonnull String name) {
		return new NativeMutationMementoImpl<>( name, this );
	}

	@Nonnull
	@Override
	public SelectionQueryImplementor<T> toSelectionQuery(@Nonnull SharedSessionContractImplementor session) {
		throw new IllegalSelectQueryException( "Not a NamedSelectionMemento", sqlString );
	}

View on GitHub (pinned to fad1729dce)

Solutions

  1. The memento is not a NamedSelectionMemento. Use a named selection query instead of a native mutation query.

When it happens

Trigger: A named query memento is used as the wrong query kind: Not a NamedSelectionMemento

Common situations: Internal mix-up reusing a named selection memento as a mutation memento or vice versa (e.g. via getNamedQuery APIs).


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