The createdAt field is always coming back null. The problem comes when I fetch data using my Entity class for this table. JDBC Driver (include name if inofficial driver): org.postgresql:postgresql:42.2. I created a table with a createdat column, of type: timestamp without time zone.(Note that I use JOOQ to generate jpa native queries.) Versions Steps to reproduce the problemĬreate jooq query with LocalDateTime param.Ĭreate jpa native query from the jooq query, and set parameters directly from jooq query.Įxecuting the above two queries give two different results. Trying to convert a jooq query into a jpa native query results in a different query (only works with UTC timezone). Jooq query is not compatible with hibernate native query. ,is used to transform to UTC before sending to db: Now at the database level, I am storing a pure UTC value. Stick to using objects rather than strings for date-time values whenever possible. ts myResultSet.getTimestamp( 1 ) No need for strings. LocalDateTime is transformed to Timestamp containing TimeZone.getDefaultRef() timezone In postgresql, I will use a timestamp without timezone column In my scala (similiar to java) code, I will generate a timestamp like: val currentMs: Long System.currentTimeMillis new (currentMs) I will save that value to the database. object for you when retrieving a value from either of Postgres’ time stamp types, TIMESTAMP WITH TIME ZONE and TIMESTAMP WITHOUT TIME ZONE. In hibernate, the LocalDateTime is transformed from current time zone to utc, then passed to db: In jooq LocalDateTime param is passed as-is to db.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |