Monday, March 21, 2016

Timestamps in EJB 3.0

While upgrading our Rational Software Architect Designer (Eclipse) several issues came up during the Workplace Migration process. One issue was related to the use of the @Temporal annotation. The issue only showed up because the version of RSAD that we were upgrading to had a more advanced validation for EJBs. Before I go into details on the problem, I want to point out this excellent article on the use of date, time, and timestamp in EJB3 JPA: http://www.developerscrappad.com/228/java/java-ee/ejb3-jpa-dealing-with-date-time-and-timestamp/

That should clear up why the following piece of code, which showed up in 66 similar instances, triggered errors:

@Temporal(TemporalType.TIMESTAMP)
private Timestamp adjrCreationDtim;

The simple solution was to remove the @Temporal annotations from Timestamp fields.