Hi Martin,
> which I understand is for composite prim. keys
Yup.
> but how does my query have to look?
Take a look at the javadocs for ObjectId and DataContext. There are two
ObjectId constructors that allow you to create new object ids for entities
that have a single column pks.
Convenience constructor for entities that have a single Integer as their id:
ObjectId(java.lang.String objEntityName, java.lang.String keyName, int id)
Convenience constructor for entities that have a single column as their id:
ObjectId(java.lang.String objEntityName, java.lang.String keyName,
java.lang.Object id)
Instantiate an ObjectId with you primary key value, and use the DataContext
methods to fetch your object with the objectId you created.
Returns an object for a given ObjectId:
registeredObject(ObjectId oid)
I think that will work.
Eric
> -----Original Message-----
> From: martin ruff [mailto:mruf..imeon.ch]
> Sent: Wednesday, November 27, 2002 1:07 PM
> To: cayenne-use..bjectstyle.org
> Subject: getting object by primary key
>
>
> hi how do i get an object if I have the primary key?
> lets say i've got an employees table with id as prim.key
>
> Expression qual = ExpressionFactory.binaryPathExp(
> Expression.EQUAL_TO,
> "id",
> "23");
> SelectQuery query = new SelectQuery("Employees", qual);
>
> fails because Employees does not have a primary key it has a map
> instead, which I understand is for composite prim. keys
> but how does my query have to look?
>
> thanks in advance
> martin
>
**********************************************************************
This message, including any attachments, contains confidential information intended for a specific individual and purpose, and is protected by law. If you are not the intended recipient, please contact sender immediately by reply e-mail and destroy all copies. You are hereby notified that any disclosure, copying, or distribution of this message, or the taking of any action based on it, is strictly prohibited.
TIAA-CREF
**********************************************************************
This archive was generated by hypermail 2.0.0 : Wed Nov 27 2002 - 13:31:19 EST