Hibernate saveorupdate is not updating dating point co uk

rows in the database), or if a lot of data is needed to construct an entity object.

With object-relational mapping (ORM) tools such as Hibernate, one usually modifies entities by first fetching them from the database, modifying some fields, and then persisting the entities again.

Using Spring Data JPA, one can easily create update queries with JPQL that translate into SQL update queries. may contain outdated entities after the query has executed.

This could be the case if your JPA provider uses a cache (such as Hibernate’s second level cache), or if there are changes that are pending to be flushed.

To facilitate this, I have created the following method in a generic DAO class: /// /// Inserts or updates the object to the associated datastore and then refreshes the object, /// returning the refreshed object.

This is applicable for situations where triggers are /// utilized, so that any changes resulting from the triggers will be reflected in the returned /// object instance.

Leave a Reply