Here is how i build my Select using JPA criteria API, builder bein my CriteriaBuilder
And My obj has a constructor :
I was using hibernate 4 and had a nullpointer on the handler so after looking in the net, and seeing there was now a BooleanValueHandler in Hibernate 5, I upgraded.
now the error i get is :
Caused by: org.hibernate.hql.internal.ast.QuerySyntaxException: Unable to locate appropriate constructor on class [mypackage.MyDto]. Expected arguments are: long, java.lang.String, boolean [select distinct new mypackage.MyDto(generatedAlias0.intField, generatedAlias0.stringField, case when generatedAlias1.booleanField = true then true else false end, false) from myEntityPackage.MyEntity as generatedAlias0]
If i replace the literal(false) by literal(0) and I change the type of pBooleanAttr2 to Integer in the constructor, it works fine.
If I keep the boolean but remove it from the constructor, it tells me i have 4 fields in my select and only 3 in the constructor.
So what am I missing ?
Of course my query is more complex than this.
Hibernate-entitymanager 5.1.0.final with hibernante-jpa-2.1-api