小编use*_*909的帖子

使用Spring 3 @Transactional注释时,事务不会回滚

我正在使用Spring(3.0版)'@Transactional'注释来演示Spring中的事务支持,但无法实现这一点(尽管已经看到人们在此论坛和其他技术论坛中遇到过类似的问题).

这是我的Spring配置条目spring-application-context.xml:

<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
    <property name="dataSource" ref="dataSource"/>
  </bean>

  <tx:annotation-driven /> 

  <bean id="formatDao" class="com.gj.dao.FormatDao">
    <property name="dataSource" ref="dataSource"/>
  </bean>
Run Code Online (Sandbox Code Playgroud)

这是我的测试类中的事务方法:

  @Transactional(readOnly = true)
  public class FormatDaoTest
  {

      private static ApplicationContext context = new FileSystemXmlApplicationContext(
        "c:\\catalogue\\src\\com\\gj\\conf\\spring-application-context.xml");

      public static void main(String[] args)
      {
    FormatDaoTest test = new FormatDaoTest();
    test.doTransaction();
      }


      @Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = false)
      public void doTransaction()
      {

    IDao dao = (IDao) context.getBean("formatDao");

    Format newFormat = new Format(1, "Test Format 1");

    // Creating a single format
    dao.create(newFormat);

    List newFormatList …
Run Code Online (Sandbox Code Playgroud)

spring unit-testing transactions ora-12899

2
推荐指数
1
解决办法
3431
查看次数

标签 统计

ora-12899 ×1

spring ×1

transactions ×1

unit-testing ×1