-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: using class property in polymorphic hql query
PostPosted: Fri Dec 03, 2010 11:03 am 
Newbie

Joined: Fri Dec 03, 2010 10:54 am
Posts: 2
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.