Skip to content

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

Closed
wants to merge 2 commits into from
Closed

Conversation

mp911de
Copy link
Member

@mp911de mp911de commented Jul 19, 2022

Closes #1286

mp911de added 2 commits July 19, 2022 08:07
We now support disabling lifecycle events through the Template API to reduce the framework overhead when events are not needed.
@mp911de mp911de added the type: enhancement A general enhancement label Jul 19, 2022
@mp911de mp911de requested a review from christophstrobl July 19, 2022 06:11
Copy link
Member

@christophstrobl christophstrobl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mp911de mp911de requested a review from schauder July 20, 2022 09:05
Copy link
Contributor

@schauder schauder left a 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();
Copy link
Contributor

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.

@@ -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();
Copy link
Contributor

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();
Copy link
Contributor

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();
Copy link
Contributor

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.
Copy link
Contributor

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.

@mp911de mp911de added this to the 4.0 M6 (2022.0.0) milestone Jul 21, 2022
@mp911de
Copy link
Member Author

mp911de commented Jul 21, 2022

Merged.

@mp911de mp911de closed this Jul 21, 2022
@mp911de mp911de deleted the issue/1286 branch July 21, 2022 08:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add configuration to disable entity lifecycle events
3 participants