You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by Dave Lamy <da...@gmail.com> on 2009/07/24 05:15:38 UTC

Simple callback question

Should the preUpdate callback event get fired for both new and existing
objects?

The behavior I'm seeing (3.0M5) is that preUpdate is not getting called when
saving my new object, but does get called when saving an existing object.
prePersist is not the correct time for my event code to run.. I need to have
this run during the commit phase, not during the creation phase.

Please let me know if this is surprising or not.  And if not, do I have any
choices to get the behavior I need?

Thanks--
Dave

Re: Simple callback question

Posted by Aristedes Maniatis <ar...@ish.com.au>.
On 24/07/09 1:15 PM, Dave Lamy wrote:
> Should the preUpdate callback event get fired for both new and existing
> objects?
>
> The behavior I'm seeing (3.0M5) is that preUpdate is not getting called when
> saving my new object, but does get called when saving an existing object.
> prePersist is not the correct time for my event code to run.. I need to have
> this run during the commit phase, not during the creation phase.
>
> Please let me know if this is surprising or not.  And if not, do I have any
> choices to get the behavior I need?


That's how it works unfortunately. These callbacks follow the JPA standard, but they certainly don't make the most sense. They are even less useful in ROP (three tier). You are going to have to work within the confines of what is available [1] for now but there has been some discussion of changing or adding new events.

Ari Maniatis


[1] http://cayenne.apache.org/doc/lifecycle-callbacks.html



-------------------------->
ish
http://www.ish.com.au
Level 1, 30 Wilson Street Newtown 2042 Australia
phone +61 2 9550 5001   fax +61 2 9550 4001
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A