Java Reference
In-Depth Information
pm = pmf.getPersistenceManager();
transaction = pm.currentTransaction();
// change DataString field of the second persisted object
aYacht = (Yacht)pm.getObjectById(id.elementAt(1), false);
aYacht.setYachtName("New_Name");
// commit the change and close the PM
transaction.commit();
pm.close();
}
/** Delete a Yacht object from persistent datastore */
public void delete() {
// get a PM and set transaction
pm = pmf.getPersistenceManager();
transaction = pm.currentTransaction();
// delete the 2nd persisted object from datastore and its ID from
Vector id.
pm.deletePersistent(pm.getObjectById(id.remove(1), false));
// commit the change and close the persistence manager
transaction.commit();
pm.close();
}
/**
* The main method of the Test Client program.
*/
public static void main(String[] args) {
System.out.println("Start Test");
// Instantiate a TestClient
TestClient aTestClient = new TestClient();
// Setup and persist a group of yachts, then display tieir persised
state.
System.out.println("\nThree yachts are persisted");
aTestClient.yachtPersistor();
aTestClient.display(SIZE);
// Change a yacht'sname, and then display the yachts' state again.
System.out.println("\nSecond yacht's name is changed");
aTestClient.change();
aTestClient.display(SIZE);
// Delete a person and display the yachts'state again.
Search WWH ::




Custom Search