| Apache Cayenne > Index > Cayenne FAQ > Fetch By Primary Key |
DataObjectUtils is your friend. It has a number of useful shortcuts to quickly and efficiently (i.e. using cache whenever possible) locate individual DataObjects.
Example:
DataContext context = // obtain DataContext using one of the standard methods int pk = 5; Artist artist = (Artist) DataObjectUtils.objectForPK(context, Artist.class, pk);
More Info: