[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[eclipselink-users] @PreUpdate question
|
I don't think the JPA specification addresses this fully, so I thought I'd ask it here.
I have an entity that consists of an integer ID and a byte[] field mapped onto a @Lob column.
The data that goes into that byte array is computed from another operation.
I had the bright idea that I'd stick a @PreUpdate annotation on the operation that computes the data. Easy, I thought, this will ensure that the byte[] field is always up to date when the entity is updated.
I am observing (by turning EclipseLink logging up to FINEST) that this only fires when EclipseLink has determined that the state of the object has changed.
I had assumed that @PreUpdate fired sometime "before" an EntityManager#merge() operation started. That is, I had assumed that when you called EntiytManager#merge() and passed it an entity, that entity's @PreUpdate callbacks would fire, whether (ultimately) EclipseLink determined it needed to get flushed to the database or not. I realize now that I must be wrong--the @PreUpdate must only fire when (effectively) an UPDATE SQL statement is about to be fired.
My question is: is there any kind of interceptor or callback mechanism I can employ that fires before the EclipseLink I-wonder-if-this-object-needs-to-be-flushed-to-the-database-or-not process (change tracking) begins?
Thanks,
Laird