-->
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: HQL and subqueries
PostPosted: Mon Feb 04, 2013 5:23 pm 
Newbie

Joined: Tue Sep 18, 2007 3:30 pm
Posts: 17
Hello,

I have a column invoiceNumber of var chars in the format like that:
\d+/\d+ or \d+, so it may be: 123/12, 12/234, 23,....

I would like to execute a HibernateTemplate's find with HQL query which will load a row with max invoiceNumber (but if '/' exists in the string the query should take only a substring before '/' char into the comparison).

I tried to use:
getHibernateTemplate().find("select max(substring(w.invoiceNumber from '^[0-9]+')) from Work w")
but I can see in the logs that it creates:
select max(substring(work0_.invoice_number, from, '^[0-9]+')) as col_0_0_ from works work0_

so of course it does not work. Any ideas how should I fix my HQL?

Kind regards,
Gandalf


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.