Open LumnitzF opened 6 years ago
Do you use this in your application or is this simply for completeness? If you use it in your application would you mind sharing your use case?
Which JPA provider are you using?
In our application, we are currently storing times only as local times. In the future we want to migrate to times with time-zone information. So it is possible that we will change to the TIMESTAMPLTZ
and then the backend has to support it...
So it's part for completness and part for real use case.
I am using EclipseLink 2.6.4
Can you elaborate why you would prefer TIMESTAMPLZ
over TIMESTAMPTZ
?
The TIMESTAMPLTZ
supports an automated conversion into the time zone of the session. When an application has many users from all over the world, and you don't want to do the conversion in the back- or frontend, you can set the correct timezone in the session, and let the database do the conversion for you.
So in my opinion, I would prefare TIMESTAMPLTZ
only, when I always want the time to be in the timezone of the session, without having to check or convert it in my application
When an application has many users from all over the world, and you don't want to do the conversion in the back- or frontend
Can you expand on why you don't want to have this happen in the back- or frontend?
supports an automated conversion into the time zone of the session
Of the database session. (Assuming you have a server application) When a request comes in you have to change the time zone of the database session to the time zone of the user before making and database calls. Also you have to be careful that you don't store or cache objects across different sessions, (eg. JPA second-level cache).
I'm not saying you're wrong. I'm just curious about your use case.
As I already said, at the moment I don't really have a use case. However I may have to support this type in the future, so it may be good to support it for completeness
Oracle also supports the
TIMESTAMP WITH LOCAL TIME ZONE
, where the database stores the time normalized to the database timezone. Upon querying, the time is converted into the session timezone of the query. --> The Java Attribute could either be ofLocalDateTime
(this can be read directly from theoracle.sql.TIMESTAMPLTZ
object) or of Offset-/ZonedDateTime (this would require to read the timezone information out of the session)Please note, that EclipseLink also uses a
TIMESTAMPLTZWrapper
which leads to a similiar issue as #23