java.lang.NullPointerException: null

Spring JIRA | Benjamin M | 1 year ago
  1. 0

    Following code throws a NullPointerException: {code} mongoOperations.updateFirst( new Query(), new Update().set("date", null), TestEntity.class ); {code} Where {{TestEntity}} simply this: {code} @Document(collection="test") public class TestEntity { @Id private String id; public String getId() { return id; } private LocalDate date; public LocalDate getDate() { return date; } public void setDate(LocalDate date) { this.date = date; } } {code} StackTrace: {code} java.lang.NullPointerException: null at org.springframework.data.mongodb.core.convert.UpdateMapper.processTypeHintForNestedDocuments(UpdateMapper.java:155) at org.springframework.data.mongodb.core.convert.UpdateMapper.getTypeHintForEntity(UpdateMapper.java:145) at org.springframework.data.mongodb.core.convert.UpdateMapper.delegateConvertToMongoType(UpdateMapper.java:70) at org.springframework.data.mongodb.core.convert.QueryMapper.convertSimpleOrDBObject(QueryMapper.java:362) at org.springframework.data.mongodb.core.convert.QueryMapper.getMappedValue(QueryMapper.java:308) at org.springframework.data.mongodb.core.convert.UpdateMapper.getMappedObjectForField(UpdateMapper.java:93) at org.springframework.data.mongodb.core.convert.QueryMapper.getMappedObject(QueryMapper.java:123) at org.springframework.data.mongodb.core.convert.QueryMapper.convertSimpleOrDBObject(QueryMapper.java:359) at org.springframework.data.mongodb.core.convert.QueryMapper.getMappedKeyword(QueryMapper.java:242) at org.springframework.data.mongodb.core.convert.QueryMapper.getMappedObject(QueryMapper.java:100) at org.springframework.data.mongodb.core.MongoTemplate$12.doInCollection(MongoTemplate.java:1095) at org.springframework.data.mongodb.core.MongoTemplate$12.doInCollection(MongoTemplate.java:1086) at org.springframework.data.mongodb.core.MongoTemplate.execute(MongoTemplate.java:461) at org.springframework.data.mongodb.core.MongoTemplate.doUpdate(MongoTemplate.java:1086) at org.springframework.data.mongodb.core.MongoTemplate.updateFirst(MongoTemplate.java:1060) {code} Using {{mongoOperations.save / insert}} works as expected. And using field of type String works as well. I tried to debug it, but I can't figure out why this happens. It looks like it treats {{LocalDate}} as a {{MongoPersistentEntity}}, but it doesn't do that for a {{String}} ?! I also tried to provide my own Converter for {{LocalDate}} to {{Date}} and backwords, but this results in the same exception. Here's the full code: http://pastebin.com/xEq54Umh And pom.xml: http://pastebin.com/wDhWzx8s It also happens with mongo-java-driver 2.12.5 and/or spring-data-mongodb 1.6.3

    Spring JIRA | 1 year ago | Benjamin M
    java.lang.NullPointerException: null
  2. 0

    Following code throws a NullPointerException: {code} mongoOperations.updateFirst( new Query(), new Update().set("date", null), TestEntity.class ); {code} Where {{TestEntity}} simply this: {code} @Document(collection="test") public class TestEntity { @Id private String id; public String getId() { return id; } private LocalDate date; public LocalDate getDate() { return date; } public void setDate(LocalDate date) { this.date = date; } } {code} StackTrace: {code} java.lang.NullPointerException: null at org.springframework.data.mongodb.core.convert.UpdateMapper.processTypeHintForNestedDocuments(UpdateMapper.java:155) at org.springframework.data.mongodb.core.convert.UpdateMapper.getTypeHintForEntity(UpdateMapper.java:145) at org.springframework.data.mongodb.core.convert.UpdateMapper.delegateConvertToMongoType(UpdateMapper.java:70) at org.springframework.data.mongodb.core.convert.QueryMapper.convertSimpleOrDBObject(QueryMapper.java:362) at org.springframework.data.mongodb.core.convert.QueryMapper.getMappedValue(QueryMapper.java:308) at org.springframework.data.mongodb.core.convert.UpdateMapper.getMappedObjectForField(UpdateMapper.java:93) at org.springframework.data.mongodb.core.convert.QueryMapper.getMappedObject(QueryMapper.java:123) at org.springframework.data.mongodb.core.convert.QueryMapper.convertSimpleOrDBObject(QueryMapper.java:359) at org.springframework.data.mongodb.core.convert.QueryMapper.getMappedKeyword(QueryMapper.java:242) at org.springframework.data.mongodb.core.convert.QueryMapper.getMappedObject(QueryMapper.java:100) at org.springframework.data.mongodb.core.MongoTemplate$12.doInCollection(MongoTemplate.java:1095) at org.springframework.data.mongodb.core.MongoTemplate$12.doInCollection(MongoTemplate.java:1086) at org.springframework.data.mongodb.core.MongoTemplate.execute(MongoTemplate.java:461) at org.springframework.data.mongodb.core.MongoTemplate.doUpdate(MongoTemplate.java:1086) at org.springframework.data.mongodb.core.MongoTemplate.updateFirst(MongoTemplate.java:1060) {code} Using {{mongoOperations.save / insert}} works as expected. And using field of type String works as well. I tried to debug it, but I can't figure out why this happens. It looks like it treats {{LocalDate}} as a {{MongoPersistentEntity}}, but it doesn't do that for a {{String}} ?! I also tried to provide my own Converter for {{LocalDate}} to {{Date}} and backwords, but this results in the same exception. Here's the full code: http://pastebin.com/xEq54Umh And pom.xml: http://pastebin.com/wDhWzx8s It also happens with mongo-java-driver 2.12.5 and/or spring-data-mongodb 1.6.3

    Spring JIRA | 1 year ago | Benjamin M
    java.lang.NullPointerException: null
  3. 0

    HQL Exception (org.hibernate.dialect.Dialect$3)

    Stack Overflow | 4 years ago | Hari
    java.lang.NullPointerException: null
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Error loading model properties in JPA on play 2.0.3

    Stack Overflow | 4 years ago | Chappies
    java.lang.NullPointerException: null

    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. java.lang.NullPointerException

      null

      at org.springframework.data.mongodb.core.convert.UpdateMapper.processTypeHintForNestedDocuments()
    2. Spring Data MongoDB - Core
      MongoTemplate.updateFirst
      1. org.springframework.data.mongodb.core.convert.UpdateMapper.processTypeHintForNestedDocuments(UpdateMapper.java:155)
      2. org.springframework.data.mongodb.core.convert.UpdateMapper.getTypeHintForEntity(UpdateMapper.java:145)
      3. org.springframework.data.mongodb.core.convert.UpdateMapper.delegateConvertToMongoType(UpdateMapper.java:70)
      4. org.springframework.data.mongodb.core.convert.QueryMapper.convertSimpleOrDBObject(QueryMapper.java:362)
      5. org.springframework.data.mongodb.core.convert.QueryMapper.getMappedValue(QueryMapper.java:308)
      6. org.springframework.data.mongodb.core.convert.UpdateMapper.getMappedObjectForField(UpdateMapper.java:93)
      7. org.springframework.data.mongodb.core.convert.QueryMapper.getMappedObject(QueryMapper.java:123)
      8. org.springframework.data.mongodb.core.convert.QueryMapper.convertSimpleOrDBObject(QueryMapper.java:359)
      9. org.springframework.data.mongodb.core.convert.QueryMapper.getMappedKeyword(QueryMapper.java:242)
      10. org.springframework.data.mongodb.core.convert.QueryMapper.getMappedObject(QueryMapper.java:100)
      11. org.springframework.data.mongodb.core.MongoTemplate$12.doInCollection(MongoTemplate.java:1095)
      12. org.springframework.data.mongodb.core.MongoTemplate$12.doInCollection(MongoTemplate.java:1086)
      13. org.springframework.data.mongodb.core.MongoTemplate.execute(MongoTemplate.java:461)
      14. org.springframework.data.mongodb.core.MongoTemplate.doUpdate(MongoTemplate.java:1086)
      15. org.springframework.data.mongodb.core.MongoTemplate.updateFirst(MongoTemplate.java:1060)
      15 frames