String address,
String email,
String creditcard,
BigDecimal openBalance) throws Exception {
AccountDataBeanImpl account = null;
AccountProfileDataBeanImpl profile = null;
if (Log.doTrace())
Log.trace("TradeJpaCm:register", userID, password, fullname, address, email, creditcard, openBalance);
// Check to see if a profile with the desired userID already exists
profile = entityManager.find(AccountProfileDataBeanImpl.class, userID);
if (profile != null) {
Log.error("Failed to register new Account - AccountProfile with userID(" + userID + ") already exists");
return null;
}
else {
profile = new AccountProfileDataBeanImpl(userID, password, fullname,
address, email, creditcard);
account = new AccountDataBeanImpl(0, 0, null, new Timestamp(System.currentTimeMillis()), openBalance, openBalance, userID);
profile.setAccount((AccountDataBean)account);
account.setProfile((AccountProfileDataBean)profile);
entityManager.persist(profile);
entityManager.persist(account);
// Uncomment this line to verify that datasources has been enlisted. After rebuild attempt to register a user with
// a user id "fail". After the exception is thrown the database should not contain the user "fail" even though