Categories
java jpa spring spring-boot spring-data-jpa

SpringBoot JPA need no .save() on @Transactional?

I have short question:

Do I need a repo.save(x) call on @Transactional methods?

I ask cause I see changes on my DB without save, and read no clear docs about it.

So is it working as intended, or just a (welcome) unexpected behavior?

example:

@Autowired
private UserRepo repo;
@Transactional
@PutMapping
public Long put(@RequestBody User user)
{
User u = repo.findOne(user.getId());
u.setName("Paul");
repo.save(u); // DO I NEED THIS LINE?
}

I’am just unsure about it, so maybe someone can shed some light on the subject?