try {
Transaction.begin();
User dbUser = factory.lookup(user.getEmailAddress());
if (dbUser == null){
throw new DAOException("User "+user.getEmailAddress()+" no longer exists");
}
dbUser.setFirstName(user.getFirstName());
dbUser.setLastName(user.getLastName());
dbUser.setGender(user.getGender());
Transaction.commit();
} catch (RollbackException e) {
throw new DAOException(e);
} finally {
if (Transaction.isActive()) Transaction.rollback();
}
}