Hibernate Tip: How does Hibernate’s native ID generator work

Hibernate Tip: How does Hibernate’s native ID generator work

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 post a comment below. Question: One of the readers of my article about using Hibernate with a MySQL database asked the following question: What is…

Hibernate Tips: How to Prevent the Removal of a Parent Entity with Children

Hibernate Tips: How to Prevent the Removal of a Parent Entity with Children

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 post a comment below. Question: In one of the previous Hibernate Tips, I showed how to remove child entities automatically when you remove their…

5 Primary Key Mappings for JPA and Hibernate Every Developer Should Know

5 Primary Key Mappings for JPA and Hibernate Every Developer Should Know

Mapping a primary key column with JPA and Hibernate is simple. You just need to add an attribute to your entity, make sure that its type and name match the database column, annotate it with @Column and you’re done. You can then use the primary key to load the entity, and Hibernate sets the primary…