java.lang.NullPointerException

Hibernate JIRA | Gábor Varga | 10 months ago
  1. 0

    When the in-line dirty tracking bytecode enhancement is enabled (the {{enableDirtyTracking}} parameter of the {{hibernate-enhance-maven-plugin}}'s configuration is {{true}}), and an entity with an {{@Embeddable}} property is constructed by setting this field to {{null}} in the constructor, a {{NullPointerException}} is thrown from the following location: {code:none} java.lang.NullPointerException at com.example.model.MyTestEntity.$$_hibernate_write_myTestEmbeddable(MyTestEntity.java) at com.example.model.MyTestEntity.<init>(MyTestEntity.java:37) {code} The interesting code snippets in the bytecode enhanced entity are as follows: {code:java} private MyTestEmbeddable myTestEmbeddable; @Transient private transient PersistentAttributeInterceptor $$_hibernate_attributeInterceptor; public MyTestEntity(Long id, Integer myTestInteger, MyTestEmbeddable myTestEmbeddable) { this.$$_hibernate_write_id(id); this.$$_hibernate_write_myTestInteger(myTestInteger); this.$$_hibernate_write_myTestEmbeddable(myTestEmbeddable); } public PersistentAttributeInterceptor $$_hibernate_getInterceptor() { return this.$$_hibernate_attributeInterceptor; } public void $$_hibernate_write_myTestEmbeddable(MyTestEmbeddable myTestEmbeddable) { // #1 if (this.myTestEmbeddable != null) { ((CompositeTracker)this.myTestEmbeddable).$$_hibernate_clearOwner("myTestEmbeddable"); } // #2 if (!EqualsHelper.areEqual((Object)this.myTestEmbeddable, (Object)myTestEmbeddable)) { this.$$_hibernate_trackChange("myTestEmbeddable"); } // #3 MyTestEmbeddable myTestEmbeddable2 = myTestEmbeddable; // #4 if (this.$$_hibernate_getInterceptor() != null) { myTestEmbeddable2 = (MyTestEmbeddable)this.$$_hibernate_getInterceptor().writeObject((Object)this, "myTestEmbeddable", (Object)this.myTestEmbeddable, (Object)myTestEmbeddable); } // #5 this.myTestEmbeddable = myTestEmbeddable2; // #6 Object var4_3 = null; // #7 ((CompositeTracker)this.myTestEmbeddable).$$_hibernate_setOwner("myTestEmbeddable", (CompositeOwner)this); // #8 this.$$_hibernate_trackChange("myTestEmbeddable"); } {code} The {{myTestEmbeddable}} argument of the constructor is {{null}}, so {{$$_hibernate_write_myTestEmbeddable()}} is called with a {{null}} argument. The {{$$_hibernate_attributeInterceptor}} field is not initialized in the constructor, so {{$$_hibernate_getInterceptor()}} always returns {{null}}. Because of this, the conditional code _#4_ is not run. In _#3_, the {{null}} argument is written to a temporary variable, and then in _#5_, it's written to the {{myTestEmbeddable}} field. Afterwards in _#7_, it's being cast to {{CompositeTracker}}, and its [{{$$_hibernate_setOwner}}|https://github.com/hibernate/hibernate-orm/blob/5.0.8/hibernate-core/src/main/java/org/hibernate/bytecode/enhance/internal/PersistentAttributesEnhancer.java#L449] is called, while the field is still {{null}}. I think this is what throws the {{NullPointerException}}. The Java source files of the original and bytecode enhanced {{@Entity}} and {{@Embeddable}} classes are attached to this ticket. The {{hibernate-enhance-maven-plugin}} configuration was as follows: {code:xml} <configuration> <enableLazyInitialization>true</enableLazyInitialization> <enableDirtyTracking>true</enableDirtyTracking> <enableAssociationManagement>false</enableAssociationManagement> <enableExtendedEnhancement>false</enableExtendedEnhancement> </configuration> {code} The description above is valid for Hibernate 5.0.8, but the same {{NullPointerException}} occurs when using Hibernate 5.1.0.

    Hibernate JIRA | 10 months ago | Gábor Varga
    java.lang.NullPointerException
  2. 0

    When the in-line dirty tracking bytecode enhancement is enabled (the {{enableDirtyTracking}} parameter of the {{hibernate-enhance-maven-plugin}}'s configuration is {{true}}), and an entity with an {{@Embeddable}} property is constructed by setting this field to {{null}} in the constructor, a {{NullPointerException}} is thrown from the following location: {code:none} java.lang.NullPointerException at com.example.model.MyTestEntity.$$_hibernate_write_myTestEmbeddable(MyTestEntity.java) at com.example.model.MyTestEntity.<init>(MyTestEntity.java:37) {code} The interesting code snippets in the bytecode enhanced entity are as follows: {code:java} private MyTestEmbeddable myTestEmbeddable; @Transient private transient PersistentAttributeInterceptor $$_hibernate_attributeInterceptor; public MyTestEntity(Long id, Integer myTestInteger, MyTestEmbeddable myTestEmbeddable) { this.$$_hibernate_write_id(id); this.$$_hibernate_write_myTestInteger(myTestInteger); this.$$_hibernate_write_myTestEmbeddable(myTestEmbeddable); } public PersistentAttributeInterceptor $$_hibernate_getInterceptor() { return this.$$_hibernate_attributeInterceptor; } public void $$_hibernate_write_myTestEmbeddable(MyTestEmbeddable myTestEmbeddable) { // #1 if (this.myTestEmbeddable != null) { ((CompositeTracker)this.myTestEmbeddable).$$_hibernate_clearOwner("myTestEmbeddable"); } // #2 if (!EqualsHelper.areEqual((Object)this.myTestEmbeddable, (Object)myTestEmbeddable)) { this.$$_hibernate_trackChange("myTestEmbeddable"); } // #3 MyTestEmbeddable myTestEmbeddable2 = myTestEmbeddable; // #4 if (this.$$_hibernate_getInterceptor() != null) { myTestEmbeddable2 = (MyTestEmbeddable)this.$$_hibernate_getInterceptor().writeObject((Object)this, "myTestEmbeddable", (Object)this.myTestEmbeddable, (Object)myTestEmbeddable); } // #5 this.myTestEmbeddable = myTestEmbeddable2; // #6 Object var4_3 = null; // #7 ((CompositeTracker)this.myTestEmbeddable).$$_hibernate_setOwner("myTestEmbeddable", (CompositeOwner)this); // #8 this.$$_hibernate_trackChange("myTestEmbeddable"); } {code} The {{myTestEmbeddable}} argument of the constructor is {{null}}, so {{$$_hibernate_write_myTestEmbeddable()}} is called with a {{null}} argument. The {{$$_hibernate_attributeInterceptor}} field is not initialized in the constructor, so {{$$_hibernate_getInterceptor()}} always returns {{null}}. Because of this, the conditional code _#4_ is not run. In _#3_, the {{null}} argument is written to a temporary variable, and then in _#5_, it's written to the {{myTestEmbeddable}} field. Afterwards in _#7_, it's being cast to {{CompositeTracker}}, and its [{{$$_hibernate_setOwner}}|https://github.com/hibernate/hibernate-orm/blob/5.0.8/hibernate-core/src/main/java/org/hibernate/bytecode/enhance/internal/PersistentAttributesEnhancer.java#L449] is called, while the field is still {{null}}. I think this is what throws the {{NullPointerException}}. The Java source files of the original and bytecode enhanced {{@Entity}} and {{@Embeddable}} classes are attached to this ticket. The {{hibernate-enhance-maven-plugin}} configuration was as follows: {code:xml} <configuration> <enableLazyInitialization>true</enableLazyInitialization> <enableDirtyTracking>true</enableDirtyTracking> <enableAssociationManagement>false</enableAssociationManagement> <enableExtendedEnhancement>false</enableExtendedEnhancement> </configuration> {code} The description above is valid for Hibernate 5.0.8, but the same {{NullPointerException}} occurs when using Hibernate 5.1.0.

    Hibernate JIRA | 10 months ago | Gábor Varga
    java.lang.NullPointerException
  3. 0

    Android: Saving Map State in Google map

    Stack Overflow | 11 months ago | Junie Negentien
    java.lang.RuntimeException: Unable to resume activity {com.ourThesis.junieNegentien2015/com.ourThesis.junieNegentien2015.MainActivity}: java.lang.NullPointerException
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

    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

      No message provided

      at com.example.model.MyTestEntity.$$_hibernate_write_myTestEmbeddable()
    2. com.example.model
      MyTestEntity.<init>
      1. com.example.model.MyTestEntity.$$_hibernate_write_myTestEmbeddable(MyTestEntity.java)
      2. com.example.model.MyTestEntity.<init>(MyTestEntity.java:37)
      2 frames