I am using spring and hibernate. i am using spring for transaction management. i have below class.
@Service
@Transactional(readOnly = true)
public class Sample implements SampleInterface{
@Override
public List<Some> getData(){
//gets data after that it updates something
setStatus(someId);
}
@Override
@Transactional
public void setStatus(Long someId){
//sets status
}
}
If i dont keep @Transactional for getData() then i get below exception.
Caused by: org.springframework.dao.InvalidDataAccessApiUsageException: Write operations are not allowed in read-only mode (FlushMode.MANUAL): Turn your Session into FlushMode
if i keep @Transactional for getData() then it will save properly. what is an issue here? any how i have @Transactional for setStatus(). Still do i need to keep @Transactional for getData() as it is calling a public method which will set the status?
Thanks!