Ora2Pg Migration – @Temporal(TemporalType.DATE)

Both Oracle and PostgreSQL supports Date as the data type. However there is a difference, In oracle date includes timestamp and in case of PostgreSQL it gives only date omitting timestamp. It is mainly because PostgreSQL has we have another data type called “Timestamp”.

Having said that, If you are using JPA annotation @Temporal in your program with TemporalType.Date keeping Oracle behaviour in mind, it will create problem after migrating to PostgreSQL.

 @Temporal(TemporalType.DATE)
 @Column(name = "UPDATE_TIME", length = 7)
 public Date getUpdateTime() {
     return data == null ? getCachedValue(Date.class, 6) : data.update_time;
 }

The fix is to use “TemporalType.TIMESTAMP”.

Happy Migration !

Leave a Reply

Your email address will not be published.

WP2Social Auto Publish Powered By : XYZScripts.com