0
I want to know more about transactions in spring. I have the following structure:
My Service:
@Service
@Transactional
public class MinhaClasseServiceImpl implements MinhaClasseService {
@Autowired
private MinhaClasseDao minhaClasseDao;
@Autowired
private OutraClasseDao outraClasseDao;
@Autowired
private MaisOutraClasseDao maisOutraClasseDao;
public void salvarMinhaClasse(final MinhaClasse minhaClasse) throws Exception {
maisOutraClasseDao.salvarMaisOutraClasse(minhaClasse().getOutraClasse().getMaisOutraClasse());
outraClasseDao.salvarOutraClasse(minhaClasse().getOutraClasse());
minhaClasseDao.salvarminhaClasse(minhaClasse());
}
}
But when saving, an exception is made:
11:11:33,766 ERROR [stderr] (default task-13) javax.persistence.PersistenceException:
org.hibernate.PersistentObjectException: detached entity passed to persist:
com.teste.entity.MaisOutraClasse
Is the transaction not spreading? Can someone help me?