128 words

Issue #80 - @PrePersist not working correctly

BugVersion: Priority: NormalStatus: FixedReplies: 1
2011-11-03 14:24

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. 

mosi0815's picture
Joined on 2011-10-08
User Post #6
2011-11-03 21:16

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)
support's picture
Joined on 2010-05-03
User Post #689

Post Reply

Please read carefully the posting instructions - before posting to the ObjectDB website.

  • You may have to disable pop up blocking in order to use the toolbar (e.g. in Chrome).
  • Use ctrl + right click to open the browser context menu in the editing area (e.g. for using a browser spell checker).
  • To insert formatted lines (e.g. Java code, stack trace) - select a style in the toolbar and then insert the text in the new created block.
  • Avoid overflow of published source code examples by breaking long lines.
  • You may mark in paragraph code words (e.g. class names) with the code style (can be applied by ctrl + D).
  • Long stack traces (> 50 lines) and complex source examples (> 100 lines) should be posted as attachments.
Maximum file size: 32 MB