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

Re: retrieving PK immediately after saveChanges() ...


  • Subject: Re: retrieving PK immediately after saveChanges() ...
  • From: Gavin Eadie <email@hidden>
  • Date: Tue, 10 Jun 2008 19:49:58 -0400

On 10 Jun 2008, at 23:36, 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.


On Jun 10, 2008, at 6:49 PM, Simon McLean wrote:

how about just using newRecord.primaryKey() ?


... works great, but you MUST save the record first (else you get a null result).


On Jun 10, 2008, at 6:52 PM, Thomas wrote:

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.

... also works great. Both return a String, reasonably enough, and so leave me a couple of hops to get back to an Integer. Thanks, both. As I suspected, simple enough. Some day, I will memorize all the WO class libraries!



As an aside "primaryKeyInTransaction" was unresolved till I noticed that _Entity.java inherits from EOGenericRecord and not ERXGenericRecord. Is that intentional Mike?
_______________________________________________
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: Mike Schrag <email@hidden>
References: 
 >retrieving PK immediately after saveChanges() ... (From: Gavin Eadie <email@hidden>)

  • Prev by Date: Re: MochaCode
  • Next by Date: Re: retrieving PK immediately after saveChanges() ...
  • Previous by thread: Re: retrieving PK immediately after saveChanges() ...
  • Next by thread: Re: retrieving PK immediately after saveChanges() ...
  • Index(es):
    • Date
    • Thread