From 2db5210c1e6a015503ef64f6652080fe9fa65435 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Wed, 31 Aug 2016 15:32:16 +0200 Subject: [PATCH] Please cherry-pick: - renamed updatedUser -> managedUser - better set all data in EJB to avoid managedUser become detached (as the scope is not EJB anymore) --- .../jusercore/model/user/JobsUserSessionBean.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/java/org/mxchange/jusercore/model/user/JobsUserSessionBean.java b/src/java/org/mxchange/jusercore/model/user/JobsUserSessionBean.java index 9cb2a0a..094e9c8 100644 --- a/src/java/org/mxchange/jusercore/model/user/JobsUserSessionBean.java +++ b/src/java/org/mxchange/jusercore/model/user/JobsUserSessionBean.java @@ -642,12 +642,14 @@ public class JobsUserSessionBean extends BaseJobsDatabaseBean implements UserSes } // 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 JobsUserSessionBean extends BaseJobsDatabaseBean implements UserSes 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); -- 2.39.5