Search in sources :

Example 41 with Transaction

use of org.neo4j.ogm.transaction.Transaction in project neo4j-ogm by neo4j.

the class BasicDriverTest method shouldNotFindExplicitlyRolledBackEntity.

@Test
public void shouldNotFindExplicitlyRolledBackEntity() {
    Transaction tx = session.beginTransaction();
    session.save(new User());
    tx.rollback();
    session.clear();
    assertThat(session.loadAll(User.class)).isEmpty();
}
Also used : User(org.neo4j.ogm.domain.social.User) Transaction(org.neo4j.ogm.transaction.Transaction) Test(org.junit.Test)

Example 42 with Transaction

use of org.neo4j.ogm.transaction.Transaction in project neo4j-ogm by neo4j.

the class BasicDriverTest method doExtendedRollbackRollbackCommit.

private void doExtendedRollbackRollbackCommit() throws TransactionException {
    try (Transaction tx = session.beginTransaction()) {
        // rollback_deferred
        m3();
        // rollback_deferred
        m3();
        // cannot commit outer transaction
        tx.commit();
    }
}
Also used : Transaction(org.neo4j.ogm.transaction.Transaction)

Example 43 with Transaction

use of org.neo4j.ogm.transaction.Transaction in project neo4j-ogm by neo4j.

the class BasicDriverTest method doExtendedRollbackCommitRollback.

private void doExtendedRollbackCommitRollback() {
    try (Transaction tx = session.beginTransaction()) {
        // rollback_deferred
        m3();
        // commit_deferred
        m2();
        tx.rollback();
    }
}
Also used : Transaction(org.neo4j.ogm.transaction.Transaction)

Example 44 with Transaction

use of org.neo4j.ogm.transaction.Transaction in project neo4j-ogm by neo4j.

the class BasicDriverTest method doExtendedCommitCommitCommit.

private void doExtendedCommitCommitCommit() {
    try (Transaction tx = session.beginTransaction()) {
        // commit_deferred
        m2();
        // commit_deferred
        m2();
        // should be able to commit outer transaction
        tx.commit();
    }
}
Also used : Transaction(org.neo4j.ogm.transaction.Transaction)

Example 45 with Transaction

use of org.neo4j.ogm.transaction.Transaction in project neo4j-ogm by neo4j.

the class BaseAutoIndexManagerTestClass method executeCreate.

void executeCreate(String... statements) {
    Session session = sessionFactory.openSession();
    try (Transaction transaction = session.beginTransaction()) {
        for (String statement : statements) {
            logger.info("Execute CREATE " + statement);
            session.query("CREATE " + statement, emptyMap());
        }
        transaction.commit();
    }
}
Also used : Transaction(org.neo4j.ogm.transaction.Transaction) Session(org.neo4j.ogm.session.Session)

Aggregations

Transaction (org.neo4j.ogm.transaction.Transaction)47 Test (org.junit.Test)30 Session (org.neo4j.ogm.session.Session)10 ArrayList (java.util.ArrayList)5 Neo4jSession (org.neo4j.ogm.session.Neo4jSession)5 SessionConfig (org.neo4j.driver.SessionConfig)4 Result (org.neo4j.ogm.model.Result)4 HashSet (java.util.HashSet)3 LinkedHashSet (java.util.LinkedHashSet)3 HttpResponseException (org.apache.http.client.HttpResponseException)3 Bike (org.neo4j.ogm.domain.gh817.Bike)3 Studio (org.neo4j.ogm.domain.music.Studio)3 Satellite (org.neo4j.ogm.domain.satellites.Satellite)3 User (org.neo4j.ogm.domain.social.User)3 SessionFactory (org.neo4j.ogm.session.SessionFactory)3 IOException (java.io.IOException)2 Arrays (java.util.Arrays)2 Collections (java.util.Collections)2 List (java.util.List)2 Map (java.util.Map)2