Home » Support » Issue Tracking » @PrePersist not working correctly

@PrePersist not working correctly

Type: BugPriority: NormalStatus: FixedReplies: 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. 


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
ObjectDB - Fast Object Database for Java (JPA/JDO)

Post Reply

To post a reply and/or subscribe to update notifications - please login