-->
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.  [ 7 posts ] 
Author Message
 Post subject: Session.find() returns List instead of Set. Why?
PostPosted: Mon Dec 08, 2003 9:15 pm 
Beginner
Beginner

Joined: Thu Nov 20, 2003 8:13 pm
Posts: 31
Location: Newport Beach, CA
Didn't find this by searching so hoping for some guidance here:

Why does Session.find() return a java.util.List? Why not Set for example? Or Collection?

My guess is that it is more important to support multiple identical objects rather than making a point that the results are not ordered.

If all of my objects have unique identifiers, is it safe to just use:

new Set(Session.find(...))?

Thanks,
Justin


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 09, 2003 12:17 am 
Regular
Regular

Joined: Wed Nov 05, 2003 10:57 pm
Posts: 96
java.util.Set is an inteface. Nothing prevents you from instantiating one of its implementations (e.g. HashSet) from a List.

mota


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 09, 2003 12:19 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
The semantics of a query result set are List semantics. Ordered, may contain the same element twice...


Top
 Profile  
 
 Post subject: Inherent ordering of search results
PostPosted: Tue Dec 09, 2003 1:12 pm 
Beginner
Beginner

Joined: Thu Nov 20, 2003 8:13 pm
Posts: 31
Location: Newport Beach, CA
I guess that's the question behind the question. What is the inherent ordering of the search results? Is it simply an arbitrarily-applied ordering depending on what order the database returns the results in?
Thanks again,
Justin


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 09, 2003 1:45 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
What ever it may be, guessing on that is dangerous since it's internal implementation choice and might change in the future

_________________
Emmanuel


Top
 Profile  
 
 Post subject: Collection
PostPosted: Tue Dec 09, 2003 1:50 pm 
Beginner
Beginner

Joined: Thu Nov 20, 2003 8:13 pm
Posts: 31
Location: Newport Beach, CA
Ok. Sounds like there shouldn't be a problem returning a Collection (rather than List) from my own search API.
Thanks all :p


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 09, 2003 7:50 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
The order is not arbitrary if you have an ORDER BY clause though!


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