-->
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.  [ 2 posts ] 
Author Message
 Post subject: Returning java.util.Set from Query does reordering
PostPosted: Sun Oct 15, 2006 6:07 pm 
Beginner
Beginner

Joined: Fri Apr 15, 2005 3:30 pm
Posts: 46
Location: Fortaleza, Brazil
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:
Hibernate 3.2 cr4

Hi all, allow my code to explain:

Code:
   String strQuery = "select assetsScenarios "
             + "from Asset myasset "
              + "LEFT JOIN myasset.assetsScenarios assetsScenarios "
            + "WHERE myasset.id = :assetID "
            + "Order by assetsScenarios.includeScenario desc";

   Query query;
   query = getSession().createQuery(strQuery);
   query.setParameter("assetID", assetID);
   List <Assetscenario> scenarioList = query.list();
   Set<Assetscenario> assetsScenarios = new HashSet<Assetscenario>(0);
   Boolean wtf = assetsScenarios.addAll(scenarioList);
   logger.debug("WTF bool: " + wtf);


So I want to return a Set instead of List. The code works, except that the List follows the 'Order by' clause semantics, but the Set does not. The boolean shows true. Any ideas ?

Robert


Top
 Profile  
 
 Post subject:
PostPosted: Sun Oct 15, 2006 6:42 pm 
Beginner
Beginner

Joined: Wed Jan 25, 2006 10:18 am
Posts: 28
A Set is never ordered, you'd have to use a SortedSet instead if you absolutely need Set. I'd recommend you stick with List if you can.


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