-->
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: Query on (many-to-one) polymorphic association subclass
PostPosted: Mon Jan 16, 2006 8:50 am 
Newbie

Joined: Mon Jan 16, 2006 6:55 am
Posts: 1
The problem:
Querying on a property of a subclass of a polymorphic association does not work. The resulting SQL query refers to an alias that does not exist,
causing a "unknown column" SQL exception.

This is similar to the following posting except in my case it is a many-to-one association.
http://forum.hibernate.org/viewtopic.ph ... highlight=
There was no proper response for that topic.

Let me try to lay it down in simple terms.

The Entities/Mappings:

Mapping for A

Class A
property superClassProperty

Joined SubClass B extends A
property subClassProperty

End of Mapping A


Mapping for R

Class R
property id
property refToA of type A (many-to-one) polymorphic association
property someOtherProperty

End of Mapping R


The Query:
from R as r1 where r1.id = 'someid' order by r1.refToA.subClassProperty

The above query results in the SQL exception I mentioned earlier however the following query works perfectly.

from R as r1 where r1.id = 'someid' order by r1.refToA.superClassProperty

The difference being that the latter refers to a property of A rather than a subclass' property.

What I really want to know is how can I achieve the main goal of querying on a subclass property of a polymorphic association.

Thanks in advance for any help on this.


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.