• 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
retrieving PK immediately after saveChanges() ...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

retrieving PK immediately after saveChanges() ...


  • Subject: retrieving PK immediately after saveChanges() ...
  • From: Gavin Eadie <email@hidden>
  • Date: Tue, 10 Jun 2008 18:36:53 -0400

I need to provide a unique user-facing serial number on records, and it would be fine if it was the same as the primary key integer.  What I've been trying to do is to save the record once so the pkey is assigned, then use it to set the serial.  Essentially, as follows:

  public void addPerson () {
    SampleDB  newRecord = SampleDB.createSampleDB(myEditingContext, firstName, lastName);
    myEditingContext.saveChanges();
    newRecord.setSerial(newRecord.id());
    myEditingContext.saveChanges();
  }

I've some old code that does this 'by force', but in converting to Wonder, I don't seem to be able to get there.

If I tell Entity Modeler/EOgen to provide accessors on id then the SampleDB.createSampleDB method has id as a parameter, and I shouldn't be specifying the primary key in my code.  If I don't provide accessors then I can't access the pkey.  I tried specifying id as read-only, thinking that EOgen would then provide a getID, but no setID (or a need to specify it in SampleDB.createSampleDB), and that would work for me but no.

I suspect there is a really simple solution but it eludes me.  As I noted, I've got Wonder-less code that works, so I'm looking for the best way to do it with Wonder ... so much of the WOLips/Wonder stuff seems to just work; I'm a tad perturbed that this one has me stumped.
 _______________________________________________
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

  • Follow-Ups:
    • Re: retrieving PK immediately after saveChanges() ...
      • From: Thomas <email@hidden>
  • Prev by Date: Re: LEWOStuff (the stuff with JSON-RPC!)
  • Next by Date: Re: retrieving PK immediately after saveChanges() ...
  • Previous by thread: Re: Versioning ... CVS or Subversion?
  • Next by thread: Re: retrieving PK immediately after saveChanges() ...
  • Index(es):
    • Date
    • Thread