Hi!
I'm developing a Spring MVC web app following the stack:
@Controller
@Service@Transactional
@Repository
I inserted the org.springframework.dao.annotation.PersistenceExce ptionTranslationPostProcessor in my applicationContext.xml
and in my spring-servlet:
I found out that if in my controller i call directly the DAO the DataAccessException is caught, while if I use the service it does not.Code:<bean class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver"> <property name="exceptionMappings"> <map> <entry key="DataAccessException" value="dataAccessFailure"/> </map> </property> </bean>
It can be obvious because it is raised an unchecked exception, but the question is: How to propagate the DataAccessException in order to be caught by the SimpleMappingExceptionResolver?
Should I have to use a try catch(DataAccessException) block in the service? I tried but it's not caught..
Another question: where is it useful insert log? In the DAO or in the service?
What is the best practise?
Thank you in advance


Reply With Quote
