Let's say I'm using spring and hibernate and I do something like the following in one of my transactional service methods. What would be the expected outcomes of the prints and more importantly why?
// user1 perviously has some other name then x
User userInstance = userDAO.findById(1);
userInstance.setName("x");
System.out.println(userDAO.findById(1).getName());
userDAO.save(userInstance);
System.out.println(userDAO.findById(1).getName());
Would I always expect to see the changes that I made to the user entity I queried and why? How exactly does this interact with the hibernate proxy and the first level cache?
Thanks for any insights!