-->
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: problem:lazy-load action are performed recursively?
PostPosted: Wed Oct 11, 2006 9:16 pm 
Newbie

Joined: Wed Oct 11, 2006 8:53 pm
Posts: 1
I have three entity classes:Operator,Mailbox and MailboxFolder
relationship: operator to mailbox is one-to-many and mailbox to mailboxFolder is one-to-many too, and both set lazy to true,but when I set show_sql to true ,I found that when I call operator.getMailBoxSet without call MailBox.getFolderSet(), hibernate try to read all mailBox for this operator,but the confused thing is: hibernate try to read all mailBoxFolder for each mailBox too!

the codes:
Iterator iter = operator.getMailBoxSet().Iterator();while(iter.hasNext()){MailBox mailBox=(MailBox)iter.next();logger.debug(mailBox.getID())};

according to hibernat reference,if mailBox.getFolderSet dosen't be called,it's foldSet property should still be lazy collection.
and I also tested such a case: if I use hql to load all mailBox for this operator,lazy-load works fine.

any one could help? thanks very much.
Mapping files:

<class name="com.sinohotel.module.operator.data.Operator" table="operator"
dynamic-update="true" dynamic-insert="true">
<set name="mailBoxSet" table="operator_mailbox" lazy="true" cascade="none" batch-size="5">
<key column="operator_id"/>
<many-to-many class="com.sinohotel.module.mail.data.MailBox" column="mailbox_id"/>
</set>
</class>
<class name="com.sinohotel.module.mail.data.MailBox" table="mailbox"
dynamic-update="true" dynamic-insert="true">
<set name="folderSet" cascade="all,delete-orphan" inverse="true" lazy="true" batch-size="5">
<key column="mailbox_id"/>
<one-to-many class="com.sinohotel.module.mail.data.MailBoxFolder"/>
</set>
</class>

<class name="com.sinohotel.module.mail.data.MailBoxFolder" table="mailbox_folder"
dynamic-update="true" dynamic-insert="true">
<id name="id" type="int">
<column name="id" sql-type="int" not-null="true"/>
<generator class="native"/>
</id>
<property name="name" type="string">
<column name="name" sql-type="char(255)"/>
</property>
<many-to-one name="mailBox" class="com.sinohotel.module.mail.data.MailBox" column="mailbox_id"/>
</class>


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.