use of org.neo4j.ogm.transaction.Transaction in project neo4j-ogm by neo4j.
the class BookmarkTest method shouldHaveAvailableBookmark.
@Test
public void shouldHaveAvailableBookmark() {
when(nativeDriver.session(any(SessionConfig.class))).thenReturn(nativeSession);
when(nativeSession.beginTransaction().isOpen()).thenReturn(true);
when(nativeSession.lastBookmark()).thenReturn(Bookmark.from(Collections.singleton("last-bookmark")));
Transaction transaction = session.beginTransaction(Transaction.Type.READ_WRITE);
transaction.commit();
transaction.close();
String lastBookmark = session.getLastBookmark();
assertThat(lastBookmark).isEqualTo("last-bookmark");
}
use of org.neo4j.ogm.transaction.Transaction in project neo4j-ogm by neo4j.
the class DatesBoltTest method shouldUseNativeDateTimeTypesInParameterMaps.
@Override
public void shouldUseNativeDateTimeTypesInParameterMaps() {
try (Driver driver = GraphDatabase.driver(getBoltUrl())) {
Session session = sessionFactory.openSession();
Transaction transaction = session.beginTransaction();
LocalDate localDate = LocalDate.of(2018, 11, 14);
LocalDateTime localDateTime = LocalDateTime.of(2018, 10, 11, 15, 24);
Map<String, Object> parameters = new HashMap<>();
parameters.put("a", localDate);
parameters.put("b", localDateTime);
session.query("CREATE (n:Test {a: $a, b: $b})", parameters);
transaction.commit();
Record record = driver.session().run("MATCH (n:Test) RETURN n.a, n.b").single();
Object a = record.get("n.a").asObject();
assertThat(a).isInstanceOf(LocalDate.class).isEqualTo(localDate);
Object b = record.get("n.b").asObject();
assertThat(b).isInstanceOf(LocalDateTime.class).isEqualTo(localDateTime);
}
}
use of org.neo4j.ogm.transaction.Transaction in project neo4j-ogm by neo4j.
the class BasicDriverTest method doExtendedCommitCommitRollback.
private void doExtendedCommitCommitRollback() {
try (Transaction tx = session.beginTransaction()) {
// commit_deferred
m2();
// commit_deferred
m2();
tx.rollback();
}
}
use of org.neo4j.ogm.transaction.Transaction in project neo4j-ogm by neo4j.
the class BasicDriverTest method shouldFindExplicitlyCommittedEntity.
@Test
public void shouldFindExplicitlyCommittedEntity() {
Transaction tx = session.beginTransaction();
session.save(new User());
tx.commit();
session.clear();
assertThat(session.loadAll(User.class)).hasSize(1);
}
use of org.neo4j.ogm.transaction.Transaction in project neo4j-ogm by neo4j.
the class BasicDriverTest method m3.
private void m3() {
// inner transaction rolls back (defers rollback)
try (Transaction tx = session.beginTransaction()) {
session.save(new User());
tx.rollback();
}
}
Aggregations