Neo4jTransaction(Session session, boolean logCypher) { this.logCypher = logCypher; this.neo4jTransaction = session.beginTransaction(); this.result = new CompletableFuture<>(); }
@Override public void beginTransaction() { if ( session == null ) { session = driver.session(); } if ( tx == null ) { tx = session.beginTransaction(); } }
@Override public void begin() { if ( session == null ) { session = driver.session(); } tx = session.beginTransaction(); status = TransactionStatus.ACTIVE; BoltNeo4jResourceLocalTransactionCoordinator.this.afterBeginCallback(); }
private org.neo4j.driver.v1.Transaction nativeTransaction(Session session) { org.neo4j.driver.v1.Transaction nativeTransaction; Transaction tx = transactionManager.getCurrentTransaction(); if (tx != null) { LOGGER.debug("Using current transaction: {}", tx); nativeTransaction = ((BoltTransaction) tx).nativeBoltTransaction(); } else { LOGGER.debug("No current transaction, starting a new one"); nativeTransaction = session.beginTransaction(); } LOGGER.debug("Native transaction: {}", nativeTransaction); return nativeTransaction; }
private org.neo4j.driver.v1.Transaction nativeTransaction(Session session) { org.neo4j.driver.v1.Transaction nativeTransaction; Transaction tx = transactionManager.getCurrentTransaction(); if (tx != null) { LOGGER.debug("Using current transaction: {}", tx); nativeTransaction = ((BoltTransaction) tx).nativeBoltTransaction(); } else { LOGGER.debug("No current transaction, starting a new one"); nativeTransaction = session.beginTransaction(); } LOGGER.debug("Native transaction: {}", nativeTransaction); return nativeTransaction; }
public Transaction getTransaction() { if (this.transaction == null) { BoltDBAccess bdba = getBoltDBAccess(); this.transaction = bdba.getSession().beginTransaction(); } return this.transaction; }
public Transaction getTransaction() { if (this.transaction == null) { BoltDBAccess bdba = getBoltDBAccess(); this.transaction = bdba.getSession().beginTransaction(); } return this.transaction; }
private Transaction transaction(TransactionContext transactionContext) { if ( transactionContext == null ) { Session session = boltClient.getDriver().session(); return session.beginTransaction(); } return (Transaction) transactionContext.getTransactionId(); } }
public Object process(ProceedingJoinPoint pjp) throws Throwable { Object[] args = pjp.getArgs(); int index = -1; Transaction tx = null; MethodSignature signature = (MethodSignature) pjp.getSignature(); Class<?>[] parameterTypes = signature.getParameterTypes(); for(int i=0; i<parameterTypes.length; i++) { if(parameterTypes[i].isAssignableFrom(Transaction.class)) { index = i; tx = (Transaction) args[i]; } } @SuppressWarnings("resource") final Session session = tx == null ? this.driver.session() : null; final Transaction transaction = tx == null ? session.beginTransaction() : tx; if(tx == null) args[index] = transaction; Object obj = pjp.proceed(args); CompletionStage<?> cs = (CompletionStage<?>) obj; if(index != -1) cs.thenAcceptAsync(o -> transaction.commitAsync().thenAcceptAsync(v -> session.closeAsync())) .exceptionally(ex -> { log.error("SQL process has an exception" , ex); transaction.rollbackAsync().thenAcceptAsync(v -> session.closeAsync()); return null; }); return obj; } }
tx = btx.getTransaction(); else tx = getSession().beginTransaction();
tx = btx.getTransaction(); else tx = getSession().beginTransaction();
@Before public void setUp() throws Exception { BoltDriver driver = new BoltDriver(nativeDriver); session = new Neo4jSession(new MetaData("org.neo4j.ogm.empty"), driver); when(nativeDriver.session(any(AccessMode.class), anyIterable())).thenReturn(nativeSession); when(nativeSession.beginTransaction().isOpen()).thenReturn(true); when(nativeSession.lastBookmark()).thenReturn("last-bookmark"); }
private StatementResult execute( List<Statement> statements ) { Driver driver = client.getDriver(); Session session = null; try { session = driver.session(); Transaction tx = null; try { tx = session.beginTransaction(); StatementResult result = runAll( tx, statements ); tx.success(); return result; } finally { close( tx ); } } finally { close( session ); } }
private void createIndexes() { Session session = this.driver.session(); if (session != null) { try (Transaction tx = session.beginTransaction()) { tx.run("CREATE INDEX ON :" + NodeTypes.PHYSICAL_ENTITY + "(id)"); tx.run("CREATE INDEX ON :" + NodeTypes.PHYSICAL_ENTITY + "(name)"); tx.run("CREATE INDEX ON :" + NodeTypes.INTERACTION + "(id)"); tx.run("CREATE INDEX ON :" + NodeTypes.INTERACTION + "(name)"); tx.run("CREATE INDEX ON :" + NodeTypes.XREF + "(id)"); tx.run("CREATE INDEX ON :Tissue(tissue)"); tx.run("CREATE INDEX ON :TimeSeries(timeseries)"); tx.success(); } session.close(); } }
private void run(DatastoreProvider provider, List<Statement> statements) { BoltNeo4jDatastoreProvider boltProvider = (BoltNeo4jDatastoreProvider) provider; Driver driver = boltProvider.getClient().getDriver(); Session session = null; try { session = driver.session(); Transaction tx = null; try { tx = session.beginTransaction(); runAll( tx, statements ); tx.success(); } catch (ClientException e) { throw log.constraintsCreationException( e.code(), e.getMessage() ); } finally { close( tx ); } } finally { close( session ); } }
final Transaction transaction = session == null ? tx : session.beginTransaction(); CompletionStage<StatementResultCursor> runAsync = transaction.runAsync(sql.getSql(), Values.value(sql.getParameters())); Object obj = runAsync.thenComposeAsync(src -> deSerializer.deSerialize(src , sqlMethod))
try { session = dataBase.session(); Transaction tx = session.beginTransaction(); try {
/** * Method to annotate Xrefs in the database. * * @param nodeID ID of the node we want to annotate * @param xrefList List containing all the Xref annotations to be added in the database */ @Override public void addXrefs(String nodeID, List<Xref> xrefList) throws BioNetDBException { Session session = this.driver.session(); try (Transaction tx = session.beginTransaction()) { StatementResult xrefNode = getNode(tx, NodeTypes.XREF.toString(), new ObjectMap("id", nodeID)); if (xrefNode.hasNext()) { // Look for the physical entity to which the xref is associated with StatementResult pE = tx.run("MATCH (n:" + NodeTypes.PHYSICAL_ENTITY + ")-[" + RelTypes.XREF + "]->(x:" + NodeTypes.XREF + ") WHERE ID(x) = " + xrefNode.peek().get("ID").toString() + " RETURN ID(n) AS ID, LABELS(n) AS LABELS"); for (Xref x : xrefList) { StatementResult myxref = getOrCreateNode(tx, NodeTypes.XREF.toString(), parseXref(x)); addRelationship(tx, concatenateLabels(pE.peek().get("LABELS")), NodeTypes.XREF.toString(), pE.peek().get("ID").toString(), myxref.peek().get("ID").toString(), RelTypes.XREF); } } else { throw new BioNetDBException("The node to be annotated does not exist in the database."); } tx.success(); } session.close(); }
Session session = this.driver.session(); try (Transaction tx = session.beginTransaction()) { try (Transaction tx = session.beginTransaction()) {
try (Transaction tx = session.beginTransaction()) { for (Interaction i : interactionList) { String interactionLabel = NodeTypes.INTERACTION + ":" + i.getType(); try (Transaction tx = session.beginTransaction()) { for (Interaction i : interactionList) { String interactionLabel = NodeTypes.INTERACTION + ":" + i.getType();