当前位置: 代码迷 >> Java Web开发 >> [SSH]关于AfterReturningAdvice的一个有关问题!高手速进!
  详细解决方案

[SSH]关于AfterReturningAdvice的一个有关问题!高手速进!

热度:290   发布时间:2016-04-17 00:57:34.0
[SSH]关于AfterReturningAdvice的一个问题!!高手速进!!!
问题描述:在AfterReturningAdvice的实现类的afterReturning方法中查询失败
spring配置
XML code
    <!-- TransactionManager -->    <bean id="hibTransactionManager"        class="org.springframework.orm.hibernate3.HibernateTransactionManager">        <property name="sessionFactory" ref="sessionFactory" />    </bean>    <tx:advice id="txAdvice" transaction-manager="hibTransactionManager">        <tx:attributes>            <tx:method name="add*" propagation="REQUIRED" />            <tx:method name="del*" propagation="REQUIRED" />            <tx:method name="update*" propagation="REQUIRED" />            <tx:method name="select*" propagation="REQUIRED"/>            <tx:method name="search*" propagation="REQUIRED"/>            <tx:method name="insert*" propagation="REQUIRED" />            <tx:method name="do*" propagation="REQUIRED" />            <tx:method name="*" propagation="SUPPORTS" read-only="true" />        </tx:attributes>    </tx:advice>    <aop:config>        <aop:pointcut expression="execution(* biz.*.*(..))"            id="bizMethods" />        <aop:advisor advice-ref="txAdvice" pointcut-ref="bizMethods" />    </aop:config>    <!--        ********************************我是很长的分割线********************************    -->    <!-- Dao -->    <bean id="petDiaryDao" class="dao.impl.hib.PetDiaryDaoHibImpl">        <property name="sessionFactory" ref="sessionFactory" />    </bean>    <bean id="petInfoDao" class="dao.impl.hib.PetInfoDaoHibImpl">        <property name="sessionFactory" ref="sessionFactory" />    </bean>    <!--        ********************************我是很长的分割线********************************    -->    <!-- Biz -->    <bean id="petDiaryBizTarget" class="biz.impl.PetDiaryBizImpl">        <property name="petDiaryDao" ref="petDiaryDao" />    </bean>    <bean id="petInfoBizTarget" class="impl.PetInfoBizImpl">        <property name="petInfoDao" ref="petInfoDao" />    </bean>    <!--        ********************************我是很长的分割线********************************    -->    <!-- Advice -->    <bean id="lotteryAdvice" class="advice.LotteryAdvice">        <property name="petInfoBiz" ref="petInfoBizTarget" />    </bean>    <bean id="petInfoBiz" class="org.springframework.aop.framework.ProxyFactoryBean">        <property name="proxyInterfaces" value="biz.PetInfoBiz" />        <property name="interceptorNames" value="lotteryAdvice" />        <property name="target" ref="petInfoBizTarget" />    </bean>    <bean id="petDiaryBiz" class="org.springframework.aop.framework.ProxyFactoryBean">        <property name="ProxyInterfaces" value="biz.PetDiaryBiz" />        <property name="interceptorNames" value="lotteryAdvice" />        <property name="target" ref="petDiaryBizTarget" />    </bean>


LotteryAdvice类
Java code
         private PetInfoBiz petInfoBiz = null;    public void setPetInfoBiz(PetInfoBiz petInfoBiz) {        this.petInfoBiz = petInfoBiz;    }    public void afterReturning(Object resultValue, Method method,            Object[] args, Object target) throws Throwable {            PetDiary petDiary = (PetDiary)args[0];            [b]PetInfo petInfo = this.petInfoBiz.selectPetInfo(petDiary.getPetInfo().getPetId());[/b]//这里petInfo的值全部为空,并且SQL语句也不输出(petId有值,且在数据库中存在)            petInfo.setPetCute(petInfo.getPetCute()+10);            petInfo.setPetLove(petInfo.getPetLove()+10);            this.petInfoBiz.updatePet(petInfo);            System.out.println("["+petInfo.getPetName()+"]聪明+10,爱心+10");            }
  相关解决方案
本站暂不开放注册!
内测阶段只得通过邀请码进行注册!
 
  • 最近登录:Wed May 23 01:33:48 CST 2018
  • 最近登录:Wed May 23 01:33:48 CST 2018
  • 最近登录:Wed May 23 01:33:48 CST 2018
  • 最近登录:Wed May 23 01:33:48 CST 2018
  • 最近登录:Wed May 23 01:33:48 CST 2018