org.hibernate.Transaction.setRollbackOnly()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(6.0k)|赞(0)|评价(0)|浏览(119)

本文整理了Java中org.hibernate.Transaction.setRollbackOnly()方法的一些代码示例,展示了Transaction.setRollbackOnly()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Transaction.setRollbackOnly()方法的具体详情如下:
包路径:org.hibernate.Transaction
类名称:Transaction
方法名:setRollbackOnly

Transaction.setRollbackOnly介绍

暂无

代码示例

代码示例来源:origin: hibernate/hibernate-orm

/**
 * Make a best effort to mark the underlying transaction for rollback only.
 */
default void markRollbackOnly() {
  setRollbackOnly();
}

代码示例来源:origin: hibernate/hibernate-orm

@Test
public void testMapsIdJoinColumnOneToOneSelectException() {
  setupTest( PersonMapsIdColumnSelectException.class, 1L, true );
  doInHibernate(
      this::sessionFactory, session -> {
        Person pCheck = session.find( PersonMapsIdColumnSelectException.class, 1L );
        assertNotNull( pCheck );
        assertFalse( Hibernate.isInitialized( pCheck.getCity() ) );
        try {
          Hibernate.initialize( pCheck.getCity() );
          fail( "Should have thrown ObjectNotFoundException" );
        }
        catch (ObjectNotFoundException expected) {
          session.getTransaction().setRollbackOnly();
        }
      }
  );
}

代码示例来源:origin: hibernate/hibernate-orm

@Test
public void testMapsIdOneToOneSelectException() {
  setupTest( PersonMapsIdSelectException.class, 1L, true );
  doInHibernate(
      this::sessionFactory, session -> {
        Person pCheck = session.find( PersonMapsIdSelectException.class, 1L );
        assertNotNull( pCheck );
        assertFalse( Hibernate.isInitialized( pCheck.getCity() ) );
        try {
          Hibernate.initialize( pCheck.getCity() );
          fail( "Should have thrown ObjectNotFoundException" );
        }
        catch (ObjectNotFoundException expected) {
          session.getTransaction().setRollbackOnly();
        }
      }
  );
}

代码示例来源:origin: hibernate/hibernate-orm

@Test
public void testMapsIdJoinColumnOneToOneSelectException() {
  setupTest( PersonMapsIdColumnSelectException.class, 1L, true );
  doInHibernate(
      this::sessionFactory, session -> {
        Person pCheck = session.find( PersonMapsIdColumnSelectException.class, 1L );
        assertNotNull( pCheck );
        assertFalse( Hibernate.isInitialized( pCheck.getCity() ) );
        try {
          Hibernate.initialize( pCheck.getCity() );
          fail( "Should have thrown ObjectNotFoundException" );
        }
        catch (ObjectNotFoundException expected) {
          session.getTransaction().setRollbackOnly();
        }
      }
  );
}

代码示例来源:origin: hibernate/hibernate-orm

@Test
public void testManyToOneSelectException() {
  setupTest( PersonManyToOneSelectException.class, 1L, false );
  doInHibernate(
      this::sessionFactory, session -> {
        Person pCheck = session.find( PersonManyToOneSelectException.class, 1L );
        assertNotNull( pCheck );
        assertFalse( Hibernate.isInitialized( pCheck.getCity() ) );
        try {
          Hibernate.initialize( pCheck.getCity() );
          fail( "Should have thrown ObjectNotFoundException" );
        }
        catch (ObjectNotFoundException expected) {
          session.getTransaction().setRollbackOnly();
        }
      }
  );
}

代码示例来源:origin: hibernate/hibernate-orm

@Test
public void testMapsIdOneToOneSelectException() {
  setupTest( PersonMapsIdSelectException.class, 1L, true );
  doInHibernate(
      this::sessionFactory, session -> {
        Person pCheck = session.find( PersonMapsIdSelectException.class, 1L );
        assertNotNull( pCheck );
        assertFalse( Hibernate.isInitialized( pCheck.getCity() ) );
        try {
          Hibernate.initialize( pCheck.getCity() );
          fail( "Should have thrown ObjectNotFoundException" );
        }
        catch (ObjectNotFoundException expected) {
          session.getTransaction().setRollbackOnly();
        }
      }
  );
}

