Unable to proxy method HibernateDaoSupport.setHibernateTemplate because it is final

最近整合struts 1 + spring 2.5 + hibernate 3.2,demo调通后分析日志,发现控制台输出一系列警告:

警告: Unable to proxy method [public final org.springframework.orm.hibernate3.HibernateTemplate org.springframework.orm.hibernate3.support.HibernateDaoSupport.getHibernateTemplate()] because it is final: All calls to this method via a proxy will be routed directly to the proxy.
2014-5-14 22:47:52 org.springframework.aop.framework.Cglib2AopProxy doValidateClass
解决方案:修改applicationContext.xml中spring事务控制机制,换一种实现方案。

报警告信息的配置:

	<!-- 指定事务管理器类,将sessionFactory注入,让该事务管理器具有打开和关闭事务的能力 -->
    <bean id="transactionManager"
    	class="org.springframework.orm.hibernate3.HibernateTransactionManager">
    	<property name="sessionFactory" ref="sessionFactory"></property>
    </bean>
	<!-- 为事务管理器类指定匹配器,通过用name指定的匹配字符串进行对对应的方法进行打开和关闭事务 -->
    <tx:advice id="txAdvice" transaction-manager="transactionManager">
       <tx:attributes>
           <tx:method name="save*" propagation="REQUIRED" />
           <tx:method name="delete*" propagation="REQUIRED" />
           <tx:method name="modify*" propagation="REQUIRED" />
           <tx:method name="deploy*" propagation="REQUIRED" />
           <tx:method name="*" read-only="true" />
       </tx:attributes>
    </tx:advice>

    <!-- 为事务管理器类指定进行匹配的范围,到指定的地方通过匹配器字符串进行筛选,对应上后为该方法打开和关闭事务 -->
    <aop:config proxy-target-class="true">
       <aop:pointcut id="managerOperation" expression="execution(* com.xy6.dao.*.*(..))" />
       <aop:advisor advice-ref="txAdvice" pointcut-ref="managerOperation" />
    </aop:config>
修改后的配置:

	<bean id="myTransactionManager"
		class="org.springframework.orm.hibernate3.HibernateTransactionManager">
		<property name="sessionFactory" ref="sessionFactory" />
	</bean>
	<bean id="myBaseTransactionProxy"
		class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"
	  	abstract="true">
		<property name="transactionManager" ref="myTransactionManager" />
		<property name="transactionAttributes">
		<props>
			<prop key="*">PROPAGATION_REQUIRED</prop>
		    <!--
		     <prop key="insert*">PROPAGATION_REQUIRED</prop>
		     <prop key="save">PROPAGATION_REQUIRED</prop>
		     <prop key="update*">PROPAGATION_REQUIRED</prop>
		     <prop key="edit*">PROPAGATION_REQUIRED</prop>
		     <prop key="del*">PROPAGATION_REQUIRED</prop>
		     <prop key="get*">PROPAGATION_REQUIRED,readOnly</prop>
		     <prop key="query*">PROPAGATION_REQUIRED,readOnly</prop>
		     <prop key="disPlay*">PROPAGATION_REQUIRES_NEW</prop>
		    -->
		</props>
		</property>
	</bean>
警告产生原因:org.springframework.orm.hibernate3.support.HibernateDaoSupport类中 getHibernateTemplate等方法为final类型。

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值