Re: Setting an attribute based on PK?
Re: Setting an attribute based on PK?
- Subject: Re: Setting an attribute based on PK?
- From: Ashley Aitken <email@hidden>
- Date: Tue, 27 Apr 2004 21:54:16 +0800
Hi Chuck (et al),
Thanks for your post.
On 26/04/2004, at 1:38 AM, Chuck Hill wrote:
If all you need is an unique value, then why torture EOF? Some
possibilities:
- create a session and grab the session ID. Quick, dirty, effective.
- use one of the digest algorithms to digest information on the object
and
produce a unique value
- use EO_PK_TABLE or the database's PK generation support to generate a
number just for this purpose.
- use and EO to keep track of the last used value, use this value +1
and
update it on an insert of the other object
Yes, all good ideas. I just thought EOF was creating a unique
sequenced integer, why not use it. It seemed, at the time, like the
easy way (see other post for recent problems).
I've also put this code into my EC class, and it calls a method that
gives any EO (when inserted) an opportunity to set attribute values
based on the primary key.
The default code in my generic record class even looks for a key
entityName() + "Code" and automatically sets that to the primary key
value (I know some may not like this) .
I want to set an attribute (not the primary key) based on the
primaryKey value.
No. You want to set an attribute (not the primary key) to a unique
value.
You've just fixated on the primary key value. :-)
Yes, you're right, but see above.
The only thing is, it still saves the original value of the other
attribute. I seem to remember it is ill-advised to change an EO
during
validation (although this is not validation, probably later) maybe
this
is similar.
You're changing things that EOF considers already settled. This is
way,
way too late to be mucking about changing attibute values.
Yes, I've learnt that lesson ;-)
Cheers,
Ashley.
--
Ashley Aitken
Perth, Western Australia
mrhatken at mac dot com
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.