org.springframework.data.mapping.model.MappingException: No mapping metadata found for class com.mongodb.BasicDBObject

Spring JIRA | Marcin Kowalski | 3 years ago
  1. 0

    For repository method definition like below: {code:java} @Query("{meanings: {$not: {$size: 0}}}") Page<Entry> findAllWithMeanings(Pageable pageable); {code} Entry documents contain {{meanings}} field which is a list of {{@DBRef}} s. When I remove {{@DBRef}} annotation it works ok, but otherwise I get the following exception: {noformat} Exception in thread "main" org.springframework.data.mapping.model.MappingException: No mapping metadata found for class com.mongodb.BasicDBObject at org.springframework.data.mongodb.core.convert.MappingMongoConverter.createDBRef(MappingMongoConverter.java:729) 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.getMappedKeyword(QueryMapper.java:158) at org.springframework.data.mongodb.core.convert.QueryMapper.getMappedObject(QueryMapper.java:111) at org.springframework.data.mongodb.core.MongoTemplate.doFind(MongoTemplate.java:1489) at org.springframework.data.mongodb.core.MongoTemplate.doFind(MongoTemplate.java:1480) at org.springframework.data.mongodb.core.MongoTemplate.find(MongoTemplate.java:527) at org.springframework.data.mongodb.repository.query.AbstractMongoQuery$PagedExecution.execute(AbstractMongoQuery.java:205) at org.springframework.data.mongodb.repository.query.AbstractMongoQuery.execute(AbstractMongoQuery.java:93) at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:337) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204) … {noformat}

    Spring JIRA | 3 years ago | Marcin Kowalski
    org.springframework.data.mapping.model.MappingException: No mapping metadata found for class com.mongodb.BasicDBObject
  2. 0

    For repository method definition like below: {code:java} @Query("{meanings: {$not: {$size: 0}}}") Page<Entry> findAllWithMeanings(Pageable pageable); {code} Entry documents contain {{meanings}} field which is a list of {{@DBRef}} s. When I remove {{@DBRef}} annotation it works ok, but otherwise I get the following exception: {noformat} Exception in thread "main" org.springframework.data.mapping.model.MappingException: No mapping metadata found for class com.mongodb.BasicDBObject at org.springframework.data.mongodb.core.convert.MappingMongoConverter.createDBRef(MappingMongoConverter.java:729) 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.getMappedKeyword(QueryMapper.java:158) at org.springframework.data.mongodb.core.convert.QueryMapper.getMappedObject(QueryMapper.java:111) at org.springframework.data.mongodb.core.MongoTemplate.doFind(MongoTemplate.java:1489) at org.springframework.data.mongodb.core.MongoTemplate.doFind(MongoTemplate.java:1480) at org.springframework.data.mongodb.core.MongoTemplate.find(MongoTemplate.java:527) at org.springframework.data.mongodb.repository.query.AbstractMongoQuery$PagedExecution.execute(AbstractMongoQuery.java:205) at org.springframework.data.mongodb.repository.query.AbstractMongoQuery.execute(AbstractMongoQuery.java:93) at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:337) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204) … {noformat}

    Spring JIRA | 3 years ago | Marcin Kowalski
    org.springframework.data.mapping.model.MappingException: No mapping metadata found for class com.mongodb.BasicDBObject
  3. 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
  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

    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

    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 com.mongodb.BasicDBObject

      at org.springframework.data.mongodb.core.convert.MappingMongoConverter.createDBRef()
    2. Spring Data MongoDB - Core
      AbstractMongoQuery.execute
      1. org.springframework.data.mongodb.core.convert.MappingMongoConverter.createDBRef(MappingMongoConverter.java:729)
      2. org.springframework.data.mongodb.core.convert.MappingMongoConverter.toDBRef(MappingMongoConverter.java:288)
      3. org.springframework.data.mongodb.core.convert.QueryMapper.convertAssociation(QueryMapper.java:273)
      4. org.springframework.data.mongodb.core.convert.QueryMapper.getMappedKeyword(QueryMapper.java:158)
      5. org.springframework.data.mongodb.core.convert.QueryMapper.getMappedObject(QueryMapper.java:111)
      6. org.springframework.data.mongodb.core.MongoTemplate.doFind(MongoTemplate.java:1489)
      7. org.springframework.data.mongodb.core.MongoTemplate.doFind(MongoTemplate.java:1480)
      8. org.springframework.data.mongodb.core.MongoTemplate.find(MongoTemplate.java:527)
      9. org.springframework.data.mongodb.repository.query.AbstractMongoQuery$PagedExecution.execute(AbstractMongoQuery.java:205)
      10. org.springframework.data.mongodb.repository.query.AbstractMongoQuery.execute(AbstractMongoQuery.java:93)
      10 frames
    3. Spring Data Core
      RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke
      1. org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:337)
      1 frame
    4. Spring AOP
      JdkDynamicAopProxy.invoke
      1. org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
      2. org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
      2 frames