-->
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: Use function in HQL
PostPosted: Mon May 03, 2010 4:51 pm 
Newbie

Joined: Tue Mar 09, 2010 5:17 pm
Posts: 3
Say I create a function cal_diff(arg0 number, arg1 number) in Oracle 10g, could I use it in HQL?

for example in HQL: from Something t where t.someValue < cal_diff(t.val1, t.val2)

I am sorry if it's obviously covered in the documentation, though I can't find anywhere it talks about this capability. Any help would be appreciated. Thanks.


Top
 Profile  
 
 Post subject: Re: Use function in HQL
PostPosted: Tue May 04, 2010 2:11 am 
Expert
Expert

Joined: Wed Mar 03, 2004 6:35 am
Posts: 1240
Location: Lund, Sweden
It is possible to register other SQL functions with Hibernate and use them with HQL. As mentioned in http://docs.jboss.org/hibernate/stable/ ... -functions this is an area that needs improvement. The usual way to solve this is to subclass an existing Dialect implementation and add definitions for your extra functions there. It is not very difficult but is a bit messy if you need to support multiple databases.

Another approach (that I prefer) is to register the function using the Configuration.addSqlFunction() method.


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.