-->
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: Verifying how @OrderBy works
PostPosted: Wed Jul 06, 2005 11:01 pm 
Beginner
Beginner

Joined: Mon Mar 28, 2005 12:58 pm
Posts: 27
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: Annotations beta3 + Hibernate 3.0.5

Mapping documents:

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

Name and version of the database you are using:

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


I read the annotations documentation and wanted to make sure I understood it correctly. The @OrderBy will only work if the entity class that is of the collection does not reference any other tables. For example:

Code:
public class Gender
{
    public GenderType type;
    public Date cDate;
    public Person person;

    @ManyToOne
    public Person getPerson()
    {

    }

    @ManyToOne
    public GenderType getType()
    {

    }
}

public class Person
{
    public List<Gender> genders;

    @OneToMany(mappedBy = "person")
    @OrderBy("cDate asc")
    public List<Gender> getGenders()
    {
         ...
    }
}


The @OrderBy will have no effect because the Gender class has another GenderType association. Am I understanding this correctly? Thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jul 10, 2005 12:21 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
No, this is not what I tried to explained in the doc :-)

It will not work if you have
Code:
@ManyToMany
@JoinTable(table="blah")
public Collection<Child> ...

_________________
Emmanuel


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.