Hibernate equals and proxy

后端 未结 4 1847
忘了有多久
忘了有多久 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:51

    You can also make it works this way, usefull if you don't know wich instance is B (may happen if your equals is in a superclass)

    if (HibernateProxyHelper.getClassWithoutInitializingProxy(this) != HibernateProxyHelper.getClassWithoutInitializingProxy(obj)) 
        return false
    

提交回复
热议问题