simulated. This is more accurate than just assuming ResultSet concurrency to be a sufficient indicator
This commit is contained in:
parent
7c735242c0
commit
e2fc0f16a9
@ -42,6 +42,7 @@ import static java.util.concurrent.Executors.newSingleThreadExecutor;
|
||||
import static org.jooq.SQLDialect.ASE;
|
||||
import static org.jooq.SQLDialect.CUBRID;
|
||||
import static org.jooq.SQLDialect.SQLSERVER;
|
||||
import static org.jooq.impl.Utils.DATA_LOCK_ROWS_FOR_UPDATE;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.ResultSet;
|
||||
@ -176,6 +177,7 @@ abstract class AbstractResultQuery<R extends Record> extends AbstractQuery imple
|
||||
// [#1296] These dialects do not implement FOR UPDATE. But the same
|
||||
// effect can be achieved using ResultSet.CONCUR_UPDATABLE
|
||||
if (isForUpdate() && asList(CUBRID, SQLSERVER).contains(ctx.configuration().dialect())) {
|
||||
ctx.data(DATA_LOCK_ROWS_FOR_UPDATE, true);
|
||||
ctx.statement(ctx.connection().prepareStatement(ctx.sql(), TYPE_SCROLL_SENSITIVE, CONCUR_UPDATABLE));
|
||||
}
|
||||
|
||||
|
||||
@ -35,6 +35,9 @@
|
||||
*/
|
||||
package org.jooq.impl;
|
||||
|
||||
import static java.lang.Boolean.TRUE;
|
||||
import static org.jooq.impl.Utils.DATA_LOCK_ROWS_FOR_UPDATE;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.Reader;
|
||||
import java.math.BigDecimal;
|
||||
@ -1263,7 +1266,7 @@ class CursorImpl<R extends Record> implements Cursor<R> {
|
||||
|
||||
// [#1296] Force a row-lock by updating the row if the
|
||||
// FOR UPDATE clause is simulated
|
||||
if (rs.getConcurrency() == ResultSet.CONCUR_UPDATABLE) {
|
||||
if (TRUE.equals(ctx.data(DATA_LOCK_ROWS_FOR_UPDATE))) {
|
||||
rs.updateObject(1, rs.getObject(1));
|
||||
rs.updateRow();
|
||||
}
|
||||
|
||||
@ -153,6 +153,13 @@ final class Utils {
|
||||
*/
|
||||
static final String DATA_ROW_VALUE_EXPRESSION_PREDICATE_SUBQUERY = "org.jooq.configuration.row-value-expression-subquery";
|
||||
|
||||
/**
|
||||
* [#1296] This constant is used internally by jOOQ to indicate that
|
||||
* {@link ResultSet} rows must be locked to simulate a
|
||||
* <code>FOR UPDATE</code> clause.
|
||||
*/
|
||||
static final String DATA_LOCK_ROWS_FOR_UPDATE = "org.jooq.configuration.lock-rows-for-update";
|
||||
|
||||
/**
|
||||
* [#1520] Count the number of bind values, and potentially enforce a static
|
||||
* statement.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user