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.

 @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 !

WP2Social Auto Publish Powered By : XYZScripts.com