From: Roland Häder Date: Wed, 31 Aug 2016 13:32:16 +0000 (+0200) Subject: Please cherry-pick: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=fbdadb34820b4bbd0fe2901a341547ce93a860df;p=pizzaservice-ejb.git Please cherry-pick: - renamed updatedUser -> managedUser - better set all data in EJB to avoid managedUser become detached (as the scope is not EJB anymore) --- diff --git a/src/java/org/mxchange/jusercore/model/user/PizzaUserSessionBean.java b/src/java/org/mxchange/jusercore/model/user/PizzaUserSessionBean.java index cf9e906..fed3db6 100644 --- a/src/java/org/mxchange/jusercore/model/user/PizzaUserSessionBean.java +++ b/src/java/org/mxchange/jusercore/model/user/PizzaUserSessionBean.java @@ -642,12 +642,14 @@ public class PizzaUserSessionBean extends BasePizzaDatabaseBean implements UserS } // Call other method - User updatedUser = this.updateUserData(user); + User managedUser = this.updateUserData(user); // Create history entry - PasswordHistory entry = new UserPasswordHistory(user.getUserEncryptedPassword(), updatedUser); + PasswordHistory entry = new UserPasswordHistory(); - // Set created timestamp + // Set all data here to avoid user instance become detached again + entry.setUserPasswordHistoryPasswordHash(managedUser.getUserEncryptedPassword()); + entry.setUserPasswordHistoryUser(managedUser); entry.setUserPasswordHistoryCreated(new GregorianCalendar()); // Persist it @@ -661,7 +663,7 @@ public class PizzaUserSessionBean extends BasePizzaDatabaseBean implements UserS try { // Create email address and set - emailAddress = new InternetAddress(updatedUser.getUserContact().getContactEmailAddress()); + emailAddress = new InternetAddress(managedUser.getUserContact().getContactEmailAddress()); } catch (final AddressException ex) { // Throw again throw new EJBException(ex);