hibernate/hibernate-orm · error · PersistenceException

Unrecognized unwrap type

Error message

Unrecognized unwrap type [{type.getName()}]

What it means

PersistenceException from unwrap: none of the unwrap delegates (self, MutationOrSelectionQuery view, others) could produce an instance of the requested type, so the unwrap target is unsupported for this query.

Solutions

  1. The requested unwrap type is not supported by this query. Use a supported unwrap target type (e.g. the Hibernate Query/SelectionQuery interface actually implemented).
Defensive patterns

Strategy: validation

When it happens

Trigger: An unsupported unwrap target type is requested: Unrecognized unwrap type [<value>]

Common situations: Calling Query.unwrap() with an interface the query does not implement.


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

Appendix: source

Thrown at hibernate-core/src/main/java/org/hibernate/query/internal/AbstractQuery.java:108

	}

	@Override
	@Nonnull
	public final <X> X unwrap(Class<X> type) {
		if ( type.isInstance( this ) ) {
			return type.cast( this );
		}

		if ( type == MutationOrSelectionQuery.class ) {
			return type.cast( MutationOrSelectionQueryImpl.from( this ) );
		}

		final X unwrappedDelegate = unwrapDelegates( type );
		if ( unwrappedDelegate != null ) {
			return unwrappedDelegate;
		}

		throw new PersistenceException( "Unrecognized unwrap type [" + type.getName() + "]" );
	}

	// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// Execution

	protected <R> R executeQuery(Supplier<? extends R> supplier) {
		final var fetchProfiles = beforeQueryHandlingFetchProfiles();
		boolean success = false;
		try {
			final var result = supplier.get();
			success = true;
			return result;
		}
		catch (IllegalQueryOperationException e) {
			throw new IllegalStateException( e );
		}
		catch (HibernateException he) {
			throw getExceptionConverter().convert( he, getQueryOptions().getLockOptions() );

View on GitHub (pinned to fad1729dce)