Search code examples
hibernatepostgresqldatehbm

Insertion of date by hibernate in Postgresql


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


Solution

  • 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