Miguel Arroz wrote:
Hi!
I was wondering how to do something like this... imagine a form to
create a new user on a site. The code would be something like:
EOFetchSpecification fetchSpecificationForUserWithLoginArroz = blah
blah blah; // line 1
NSArray objects = someContext.objectsWithFetchSpecification
(fetchSpecificationForUserWithLoginArroz); // line 2
if( objects.count() == 0 ) { // line 3
/* create user with login arroz */
}
The problem is... what happens if two or more instances of the
application run this code at the same time? Specifically, if two
instances run both line one and line two at the exactly same time, when
running line 3, one of them will create a second user with the same login.
How do you take care os this problem on your apps?
The way I've done it is to put a UNIQUE constraint on the login. Then,
when I save changes, I trap the constraint violation if it occurs.
There's a thread on this that you might find helpful. Pierre Bernard,
Chuck Hill and myself participated in it but I don't remember the name
of the thread. It was back in September I think.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com
This email sent to [email protected]