<tx:advice id="txAdvice" transaction-manager="myHibTxManager">
<tx:attributes> <tx:method name="get*" propagation="SUPPORTS" read-only="true" />
<tx:method name="load*" propagation="SUPPORTS" read-only="true" />
<tx:method name="search*" propagation="SUPPORTS" read-only="true" />
<tx:method name="*" propagation="REQUIRED" />
</tx:attributes >
</tx:advice>
<aop:config>
<aop:pointcut id="serviceMethods"
expression="execution(* com.crm.serviceimpl.*.*(..))" />
<aop:advisor advice-ref="txAdvice" pointcut-ref="serviceMethods" />
</aop:config>
高手解释一下
<tx:attributes> <tx:method name="get*" propagation="SUPPORTS" read-only="true" />
<tx:method name="load*" propagation="SUPPORTS" read-only="true" />
<tx:method name="search*" propagation="SUPPORTS" read-only="true" />
<tx:method name="*" propagation="REQUIRED" />
</tx:attributes >
</tx:advice>
<aop:config>
<aop:pointcut id="serviceMethods"
expression="execution(* com.crm.serviceimpl.*.*(..))" />
<aop:advisor advice-ref="txAdvice" pointcut-ref="serviceMethods" />
</aop:config>
高手解释一下
解决方案 »
- 技术面试,分两次,那么第二次问哪些方面的呢?
- 用SAX解析XML的疑问
- 数据库的表属于MVC中的模型层吗?急!!!!
- 用的是jpetstore的框架(struts+spring+ibatis),怎么实现文件的上传???
- 错误提示是这样的,请问是什么地方出了问题?
- javamail smtp连接缓冲池
- oracle DB中,如何设置链接url才能从oracleresultsetMetadata中取得table name?
- 像我这个简历,为什么连面试机会都没有??????
- 怎么学习JMF
- struts1.1中的multibox怎么用
- Oracle JDBC 不支持命名的输出参数吗?
- javaScript问题!求答案!
<tx:attributes> <tx:method name="get*" propagation="SUPPORTS" read-only="true" />
<tx:method name="load*" propagation="SUPPORTS" read-only="true" />
<tx:method name="search*" propagation="SUPPORTS" read-only="true" />
<tx:method name="*" propagation="REQUIRED" />
</tx:attributes >
</tx:advice>
这一段 是定义 事务的传播特性 和 是否 对 异常进行处理 你看你的都是使用的 propagation="SUPPORTS 说明是 当前 业务如果运行在事务中就使用改事务 如果没有事务就以无事务方式运行 <aop:config>
<aop:pointcut id="serviceMethods"
expression="execution(* com.crm.serviceimpl.*.*(..))" />
<aop:advisor advice-ref="txAdvice" pointcut-ref="serviceMethods" />
</aop:config>
这个是配置你的 切入点
pointcut 指定的id expression指定改切入点 运用到那些 接入点上 com.crm.serviceimpl.*.*(..))" 是com.crm.serviceimpl下面的所有包的所有类的所有方法下面:
<aop:advisor
定义通知 把上面定义处理事务的通知txAdvice(切面) 运用到 serviceMethods搞切入点上
最后的效果就是: 你的serviceimpl里面的所有类的所有方法 都是有spring来管理hibernate事务 ,使用的使用 要注意 hibernateTemplate的使用