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

Spring JIRA | Matej Zachar | 3 years ago
  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
  3. 0

    Excluding a field in a query where the field is a DBRef as below throws a MappingException. Query query = new Query(Criteria.where("parentField").is("test")); query.fields().exclude("children"); ParentClass parentClass = mongoOperations.findOne(query, ParentClass.class); Exception trace: 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) at com.digitalshadows.collation.persistence.impl.CollectionNameProvidedMongoConverter.createDBRef(CollectionNameProvidedMongoConverter.java:28) at org.springframework.data.mongodb.core.convert.MappingMongoConverter.toDBRef(MappingMongoConverter.java:288) at org.springframework.data.mongodb.core.convert.QueryMapper.convertAssociation(QueryMapper.java:273) at org.springframework.data.mongodb.core.convert.QueryMapper.getMappedValue(QueryMapper.java:204) at org.springframework.data.mongodb.core.convert.QueryMapper.getMappedObject(QueryMapper.java:113) at org.springframework.data.mongodb.core.MongoTemplate.doFindOne(MongoTemplate.java:1439) at org.springframework.data.mongodb.core.MongoTemplate.findOne(MongoTemplate.java:489) at org.springframework.data.mongodb.core.MongoTemplate.findOne(MongoTemplate.java:484) at ExcludeDBRefFieldTest.testExcludeChildren(ExcludeDBRefFieldTest.java:28) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74) at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:83) at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:231) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:88) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222) at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61) at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:71) at org.junit.runners.ParentRunner.run(ParentRunner.java:300) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:174) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) I've attached a simple test case that throws the MappingException. The workaround for this I can currently see is to use include for all the other fields instead.

    Spring JIRA | 3 years ago | Catherine Howe
    org.springframework.data.mapping.model.MappingException: No mapping metadata found for class java.lang.Integer
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Excluding a field in a query where the field is a DBRef as below throws a MappingException. Query query = new Query(Criteria.where("parentField").is("test")); query.fields().exclude("children"); ParentClass parentClass = mongoOperations.findOne(query, ParentClass.class); Exception trace: 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) at com.digitalshadows.collation.persistence.impl.CollectionNameProvidedMongoConverter.createDBRef(CollectionNameProvidedMongoConverter.java:28) at org.springframework.data.mongodb.core.convert.MappingMongoConverter.toDBRef(MappingMongoConverter.java:288) at org.springframework.data.mongodb.core.convert.QueryMapper.convertAssociation(QueryMapper.java:273) at org.springframework.data.mongodb.core.convert.QueryMapper.getMappedValue(QueryMapper.java:204) at org.springframework.data.mongodb.core.convert.QueryMapper.getMappedObject(QueryMapper.java:113) at org.springframework.data.mongodb.core.MongoTemplate.doFindOne(MongoTemplate.java:1439) at org.springframework.data.mongodb.core.MongoTemplate.findOne(MongoTemplate.java:489) at org.springframework.data.mongodb.core.MongoTemplate.findOne(MongoTemplate.java:484) at ExcludeDBRefFieldTest.testExcludeChildren(ExcludeDBRefFieldTest.java:28) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74) at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:83) at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:231) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:88) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222) at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61) at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:71) at org.junit.runners.ParentRunner.run(ParentRunner.java:300) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:174) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) I've attached a simple test case that throws the MappingException. The workaround for this I can currently see is to use include for all the other fields instead.

    Spring JIRA | 3 years ago | Catherine Howe
    org.springframework.data.mapping.model.MappingException: No mapping metadata found for class java.lang.Integer
  6. 0

    Spring MongoDB $size query throws exception "org.springframework.data.mapping.model.MappingException"

    Stack Overflow | 3 years ago | rohit kotian
    org.springframework.data.mapping.model.MappingException: No mapping metadata found for class java.lang.Integer

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    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