Hello, I'm having trouble keeping track of object "modification" / "last update" times. Here's what I have:
----
@PreUpdate
@PrePersist
public void onUpdateExisting(){
setModificationTime(System.currentTimeMillis());
}
----
This seemed natural enough, but it's causing problems. Just the act of reading an object from the EntityManager, and making no changes to it whatsoever, will cause it to be updated with new values upon flush.. I can tell because both the ModificationTime is being updated to a new value AND my Version column is being incremented.
Again, no other properties of the object are being updated. The object is only being read from (other objects are being updated). But, when the flush happens, this "only read" object is being updated with a new modification time and version.
I'm sure there is a correct place to be doing this kind of thing in EJB3 but I don't know where it is. Any ideas?
Ryan
|