lundi 6 avril 2015

How to handle objectNotFoundExcetion at service layer

I have two methods at service layer in springs MVC. In one method i am throwing ObjectNotFoundExcetion with my own reason when my record not found. I am calling this method from the first method. In first method I have declared try catch for it and have further code. But once i get the ObjectNotFoundException, the whole transaction rolls back. Hence I am not able to do further processing. Why is the transaction rolling back at service layer ?



public void foo() {
try {
boo();
} catch(ObjectNotFoundException e) {

}
// further code.
}

public void boo() throws ObjectNotFoundException
{
if () {
} else {
throw new ObjectNotFoundException("Record not found");
}
}

Aucun commentaire:

Enregistrer un commentaire