Skip to content

Commit 97e4945

Browse files
authored
Merge pull request #658 from martin-neotech/4.0-docs-update
Updated the SimpleExample
2 parents 3620ff1 + 42c809c commit 97e4945

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

driver/src/main/javadoc/overview.html

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
<h3>Example</h3>
1111

12-
<pre><code>import org.neo4j.driver.v1.*;
12+
<pre><code>import org.neo4j.driver.*;
1313

1414
import static org.neo4j.driver.Values.parameters;
1515

@@ -28,21 +28,21 @@ <h3>Example</h3>
2828
// Sessions are lightweight and disposable connection wrappers.
2929
try (Session session = driver.session())
3030
{
31-
// Wrapping Cypher in an unmanaged transaction provides atomicity
31+
// Wrapping a Cypher Query in a Managed Transaction provides atomicity
3232
// and makes handling errors much easier.
33-
try (Transaction tx = session.beginTransaction())
34-
{
35-
tx.run("MERGE (a:Person {name: $x})", parameters("x", name));
36-
tx.success(); // Mark this write as successful.
37-
}
33+
// Use `session.writeTransaction` for writes and `session.readTransaction` for reading data.
34+
// These methods are also able to handle connection problems and transient errors using an automatic retry mechanism.
35+
session.writeTransaction(tx -> tx.run("MERGE (a:Person {name: $x})", parameters("x", name)));
3836
}
3937
}
4038

4139
private void printPeople(String initial)
4240
{
4341
try (Session session = driver.session())
4442
{
45-
// Auto-commit transactions are a quick and easy way to wrap a read.
43+
// A Managed Transaction transactions are a quick and easy way to wrap a Cypher Query.
44+
// The `session.run` method will run the specified Query.
45+
// This simpler method does not use any automatic retry mechanism.
4646
Result result = session.run(
4747
"MATCH (a:Person) WHERE a.name STARTS WITH $x RETURN a.name AS name",
4848
parameters("x", initial));

0 commit comments

Comments
 (0)