Skip to content

Commit 257e579

Browse files
committed
Removed conflict on transaction usage
1 parent fc66a7d commit 257e579

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

jdbc/src/main/java/tech/ydb/jdbc/context/QueryServiceExecutor.java

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -255,18 +255,13 @@ public YdbQueryResult executeScanQuery(YdbStatement statement, YdbQuery query, S
255255
.withRequestTimeout(scanQueryTimeout)
256256
.build();
257257

258-
if (tx == null) {
259-
tx = createNewQuerySession(validator).createNewTransaction(txMode);
260-
}
261-
258+
final QuerySession session = createNewQuerySession(validator);
262259
String msg = "STREAM_QUERY >>\n" + yql;
263260
return validator.call(msg, () -> {
264-
QueryStream stream = tx.createQuery(yql, isAutoCommit, params, settings);
261+
QueryStream stream = session.createQuery(yql, TxMode.SNAPSHOT_RO, params, settings);
265262
StreamQueryResult result = new StreamQueryResult(msg, statement, query, stream::cancel);
266263
return result.execute(stream, () -> {
267-
if (!tx.isActive()) {
268-
cleanTx();
269-
}
264+
session.close();
270265
});
271266
});
272267
}

jdbc/src/test/java/tech/ydb/jdbc/impl/YdbQueryPreparedStatementImplTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,8 @@ public void executeScanQueryAsUpdate() throws SQLException {
350350
statement.setInt(1, 1);
351351
statement.setString(2, "value-1");
352352

353-
statement.executeUpdate();
353+
ExceptionAssert.ydbException("Operation 'Upsert' can't be performed in read only transaction",
354+
statement::executeQuery);
354355
}
355356
}
356357

0 commit comments

Comments
 (0)