-->
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.  [ 1 post ] 
Author Message
 Post subject: Ordering a set. A complex case
PostPosted: Thu Nov 12, 2009 7:51 am 
Beginner
Beginner

Joined: Tue Oct 30, 2007 7:57 am
Posts: 47
I have the following mapping in hibernate 3.2.6:

Code:
<class name="Persona" table="TBMHABPERSONA">
     ... more properties ...
   <set name="cursosPersona" lazy="true" fetch="select" inverse="true" order-by="ANIOFINALIZACION ASC">
          <key column="IDPERSONA" />
          <one-to-many class="CursoPersona" />
   </set>
</class>

<class name="CursoPersona" table="TBRHABCURSOPERSONA">
     ...more properties...
     <property name="anioCurso" column="ANIOFINALIZACION" type="string" not-null="true" />
     <many-to-one name="curso" column="IDCURSO" lazy="proxy" not-null="true" class="Curso" />
</class>

<class name="Curso" table="TBMHABCURSO">
     ...more properties...
     <property name="descripcion" column="DECURSO" type="string" length="200" not-null="true" /> 
</class>



So, I have an entity called Persona. Each one has several CursoPersona, and each CursoPersona relates to an entity of type Curso. CursoPersona is an entity that relates Persona and Curso, but it contains some extra data, so I can't use a Many-to-many relationship.

The set "cursosPersona" in the entity Persona, is ordered by column ANIOFINALIZACION, which is in CursoPersona. That's easy, because I order by a field that is on the table referenced by the set

But I'd like to add an extra ordering token using column DECURSO, which is on the entity Curso. How can I do that?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.