Different types of uniqueNumbers

If I want to have different types of uniqueNumbers.
Seq 1 = starts at 1000 shall increment with one or as set by user
Seq 2 = starts at 5000 shall increment with one or as set by user
Seq 3 = starts at 10000 shall increment with one or as set by user
Seq 4 = starts at 1 shall increment with one or as set by user and has a formatting as N001
Each of the sequence numbers above may be created by user and presented in a table.
Different entites uses each of the sequence numbers as report number or document Id.
Every time a new post is created, the post will get a new sequence number.

How can we solve this?

1 Like

On the middle tier, you have full control over sequences through the UniqueNumbersAPI interface. See its JavaDocs for details.
So you can create a service or a managed bean in the core module of your project and invoke UniqueNumbersAPI through it.

I have some trouble with DeleteNumber (domain)
I have created a sequence Demo in lowerletters.
When I try to delete it I get an error. Demo not found.
I am using Postgresql.

If I try to remove seq_un_demo sequence in Postgresql.
I get an error telling me that seq_un_demo is not found when I try to create it in
Cuba-platform again.
Is there any table I can’t see in Postgresql?
Where is sequence entries saved in Cuba-platform?


If you want to create the “demo” sequence using the DB manager you should specify its name seq_un_demo.

When the sequence is created by some method of the UniqueNumbers class, “seq_un” is added before domain automatically.

Try to call the following code in some service in your application.

private UniqueNumbersAPI uniqueNumbers;
Long longValue = uniqueNumbers.getNextNumber("demo")

As result, the sequence with the name “seq_un_demo” is created automatically in the Database.

After that, call uniqueNumbers.deleteSequence(domain) and the sequence is deleted. And if to call it again “IllegalStateException: Attempt to delete nonexistent sequence demo” occurs.



I have solved the problem and created a service/gui to handle
Sequence to Entity attribute.