-->
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.  [ 4 posts ] 
Author Message
 Post subject: Explicit type specification in where clause of HQLSo
PostPosted: Wed Aug 27, 2003 8:48 am 
Newbie

Joined: Wed Aug 27, 2003 8:35 am
Posts: 6
Location: Tampa, FL
Thanks in advance for any tips or tricks for this issue!

I have an entity (Headline) which is described by Metadata. Metadata is implemented as a few different joined-sublcasses (Company, Publication, Region, etc..)

I've associated Metadata to Headlines through an associative entity (this is another issue altogether. Perhaps someone can suggest a better way to perform this association as it seems unweildy when it comes to writing HQL.)

What we're trying to do now is lookup Headlines that need to be removed. The condition for this purging is based on an attribute of Publication Metadata entities. But we can't figure out a way to filter a collection (Headline.metadata) for a specific type

e.g:

delete
from Headline hl
where hl.metadata.class = Publication pub
and pub.ttl > (sysdate - hl.published)

So this could be simplified by asking "Can one constrain a condition on a collection by subclass?" :-)

thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 27, 2003 2:01 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
(1) you can use a composite element instead of an entity (you should use Hibernate 2.1 though)

(2) Collection mappings have a where attribute

(3) You could use a collection filter


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 27, 2003 3:44 pm 
Newbie

Joined: Wed Aug 27, 2003 8:35 am
Posts: 6
Location: Tampa, FL
Gavin-

Composition isn't the way the model is built as metadata has a many-to-many relationship with Headlines. I assume the collection "where" attribute is subject to the same rules in HQL (unless I'm completely overlooking something here) in that there is no way to specify you only want a particular subclass of the associated entities (Publications are Metadata, and Headlines associate to Metadata.)

Would it be clearer to ask "how I can go from Headline to Publications in a single statement?"


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 27, 2003 4:07 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
(1) composite-elements are intended EXACTLY for many-to-many associations. Please read the documentation.


(2) The where attribute is an SQL fragment. Please read the documentation.


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

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.