// get the session to store the new user object
HttpSession session = request.getSession();
// cast my form to a useful Type
PartyForm customerForm = (PartyForm) form;
// copy form-bean values to new Stake and Address objects
Address newAddress = new Address();
PropertyUtils.copyProperties(newAddress, customerForm);
Customer newCustomer = new Customer();
PropertyUtils.copyProperties(newCustomer, customerForm);
// attache the address to this new customer
newCustomer.setAddress(newAddress);
// store customer object in the session
session.setAttribute(Constants.LOGGED_IN_USER_KEY,newCustomer);
// get a DAO for the new Stake
dao = new CustomerDAO();
// store the new Stake
dao.makePersistent(newCustomer);
// commit this transaction
HibernateUtility.commitTransaction();
HibernateUtility.closeSession();
//********** NOW LOG the CUSTOMER IN **********
SecurityService securityService = new CustomerSecurityService();
Customer customer = null;
// perform authentication
try {
customer = (Customer) securityService.authenticate(customerForm.getUsername(), customerForm.getPassword());
} catch (AuthenticationException e) {
if (e.getMessage().equals("Error initializing dao"))
errors.add(
ActionMessages.GLOBAL_MESSAGE,
new ActionMessage("error.database"));