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

Spring JIRA | Zhu Hongshang | 1 year ago
  1. 0

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

    Stack Overflow | 1 year 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 | 1 year 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 | 1 year 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

  5. 0

    MongoDB: $slice on embedded data throws MappingException

    Stack Overflow | 2 years ago | user3770946
    org.springframework.data.mapping.model.MappingException: No id property found on class class [Ljava.lang.Integer; at org.springframework.data.mongodb.core.convert.Mapp ingMongoConverter.createDBRef(MappingMongoConverte r.java:774) at org.springframework.data.mongodb.core.convert.Mapp ingMongoConverter.toDBRef(MappingMongoConverter.ja va:302) at org.springframework.data.mongodb.core.convert.Quer yMapper.createDbRefFor(QueryMapper.java:389) at org.springframework.data.mongodb.core.convert.Quer yMapper.convertAssociation(QueryMapper.java:346) at org.springframework.data.mongodb.core.convert.Quer yMapper.convertAssociation(QueryMapper.java:313) at org.springframework.data.mongodb.core.convert.Quer yMapper.getMappedKeyword(QueryMapper.java:193) at org.springframework.data.mongodb.core.convert.Quer yMapper.getMappedObjectForField(QueryMapper.java:1 36) at org.springframework.data.mongodb.core.convert.Quer yMapper.getMappedObject(QueryMapper.java:114)
  6. 0

    Spring data mongodb problems with @DBRef

    Stack Overflow | 1 year ago | Javier Oliver
    org.springframework.data.mapping.model.MappingException: No id property found on class class com.vexiza.web.vacunapp.domain.Region

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