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
|