On 08/04/2009, at 8:26 AM, Joseph Schmidt wrote:
> Can't get primary key from temporary id
> ------------
>
> while trying to access the 'id' of a newly created object entity A.
> I need this 'id' to write the value together with some other fields
> in some other object entity B inside the same transaction. Between A
> and B there's no relationship (I'm using MySQL as a DB and CayenneM5).
The primary key doesn't exist until the record is written to the
database, so you just can't do this. You have two options:
* write the record to database, fetch it back again and then you'll
have the primary key
* create a relationship between A and B
If you find yourself using the primary keys directly very often, you
are probably not using Cayenne in the manner it was intended. The idea
is that it removes you from thinking about database-centric issues
like primary keys and just think about objects and how they relate to
each other. Mostly.
Ari
-------------------------->
ish
http://www.ish.com.au
Level 1, 30 Wilson Street Newtown 2042 Australia
phone +61 2 9550 5001 fax +61 2 9550 4001
GPG fingerprint CBFB 84B4 738D 4E87 5E5C 5EFA EF6A 7D2E 3E49 102A
This archive was generated by hypermail 2.0.0 : Tue Apr 07 2009 - 20:35:55 EDT