org.springframework.data.mapping.model.MappingException: Cannot use a complex object as a key value.

Spring JIRA | Alexander Bätz | 4 years ago
  1. 0

    We want to store Domain-Objects that use complex classes as ids (every object has a property id that is a complex class) from Hazelcast. see project and projectId for an example. when we try and call save on the mongo-template with a complete object (with id). Call: MongoTemplate.save(object); Result: {code}org.springframework.data.mapping.model.MappingException: Cannot use a complex object as a key value. at org.springframework.data.mongodb.core.convert.MappingMongoConverter.writeMapInternal(MappingMongoConverter.java:525) ~[spring-data-mongodb-1.0.2.RELEASE.jar:na] at org.springframework.data.mongodb.core.convert.MappingMongoConverter.writePropertyInternal(MappingMongoConverter.java:385) ~[spring-data-mongodb-1.0.2.RELEASE.jar:na] at org.springframework.data.mongodb.core.convert.MappingMongoConverter$3.doWithPersistentProperty(MappingMongoConverter.java:346) ~[spring-data-mongodb-1.0.2.RELEASE.jar:na] at org.springframework.data.mongodb.core.convert.MappingMongoConverter$3.doWithPersistentProperty(MappingMongoConverter.java:335) ~[spring-data-mongodb-1.0.2.RELEASE.jar:na] at org.springframework.data.mapping.model.BasicPersistentEntity.doWithProperties(BasicPersistentEntity.java:173) ~[spring-data-commons-core-1.2.1.RELEASE.jar:na] at org.springframework.data.mongodb.core.convert.MappingMongoConverter.writeInternal(MappingMongoConverter.java:335) ~[spring-data-mongodb-1.0.2.RELEASE.jar:na] at org.springframework.data.mongodb.core.convert.MappingMongoConverter.writeInternal(MappingMongoConverter.java:307) ~[spring-data-mongodb-1.0.2.RELEASE.jar:na] at org.springframework.data.mongodb.core.convert.MappingMongoConverter.write(MappingMongoConverter.java:272) ~[spring-data-mongodb-1.0.2.RELEASE.jar:na] at org.springframework.data.mongodb.core.convert.MappingMongoConverter.write(MappingMongoConverter.java:73) ~[spring-data-mongodb-1.0.2.RELEASE.jar:na] at org.springframework.data.mongodb.core.MongoTemplate.doSave(MongoTemplate.java:718) ~[spring-data-mongodb-1.0.2.RELEASE.jar:na] at org.springframework.data.mongodb.core.MongoTemplate.save(MongoTemplate.java:708) ~[spring-data-mongodb-1.0.2.RELEASE.jar:na] at org.springframework.data.mongodb.core.MongoTemplate.save(MongoTemplate.java:704) ~[spring-data-mongodb-1.0.2.RELEASE.jar:na] at net.bigpoint.globalchat.hazelcast.MongoMapStore.store(MongoMapStore.java:86) [classes/:na] at net.bigpoint.globalchat.hazelcast.MongoMapStore.store(MongoMapStore.java:1) [classes/:na] at com.hazelcast.impl.concurrentmap.MapStoreWrapper.store(MapStoreWrapper.java:114) [hazelcast-2.1.2.jar:2.1.2] at com.hazelcast.impl.ConcurrentMapManager$PutOperationHandler$PutStorer.doMapStoreOperation(ConcurrentMapManager.java:2853) [hazelcast-2.1.2.jar:2.1.2] at com.hazelcast.impl.ConcurrentMapManager$AbstractMapStoreOperation.run(ConcurrentMapManager.java:3560) [hazelcast-2.1.2.jar:2.1.2] at com.hazelcast.impl.executor.ParallelExecutorService$ParallelExecutorImpl$ExecutionSegment.run(ParallelExecutorService.java:212) [hazelcast-2.1.2.jar:2.1.2] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) [na:1.7.0_04] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) [na:1.7.0_04] at java.lang.Thread.run(Thread.java:722) [na:1.7.0_04] at com.hazelcast.impl.ExecutorThreadFactory$1.run(ExecutorThreadFactory.java:38) [hazelcast-2.1.2.jar:2.1.2]{code}

    Spring JIRA | 4 years ago | Alexander Bätz
    org.springframework.data.mapping.model.MappingException: Cannot use a complex object as a key value.
  2. 0

    We want to store Domain-Objects that use complex classes as ids (every object has a property id that is a complex class) from Hazelcast. see project and projectId for an example. when we try and call save on the mongo-template with a complete object (with id). Call: MongoTemplate.save(object); Result: {code}org.springframework.data.mapping.model.MappingException: Cannot use a complex object as a key value. at org.springframework.data.mongodb.core.convert.MappingMongoConverter.writeMapInternal(MappingMongoConverter.java:525) ~[spring-data-mongodb-1.0.2.RELEASE.jar:na] at org.springframework.data.mongodb.core.convert.MappingMongoConverter.writePropertyInternal(MappingMongoConverter.java:385) ~[spring-data-mongodb-1.0.2.RELEASE.jar:na] at org.springframework.data.mongodb.core.convert.MappingMongoConverter$3.doWithPersistentProperty(MappingMongoConverter.java:346) ~[spring-data-mongodb-1.0.2.RELEASE.jar:na] at org.springframework.data.mongodb.core.convert.MappingMongoConverter$3.doWithPersistentProperty(MappingMongoConverter.java:335) ~[spring-data-mongodb-1.0.2.RELEASE.jar:na] at org.springframework.data.mapping.model.BasicPersistentEntity.doWithProperties(BasicPersistentEntity.java:173) ~[spring-data-commons-core-1.2.1.RELEASE.jar:na] at org.springframework.data.mongodb.core.convert.MappingMongoConverter.writeInternal(MappingMongoConverter.java:335) ~[spring-data-mongodb-1.0.2.RELEASE.jar:na] at org.springframework.data.mongodb.core.convert.MappingMongoConverter.writeInternal(MappingMongoConverter.java:307) ~[spring-data-mongodb-1.0.2.RELEASE.jar:na] at org.springframework.data.mongodb.core.convert.MappingMongoConverter.write(MappingMongoConverter.java:272) ~[spring-data-mongodb-1.0.2.RELEASE.jar:na] at org.springframework.data.mongodb.core.convert.MappingMongoConverter.write(MappingMongoConverter.java:73) ~[spring-data-mongodb-1.0.2.RELEASE.jar:na] at org.springframework.data.mongodb.core.MongoTemplate.doSave(MongoTemplate.java:718) ~[spring-data-mongodb-1.0.2.RELEASE.jar:na] at org.springframework.data.mongodb.core.MongoTemplate.save(MongoTemplate.java:708) ~[spring-data-mongodb-1.0.2.RELEASE.jar:na] at org.springframework.data.mongodb.core.MongoTemplate.save(MongoTemplate.java:704) ~[spring-data-mongodb-1.0.2.RELEASE.jar:na] at net.bigpoint.globalchat.hazelcast.MongoMapStore.store(MongoMapStore.java:86) [classes/:na] at net.bigpoint.globalchat.hazelcast.MongoMapStore.store(MongoMapStore.java:1) [classes/:na] at com.hazelcast.impl.concurrentmap.MapStoreWrapper.store(MapStoreWrapper.java:114) [hazelcast-2.1.2.jar:2.1.2] at com.hazelcast.impl.ConcurrentMapManager$PutOperationHandler$PutStorer.doMapStoreOperation(ConcurrentMapManager.java:2853) [hazelcast-2.1.2.jar:2.1.2] at com.hazelcast.impl.ConcurrentMapManager$AbstractMapStoreOperation.run(ConcurrentMapManager.java:3560) [hazelcast-2.1.2.jar:2.1.2] at com.hazelcast.impl.executor.ParallelExecutorService$ParallelExecutorImpl$ExecutionSegment.run(ParallelExecutorService.java:212) [hazelcast-2.1.2.jar:2.1.2] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) [na:1.7.0_04] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) [na:1.7.0_04] at java.lang.Thread.run(Thread.java:722) [na:1.7.0_04] at com.hazelcast.impl.ExecutorThreadFactory$1.run(ExecutorThreadFactory.java:38) [hazelcast-2.1.2.jar:2.1.2]{code}

    Spring JIRA | 4 years ago | Alexander Bätz
    org.springframework.data.mapping.model.MappingException: Cannot use a complex object as a key value.
  3. 0

    How to configure handling of Map Properties

    Stack Overflow | 5 years ago | Laures
    org.springframework.data.mapping.model.MappingException: Map key net.bigpoint.globalchat.models.keys.ProjectId@0 contains dots but no replacement was configured! Make sure map keys don't contain dots in the first place or configure an appropriate replacement!
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Spring Data (mongoDb) + @Id element + EJB + DBRef. Cannot create a reference to an object with a NULL id

    Stack Overflow | 2 years ago | ginxo
    org.springframework.data.mapping.model.MappingException: Cannot create a reference to an object with a NULL id.

    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

      Cannot use a complex object as a key value.

      at org.springframework.data.mongodb.core.convert.MappingMongoConverter.writeMapInternal()
    2. Spring Data MongoDB - Core
      MappingMongoConverter$3.doWithPersistentProperty
      1. org.springframework.data.mongodb.core.convert.MappingMongoConverter.writeMapInternal(MappingMongoConverter.java:525)[spring-data-mongodb-1.0.2.RELEASE.jar:na]
      2. org.springframework.data.mongodb.core.convert.MappingMongoConverter.writePropertyInternal(MappingMongoConverter.java:385)[spring-data-mongodb-1.0.2.RELEASE.jar:na]
      3. org.springframework.data.mongodb.core.convert.MappingMongoConverter$3.doWithPersistentProperty(MappingMongoConverter.java:346)[spring-data-mongodb-1.0.2.RELEASE.jar:na]
      4. org.springframework.data.mongodb.core.convert.MappingMongoConverter$3.doWithPersistentProperty(MappingMongoConverter.java:335)[spring-data-mongodb-1.0.2.RELEASE.jar:na]
      4 frames
    3. Spring Data Core
      BasicPersistentEntity.doWithProperties
      1. org.springframework.data.mapping.model.BasicPersistentEntity.doWithProperties(BasicPersistentEntity.java:173)[spring-data-commons-core-1.2.1.RELEASE.jar:na]
      1 frame
    4. Spring Data MongoDB - Core
      MongoTemplate.save
      1. org.springframework.data.mongodb.core.convert.MappingMongoConverter.writeInternal(MappingMongoConverter.java:335)[spring-data-mongodb-1.0.2.RELEASE.jar:na]
      2. org.springframework.data.mongodb.core.convert.MappingMongoConverter.writeInternal(MappingMongoConverter.java:307)[spring-data-mongodb-1.0.2.RELEASE.jar:na]
      3. org.springframework.data.mongodb.core.convert.MappingMongoConverter.write(MappingMongoConverter.java:272)[spring-data-mongodb-1.0.2.RELEASE.jar:na]
      4. org.springframework.data.mongodb.core.convert.MappingMongoConverter.write(MappingMongoConverter.java:73)[spring-data-mongodb-1.0.2.RELEASE.jar:na]
      5. org.springframework.data.mongodb.core.MongoTemplate.doSave(MongoTemplate.java:718)[spring-data-mongodb-1.0.2.RELEASE.jar:na]
      6. org.springframework.data.mongodb.core.MongoTemplate.save(MongoTemplate.java:708)[spring-data-mongodb-1.0.2.RELEASE.jar:na]
      7. org.springframework.data.mongodb.core.MongoTemplate.save(MongoTemplate.java:704)[spring-data-mongodb-1.0.2.RELEASE.jar:na]
      7 frames
    5. net.bigpoint.globalchat
      MongoMapStore.store
      1. net.bigpoint.globalchat.hazelcast.MongoMapStore.store(MongoMapStore.java:86)[classes/:na]
      2. net.bigpoint.globalchat.hazelcast.MongoMapStore.store(MongoMapStore.java:1)[classes/:na]
      2 frames
    6. hazelcast
      ParallelExecutorService$ParallelExecutorImpl$ExecutionSegment.run
      1. com.hazelcast.impl.concurrentmap.MapStoreWrapper.store(MapStoreWrapper.java:114)[hazelcast-2.1.2.jar:2.1.2]
      2. com.hazelcast.impl.ConcurrentMapManager$PutOperationHandler$PutStorer.doMapStoreOperation(ConcurrentMapManager.java:2853)[hazelcast-2.1.2.jar:2.1.2]
      3. com.hazelcast.impl.ConcurrentMapManager$AbstractMapStoreOperation.run(ConcurrentMapManager.java:3560)[hazelcast-2.1.2.jar:2.1.2]
      4. com.hazelcast.impl.executor.ParallelExecutorService$ParallelExecutorImpl$ExecutionSegment.run(ParallelExecutorService.java:212)[hazelcast-2.1.2.jar:2.1.2]
      4 frames
    7. Java RT
      Thread.run
      1. java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)[na:1.7.0_04]
      2. java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)[na:1.7.0_04]
      3. java.lang.Thread.run(Thread.java:722)[na:1.7.0_04]
      3 frames