public AccountDataBean register(String userID, String password, String fullname,
String address, String email, String creditcard,
BigDecimal openBalance) {
AccountDataBeanImpl account = null;
AccountProfileDataBeanImpl profile = null;
EntityManager entityManager = emf.createEntityManager();
if (Log.doTrace())
Log.trace("TradeJpaAm: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);
/*
* managed Transaction
*/
try {