Managing DAO transactions
Aspects do not only intercept the service layer but also the data transaction layer. This recipe will give us a concrete scenario when AOP is needed in most DAO transactions. Aspects implemented for the DAO layer are just limited to logging, tracing, and validating tasks due to undesirable effects when transactions become complex.
Getting started
Open ch05 and add an @Aspect that will filter null record(s) from JdbcSimpleInsert and JdbcTemplate.
How to do it...
Our first AOP implementation will be applied for managing DAO transactions. Follow the following procedure to log all the DAO transactions using aspects, advices and Pointcuts:
- Before this recipe starts, be sure to have the
EmployeeDaoandEmployeeDaoImplinside the packagesorg.packt.aop.transaction.daoandorg.packt.aop.transaction.dao.impl, respectively. - To apply aspects to our DAO transactions, let us create an
@Aspectinside the packageorg.packt.aop.transaction.corethat will monitorgetEmployees()andgetEmployee...