一个神奇问题-应用程序组件实体继承问题

cuba.rar (301.3 KB)

发现一个神奇的Bug,两个代码一模一样的项目,编译并发布成应用程序组件以后,反编译出来的有很大差异,导致导致组件中的Bill类无法正常被继承,两种编码随机出现

Bill1

    //
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package com.company.bill.entity;

import com.haulmont.chile.core.annotations.MetaClass;
import com.haulmont.chile.core.model.utils.InstanceUtils;
import com.haulmont.cuba.core.entity.StandardEntity;
import com.haulmont.cuba.core.entity.annotation.OnDelete;
import com.haulmont.cuba.core.entity.annotation.OnDeleteInverse;
import com.haulmont.cuba.core.entity.annotation.UnavailableInSecurityConstraints;
import com.haulmont.cuba.core.global.DeletePolicy;
import com.haulmont.cuba.core.sys.CubaEnhanced;
import com.haulmont.cuba.security.entity.Group;
import javax.persistence.Column;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.MappedSuperclass;
import javax.persistence.Transient;
import javax.xml.bind.annotation.XmlTransient;
import org.eclipse.persistence.indirection.ValueHolder;
import org.eclipse.persistence.indirection.WeavedAttributeValueHolderInterface;
import org.eclipse.persistence.internal.descriptors.PersistenceObject;
import org.eclipse.persistence.internal.weaving.PersistenceWeaved;
import org.eclipse.persistence.internal.weaving.PersistenceWeavedChangeTracking;
import org.eclipse.persistence.internal.weaving.PersistenceWeavedFetchGroups;
import org.eclipse.persistence.internal.weaving.PersistenceWeavedLazy;

@MappedSuperclass
@MetaClass(
    name = "bill_Bill"
)
@UnavailableInSecurityConstraints
public class Bill extends StandardEntity implements PersistenceWeaved, PersistenceObject, PersistenceWeavedFetchGroups, PersistenceWeavedLazy, PersistenceWeavedChangeTracking, CubaEnhanced {
    private static final long serialVersionUID = 7342884335729454184L;
    @Column(
        name = "CODE"
    )
    protected String code;
    @Column(
        name = "NAME"
    )
    protected String name;
    @OnDeleteInverse(DeletePolicy.UNLINK)
    @OnDelete(DeletePolicy.UNLINK)
    @ManyToOne(
        fetch = FetchType.LAZY
    )
    @JoinColumn(
        name = "GROUP_ID"
    )
    protected Group group;
    @Transient
    @XmlTransient
    protected WeavedAttributeValueHolderInterface _persistence_group_vh;

    public Bill() {
    }

    public Group getGroup() {
        return this._persistence_get_group();
    }

    public void setGroup(Group group) {
        Group __prev = this.getGroup();
        this._persistence_set_group(group);
        Object var5 = null;
        Group __new = this.getGroup();
        if (!InstanceUtils.propertyValueEquals(__prev, __new)) {
            this.propertyChanged("group", __prev, __new);
        }

    }

    public String getName() {
        return this._persistence_get_name();
    }

    public void setName(String name) {
        String __prev = this.getName();
        this._persistence_set_name(name);
        Object var5 = null;
        String __new = this.getName();
        if (!InstanceUtils.propertyValueEquals(__prev, __new)) {
            this.propertyChanged("name", __prev, __new);
        }

    }

    public String getCode() {
        return this._persistence_get_code();
    }

    public void setCode(String code) {
        String __prev = this.getCode();
        this._persistence_set_code(code);
        Object var5 = null;
        String __new = this.getCode();
        if (!InstanceUtils.propertyValueEquals(__prev, __new)) {
            this.propertyChanged("code", __prev, __new);
        }

    }

    public Object _persistence_post_clone() {
        super._persistence_post_clone();
        if (this._persistence_group_vh != null) {
            this._persistence_group_vh = (WeavedAttributeValueHolderInterface)this._persistence_group_vh.clone();
        }

        this._persistence_listener = null;
        this._persistence_fetchGroup = null;
        this._persistence_session = null;
        this._persistence_primaryKey = null;
        return this;
    }

    public Object _persistence_new(PersistenceObject var1) {
        return new Bill();
    }

    public Object _persistence_get(String var1) {
        if (var1 == "code") {
            return this.code;
        } else if (var1 == "name") {
            return this.name;
        } else {
            return var1 == "group" ? this.group : super._persistence_get(var1);
        }
    }

    public void _persistence_set(String var1, Object var2) {
        if (var1 == "code") {
            this.code = (String)var2;
        } else if (var1 == "name") {
            this.name = (String)var2;
        } else if (var1 == "group") {
            this.group = (Group)var2;
        } else {
            super._persistence_set(var1, var2);
        }
    }

    protected String _persistence_get_code() {
        this._persistence_checkFetched("code");
        return this.code;
    }

