Reputation: 7491
I have the following mapping for the birth date in the hbm.xml file
<property name="birthDate" type="date">
<column name="birth_date" length="4" />
</property>>
The name/type of the column in the Postgresql database are:
birth_date|date
Once in a while the date is inserted incorrectly – it is about 0.03% cases, the result is a strange date, i.e. a 2456 year
What can be a reason? I suspect the column length of 4 in the hbm.xml file maybe not enough – not sure.
The hibernate version is 3.1
Upvotes: 1
Views: 1032
Reputation: 7491
I was incorrect blaming the problem on Hibernate. The problem was in SimpleDateFormat. Someone before me specified a static class object of this class. In the multithreaded environment this resulted in incorrect Date formatting before using by Hibernate
Upvotes: 0
Reputation: 11829
If you are new to hibernate, Keep the declarations as simple as possible. So, if you want to add a Date
Object in the mapping use the below code.
In the maaping file,
<property column="CREATED_DATE" name="createdDate" />
In java class,
java.lang.util.Date createdDate
//getters & setters
Once it is stable and working, you can start playing around with more options in the mapping.
Upvotes: 1