jakartaee / persistence

https://jakartaee.github.io/persistence/
Other
186 stars 55 forks source link

Introduce PreMerge lifecycle callback #635

Open beikov opened 3 weeks ago

beikov commented 3 weeks ago

The idea is to introduce a new lifecycle callback that allows to react to merge being called for an entity. This is different from PreUpdate in the sense that this operation would be called on a detached entity instance instead of on the managed entity instance.

If an entity stores some transient state that should be synchronized with persistent state, it is desirable to do so before the merge operation copies the state from the detached object to a managed object. Also see https://discourse.hibernate.org/t/queryparameterbindingvalidator-uses-property-type-instead-of-attributeconverter-type/9650/2

gavinking commented 3 weeks ago

This is a good idea.