next ...
I'm using spring for a private project and wanted to know the best way to catch errors.
I have my repository classes:
@Repository
public class PrimeiraClasseDaoImpl implements PrimeiraClasseDao {
@PersistenceContext
private EntityManager em;
public void salvarObjeto(final ObjetoTeste objetoTeste) {
em.persist(objetoTeste);
}
... outros métodos....
@Repository
public class SegundaClasseDaoImpl implements SegundaClasseDao {
@PersistenceContext
private EntityManager em;
public void salvarObjeto(final ObjetoTeste objetoTeste) {
em.persist(objetoTeste);
}
... outros métodos....
I also have the service class:
@Service
@Transactional
public class PrimeiraClasseServiceImpl implements PrimeiraClasseService {
@Autowired
private PrimeiraClasseDao primeiraClasseDao;
@Autowired
private SegundaClasseDao segundaClasseDao;
public void salvarObjeto(PrimeiraClasse primeiraClasse) {
segundaClasseDao.salvarObjeto(primeiraClasse.getSegundaClasse());
primeiraClasseDao.salvarObjeto(primeiraClasse);
}
I want to change the void of these methods to return success or error, I thought about creating an object and fixing the error ...
But I wanted to know how I capture the errors and stick to that object.
I do not know if you have any other way to work, how do you work in this situation?