org.springframework.data.mapping.model.MappingException: No id property found on class class [Ljava.lang.Integer;

Spring JIRA | Zhu Hongshang | 2 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

    spring-data-mongodb Query.fields().slice() on @DBRef field throws MappingException

    Stack Overflow | 2 years ago | zhsyourai
    org.springframework.data.mapping.model.MappingException: No id property found on class class [Ljava.lang.Integer;
  2. 0

    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} org.springframework.data.mapping.model.MappingException: No id property found on class class [Ljava.lang.Integer; at org.springframework.data.mongodb.core.convert.MappingMongoConverter.createDBRef(MappingMongoConverter.java:842) at org.springframework.data.mongodb.core.convert.MappingMongoConverter.toDBRef(MappingMongoConverter.java:329) at org.springframework.data.mongodb.core.convert.QueryMapper.createDbRefFor(QueryMapper.java:460) at org.springframework.data.mongodb.core.convert.QueryMapper.convertAssociation(QueryMapper.java:417) at org.springframework.data.mongodb.core.convert.QueryMapper.convertAssociation(QueryMapper.java:378) at org.springframework.data.mongodb.core.convert.QueryMapper.getMappedKeyword(QueryMapper.java:257) at org.springframework.data.mongodb.core.convert.QueryMapper.getMappedObjectForField(QueryMapper.java:200) at org.springframework.data.mongodb.core.convert.QueryMapper.getMappedObject(QueryMapper.java:123) at org.springframework.data.mongodb.core.MongoTemplate.doFindOne(MongoTemplate.java:1647) at org.springframework.data.mongodb.core.MongoTemplate.findOne(MongoTemplate.java:563) at org.springframework.data.mongodb.core.MongoTemplate.findOne(MongoTemplate.java:558) {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.

    Spring JIRA | 2 years ago | Zhu Hongshang
    org.springframework.data.mapping.model.MappingException: No id property found on class class [Ljava.lang.Integer;
  3. 0

    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} org.springframework.data.mapping.model.MappingException: No id property found on class class [Ljava.lang.Integer; at org.springframework.data.mongodb.core.convert.MappingMongoConverter.createDBRef(MappingMongoConverter.java:842) at org.springframework.data.mongodb.core.convert.MappingMongoConverter.toDBRef(MappingMongoConverter.java:329) at org.springframework.data.mongodb.core.convert.QueryMapper.createDbRefFor(QueryMapper.java:460) at org.springframework.data.mongodb.core.convert.QueryMapper.convertAssociation(QueryMapper.java:417) at org.springframework.data.mongodb.core.convert.QueryMapper.convertAssociation(QueryMapper.java:378) at org.springframework.data.mongodb.core.convert.QueryMapper.getMappedKeyword(QueryMapper.java:257) at org.springframework.data.mongodb.core.convert.QueryMapper.getMappedObjectForField(QueryMapper.java:200) at org.springframework.data.mongodb.core.convert.QueryMapper.getMappedObject(QueryMapper.java:123) at org.springframework.data.mongodb.core.MongoTemplate.doFindOne(MongoTemplate.java:1647) at org.springframework.data.mongodb.core.MongoTemplate.findOne(MongoTemplate.java:563) at org.springframework.data.mongodb.core.MongoTemplate.findOne(MongoTemplate.java:558) {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.

    Spring JIRA | 2 years ago | Zhu Hongshang
    org.springframework.data.mapping.model.MappingException: No id property found on class class [Ljava.lang.Integer;
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. org.springframework.data.mapping.model.MappingException

      No id property found on class class [Ljava.lang.Integer;

      at org.springframework.data.mongodb.core.convert.MappingMongoConverter.createDBRef()
    2. Spring Data MongoDB - Core
      MongoTemplate.findOne
      1. org.springframework.data.mongodb.core.convert.MappingMongoConverter.createDBRef(MappingMongoConverter.java:842)
      2. org.springframework.data.mongodb.core.convert.MappingMongoConverter.toDBRef(MappingMongoConverter.java:329)
      3. org.springframework.data.mongodb.core.convert.QueryMapper.createDbRefFor(QueryMapper.java:460)
      4. org.springframework.data.mongodb.core.convert.QueryMapper.convertAssociation(QueryMapper.java:417)
      5. org.springframework.data.mongodb.core.convert.QueryMapper.convertAssociation(QueryMapper.java:378)
      6. org.springframework.data.mongodb.core.convert.QueryMapper.getMappedKeyword(QueryMapper.java:257)
      7. org.springframework.data.mongodb.core.convert.QueryMapper.getMappedObjectForField(QueryMapper.java:200)
      8. org.springframework.data.mongodb.core.convert.QueryMapper.getMappedObject(QueryMapper.java:123)
      9. org.springframework.data.mongodb.core.MongoTemplate.doFindOne(MongoTemplate.java:1647)
      10. org.springframework.data.mongodb.core.MongoTemplate.findOne(MongoTemplate.java:563)
      11. org.springframework.data.mongodb.core.MongoTemplate.findOne(MongoTemplate.java:558)
      11 frames