Semi-unique column
Semi-unique column
- Subject: Semi-unique column
- From: Ondra Cada <email@hidden>
- Date: Mon, 28 Nov 2005 11:09:39 +0100
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@hidden http://www.ocs.cz
private email@hidden http://www.ocs.cz/oc
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden