Hello,My current customer needs a column which is semi-unique, i.e., some of its values (programmatically determined which ones, in this case those which happen to contain a decimal digit) need to be unique, whilst others need not.
Of course, I can easily write a Java code to handle this kind of "uniqueness", something conceptually like
void testAndSave() {
String uval=changedObject.uniqueValue();
if (shouldBeUniqueValue(uval)) {
NSArray a=EOUtilities.objectMatchingKeyAndValue
(changedObject.editingContext(),"uniqueValue",uval);
if (a.count()>0) throw new Exception("Not unique "+uval);
}
changedObject.editingContext().saveChanges();
}
I don't quite like this code though, for there still is a slight
possibility for two concurrent clients' operations may be ordered so
that both tests are all right, and then non-unique values are saved.
Since only some values are to be uniqued, I cannot use a database
unique constraint to prevent that (incidentally, am using FrontBase
-- not that it is important in this case).
What would be the best solution? Is there a standard way to make such a test and save an atomical operation? I could lock or create an explicit transaction I guess, but at the first look it seems to be a bit overkill for such a plain task?
Thanks for any idea, --- Ondra Čada OCSoftware: [EMAIL PROTECTED] http://www.ocs.cz private [EMAIL PROTECTED] http://www.ocs.cz/oc
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________ 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]
