Skip to content
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

Lambda entity callbacks no longer invoked #2853

Closed
hubertvolz opened this issue Jun 12, 2023 · 5 comments
Closed

Lambda entity callbacks no longer invoked #2853

hubertvolz opened this issue Jun 12, 2023 · 5 comments
Assignees
Labels
type: regression A regression from a previous release

Comments

@hubertvolz
Copy link

Hi everyone,

as mentioned on stackoverflow issue the behaviour of spring-data-jdbc changed.

If you wanted to use a BeforeConvertCallback to assign a custom id to an entity, you could do this in spring boot versions up to 3.0.5. But later versions, 3.1.0 for example, do not use this callback anymore.

A repo to reproduce: Repo. If something is unclear, don't hesitate to reach out to me.

best regards
hubert

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jun 12, 2023
@mp911de mp911de changed the title BeforeConvertCallback is not called anymore from spring boot versions > 3.0.5 Lambda entity callbacks no longer invoked Jun 13, 2023
@mp911de mp911de transferred this issue from spring-projects/spring-data-relational Jun 13, 2023
@mp911de
Copy link
Member

mp911de commented Jun 13, 2023

Sorry for inconvenience, this is a regression from #2812. Please avoid lambdas as workaround.

@mp911de mp911de added type: regression A regression from a previous release and removed status: waiting-for-triage An issue we've not yet triaged labels Jun 13, 2023
@mp911de
Copy link
Member

mp911de commented Jun 13, 2023

The difference between our tests stems from our tests using StandardMethodMetadata (reflection) while the reproducer uses SimpleMethodMetadata (ASM classreading). StandardMethodMetadata provides the Method object for the bean method while ASM classreading does not provide any reflection metadata to resolve the bean method return type.

@mp911de
Copy link
Member

mp911de commented Jun 13, 2023

Another workaround is moving the lambda callbacks into a non-@Configuration class that you import via @Import(…). Using @Configuration classes uses ASM-based parsing while non-@Configuration classes fall back to reflection.

@mp911de
Copy link
Member

mp911de commented Jun 13, 2023

Here's a reduced reproducer that walks through bean definitions and prints their type to the console: https://gist.github.com/mp911de/435d0b8259ac41671edbd40aaae4c8ba

@mp911de
Copy link
Member

mp911de commented Jun 14, 2023

Using merged bean definitions is actually doing what we're looking for.

@mp911de mp911de self-assigned this Jun 14, 2023
@mp911de mp911de added this to the 3.1.1 (2023.0.1) milestone Jun 14, 2023
mp911de added a commit that referenced this issue Jun 14, 2023
We now use the merged bean definition to resolve the defined EntityCallback type.

Previously, we used just the bean definition that might have contained no type hints because of ASM-parsed configuration classes.

Closes #2853
mp911de added a commit that referenced this issue Jun 14, 2023
We now use the merged bean definition to resolve the defined EntityCallback type.

Previously, we used just the bean definition that might have contained no type hints because of ASM-parsed configuration classes.

Closes #2853
mp911de added a commit that referenced this issue Jun 14, 2023
We now use the merged bean definition to resolve the defined EntityCallback type.

Previously, we used just the bean definition that might have contained no type hints because of ASM-parsed configuration classes.

Closes #2853
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: regression A regression from a previous release
Projects
None yet
Development

No branches or pull requests

4 participants