Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

R2DBC @Sequence annotation support #2028

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
mipo256 wants to merge 3 commits into spring-projects:main from mipo256:r2dbc-sequences

Conversation

Copy link
Contributor

@mipo256 mipo256 commented Apr 14, 2025

Hey @mp911de! As discussed here, I've provided the corresponding PR for the Spring Data R2DBC module for @Sequence support.

I've also provided the adoc documentation for this feature, I think it is worth a separate small page. I can do the same for the Spring Data JDBC module, should I? @mp911de

Signed-off-by: mipo256 <mikhailpolivakha@gmail.com>
@mp911de mp911de self-assigned this Apr 15, 2025
@mp911de mp911de added type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged labels Apr 15, 2025
@mp911de mp911de added this to the 3.5 RC1 (202500) milestone Apr 15, 2025
Copy link
Member

mp911de commented Apr 15, 2025

Thanks a lot. Let me check how the documentation fits into both modules. Maybe we can have a shared fragment for inclusion.

mipo256 reacted with thumbs up emoji

.map((r, rowMetadata) -> r.get(0)) //
.one() //
.doOnNext(fetchedId -> { //
row.put(persistentEntity.getIdColumn().toSql(dialect.getIdentifierProcessing()), //
Copy link
Member

Choose a reason for hiding this comment

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

Obtaining the IdColumn as early as possible guards the later code against potential absence. Also, there's repetative access to IdProperty. I think it would be much more aligned with a future support of embedded Id's to use the IdProperty instead of IdColumn.

mipo256 reacted with eyes emoji
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it would be much more aligned with a future support of embedded Id's to use the IdProperty instead of IdColumn.

Can you please elaborate on what you mean here? The OutboundRow contains the mapping between column names (not properties) and their repsective values. I can obtain the idProperty once (although, this operation is relatively cheap since it just returns a reference to an already computed Id PersistentProperty), but I do not see how we can use the property here intead of column.

Copy link
Member

Choose a reason for hiding this comment

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

This is a difference between persistentEntity.getIdColumn() and PersistentProperty.getColumnName().

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I still do not understand what change needs to be done here to be honest @mp911de

This is a difference between persistentEntity.getIdColumn() and PersistentProperty.getColumnName().

The persistentEntity.getIdColumn() is implemeted internally as getRequiredIdProperty().getColumnName(), which partically the same as calling the PersistentProperty.getColumnName().

mipo256 added 2 commits April 16, 2025 12:21
Signed-off-by: mipo256 <mikhailpolivakha@gmail.com>
Signed-off-by: mipo256 <mikhailpolivakha@gmail.com>
Comment on lines +197 to +201
withJsonRepository.findAll().as(StepVerifier::create).consumeNextWith(actual -> {

assertThat(actual.jsonValue).isNotNull().isEqualTo(4);
assertThat(actual.jsonValue.asString()).isEqualTo("NewName");
}).verifyComplete();
Copy link
Member

Choose a reason for hiding this comment

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

This is wrong. It should actually be withIdFromSequenceRepository and asserting id and name properties. I wonder whether you ever ran these tests because they fail upon the first run.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm terribly sorry for this overlook @mp911de. Of course, I run them. As far as I understood, you've already merged this PR. Should I take a look? Or you already did

mp911de pushed a commit that referenced this pull request Apr 24, 2025
Signed-off-by: mipo256 <mikhailpolivakha@gmail.com>
See #1955
Original pull request: #2028 
mp911de added a commit that referenced this pull request Apr 24, 2025
Extract SequenceEntityCallbackDelegate from IdGeneratingBeforeSaveCallback. Renameto IdGeneratingEntityCallback and move callback to convert package.
Align return values and associate generated sequence value with the entity. Fix test. Add ticket references to tests.
Extract documentation partials.
See #1955
Original pull request: #2028 
mp911de pushed a commit that referenced this pull request Apr 24, 2025
Signed-off-by: mipo256 <mikhailpolivakha@gmail.com>
See #1955
Original pull request: #2028 
mp911de added a commit that referenced this pull request Apr 24, 2025
Extract SequenceEntityCallbackDelegate from IdGeneratingBeforeSaveCallback. Renameto IdGeneratingEntityCallback and move callback to convert package.
Align return values and associate generated sequence value with the entity. Fix test. Add ticket references to tests.
Extract documentation partials.
See #1955
Original pull request: #2028 
Copy link
Member

mp911de commented Apr 24, 2025

Thank you for your contribution. That's merged, polished, and forward-ported now.

mipo256 reacted with heart emoji

Copy link
Member

mp911de commented Apr 24, 2025 via email

No worries for now. I took care of this. In any case, please run the full build including the all-dbs profile to run tests at least once. Am 24. Apr. 2025, 11:19 +0200 schrieb Mikhail Polivakha ***@***.***>:
...
@mipo256 commented on this pull request. In spring-data-r2dbc/src/test/java/org/springframework/data/r2dbc/repository/PostgresR2dbcRepositoryIntegrationTests.java: > + withJsonRepository.findAll().as(StepVerifier::create).consumeNextWith(actual -> { + + assertThat(actual.jsonValue).isNotNull().isEqualTo(4); + assertThat(actual.jsonValue.asString()).isEqualTo("NewName"); + }).verifyComplete(); I'm terribly sorry for this overlook @mp911de. Of course, I run them. As far as I understood, you've already merged this PR. Should I take a look? Or you already did — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: ***@***.***>
mipo256 reacted with heart emoji

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

@mp911de mp911de mp911de requested changes

Labels
type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /