There are no available Samebug tips for this exception. Do you have an idea how to solve this issue? A short tip would help users who saw this issue last week.

  • 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: No mapping metadata found for class java.lang.Integer at at com.digitalshadows.collation.persistence.impl.CollectionNameProvidedMongoConverter.createDBRef( at at at at at at at at ExcludeDBRefFieldTest.testExcludeChildren( 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( at at org.junit.runners.model.FrameworkMethod.invokeExplosively( at org.junit.internal.runners.statements.InvokeMethod.evaluate( at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate( at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate( at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate( at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild( at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild( at org.junit.runners.ParentRunner$ at org.junit.runners.ParentRunner$1.schedule( at org.junit.runners.ParentRunner.runChildren( at org.junit.runners.ParentRunner.access$000( at org.junit.runners.ParentRunner$2.evaluate( at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate( at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate( at at at at at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests( at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests( at at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main( 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.
    via by Catherine Howe,
  • 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} No mapping metadata found for class java.lang.Integer at ~[spring-data-mongodb-1.3.1.RELEASE.jar:na] at ~[spring-data-mongodb-1.3.1.RELEASE.jar:na] at ~[spring-data-mongodb-1.3.1.RELEASE.jar:na] at ~[spring-data-mongodb-1.3.1.RELEASE.jar:na] at ~[spring-data-mongodb-1.3.1.RELEASE.jar:na] at ~[spring-data-mongodb-1.3.1.RELEASE.jar:na] at ~[spring-data-mongodb-1.3.1.RELEASE.jar:na] {noformat} This issue is related to [DATAMONGO-702|]
    via by Matej Zachar,
  • 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" No mapping metadata found for class com.mongodb.BasicDBObject at at at at at at at at at$PagedExecution.execute( at at$QueryExecutorMethodInterceptor.invoke( at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed( at org.springframework.aop.framework.JdkDynamicAopProxy.invoke( … {noformat}
    via by Marcin Kowalski,
  • There is a model is like: {code:java} class Model { .... @DBRef List<OtherModel> members; ... } {code} and I need sliced access to the members variable. I use this query: {code:java} ObjectId objectId = new ObjectId("55c36f44f359d8a455a21f68"); Query query = new Query(Criteria.where("_id").is(objectId)); query.fields().slice("members", pageable.getOffset(), pageable.getPageSize()); List<Model> models = mongoTemplate.findOne(query, Model.class); {code} And I get this exception: {code:java} No id property found on class class [Ljava.lang.Integer; at at at at at at at at at at at {code} where a field: {code:java} boolean needsAssociationConversion = property.isAssociation() && !keyword.isExists(); {code} is set. It checks against isExists, but not against something like isSliced (which does not yet exist) and therefore is evaluated to true and, as a cause, tries to convert the non-existing association which is, in this case, just the slice-directive (an integer array). When I set the variable needsAssociationConversion to false while debugging, as if a kind of {code:java} keyword.isSlice() {code} check was done, everything works fine.
    via by Zhu Hongshang,
    • Cannot create a reference to an object with a NULL id. at at

    Users with the same issue

    Unknown visitor1 times, last one,
    Unknown visitor1 times, last one,
    Unknown visitor1 times, last one,