Re: sequential numbering across more instances
Re: sequential numbering across more instances
- Subject: Re: sequential numbering across more instances
- From: Florijan Stamenkovic <email@hidden>
- Date: Fri, 15 Aug 2008 15:08:18 -0400
On Aug 15, 2008, at 14:59, Chuck Hill wrote:
On Aug 15, 2008, at 11:45 AM, Florijan Stamenkovic wrote:
With any such value there is some probability the client will
(next week or next year) want (a) to edit it, (b) in some special
case, to have non-unique values.
Aaaaaah, I love being an in-house developer that can just stamp
his foot and say no, without having to think about such a thing
as: clients :)
That -- same as an extra UNIQUE column -- would not satisfy the
demand that "all numbered orders make a sequence 1,2,3,4,....".
The client would prefer that the sequence is without gaps (not
something like "1,5,6,27,....").
I start to see your point. It makes it very tedious to deal with
however. I've been in this situation. The decision (based on my
selfless recommendations :) was not to care that 1,2,3,7,10... is
ugly. They are unique. They identify things persistently. Sold.
As for Chuck's solution, also notice that it does not help you
deal with the potential demand for edibility. And since it
doesn't, you might as well use PKs (or a separate db generated
sequence) in a two table setup in which you would still get the
sparse but linear sequence like in Chuck's solution, but with far
less fuss.
I think my solution would avoid gaps. The Order and OrderNumber
are updated in the same transaction so there should be no rolling
back of the number after another order has used a higher one.
Was not thinking that it would not. Uhm frankly was not exactly sure
if and how it would work :) I'm just saying that you can get the same
thing, if I understand correctly what the end result of your code
would be, but in an easier way by doing this in the Order:
public void assignNumber(){
addToBothSides(EOUtilities.createAndInsert(editingContext(),
"OrderNumber"), "orderNumber");
}
public Number number(){
OrderNumber on = orderNumber();
if(on == null) return null;
return (Integer)((EOKeyGlobalID)editingContext().globalIDForObject
(on)).keyValues()[0];
}
And you're done. Not every Order has to have a number, but when they
do, they are in sequence.
Writing this in Mail, so it might not be entirely correct.
F
_______________________________________________
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