本文整理汇总了Java中org.neo4j.driver.v1.Transaction类的典型用法代码示例。如果您正苦于以下问题:Java Transaction类的具体用法?Java Transaction怎么用?Java Transaction使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Transaction类属于org.neo4j.driver.v1包,在下文中一共展示了Transaction类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: importExport
import org.neo4j.driver.v1.Transaction; //导入依赖的package包/类
public boolean importExport(String branchId) {
final DbServices dbServices = DbServicesManager.getDbServices(branchId);
final Collection<String> importExportQueries = ResourceReader.getImportExportQueries();
try (Transaction tx = dbServices.beginTx()) {
for (String query : importExportQueries) {
dbServices.execute(query);
}
tx.success();
return true;
} catch (Exception e) {
e.printStackTrace();
return false;
}
}
开发者ID:FTSRG,项目名称:codemodel-rifle,代码行数:17,代码来源:ImportExport.java
示例2: run
import org.neo4j.driver.v1.Transaction; //导入依赖的package包/类
public String run(String branchId) {
final DbServices dbServices = DbServicesManager.getDbServices(branchId);
try (Transaction tx = dbServices.beginTx()) {
final StatementResult result = dbServices.execute(GET_LAST_COMMIT_HASH);
JSONObject response = new JSONObject();
while (result.hasNext()) {
Record next = result.next();
Object commitHash = next.get("commitHash");
response.put("commitHash", commitHash);
}
return response.toString();
} catch (Exception e) {
e.printStackTrace();
}
return "ERROR";
}
开发者ID:FTSRG,项目名称:codemodel-rifle,代码行数:21,代码来源:GetLastCommitHash.java
示例3: parseFile
import org.neo4j.driver.v1.Transaction; //导入依赖的package包/类
protected void parseFile(String sessionId, String path, String content, String branchId, Transaction tx) throws JsError {
Stopwatch stopwatch = Stopwatch.createUnstarted();
ParserWithLocation parser = new ParserWithLocation();
stopwatch.start();
Module module = parser.parseModule(content);
long parseDone = stopwatch.elapsed(TimeUnit.MILLISECONDS);
logger.info(
String.format("%s %s %dms", path, "PARSE", parseDone)
);
stopwatch.reset();
stopwatch.start();
GlobalScope scope = ScopeAnalyzer.analyze(module);
long scopeDone = stopwatch.elapsed(TimeUnit.MILLISECONDS);
logger.info(
String.format("%s %s %dms", path, "SCOPE", scopeDone)
);
stopwatch.reset();
ASTScopeProcessor astScopeProcessor = new ASTScopeProcessor(path, parser);
astScopeProcessor.processScope(scope, sessionId, tx);
}
开发者ID:FTSRG,项目名称:codemodel-rifle,代码行数:24,代码来源:HandleChange.java
示例4: transactionEnlistmentReadAfterCallingTransactionClose
import org.neo4j.driver.v1.Transaction; //导入依赖的package包/类
public String transactionEnlistmentReadAfterCallingTransactionClose() {
// JTA transaction is started by CMT, the following obtains a Session that is enlisted into the JTA transaction.
Session session = injectedDriver.session();
// The only way to influence success/failure of the Neo4j + JTA transaction, is at the JTA transaction level.
// If the JTA transaction fails, org.neo4j.driver.v1.Transaction.failure() is called.
// If the JTA transaction succeeds, org.neo4j.driver.v1.Transaction.success() is called.
// org.neo4j.driver.v1.Transaction.close() is also called when the JTA transaction ends.
// Calls to Session.beginTransaction() in a JTA transaction are expected to throw a RuntimeException
try {
Transaction transaction = session.beginTransaction();
fail("Calling Session.beginTransaction in a JTA transaction should throw a RuntimeException.");
} catch (RuntimeException expectedException) {
// success
}
try {
session.run("CREATE (a:Person {name:'TRANSACTION', title:'King'})");
return nestedBean.getPerson("TRANSACTION");
} finally {
if ( session.isOpen()) { // this will be true
session.run("MATCH (a:Person) delete a");
session.close(); // ignored, session is auto closed when the transaction ends.
}
}
}
开发者ID:wildfly-swarm,项目名称:wildfly-swarm,代码行数:27,代码来源:StatefulTestBean.java
示例5: prepareTest
import org.neo4j.driver.v1.Transaction; //导入依赖的package包/类
@BeforeClass
public void prepareTest() throws IOException {
Config reference = ConfigFactory.load();
File conf = new File("target/test-classes/TwitterFollowNeo4jIT.conf");
assertTrue(conf.exists());
Config testResourceConfig = ConfigFactory.parseFileAnySyntax(conf, ConfigParseOptions.defaults().setAllowMissing(false));
Config typesafe = testResourceConfig.withFallback(reference).resolve();
testConfiguration = new ComponentConfigurator<>(TwitterFollowNeo4jConfiguration.class).detectConfiguration(typesafe);
testClient = Neo4jBoltClient.getInstance(testConfiguration.getNeo4j());
Session session = testClient.client().session();
Transaction transaction = session.beginTransaction();
transaction.run("MATCH ()-[r]-() DELETE r");
transaction.run("MATCH (n) DETACH DELETE n");
transaction.success();
session.close();
}
开发者ID:apache,项目名称:streams-examples,代码行数:19,代码来源:TwitterFollowNeo4jIT.java
示例6: executeOperation
import org.neo4j.driver.v1.Transaction; //导入依赖的package包/类
@Override
public void executeOperation(LdbcUpdate2AddPostLike operation,
DbConnectionState dbConnectionState,
ResultReporter reporter) throws DbException {
Driver driver = ((Neo4jDbConnectionState) dbConnectionState).getDriver();
try (Session session = driver.session(AccessMode.WRITE)) {
try (Transaction tx = session.beginTransaction()) {
String statement =
" MATCH (p:Person {id:{personId}}),"
+ " (m:Post {id:{postId}})"
+ " CREATE (p)-[:LIKES {creationDate:{creationDate}}]->(m)";
Value parameters = parameters(
"personId", String.valueOf(operation.personId()),
"postId", String.valueOf(operation.postId()),
"creationDate", operation.creationDate().getTime());
tx.run(statement, parameters);
tx.success();
tx.close();
}
}
reporter.report(0, LdbcNoResult.INSTANCE, operation);
}
开发者ID:PlatformLab,项目名称:ldbc-snb-impls,代码行数:27,代码来源:Neo4jDb.java
示例7: executeInTransaction
import org.neo4j.driver.v1.Transaction; //导入依赖的package包/类
private void executeInTransaction(
Consumer<Transaction> consumer,
String consumerDescription,
Meter failureMeter
) {
try (
Session session = sessionFactory.getSession();
Transaction transaction = session.beginTransaction()
) {
try {
consumer.accept(transaction);
transaction.success();
} catch (Exception e) {
transaction.failure();
failureMeter.mark();
Throwables.propagateIfInstanceOf(e, Neo4jPersistenceException.class);
throw Neo4jPersistenceException.create("Failed to " + consumerDescription, e);
}
}
}
开发者ID:atlasapi,项目名称:atlas-deer,代码行数:22,代码来源:Neo4jContentStore.java
示例8: commit
import org.neo4j.driver.v1.Transaction; //导入依赖的package包/类
public List<Map<String, Object>> commit(Function<Transaction, List<Map<String, Object>>> callback) {
try (Driver driver = GraphDatabase.driver(configuration.getBoltUri(), configuration.getAuthToken());
Session session = driver.session();
Transaction tx = session.beginTransaction()) {
List<Map<String, Object>> result = callback.apply(tx);
tx.success();
return result;
}
}
开发者ID:fbiville,项目名称:hands-on-neo4j-devoxx-fr-2017,代码行数:11,代码来源:CypherQueryExecutor.java
示例9: rollback
import org.neo4j.driver.v1.Transaction; //导入依赖的package包/类
public void rollback(Consumer<Transaction> callback) {
try (Driver driver = GraphDatabase.driver(configuration.getBoltUri(), configuration.getAuthToken());
Session session = driver.session();
Transaction tx = session.beginTransaction()) {
callback.accept(tx);
tx.failure();
}
}
开发者ID:fbiville,项目名称:hands-on-neo4j-devoxx-fr-2017,代码行数:10,代码来源:CypherQueryExecutor.java
示例10: countAll
import org.neo4j.driver.v1.Transaction; //导入依赖的package包/类
public int countAll(String branchId) {
final DbServices dbServices = DbServicesManager.getDbServices(branchId);
try (Transaction tx = dbServices.beginTx()) {
StatementResult result = dbServices.execute(COUNT_NODES);
tx.success();
return result.single().get("count").asInt();
}
}
开发者ID:FTSRG,项目名称:codemodel-rifle,代码行数:11,代码来源:CountNodes.java
示例11: countCompilationUnitNodes
import org.neo4j.driver.v1.Transaction; //导入依赖的package包/类
public int countCompilationUnitNodes(String branchId) {
final DbServices dbServices = DbServicesManager.getDbServices(branchId);
try (Transaction tx = dbServices.beginTx()) {
StatementResult result = dbServices.execute(COUNT_COMPILATIONUNIT_NODES);
tx.success();
return result.single().get("count").asInt();
}
}
开发者ID:FTSRG,项目名称:codemodel-rifle,代码行数:11,代码来源:CountNodes.java
示例12: runAnalyses
import org.neo4j.driver.v1.Transaction; //导入依赖的package包/类
public void runAnalyses(String branchId) {
final DbServices dbServices = DbServicesManager.getDbServices(branchId);
final Collection<String> analysisQueries = ResourceReader.getAnalysisQueries();
for (String query : analysisQueries) {
try (Transaction tx = dbServices.beginTx()) {
StatementResult result = dbServices.execute(query);
while (result.hasNext()) {
Record record = result.next();
String message = record.get("message").asString();
String entityName = record.get("entityName").asString();
String compilationUnitPath = record.get("compilationUnitPath").asString();
int line = Integer.parseInt(record.get("line").asString());
int column = Integer.parseInt(record.get("column").asString());
if (entityName.isEmpty()) {
logger.info(String.format("%s at %d:%d in %s", message, line, column, compilationUnitPath));
} else {
logger.info(String.format("%s: %s at %d:%d in %s", message, entityName, line, column, compilationUnitPath));
}
}
tx.success();
} catch (Exception e) {
e.printStackTrace();
}
}
}
开发者ID:FTSRG,项目名称:codemodel-rifle,代码行数:30,代码来源:RunAnalyses.java
示例13: delete
import org.neo4j.driver.v1.Transaction; //导入依赖的package包/类
public boolean delete(String branchId) {
final DbServices dbServices = DbServicesManager.getDbServices(branchId);
try (Transaction tx = dbServices.beginTx()) {
dbServices.execute(DELETE_GRAPH);
tx.success();
return true;
}
}
开发者ID:FTSRG,项目名称:codemodel-rifle,代码行数:11,代码来源:DeleteGraph.java
示例14: add
import org.neo4j.driver.v1.Transaction; //导入依赖的package包/类
public boolean add(String sessionId, String path, String content, String branchId, String commitHash, Transaction tx) {
setCommitHashInNewTransaction(branchId, commitHash);
try {
parseFile(sessionId, path, content, branchId, tx);
return true;
} catch (JsError jsError) {
System.err.println(path);
jsError.printStackTrace();
return false;
}
}
开发者ID:FTSRG,项目名称:codemodel-rifle,代码行数:15,代码来源:HandleChange.java
示例15: setCommitHash
import org.neo4j.driver.v1.Transaction; //导入依赖的package包/类
private void setCommitHash(DbServices dbServices, Transaction tx, String branchId, String commitHash) {
if (commitHash == null) {
return;
}
Map<String, Object> parameters = new HashMap<>();
parameters.put("commithash", commitHash);
dbServices.execute(SET_COMMIT_HASH, parameters);
}
开发者ID:FTSRG,项目名称:codemodel-rifle,代码行数:11,代码来源:HandleChange.java
示例16: setCommitHashInNewTransaction
import org.neo4j.driver.v1.Transaction; //导入依赖的package包/类
private void setCommitHashInNewTransaction(String branchId, String commitHash) {
final DbServices dbServices = DbServicesManager.getDbServices(branchId);
try (Transaction tx = dbServices.beginTx()) {
setCommitHash(dbServices, tx, branchId, commitHash);
tx.success();
} catch (Exception e) {
e.printStackTrace();
}
}
开发者ID:FTSRG,项目名称:codemodel-rifle,代码行数:11,代码来源:HandleChange.java
示例17: executeWithRetry
import org.neo4j.driver.v1.Transaction; //导入依赖的package包/类
private List<BoltResult> executeWithRetry(List<Statement> transactionStatements, BiFunction<Statement, Transaction, BoltResult> biFunction) {
return session.writeTransaction(tx ->
transactionStatements.stream()
.map(transactionStatement -> biFunction.apply(transactionStatement, tx))
.collect(Collectors.toList()));
}
开发者ID:neo4j,项目名称:cypher-shell,代码行数:8,代码来源:BoltStateHandler.java
示例18: cleanup
import org.neo4j.driver.v1.Transaction; //导入依赖的package包/类
@AfterClass
public void cleanup() throws Exception {
Session session = testClient.client().session();
Transaction transaction = session.beginTransaction();
transaction.run("MATCH ()-[r]-() DELETE r");
transaction.run("MATCH (n) DETACH DELETE n");
transaction.success();
session.close();
}
开发者ID:apache,项目名称:streams-examples,代码行数:10,代码来源:TwitterFollowNeo4jIT.java
示例19: close
import org.neo4j.driver.v1.Transaction; //导入依赖的package包/类
@Override
public List<JcError> close() {
List<JcError> errors;
if (isClosed())
throw new RuntimeException(ERR_CLOSED);
if (!isMyThread())
throw new RuntimeException(ERR_THREAD);
BoltDBAccess bdba = getBoltDBAccess();
bdba.removeTx();
if (this.transaction != null) {
Transaction tx = getTransaction();
if (failed)
tx.failure();
else
tx.success();
Throwable dbException = null;
try {
tx.close();
} catch(Throwable e) {
dbException = e;
}
errors = DBUtil.buildErrorList(null, dbException);
} else
errors = new ArrayList<JcError>();
if (errors.size() > 0)
failure();
setClosed();
return errors;
}
开发者ID:Wolfgang-Schuetzelhofer,项目名称:jcypher,代码行数:34,代码来源:BoltTransactionImpl.java
示例20: getTransaction
import org.neo4j.driver.v1.Transaction; //导入依赖的package包/类
public Transaction getTransaction() {
if (this.transaction == null) {
BoltDBAccess bdba = getBoltDBAccess();
this.transaction = bdba.getSession().beginTransaction();
}
return this.transaction;
}
开发者ID:Wolfgang-Schuetzelhofer,项目名称:jcypher,代码行数:8,代码来源:BoltTransactionImpl.java
注:本文中的org.neo4j.driver.v1.Transaction类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论