Issue #551: @PrePersist not working correctly

Type: Bug ReoprtPriority: NormalStatus: FixedReplies: 1
#1

I have a method to calculate some values before persisting to the database. So i annotated it with @PrePersist. If i merge an object the annotated method get's called but all members are on their default values. I only tried it with new objects. So merge get's an object with id = null and therefore shoud behave like persist. (I always use merge)
If i set a breakpoint before the em.merge(..) call the object is ok. Inside the @PrePersist method all fields are cleared. 

#2

You are right. Build 2.3.2_04 fixes the execution order and now you should see your field values in the event callback method.

Notice, however, that using merge as a replacement of persist is inefficient since it requires copying fields to a new managed object.

ObjectDB Support

Reply