Skip to content

PropertyReferenceException if path expression maps into simple type properties #369

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
murdos opened this issue May 16, 2020 · 2 comments
Closed
Labels
type: bug A general bug

Comments

@murdos
Copy link

murdos commented May 16, 2020

While working on the SpringBoot 2.3 support in JHipster, I stumble upon an new issue that we had not before:

org.springframework.data.mapping.MappingException: Couldn't find PersistentEntity for type java.lang.String!

	at org.springframework.data.mapping.context.MappingContext.getRequiredPersistentEntity(MappingContext.java:119)
	at org.springframework.data.mapping.context.PersistentPropertyPathFactory.getPair(PersistentPropertyPathFactory.java:237)
	at org.springframework.data.mapping.context.PersistentPropertyPathFactory.createPersistentPropertyPath(PersistentPropertyPathFactory.java:210)
	at org.springframework.data.mapping.context.PersistentPropertyPathFactory.lambda$getPersistentPropertyPath$2(PersistentPropertyPathFactory.java:183)
	at java.base/java.util.concurrent.ConcurrentMap.computeIfAbsent(ConcurrentMap.java:330)
	at org.springframework.data.mapping.context.PersistentPropertyPathFactory.getPersistentPropertyPath(PersistentPropertyPathFactory.java:182)
	at org.springframework.data.mapping.context.PersistentPropertyPathFactory.from(PersistentPropertyPathFactory.java:97)
	at org.springframework.data.mapping.context.PersistentPropertyPathFactory.from(PersistentPropertyPathFactory.java:110)
	at org.springframework.data.mapping.context.AbstractMappingContext.getPersistentPropertyPath(AbstractMappingContext.java:286)

I've created a minimal project to expose the issue: https://github.com/murdos/spring-data-r2dbc-mapping-bug

The issues seems to comes from the password_hash column of the jhi_user table: because propertyPath is then valued to User.password.hash.
It the column is renamed to passwordhash everything works fine.

@mp911de
Copy link
Member

mp911de commented May 20, 2020

Thanks for reporting the issue. Spring Data's PropertyPath resolution tries to introspect the property password assuming that hash is a nested property of password. Therefore it attempts to introspect String which isn't an entity and so the mapping fails.

This issue pops up also in other Spring Data modules so we probably need to take a deeper look how to handle the issue.

@mp911de mp911de modified the milestones: 1.0.1, 1.1.1 (Neumann SR1) May 22, 2020
@mp911de mp911de changed the title MappingException: Couldn't find PersistentEntity for type java.lang.String PropertyReferenceException if path expression maps into simple type properties May 22, 2020
mp911de added a commit that referenced this issue May 22, 2020
…s into simple type property.

We now fall back to the column name when resolving a property path expression that maps into a simple-typed property. PropertyPath.from(…) fails internally as it attempts to look up a simple type from the MappingContext and this fails for primitive and simple types.
mp911de added a commit that referenced this issue May 22, 2020
Remove unused code.
mp911de added a commit that referenced this issue May 22, 2020
…s into simple type property.

We now fall back to the column name when resolving a property path expression that maps into a simple-typed property. PropertyPath.from(…) fails internally as it attempts to look up a simple type from the MappingContext and this fails for primitive and simple types.
mp911de added a commit that referenced this issue May 22, 2020
Remove unused code.
@mp911de
Copy link
Member

mp911de commented May 22, 2020

That's fixed now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

No branches or pull requests

2 participants