Skip to content

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.

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.

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.

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.

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

3 participants