Skip to content

Couldn't find PersistentEntity for type java.lang.Object when updating a field with suffix "class" #3566

Closed
@davebarda

Description

@davebarda

Spring data mongodb version: 3.0.5.RELEASE

If i'm calling
mongoOperations.updateFirst(query, Map.of("field1.class", "value"), MyModel.class);
where the model has the following structure:

public class MyModel {
    private Map<String, Object> field1;
}

I receive:
Couldn't find PersistentEntity for type java.lang.Object!

After debugging, I have realized that:

<init>:76, GenericTypeAwarePropertyDescriptor (org.springframework.beans)
buildGenericTypeAwarePropertyDescriptor:361, CachedIntrospectionResults (org.springframework.beans)
<init>:295, CachedIntrospectionResults (org.springframework.beans)
forClass:178, CachedIntrospectionResults (org.springframework.beans)
getPropertyDescriptors:444, BeanUtils (org.springframework.beans)
addPersistentEntity:379, AbstractMappingContext (org.springframework.data.mapping.context)
getPersistentEntity:263, AbstractMappingContext (org.springframework.data.mapping.context)
getPersistentEntity:206, AbstractMappingContext (org.springframework.data.mapping.context)
getPersistentEntity:90, AbstractMappingContext (org.springframework.data.mapping.context)
getRequiredPersistentEntity:73, MappingContext (org.springframework.data.mapping.context)
getEntityInformation:150, MongoRepositoryFactory (org.springframework.data.mongodb.repository.support)

in CachedIntrospectionResults
we have:
java.beans.Introspector.java:205
where
beanInfo = new Introspector(beanClass=MyModel.class, null, USE_ALL_BEANINFO).getBeanInfo()
it returns

java.beans.PropertyDescriptor[name=class; values={expert=false; visualUpdate=false; hidden=false; enumerationValues=[Ljava.lang.Object;@5b1965ea; required=false}; propertyType=class java.lang.Class; readMethod=public final native java.lang.Class java.lang.Object.getClass()]

which causes issues later on, as this is not the getter intended to be used.

I believe class property descriptor should be filtered, but I wonder how it may affect other stuff.

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions