ID with auto-incremental value


I am migrating an existing application built on Access to Cuba Platform.
For all entities, the Id (being the primary key) has to be an auto-generated incremental number, i.e. the first created customer would take Id 1, the 2nd would take id 2, and so on…
How can I override Cuba’s auto-generated primary key id which looks something like “370625ee-8c17-4eb2-bafe-b0f72a64fe2f”?

Thanks in advance for your help.

Shady Hanna

Hi Shady,

you can use a different base entity like BaseLongIdEntity as the base class for your customer. Probably you now have StandardEntity which uses a UUID as the identifier. BaseLongIdEntity / BaseIntegerIdEntity uses a sequence to do the auto increment feature. More information about this can be found here:

Additionally you might think of using a extra field for storing the business related “customer id” instead of using the database identifier. In this case you can use the sequence generation from the platform (which is used internally at the BaseLongIdEntity as well) to achieve this.


Please keep in mind that when using BaseLongIdEntity you are not guaranteed to have strongly sequential IDs - they will have gaps as we cache some number of IDs on the client tier for better performance. So if you have some strong requirements regarding numbering, better use a separate field as suggested by Mario.

Thank you gents for your help!