-
Notifications
You must be signed in to change notification settings - Fork 310
Add configuration to disable entity lifecycle events #1291
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
We now support disabling lifecycle events through the Template API to reduce the framework overhead when events are not needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks almost perfect.
I just have a couple of minor issues that I would change, and one question.
It's all in the comments.
@@ -190,11 +191,12 @@ public AsyncCassandraTemplate(AsyncCqlTemplate asyncCqlTemplate, CassandraConver | |||
this.entityOperations = new EntityOperations(converter); | |||
this.exceptionTranslator = asyncCqlTemplate.getExceptionTranslator(); | |||
this.statementFactory = new StatementFactory(converter); | |||
this.eventDelegate = new EntityLifecycleEventDelegate(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpicking: I'd prefer to initialize this on declaration since it does not depend on anything in the constructor.
...-cassandra/src/main/java/org/springframework/data/cassandra/core/AsyncCassandraTemplate.java
Show resolved
Hide resolved
@@ -183,6 +184,7 @@ public CassandraTemplate(CqlOperations cqlOperations, CassandraConverter convert | |||
this.cqlOperations = cqlOperations; | |||
this.entityOperations = new EntityOperations(converter); | |||
this.statementFactory = new StatementFactory(new QueryMapper(converter), new UpdateMapper(converter)); | |||
this.eventDelegate = new EntityLifecycleEventDelegate(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again: I'd prefer initialization at declaration time when possible.
@@ -190,6 +191,7 @@ public ReactiveCassandraTemplate(ReactiveCqlOperations reactiveCqlOperations, Ca | |||
this.cqlOperations = reactiveCqlOperations; | |||
this.entityOperations = new EntityOperations(converter); | |||
this.statementFactory = new StatementFactory(converter); | |||
this.eventDelegate = new EntityLifecycleEventDelegate(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See above.
return getReactiveCqlOperations() | ||
.execute(new GetConfiguredPageSize()) | ||
.single(); | ||
return getReactiveCqlOperations().execute(new GetConfiguredPageSize()).single(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should protect the previous formatting in this case.
@@ -530,6 +533,8 @@ Being based on Spring's application context event infrastructure lets other prod | |||
|
|||
To intercept an object before it goes into the database, you can register a subclass of `org.springframework.data.cassandra.core.mapping.event.AbstractCassandraEventListener` that overrides the `onBeforeSave(…)` method. | |||
When the event is dispatched, your listener is called and passed the domain object (which is a Java entity). | |||
Entity lifecycle events can be costly and you may notice a change in the performance profile when loading large result sets. | |||
You can disable lifecycle events on the Template API object. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A link to the setEnabled
methods in the API doc would be nice. At least we should name the method explicitly so the user doesn't have to search for the right method.
Merged. |
Closes #1286