}
public static void test(Connection connection)
throws Exception
{
Transaction txn = new Transaction();
UUIDGen uuidgen = UUIDGenFactory.getUUIDGen();
if (connection != null)
{
try
{
String authorizedUserID = "sviens";
String businessKey = uuidgen.uuidgen();
BusinessEntity business = new BusinessEntity();
business.setBusinessKey(businessKey);
business.setAuthorizedName("sviens");
business.setOperator("WebServiceRegistry.com");
Contact contact = new Contact();
contact.setPersonNameValue("Bill Bob");
contact.setUseType("server");
Vector contactList = new Vector();
contactList.add(contact);
int contactID = 0;
Address address = new Address();
address.setUseType("Mailing");
address.setSortCode("a");
Vector addrList = new Vector();
addrList.add(address);
int addressID = 0;
AddressLine addrLine1 = new AddressLine();
addrLine1.setLineValue("SteveViens.com, Inc.");
AddressLine addrLine2 = new AddressLine();
addrLine2.setLineValue("PO BOX 6856");
AddressLine addrLine3 = new AddressLine();
addrLine3.setLineValue("78 Marne Avenue");
AddressLine addrLine4 = new AddressLine();
addrLine4.setLineValue("Portsmouth");
AddressLine addrLine5 = new AddressLine();
addrLine5.setLineValue("New Hampshire");
Vector lineList = new Vector();
lineList.add(addrLine1);
lineList.add(addrLine2);
lineList.add(addrLine3);
lineList.add(addrLine4);
lineList.add(addrLine5);
// begin a new transaction
txn.begin(connection);
// insert a new BusinessEntity
BusinessEntityTable.insert(business,authorizedUserID,connection);
// insert a new Contact
ContactTable.insert(businessKey,contactList,connection);
// insert a new Address
AddressTable.insert(businessKey,contactID,addrList,connection);
// insert a Collection of AddressLine objects
AddressLineTable.insert(businessKey,contactID,addressID,lineList,connection);
// select the Collection of AddressLine objects
lineList = AddressLineTable.select(businessKey,contactID,addressID,connection);
// delete the Collection of AddressLine objects
//AddressLineTable.delete(businessKey,connection);
// re-select the Collection of AddressLine objects
lineList = AddressLineTable.select(businessKey,contactID,addressID,connection);
// commit the transaction
txn.commit();
}
catch(Exception ex)
{
try { txn.rollback(); }
catch(java.sql.SQLException sqlex) { sqlex.printStackTrace(); }
throw ex;
}
}
}