Package javax.transaction

Examples of javax.transaction.TransactionManager.commit()


    TransactionManager transactionManager = getTransactionManager();
    try {
      final Session session = factory.openSession();
      transactionManager.begin();
      delegate.run( session, tuple );
      transactionManager.commit();
      session.close();
    }
    catch ( Throwable e ) {
      errorHandler.handleException( log.massIndexerUnexpectedErrorMessage(), e );
      rollback( transactionManager, e );
View Full Code Here


    transactionManager.begin();
    final EntityManager em = emf.createEntityManager();
    Poem poem = new Poem();
    poem.setName( "L'albatros" );
    em.persist( poem );
    transactionManager.commit();

    em.clear();

    transactionManager.begin();
    poem = em.find( Poem.class, poem.getId() );
View Full Code Here

    transactionManager.begin();
    poem = em.find( Poem.class, poem.getId() );
    assertThat( poem ).isNotNull();
    assertThat( poem.getName() ).isEqualTo( "L'albatros" );
    em.remove( poem );
    transactionManager.commit();

    em.close();

    dropSchemaAndDatabase( emf );
    emf.close();
View Full Code Here

    em.persist( h );
    SuperHero sh = new SuperHero();
    sh.setName( "Batman" );
    sh.setSpecialPower( "Technology and samurai techniques" );
    em.persist( sh );
    transactionManager.commit();

    em.clear();

    transactionManager.begin();
    Hero lh = em.find( Hero.class, h.getName() );
View Full Code Here

    assertThat( lsh ).isNotNull();
    assertThat( lsh ).isInstanceOf( SuperHero.class );
    em.remove( lh );
    em.remove( lsh );

    transactionManager.commit();

    em.close();

    dropSchemaAndDatabase( emf );
    emf.close();
View Full Code Here

        // Transaction Service available
        osgi.isServiceAvailable(TransactionManager.class.getName());
        TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
        tm.begin();
        Assert.assertNotNull(tm.getTransaction());
        tm.commit();

        tm.begin();
        Assert.assertNotNull(tm.getTransaction());
        tm.rollback();
View Full Code Here

            return;
        } else if (suspendInJTA()) {
            try {
                TransactionManager tm = getConfiguration()
                    .getManagedRuntimeInstance().getTransactionManager();
                tm.commit();
                try { conn.close(); } catch (SQLException se) {}

                if (_outerTransaction != null)
                    tm.resume(_outerTransaction);
View Full Code Here

      Poem poem = new Poem();
      poem.setName( "L'albatros" );
      poem.setPoemSocietyId( UUID.randomUUID() );
      poem.setCreation( new Date() );
      em.persist( poem );
      transactionManager.commit();
      assertThat( true ).as( "Custom type not used" ).isFalse();
    }
    catch ( RollbackException e ) {
      //make this chaing more robust
      assertThat( e.getCause().getCause().getMessage() ).isEqualTo( "Exploding type" );
View Full Code Here

      dina.setBreed( collie );
      em.persist( dina );
      Long dinaId = dina.getId();
      em.flush();
      em.close();
      tm.commit();

      //Retrieve your entities the way you are used to in plain JPA
      logger.infof( "About to retrieve dog and breed" );
      tm.begin();
      em = emf.createEntityManager();
View Full Code Here

      em = emf.createEntityManager();
      dina = em.find( Dog.class, dinaId );
      logger.infof( "Found dog %s of breed %s", dina.getName(), dina.getBreed().getName() );
      em.flush();
      em.close();
      tm.commit();

      emf.close();
    } catch ( Exception e ) {
      e.printStackTrace();
    }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.