代码示例来源:origin: hibernate/hibernate-orm

@Test
public void testOneToOneSelectException() {
  setupTest( PersonOneToOneSelectException.class, 1L, false );
  doInHibernate(
      this::sessionFactory, session -> {
        Person pCheck = session.find( PersonOneToOneSelectException.class, 1L );
        assertNotNull( pCheck );
        assertFalse( Hibernate.isInitialized( pCheck.getCity() ) );
        try {
          Hibernate.initialize( pCheck.getCity() );
          fail( "Should have thrown ObjectNotFoundException" );
        }
        catch (ObjectNotFoundException expected) {
          session.getTransaction().setRollbackOnly();
        }
      }
  );
}

代码示例来源:origin: hibernate/hibernate-orm

@Test
public void testOneToOneSelectException() {
  setupTest( PersonOneToOneSelectException.class, 1L, false );
  doInHibernate(
      this::sessionFactory, session -> {
        Person pCheck = session.find( PersonOneToOneSelectException.class, 1L );
        assertNotNull( pCheck );
        assertFalse( Hibernate.isInitialized( pCheck.getCity() ) );
        try {
          Hibernate.initialize( pCheck.getCity() );
          fail( "Should have thrown ObjectNotFoundException" );
        }
        catch (ObjectNotFoundException expected) {
          session.getTransaction().setRollbackOnly();
        }
      }
  );
}

代码示例来源:origin: hibernate/hibernate-orm

@Test
public void testManyToOneSelectException() {
  setupTest( PersonManyToOneSelectException.class, 1L, false );
  doInHibernate(
      this::sessionFactory, session -> {
        Person pCheck = session.find( PersonManyToOneSelectException.class, 1L );
        assertNotNull( pCheck );
        assertFalse( Hibernate.isInitialized( pCheck.getCity() ) );
        try {
          Hibernate.initialize( pCheck.getCity() );
          fail( "Should have thrown ObjectNotFoundException" );
        }
        catch (ObjectNotFoundException expected) {
          session.getTransaction().setRollbackOnly();
        }
      }
  );
}

代码示例来源:origin: hibernate/hibernate-orm

@Test
public void testPkjcOneToOneSelectException() {
  setupTest( PersonPkjcSelectException.class, 1L, false );
  doInHibernate(
      this::sessionFactory, session -> {
        Person pCheck = session.find( PersonPkjcSelectException.class, 1L );
        assertNotNull( pCheck );
        assertFalse( Hibernate.isInitialized( pCheck.getCity() ) );
        try {
          Hibernate.initialize( pCheck.getCity() );
          fail( "Should have thrown ObjectNotFoundException" );
        }
        catch (ObjectNotFoundException expected) {
          session.getTransaction().setRollbackOnly();
        }
      }
  );
}

代码示例来源:origin: hibernate/hibernate-orm

assertTrue( transaction.isActive() );
transaction.setRollbackOnly();
assertTrue( transaction.isActive() );
assertTrue( transaction.getRollbackOnly() );
assertTrue( transaction.isActive() );
transaction.setRollbackOnly();
assertTrue( transaction.isActive() );
assertTrue( transaction.getRollbackOnly() );

代码示例来源:origin: hibernate/hibernate-orm

assertFalse( transaction.isActive() );
try {
  transaction.setRollbackOnly();
  fail( "Expecting failure #setRollbackOnly on non-active txn" );

代码示例来源:origin: org.hibernate.orm/hibernate-core

/**
 * Make a best effort to mark the underlying transaction for rollback only.
 */
default void markRollbackOnly() {
  setRollbackOnly();
}

代码示例来源:origin: com.atlassian.hibernate/hibernate.adapter

@Override
public void setRollbackOnly() {
  transaction.setRollbackOnly();
}

相关文章