Fetch the column of type Date with date & time

230 views
Skip to first unread message

vijay.ra...@gmail.com

unread,
May 9, 2014, 6:04:29 AM5/9/14
to jooq...@googlegroups.com
My database is Oracle 11g. I have a table with a column of type DATE. While i select the rows from this table the date fields has date but with no time. What do I do to retrieve the date with time.

thanks
--Vijay

Lukas Eder

unread,
May 9, 2014, 12:33:17 PM5/9/14
to jooq...@googlegroups.com
Hi Vijay,

By default, jOOQ maps Oracle's DATE column to java.sql.Date and TIMESTAMP to java.sql.Timestamp.
If you want to use Oracle's historic DATE semantics (date-time with seconds precision), then you can have jOOQ generate java.sql.Timestamp columns also for DATE columns using the <dateAsTimestamp/> code generation flag:

  <!-- Generate java.sql.Timestamp fields for DATE columns. This is
       particularly useful for Oracle databases.
       Defaults to false -->
  <dateAsTimestamp>false</dateAsTimestamp>

Details here:

For the reference, I'll also post this as an answer to your Stack Overflow question:

Cheers
Lukas


--
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.

erle...@gmail.com

unread,
Feb 15, 2016, 6:43:56 AM2/15/16
to jOOQ User Group
As you now have deprecated the use of dateAsTimestamp, it is not so clear to me how to achieve the same effect using bindings only. I tried to create and use a binding (implementing Binding<Date, Timestamp>) similar to your org.jooq.impl.DateAsTimestampBinding, but this results in loosing the time component of the Oracle date. So as of now, I'm stuck with using the dateAsTimestamp flag.

(This reply (with a small edit) is also posted as a comment to http://stackoverflow.com/a/23569699/1282989.)

Lukas Eder

unread,
Feb 16, 2016, 10:11:44 AM2/16/16
to jooq...@googlegroups.com
Hi Erlend,

Thanks for your message. This deprecation was a bit unfortunate, because while it is possible to re-enact similar functionality via data type binding, the current situation is still a bit confusing - and it has confused many others as well.

I'm hoping that jOOQ 3.8 will bring answers to how to best create bindings for various date time data types, including TIMESTAMP WITH TIME ZONE (or TIMESTAMPTZ). Also, there should be out-of-the-box bindings for these cases. Until then, it is safe to continue using <dateAsTimestamp/>. "Deprecated" here means that we'll remove the flag in the future, but it is still supported.

If you have any additional, specific questions, let me know and I'm very happy to help.

I hope this helps (for now),
Lukas
Reply all
Reply to author
Forward
0 new messages