I have some simple properties tables that all extend a @MappedSuperclass.
Each property table needs to have their own unique long sequence starting from 1L. So, the number of records in the table will always equal the primary key value of the last insert.
I want to use the @GeneratedValue annotation however I a not sure which strategy to use that will ensure that each table has its own sequence of primary keys from 1L upwards.
Any advice would be appreciated.
I am using Hibernate as my JPA implementation.
THERE WILL NEVER BE A RECORD REMOVAL FROM ANY TABLES.**
///ADDITIONAL BACKGROUND INFO////////
The problem I am trying to solve is that when I update properties in a table, other distributed elements of the application are informed that they need to update their own state based on the new properties. I wanted to avoid passing the identifier of the new record in the remote calls and rely on a ‘just look at the latest insert’ approach – hence why I am trying to ensure that the row count equates to the ID of the latest record.
I have simply taken the advice a_horse_with_no_name and generated ID’s using Hibernates auto generation strategy – never requiring sequential input or assertions about the ID of an entity based on the number of rows in the table.