Hibernate 4 bytecode enhancement not working for dirty checking optimization

后端 未结 2 1285
星月不相逢
星月不相逢 2021-02-02 08:07

I am using the Hibernate 4.3.6 and I made use of the latest Maven bytecode enhancement to instrument all entities for self dirtiness awareness.

I added the maven plugin:

2条回答
  •  灰色年华
    2021-02-02 08:22

    Hibernate 5 fixes this issue and now the dirty checking for a setter looks like this:

    public void $$_hibernate_write_title(String paramString)
    {
        if (!EqualsHelper.areEqual(this.title, paramString)) {
          $$_hibernate_trackChange("title");
        }
        this.title = paramString;
    }
    
    public void $$_hibernate_trackChange(String paramString)
    {
        if (this.$$_hibernate_tracker == null) {
          this.$$_hibernate_tracker = new SimpleFieldTracker();
        }
        this.$$_hibernate_tracker.add(paramString);
    }
    

    So, the solution is an upgrade to Hibernate 5.

提交回复
热议问题