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