Closed simasch closed 1 year ago
Why is it an anti-pattern? Why shouldn't equals be implemented? Why would it be better to put generic code in all entity classes?
If you want to use a Sequence per entity you have to put the id in the entity (that's the default case)
Why you must not want to implement equals and hashCode or how you should: https://thorben-janssen.com/ultimate-guide-to-implementing-equals-and-hashcode-with-hibernate/
If you do not implement equals for an entity and use it in e.g grid then it will not work as you would expect because of the requirement also specified in the linked page
// 2 managed entities that represent the same record need to be equal
e1 = em.find(MyEntity.class, id1);
e2 = em.find(MyEntity.class, id1);
Assert.assertTrue(e1.equals(e2));
@Artur- Yes, you are right with the Grid refreshItem would probably not work.
Let's not do this as it won't work when you use entities in a component. Also we will add optimistic locking by default and that naturally goes into AbstractEntity
The AbstractEntity that is generate for master-detail is an anti-pattern
I would suggest to remove the AbstractEntity