DAO中
@Repository
public class TestDao extends BaseHibernateDao {

public void test(){
String hql = " update ZTest set uname = ? where id = 5 ";
Query q = this.getSession(true).createQuery(hql);
q.setString(0, "x");
q.executeUpdate();

String hql2 = " update ZTest set unadfme = ? where id = 5";
Query q2 = this.getSession(true).createQuery(hql2);
q2.executeUpdate();
}

}
SERVICE中@Service
public class ServiceTest extends BaseService {

@Autowired
TestDao testDao; @Override
public void destroy() { } @Override
public void init() { }
@Transactional
public void testTransactional(){
testDao.test();
} }CONTROLLER中@Controller
public class PLetterController extends BaseController {
@Autowired
ServiceTest serviceTest;
@RequestMapping("/testT.do")
public void test(Writer writer) throws Exception{
serviceTest.testTransactional();
}

}SPRING 管理 HIBERNATE <?xml version="1.0" encoding="UTF-8" ?>
<beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:aop="http://www.springframework.org/schema/aop"
        xmlns:tx="http://www.springframework.org/schema/tx"
        xsi:schemaLocation="
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
        http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource" > 
     <property name="driverClassName">
      <value>org.logicalcobwebs.proxool.ProxoolDriver</value> 
     </property> 
     <property name="url"> 
      <value>jdbc:oracle:thin:省略..........</value> 
     </property>     
</bean> 

  <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="packagesToScan">
<list>
<value>com.XXXXXXX.domain</value>
</list>
</property>
<property name="dataSource">
   <ref bean="dataSource" /> 
</property>
<property name="configLocation">
            <value>WEB-INF/classes/hibernate.cfg.xml</value>
        </property>
  </bean>

<!--
<tx:annotation-driven transaction-manager="transactionManager" /> <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean> <bean class="org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator" /> <bean class="org.springframework.transaction.interceptor.TransactionAttributeSourceAdvisor">
<property name="transactionInterceptor" ref="transactionInterceptor"/>
</bean> <bean id="transactionInterceptor" class="org.springframework.transaction.interceptor.TransactionInterceptor">
<property name="transactionManager" ref="transactionManager"/>
<property name="transactionAttributeSource">
<bean class="org.springframework.transaction.annotation.AnnotationTransactionAttributeSource"/>
</property>
</bean>
-->

<bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
        <property name="dataSource" ref="dataSource"/>
    </bean>    <!-- enable the configuration of transactional behavior based on annotations -->
    <tx:annotation-driven transaction-manager="txManager" proxy-target-class="true"/>
</beans>大侠救命!

