-->
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: Order by and formula
PostPosted: Sat May 05, 2007 3:54 pm 
Newbie

Joined: Fri Mar 23, 2007 7:39 pm
Posts: 11
Hi.
I am trying to learn more of Hibernate by trying to make some forum.

I have a Forum class, a Thread class and a Message class.

I would like the Forum to have a collection of threads that are ordered by the latest message date.

Code:
        <bag name="threads"
             cascade="save-update"
             inverse="true"
             order-by="?">
            <key column="THREAD_ID"/>
            <one-to-many class="Thread"/>
        </bag>


The problem is that I don't know what to put in the order-by, because the information has to come indirectly from messages and the association with threads.

I thought about making a formula to make a lastMessageDate in Thread. But this property does not have a column in the database, right? So how can I use it to order?

I also thought about making lastMessageDate a normal property and calculate the date in the Java code. But wouldn't that cause redundant information in the database?

What is the best way to map something like this?


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 07, 2007 2:51 pm 
Newbie

Joined: Fri Mar 23, 2007 7:39 pm
Posts: 11
Please... any help is really appreciated.
Also if my question is not clear enough or you need more information please ask me too.


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.