Hi,
Just a bit of background so I don't get bombarded with questions about WHY I want to do what I am doing.
We have a Flex application communicating to a Java (GraniteDS) back end. Flex/AMF3 serializes Dates as just a number that represents UTC milliseconds from the epoch with NO time zone component so both Flex and Java assume local time zone for all Dates. In cases where you are only interested in the date, this causes problems; Flex and Java attempt to adjust based on their respective time zones, frequently resulting in the date being inadvertently changed. For example, if you send 3/1/2011 with no time component (defaults to 00:00:00) from a Flex client in the UK back to a Java server in EST, it subtracts hours and ends up storing the data as 2/28/2011 instead. As a workaround, we need to send the dates over the wire as strings, to bypass Flex's insistence on performing these unwanted Date adjustments.
So ... my question ...
I have a String instance variable on my entity class and I want to map it to a DATE column in Oracle. The problem is that when I do queries, Hibernate selects the format 'YYYY-MM-DD HH:MI:SS' to return the string, but if I try to save the same object back, it simply tries to insert a string in that format, which of course fails because the Oracle default is 'DD-MON-YY'.
Is there any way short of defining my own custom type to force Hibernate to use the same 'DD-MON-YY' format when it selects the DATE column into a String? It seems to me that the mapping should at least be symmetrical ... i.e. if you query the object in Hibernate without error, you should be able to update/insert the same object ... but that is not what I am observing.
|