0 Replies Latest reply on May 11, 2006 2:31 AM by voidhawc

    Using a PrePersist test to set ID variable if not set.

      Hi,

      This is also at

      http://opensource.atlassian.com/projects/hibernate/browse/EJB-46

      But I'm experiencing the same thing in 4.0.3SP1 and 4.0.4CR2

      ***************************

      Hibernate does property validation such as not null checking before it does the EJB3 callback to prepersist/preupdate. I'm not sure if there's a good reason for this, but I think it would be particularly convenient if this behavior was reversed. IMHO it seems to better fit the semantics of the PRE callbacks, and it would allow callbacks to make modifications to the objects before they are persisted or updated -- modifications that might in turn effect the property validation Hibernate is doing.

      The "audit" example in the entity manager documentation does make changes to the object. What if these changes had effected the property validation done before the callback occurred? What if the object was in an invalid state before the callback, but a valid state after the callback? The latter case is what I think would be conveniently handled if hibernate did its property validation after prepersist/preupdate.

      Just two cents worth, obviously there are workarounds. This EJB3 stuff is looking great.

      Ryan

      P.S. This might also allow those of us who assign our own IDs to objects to do so automatically within a callback.

      ****************************

      Any ideas or should I just post it to JIRA

      Thanks, Grant