For some reason my object changes aren't being saved/reflected in the database and I am not sure why.
Here is my UserRepository
Which gives me my save method.Code:public interface UserRepository extends GraphRepository<User>, RelationshipOperationsRepository<User>, EventGateUserDetailsService {
Here is my Service code that is wrapped in a Transaction. I have @Transactional at the class level and this method is part of the interface that the service implements.
The user parameter if a User object created from a form submission, so detached. But the currentUser is the user in Spring Security SecurityContext. So I pass the values from the from submission to that currentUser object, then pass that to the userRepository.save method. But when I re-retrieve the user from the db, any changes are no longer there. Meaning it wasn't persisted to the db. The Transaction commits, no RuntimeExceptions to cause it to roll back.Code:@Override public void updateUser(User user, String password) { User currentUser = getUserFromSession(); currentUser.setFirstName(user.getFirstName()); currentUser.setLastName(user.getLastName()); currentUser.setTwitterAccountName(user.getTwitterAccountName()); if (password != null) { currentUser.updatePassword(password, user.getPassword(), user.getPassword()); } userRepository.save(currentUser); }
Or I could first go to the db reload the User, update that object and let the tx commit if I have to.
Thanks
Mark


Reply With Quote
