How can I instruct Hibernate to map a Java date to and from an Oracle DATE column using a time zone other than the local time zone?
2 Answers
I'm not sure but I think that you'll have to use the OracleConnection.setSessionTimeZone(String regionName) method to set the session time zone.
To do that on the OracleConnection before having Hibernate dealing with it, the cleanest way would be to provide and use a custom implementation of o.h.c.ConnectionProvider.
See this related question.
9 Comments
TIMESTAMP WITH TIME ZOME and does not recognize TIMESTAMP literals that include a time zone. So, time zone interpretation must be entirely dependent on JDBC driver implementation!Hibernate does not allow for specifying time zones by annotation or any other means. If you use Calendar instead of date, you can implement a workaround using HIbernate property AccessType and implementing the mapping yourself. The more advanced solution is to implement a custom UserType to map your Date or Calendar. Both solutions are explained in this blog post: http://dev-metal.blogspot.com/2010/11/mapping-dates-and-time-zones-with.html