Reputation: 1271
We are using a source link to include generated hibernate beans in a j2ee web project in eclipse. We have an included project that includes various utilities and services and such off the main project.
When we import our beans into the utility project, the bean import fine. They have hibernate 4.3 in them and the hibernate-jpa 2.1 jar. BUT, when I import the same model beans into the main project instead the @Version annotation gets compile errors. It says :
JSR 220: Java Persistence API, 9.1.17: Only the following types are supported for version properties: int, Integer, short, Short, long, Long, Timestamp.
The code is:
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "UPDT_TMSTMP", nullable = false)
@Version
private Date updateTimestamp;
Which as I said, works perfectly when imported to a simple java project, but when imported into a web module (we tried a couple) it gets this error. The error text seems to be saying that we can't use java.util.Date for the property type, but again, we used it before, when imported into utility projects.
We are at a loss to explain why the difference between utility project vs web module. We kind of want it in the web module because we want to be able to move these utility modules around without importing the same model beans multiple times.
Any ideas? Even avenues of investigation would be better than what we have now. We're striking out.
Upvotes: 1
Views: 351
Reputation: 2026
Please use Timestamp. Some countrys have a DST (from my pov a stupid idea). In this countrys the Date can exists, can be duplicate or never exists. A Timestamp has no such exceptions and is much better as a SSOT.
BTW: If you have a moving server(in plane or car or submarine, who may changing the timezone somedays) a localized TimestampZ might be better.
Upvotes: 2