Hibernate Tips: How to use a timestamp for versioning and optimistic locking

Hibernate Tips: How to use a timestamp for versioning and optimistic locking

Hibernate Tips is a series of posts in which I describe a quick and easy solution for common Hibernate questions. If you have a question for a future Hibernate Tip, please leave a comment below. Question: My table model uses a timestamp instead of a numeric column for versioning. How can I use this column…

Best Practices for Many-To-One and One-To-Many Association Mappings
|

Best Practices for Many-To-One and One-To-Many Association Mappings

When you model your database, you will most likely define several many-to-one or one-to-many associations. And it’s, of course, the same when you model your entities. It’s quite easy to do that with JPA and Hibernate. You just need an attribute that represents the association and annotate it with a @ManyToOne or @OneToMany association. But…

How to override the primary key generation strategy

Hibernate Tips: How to override the primary key generation strategy

Hibernate Tips is a series of posts in which I describe a quick and easy solution for common Hibernate questions. If you have a question for a future Hibernate Tip, please leave a comment below. Question: You explained that the GenerationType.SEQUENCE is the most efficient primary key generation strategy and that MySQL doesn’t support it….