Let's suppose a base entity like this
Code:
@MappedSuperclass
public abstract class AbstractEntity {
@Id
@GeneratedValue(strategy = GenerationType.TABLE, generator = "genericTableGenerator")
@TableGenerator(name = "genericTableGenerator",
table = "ID_GENERATOR",
pkColumnName = "NAME",
pkColumnValue = "ENTITY_GEN", // ??? dynamic way to specify this information ???
valueColumnName = "VALUE")
private long id;
used by a subclass like this
Code:
public Person extends AbstractEntity {
How could it be possible to have a fully
database independent generator (table generator) having
a sequence by entity type. The idea is to use the concrete class name as sequence name (
AbstractEntity.class.getName()) BUT there is actually no way to specify this information at annotation level or make it dynamic!
So, what could be done except a weird override of generator (see
MultipleHiLoPerTableGenerator#generate)