Re: retrieving PK immediately after saveChanges() ...
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