Search in sources :

Example 1 with DefaultTransactionManager

use of org.neo4j.ogm.session.transaction.DefaultTransactionManager in project neo4j-ogm by neo4j.

the class ClosedTransactionTest method init.

@Before
public void init() {
    Session session = sessionFactory.openSession();
    // The session actually has it's own transaction manager, which is btw tied to thread locally to the driver.
    // We could force get the sessions transaction manager or just create a new one here and tie it to the driver.
    // Both feel broken, this here a little less painfull, though.
    transactionManager = new DefaultTransactionManager(session, getDriver().getTransactionFactorySupplier());
}
Also used : DefaultTransactionManager(org.neo4j.ogm.session.transaction.DefaultTransactionManager) Session(org.neo4j.ogm.session.Session) Before(org.junit.Before)

Example 2 with DefaultTransactionManager

use of org.neo4j.ogm.session.transaction.DefaultTransactionManager in project neo4j-ogm by neo4j.

the class TransactionManagerTest method shouldRollbackManagedTransaction.

@Test
public void shouldRollbackManagedTransaction() {
    DefaultTransactionManager transactionManager = new DefaultTransactionManager(session, getDriver().getTransactionFactorySupplier());
    assertThat(session.getLastBookmark()).isNull();
    try (Transaction tx = transactionManager.openTransaction()) {
        assertThat(tx.status()).isEqualTo(Transaction.Status.OPEN);
        tx.rollback();
        assertThat(tx.status()).isEqualTo(Transaction.Status.ROLLEDBACK);
    }
}
Also used : Transaction(org.neo4j.ogm.transaction.Transaction) DefaultTransactionManager(org.neo4j.ogm.session.transaction.DefaultTransactionManager) Test(org.junit.Test)

Example 3 with DefaultTransactionManager

use of org.neo4j.ogm.session.transaction.DefaultTransactionManager in project neo4j-ogm by neo4j.

the class TransactionManagerTest method shouldBeAbleToCreateManagedTransaction.

@Test
public void shouldBeAbleToCreateManagedTransaction() {
    DefaultTransactionManager transactionManager = new DefaultTransactionManager(session, getDriver().getTransactionFactorySupplier());
    assertThat(session.getLastBookmark()).isNull();
    try (Transaction tx = transactionManager.openTransaction()) {
        assertThat(tx.status()).isEqualTo(Transaction.Status.OPEN);
    }
}
Also used : Transaction(org.neo4j.ogm.transaction.Transaction) DefaultTransactionManager(org.neo4j.ogm.session.transaction.DefaultTransactionManager) Test(org.junit.Test)

Aggregations

DefaultTransactionManager (org.neo4j.ogm.session.transaction.DefaultTransactionManager)3 Test (org.junit.Test)2 Transaction (org.neo4j.ogm.transaction.Transaction)2 Before (org.junit.Before)1 Session (org.neo4j.ogm.session.Session)1