There are many entities in my project that utilize the same custom IdentifierGenerator
for @Id
generation using SpringDataJPA/Hibernate
.
An example entity;
@Entity
@Table(name = "CHAIRS")
public class ChairEntity {
@Id
@GeneratedValue(generator = "myGenerator")
@GenericGenerator(strategy = "a.b.jpa.generator.MyGenerator", name = "myGenerator")
protected String id;
// rest of the entity
}
But I do not want to repeat @GenericGenerator
decleration for every id field of every entity. Is there no way to hide this annotation that contains an ugly hardcoded full class name inside?
post scriptum
I was previously utilizing @MappedSuperClass
with a BaseEntity
class containing id
field, but due to some technical reasons I had to abandon utilizing such a superclass. Obviously that is the easiest solution to this question.