javax.persistence.PreUpdate
object need to be "dirty" to trigger...
obj.setColumn01("text");
repo.save(obj);
then make obj "dirty" before save to trigger @PreUpdate
obj.setColumn01("new text);
repo.save(obj);
obj.setColumn01("new text);
repo.save(obj);
Solution
As you said, the callback method is called the second time, if the entity is detached or fetched again from DB.
I cannot explain it exactly, but can think of the scenario described here, when no dirty fields are identified before the second save()
call and thus the @PreUpdate callback not called. Or it may be simply a bug within your version of EclipseLink.
No comments:
Post a Comment