I'm getting a parse error when parsing a date from a XML file. I'm using entitymode.dom4j to load tables. The mapping file specify a date type. If i change it for string, no error is generated.
Code:
Hibernate: insert into agegroup (lowend, highend, name) values (?, ?, ?)
<Period id="1">
<startdate>2005-5-5</startdate>
<enddate/>
<name>High Season</name>
</Period>
Exception in thread "main" org.hibernate.HibernateException: could not parse XML
at org.hibernate.type.DateType.fromStringValue(DateType.java:95)
at org.hibernate.type.CalendarDateType.fromStringValue(CalendarDateType.java:54)
at org.hibernate.type.NullableType.fromXMLString(NullableType.java:102)
at org.hibernate.type.NullableType.fromXMLNode(NullableType.java:126)
at org.hibernate.property.Dom4jAccessor$ElementGetter.get(Dom4jAccessor.java:192)
at org.hibernate.property.Dom4jAccessor$Dom4jGetter.getForInsert(Dom4jAccessor.java:93)
at org.hibernate.tuple.AbstractTuplizer.getPropertyValuesToInsert(AbstractTuplizer.java:189)
at org.hibernate.persister.entity.BasicEntityPersister.getPropertyValuesToInsert(BasicEntityPersister.java:3005)
at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:216)
at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:160)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:95)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:184)
at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:33)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:173)
at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:27)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:69)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:481)
at com.optionaltours.util.TourLoader.recurLoadXml(TourLoader.java:74)
at com.optionaltours.util.TourLoader.recurLoadXml(TourLoader.java:71)
at com.optionaltours.util.TourLoader.loadDatabaseFromXml(TourLoader.java:56)
at com.optionaltours.util.TourLoader.main(TourLoader.java:33)
Caused by: java.text.ParseException: Unparseable date: "2005-5-5"
at java.text.DateFormat.parse(DateFormat.java:335)
at org.hibernate.type.DateType.fromStringValue(DateType.java:92)
... 20 more