• 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: Need To Get PrimaryKey ID
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Need To Get PrimaryKey ID


  • Subject: Re: Need To Get PrimaryKey ID
  • From: Art Isbell <email@hidden>
  • Date: Fri, 21 Mar 2003 11:01:01 -1000

On Friday, March 21, 2003, at 09:44  AM, Jonathan Fleming wrote:

Below is the Method i am trying to use and I'm getting null value in the WOString element that i'm testing it with in the build for every item in my fetched List...

When you single-step through your method in the Java debugger, at what point are you seeing an unexpected null value?


   protected TbJob tbJob;
   protected TbJobPicture tbJobPicture;
   protected String sTb_JobID;
   protected String sTb_ClientID;

public Integer tbClientID() {
EOEnterpriseObject tbJobPicture = (EOEnterpriseObject) valueForKeyPath("tbJob");
NSDictionary primaryKey = EOUtilities.primaryKeyForObject(tbJobPicture.editingContext(), tbJob);

Looks like you're using tbJobPicture only to get its editing context. If tbJob isn't in the same editing context, its primary key probably won't be returned. Why not just use its editing context - tbJob.editingContext()?


NSLog.out.appendln("Dictionary to get tbClientID: " + primaryKey);
String strID = new String();

No need to create a new string.

strID = String.valueOf( (Integer) primaryKey.valueForKey("tbClientID") );
setTb_ClientID(strID);


return (Integer) primaryKey.valueForKey("tbClientID");

If the JVM optimizer doesn't notice that you are asking the primaryKey dictionary for the value of its tbClientID key twice, your app will be spending more execution time than necessary. For the best-performing app, it's probably best not to depend on automatic optimization to provide the best performance. Instead, it's probably best to cache the value of primaryKey's tbClientID key in a local variable and reference that variable twice. Little things like this could add up to degrade performance.


   }


public String getTb_ClientID() { return sTb_ClientID; }

public void setTb_ClientID(String value) {
NSLog.out.appendln( "\nThe Client ID For " + sClientLastName() + " is: " + getTb_ClientID() );

You probably realize that the above statement will return the sTb_ClientID value prior to the new value being set, so this will print a null value before sTb_ClientID is set.


       sTb_ClientID = value;
   }

Aloha, Art _______________________________________________ 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.

References: 
 >Need To Get PrimaryKey ID (From: "Jonathan Fleming" <email@hidden>)

  • Prev by Date: Which Version of Documentation should I use
  • Next by Date: Re: Need To Get PrimaryKey ID
  • Previous by thread: Need To Get PrimaryKey ID
  • Next by thread: Re: Need To Get PrimaryKey ID
  • Index(es):
    • Date
    • Thread