]> git.mxchange.org Git - pizzaservice-ejb.git/commitdiff
Please cherry-pick:
authorRoland Häder <roland@mxchange.org>
Wed, 31 Aug 2016 13:32:16 +0000 (15:32 +0200)
committerRoland Haeder <roland@mxchange.org>
Wed, 31 Aug 2016 19:53:49 +0000 (21:53 +0200)
- renamed updatedUser -> managedUser
- better set all data in EJB to avoid managedUser become detached (as the scope is not EJB anymore)

src/java/org/mxchange/jusercore/model/user/PizzaUserSessionBean.java

index cf9e90639c3ba16b2724db393199abb278d95a13..fed3db63ec5788ef274594ac6c137888d1211e6f 100644 (file)
@@ -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);