Hi Daniel,

Yes, post load callback should be invoked as advertised. I never personally 
tried it from a commit catch block, but it should work. Do you have a code 
sample? Maybe there is a scenario that we do not handle.

> Is there any chance to get a kind of a "postRollback" lifecycle callback
> working or something similar? 

The original callbacks were taken from the JPA spec that doesn't specify 
postRollback. We've already diverged from JPA by adding PostAdd. I think we 
might go further to better reflect Cayenne object lifecycle. So I am open to 
adding PostRollback in the future (need to think it through though)… 

Andrus

On Mar 5, 2013, at 6:43 PM, Daniel Scheibe <[email protected]> wrote:
> All,
> 
> i'm trying to get the lifecycle listeners working for my use case and i've
> come accross a problem. I registered a listener to do some extra stuff for
> an entity whenever it will be persisted (prePersist) via:
> 
> callbackRegistry.addListener(LifecycleEvent.PRE_PERSIST, Content.class,
> "prePersist");
> 
> This get's called as expected and works smoothly.
> 
> Now whenever i have the scenario of a CommitException thrown during
> commitChanges() (for whatever reason, underlying database not available,
> etc.) i need to revert some of the stuff i did in the "prePersist"
> lifefycle callback on the object in question.
> 
> Unfortunately i haven't had luck yet to register a lifecycle listener that
> will be called in case of a "rollback" through "rollbackChanges".
> 
> The documentation states something about "PostLoad" being called "Within
> "ObjectContext.rollbackChanges()" after the object is reverted." (although
> this is from 3.0 i guess it should still apply?
> https://cayenne.apache.org/docs/3.0/lifecycle-callbacks.html)
> 
> Is there any chance to get a kind of a "postRollback" lifecycle callback
> working or something similar? Or did i just hit a bug with the version i'm
> using?
> 
> Any help is much appreciated.
> 
> Cheers,
> Daniel

Reply via email to