org.springframework.data.mapping.model.MappingException: No mapping metadata found for class java.lang.Integer

Spring JIRA | Matej Zachar | 3 years ago
tip
Your exception is missing from the Samebug knowledge base.
Here are the best solutions we found on the Internet.
Click on the to mark the helpful solution and get rewards for you help.
  1. 0

    Using {noformat} @Query(fields="{property3:1}") {noformat} or query object itself {noformat} query.fields().include("property3") {noformat} will fail if the filed has @DBref annotation (with or without @Field) eg.: {noformat} class A { @Id String id; @Field("prop1") String property1; @Field("prop2") String property2; @Field("prop3") @DBRef B property3; } class B { @Id String id; } {noformat} will throw {noformat} org.springframework.data.mapping.model.MappingException: No mapping metadata found for class java.lang.Integer at org.springframework.data.mongodb.core.convert.MappingMongoConverter.createDBRef(MappingMongoConverter.java:729) ~[spring-data-mongodb-1.3.1.RELEASE.jar:na] at org.springframework.data.mongodb.core.convert.MappingMongoConverter.toDBRef(MappingMongoConverter.java:288) ~[spring-data-mongodb-1.3.1.RELEASE.jar:na] at org.springframework.data.mongodb.core.convert.QueryMapper.convertAssociation(QueryMapper.java:272) ~[spring-data-mongodb-1.3.1.RELEASE.jar:na] at org.springframework.data.mongodb.core.convert.QueryMapper.getMappedValue(QueryMapper.java:203) ~[spring-data-mongodb-1.3.1.RELEASE.jar:na] at org.springframework.data.mongodb.core.convert.QueryMapper.getMappedObject(QueryMapper.java:114) ~[spring-data-mongodb-1.3.1.RELEASE.jar:na] at org.springframework.data.mongodb.core.MongoTemplate.doFind(MongoTemplate.java:1479) ~[spring-data-mongodb-1.3.1.RELEASE.jar:na] at org.springframework.data.mongodb.core.MongoTemplate.doFind(MongoTemplate.java:1471) ~[spring-data-mongodb-1.3.1.RELEASE.jar:na] {noformat} This issue is related to [DATAMONGO-702|https://jira.springsource.org/browse/DATAMONGO-702]

    Spring JIRA | 3 years ago | Matej Zachar
    org.springframework.data.mapping.model.MappingException: No mapping metadata found for class java.lang.Integer
  2. 0

    Using {noformat} @Query(fields="{property3:1}") {noformat} or query object itself {noformat} query.fields().include("property3") {noformat} will fail if the filed has @DBref annotation (with or without @Field) eg.: {noformat} class A { @Id String id; @Field("prop1") String property1; @Field("prop2") String property2; @Field("prop3") @DBRef B property3; } class B { @Id String id; } {noformat} will throw {noformat} org.springframework.data.mapping.model.MappingException: No mapping metadata found for class java.lang.Integer at org.springframework.data.mongodb.core.convert.MappingMongoConverter.createDBRef(MappingMongoConverter.java:729) ~[spring-data-mongodb-1.3.1.RELEASE.jar:na] at org.springframework.data.mongodb.core.convert.MappingMongoConverter.toDBRef(MappingMongoConverter.java:288) ~[spring-data-mongodb-1.3.1.RELEASE.jar:na] at org.springframework.data.mongodb.core.convert.QueryMapper.convertAssociation(QueryMapper.java:272) ~[spring-data-mongodb-1.3.1.RELEASE.jar:na] at org.springframework.data.mongodb.core.convert.QueryMapper.getMappedValue(QueryMapper.java:203) ~[spring-data-mongodb-1.3.1.RELEASE.jar:na] at org.springframework.data.mongodb.core.convert.QueryMapper.getMappedObject(QueryMapper.java:114) ~[spring-data-mongodb-1.3.1.RELEASE.jar:na] at org.springframework.data.mongodb.core.MongoTemplate.doFind(MongoTemplate.java:1479) ~[spring-data-mongodb-1.3.1.RELEASE.jar:na] at org.springframework.data.mongodb.core.MongoTemplate.doFind(MongoTemplate.java:1471) ~[spring-data-mongodb-1.3.1.RELEASE.jar:na] {noformat} This issue is related to [DATAMONGO-702|https://jira.springsource.org/browse/DATAMONGO-702]

    Spring JIRA | 3 years ago | Matej Zachar
    org.springframework.data.mapping.model.MappingException: No mapping metadata found for class java.lang.Integer

    Root Cause Analysis

    1. org.springframework.data.mapping.model.MappingException

      No mapping metadata found for class java.lang.Integer

      at org.springframework.data.mongodb.core.convert.MappingMongoConverter.createDBRef()
    2. Spring Data MongoDB - Core
      MongoTemplate.doFind
      1. org.springframework.data.mongodb.core.convert.MappingMongoConverter.createDBRef(MappingMongoConverter.java:729)[spring-data-mongodb-1.3.1.RELEASE.jar:na]
      2. org.springframework.data.mongodb.core.convert.MappingMongoConverter.toDBRef(MappingMongoConverter.java:288)[spring-data-mongodb-1.3.1.RELEASE.jar:na]
      3. org.springframework.data.mongodb.core.convert.QueryMapper.convertAssociation(QueryMapper.java:272)[spring-data-mongodb-1.3.1.RELEASE.jar:na]
      4. org.springframework.data.mongodb.core.convert.QueryMapper.getMappedValue(QueryMapper.java:203)[spring-data-mongodb-1.3.1.RELEASE.jar:na]
      5. org.springframework.data.mongodb.core.convert.QueryMapper.getMappedObject(QueryMapper.java:114)[spring-data-mongodb-1.3.1.RELEASE.jar:na]
      6. org.springframework.data.mongodb.core.MongoTemplate.doFind(MongoTemplate.java:1479)[spring-data-mongodb-1.3.1.RELEASE.jar:na]
      7. org.springframework.data.mongodb.core.MongoTemplate.doFind(MongoTemplate.java:1471)[spring-data-mongodb-1.3.1.RELEASE.jar:na]
      7 frames