-->
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.  [ 3 posts ] 
Author Message
 Post subject: Problem with ordering of collections
PostPosted: Thu Mar 01, 2007 4:54 am 
Newbie

Joined: Wed May 04, 2005 9:34 am
Posts: 16
Location: Germany
Hi,

i have a problem with the ordering of a collection that i canĀ“t solve myself. I have two objects with a many-to-many relationship. In one of this objects i mapped this relationship unidirectional with hibernate annotations like this:

Code:
    @ManyToMany(cascade={CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH},
       targetEntity=BasiszeitraumDOM.class, fetch=FetchType.EAGER)
    @JoinTable(name="S_Basiszeitverknuepfungen", joinColumns={@JoinColumn(name="bzv_bt")},
        inverseJoinColumns={@JoinColumn(name="bzv_bzt")})
   @OrderBy("name")
   public Set<IBasiszeitraumDOM> getZeitraeume() {
      return zeitraeume;
   }


The two objects related are BasistabelleDOM and BasiszeitraumDOM connected via the table "S_Basiszeitraumverknuepfungen".

The mapping works, the records from BasistabellenDOM together with those from BasiszeitraumDOm are loaded via the following sql:

Code:
select this_.bt_nr as bt1_12_2_, this_.bt_name as bt2_12_2_, this_.bt_aus_version as bt3_12_2_, this_.bt_abfrage_name as bt4_12_2_, this_.bt_abfrage_komm as bt5_12_2_, this_.bt_abfrage_sql as bt6_12_2_, this_.bt_abfrage_nr as bt7_12_2_, this_.bt_gg1 as bt8_12_2_, this_.bt_gg2 as bt9_12_2_, this_.bt_gg3 as bt10_12_2_, this_.bt_gg4 as bt11_12_2_, this_.bt_gg5 as bt12_12_2_, this_.bt_gg6 as bt13_12_2_, this_.bt_gg7 as bt14_12_2_, this_.bt_gg8 as bt15_12_2_, this_.bt_zf as bt20_12_2_, this_.bt_abschlussfilter as bt16_12_2_, this_.bt_datum as bt17_12_2_, this_.bt_zeit as bt18_12_2_, this_.bt_guid as bt19_12_2_, basiszeitf2_.zf_nr as zf1_10_0_, basiszeitf2_.zf_name as zf2_10_0_, basiszeitf2_.zf_komm as zf3_10_0_, basiszeitf2_.zf_sql1 as zf4_10_0_, basiszeitf2_.zf_sql2 as zf5_10_0_, basiszeitf2_.zf_sql3 as zf6_10_0_, basiszeitf2_.zf_sql4 as zf7_10_0_, basiszeitf2_.zf_sql5 as zf8_10_0_, basiszeitf2_.zf_sql6 as zf9_10_0_, basiszeitf2_.zf_sql7 as zf10_10_0_, basiszeitf2_.zf_sql8 as zf11_10_0_, zeitraeume3_.bzv_bt as bzv1_4_, basiszeitr4_.bzt_nr as bzv2_4_, basiszeitr4_.bzt_nr as bzt1_11_1_, basiszeitr4_.bzt_name as bzt2_11_1_, basiszeitr4_.bzt_von as bzt3_11_1_, basiszeitr4_.bzt_bis as bzt4_11_1_ from S_Basistabellen this_ left outer join S_Basiszeitfilter basiszeitf2_ on this_.bt_zf=basiszeitf2_.zf_nr left outer join S_Basiszeitverknuepfungen zeitraeume3_ on this_.bt_nr=zeitraeume3_.bzv_bt left outer join S_Basiszeitraeume basiszeitr4_ on zeitraeume3_.bzv_bzt=basiszeitr4_.bzt_nr where this_.bt_nr = ? order by basiszeitr4_.bzt_name asc


Although there is an order-statement at the end, the collection of BasiszeitraumDOM-objects in the BasistabelleDOM-Object is not ordered.

What am i doing wrong?

Thanks for any help.
Christoph

Hibernate version:
Hibernate 3.2.1
Hibernate Annotations 3.2 GA

Name and version of the database you are using:
Microsoft SQL-Server 7.0


Top
 Profile  
 
 Post subject: Set is an unordered collection
PostPosted: Thu Mar 01, 2007 5:01 am 
Newbie

Joined: Mon Feb 19, 2007 12:54 am
Posts: 16
Location: banglore, india
Hi,

U r putting the result in set. Set is not a ordered collection. U can t predict the order.
If u want order user List.

_________________
Banglore Developer


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 01, 2007 5:29 am 
Newbie

Joined: Wed May 04, 2005 9:34 am
Posts: 16
Location: Germany
thanks very much. That was it!


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