-->
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.  [ 5 posts ] 
Author Message
 Post subject: The lazy="true" ,it can't run.....
PostPosted: Sun Mar 07, 2004 11:37 pm 
Regular
Regular

Joined: Tue Dec 30, 2003 2:35 am
Posts: 85
author:publication=1:n

i had set the lazy="true" in the author.hbm.xml,but i run the java code,it looks like the lazy="true" is not acted as my wish.

com.one2many.Author objAuthorFind = (com.one2many.Author)objSession.load(com.one2many.Author.class,"PersonNo1");
com.one2many.Publication objPublication = null;
String strResult = objAuthorFind.getALIAS();
System.out.print(strResult);
java.util.Iterator objIterator = objAuthorFind.getpublications().iterator();
while(objIterator.hasNext())
{
objPublication = (com.one2many.Publication)objIterator.next();
//★★★★★
System.out.println(objPublication.getbookName());
}

at the ★★★★★,it also can provide the right fields value of the database,but i had set the i set the lazy="true" in the author.hbm.xml,it select the author entity from database,but it also select the publication entity from database,but why,the publication entity would not be select from the database!!!!

i can't understand how the lazy="true" runs....

thank a lot!


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 08, 2004 4:50 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Of course the publications get loaded as soon as you request an iterator on them.


Top
 Profile  
 
 Post subject: but i don't understand....
PostPosted: Mon Mar 08, 2004 11:27 pm 
Regular
Regular

Joined: Tue Dec 30, 2003 2:35 am
Posts: 85
the publications is the son of the author,when i loaded the father,the son is loaded(not as my wish)!

is this a memory waste?i need not the hibernate load the son infomation(publication),i only need the hibernate load the father information(author)

Does the things i describe has some relation with the lazy="true"??

thanks a lot!


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 09, 2004 5:48 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Of course the publications get loaded when you access them, thats the whole point of "lazy=true"


Top
 Profile  
 
 Post subject: but as you say....
PostPosted: Tue Mar 09, 2004 11:27 am 
Regular
Regular

Joined: Tue Dec 30, 2003 2:35 am
Posts: 85
as the document,if lazy="true",when i load the entity of father,the hibernate can't load the entity of son.

in fact,i set lazy="true",but the hibernate load the father,also hibernate load the son.

that situation is very strange,it looks like NO DIFFERENT BETWEEN lazy="true" and lazy="false"!

thanks a lot!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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.