org.jooq
Interface LockProvider

All Known Subinterfaces:
SelectQuery, SimpleSelectQuery<R>

public interface LockProvider

A query part (mostly a Select statement) providing the possibility of locking tables, rows using a FOR UPDATE clause

Author:
Lukas Eder

Method Summary
 void setForShare(boolean forShare)
          Sets the "FOR SHARE" flag onto the query This has been observed to be supported by any of these dialects: MySQL's InnoDB locking reads Postgres FOR UPDATE / FOR SHARE If your dialect does not support this clause, jOOQ will still render it, if you apply it to your query.
 void setForUpdate(boolean forUpdate)
          Sets the "FOR UPDATE" flag onto the query This has been observed to be supported by any of these dialects:
 void setForUpdateNoWait()
          Some RDBMS allow for specifying the locking mode for the applied FOR UPDATE clause.
 void setForUpdateOf(Collection<? extends Field<?>> fields)
          Some RDBMS allow for specifying the fields that should be locked by the FOR UPDATE clause, instead of the full row.
 void setForUpdateOf(Field<?>... fields)
          Some RDBMS allow for specifying the fields that should be locked by the FOR UPDATE clause, instead of the full row.
 void setForUpdateOf(Table<?>... tables)
          Some RDBMS allow for specifying the tables that should be locked by the FOR UPDATE clause, instead of the full row.
 void setForUpdateSkipLocked()
          Some RDBMS allow for specifying the locking mode for the applied FOR UPDATE clause.
 void setForUpdateWait(int seconds)
          Some RDBMS allow for specifying the locking mode for the applied FOR UPDATE clause.
 

Method Detail

setForUpdate

void setForUpdate(boolean forUpdate)
Sets the "FOR UPDATE" flag onto the query

This has been observed to be supported by any of these dialects:

These dialects are known not to support the FOR UPDATE clause in regular SQL:

If your dialect does not support this clause, jOOQ will still render it, if you apply it to your query. This might then cause syntax errors reported either by your database or your JDBC driver.

You shouldn't combine this with setForShare(boolean)

Parameters:
forUpdate - The flag's value

setForUpdateOf

void setForUpdateOf(Field<?>... fields)
Some RDBMS allow for specifying the fields that should be locked by the FOR UPDATE clause, instead of the full row.

This automatically sets the setForUpdate(boolean) flag, and unsets the setForShare(boolean) flag, if it was previously set.

This has been observed to be natively supported by any of these dialects:

Parameters:
fields - The fields that should be locked

setForUpdateOf

void setForUpdateOf(Collection<? extends Field<?>> fields)
Some RDBMS allow for specifying the fields that should be locked by the FOR UPDATE clause, instead of the full row.

See Also:
setForUpdateOf(Field...)

setForUpdateOf

void setForUpdateOf(Table<?>... tables)
Some RDBMS allow for specifying the tables that should be locked by the FOR UPDATE clause, instead of the full row.

This automatically sets the setForUpdate(boolean) flag, and unsets the setForShare(boolean) flag, if it was previously set.

This has been observed to be natively supported by any of these dialects:

jOOQ simulates this by locking all known fields of [tables] for any of these dialects:

Parameters:
tables - The tables that should be locked

setForUpdateWait

void setForUpdateWait(int seconds)
Some RDBMS allow for specifying the locking mode for the applied FOR UPDATE clause. In this case, the session will wait for some seconds, before aborting the lock acquirement if the lock is not available.

This automatically sets the setForUpdate(boolean) flag, and unsets the setForShare(boolean) flag, if it was previously set.

This has been observed to be supported by any of these dialects:

Parameters:
seconds - The number of seconds to wait for a lock

setForUpdateNoWait

void setForUpdateNoWait()
Some RDBMS allow for specifying the locking mode for the applied FOR UPDATE clause. In this case, the session will not wait before aborting the lock acquirement if the lock is not available.

This automatically sets the setForUpdate(boolean) flag, and unsets the setForShare(boolean) flag, if it was previously set.

This has been observed to be supported by any of these dialects:


setForUpdateSkipLocked

void setForUpdateSkipLocked()
Some RDBMS allow for specifying the locking mode for the applied FOR UPDATE clause. In this case, the session will skip all locked rows from the select statement, whose lock is not available.

This automatically sets the setForUpdate(boolean) flag, and unsets the setForShare(boolean) flag, if it was previously set.

This has been observed to be supported by any of these dialects:


setForShare

void setForShare(boolean forShare)
Sets the "FOR SHARE" flag onto the query

This has been observed to be supported by any of these dialects:

If your dialect does not support this clause, jOOQ will still render it, if you apply it to your query. This might then cause syntax errors reported either by your database or your JDBC driver.

You shouldn't combine this with setForUpdate(boolean)

Parameters:
forShare - The flag's value


Copyright © 2012. All Rights Reserved.