From 95b8db9cce2b2e700a2d821b0ca4524ecbd69e23 Mon Sep 17 00:00:00 2001 From: Lukas Eder Date: Sat, 27 Oct 2012 21:15:46 +0200 Subject: [PATCH] [#1887] Remove all deprecated code --- .../java/org/jooq/AttachableInternal.java | 12 - jOOQ/src/main/java/org/jooq/LockProvider.java | 266 ---------------- .../src/main/java/org/jooq/OrderProvider.java | 217 ------------- .../main/java/org/jooq/SimpleSelectQuery.java | 299 +++++++++++++++--- .../java/org/jooq/impl/AbstractQuery.java | 6 - .../java/org/jooq/impl/AbstractRecord.java | 2 +- .../java/org/jooq/impl/AbstractRoutine.java | 6 - .../java/org/jooq/impl/AbstractStore.java | 4 +- .../java/org/jooq/impl/AbstractSubSelect.java | 12 +- .../java/org/jooq/impl/ArrayRecordImpl.java | 2 +- .../main/java/org/jooq/impl/ResultImpl.java | 19 +- .../org/jooq/impl/SimpleSelectQueryImpl.java | 7 +- 12 files changed, 274 insertions(+), 578 deletions(-) delete mode 100644 jOOQ/src/main/java/org/jooq/LockProvider.java delete mode 100644 jOOQ/src/main/java/org/jooq/OrderProvider.java diff --git a/jOOQ/src/main/java/org/jooq/AttachableInternal.java b/jOOQ/src/main/java/org/jooq/AttachableInternal.java index 523a6b3163..b7addec501 100644 --- a/jOOQ/src/main/java/org/jooq/AttachableInternal.java +++ b/jOOQ/src/main/java/org/jooq/AttachableInternal.java @@ -35,7 +35,6 @@ */ package org.jooq; -import java.util.List; /** * Base functionality declaration for all {@link Attachable}s @@ -46,17 +45,6 @@ import java.util.List; */ public interface AttachableInternal extends Attachable { - /** - * Get the list of dependent Attachables - *

- * This method is for JOOQ INTERNAL USE only. Do not reference directly - * - * @deprecated - 2.5.0 [#1544] - This internal method will be removed soon. - * Do not reuse. - */ - @Deprecated - List getAttachables(); - /** * Get the underlying configuration */ diff --git a/jOOQ/src/main/java/org/jooq/LockProvider.java b/jOOQ/src/main/java/org/jooq/LockProvider.java deleted file mode 100644 index 40d0cc553c..0000000000 --- a/jOOQ/src/main/java/org/jooq/LockProvider.java +++ /dev/null @@ -1,266 +0,0 @@ -/** - * Copyright (c) 2009-2012, Lukas Eder, lukas.eder@gmail.com - * All rights reserved. - * - * This software is licensed to you under the Apache License, Version 2.0 - * (the "License"); You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * . Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * . Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * . Neither the name "jOOQ" nor the names of its contributors may be - * used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -package org.jooq; - -import static org.jooq.SQLDialect.ASE; -import static org.jooq.SQLDialect.CUBRID; -import static org.jooq.SQLDialect.DB2; -import static org.jooq.SQLDialect.DERBY; -import static org.jooq.SQLDialect.FIREBIRD; -import static org.jooq.SQLDialect.H2; -import static org.jooq.SQLDialect.HSQLDB; -import static org.jooq.SQLDialect.INGRES; -import static org.jooq.SQLDialect.MYSQL; -import static org.jooq.SQLDialect.ORACLE; -import static org.jooq.SQLDialect.POSTGRES; -import static org.jooq.SQLDialect.SQLSERVER; -import static org.jooq.SQLDialect.SYBASE; - -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.util.Collection; - -/** - * A query part (mostly a {@link Select} statement) providing the possibility of - * locking tables, rows using a FOR UPDATE clause - * - * @author Lukas Eder - * @deprecated - 2.6.0 [#1881] - This type will be removed from the public API, - * soon. Its methods will be pushed down into extending interfaces. - * Do not reference this type directly. - */ -@Deprecated -public interface LockProvider { - - /** - * Sets the "FOR UPDATE" flag onto the query - *

- *

Native implementation

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

Simulation

These dialects can simulate the - * FOR UPDATE clause using a cursor. The cursor is handled by - * the JDBC driver, at {@link PreparedStatement} construction time, when - * calling {@link Connection#prepareStatement(String, int, int)} with - * {@link ResultSet#CONCUR_UPDATABLE}. jOOQ handles simulation of a - * FOR UPDATE clause using CONCUR_UPDATABLE for - * these dialects: - * - *

- * Note: This simulation may not be efficient for large result sets! - *

Not supported

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 {@link #setForShare(boolean)} - * - * @param forUpdate The flag's value - */ - @Support({ ASE, CUBRID, DB2, DERBY, FIREBIRD, H2, HSQLDB, INGRES, MYSQL, ORACLE, POSTGRES, SQLSERVER, SYBASE }) - void setForUpdate(boolean forUpdate); - - /** - * 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 {@link #setForUpdate(boolean)} flag, and - * unsets the {@link #setForShare(boolean)} flag, if it was previously set. - *

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

- *

- * Note, that {@link SQLDialect#DB2} has some stricter requirements - * regarding the updatability of fields. Refer to the DB2 documentation for - * further details - * - * @param fields The fields that should be locked - */ - @Support({ DB2, DERBY, FIREBIRD, H2, HSQLDB, INGRES, ORACLE, SYBASE }) - 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. - *

- * - * @see #setForUpdateOf(Field...) - */ - @Support({ DB2, DERBY, FIREBIRD, H2, HSQLDB, INGRES, ORACLE, SYBASE }) - void setForUpdateOf(Collection> fields); - - /** - * 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 {@link #setForUpdate(boolean)} flag, and - * unsets the {@link #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: - *

- * - * @param tables The tables that should be locked - */ - @Support({ DB2, DERBY, FIREBIRD, H2, HSQLDB, INGRES, POSTGRES, ORACLE, SYBASE }) - void setForUpdateOf(Table... tables); - - /** - * 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 {@link #setForUpdate(boolean)} flag, and - * unsets the {@link #setForShare(boolean)} flag, if it was previously set. - *

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

- * - * @param seconds The number of seconds to wait for a lock - */ - @Support(ORACLE) - void setForUpdateWait(int seconds); - - /** - * 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 {@link #setForUpdate(boolean)} flag, and - * unsets the {@link #setForShare(boolean)} flag, if it was previously set. - *

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

- */ - @Support(ORACLE) - void setForUpdateNoWait(); - - /** - * 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 {@link #setForUpdate(boolean)} flag, and - * unsets the {@link #setForShare(boolean)} flag, if it was previously set. - *

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

- */ - @Support(ORACLE) - void setForUpdateSkipLocked(); - - /** - * 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 {@link #setForUpdate(boolean)} - * - * @param forShare The flag's value - */ - @Support({ MYSQL, POSTGRES }) - void setForShare(boolean forShare); -} diff --git a/jOOQ/src/main/java/org/jooq/OrderProvider.java b/jOOQ/src/main/java/org/jooq/OrderProvider.java deleted file mode 100644 index 91301bad38..0000000000 --- a/jOOQ/src/main/java/org/jooq/OrderProvider.java +++ /dev/null @@ -1,217 +0,0 @@ -/** - * Copyright (c) 2009-2012, Lukas Eder, lukas.eder@gmail.com - * All rights reserved. - * - * This software is licensed to you under the Apache License, Version 2.0 - * (the "License"); You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * . Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * . Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * . Neither the name "jOOQ" nor the names of its contributors may be - * used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -package org.jooq; - -import static org.jooq.SQLDialect.CUBRID; -import static org.jooq.SQLDialect.DB2; -import static org.jooq.SQLDialect.DERBY; -import static org.jooq.SQLDialect.FIREBIRD; -import static org.jooq.SQLDialect.H2; -import static org.jooq.SQLDialect.HSQLDB; -import static org.jooq.SQLDialect.INGRES; -import static org.jooq.SQLDialect.MYSQL; -import static org.jooq.SQLDialect.ORACLE; -import static org.jooq.SQLDialect.POSTGRES; -import static org.jooq.SQLDialect.SQLITE; -import static org.jooq.SQLDialect.SQLSERVER; -import static org.jooq.SQLDialect.SYBASE; - -import java.util.Collection; - -/** - * A query that can be ordered and limited - * - * @author Lukas Eder - * @deprecated - 2.6.0 [#1881] - This type will be removed from the public API, - * soon. Its methods will be pushed down into extending interfaces. - * Do not reference this type directly. - */ -@Deprecated -public interface OrderProvider { - - /** - * Adds ordering fields, ordering by the default sort order - * - * @param fields The ordering fields - */ - @Support - void addOrderBy(Field... fields); - - /** - * Adds ordering fields - * - * @param fields The ordering fields - */ - @Support - void addOrderBy(SortField... fields); - - /** - * Adds ordering fields - * - * @param fields The ordering fields - */ - @Support - void addOrderBy(Collection> fields); - - /** - * Adds ordering fields - *

- * Indexes start at 1 in SQL! - *

- * Note, you can use addOrderBy(Factory.val(1).desc()) or - * addOrderBy(Factory.literal(1).desc()) to apply descending - * ordering - * - * @param fieldIndexes The ordering fields - */ - @Support - void addOrderBy(int... fieldIndexes); - - /** - * Indicate whether the SIBLINGS keyword should be used in an - * ORDER BY clause to form an ORDER SIBLINGS BY - * clause. - *

- * This clause can be used only along with Oracle's CONNECT BY - * clause, to indicate that the hierarchical ordering should be preserved - * and elements of each hierarchy should be ordered among themselves. - * - * @param orderBySiblings - */ - @Support({ CUBRID, ORACLE }) - void setOrderBySiblings(boolean orderBySiblings); - - /** - * Limit the results of this select - *

- * This is the same as calling {@link #addLimit(int, int)} with offset = 0 - * - * @param numberOfRows The number of rows to return - */ - @Support - void addLimit(int numberOfRows); - - /** - * Limit the results of this select using named parameters - *

- * Note that some dialects do not support bind values at all in - * LIMIT or TOP clauses! - *

- * If there is no LIMIT or TOP clause in your - * RDBMS, or the LIMIT or TOP clause does not - * support bind values, this may be simulated with a - * ROW_NUMBER() window function and nested SELECT - * statements. - *

- * This is the same as calling {@link #addLimit(int, int)} with offset = 0 - * - * @param numberOfRows The number of rows to return - */ - @Support({ CUBRID, DB2, DERBY, FIREBIRD, H2, HSQLDB, MYSQL, ORACLE, POSTGRES, SQLITE, SQLSERVER, SYBASE }) - void addLimit(Param numberOfRows); - - /** - * Limit the results of this select - *

- * Note that some dialects do not support bind values at all in - * LIMIT or TOP clauses! - *

- * If there is no LIMIT or TOP clause in your - * RDBMS, or if your RDBMS does not natively support offsets, this is - * simulated with a ROW_NUMBER() window function and nested - * SELECT statements. - * - * @param offset The lowest offset starting at 0 - * @param numberOfRows The number of rows to return - */ - @Support({ CUBRID, DB2, DERBY, FIREBIRD, H2, HSQLDB, INGRES, MYSQL, ORACLE, POSTGRES, SQLITE, SQLSERVER, SYBASE }) - void addLimit(int offset, int numberOfRows); - - /** - * Limit the results of this select - *

- * Note that some dialects do not support bind values at all in - * LIMIT or TOP clauses! - *

- * If there is no LIMIT or TOP clause in your - * RDBMS, or the LIMIT or TOP clause does not - * support bind values, or if your RDBMS does not natively support offsets, - * this may be simulated with a ROW_NUMBER() window function - * and nested SELECT statements. - * - * @param offset The lowest offset starting at 0 - * @param numberOfRows The number of rows to return - */ - @Support({ CUBRID, DB2, DERBY, FIREBIRD, H2, HSQLDB, MYSQL, ORACLE, POSTGRES, SQLITE, SQLSERVER, SYBASE }) - void addLimit(Param offset, int numberOfRows); - - /** - * Limit the results of this select using named parameters - *

- * Note that some dialects do not support bind values at all in - * LIMIT or TOP clauses! - *

- * If there is no LIMIT or TOP clause in your - * RDBMS, or the LIMIT or TOP clause does not - * support bind values, or if your RDBMS does not natively support offsets, - * this may be simulated with a ROW_NUMBER() window function - * and nested SELECT statements. - * - * @param offset The lowest offset starting at 0 - * @param numberOfRows The number of rows to return - */ - @Support({ CUBRID, DB2, DERBY, FIREBIRD, H2, HSQLDB, MYSQL, ORACLE, POSTGRES, SQLITE, SQLSERVER, SYBASE }) - void addLimit(int offset, Param numberOfRows); - - /** - * Limit the results of this select using named parameters - *

- * Note that some dialects do not support bind values at all in - * LIMIT or TOP clauses! - *

- * If there is no LIMIT or TOP clause in your - * RDBMS, or the LIMIT or TOP clause does not - * support bind values, or if your RDBMS does not natively support offsets, - * this may be simulated with a ROW_NUMBER() window function - * and nested SELECT statements. - * - * @param offset The lowest offset starting at 0 - * @param numberOfRows The number of rows to return - */ - @Support({ CUBRID, DB2, DERBY, FIREBIRD, H2, HSQLDB, MYSQL, ORACLE, POSTGRES, SQLITE, SQLSERVER, SYBASE }) - void addLimit(Param offset, Param numberOfRows); - -} diff --git a/jOOQ/src/main/java/org/jooq/SimpleSelectQuery.java b/jOOQ/src/main/java/org/jooq/SimpleSelectQuery.java index fb2b70e935..ac5769920f 100644 --- a/jOOQ/src/main/java/org/jooq/SimpleSelectQuery.java +++ b/jOOQ/src/main/java/org/jooq/SimpleSelectQuery.java @@ -50,6 +50,9 @@ import static org.jooq.SQLDialect.SQLITE; import static org.jooq.SQLDialect.SQLSERVER; import static org.jooq.SQLDialect.SYBASE; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; import java.util.Collection; /** @@ -67,7 +70,7 @@ import java.util.Collection; * @see SelectQuery */ @SuppressWarnings("deprecation") -public interface SimpleSelectQuery extends Select, ConditionProvider, OrderProvider, LockProvider { +public interface SimpleSelectQuery extends Select, ConditionProvider { // ------------------------------------------------------------------------ // Methods from ConditionProvider, OrderProvider, LockProvider @@ -102,135 +105,353 @@ public interface SimpleSelectQuery extends Select, Conditio void addConditions(Operator operator, Collection conditions); /** - * {@inheritDoc} + * Adds ordering fields, ordering by the default sort order + * + * @param fields The ordering fields */ - @Override @Support void addOrderBy(Field... fields); /** - * {@inheritDoc} + * Adds ordering fields + * + * @param fields The ordering fields */ - @Override @Support void addOrderBy(SortField... fields); /** - * {@inheritDoc} + * Adds ordering fields + * + * @param fields The ordering fields */ - @Override @Support void addOrderBy(Collection> fields); /** - * {@inheritDoc} + * Adds ordering fields + *

+ * Indexes start at 1 in SQL! + *

+ * Note, you can use addOrderBy(Factory.val(1).desc()) or + * addOrderBy(Factory.literal(1).desc()) to apply descending + * ordering + * + * @param fieldIndexes The ordering fields */ - @Override @Support void addOrderBy(int... fieldIndexes); /** - * {@inheritDoc} + * Indicate whether the SIBLINGS keyword should be used in an + * ORDER BY clause to form an ORDER SIBLINGS BY + * clause. + *

+ * This clause can be used only along with Oracle's CONNECT BY + * clause, to indicate that the hierarchical ordering should be preserved + * and elements of each hierarchy should be ordered among themselves. + * + * @param orderBySiblings */ - @Override @Support({ CUBRID, ORACLE }) void setOrderBySiblings(boolean orderBySiblings); /** - * {@inheritDoc} + * Limit the results of this select + *

+ * This is the same as calling {@link #addLimit(int, int)} with offset = 0 + * + * @param numberOfRows The number of rows to return */ - @Override @Support void addLimit(int numberOfRows); /** - * {@inheritDoc} + * Limit the results of this select using named parameters + *

+ * Note that some dialects do not support bind values at all in + * LIMIT or TOP clauses! + *

+ * If there is no LIMIT or TOP clause in your + * RDBMS, or the LIMIT or TOP clause does not + * support bind values, this may be simulated with a + * ROW_NUMBER() window function and nested SELECT + * statements. + *

+ * This is the same as calling {@link #addLimit(int, int)} with offset = 0 + * + * @param numberOfRows The number of rows to return */ - @Override @Support({ CUBRID, DB2, DERBY, FIREBIRD, H2, HSQLDB, MYSQL, ORACLE, POSTGRES, SQLITE, SQLSERVER, SYBASE }) void addLimit(Param numberOfRows); /** - * {@inheritDoc} + * Limit the results of this select + *

+ * Note that some dialects do not support bind values at all in + * LIMIT or TOP clauses! + *

+ * If there is no LIMIT or TOP clause in your + * RDBMS, or if your RDBMS does not natively support offsets, this is + * simulated with a ROW_NUMBER() window function and nested + * SELECT statements. + * + * @param offset The lowest offset starting at 0 + * @param numberOfRows The number of rows to return */ - @Override @Support({ CUBRID, DB2, DERBY, FIREBIRD, H2, HSQLDB, INGRES, MYSQL, ORACLE, POSTGRES, SQLITE, SQLSERVER, SYBASE }) void addLimit(int offset, int numberOfRows); /** - * {@inheritDoc} + * Limit the results of this select + *

+ * Note that some dialects do not support bind values at all in + * LIMIT or TOP clauses! + *

+ * If there is no LIMIT or TOP clause in your + * RDBMS, or the LIMIT or TOP clause does not + * support bind values, or if your RDBMS does not natively support offsets, + * this may be simulated with a ROW_NUMBER() window function + * and nested SELECT statements. + * + * @param offset The lowest offset starting at 0 + * @param numberOfRows The number of rows to return */ - @Override @Support({ CUBRID, DB2, DERBY, FIREBIRD, H2, HSQLDB, MYSQL, ORACLE, POSTGRES, SQLITE, SQLSERVER, SYBASE }) void addLimit(Param offset, int numberOfRows); /** - * {@inheritDoc} + * Limit the results of this select using named parameters + *

+ * Note that some dialects do not support bind values at all in + * LIMIT or TOP clauses! + *

+ * If there is no LIMIT or TOP clause in your + * RDBMS, or the LIMIT or TOP clause does not + * support bind values, or if your RDBMS does not natively support offsets, + * this may be simulated with a ROW_NUMBER() window function + * and nested SELECT statements. + * + * @param offset The lowest offset starting at 0 + * @param numberOfRows The number of rows to return */ - @Override @Support({ CUBRID, DB2, DERBY, FIREBIRD, H2, HSQLDB, MYSQL, ORACLE, POSTGRES, SQLITE, SQLSERVER, SYBASE }) void addLimit(int offset, Param numberOfRows); /** - * {@inheritDoc} + * Limit the results of this select using named parameters + *

+ * Note that some dialects do not support bind values at all in + * LIMIT or TOP clauses! + *

+ * If there is no LIMIT or TOP clause in your + * RDBMS, or the LIMIT or TOP clause does not + * support bind values, or if your RDBMS does not natively support offsets, + * this may be simulated with a ROW_NUMBER() window function + * and nested SELECT statements. + * + * @param offset The lowest offset starting at 0 + * @param numberOfRows The number of rows to return */ - @Override @Support({ CUBRID, DB2, DERBY, FIREBIRD, H2, HSQLDB, MYSQL, ORACLE, POSTGRES, SQLITE, SQLSERVER, SYBASE }) void addLimit(Param offset, Param numberOfRows); /** - * {@inheritDoc} + * Sets the "FOR UPDATE" flag onto the query + *

+ *

Native implementation

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

Simulation

These dialects can simulate the + * FOR UPDATE clause using a cursor. The cursor is handled by + * the JDBC driver, at {@link PreparedStatement} construction time, when + * calling {@link Connection#prepareStatement(String, int, int)} with + * {@link ResultSet#CONCUR_UPDATABLE}. jOOQ handles simulation of a + * FOR UPDATE clause using CONCUR_UPDATABLE for + * these dialects: + * + *

+ * Note: This simulation may not be efficient for large result sets! + *

Not supported

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 {@link #setForShare(boolean)} + * + * @param forUpdate The flag's value */ - @Override @Support({ ASE, CUBRID, DB2, DERBY, FIREBIRD, H2, HSQLDB, INGRES, MYSQL, ORACLE, POSTGRES, SQLSERVER, SYBASE }) void setForUpdate(boolean forUpdate); /** - * {@inheritDoc} + * 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 {@link #setForUpdate(boolean)} flag, and + * unsets the {@link #setForShare(boolean)} flag, if it was previously set. + *

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

+ *

+ * Note, that {@link SQLDialect#DB2} has some stricter requirements + * regarding the updatability of fields. Refer to the DB2 documentation for + * further details + * + * @param fields The fields that should be locked */ - @Override @Support({ DB2, DERBY, FIREBIRD, H2, HSQLDB, INGRES, ORACLE, SYBASE }) void setForUpdateOf(Field... fields); /** - * {@inheritDoc} + * Some RDBMS allow for specifying the fields that should be locked by the + * FOR UPDATE clause, instead of the full row. + *

+ * + * @see #setForUpdateOf(Field...) */ - @Override @Support({ DB2, DERBY, FIREBIRD, H2, HSQLDB, INGRES, ORACLE, SYBASE }) void setForUpdateOf(Collection> fields); /** - * {@inheritDoc} + * 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 {@link #setForUpdate(boolean)} flag, and + * unsets the {@link #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: + *

+ * + * @param tables The tables that should be locked */ - @Override @Support({ DB2, DERBY, FIREBIRD, H2, HSQLDB, INGRES, POSTGRES, ORACLE, SYBASE }) void setForUpdateOf(Table... tables); /** - * {@inheritDoc} + * 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 {@link #setForUpdate(boolean)} flag, and + * unsets the {@link #setForShare(boolean)} flag, if it was previously set. + *

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

+ * + * @param seconds The number of seconds to wait for a lock */ - @Override @Support(ORACLE) void setForUpdateWait(int seconds); /** - * {@inheritDoc} + * 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 {@link #setForUpdate(boolean)} flag, and + * unsets the {@link #setForShare(boolean)} flag, if it was previously set. + *

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

*/ - @Override @Support(ORACLE) void setForUpdateNoWait(); /** - * {@inheritDoc} + * 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 {@link #setForUpdate(boolean)} flag, and + * unsets the {@link #setForShare(boolean)} flag, if it was previously set. + *

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

*/ - @Override @Support(ORACLE) void setForUpdateSkipLocked(); /** - * {@inheritDoc} + * 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 {@link #setForUpdate(boolean)} + * + * @param forShare The flag's value */ - @Override @Support({ MYSQL, POSTGRES }) void setForShare(boolean forShare); + } diff --git a/jOOQ/src/main/java/org/jooq/impl/AbstractQuery.java b/jOOQ/src/main/java/org/jooq/impl/AbstractQuery.java index e0cf119622..79c37ad36c 100644 --- a/jOOQ/src/main/java/org/jooq/impl/AbstractQuery.java +++ b/jOOQ/src/main/java/org/jooq/impl/AbstractQuery.java @@ -47,7 +47,6 @@ import java.util.Collections; import java.util.List; import java.util.Map; -import org.jooq.Attachable; import org.jooq.AttachableInternal; import org.jooq.Configuration; import org.jooq.ExecuteContext; @@ -89,11 +88,6 @@ abstract class AbstractQuery extends AbstractQueryPart implements Query, Attacha return configuration; } - @Override - public final List getAttachables() { - return Collections.emptyList(); - } - // ------------------------------------------------------------------------- // The Query API // ------------------------------------------------------------------------- diff --git a/jOOQ/src/main/java/org/jooq/impl/AbstractRecord.java b/jOOQ/src/main/java/org/jooq/impl/AbstractRecord.java index 2fbf26bc88..291b9d6a16 100644 --- a/jOOQ/src/main/java/org/jooq/impl/AbstractRecord.java +++ b/jOOQ/src/main/java/org/jooq/impl/AbstractRecord.java @@ -96,7 +96,7 @@ abstract class AbstractRecord extends AbstractStore implements Record { // ------------------------------------------------------------------------ @Override - public final List getAttachables() { + final List getAttachables() { List result = new ArrayList(); int size = getFields().size(); diff --git a/jOOQ/src/main/java/org/jooq/impl/AbstractRoutine.java b/jOOQ/src/main/java/org/jooq/impl/AbstractRoutine.java index cd9dc188bd..520f654c89 100644 --- a/jOOQ/src/main/java/org/jooq/impl/AbstractRoutine.java +++ b/jOOQ/src/main/java/org/jooq/impl/AbstractRoutine.java @@ -53,7 +53,6 @@ import java.util.Set; import org.jooq.AggregateFunction; import org.jooq.ArrayRecord; -import org.jooq.Attachable; import org.jooq.AttachableInternal; import org.jooq.BindContext; import org.jooq.Configuration; @@ -184,11 +183,6 @@ public abstract class AbstractRoutine extends AbstractQueryPart implements Ro configuration = c; } - @Override - public final List getAttachables() { - return Collections.emptyList(); - } - @Override public final Configuration getConfiguration() { return configuration; diff --git a/jOOQ/src/main/java/org/jooq/impl/AbstractStore.java b/jOOQ/src/main/java/org/jooq/impl/AbstractStore.java index 83ffcfc962..0cd15a5c1e 100644 --- a/jOOQ/src/main/java/org/jooq/impl/AbstractStore.java +++ b/jOOQ/src/main/java/org/jooq/impl/AbstractStore.java @@ -36,6 +36,7 @@ package org.jooq.impl; import java.util.Arrays; +import java.util.List; import org.jooq.ArrayRecord; import org.jooq.Attachable; @@ -72,7 +73,8 @@ abstract class AbstractStore implements AttachableInternal { // The Attachable API // ------------------------------------------------------------------------- - @SuppressWarnings("deprecation") + abstract List getAttachables(); + @Override public final void attach(Configuration c) { configuration = c; diff --git a/jOOQ/src/main/java/org/jooq/impl/AbstractSubSelect.java b/jOOQ/src/main/java/org/jooq/impl/AbstractSubSelect.java index b28aa609a9..660efa89fe 100644 --- a/jOOQ/src/main/java/org/jooq/impl/AbstractSubSelect.java +++ b/jOOQ/src/main/java/org/jooq/impl/AbstractSubSelect.java @@ -55,17 +55,15 @@ import java.util.List; import org.jooq.BindContext; import org.jooq.Condition; -import org.jooq.ConditionProvider; import org.jooq.Configuration; import org.jooq.Field; -import org.jooq.LockProvider; import org.jooq.Operator; -import org.jooq.OrderProvider; import org.jooq.Param; import org.jooq.QueryPart; import org.jooq.Record; import org.jooq.RenderContext; import org.jooq.SQLDialect; +import org.jooq.SimpleSelectQuery; import org.jooq.SortField; import org.jooq.Table; import org.jooq.TableLike; @@ -78,13 +76,7 @@ import org.jooq.tools.StringUtils; * * @author Lukas Eder */ -@SuppressWarnings("deprecation") -abstract class AbstractSubSelect -extends AbstractSelect -implements - ConditionProvider, - OrderProvider, - LockProvider { +abstract class AbstractSubSelect extends AbstractSelect implements SimpleSelectQuery { /** * Generated UID diff --git a/jOOQ/src/main/java/org/jooq/impl/ArrayRecordImpl.java b/jOOQ/src/main/java/org/jooq/impl/ArrayRecordImpl.java index d8dfc14f4d..502511385a 100644 --- a/jOOQ/src/main/java/org/jooq/impl/ArrayRecordImpl.java +++ b/jOOQ/src/main/java/org/jooq/impl/ArrayRecordImpl.java @@ -96,7 +96,7 @@ public class ArrayRecordImpl extends AbstractStore implements ArrayRecord // ------------------------------------------------------------------------- @Override - public final List getAttachables() { + final List getAttachables() { List result = new ArrayList(); if (Attachable.class.isAssignableFrom(type.getType())) { diff --git a/jOOQ/src/main/java/org/jooq/impl/ResultImpl.java b/jOOQ/src/main/java/org/jooq/impl/ResultImpl.java index 9f8637f205..ba560d06ec 100644 --- a/jOOQ/src/main/java/org/jooq/impl/ResultImpl.java +++ b/jOOQ/src/main/java/org/jooq/impl/ResultImpl.java @@ -59,7 +59,6 @@ import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; -import org.jooq.Attachable; import org.jooq.AttachableInternal; import org.jooq.Configuration; import org.jooq.Converter; @@ -108,23 +107,11 @@ class ResultImpl implements Result, AttachableInternal { public final void attach(Configuration c) { this.configuration = c; - for (Attachable attachable : getAttachables()) { - attachable.attach(c); - } - } - - @Override - @Deprecated - public final List getAttachables() { - List result = new ArrayList(); - - for (Attachable item : records) { - if (item != null) { - result.add(item); + for (R record : records) { + if (record != null) { + record.attach(c); } } - - return result; } @Override diff --git a/jOOQ/src/main/java/org/jooq/impl/SimpleSelectQueryImpl.java b/jOOQ/src/main/java/org/jooq/impl/SimpleSelectQueryImpl.java index 3c68736802..3a956e8cc2 100644 --- a/jOOQ/src/main/java/org/jooq/impl/SimpleSelectQueryImpl.java +++ b/jOOQ/src/main/java/org/jooq/impl/SimpleSelectQueryImpl.java @@ -37,11 +37,12 @@ package org.jooq.impl; import org.jooq.Configuration; import org.jooq.Record; -import org.jooq.SimpleSelectQuery; import org.jooq.TableLike; -class SimpleSelectQueryImpl extends AbstractSubSelect implements - SimpleSelectQuery { +/** + * @author Lukas Eder + */ +class SimpleSelectQueryImpl extends AbstractSubSelect { /** * Generated UID