From: Roland Häder Date: Tue, 3 May 2016 13:13:35 +0000 (+0200) Subject: Continued a bit: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=cce044ce53edb339db368afe7de94611af03dec0;p=pizzaservice-ejb.git Continued a bit: - implemented linkUser() - use interface for class name Signed-off-by: Roland Häder --- diff --git a/src/java/org/mxchange/jusercore/model/user/PizzaUserSessionBean.java b/src/java/org/mxchange/jusercore/model/user/PizzaUserSessionBean.java index f86f5a2..c27e1bb 100644 --- a/src/java/org/mxchange/jusercore/model/user/PizzaUserSessionBean.java +++ b/src/java/org/mxchange/jusercore/model/user/PizzaUserSessionBean.java @@ -519,35 +519,26 @@ public class PizzaUserSessionBean extends BasePizzaDatabaseBean implements UserS throw new IllegalStateException("User does already exist."); //NOI18N } - // Check if user is registered - if (this.registerBean.isUserNameRegistered(user)) { - // Abort here - throw new UserNameAlreadyRegisteredException(user); - } else if (this.registerBean.isEmailAddressRegistered(user)) { - // Abort here - throw new EmailAddressAlreadyRegisteredException(user); - } - - // Set created timestamp - user.setUserCreated(new GregorianCalendar()); - - // Try to find the contact instance + // Try to find the contact Contact foundContact = this.getEntityManager().find(user.getUserContact().getClass(), user.getUserContact().getContactId()); - // Try to merge it + // Merge the contact to get a detached object back Contact detachedContact = this.getEntityManager().merge(foundContact); - // Set it in user + // Set detached object in rexcruiter instance user.setUserContact(detachedContact); - // Persist user + // Set timestamp + user.setUserCreated(new GregorianCalendar()); + + // Perist it this.getEntityManager().persist(user); - // Flush it to get id + // Flush it to get updated instance back this.getEntityManager().flush(); - // Trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("linkUser: user.userId={0} - EXIT!", user.getUserId())); //NOI18N + // Log trace message + this.getLoggerBeanLocal().logTrace(MessageFormat.format("linkUser: user={0} - EXIT!", user)); //NOI18N // Return updated instanc return user;