I am building ReSTful APIs using Spring-boot 1.5.10.RELEASE, Java 8 and MySQL 5.6 and jOOQ(https://www.jooq.org/doc/3.9/manual/). In Service layer, I am using @Transactional annotation offered by Spring framework.
Here is how my UserService class looks like:
@Service
@Slf4j
public class UserService {
//My repository isn't using @Transactional annotation, only Service layer
@Autowired
private UserRepository userRepository;
@Transactional
public User createUser(User user){
...
}
@Transactional
public User updateUser(User user){
...
}
@Transactional
public Boolean deleteUser(Integer userId){
...
}
@Transactional(readOnly = true)
public User findUserByUserId(Integer userId){
...
}
}
Shall I use @Transactional(readOnly=true) or not use @Transactional annotation at all for HTTP GET API calls? Are there any side effects I should be aware of when not using @Transactional on all CRUD operations above? Do I have to make jOOQ aware of Transactional capabilities by offering configuration?
I have not used @Transactional from Spring framework in past but do understand what transactions are and why we need them.
I hope I didn't miss any details in question :)