Here is what I used a while back which seemed to work:
Map map = new HashMap();
map.put("identifier",
HexCoder.decode(PSCollection.QUEUE_PURCHASE_MONTHLY));
ObjectId oid = new ObjectId(PSCollection.class, map);
PSCollection collection = (PSCollection) dataContext.refetchObject(oid);
if (collection != null)
{
// Do stuff here ...
}
A few notes ... The "identifier" is the primary key column. The
HexCoder stuff makes a binary data type out of a large hexadecimal value
(we don't have simple integers in our existing legacy database). One of
the other ObjectId constructors might work better for you, though. From
what I understand, making an ObjectId like this essentially makes a
fault object, and then you can ask your DataContext object to refetch
it. I believe if the object is already in memory, it is refetched
(updated from the DB) due to object uniquing.
Hope that helps!
/dev/mrg
-----Original Message-----
From: Leonardo Queiroz Antunes [mailto:Leonardo.Antune..r-tcs.com]
Sent: Wednesday, January 07, 2004 7:30 AM
To: cayenne-use..bjectstyle.org
Subject: Select by PK
Hi everybody,
how can we select an object by its pk value?
thanks
Leonardo
This archive was generated by hypermail 2.0.0 : Wed Jan 07 2004 - 10:15:41 EST