-->
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.  [ 3 posts ] 
Author Message
 Post subject: HQL Order By Problem on Composite datatype
PostPosted: Wed Sep 27, 2006 2:57 pm 
Beginner
Beginner

Joined: Wed Jul 14, 2004 11:51 am
Posts: 43
Hibernate version: 3.1

Hello,

I am having problems with an order by statement on a composite datatype.

My composite datatype is Money (which has a Double and a Currency). My HQL query is

Code:
"select from Item as item order by item.price desc"


(price being my composite datatype)

Here is the abbreviated generated sql (with Oracle9iDialect):

Code:
select ....
from ....
where ...
order by item_.PRICE_AMOUNT, item_.PRICE_CURRENCY desc

When it should be:
Code:
select ....
from ....
where ...
order by item_.PRICE_AMOUNT desc, item_.PRICE_CURRENCY desc



The difference being that the "desc" is only applied to the second attribute of my composite datatype. I would want the desc to be on the amount and on the currency.

Anybody ever encounter this problem? If there is a workaround or if it can be easily modified in the dialect or in the code? If so, please give me some cues as to where to start.

Thank you,

François


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 28, 2006 1:24 am 
Regular
Regular

Joined: Tue May 16, 2006 3:32 am
Posts: 117
Try

Code:
"... as item order by item.price.priceAmount desc, item.price.priceCurrency desc"


Use the right variable names in place of priceAmount & priceCurrency.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 28, 2006 11:27 am 
Beginner
Beginner

Joined: Wed Jul 14, 2004 11:51 am
Posts: 43
Great! That works fine. I didn't think I could access the inner properties of my composite type.

Thanks,

François


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