Hello,

I've finally had some time to have a closer look at your work. I can
confirm your assumptions and suspect the problem is here (and in
similar places):

>       catCond = dateDiff.le(new DayToSecond(0, 0, 90));

As I've mentioned before, jOOQ's interval data types aren't really
supported by other third-party libraries - including JDBC drivers.
They are a part of the jOOQ API, to be used for people that want to
express date time arithmetic in a SQL-like way. jOOQ then internally
takes care of transforming intervals into apropriate data types before
binding values.

In general, when it comes to interval data types, there is quite a bit
of trouble that you'll go through, when trying to stay interoperable
between databases. From what I've seen in your code, I think you
properly used the jOOQ API to create what you wanted, e.g. a predicate
checking if some timestamp difference is <= 90 seconds.

In fact, jOOQ should be smart enough to know that in the context of a
SQL Server timestampDiff function, the DayToSecond bind value should
be rendered as a millisecond long value. I will try to see what can be
done for this problem. It really should be resolved in jOOQ. I have
registered #2006 for this:
https://github.com/jOOQ/jOOQ/issues/2006

> What I understand is it could be the Sprint JDBCTemplate that has the issue
> and not JOOQ right?

It isn't Spring's fault that jOOQ leaks interval data types to JDBC
drivers / databases that do not support them.

As a workaround, you could do your calculations the other way round.
E.g. the two following predicates are logically equivalent:

timestampDiff(t1, t2).le(new DayToSecond(0, 0, 90));
timestampAdd(t1, new DayToSecond(0, 0, 90)).le(t2);

This will probably work, because the interval data type is correctly
bound as a long type to a SQL Server dateadd(ss, t1, :long_type)
function within the org.jooq.impl.Expression.DateExpression class

Please tell me if this workaround solves your problem right now. I'll
try to see if #2006 can be fixed, soon

Cheers
Lukas

Reply via email to