-->
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.  [ 5 posts ] 
Author Message
 Post subject: HQL query: order by a not mapped property...?
PostPosted: Wed May 31, 2006 1:15 pm 
Newbie

Joined: Wed May 31, 2006 12:58 pm
Posts: 14
Hi all!

I have the following problem: There is a domain model class and some properties of it are mapped to the columns in a database table. This class has some business properties (BP), which are not persistent, but can be calculated upon a request from the persistent properties (PP), e.g. let's say that property BP1 = PP1 - PP2 - PP3.

I need to create a HQL query such that the result would be ordered by a business property. But I can't just write "...order by <ClassName>.BP1" as the property BP1 is not mapped to any database column...

What I think about is to create a CompositeUserType for the property BP1, which is mapped to the columns corresponding to PP1, PP2 and PP3. Will I be able to perform ordering in this case? May the same column from a database table be mapped with a build-in type to some class property (e.g. to PP1) and be mapped with a composite type as a part of another property (e.g. of BP1) at the same time?

Many thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 31, 2006 2:04 pm 
Beginner
Beginner

Joined: Tue May 02, 2006 10:04 am
Posts: 29
You can define a property with a formula:

Code:
<propery name="BP" type="..." formula="select p1+p2 from tbl where ...."/>


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 31, 2006 2:05 pm 
Beginner
Beginner

Joined: Tue May 02, 2006 10:04 am
Posts: 29
You can define a property with a formula:

Code:
<propery name="BP" type="..." formula="select p1+p2 from tbl where ...."/>


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 31, 2006 2:07 pm 
Beginner
Beginner

Joined: Tue May 02, 2006 10:04 am
Posts: 29
You can define a property with a formula:

Code:
<propery name="BP" type="..." formula="select p1+p2 from tbl where ...."/>


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 31, 2006 2:08 pm 
Beginner
Beginner

Joined: Tue May 02, 2006 10:04 am
Posts: 29
You can define a property with a formula:

Code:
<propery name="BP" type="..." formula="select p1+p2 from tbl where ...."/>


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