hello, this is my first post, hope you could help me
my problem is generally about JPA, currently i developing a sales and inventory system for a local corporation in my town. in usual inventory systems, you have the option to add a supplier record. our client wants that in the "Add Supplier" GUI, there is already a generated supplier id (because of the reason that it is their habit to memorize all supplier ids instead of names) displayed, this is all before adding of the supplier record.
any help or redirections is greatly appreciated.
You just save maxSupplierID someplace and then when you make a call to "Add Supplier" you just put the next supplier ID in that dialog. If you don't save it, then don't increment the maxSupplierID.
This is done very easily with a database that support sequences.
yes it would work, but then my application is used by multiple users, so there will be concurrency problems. one thinking is, what if i created an extra table which would cater currently generated id and if its reserved or not, but i'm thinking of other solutions would be better. what do you think
thanks for your reply by the way.
I like the way sequences work in Oracle... you just request the next one and let Oracle worry about concurrency issues.
If your talking about 100's or possibly 1000's of simulatanious users, then concurrency can be a real headache, but if we are talking a few... then any way you can think of to get a lock on the next number until it is finalized is probably going to be fine.