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

Spring JIRA | Catherine Howe | 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

    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
  2. 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

    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
      MappingMongoConverter.createDBRef
      1. org.springframework.data.mongodb.core.convert.MappingMongoConverter.createDBRef(MappingMongoConverter.java:729)
      1 frame
    3. com.digitalshadows.collation
      CollectionNameProvidedMongoConverter.createDBRef
      1. com.digitalshadows.collation.persistence.impl.CollectionNameProvidedMongoConverter.createDBRef(CollectionNameProvidedMongoConverter.java:28)
      1 frame
    4. Spring Data MongoDB - Core
      MongoTemplate.findOne
      1. org.springframework.data.mongodb.core.convert.MappingMongoConverter.toDBRef(MappingMongoConverter.java:288)
      2. org.springframework.data.mongodb.core.convert.QueryMapper.convertAssociation(QueryMapper.java:273)
      3. org.springframework.data.mongodb.core.convert.QueryMapper.getMappedValue(QueryMapper.java:204)
      4. org.springframework.data.mongodb.core.convert.QueryMapper.getMappedObject(QueryMapper.java:113)
      5. org.springframework.data.mongodb.core.MongoTemplate.doFindOne(MongoTemplate.java:1439)
      6. org.springframework.data.mongodb.core.MongoTemplate.findOne(MongoTemplate.java:489)
      7. org.springframework.data.mongodb.core.MongoTemplate.findOne(MongoTemplate.java:484)
      7 frames
    5. Unknown
      ExcludeDBRefFieldTest.testExcludeChildren
      1. ExcludeDBRefFieldTest.testExcludeChildren(ExcludeDBRefFieldTest.java:28)
      1 frame
    6. Java RT
      Method.invoke
      1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      2. sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      3. sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      4. java.lang.reflect.Method.invoke(Unknown Source)
      4 frames
    7. JUnit
      InvokeMethod.evaluate
      1. org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
      2. org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
      3. org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
      4. org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
      4 frames
    8. Spring TestContext
      SpringJUnit4ClassRunner.runChild
      1. org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74)
      2. org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:83)
      3. org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72)
      4. org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:231)
      5. org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:88)
      5 frames
    9. JUnit
      ParentRunner$2.evaluate
      1. org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
      2. org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
      3. org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
      4. org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
      5. org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
      5 frames
    10. Spring TestContext
      RunAfterTestClassCallbacks.evaluate
      1. org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
      2. org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:71)
      2 frames
    11. JUnit
      ParentRunner.run
      1. org.junit.runners.ParentRunner.run(ParentRunner.java:300)
      1 frame
    12. Spring TestContext
      SpringJUnit4ClassRunner.run
      1. org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:174)
      1 frame
    13. JUnit4 Runner
      JUnit4TestReference.run
      1. org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
      1 frame
    14. JUnit3 Runner
      RemoteTestRunner.main
      1. org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
      2. org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
      3. org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
      4. org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
      5. org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
      5 frames