I have an entity class with the following primary key generation strategy
@Id
@Column(name = "id", nullable = false)
@TableGenerator(name = "USERGENERATOR", table = "my_sequences", pkColumnName = "sequence_name", pkColumnValue = "user_id", valueColumnName = "next_value")
@GeneratedValue(strategy = GenerationType.TABLE, generator = "USERGENERATOR")
protected Integer id;
This worked fine until a new requirement came up, when I needed to insert a new row using my own query. Auto_increment is not used in the primary key column because of the Entity Inheritance strategy (@Inheritance (strategy = InheritanceType.TABLE_PER_CLASS)).
I was wondering if there is a way to ask the table generator for the next value using EntityManager.
chege source
share