Projections Failing - Instantiation Exception

Upgrading from 7.2.0.Final to 7.3.1.Final causes org.hibernate.InstantiationException: Cannot instantiate query result type, found no matching constructor

Problem is in class RowTransformerConstructorImpl Line: 46

This was once a problem in early version 6, And was fixed BUT It seems merging just brought it back - Anyway, Thing is - When one projects, The results are not expected to be loaded into an entity object (hence looking for a suitable constructor is not necessary), And remember in new implementation we already have configured Tuple Transformers…

As pointed out, It once appeared as indicated here:

Please try to create a reproducer with our test case template and if you are able to reproduce the issue, create a bug ticket in our issue tracker and attach that reproducer.

Hi,

Just to give an update on this bug, Its still present in the latest Hibernate 7.4.0.Final - Haven’t found time to create a reproducer, But I personally believe its self-explanatory - Try projecting properties of an entity, It should come right up…

Exception in thread “taskExecutor-1” org.hibernate.InstantiationException: Cannot instantiate query result type, found no matching constructor ‘SomeEntity’
at org.hibernate.sql.results.internal.RowTransformerConstructorImpl.(RowTransformerConstructorImpl.java:46)

Its looking for a constructor on the entity for a projection, Anyways we had to revert back to version 7.3.0.Final, Thats the last version without this bug…

Thanks.

It might be a surprise to you, but we have tests that cover projections, so we really need a reproducer if you want us to look into this.

Try projecting a field of a related entity, One that would need a join - But even for a basic entity, Why would hibernate really require a matching constructor? Most entities only have default constructors - We didn’t change any code for this to come up, Its as a result of upgrading to the latest version and reverting back works very fine…