- // Find the instance
- User foundUser = this.getEntityManager().find(user.getClass(), user.getUserId());
-
- // Should be found!
- assert (foundUser instanceof User) : MessageFormat.format("User with id {0} not found, but should be.", user.getUserId()); //NOI18N
-
- // Copy all data
- foundUser.copyAll(user);
-
- // Set as locked
- foundUser.setUserAccountStatus(UserAccountStatus.LOCKED);
- foundUser.setUserLastLocked(new GregorianCalendar());
- foundUser.setUserLastLockedReason(userLockReason);
-
- // Merge user
- User detachedUser = this.getEntityManager().merge(foundUser);
-
- // Should be found!
- assert (detachedUser instanceof User) : MessageFormat.format("User with id {0} not merged, but should be.", user.getUserId()); //NOI18N
+ // Set as locked, set timestamp and lock reason
+ user.setUserAccountStatus(UserAccountStatus.LOCKED);
+ user.setUserLastLocked(new GregorianCalendar());
+ user.setUserLastLockedReason(userLockReason);