Re: [hibernate-dev] Entity implementation of equals()

2019-08-28 Thread Steve Ebersole
There are 2 different discussions here: 1) How to implement `#equals` to account for HibernateProxy 2) How to implement `#equals` in a MappedSuperclass These things are at odds here. With regards to (1), as discussed above, you have to allow subclasses in the equality comparison *if* you want to

Re: [hibernate-dev] Entity implementation of equals()

2019-08-27 Thread Gail Badner
Please see below... On Tue, Aug 27, 2019 at 8:00 PM Jan-Willem Gmelig Meyling < jan-wil...@youngmediaexperts.nl> wrote: > I tend to use this.getClass().isInstance(o) and this.getClass().cast(o) > which works even in a mapped super class on most occasions. (Assuming that > the proxy delegates equa

Re: [hibernate-dev] Entity implementation of equals()

2019-08-27 Thread Jan-Willem Gmelig Meyling
I tend to use this.getClass().isInstance(o) and this.getClass().cast(o) which works even in a mapped super class on most occasions. (Assuming that the proxy delegates equals to a concrete target). Jan-Willem > Op 27 aug. 2019 om 22:29 heeft Steve Ebersole het > volgende geschreven: > > Gen

Re: [hibernate-dev] Entity implementation of equals()

2019-08-27 Thread Steve Ebersole
Generally speaking an `#equals` method would not allow subclasses to match. For entity mappings specifically I this it is generally considered kosher to allow subclass matching in `#equals`. Interestingly, when generating `#equals` overrides through IntelliJ it even asks specifically whether subc

[hibernate-dev] Entity implementation of equals()

2019-08-27 Thread Gail Badner
Hi, I'm looking into the impact of HHH-13590. In the test for HHH-13590, I see that the mapped superclass entity defines equals() as: @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; ... } Due to the bu