| @NaturalId does not work if applied to an inherited field. In fact when trying to load Section section = session.bySimpleNaturalId(Section.class).load(name); an exception is thrown. I tried several variants with repeating the name, @AnnotateOverwrite, getter with and without setter, adding the @NaturalId to the super class - nothing worked. From my understanding it could and should work as long as the derived entities do not share the same table space. {{@MappedSuperclass public abstract class BasicEntity implements Serializable { private static final long serialVersionUID = 1L; private Long id; private String name; @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "seqEntities") @SequenceGenerator(name = "seqEntities", sequenceName = "seqEntities") public Long getId() { return id; } protected void setId(Long id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } } @Entity @Cache(usage = CacheConcurrencyStrategy.READ_WRITE) @NaturalIdCache public class MyEntity extends BasicEntity { private String name; @NaturalId public String getName() { return name; } public void setName(String name) { this.name = name; } }}} |