No need to save the entity:

ERXGenericRecord primaryKeyInTransaction()
Calling this method will return the primary key of the given enterprise object or if one has not been assigned to it yet, then it will have the adaptor channel generate one for it, cache it and then use that primary key when it is saved to the database.

Regards
Thomas

On 11/06/2008, at 8:36 AM, Gavin Eadie wrote:

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 protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/webobjects%40woomeranet.com.au

This email sent to [EMAIL PROTECTED]

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to