I'm using @MappedSuperclass to keep some common entity properties such as version or creation date in one place. This superclass does not have @Id field. Obviously, this prevents enhancer from creating equals() for it. But when I add @Id property in entity class extending this superclass, enhancer assumes that equals() is inherited from the superclass and does not create equals() as well. Here is a small test case:
// Super.java :import javax.persistence.MappedSuperclass;@MappedSuperclasspublic abstract class Super { public String getFoo() { return foo; } public void setFoo( String f ) { foo = f; } private String foo;}
// Model.java :import javax.persistence.Entity;import javax.persistence.Id;
@Entitypublic class Model extends Super { @Id private Long id; public Long getId() { return id; }}
// Main.java :public class Main { public static void main( String[] args ) { Model m = new Model(); }}
Running javaagent for this example produces the following debug output:transform> cls: Model msg: entity extends Supertransform> cls: Model msg: ... skipping add equals() ... will inherit this from super classtransform> cls: Model msg: enhanced transform> cls: Super msg: has no id fields. Not adding equals() method.transform> cls: Super msg: enhanced