I want to use Hibernate TypedQuery for a NativeQuery with Integer.class argument. Is it possible?
NativeQuery<Integer> query = session.createNativeQuery("select 1 from dual", Integer.class);
query.list(); //<--Error. Caused by: org.hibernate.MappingException: Unknown entity: java.lang.Integer
or
query.getResultList(); //<--Error. Caused by: org.hibernate.MappingException: Unknown entity: java.lang.Integer
or
query.getSingleResult(); //<--Error. Caused by: org.hibernate.MappingException: Unknown entity: java.lang.Integer
I've found some examples on Web that suggest, this is theoretically possible.
Update 1: I've updated the example.
Update 2: Add getSingleResult() example.