Reputation: 9745
I need to persist a time duration e.g. 5 d 4 h
I was thinking of using a convertion (Duration / Calendar / Date class) where I than can persist it as a long (millisec)
to the db (MySql). Like that I can easily convert and work with it.
Is this a good way to do this?
Upvotes: 1
Views: 1886
Reputation: 30088
For the Hibernate 4.0 JPA provider, you can use the Usertype project to get JPA persistence for Joda Time classes, and then use the @Type annotation.
Upvotes: 1
Reputation: 15577
JodaTime (and forthcoming javax.time) provide a Duration class, and JPA providers such as DataNucleus JPA provide persistence for them out of the box without the need to play around with conversions.
Upvotes: 1