Skip to content

Instantly share code, notes, and snippets.

@andrus
Last active May 31, 2017 10:20
Show Gist options
  • Save andrus/2c9e7daf305d934b0b007e13ecb2decd to your computer and use it in GitHub Desktop.
Save andrus/2c9e7daf305d934b0b007e13ecb2decd to your computer and use it in GitHub Desktop.
CommitLogListener listener = // custom listener
Module commitLog = CommitLogModule
.extend()
.addListener(listener)
.commitLogAnnotationEntitiesOnly()
.module();
ServerRuntime runtime = ServerRuntime
.builder()
.addConfig("cayenne-project.xml")
.addModule(postCommit)
.build();
@andrus
Copy link
Author

andrus commented May 25, 2016

Here is how you track all commit changes in Cayenne. This includes direct ObjectContext changes or changes originating from pre- listeners/callbacks. Requires Cayenne 4.0.B1 or newer. You will need to add org.apache.cayenne:cayenne-commitlog dependency that will auto-load a corresponding module, and then add custom CommitLogListener objects to receive the events.

If you have callbacks or listeners modifying the context being committed in pre- events, make sure that CommitLogFilter is included in transaction. This is true by default, unless you explicitly call CommitLogModule.extend().excludeFromTransaction().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment