Lets say I have 3 very complex Java classes (ClassA, ClassB, ClassC) with some inheritance: ClassC extends ClassA ClassB extends ClassA
I want to obtain the identifier of a set of objects and the class of this objects:
for(ClassA element: getSession(false).createQuery("from ClassA where ...").list() ) { doSomeProcessWith( element.getClass(), element.getId() ) }
Because I have really complex objects, this HQL query causes a heavy database query (complete ClassA objects and inheritance solving causes complex queries).
Then I try this alternative query (causing a really simple sql query)
for(Object[] element: getSession(false).createQuery("select class, id from ClassA where ...").list() { doSomeProcessWith( element[0], element[1] ) }
The problem here is Hibernate solves "class" as an integer value (the class discriminator in a polymorfic query)
¿Is there any way to obtain the Java Class as a result in HQL? ¿Is there any way to traslate the HQL polymorfic discriminator in a Java Class object?
Thanks a lot
|