• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: accessing the primarykey???
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: accessing the primarykey???


  • Subject: Re: accessing the primarykey???
  • From: Kieran Kelleher <email@hidden>
  • Date: Tue, 13 Jul 2010 08:23:48 -0400

IMHO (and that's all it is :-)  ), using the primary key as a "job code" is just fine. Sure "it is a database artifact, blah, blah, etc.", but in practice, the PK is going to probably never change unless you have 3 databases with identical schemas, or some similar scenario, that you plan to merge into one db some day. ..... plus, if you are a busy man, you don't want to spend time coming up with your own "uniqueCodeGenerator" (btw, if you do, copy the SQL approach of EO_PK_TABLE PK generation)

You can use the PK key ("id", "oid" or whatever you have used) in EOKeyValueQualifiers, ERXInQualifiers, etc too as long as those qualifiers are used as schema based qualifiers (in a EOFetchSpec for example) and you don't try to use them for in-memory filtering of object arrays.

To programmatically get the the PK attribute name, just use ((EOAttribute)entity.primaryKeyAttributes().lastObject()).name() (or sth like that)

Also, Wonder has a bunch of utility methods in ERXEOAccessUtilities and ERXEOControlUtilities for dealing with PK related stuff, for example:

er.extensions.eof.ERXEOAccessUtilities.primaryKeyDictionaryForEntity(EOEditingContext, String)
er.extensions.eof.ERXEOControlUtilities.objectWithPrimaryKeyValue(EOEditingContext, String, Object, NSArray, boolean)

and to fetch an array of EOs for an array of PKs, just use new ERXInQualifier(pkAttributeName, arrayOfPks) and a FetchSpec.

In one project I maintain that was started many years ago, I went the route of generating unique Codes instead of using PKs and to this day, I regret it.

My 2 cents,

Kieran

On Jul 13, 2010, at 7:08 AM, Farrukh Ijaz wrote:

>
> On 2010-07-13, at 1:41 PM, Theodore Petrosky wrote:
>
>> I need a qualifier that gets a primary key...
>>
>> is the primary key accessible in a qualifier like this?
>>
>> versionQual = Version.JOB.dot(Job.<primaryKey()>).eq(something);
>>
>> My primary key is the Job Number....
>
> In dataflex and cobol times, PK were used in query's where clause. Today PK is left for DB to manage relationships internally. You should look into modify the Model and add a job number column. This will give you to benefits. One you don't need to worry about the PK, second, if your original record is deleted and you need to have the same code again, in EOF it won't be that easy from the front-end as it uses sequences. There are other benefits too but I don't remember yet :)
>
> Farrukh
>
>>
>> Ted
>>
>>
>>
>> _______________________________________________
>> 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
>
> _______________________________________________
> 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

 _______________________________________________
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

References: 
 >accessing the primarykey??? (From: Theodore Petrosky <email@hidden>)
 >Re: accessing the primarykey??? (From: Farrukh Ijaz <email@hidden>)

  • Prev by Date: Re: EOF and meaningful, modifiable PKs
  • Next by Date: Re: accessing the primarykey???
  • Previous by thread: Re: accessing the primarykey???
  • Next by thread: Migrations in Production?
  • Index(es):
    • Date
    • Thread