org.springframework.data.mapping.model.MappingException: Cannot create a reference to an object with a NULL id.

Spring JIRA | John Souza | 3 years ago
  1. 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.
  2. Speed up your debug routine!

    Automated exception search integrated into your IDE

  3. 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.
  4. 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.

    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 create a reference to an object with a NULL id.

      at org.springframework.data.mongodb.core.convert.MappingMongoConverter.createDBRef()
    2. Spring Data MongoDB - Core
      MappingMongoConverter.toDBRef
      1. org.springframework.data.mongodb.core.convert.MappingMongoConverter.createDBRef(MappingMongoConverter.java:800)
      2. org.springframework.data.mongodb.core.convert.MappingMongoConverter.toDBRef(MappingMongoConverter.java:311)
      2 frames