Package javax.transaction

Examples of javax.transaction.TransactionManager.begin()


    em.persist( poem );
    transactionManager.commit();

    em.clear();

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


    final EntityManagerFactory emf = Persistence.createEntityManagerFactory( "jpajtastandalone",
        TestHelper.getEnvironmentProperties() );

    TransactionManager transactionManager = extractJBossTransactionManager( emf );

    transactionManager.begin();
    final EntityManager em = emf.createEntityManager();
    Hero h = new Hero();
    h.setName( "Spartacus" );
    em.persist( h );
    SuperHero sh = new SuperHero();
View Full Code Here

    em.persist( sh );
    transactionManager.commit();

    em.clear();

    transactionManager.begin();
    Hero lh = em.find( Hero.class, h.getName() );
    assertThat( lh ).isNotNull();
    assertThat( lh ).isInstanceOf( Hero.class );
    Hero lsh = em.find( Hero.class, sh.getName() );
    assertThat( lsh ).isNotNull();
View Full Code Here

                if (transaction == null) {
                    // No, create one
                    if (timeout > 0) {
                        manager.setTransactionTimeout(timeout);
                    }
                    manager.begin();
                    m_owned.put(Thread.currentThread(), manager.getTransaction());
                } else {
                    // Add the transaction to the transaction list
                    handler.addTransaction(transaction);
                }
View Full Code Here

                if (transaction == null) {
                    // No current transaction, Just creates a new one
                    if (timeout > 0) {
                        manager.setTransactionTimeout(timeout);
                    }
                    manager.begin();
                    m_owned.put(Thread.currentThread(), manager.getTransaction());
                } else {
                    if (suspended == null) {
                        suspended = manager.suspend();
                        if (timeout > 0) {
View Full Code Here

                    if (suspended == null) {
                        suspended = manager.suspend();
                        if (timeout > 0) {
                            manager.setTransactionTimeout(timeout);
                        }
                        manager.begin();
                        m_owned.put(Thread.currentThread(), manager.getTransaction());
                    } else {
                        throw new IllegalStateException("The method " + method + " requires to suspend a second times a transaction");
                    }
                }
View Full Code Here

           }
        });

        thread.start();

        tm.begin();
        Transaction t = tm.getTransaction();
        cs.doSomethingLong(); // 5s, so prov should be disposed during this time and under becomes invalid

        Assert.assertEquals(ComponentInstance.INVALID, under.getState());
View Full Code Here

        Assert.assertNotNull(ref);

        osgi.waitForService(TransactionManager.class.getName(), null, 5000);
        CheckService cs = (CheckService) osgi.getServiceObject(ref);
        TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
        tm.begin();
        Transaction t = tm.getTransaction();
        cs.doSomethingGood();
        Transaction t2 = cs.getCurrentTransaction(); // Is executed in the transaction despite it's not supported.
        Assert.assertSame(t2, t);
        t.commit();
View Full Code Here

        Assert.assertNotNull(ref);

        osgi.waitForService(TransactionManager.class.getName(), null, 5000);
        CheckService cs = (CheckService) osgi.getServiceObject(ref);
        TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
        tm.begin();
        Transaction t = tm.getTransaction();
        try {
            cs.doSomethingBad();
            Assert.fail("NullPointerException expected");
        } catch(Exception e) {
View Full Code Here

        Assert.assertNotNull(ref);

        osgi.waitForService(TransactionManager.class.getName(), null, 5000);
        CheckService cs = (CheckService) osgi.getServiceObject(ref);
        TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
        tm.begin();
        Transaction t = tm.getTransaction();
        try {
            cs.doSomethingBad();
            Assert.fail("NullPointerException expected");
        } catch(Exception e) {
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.