Reputation:
I am developing a web application with mybatis 3, Spring 3.1.1-RELEASE. I am referring the documentation.
None of the Data Access Layer objects created by MapperFactoryBean
can be pointed as a pointcut of AOP.
I coded spring configuration like this:
<bean id="memberDao" name="memberDao" class="org.mybatis.spring.mapper.MapperFactoryBean">
<property name="mapperInterface" value="com.musicovery.bookervery.dao.MemberDao" />
<property name="sqlSessionFactory" ref="sqlSessionFactory" />
</bean>
<!-- AOP Aspect -->
<bean id="customSqlExceptionTranslator" class="com.musicovery.bookervery.service.exception.CustomSqlExceptionTranslator" />
<!-- AOP Configuration -->
<aop:config>
<aop:advisor advice-ref="customSqlExceptionTranslator" pointcut="bean(memberDao)" />
</aop:config>
With this configuration, Eclipse does not show a pointcut-mark of AOP
When I configure the pointcut to another bean, it works.
But just the objects created by MapperFactoryBean
.
I want to apply AOP with Data Access Layer Objects provided from MapperFactoryBean.
How do I solve this ??
Thanks in advance
Upvotes: 0
Views: 1128
Reputation: 895
(1)pointcut to the com.musicovery.bookervery.dao.MemberDao , not the MapperFactoryBean. (2)the MapperFactoryBean is the adapter which spring use to wrapper mybatis mapper to spring bean.
so you can do like this to achieve the transaction aop:
<aop:config>
<aop:pointcut id="txPointcut"
expression="execution(public * com.musicovery.bookervery.dao.*.*(..))"/>
<aop:advisor pointcut-ref="txPointcut" advice-ref="txAdvice"/>
</aop:config>
Upvotes: 2