I need to write a invoice generating software in ColdFusion 9 using ORM (Hibernate).
One of the requirements is that the invoice number must be sequential without gap, which means no invoice number can be skipped.
The database identity value (i.e. generator="native") does not work as it skips a number if transaction failed to commit.
According to the CF9 documentation:
increment: This algorithm generates identifiers of type long, short, or int by incrementing a counter maintained by ORM. This is commonly used when auto-generation for the primary key is not enabled in the table and you want ORM to generate the primary key. This should be used when a single instance of ColdFusion is the only process to insert data into the table.
Does Hibernate's increment generator guarantee no skipping on failed transaction? Is it good enough?
If not, how should I go about doing that? insert invoice number by a thread-safe sequential number generator at postInsert()?