The table is not touched until you call save (and then only if the
object validates)..
So you generate a transaction number before receiving all the
information from the user? Is this necessary? Could you give them the
transaction number after it has been accepted?
This is one of the classical breaking points of object-relational
mapping - the transaction boundary. It occurs in single user and
mutli-user paradigms equally.
If, for auditing purposes, there is a requirement that transaction
numbers be sequential, _and_ you don't need a transaction number until
the transaction is comitted, then generate your transaction ID at save
time within the boundaries of the database transaction.
If, for auditing purposes, there is a requirement that transaction
numbers be sequential, _and_ you need transaction numbers early, then
make sure that you record thetransactionearly, and be prepared to
record the transaction as being canceled by user or aborted due to
technical failure.
If there is no need for keeping the transaction number sequential (not
likely), then youcan throw away unused numbers. Numbers are cheap, if
they have enough digits.