-->
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: TRIM function in @Formula not working
PostPosted: Tue Jun 25, 2013 4:05 am 
Newbie

Joined: Tue Jun 25, 2013 3:44 am
Posts: 1
Hi. I'm trying to make a formula to select a user-friendly name of the user profile.
Code:
@Formula("COALESCE(NULLIF(TRIM(BOTH FROM CONCAT(sp.firstname, ' ', sp.lastname)), ''), p.shortname, to_char(p.id, 'FM9999999999999999')) " +
   "FROM socialprofile AS sp " +
   "JOIN profile AS p ON sp.id=p.id")
   public String getUserFriendlyName() {
      return super.getUserFriendlyName();
   }

The result is:
"org.hibernate.HibernateException: Unexpected number of trim function operands : 10"
but there is only 3 arguments: BOTH, FROM and result of CONCAT. Is there any workaround of this issue?
Upd: DB is PostgreSQL, Hibernate version is 4.2.1


Top
 Profile  
 
 Post subject: Re: TRIM function in @Formula not working
PostPosted: Wed Jul 10, 2013 7:02 am 
Newbie

Joined: Wed Nov 12, 2008 2:14 am
Posts: 6
Hi I have the same problem.
In org.hibernate.sql.Template.renderWhereStringTemplate()
in line
TrimOperands trimOperands = new TrimOperands( operands );
constructor TrimOperands expects only 1-4 operands, else Unexpected number of trim function operands is throw.
In your case, there are 10 operands: BOTH, , CONCAT usw.

I dont understand why this is.

see https://hibernate.atlassian.net/browse/HHH-5970
Any hint? Or I have to create my user PLSQL function for trim?


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.