Skip to content

AbstractMapping.getPersistentEntity(Class<?> type) fails to lookup the PersistentEntity when the provided type is a HibernateProxy #2383

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
alienisty opened this issue Nov 23, 2021 · 2 comments
Assignees
Labels
type: regression A regression from a previous release

Comments

@alienisty
Copy link

From my analysis, the regression has been added by commit c866b4202527b3acc64e7cc205a98a8aa754cb59 where "ClassTypeInformation now never unwraps the user type to consistently work with the type originally presented in the lookup..."

The assumption in that comment might be incorrect, I would be surprised if PersistentEntity instances are mapped against an HibernateProxy class.

I believe that at least ClassTypeInformation.from(Class type) should have retained the type unwrapping.

This is a minimal demonstrating project which also shows the impact on Spring Data REST
demo.zip

@mp911de
Copy link
Member

mp911de commented Nov 24, 2021

The change is more invasive than anticipated. Prior the unwrapping change, looking up the persistent entity using the proxy type worked because ClassTypeInformation unwrapped the type before constructing TypeDiscoverer. That has led to the successful lookup through the proxy. We need to fix this regression.

@mp911de mp911de self-assigned this Nov 29, 2021
@mp911de mp911de transferred this issue from spring-projects/spring-data-commons Dec 8, 2021
@mp911de mp911de added the type: regression A regression from a previous release label Dec 8, 2021
@mp911de mp911de changed the title AbstractMapping.getPersistentEntity(Class<?> type) fails to lookup the PersistentEntity when the provided type is a HibernateProxy AbstractMapping.getPersistentEntity(Class<?> type) fails to lookup the PersistentEntity when the provided type is a HibernateProxy Dec 8, 2021
@mp911de
Copy link
Member

mp911de commented Dec 8, 2021

I transferred the ticket into the JPA project as we can easily fix the issue here.

@mp911de mp911de closed this as completed in a052065 Dec 8, 2021
mp911de added a commit that referenced this issue Dec 8, 2021
Trim trailing white spaces. Introduce getRequiredMetamodel(…) to refine nullability handling. Use diamond syntax and method handles where possible.

See #2383
@mp911de mp911de added this to the 2.6.1 (2021.1.1) milestone Dec 8, 2021
mp911de added a commit that referenced this issue Dec 8, 2021
We now unwrap the user type in JpaMetamodelMappingContext.shouldCreatePersistentEntityFor(…) to enable usage of proxy types when requesting a PersistentEntity.

Previously, we checked against the proxy type which is not managed by the JPA meta-model.

Closes #2383
mp911de added a commit that referenced this issue Dec 8, 2021
Trim trailing white spaces. Introduce getRequiredMetamodel(…) to refine nullability handling. Use diamond syntax and method handles where possible.

See #2383
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

2 participants