Transaction tx = Transaction new();
EmployeeHomeImpl empHome = EmployeeHomeImpl.singleton();
Employee emp;
AddressHomeImpl addrHome = AddressHomeImpl.singleton();
Address addr;
tx.begin();                          //begin a new transaction (transaction interface)
emp = empHome.findByKey("1234");       //find an employee instance (finder interface)
addr = addrHome.create();            //create an address instance (factory interface)
addr.setStreet("123 Somewhere Dr.");  //set attributes of the address (bus.object interface)
 ...
emp.setAddress(addr);                //set employee's address (bus.object interface)
tx.commit();                        //commit the changes (transaction interface)

Example 2: Sample persistence API code.

Back to Article
Copyright © 1999, Dr. Dobb's Journal