Hi,
I would like to understand why the built-in Hibernate type "calendar"
does not persist the timezone along with the date and time. I can
understand why Locale isn't saved, but the timezone seems like a
requirement if a query wants the results ordered by the calendar
timestamp. Specifically, 2AM GMT is before 5AM PST for any given
day, but these would be ordered with 2AM before 5AM. This situation
should only come up if Hibernate is writing to the same database from
two different computers in different timezones, as I understand it.
The source code uses a SimpleDateFormat to get the timestamp string
to write to the DB, which assumes local timezone. So:
Computer 1, EST processes data from "2AM GMT to 8AM GMT" and
Computer 2, PST processes data from "8AM GMT to 2PM GMT", and
each writes their results to a shared DB. The data includes a persisted
Calendar that has the GMT timezone set and the timestamp of the
processed data. Computer 1's data will be saved in a timestamp range
from 9pm (the previous day) to 5am, and Computer 2's data will be
saved in a timestamp range from 12am to 6am. Needless to say, the
data will now be interleaved, according to the timestamp data, when
the original data was in two separate batches.
So...Yes, I can certainly make a subclass of Calendar and persist
it in such a way that my retrieved Calendar has the correct timezone
set *and* that the database timestamps are sortable, but I'm wondering
if this is an issue that is being discussed or is otherwise already known.
I didn't manage to come up with a search string that gave me any
relevent results in my Forum search...
Thanks,
-Jennifer Bevan
Hibernate version:
2.1.6
Mapping documents:
java.util.Calendar cal;
/**
@hibernate.property type="calendar"
*/
Name and version of the database you are using:
MySQL 4.1.X
|