Hi,
I am mapping XML element to database. Facing problem in persisting date property. In XML String date is coming in the format 'yyyy-MM-ddTHH:mm:ss.SSSz'. My POJO and XDoclet for timestamp is as follows:
/**
* @hibernate.property properties-name="UNIQUE_EVENT_KEY" type="java.util.Date" not-null="false" column="SERVERTIMESTAMP" node="SERVERTIME"
*/
public Date getEventTime() {
return eventTime;
}
[b]Hibernate has org.hibernate.type.TimestampType class whic has hardcoded time format as yy-MM-dd HH:mm:ss. So if my XML has this format it works else give parse exception. Is there is way to provide date format ?[/b]
[b]Source Code from TimestampType[/b]
/**
* <tt>timestamp</tt>: A type that maps an SQL TIMESTAMP to a Java
* java.util.Date or java.sql.Timestamp.
* @author Gavin King
*/
public class TimestampType extends MutableType implements VersionType, LiteralType {
private static final String TIMESTAMP_FORMAT = "yyyy-MM-dd HH:mm:ss";
[b]Exception:[/b]
could not parse XML; nested exception is org.hibernate.HibernateException: could not parse XML
org.hibernate.HibernateException: could not parse XML
at org.hibernate.type.TimestampType.fromStringValue(TimestampType.java:124)
at org.hibernate.type.NullableType.fromXMLString(NullableType.java:102)
at org.hibernate.type.NullableType.fromXMLNode(NullableType.java:126)
|