Mhmm... the using of HQL isn't possible, one reason is I join a temporary table in the statement which isn't mapped in Hibernate.
The manually mapping of each selected field by using of a jdbc connection and createStatement(...).execute() is not convenient, because it's a large business object.
Another idea is to map Long, Integer, etc in Objects which are mapped to Hibernate. Like this:
HbnMappedInteger
+setInteger(Integer)
+getInteger():Integer
so it's possible to use Session#createSQLQuery(String,String[],Class[]). If the object contains only one field, it's possible to write a select like this:
select temp.id as {hbn.integer}, {businessObj.*}
...
createSQLQuery(select,new String[]{"hbn","businessObj"},new Class[]{HbnMappedInteger.class,BusinessObj.class})
Could this work?
|