-->
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: Formulas / HQL / custom functions
PostPosted: Fri Nov 21, 2008 1:17 pm 
Beginner
Beginner

Joined: Thu Apr 12, 2007 3:26 am
Posts: 35
Location: Germany
Hibernate version: The newest hibernate 3 version.

For my current project, I'm considering using formulas for the runtime computation of some statistical attribute values, because I need them in some of my queries - until it turns out that this runtime-computation is too slow, we don't want to compute them in a job and store them in the db.

As far as I know, only normal SQL can be used in formulas. Because our production database is MySql and our testing database is HsqlDB, I can only use Standard SQL, because otherwise the query formula couldn't be tested. Unfortunately, the standard SQL statements aren't enough for my purposes - I need some advanced date functions like startOfMonth(Date) endOfMonth(Date), because I have to compute the data per month.

Is my information wrong and is it possible to use HQL (or at least HQL functions) in formulas?
If not, is it possible to define custom startOfMonth and endOfMonth functions in Hibernate which can be used in native SQL statements? With custom functions (classes which extend StandardSqlFunction) it is possible to create own HQL functions. Further it is possible to implement them differently for different vendors. If such a custom function (or a normal hql function) could be used in native Sql statements (what formulas are), I could define different startOFMonth and endOfMonth functions for MySql and Hsqldb and my problems would be solved. Does anybody now if this is possible?

Does anybody know another solution for my problem?

Regards
Hoeft


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.