On Aug 15, 2008, at 11:57 AM, Guido Neitzer wrote:

On 15.08.2008, at 11:13, Chuck Hill wrote:

NOW, the hard part! For every save you are going to have to trap OptimisiticLocking exceptions and check if it failed on OrderNumer. If it did, you are going to need to call order.assignOrderNumber() again and repeat until the save succeeds. This will be problematic if you have multiple Orders being saved in one transaction.

Hmm, and there is one other rather serious problem: If another order saves first, it will update the snapshot for OrderNumber and you will not get the needed OptimisiticLocking exception. You would need to catch the Object Changed In Store notification and based on that updating OrderNumber, invalidate and re-assign the number you had previously generated.

It's probably easier to wrap the same idea inside some simple direct SQL statements.


If you are willing to be DB specific, an After Insert trigger might be the best way to handle this. Just make sure the order number attribute is not used for locking.

Chuck

--
Chuck Hill             Senior Consultant / VP Development

Practical WebObjects - for developers who want to increase their overall knowledge of WebObjects or who are trying to solve specific problems.
http://www.global-village.net/products/practical_webobjects






_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to