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: Concatenation problem
PostPosted: Tue Apr 03, 2007 10:27 am 
Newbie

Joined: Tue Jan 17, 2006 1:43 pm
Posts: 4
Location: Brussels, Belgium
Hello there,

we have a problem when we try to get the sum of a composite field of a mapped class. The composite field is a MonetaryAmount, containing an amount (Double) and a currency (String).
Since composite fields can not be 'summed', we have to use the DBMS functions such as DECiMAL or VARCHAR in order to concatenate the currency to the sum of amounts.
Apparently, Hibernate does not recognize those key words and throws exceptions (e.g. "undefined alias" or "( expected before )").
Although the equivalent SQL query works fine when accessing DB2 directly (using TOAD for DB2 or Squirel), we can't get through using HQL.
Does anybody know a workaround for our problem?
Thank you in advance.

Code:
select varchar(char(decimal(obj.value.amount,5,2),',')) || obj.value.currency
from MyObject as obj



Hibernate version: 2.1.7

Full stack trace of any exception that occurs:
1 errors occurred while listing (and calling getPathNames).
net.sf.hibernate.QueryException: ( expected before ) in select [select varchar(char(decimal(obj.value.amount,5,2),',')) || obj.value.currency
from MyObject as obj]

Name and version of the database you are using: IBM DB2 v8.2

The generated SQL (show_sql=true): none


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.