2015-06-18 21:38 GMT+02:00 Garret Wilson <[email protected]>:
> On 6/18/2015 12:04 PM, Lukas Eder wrote:
>
>> ...
>> It will if you're using TIMESTAMP WITH TIME ZONE.
>> It won't if you're using TIMESTAMP (WITHOUT TIME ZONE)
>>
>> However, the linked issue (https://github.com/jOOQ/jOOQ/issues/2738)
>> still prevails, as jOOQ currently doesn't explicitly support TIMESTAMP WITH
>> TIME ZONE, thus inlining the timestamp (without timezone) will again
>> produce wrong results, no matter what data type you're using.
>>
>
> What do you mean by "inlining"?
>
> I searched online, and you have something called DSL.inline().
Yes, that's what I meant. DSL.inline() forces a single bind variable to be
inlined every time. There are also other ways to force bind variables to be
inlined, e.g. by using StatementType.STATIC_STATEMENT on Settings.
So are you saying that if I use get/set on a record (which is what I care
> about right now), I'm fine? (I guess I didn't realize that "inlining" is
> something different.)
jOOQ doesn't officially support TIMESTAMP WITH TIME ZONE. jOOQ internally
does the following:
try (PreparedStatement ps = c.prepareStatement(
"select"
+ " ?::timestamp," // (the cast is necessary, syntactically in some
situations)
+ " ?::timestamp,"
+ " ?::timestamp with time zone,"
+ " ?::timestamp with time zone"
)) {
ps.setTimestamp(1, new Timestamp(0));
ps.setTimestamp(2, new Timestamp(0),
Calendar.getInstance(TimeZone.getTimeZone("UTC")));
ps.setTimestamp(3, new Timestamp(0));
ps.setTimestamp(4, new Timestamp(0),
Calendar.getInstance(TimeZone.getTimeZone("UTC")));
try (ResultSet rs = ps.executeQuery()) {
rs.next();
System.out.println(rs.getTimestamp(1) + " / " +
rs.getTimestamp(1).getTime());
System.out.println(rs.getTimestamp(2,
Calendar.getInstance(TimeZone.getTimeZone("UTC")))
+ " / " + rs.getTimestamp(2,
Calendar.getInstance(TimeZone.getTimeZone("UTC"))).getTime());
System.out.println(rs.getTimestamp(3) + " / " +
rs.getTimestamp(3).getTime());
System.out.println(rs.getTimestamp(4,
Calendar.getInstance(TimeZone.getTimeZone("UTC")))
+ " / " + rs.getTimestamp(4,
Calendar.getInstance(TimeZone.getTimeZone("UTC"))).getTime());
}
}
As you can see, jOOQ (like JDBC) will take your timestamp / instant, and
store it in your local timezone. Which is correct (thie timestamp is
preserved), but not necessarily what you wanted in the first place (the
time zone is that of your machine's configuration). Perhaps you wanted to
store the timestamp / instance in UTC.
Does jOOQ get/set on a record correctly use TIMESTAMP WITH TIME ZONE?
jOOQ doesn't officially support TIMESTAMP WITH TIME ZONE, so again. Please
implement your own Binding to be sure.
--
You received this message because you are subscribed to the Google Groups "jOOQ
User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.