spring-projects / spring-projects/spring-data-mongodb
Entity checked on wrong type, when enable EnableMongoAuditing [DATAMONGO-2420]
@christophstrobl is already working on this.
Since Dec 30, 2020.
- Dominant language
- Java
- Stars
- 1.7k
- Forks
- 1.1k
- PR merge metrics
- No merged PRs in 30d
Description
dzonekl opened DATAMONGO-2420 and commented
In a spring boot application (2.2.1), having auditing enabled. (@EnableMongoAuditing), an exception is thrown on a field of type List<...> or Set<...>
java.lang.IllegalArgumentException: Target bean of type java.util.ArrayList is not of type of the persistent entity (Comment)!: java.util.ArrayList
at org.springframework.util.Assert.instanceCheckFailed(Assert.java:696)at org.springframework.util.Assert.instanceCheckFailed(Assert.java:696) at org.springframework.util.Assert.isInstanceOf(Assert.java:615) at org.springframework.data.mapping.model.BasicPersistentEntity.verifyBeanType(BasicPersistentEntity.java:551) at org.springframework.data.mapping.model.BasicPersistentEntity.getPropertyAccessor(BasicPersistentEntity.java:453) at org.springframework.data.mapping.PersistentPropertyAccessor.setProperty(PersistentPropertyAccessor.java:76) at org.springframework.data.auditing.MappingAuditableBeanWrapperFactory$MappingMetadataAuditableBeanWrapper.lambda$setDateProperty$2(MappingAuditableBeanWrapperFactory.java:243) at java.lang.Iterable.forEach(Iterable.java:75)
Attachments: debug state of the bean, when hitting method verifyBeanType
Screenshot 1 - Successful without @EnableMongoAuditing
Screenshot 2 - Exception occurs
Attachments:
- screenshot-1 - No Problem.png (70.18 kB)
- screenshot-2.png (72.38 kB)
Issue Links:
- DATACMNS-1609 Auditing metadata should not detect paths containing map or collection like segments
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.