    protected void _persistence_set_code(String var1) {
        this._persistence_checkFetchedForSet("code");
        this._persistence_propertyChange("code", this.code, var1);
        this.code = var1;
    }

    protected String _persistence_get_name() {
        this._persistence_checkFetched("name");
        return this.name;
    }

    protected void _persistence_set_name(String var1) {
        this._persistence_checkFetchedForSet("name");
        this._persistence_propertyChange("name", this.name, var1);
        this.name = var1;
    }

    protected void _persistence_initialize_group_vh() {
        if (this._persistence_group_vh == null) {
            this._persistence_group_vh = new ValueHolder(this.group);
            this._persistence_group_vh.setIsNewlyWeavedValueHolder(true);
        }

    }

    protected WeavedAttributeValueHolderInterface _persistence_get_group_vh() {
        this._persistence_initialize_group_vh();
        if (this._persistence_group_vh.isCoordinatedWithProperty() || this._persistence_group_vh.isNewlyWeavedValueHolder()) {
            Group var1 = this._persistence_get_group();
            if (var1 != this._persistence_group_vh.getValue()) {
                this._persistence_set_group(var1);
            }
        }

        return this._persistence_group_vh;
    }

    protected void _persistence_set_group_vh(WeavedAttributeValueHolderInterface var1) {
        this._persistence_group_vh = var1;
        if (var1.isInstantiated()) {
            Group var2 = this._persistence_get_group();
            Object var3 = var1.getValue();
            if (var2 != var3) {
                this._persistence_set_group((Group)var3);
            }
        } else {
            this.group = null;
        }

    }

    protected Group _persistence_get_group() {
        this._persistence_checkFetched("group");
        this._persistence_initialize_group_vh();
        this.group = (Group)this._persistence_group_vh.getValue();
        return this.group;
    }

    protected void _persistence_set_group(Group var1) {
        this._persistence_checkFetchedForSet("group");
        this._persistence_initialize_group_vh();
        this.group = (Group)this._persistence_group_vh.getValue();
        this._persistence_propertyChange("group", this.group, var1);
        this.group = var1;
        this._persistence_group_vh.setValue(var1);
    }
}

Bill2

//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//



package com.company.bill.entity;

import com.haulmont.chile.core.annotations.MetaClass;
import com.haulmont.cuba.core.entity.StandardEntity;
import com.haulmont.cuba.core.entity.annotation.OnDelete;
import com.haulmont.cuba.core.entity.annotation.OnDeleteInverse;
import com.haulmont.cuba.core.entity.annotation.UnavailableInSecurityConstraints;
import com.haulmont.cuba.core.global.DeletePolicy;
import com.haulmont.cuba.core.sys.CubaEnhanced;
import com.haulmont.cuba.security.entity.Group;
import javax.persistence.Column;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.MappedSuperclass;
import org.eclipse.persistence.internal.descriptors.PersistenceObject;
import org.eclipse.persistence.internal.weaving.PersistenceWeaved;
import org.eclipse.persistence.internal.weaving.PersistenceWeavedChangeTracking;
import org.eclipse.persistence.internal.weaving.PersistenceWeavedFetchGroups;

@MappedSuperclass
@MetaClass(
    name = "bill_Bill"
)
@UnavailableInSecurityConstraints
public class Bill extends StandardEntity implements PersistenceWeaved, PersistenceObject, PersistenceWeavedFetchGroups, PersistenceWeavedChangeTracking, CubaEnhanced {
    private static final long serialVersionUID = 7342884335729454184L;
    @Column(
        name = "CODE"
    )
    protected String code;
    @Column(
        name = "NAME"
    )
    protected String name;
    @OnDeleteInverse(DeletePolicy.UNLINK)
    @OnDelete(DeletePolicy.UNLINK)
    @ManyToOne(
        fetch = FetchType.LAZY
    )
    @JoinColumn(
        name = "GROUP_ID"
    )
    protected Group group;

    public Bill() {
    }

    public Group getGroup() {
        return this.group;
    }

    public void setGroup(Group group) {
        this.group = group;
    }

    public String getName() {
        return this.name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getCode() {
        return this.code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public Object _persistence_post_clone() {
        super._persistence_post_clone();
        this._persistence_listener = null;
        this._persistence_fetchGroup = null;
        this._persistence_session = null;
        this._persistence_primaryKey = null;
        return this;
    }

    public Object _persistence_new(PersistenceObject var1) {
        return new Bill();
    }

    public Object _persistence_get(String var1) {
        return super._persistence_get(var1);
    }

    public void _persistence_set(String var1, Object var2) {
        super._persistence_set(var1, var2);
    }
}

两个项目编译之前先 clean 一下,再看看生成的 .class文件,应该是一样的.请再确认一下.

已解决,原因为@MappedSuperclass类在插件项目中未创建后代实体,而更新代码后 build、deploy目录下的文件未及时更新,导致问题排查困难

1赞