Hibernate equals and proxy

后端 未结 4 1844
忘了有多久
忘了有多久 2020-12-29 09:12

I have one BaseEntity which abstracts id and version property. this class also implements hashcode and equals based on PK (id) property.

BaseEntity{

    Lo         


        
4条回答
  •  鱼传尺愫
    2020-12-29 09:52

    I use Hibernate.getClass for many years and I never noticed a problem:

    @Override    
    public boolean equals(final Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null) {
            return false;
        }
        if (Hibernate.getClass(this) != Hibernate.getClass(obj)) {
            return false;
        }
    
        ... check for values
    
        return true;
    }
    

提交回复
热议问题