Skip to content

Commit 3ab3e36

Browse files
committed
Rename Session.newTransaction() to Session.beginTransaction()
1 parent d38b51b commit 3ab3e36

File tree

7 files changed

+19
-19
lines changed

7 files changed

+19
-19
lines changed

driver/src/main/java/org/neo4j/driver/v1/Driver.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public Driver( URI url, Config config )
8484
/**
8585
* Establish a session
8686
* @return a session that could be used to run {@link Session#run(String) a statement} or
87-
* {@link Session#newTransaction() a transaction }.
87+
* {@link Session#beginTransaction() a transaction }.
8888
*/
8989
public Session session()
9090
{

driver/src/main/java/org/neo4j/driver/v1/Session.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public interface Session extends AutoCloseable, StatementRunner
4545
*
4646
* @return a new transaction
4747
*/
48-
Transaction newTransaction();
48+
Transaction beginTransaction();
4949

5050
@Override
5151
void close();

driver/src/main/java/org/neo4j/driver/v1/internal/StandardSession.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ public void close()
107107
}
108108

109109
@Override
110-
public Transaction newTransaction()
110+
public Transaction beginTransaction()
111111
{
112112
ensureNoOpenTransaction();
113113
return currentTransaction = new StandardTransaction( connection, txCleanup );

driver/src/test/java/org/neo4j/driver/v1/integration/ErrorIT.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public void shouldThrowHelpfulSyntaxError() throws Throwable
5656
public void shouldNotAllowMoreTxAfterClientException() throws Throwable
5757
{
5858
// Given
59-
Transaction tx = session.newTransaction();
59+
Transaction tx = session.beginTransaction();
6060

6161
// And Given an error has occurred
6262
try { tx.run( "invalid" ); } catch ( ClientException e ) {}
@@ -87,14 +87,14 @@ public void shouldAllowNewStatementAfterRecoverableError() throws Throwable
8787
public void shouldAllowNewTransactionAfterRecoverableError() throws Throwable
8888
{
8989
// Given an error has occurred in a prior transaction
90-
try ( Transaction tx = session.newTransaction() )
90+
try ( Transaction tx = session.beginTransaction() )
9191
{
9292
tx.run( "invalid" );
9393
}
9494
catch ( ClientException e ) {}
9595

9696
// When
97-
try ( Transaction tx = session.newTransaction() )
97+
try ( Transaction tx = session.beginTransaction() )
9898
{
9999
int val = tx.run( "RETURN 1" ).single().get( "1" ).javaInteger();
100100

driver/src/test/java/org/neo4j/driver/v1/integration/TransactionIT.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public class TransactionIT
4343
public void shouldRunAndCommit() throws Throwable
4444
{
4545
// When
46-
try ( Transaction tx = session.newTransaction() )
46+
try ( Transaction tx = session.beginTransaction() )
4747
{
4848
tx.run( "CREATE (n:FirstNode)" );
4949
tx.run( "CREATE (n:SecondNode)" );
@@ -60,7 +60,7 @@ public void shouldRunAndCommit() throws Throwable
6060
public void shouldRunAndRollbackByDefault() throws Throwable
6161
{
6262
// When
63-
try ( Transaction tx = session.newTransaction() )
63+
try ( Transaction tx = session.beginTransaction() )
6464
{
6565
tx.run( "CREATE (n:FirstNode)" );
6666
tx.run( "CREATE (n:SecondNode)" );
@@ -78,7 +78,7 @@ public void shouldRetrieveResults() throws Throwable
7878
session.run( "CREATE (n {name:'Steve Brook'})" );
7979

8080
// When
81-
try ( Transaction tx = session.newTransaction() )
81+
try ( Transaction tx = session.beginTransaction() )
8282
{
8383
Result res = tx.run( "MATCH (n) RETURN n.name" );
8484

@@ -91,7 +91,7 @@ public void shouldRetrieveResults() throws Throwable
9191
public void shouldNotAllowSessionLevelStatementsWhenThereIsATransaction() throws Throwable
9292
{
9393
// Given
94-
session.newTransaction();
94+
session.beginTransaction();
9595

9696
// Expect
9797
exception.expect( ClientException.class );
@@ -104,7 +104,7 @@ public void shouldNotAllowSessionLevelStatementsWhenThereIsATransaction() throws
104104
public void shouldBeClosedAfterRollback() throws Throwable
105105
{
106106
// When
107-
Transaction tx = session.newTransaction();
107+
Transaction tx = session.beginTransaction();
108108
tx.close();
109109

110110
// Then
@@ -115,7 +115,7 @@ public void shouldBeClosedAfterRollback() throws Throwable
115115
public void shouldBeClosedAfterCommit() throws Throwable
116116
{
117117
// When
118-
Transaction tx = session.newTransaction();
118+
Transaction tx = session.beginTransaction();
119119
tx.success();
120120
tx.close();
121121

@@ -127,7 +127,7 @@ public void shouldBeClosedAfterCommit() throws Throwable
127127
public void shouldBeOpenBeforeCommit() throws Throwable
128128
{
129129
// When
130-
Transaction tx = session.newTransaction();
130+
Transaction tx = session.beginTransaction();
131131

132132
// Then
133133
assertTrue( tx.isOpen() );

driver/src/test/java/org/neo4j/driver/v1/internal/StandardSessionTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,13 @@ public void shouldNotAllowNewTxWhileOneIsRunning() throws Throwable
5555
// Given
5656
Connection mock = mock( Connection.class );
5757
StandardSession sess = new StandardSession( mock );
58-
sess.newTransaction();
58+
sess.beginTransaction();
5959

6060
// Expect
6161
exception.expect( ClientException.class );
6262

6363
// When
64-
sess.newTransaction();
64+
sess.beginTransaction();
6565
}
6666

6767
@Test
@@ -70,10 +70,10 @@ public void shouldBeAbleToOpenTxAfterPreviousIsClosed() throws Throwable
7070
// Given
7171
Connection mock = mock( Connection.class );
7272
StandardSession sess = new StandardSession( mock );
73-
sess.newTransaction().close();
73+
sess.beginTransaction().close();
7474

7575
// When
76-
Transaction tx = sess.newTransaction();
76+
Transaction tx = sess.beginTransaction();
7777

7878
// Then we should've gotten a transaction object back
7979
assertNotNull( tx );

driver/src/test/java/org/neo4j/driver/v1/util/TestNeo4jSession.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,9 @@ public void close()
9393
}
9494

9595
@Override
96-
public Transaction newTransaction()
96+
public Transaction beginTransaction()
9797
{
98-
return realSession.newTransaction();
98+
return realSession.beginTransaction();
9999
}
100100

101101
@Override

0 commit comments

Comments
 (0)