--
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 jooq-user+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Hi Lukas,
Thanks for the heads up. I can appreciate that the subject of date
handling is very tricky to get right at a generic library level to
suit all use cases. I'm struggling enough with dates in just one app,
let alone any arbitrary app :-)
I've already run into the issue of the timezone of the JVM app -
previously I had a JOOQ Timestamp <-> ZonedDateTime Converter, but
discovered that the resultant Timestamp was in the JVM timezone, i.e.
the conversion was lossy and dependent on the JVM setting. I'd prefer
the code base to be independent of the JVM time zone, since relying on
a bug-free JVM setting is asking for trouble IMHO.
So TIMESTAMPZ is the way to go - what is the advantage of this type?
BTW I think I'm still struggling with the match specification for the
forced type in the code generator. Previously I started a thread about
this with regard to NUMBER(19) and how to debug this, which I have
deferred up until now, but now I think I'll have to bite the bullet. I
think that forced type handling code is an util class that is not
ordinarily on the project classpath (because it is compiler-related
code?).
My initial implementation of this involved the following custom binding:
@Override
public void set(BindingSetStatementContext<ZonedDateTime> ctx) throws
SQLException {
ctx.statement().setTimestamp(ctx.index(), converter.to(ctx.value()), UTC);
}
whereby
public static final Calendar UTC =
Calendar.getInstance(TimeZone.getTimeZone("UTC"));
This appears to insert timestamps into TIMESTAMP(6) columns in UTC
(i.e. the default timestamp type in Oracle).
I'm assuming that the storage of all timestamps in the DB is going to
be in UTC and therefore I don't need to use the TIMESTAMP WITH TIME
ZONE type. Any translation into a non-UTC TZ would have to either be
coded into a query or converted by the app.
The main motivation behind this that I've read (on the internet, hence
it must be true) that there are indexing limitations with the
TIMESTAMP WITH TIME ZONE type.
java.time.format.DateTimeParseException: Text '2014-04-01T10:11:10.15
+0:00' could not be parsed at index 22
at java.time.format.DateTimeFormatter.parseResolved0(DateTimeFormatter.java:1949)
at java.time.format.DateTimeFormatter.parse(DateTimeFormatter.java:1851)
at java.time.OffsetDateTime.parse(OffsetDateTime.java:402)
at java.time.OffsetDateTime.parse(OffsetDateTime.java:387)
at org.jooq.impl.DefaultBinding.offsetDateTime(DefaultBinding.java:1496)
at org.jooq.impl.DefaultBinding.get(DefaultBinding.java:1336)
at org.jooq.impl.CursorImpl$CursorIterator$CursorRecordInitialiser.setValue(CursorImpl.java:1640)
On Thu, Jan 21, 2016 at 3:26 PM, Lukas Eder <lukas...@gmail.com> wrote:
> The issue here seems to be related to the fact that the offset is of the
> form +0:00 rather than +00:00. It's a shame that JSR 310 parsing is so
> strict, but we can certainly work around this issue in jOOQ. I have
> registered #4965 for this:
> https://github.com/jOOQ/jOOQ/issues/4965
If I tried tried to calculate the percentage of my career that I've
spent fixing time zone issues, that code itself would most likely have
a date/time arithmetic bug in it :-(
> Thanks again for reporting all of these things. I wish jOOQ could already
> offer more out-of-the-box help here with these data types. It shouldn't be
> so hard to integrate them as it is, right now.
I think the holy grail API-wise would be to have a greater ability to
tweak/override the default bindings when one comes across this kind of
thing. That said, I not sure what the right API design should be. If
you expose stuff such that people can subclass default
implementations, I can imagine that you will find yourself having to
break more apps as you evolve the default libraries. Tricky.
On Thu, Jan 28, 2016 at 5:07 PM, Lukas Eder <lukas...@gmail.com> wrote:
> 2016-01-26 19:49 GMT+01:00 Ben Hood <0x6e...@gmail.com>:
> Same here. :) The weirdest bug I've ever encountered was a single missing
> bank account transaction for only a single customer in only a single
> E-Document, and only on October 31, 2010. Turns out that transactions were
> searched using the following predicate (pseudo code):
>
> TRANSACTION_DATE BETWEEN TRUNC(beginning of month) AND TRUNC(end of
> month + 24 * 60 * 60 * 1000 milliseconds)
>
> Turns out that in Switzerland, 2010-10-31 had 25 hours (daylight savings
> time), and because it's a Sunday, no one noticed as there are hardly any
> bank account transactions on Sundays :)
Do you think that Block Chain DBs can handle DST? And if so, when is
JOOQ going to bind to them?
> You're right. The DefaultBinding inherited a bit of legacy. Its procedural
> if-else blocks are also a performance issue. The method is too large to be
> inlined by the JIT, plus after a couple of branches, if-else tends to be
> slower than dynamic dispatch (https://github.com/jOOQ/jOOQ/issues/4930).
Interestingly enough, I was speaking to one of the Scala compiler guys
years ago who was telling me that polymorphic dispatch was implemented
quite efficiently in the JVM.