From 80133da5285fbafceaef224fed0f31c06b532b16 Mon Sep 17 00:00:00 2001
From: Andre Brait final
and extends java.lang.Object
, lombok generates a canEqual
method which means JPA proxies can still be equal to their base class, but subclasses that add new state don't break the equals contract. The complicated reasons for why such a method is necessary are explained in this paper: How to Write an Equality Method in Java. If all classes in a hierarchy are a mix of scala case classes and classes with lombok-generated equals methods, all equality will 'just work'. If you need to write your own equals methods, you should always override canEqual
if you change equals
and hashCode
.
NEW in Lombok 1.14.0: To put annotations on the other
parameter of the equals
(and, if relevant, canEqual
) method, you can use onParam=@__({@AnnotationsHere})
. Be careful though! This is an experimental feature. For more details see the documentation on the onX feature.
+
+ NEW in Lombok 1.18.16: Caching the result of the generated hashCode()
can be cached by setting cacheStrategy
to a value other than CacheStrategy.NEVER
. Do not use this if objects of the annotated class can be modified in any way that would lead to the result of hashCode()
changing.