-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Timestamp UserType with a non-static TimeZone?
PostPosted: Thu Jul 10, 2008 10:19 am 
Newbie

Joined: Thu Jul 10, 2008 9:42 am
Posts: 4
I'm researching how to handle time zones with JPA backed by Hibernate. Unfortunately our schema does not dictate that all date/time values are stored in UTC, so on the back-end alone (disregarding display), we need to be able to pass the TimeZone down dynamically based on the current back-end being written to. I won't enumerate all of the details here, but bottom line, we need to be able to pass the TimeZone down on every query if needed.

I found http://www.hibernate.org/100.html , which is a good start, but all of the code snippets there and the general solution entail statically determining a TimeZone.

Using ParameterizedType with a time zone parameter is still static as I have to define the TimeZone in the declaration of entities.

From what I can tell, my best bet is to have a component that dynamically determines the active back-end, and its TimeZone at runtime to pass into getTimestamp(String, Calendar) and setTimestamp(int,Timestamp,Calendar). I could either access this component directly from the UserType code, or I could hide it behind an interface and pass a provider class-name in with a ParameterizedType.

What would be ideal, is if I could *explicitly* pass in the time-zone when I am creating, parameterizing, and executing a Query. For example, perhaps there is a way to access query hints in a UserType and I could define my own Query hint? It could be called something like "mycompany.timezone" and be ignored by hibernate.

Any thoughts or ideas? Thanks ahead of time for any help.

Updated: Removed rogue comma from link.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.