Re: Display PrimaryKey
Maik Musall <[email protected]> Wed, 13 Jul 2011 12:33:35 +0200
| Newsgroups | gmane.comp.web.webobjects.woproject.devel |
|---|---|
| Message-ID | <[email protected]> |
public Integer pk() {
try {
return (Integer) EOUtilities.primaryKeyForObject( =
this.editingContext(), this ).objectForKey( "id" );
} catch (Exception e ) {
return null;
}
}
The exception would occur on unsaved objects as it doesn't have a =
primary key yet.
But consider adding a unique id to the EO other than the primary key, =
which you then could make a normal attribute. You shouldn't expose the =
primary key to the outside. If you one day need to migrate the database =
somewhere else, chances are the primary key will change. An additional =
attribute could stay the same. Plus you can set and determine that =
attribute on unsaved objects, too.
Maik
Am 13.07.2011 um 12:01 schrieb Peter M=FCller:
> Hello together,
>=20
> i've a question about primary keys in WebObjects: I have a model like =
this:
> id (Integer), no accessor, primary key
> lastname (String), accessor
> firstname (String), accessor
> ...
>=20
> The id's will be needed in an PDF-Download (the people working with =
them need the ID, I don't know why, but they need this ID).
>=20
> Because there is no accessor to this id, i can't display it. Is there =
a way, to display the ID (i don't want to modify, just display)?
>=20
> Thank you a lot,
> Peter M.
> --=20
> NEU: FreePhone - kostenlos mobil telefonieren! =09
> Jetzt informieren: http://www.gmx.net/de/go/freephone