解决方案 »

  1.   

    参考资料http://japi.javaeye.com/blog/285800http://mrzhangtufu.javaeye.com/blog/241341http://blog.exis.com/colin/archives/2005/07/18/spring-12s-java-5-based-transaction-annotations/
    http://www.21java.com/html/19/t-1719.htmlhttp://justry28.javaeye.com/blog/264241
      

  2.   

    还有个http://topic.csdn.net/u/20080612/18/69d920fe-20d6-404b-9c3b-1c2656be0f12.html
      

  3.   

    http://japi.javaeye.com/blog/285800 
    这里说的很有道理,楼主可以试一下,把service的实现类排除在外
      

  4.   

      我没有service实现类啊,我并没有基于接口 cglib
      

  5.   

    AOP是基于IOC容器的
    好像你的代码里面没有Set注入哦
    IOC都没有
    怎么让AOP帮你管理事物?
      

  6.   


    注解@Autowired就已经注入了
      

  7.   

    不好意思,我把网址发错了,真正的是这里
    http://www.javaeye.com/problems/2646,我没有测试过,这里说是spring2.5的一个bug
    我一直用的都是声明式的,有时间我会测试一下。
      

  8.   

    spring的威力到底有多大呢?探索中
    不知道spring跟
    实现.开发人员提交后.用勾子自动同步新的版本到外面的服务器的测试环境上有
    关系没?
      

  9.   

    你把业务Bean(里面的dao可以直接使用)都手动的通过配置文件注入,就可以了。例子: <bean id="adminService" class="com.yudylaw.ebank.service.AdminService" abstract="true"/>
    <bean id="adminServiceImpl" class="com.yudylaw.ebank.service.impl.AdminServiceImpl" parent="adminService">
    <property name="adminDao">
    <ref bean="adminDaoImpl"/>
    </property>
    </bean>
    Dao你可以直接使用你自己那样的注解,无需在配置文件中注入了。
      

  10.   

    <tx:annotation-driven transaction-manager="txManager"  proxy-target-class="true"/> 中的 proxy-target-class="true" 我记得应该不是默认值,就是不用默认的jdk代理看LZ service 类的内容应该没为该类创建 Interface ,那么proxy-target-class="true"设置的是对的给你几个方案1,取默认值,就是proxy-target-class="true"不要了,给service穿件个接口2,检查下第三方代理类的cglib,看看是否存在版本等问题以上情况是在没报错的前提下把hibernate的show_sql打开看看有输出么,如果有输出还没数据那就是隔离级别的问题了
      

  11.   

    感谢您的建议1. 我想我还是不想用JDK的动态代理,那个是基于接口的,好麻烦,而且项目是多人开发,一改的话,要全部改成接口,。。很麻烦的2.还是想用基于不需要接口的动态代理,就是cglib,我一直也在想,是不是cglib的类库有问题,我不知道spring调用的那个cglib的类在哪个包里如果我的classpath里滑 cglib包,当我设置 proxy-target-class="true" 的时候,应该会报NoClassFoundException但是没有报,难道是spring 自带了cglib,还是JDK里有 cglib?还望高手解答,先谢谢大家了
      

  12.   


    已经有HIBERNATE输出了2008-12-22 12:51:26  [ http-8080-2:9672 ] - [ INFO ]  OSCache: New cache entry, cache stale or cache scope flushed for /p/testT.do_GET_
    Hibernate: 
        update
            MANAGOOD.Z_TEST 
        set
            UNAME=? 
        where
            ID=5
    Hibernate: 
        update
            MANAGOOD.Z_TEST 
        set
            unadfme=? 
        where
            ID=5
      

  13.   


    用的是Oracle数据库我在数据库里已经看到 字段被更新了,就是说当异常发生的时候,SPRING AOP没有拦截住ORZZZZZZZZZZZZZ
      

  14.   

    http://www.javaeye.com/problems/2646这里你测试过了吗
    先不用@Service 注释,测试一下
    用如下代码把你的service累排除在外,然后再xml中注入一下
         <context:component-scan base-package="com.xxx.xxx">  
             <context:exclude-filter type="aspectj"  
                 expression="com.xxx.xxx.ServiceTest" />  
         </context:component-scan>  
       
         <bean name="serviceTest" class="com.mycom.modules.demo.ServiceTest" />  
    测试一下事务是否完整!
      

  15.   

    <bean id="transactionManager"
    class="org.springframework.orm.hibernate3.HibernateTransactionManager">
    <property name="sessionFactory">
    <ref bean="sessionFactory" />
    </property>
    </bean>
      

  16.   


    <tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true" />
      
    <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
    <property name="sessionFactory" ref="sessionFactory" />
    </bean>

    <bean id="serviceTest" class="com.xxx.xxx.service.ServiceTest">
    <property name="letterDao" ref="letterDao" />
    </bean>  
    <context:component-scan base-package="com.xxx.xx">  
             <context:exclude-filter type="aspectj"  expression="com.xxx.xxx.ServiceTest" />  
    </context:component-scan>  之后报找不到letterDao
    LetterDao LetterDao;
    public void setLetterDao(LetterDao LetterDao) {
    this.LetterDao = LetterDao;
    }
    真是郁闷
      

  17.   

    <bean id="listeningclozetitleService" parent="proxytemplate">
    <property name="target">
    <bean class="com.gainuo.elec.service.impl.ListeningClozeTitleServiceImpl">
    <property name="dao">
    <bean class="com.gainuo.elec.dao.hibernate.ListeningClozeTitleDAOImpl">
    <property name="sessionFactory">
    <ref local="mysessionFactory"/>
    </property>
    </bean>
    </property>
    </bean>
    </property>
    </bean><bean id="proxytemplate" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean" abstract="true">
    <!-- 事务代理模板   -->
    <property name="transactionManager">
    <ref local="myTransactionManager" />
    </property>
    <property name="transactionAttributes">
    <props>
    <prop key="insert*">PROPAGATION_REQUIRED</prop>
    <prop key="get*">PROPAGATION_REQUIRED,readOnly</prop>
    <prop key="is*">PROPAGATION_REQUIRED,readOnly</prop>
    </props>
    </property>
    </bean>
      

  18.   

    把dao也拿出来,就是先不用注释ioc。排除一下是不是component-scan的问题
    <bean name="serviceTest" class="com.mycom.modules.demo.ServiceTest" >
    <property name="testDao" ref="testDao"></property>
    </bean>
    <bean id="testDao" class="xxx.yyy.TestDao">
    <property name="sessionFactory">
    <ref local="sessionFactory" />
    </property>
    </bean>
    ......
    顺便问一下,楼主为什么要用编程方式事务,呵呵
      

  19.   

    dao没有被排除啊,只要写了set方法的话,注释应该没问题,呵呵,奇怪了
    发现个问题:
    大小写改一下LetterDao LetterDao; 
    改成LetterDao letterDao; 
    否则set会无效
      

  20.   

    我没有开发测试环境,网上有人也遇到这个问题,也说可能是component-scan和@Transactional冲突导致的
    网址如下:
    http://www.blogjava.net/wangbing/archive/2008/10/08/233203.html
    http://www.javaeye.com/problems/2646
      

  21.   

    还是想用基于不需要接口的动态代理,就是cglib,我一直也在想,是不是cglib的类库有问题,我不知道spring调用的那个cglib的类在哪个包里 如果我的classpath里滑 cglib包,当我设置 proxy-target-class="true" 的时候,应该会报NoClassFoundException 但是没有报,难道是spring 自带了cglib,还是JDK里有 cglib? ????????????
      

  22.   

    谢谢你的热心回答啊,我这个问题弄了3天了,在spring 官网也问了,没有人回答俺<tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true" />
      
    <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
    <property name="sessionFactory" ref="sessionFactory" />
    </bean> 这种方式是最简便的啊在需要控制事务的XxxService的某个具体方法上加上@Transactional注解就可以了AspectJ太强大,我现在的项目中暂时还不需要这么细粒度的AOP
      

  23.   

    用@Transactional才叫细粒度呀,把事务放在代码里,每个都要写呀,如果出现隔离级别,传播行为的设置,那很麻烦的可能是bug吧,你修改一下看看吧,
    别忘了
    大小写改一下LetterDao LetterDao;
    改成LetterDao letterDao; 
    只需把serviceTest拿到xml配置,其他的还是用annotation注入即可
    呵呵,希望你能逐一的看一下我的回复,祝你好运
      

  24.   

    这个我改过了,引用一下 http://www.blogjava.net/wangbing/archive/2008/10/08/233203.html里的话“service就必须写在xml文件里面了。感觉不爽。”
      

  25.   

    哈哈,“不爽”也比“不能”强,spring2.5的bug有很多,前阵子我就遇到一个
    被context:component-scan管理进来的不同package下的同样名字的bean,
    就会出doesn't recognize same beans when included multiple times on classpath错误。同时强烈建议楼主采用声明式事务,配置一次即可!免去了烦琐的@Transactional 
      

  26.   


    如何声明式事务?我就是想一次搞定,不喜欢增量开发,喜欢注解,不喜欢XML的一个懒人。。@_@我是参考的1. 声明式事务管理 - Spring Framework reference 2.0.5 参考手册中文版
    URL  :       http://doc.javanb.com/spring-framework-reference-zh-2-0-5/ch09s05.html
      

  27.   

    spring的声明式事务是最炫耀的地方,而且极其简单。配置一次即可,这可能也是回答你这个问题的人不多的原因,因为大家都用的声明的
    bean和事务是脱离的,二者没有关系,例子给你看一下,你可以改写一下
    <context:component-scan base-package="*" />
    <context:property-placeholder location="classpath:jdbc.properties" />
    <bean id="dataSource" 
    class="org.apache.commons.dbcp.BasicDataSource"
    destroy-method="close">
    ......
    </bean> <bean id="sessionFactory"
    class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
    ......
    </bean>
    <bean id="transactionManager"
    class="org.springframework.orm.hibernate3.HibernateTransactionManager">
    <property name="sessionFactory" ref="sessionFactory" />
    </bean>
    <aop:config>
    <!--这里配置规则,满足以下规则的将触发事务,第一个*表示所有返回类型,第二个表示service包下的所有class,第三个表示所有方法-->
    <aop:pointcut id="baseServiceMethods"
    expression="execution(* xxx.yyy.service.*.*(..))" />
    <aop:advisor advice-ref="txAdvice"
    pointcut-ref="baseServiceMethods" />
    </aop:config> <tx:advice id="txAdvice" transaction-manager="transactionManager">
    <tx:attributes>
    <!--对于方法的细粒度事务配置,符合条件的方法冠以相应的事务-->
    <tx:method name="select*" read-only="true" propagation="REQUIRED"/>
    <tx:method name="find*" read-only="true"  propagation="REQUIRED"/>
    <tx:method name="save*"  propagation="REQUIRED" isolation="REPEATABLE_READ"/>
    <tx:method name="update*"  propagation="REQUIRED" isolation="REPEATABLE_READ"/>
    <tx:method name="add*"  propagation="REQUIRED" isolation="REPEATABLE_READ" />
    <tx:method name="delete*"  propagation="REQUIRED" isolation="REPEATABLE_READ"/>
    </tx:attributes>
    </tx:advice>
      

  28.   


    为何这样配置后,我在public void test(){
    String hql = " update ZTest set uname = ? where id = 5 ";
    Query q = this.getSession(true).createQuery(hql);
    q.setString(0, "1");
    q.executeUpdate();

    throw new IllegalStateException();
    }后,数据字段还是更新了。。
      

  29.   

    也一直弄不懂AOP呀,来学习!
      

  30.   


    我的dao的service都不是基于接口的,能用吗?
      

  31.   

    接分
    PS: 
    我的目标是 ----> ^_^
      

  32.   

    怎么会不起作用呢,我的测试代码如下,测试通过。
    spring版本:2.5,用声明式事务
    applicationContext.xml:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    ......
    <context:component-scan base-package="com.huaxia.oaapp">
    <context:include-filter type="aspectj" expression="com.huaxia.oaapp.service..*"/>
    <context:include-filter type="aspectj" expression="com.huaxia.oaapp.entity..*"/>
    <context:exclude-filter type="aspectj" expression="com.huaxia.oaapp.action..*"/>
    </context:component-scan>
    <context:property-placeholder location="classpath:jdbc.properties" />
    <bean id="dataSource" 
    class="org.apache.commons.dbcp.BasicDataSource"
    destroy-method="close">
    ......
    </bean>
    <bean id="sessionFactory"
    class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
    <property name="dataSource">
    <ref bean="dataSource" />
    </property>
    <property name="hibernateProperties">
    <props>
    <prop key="hibernate.dialect">
    org.hibernate.dialect.SQLServerDialect
    </prop>
    <prop key="hibernate.show_sql">true</prop>
    <prop key="hiberante.format_sql">true</prop>
    <!-- <prop key="hibernate.cache.provider_class">
    org.hibernate.cache.EhCacheProvider
    </prop> -->
    </props>
    </property>
    <property name="annotatedClasses">
    <list>
    <value>com.huaxia.oaapp.entity.Document</value>
    </list>
    </property>
    <property name="annotatedPackages">
    <list>
    <value>com.huaxia.oaapp.entity</value>
    </list>
    </property>
    </bean>
    <bean id="transactionManager"
    class="org.springframework.orm.hibernate3.HibernateTransactionManager">
    <property name="sessionFactory" ref="sessionFactory" />
    </bean>
    <aop:config>
    <aop:pointcut id="baseServiceMethods"
    expression="execution(* com.huaxia.oaapp.service.*.*(..))" />
    <aop:advisor advice-ref="txAdvice"
    pointcut-ref="baseServiceMethods" />
    </aop:config>
    <!-- <aop:aspectj-autoproxy /> -->
    <tx:advice id="txAdvice" transaction-manager="transactionManager" >
    <tx:attributes>
    <tx:method name="select*" read-only="true" propagation="REQUIRED"/>
    <tx:method name="find*" read-only="true"  propagation="REQUIRED"/>
    <tx:method name="save*"  propagation="REQUIRED" isolation="REPEATABLE_READ"/>
    <tx:method name="update*"  propagation="REQUIRED" isolation="REPEATABLE_READ"/>
    <tx:method name="add*"  propagation="REQUIRED" isolation="REPEATABLE_READ" />
    <tx:method name="delete*"  propagation="REQUIRED" isolation="REPEATABLE_READ"/>
    </tx:attributes>
    </tx:advice>
    </beans>
    Document类如下:@Entity
    @Table(name="Documents")
    public class Document {
    @Id
    // @GeneratedValue(strategy=GenerationType.AUTO)
    private Long id;
    private String sn;
    get/set......documentService代码如下:
    package com.huaxia.oaapp.service;
    ......
    @Component("documentService")
    public class DocumentServiceImpl /*implements DocumentService */{
    @Autowired
    private SessionFactory sessionFactory;
    public SessionFactory getSessionFactory() {
    return sessionFactory;
    }
    public void setSessionFactory(SessionFactory sessionFactory) {
    this.sessionFactory = sessionFactory;
    }
    /* (non-Javadoc)
     * @see com.huaxia.oaapp.service.DocumentService#saveOrUpdateDocument(com.huaxia.oaapp.entity.Document)
     */
    public void saveOrUpdateDocument(Document document11){

    Document document = new Document();
    document.setId(10l);
    document.setSn("10");
    this.sessionFactory.getCurrentSession().flush();
    Document document1 = new Document();
    document1.setId(11l);
    document1.setSn("11");
    //document1.setUser(user);

    this.sessionFactory.getCurrentSession().saveOrUpdate(document);
    this.sessionFactory.getCurrentSession().save(document1);
    }
    /* (non-Javadoc)
     * @see com.huaxia.oaapp.service.DocumentService#findDocumentById(java.lang.Long)
     */
    public Document findDocumentById(Long id) {
    return (Document) this.sessionFactory.getCurrentSession().get(Document.class,
    id);
    }
    ......
    我的junit测试类如下:
    public class UserServiceTest {
    private DocumentServiceImpl documentService;
    @Before
    public void setUp() throws Exception {
    ApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");
    this.documentService = (DocumentServiceImpl) ctx.getBean("documentService");
    }
    @Test
    public void testSaveOrUpdateUser() {
    this.documentService.saveOrUpdateDocument(null);
    }
    }
    注意:我注释掉了/*implements DocumentService */部分,启动cglib代理
    2008-12-22 22:37:34,569 DEBUG [org.springframework.aop.framework.Cglib2AopProxy] - Creating CGLIB2 proxy: target source is SingletonTargetSource for target object [com.huaxia.oaapp.service.DocumentServiceImpl@eca36e]
    ......
    当saveOrUpdateDocument方法执行时,事务启动
    ......
    2008-12-22 22:40:23,819 DEBUG [org.springframework.transaction.interceptor.NameMatchTransactionAttributeSource] - Adding transactional method [select*] with attribute [PROPAGATION_REQUIRED,ISOLATION_DEFAULT,readOnly]
    2008-12-22 22:40:23,819 DEBUG [org.springframework.transaction.interceptor.NameMatchTransactionAttributeSource] - Adding transactional method [find*] with attribute [PROPAGATION_REQUIRED,ISOLATION_DEFAULT,readOnly]
    2008-12-22 22:40:23,819 DEBUG [org.springframework.transaction.interceptor.NameMatchTransactionAttributeSource] - Adding transactional method [save*] with attribute [PROPAGATION_REQUIRED,ISOLATION_REPEATABLE_READ]
    ......
    当调用失败时(我这里用的是sqlserver,楼主可以看控制台的log4j,这里记载着详细的信息,包括事务和cglib代理是否成功):
    com.microsoft.sqlserver.jdbc.SQLServerException: Violation of PRIMARY KEY constraint 'PK_Documents'. Cannot insert duplicate key in object 'dbo.Documents'.
    ......
    2008-12-22 22:40:24,225 DEBUG [org.springframework.orm.hibernate3.HibernateTransactionManager] - Initiating transaction rollback after commit exception
    成功回滚
    贴了好一大堆,哈哈,我这里测试已经通过,楼主可以参考一下。
      

  33.   

    为什么我这边还是不行DAO中
    public void test(){
    String param = "sdfsdfsdf";
    String sql = " update z_test set uname = '" + param + "' where id = 5 ";
    this.getJdbcTemplate().queryForList(sql);

    String sql2 = " update z_test set unamfe = 'sdfsdfsd' where id = 5 ";
    this.getJdbcTemplate().queryForList(sql2);
    }我在service中调了这个方法那个sql2中 unamfe在数据库是没有的字段,执行的时候会抛异常,照理说,事务会回滚的,但是我在数据库还是看到了 id为5的 uname字段改成了 sdfsdfsdf
    我的配置文件<bean id="transactionManager"
            class="org.springframework.orm.hibernate3.HibernateTransactionManager">
            <property name="sessionFactory" ref="sessionFactory" />
        </bean>
        <aop:config>
            <aop:pointcut id="baseServiceMethods"
                expression="execution(* com.xx.service.*.*(..))" />
            <aop:advisor advice-ref="txAdvice"
                pointcut-ref="baseServiceMethods" />
        </aop:config>
        <!-- <aop:aspectj-autoproxy /> -->
        <tx:advice id="txAdvice" transaction-manager="transactionManager" >
            <tx:attributes>
                <tx:method name="select*" read-only="true" propagation="REQUIRED"/>
                <tx:method name="find*" read-only="true"  propagation="REQUIRED"/>
                <tx:method name="save*"  propagation="REQUIRED" isolation="REPEATABLE_READ"/>
                <tx:method name="update*"  propagation="REQUIRED" isolation="REPEATABLE_READ"/>
                <tx:method name="add*"  propagation="REQUIRED" isolation="REPEATABLE_READ" />
                <tx:method name="delete*"  propagation="REQUIRED" isolation="REPEATABLE_READ"/>
            </tx:attributes>
        </tx:advice>
    PS:我的SPRINGMVC 放在 dispatch-servlet.xmlhibernate放在 spring-hibernate.xmlspring security 放在 spring-security.xml这样配置是不是有问题?
      

  34.   

    为什么是getJdbcTemplate,不是hibernateTemplate吗?
    JdbcTemplate不使用的HibernateTransactionManager呀,用的是DataSourceTransactionManager有点乱呀,呵呵,你根本没加入事务!
      

  35.   


    我是没折了,把各种Manager排列组合试一下,真是郁闷,搞了4天了
      

  36.   

    更换成hibernateTemplate,也就是你的dao继承HibernateDaoSupport即可还有
          <tx:attributes>
                <tx:method name="select*" read-only="true" propagation="REQUIRED"/>
                ......
            </tx:attributes> 
    这里要包含你的那个方法,比如你的serviceTest中的方法是
    public void testTransactional(){
    testDao.test();

    那么需要把这个方法加入进来
          <tx:attributes>
                <tx:method name="select*" read-only="true" propagation="REQUIRED"/>
                <tx:method name="save*"  propagation="REQUIRED" isolation="REPEATABLE_READ"/>
                <tx:method name="testTransactional"  propagation="REQUIRED" isolation="REPEATABLE_READ"/> 
                ......
            </tx:attributes> 
    这个是通配符,就是方法名字满足这个通配符的才被加入事务!你先屡一下思路吧
      

  37.   

    谢谢Landor的热心回答,我先测试。。
      

  38.   


    因为我基础不好,错加了2个1.org.springframework.orm.hibernate3.support.OpenSessionInViewInterceptor2.org.springframework.orm.hibernate3.support.OpenSessionInViewFilter去掉其中一个就OK了本人比较喜欢基于非接口的 cglib动态代理事务编程式事务估计很少人用谢谢 Landor2004的热心回答,谢谢CSDN的网友,结贴!
      

  39.   

    接分
    PS: 
    我的目标是 ----> ^_^
      

  40.   

    接分
    PS: 
    我的目标是 ----> ^_^
      

  41.   

    接..分...
    PS: 
    我的目标是 ----> ^_^
      

  42.   

    俺也刚开始学AOP,也遇上过这样的问题,正在等待大侠们帮忙解决……
      

  43.   

    37楼正解。
    http://blog.csdn.net/masuwen/article/details/5445349
      

  44.   

    感谢,遇到同一个问题。虽然不知道哪边多加了个OpenSessionInView...但明天还是研究下