@Override @Transactional(TransactionUtils.DEFAULT_TRANSACTION_MANAGER) public Customer saveCustomer(Customer customer, boolean register) { if (register && !customer.isRegistered()) { customer.setRegistered(true); } if (customer.getUnencodedPassword() != null) { customer.setPassword(encodePassword(customer.getUnencodedPassword(), customer)); } // let's make sure they entered a new challenge answer (we will populate // the password field with hashed values so check that they have changed // id if (customer.getUnencodedChallengeAnswer() != null && !customer.getUnencodedChallengeAnswer().equals(customer.getChallengeAnswer())) { customer.setChallengeAnswer(encodePassword(customer.getUnencodedChallengeAnswer(), customer)); } return customerDao.save(customer); }
/** * After a JPA merge occurs, there is a new object created representing the merged changes. The new object does * not reflect the state of transient fields that may have been set on the object that was merged. * * This method, by default, resets the state of transient properties. * and allows the user to override this method to set additional (or different) transient values. * * @param preMergedCustome * @param postMergedCustomer */ protected void resetTransientFields(Customer preMergedCustomer, Customer postMergedCustomer) { postMergedCustomer.setUnencodedPassword(preMergedCustomer.getUnencodedPassword()); postMergedCustomer.setUnencodedChallengeAnswer(preMergedCustomer.getUnencodedChallengeAnswer()); postMergedCustomer.setAnonymous(preMergedCustomer.isAnonymous()); postMergedCustomer.setCookied(preMergedCustomer.isCookied()); postMergedCustomer.setLoggedIn(preMergedCustomer.isRegistered()); postMergedCustomer.getTransientProperties().putAll(preMergedCustomer.getTransientProperties()); }
/** * After a JPA merge occurs, there is a new object created representing the merged changes. The new object does * not reflect the state of transient fields that may have been set on the object that was merged. * * This method, by default, resets the state of transient properties. * and allows the user to override this method to set additional (or different) transient values. * * @param preMergedCustome * @param postMergedCustomer */ protected void resetTransientFields(Customer preMergedCustomer, Customer postMergedCustomer) { postMergedCustomer.setUnencodedPassword(preMergedCustomer.getUnencodedPassword()); postMergedCustomer.setUnencodedChallengeAnswer(preMergedCustomer.getUnencodedChallengeAnswer()); postMergedCustomer.setAnonymous(preMergedCustomer.isAnonymous()); postMergedCustomer.setCookied(preMergedCustomer.isCookied()); postMergedCustomer.setLoggedIn(preMergedCustomer.isLoggedIn()); postMergedCustomer.getTransientProperties().putAll(preMergedCustomer.getTransientProperties()); }