Hibernate Tips: How to remove entities from the persistence context before doing bulk operations
|

Hibernate Tips: How to remove entities from the persistence context before doing bulk operations

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: How do you remove entities from the persistence context before performing bulk update operations with JPQL or SQL?

What’s the difference between persist, save, merge and update? Which one should you use?
|

What’s the difference between persist, save, merge and update? Which one should you use?

JPA and Hibernate provide different methods to persist new and to update existing entities. You can choose between JPA’s persist and merge and Hibernate’s save and update methods. It seems like there are 2 pairs of 2 methods that do the same.  You can use the methods persist and save to store a new entity…

Hibernate Tips: How to model an association that doesn’t reference primary key columns
|

Hibernate Tips: How to model an association that doesn’t reference primary key columns

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: I have to map a legacy table model with Hibernate. It contains a many-to-one association that uses a non-primary…

Getting Started with Flyway and Version-Based Database Migration

Getting Started with Flyway and Version-Based Database Migration

Updating a database seems easy as long as you’re the only developer on the team and don’t have to support multiple systems. But that changes dramatically when your team implements multiple features in parallel, uses different test databases and runs the application on one or more production servers. Updating all these databases, keeping track of…