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

Spring JIRA | Catherine Howe | 3 years ago
  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
  3. 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
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 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
  6. 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

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