Uploaded image for project: 'Hibernate ORM'
  1. Hibernate ORM
  2. HHH-11284

Enhancer dirty tracking doesn't work with inherited entities

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 5.2.5
    • Fix Version/s: 5.2.7, 5.1.5
    • Component/s: bytecode-enhancement
    • Labels:
      None
    • Bug Testcase Reminder (view):

      Bug reports should generally be accompanied by a test case!

    • Last commented by a user?:
      true

      Description

      Given these two classes:

              @Entity private static abstract class Person {
      
                      @Id private String name;
      
                      @Version private long oca;
      
                      public Person(String name) {
                              this();
                              this.name = name;
                      }
      
                      protected Person() {}
      
                      protected void setOca(long l) {
                              this.oca = l;
                      }
              }
      
              @Entity private static class Employee extends Person {
      
                      private String title;
      
                      public Employee(String name, String title) {
                              super(name);
                              this.title = title;
                      }
      
                      public Employee() {}
      
                      public void setTitle(String title) {
                              this.title = title;
                      }
              }
      

      Then this code:

      Employee charles = new Employee( "Charles", "Engineer" );
      charles.setOca( 1002 );
      

      One would expect the "title" and "oca" fields to be dirty. However, Hibernate says only the "oca" field is dirty.

      It appears the enhancer's dirty checker doesn't correctly handle inherited fields.

      Here's a pull request which includes a test case demonstrating the issue: https://github.com/hibernate/hibernate-orm/pull/1654

        Attachments

          Issue links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: