-->
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: How to lazy load Parent/Child,lazy many-to-one does not work
PostPosted: Fri Jan 14, 2005 10:14 am 
Newbie

Joined: Fri Sep 17, 2004 3:07 pm
Posts: 14
I'm trying to filter out parts of a single-class recursive (Parent/Child) tree structure according to user's role. The complete tree is accessed ok usinga separate key field - bi-directional construction of the unfiltered tree works fine, in a single query. However, trying to filter out a subset of the nodes (and then manually evicting any orphans) does not work, because Hibernate eagerly loads the lazy nodes to which no access is intended.

Consider a public root and a public leaf, and a "secret" intermediate node between these. When I try to filter out the secret node, I find that it is automatically loaded by Hibernate, outside the filtered query. Yes, the node class is declared lazy, as well as the <set ...> side. Any help, anyone ? To work around, I had to map the parent_id as a property, basically resort to manual ORM.

Hibernate version:3.0b1

Mapping documents:

<hibernate-mapping>
<class
name="pkg.TreeNode"
table="TREE_NODE" lazy="true" proxy="pkg.TreeNode">

...

<set name="children" table="TREE_NODE" inverse="true" cascade="none" lazy="true">
<key column="PARENT_ID" />
<one-to-many class="pkg.TreeNode" />
</set>
<filter .../>
</class>
<filter-def...>
...
<filter-def>

</hibernate-mapping>


Code between sessionFactory.openSession() and session.close():

one select that retrieves a filtered list of TreeNodes. I only need the ones reachable from root. OK to return "orphans", but they are not used...


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.