-->
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: Referencing outer object values in "where" attribu
PostPosted: Wed Feb 16, 2005 4:52 pm 
Newbie

Joined: Wed Feb 16, 2005 4:22 pm
Posts: 1
I am attempting to use a <set> to map an entity's children in a tree which is expressed using "nested set" (left and right, worm walking the graph) notation. I believe that it would be relatively easy to do this if I were able to reference the containing object's properties from the where attribute. Something like this:

<class name="Category"
table="Categories">
<id name="id"
column="category_id"
type="long">
<set name="descendantCategories"
cascade="all-delete-orphan"
inverse="true"
order-by="category_left"
lazy="true"
where="category_left >= outer.category_left AND category_right <= outer.category_right">
<key column="category_id_root"
foreign-key="category_id_root" />
<one-to-many class="Category" />
</set>
<property name="left"
column="category_left" />
<property name="right"
column="category_right" />
<property name="name"
column="category_name" />
</class>

Notice the set definition for the "descendantCategories" property. The "where" attribute that I have quoted here is not valid because it attempts to access properties on the containing object (which I have prefixed with the pseudocode "outer." for clarity.) As far as I know, this is not possible with Hibernate 2.1.7. The net.sf.hibernate.sql.Template class merely scans the entire where clause and prepends the inner table name to all identifiers.

Is there something that I'm missing here? Is there another way to express what I am trying to express with the "outer." bit above? (I KNOW that "outer." is nonsense...I'm merely trying to illustrate my intent.) If not, does anybody know how difficult it would be to implement this? I believe that I could do it by making a few strategic changes to Template.renderWhereStringTemplate() and its callers. What pitfalls am I missing?

Thank you all for your time.
--Matt


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.