hibernate/hibernate-orm · error · UnknownUnwrapTypeException
Cannot unwrap to requested type [{}]
Error message
Cannot unwrap to requested type [{}] What it means
Error "Cannot unwrap to requested type [{}]" thrown in hibernate/hibernate-orm.
Source
Thrown at hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/internal/UserSuppliedConnectionProviderImpl.java:34
* exception when a connection is requested, the assumption being that the application
* is responsible for handing the connection to use to the session.
*
* @author Gavin King
* @author Steve Ebersole
*/
public class UserSuppliedConnectionProviderImpl implements ConnectionProvider {
@Override
public boolean isUnwrappableAs(@Nonnull Class<?> unwrapType) {
return unwrapType.isAssignableFrom( UserSuppliedConnectionProviderImpl.class );
}
@Override
public <T> T unwrap(@Nonnull Class<T> unwrapType) {
if ( unwrapType.isAssignableFrom( UserSuppliedConnectionProviderImpl.class ) ) {
return unwrapType.cast( this );
}
else {
throw new UnknownUnwrapTypeException( unwrapType );
}
}
@Override
public Connection getConnection() throws SQLException {
throw new UnsupportedOperationException( "The application must supply JDBC connections" );
}
@Override
public void closeConnection(Connection connection) throws SQLException {
throw new UnsupportedOperationException( "The application must supply JDBC connections" );
}
@Override
public boolean supportsAggressiveRelease() {
return false;
}
}View on GitHub (pinned to fad1729dce)
Solutions
- Only unwrap to interfaces implemented by UserSuppliedConnectionProviderImpl
- Avoid unwrap() to unrelated types
When it happens
Trigger: Thrown at hibernate-core/src/main/java/org/hibernate/engine/jdbc/connections/internal/UserSuppliedConnectionProviderImpl.java:34 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22).
Data as JSON: /api/errors/64a4f49a3da1b25d.
Report an issue: GitHub.