hi everybody, i have a polymorphic hql query with joins and want to retrieve only a concrete subclass for one of the objects contained in the query.
i know that setting the corresponding base class abstract helps (tried it;) but this has lot of impact on my app, so another solution would just be fine. now i got the hint that i can specify the class in the where clause, like:
select objA from classA objA inner join fetch objA.prop objB where objB.class=:classId
with binding the simple class name to the :classId parameter, but an exception was thrown: java.lang.String cannot be cast to java.lang.Integer
the generated sql looks like: ... and case when objB_1_.id is not null then 1 when objB_2_.id is not null then 2 when objB_.id is not null then 0 end=?
where objB_1_ and objB_2_ reference the subclass tables as i can see in the select. so maybe binding 0, 1 or 2 to the :classId param would help. but how do i find out the correct number? is the hibernate generated statement fix so i can rely on the numbers shown here? or is it possible on the next execution the numbers have changed?
is there maybe another way to specify the concrete class? by the way, i use tabe per subclass (joined) strategy...
thanks a lot best regards flo
|