We are using spring roo, and there are some methods in the codebase annotated with @Transactional.
For example,
class XService {
@Transactional
public Response doSomething(String email) {
User u = User.findByEmail(email);
u.setLastModified(Calendar.getInstance());
return new Response("OK");
}
}
Notice that u.merge() is not called after setLastModified. What should be the value in lastModified column of user table after this method is complete.
Thanks!
Depending on:
XService.doSomthing
is annotated with @Transactional
or not, and it ends with a RuntimeException
or not.By default, if you call to XService.doSomthing
from a controller, the User instance should be updated as u
is an attached instance and method doesn't throw a runtime exception.
Look at this post which I think can explain you interesting information about transaction behaviours on JPA.
Good luck.