Updating child tables hibernate who is benjamin burnley dating

This operation will discard all state in the persistence context completely.

updating child tables hibernate-23

In many cases, this feature is quite useful and will work without any issues, but sometimes you might find that Hibernate decides to update something that you did not expect.

Finding out why his happened can be a rather difficult task.

Somehow Hibernate decided that the data read by that process had become dirty and should be saved.

So now he had to find out why Hibernate thought that data was dirty.

In our situation, the session was being flushed and cleared at some point, leading to the unwanted updates and eventually the Stale Object State Exceptions. After removing the clear, the updates where gone and the bug was fixed.

Using Hibernate can save a developer a lot of time, when things are running smoothly.So to find out what the problem was, I set a breakpoint in the constructor and backtracked from there.It turned out Hibernate could not determine the dirty state of the object and therefor decided to update the entity just to be save.As mentioned eralier, Hibernate uses the "loaded state" to determine whether an object is dirty.This is the state of the object (the values of its properties) when loaded form the database.It works, otherwise use of this feature would be very limited.

Tags: , ,