-->
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: lazy collection Set
PostPosted: Fri Dec 19, 2003 7:25 pm 
Beginner
Beginner

Joined: Wed Sep 17, 2003 4:07 pm
Posts: 22
I'm thinking of using the empty() method in net.sf.hibernate.collection.Set to identify whether the lazy collection set is empty(without causing the lazy loading). Is it a safe assumption that this method will be supported in future releases?

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 19, 2003 7:48 pm 
Expert
Expert

Joined: Tue Sep 16, 2003 4:06 pm
Posts: 318
Location: St. Petersburg, Russia
Ghm...
Set.empty method is part of Set interface so Hibernate just has to continue supportin it in the future :)

But this metod forces collection initialization so I have no idea how you plan to use it without causing collection to be loaded.


Top
 Profile  
 
 Post subject: lazy collection Set
PostPosted: Fri Dec 19, 2003 7:56 pm 
Beginner
Beginner

Joined: Wed Sep 17, 2003 4:07 pm
Posts: 22
No. There is an empty() method apart from isEmpty(). I know isEmpty causes lazy loading since it is implemented in net.sf.hibernate.collection.Set. But empty() doesn't cause the lazy collection to be loaded.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 19, 2003 8:12 pm 
Expert
Expert

Joined: Tue Sep 16, 2003 4:06 pm
Posts: 318
Location: St. Petersburg, Russia
Oh sorry, you are right.

But what use do you have for empty() method which does not return correct value if Set was not loaded yet?

Btw, to perform empty-check you can use code like:

Code:
boolean empty = !Hibernate.isInitialized(collection) || collection.isEmpty();


I think this code is better because does require to cast Sets to some Hibernate specific classes. Although I still do not understand why you may need this.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Dec 21, 2003 1:30 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Your application code should *not* be coupled to the PersistentCollection class - that is internal Hibernate implementation details.


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.