tx.begin();
/** Create new objects to be persisted.
*/
PCPoint p1 = new PCPoint(10, 20);
PCPoint p2 = new PCPoint(20, 40);
PCRect rect = new PCRect(0, p1, p2);
/** This test relies on persistence by reachability.
*/
pm.makePersistent(rect);
/** This is the standard way to commit a transaction.
*/
tx.commit();
/** Begin a new transaction so that the navigation
* uses the object id to load the target object into the cache.
* The RetainValues flag false guarantees that the object fields
* are no longer loaded.
*/
tx.begin();
Object p1Id = pm.getObjectId(p1);
/** Retrieves the field values from the datastore.
*/
PCPoint p1a = (PCPoint)pm.getObjectById(p1Id, true);
/** Navigate to the point.
*/
PCPoint p1b = rect.getUpperLeft();
/** Query for the point by its values in the datastore.
*/
PCPoint p1c = findPoint(10, 20);
tx.commit();
tx = null;