Sleeping dialect + dated function

My problem is that the syntax for the datiff in mysql is different from the syntax in hsqldb:

mysql: datediff(date1,date2) hsqldb: datediff(interval,date1,date2) 

Dialects in sleep mode usually resolve these problems, however, I seem to be unable to find a way to create a dating restriction for sleep mode. This is a real nuisance because it prevents me from testing the unit using the hsql database in memory, since I have to β€œhard code” the datiff format in the sql statement.

If anyone has any advice on this, we will be very grateful.

+2
source share
1 answer

I would say that the easiest solution is to create your own custom HSQLDB dialect that extends the existing HSQLDB dialogs. Then, in the constructor, register a function for processing the datiff (date1, date2), which will be converted to dated (interval, date1, date2), provided that the interval is a static value. Something like that:

 registerFunction( "datediff", new SQLFunctionTemplate( StandardBasicTypes.INTEGER, "datediff(interval, ?1, ?2)" ) ); 
+4
source

All Articles