Often we have to use some of the methods which don't return anything useful. If I invoke saveOrUpdate() in hibernate , I don't know whether it has been performed successfully . I use a implementation like this (which I think is a bit awkward) :
public int saveOrUpdateA(A a) {
int resultFlag = 0 ;
try {
// obtaining session is omitted
session.saveOrUpdate(a);
resultFlag = 1 ;
} catch (Exception e) {
e.printStackTrace();
}
return resultFlag ;
}
How do you do this ? Any good idea ?
Exception should be caught in DAO layer or Service Layer ?