Numeric JPA identifiers
Chenile’s existing BaseJpaEntity, ChenileEntity, and IDGenerator remain the String-ID APIs. Use the
numeric bases in this guide for an ordinary JPA entity that is not a workflow state entity. String and numeric
entities can coexist in the same application.
Database-generated IDs
Extend BaseJpaLongEntity or BaseJpaIntegerEntity when the database assigns the primary key:
@Entity
class Customer extends BaseJpaLongEntity { }
The base supplies the normal Chenile audit, tenant, test-mode, and optimistic-lock fields. The ID is generated by
JPA when the entity is saved. The Long base uses GenerationType.AUTO; use a normal application entity instead if
your database requires a specific identity or sequence mapping.
Application-generated IDs
Use a generated base when another system supplies deterministic or distributed numeric IDs. Declare the named strategy on the entity, then provide a Spring bean with that name.
@Entity
@ChenileGeneratedId(strategy = "customerId")
class Customer extends BaseJpaGeneratedLongEntity { }
@Bean("customerId")
TypedIdGenerationStrategy<Long> customerId() {
return new TypedIdGenerationStrategy<>() {
@Override public Class<Long> idType() { return Long.class; }
@Override public Long generate(TypedIdGenerationRequest request) {
return idService.nextId(request.entityType(), request.contextContainer());
}
};
}
Use BaseJpaGeneratedIntegerEntity and TypedIdGenerationStrategy<Integer> for Integer keys. The framework
validates that the named strategy exists and declares the ID type required by the entity before accepting its result.
Compatibility boundary
This feature does not alter STM/workflow entities, workflow URLs, EntityStore<T>, ChenileEntity, or the legacy
String IDGenerator. Workflow state entities continue to use String IDs. A workflow-native typed-ID design will be
introduced separately so existing workflow and Revyre Core implementations do not need to change for numeric JPA
entity support.