org.jooq.Table Maven / Gradle / Ivy
/**
* Copyright (c) 2009-2014, Data Geekery GmbH (http://www.datageekery.com)
* All rights reserved.
*
* This work is dual-licensed
* - under the Apache Software License 2.0 (the "ASL")
* - under the jOOQ License and Maintenance Agreement (the "jOOQ License")
* =============================================================================
* You may choose which license applies to you:
*
* - If you're using this work with Open Source databases, you may choose
* either ASL or jOOQ License.
* - If you're using this work with at least one commercial database, you must
* choose jOOQ License
*
* For more information, please visit http://www.jooq.org/licenses
*
* Apache Software License 2.0:
* -----------------------------------------------------------------------------
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* jOOQ License and Maintenance Agreement:
* -----------------------------------------------------------------------------
* Data Geekery grants the Customer the non-exclusive, timely limited and
* non-transferable license to install and use the Software under the terms of
* the jOOQ License and Maintenance Agreement.
*
* This library is distributed with a LIMITED WARRANTY. See the jOOQ License
* and Maintenance Agreement for more details: http://www.jooq.org/licensing
*/
package org.jooq;
// ...
// ...
import static org.jooq.SQLDialect.CUBRID;
// ...
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.MARIADB;
import static org.jooq.SQLDialect.MYSQL;
// ...
// ...
// ...
import static org.jooq.SQLDialect.POSTGRES;
import static org.jooq.SQLDialect.SQLITE;
// ...
// ...
import java.sql.Timestamp;
import java.util.Collection;
import java.util.List;
import org.jooq.conf.Settings;
import org.jooq.impl.DSL;
/**
* A table to be used in queries
*
* @param The record type associated with this table
* @author Lukas Eder
*/
public interface Table extends TableLike {
/**
* Get the table schema.
*/
Schema getSchema();
/**
* The name of this table.
*/
String getName();
/**
* The comment given to the table.
*
* If this Table
is a generated table from your database, it
* may provide its DDL comment through this method. All other table
* expressions return the empty string ""
here, never
* null
.
*/
String getComment();
/**
* The record type produced by this table.
*/
RecordType recordType();
/**
* The record type produced by this table.
*/
Class extends R> getRecordType();
/**
* Create a new {@link Record} of this table's type.
*
* @see DSLContext#newRecord(Table)
*/
R newRecord();
/**
* Retrieve the table's IDENTITY
information, if available.
*
* With SQL:2003, the concept of IDENTITY
columns was
* introduced in most RDBMS. These are special kinds of columns that have
* auto-increment functionality when INSERT
statements are
* performed.
*
* An IDENTITY
column is usually part of the
* PRIMARY KEY
or of a UNIQUE KEY
in the table,
* although in some RDBMS, this is not required. There can only be at most
* one IDENTITY
column.
*
* Note: Unfortunately, this is not supported in the Oracle dialect, where
* identities simulated by triggers cannot be formally detected.
*
* @return The table's IDENTITY
information, or
* null
, if no such information is available.
*/
Identity getIdentity();
/**
* Retrieve the table's primary key
*
* @return The primary key. This is never null
for an updatable
* table.
*/
UniqueKey getPrimaryKey();
/**
* A "version" field holding record version information used for optimistic
* locking
*
* jOOQ supports optimistic locking in {@link UpdatableRecord#store()} and
* {@link UpdatableRecord#delete()} if
* {@link Settings#isExecuteWithOptimisticLocking()} is enabled. Optimistic
* locking is performed in a single UPDATE
or
* DELETE
statement if tables provide a "version" or
* "timestamp" field, or in two steps using an additional
* SELECT .. FOR UPDATE
statement otherwise.
*
* This method is overridden in generated subclasses if their corresponding
* tables have been configured accordingly. A table may have both a
* "version" and a "timestamp" field.
*
* @return The "version" field, or null
, if this table has no
* "version" field.
* @see #getRecordTimestamp()
* @see UpdatableRecord#store()
* @see UpdatableRecord#delete()
* @see Settings#isExecuteWithOptimisticLocking()
*/
TableField getRecordVersion();
/**
* A "timestamp" field holding record timestamp information used for
* optimistic locking
*
* jOOQ supports optimistic locking in {@link UpdatableRecord#store()} and
* {@link UpdatableRecord#delete()} if
* {@link Settings#isExecuteWithOptimisticLocking()} is enabled. Optimistic
* locking is performed in a single UPDATE
or
* DELETE
statement if tables provide a "version" or
* "timestamp" field, or in two steps using an additional
* SELECT .. FOR UPDATE
statement otherwise.
*
* This method is overridden in generated subclasses if their corresponding
* tables have been configured accordingly. A table may have both a
* "version" and a "timestamp" field.
*
* @return The "timestamp" field, or null
, if this table has no
* "timestamp" field.
* @see #getRecordVersion()
* @see UpdatableRecord#store()
* @see UpdatableRecord#delete()
* @see Settings#isExecuteWithOptimisticLocking()
*/
TableField getRecordTimestamp();
/**
* Retrieve all of the table's unique keys.
*
* @return All keys. This is never null
. This is never empty
* for a {@link Table} with a {@link Table#getPrimaryKey()}. This
* method returns an unmodifiable list.
*/
List> getKeys();
/**
* Get a list of FOREIGN KEY
's of a specific table, referencing
* a this table.
*
* @param The other table's record type
* @param other The other table of the foreign key relationship
* @return Some other table's FOREIGN KEY
's towards an this
* table. This is never null
. This method returns an
* unmodifiable list.
*/
List> getReferencesFrom(Table other);
/**
* Get the list of FOREIGN KEY
's of this table
*
* @return This table's FOREIGN KEY
's. This is never
* null
.
*/
List> getReferences();
/**
* Get a list of FOREIGN KEY
's of this table, referencing a
* specific table.
*
* @param The other table's record type
* @param other The other table of the foreign key relationship
* @return This table's FOREIGN KEY
's towards an other table.
* This is never null
.
*/
List> getReferencesTo(Table other);
// -------------------------------------------------------------------------
// XXX: Aliasing clauses
// -------------------------------------------------------------------------
/**
* Create an alias for this table.
*
* Note that the case-sensitivity of the returned table depends on
* {@link Settings#getRenderNameStyle()}. By default, table aliases are
* quoted, and thus case-sensitive!
*
* @param alias The alias name
* @return The table alias
*/
@Support
Table as(String alias);
/**
* Create an alias for this table and its fields
*
* Note that the case-sensitivity of the returned table and columns depends
* on {@link Settings#getRenderNameStyle()}. By default, table aliases are
* quoted, and thus case-sensitive!
*
*
Derived column lists for table references
*
* Note, not all databases support derived column lists for their table
* aliases. On the other hand, some databases do support derived column
* lists, but only for derived tables. jOOQ will try to turn table
* references into derived tables to make this syntax work. In other words,
* the following statements are equivalent:
* -- Using derived column lists to rename columns (e.g. Postgres)
* SELECT t.a, t.b
* FROM my_table t(a, b)
*
* -- Nesting table references within derived tables (e.g. SQL Server)
* SELECT t.a, t.b
* FROM (
* SELECT * FROM my_table
* ) t(a, b)
*
*
*
Derived column lists for derived tables
*
* Other databases may not support derived column lists at all, but they do
* support common table expressions. The following statements are
* equivalent:
* -- Using derived column lists to rename columns (e.g. Postgres)
* SELECT t.a, t.b
* FROM (
* SELECT 1, 2
* ) AS t(a, b)
*
* -- Using UNION ALL to produce column names (e.g. MySQL)
* SELECT t.a, t.b
* FROM (
* SELECT null a, null b FROM DUAL WHERE 1 = 0
* UNION ALL
* SELECT 1, 2 FROM DUAL
* ) t
*
*
* @param alias The alias name
* @param fieldAliases The field aliases. Excess aliases are ignored,
* missing aliases will be substituted by this table's field
* names.
* @return The table alias
*/
@Support
Table as(String alias, String... fieldAliases);
// -------------------------------------------------------------------------
// XXX: JOIN clauses on tables
// -------------------------------------------------------------------------
/**
* Join a table to this table using a {@link JoinType}
*
* Depending on the JoinType
, a subsequent
* {@link TableOnStep#on(Condition...)} or
* {@link TableOnStep#using(Field...)} clause is required. If it is required
* but omitted, a {@link DSL#trueCondition()}, i.e. 1 = 1
* condition will be rendered
*/
@Support
TableOptionalOnStep join(TableLike> table, JoinType type);
/**
* INNER JOIN
a table to this table.
*/
@Support
TableOnStep join(TableLike> table);
/**
* INNER JOIN
a table to this table.
*
* NOTE: When inserting plain SQL into jOOQ objects, you must
* guarantee syntax integrity. You may also create the possibility of
* malicious SQL injection. Be sure to properly use bind variables and/or
* escape literals when concatenated into SQL clauses!
*
* @see DSL#table(String)
*/
@Support
TableOnStep join(String sql);
/**
* INNER JOIN
a table to this table.
*
* NOTE: When inserting plain SQL into jOOQ objects, you must
* guarantee syntax integrity. You may also create the possibility of
* malicious SQL injection. Be sure to properly use bind variables and/or
* escape literals when concatenated into SQL clauses!
*
* @see DSL#table(String, Object...)
*/
@Support
TableOnStep join(String sql, Object... bindings);
/**
* INNER JOIN
a table to this table.
*
* NOTE: When inserting plain SQL into jOOQ objects, you must
* guarantee syntax integrity. You may also create the possibility of
* malicious SQL injection. Be sure to properly use bind variables and/or
* escape literals when concatenated into SQL clauses!
*
* @see DSL#table(String, QueryPart...)
*/
@Support
TableOnStep join(String sql, QueryPart... parts);
/**
* LEFT OUTER JOIN
a table to this table.
*/
@Support
TablePartitionByStep leftOuterJoin(TableLike> table);
/**
* LEFT OUTER JOIN
a table to this table.
*
* NOTE: When inserting plain SQL into jOOQ objects, you must
* guarantee syntax integrity. You may also create the possibility of
* malicious SQL injection. Be sure to properly use bind variables and/or
* escape literals when concatenated into SQL clauses!
*
* @see DSL#table(String)
*/
@Support
TablePartitionByStep leftOuterJoin(String sql);
/**
* LEFT OUTER JOIN
a table to this table.
*
* NOTE: When inserting plain SQL into jOOQ objects, you must
* guarantee syntax integrity. You may also create the possibility of
* malicious SQL injection. Be sure to properly use bind variables and/or
* escape literals when concatenated into SQL clauses!
*
* @see DSL#table(String, Object...)
*/
@Support
TablePartitionByStep leftOuterJoin(String sql, Object... bindings);
/**
* LEFT OUTER JOIN
a table to this table.
*
* NOTE: When inserting plain SQL into jOOQ objects, you must
* guarantee syntax integrity. You may also create the possibility of
* malicious SQL injection. Be sure to properly use bind variables and/or
* escape literals when concatenated into SQL clauses!
*
* @see DSL#table(String, QueryPart...)
*/
@Support
TablePartitionByStep leftOuterJoin(String sql, QueryPart... parts);
/**
* RIGHT OUTER JOIN
a table to this table.
*
* This is only possible where the underlying RDBMS supports it
*/
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
TablePartitionByStep rightOuterJoin(TableLike> table);
/**
* RIGHT OUTER JOIN
a table to this table.
*
* This is only possible where the underlying RDBMS supports it
*
* NOTE: When inserting plain SQL into jOOQ objects, you must
* guarantee syntax integrity. You may also create the possibility of
* malicious SQL injection. Be sure to properly use bind variables and/or
* escape literals when concatenated into SQL clauses!
*
* @see DSL#table(String)
*/
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
TablePartitionByStep rightOuterJoin(String sql);
/**
* RIGHT OUTER JOIN
a table to this table.
*
* This is only possible where the underlying RDBMS supports it
*
* NOTE: When inserting plain SQL into jOOQ objects, you must
* guarantee syntax integrity. You may also create the possibility of
* malicious SQL injection. Be sure to properly use bind variables and/or
* escape literals when concatenated into SQL clauses!
*
* @see DSL#table(String, Object...)
*/
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
TablePartitionByStep rightOuterJoin(String sql, Object... bindings);
/**
* RIGHT OUTER JOIN
a table to this table.
*
* This is only possible where the underlying RDBMS supports it
*
* NOTE: When inserting plain SQL into jOOQ objects, you must
* guarantee syntax integrity. You may also create the possibility of
* malicious SQL injection. Be sure to properly use bind variables and/or
* escape literals when concatenated into SQL clauses!
*
* @see DSL#table(String, QueryPart...)
*/
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
TablePartitionByStep rightOuterJoin(String sql, QueryPart... parts);
/**
* FULL OUTER JOIN
a table to this table.
*
* This is only possible where the underlying RDBMS supports it
*/
@Support({ FIREBIRD, HSQLDB, POSTGRES })
TableOnStep fullOuterJoin(TableLike> table);
/**
* FULL OUTER JOIN
a table to this table.
*
* This is only possible where the underlying RDBMS supports it
*
* NOTE: When inserting plain SQL into jOOQ objects, you must
* guarantee syntax integrity. You may also create the possibility of
* malicious SQL injection. Be sure to properly use bind variables and/or
* escape literals when concatenated into SQL clauses!
*
* @see DSL#table(String)
*/
@Support({ FIREBIRD, HSQLDB, POSTGRES })
TableOnStep fullOuterJoin(String sql);
/**
* FULL OUTER JOIN
a table to this table.
*
* This is only possible where the underlying RDBMS supports it
*
* NOTE: When inserting plain SQL into jOOQ objects, you must
* guarantee syntax integrity. You may also create the possibility of
* malicious SQL injection. Be sure to properly use bind variables and/or
* escape literals when concatenated into SQL clauses!
*
* @see DSL#table(String, Object...)
*/
@Support({ FIREBIRD, HSQLDB, POSTGRES })
TableOnStep fullOuterJoin(String sql, Object... bindings);
/**
* FULL OUTER JOIN
a table to this table.
*
* This is only possible where the underlying RDBMS supports it
*
* NOTE: When inserting plain SQL into jOOQ objects, you must
* guarantee syntax integrity. You may also create the possibility of
* malicious SQL injection. Be sure to properly use bind variables and/or
* escape literals when concatenated into SQL clauses!
*
* @see DSL#table(String, QueryPart...)
*/
@Support({ FIREBIRD, HSQLDB, POSTGRES })
TableOnStep fullOuterJoin(String sql, QueryPart... parts);
/**
* CROSS JOIN
a table to this table.
*
* If this syntax is unavailable, it is simulated with a regular
* INNER JOIN
. The following two constructs are equivalent:
*
* A cross join B
* A join B on 1 = 1
*
*/
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, SQLITE })
Table crossJoin(TableLike> table);
/**
* CROSS JOIN
a table to this table.
*
* If this syntax is unavailable, it is simulated with a regular
* INNER JOIN
. The following two constructs are equivalent:
*
* A cross join B
* A join B on 1 = 1
*
*
* NOTE: When inserting plain SQL into jOOQ objects, you must
* guarantee syntax integrity. You may also create the possibility of
* malicious SQL injection. Be sure to properly use bind variables and/or
* escape literals when concatenated into SQL clauses!
*
* @see DSL#table(String)
*/
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, SQLITE })
Table crossJoin(String sql);
/**
* CROSS JOIN
a table to this table.
*
* If this syntax is unavailable, it is simulated with a regular
* INNER JOIN
. The following two constructs are equivalent:
*
* A cross join B
* A join B on 1 = 1
*
*
* NOTE: When inserting plain SQL into jOOQ objects, you must
* guarantee syntax integrity. You may also create the possibility of
* malicious SQL injection. Be sure to properly use bind variables and/or
* escape literals when concatenated into SQL clauses!
*
* @see DSL#table(String, Object...)
*/
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, SQLITE })
Table crossJoin(String sql, Object... bindings);
/**
* CROSS JOIN
a table to this table.
*
* If this syntax is unavailable, it is simulated with a regular
* INNER JOIN
. The following two constructs are equivalent:
*
* A cross join B
* A join B on 1 = 1
*
*
* NOTE: When inserting plain SQL into jOOQ objects, you must
* guarantee syntax integrity. You may also create the possibility of
* malicious SQL injection. Be sure to properly use bind variables and/or
* escape literals when concatenated into SQL clauses!
*
* @see DSL#table(String, QueryPart...)
*/
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, SQLITE })
Table crossJoin(String sql, QueryPart... parts);
/**
* NATURAL JOIN
a table to this table.
*
* If this is not supported by your RDBMS, then jOOQ will try to simulate
* this behaviour using the information provided in this query.
*/
@Support
Table naturalJoin(TableLike> table);
/**
* NATURAL JOIN
a table to this table.
*
* If this is not supported by your RDBMS, then jOOQ will try to simulate
* this behaviour using the information provided in this query.
*
* NOTE: When inserting plain SQL into jOOQ objects, you must
* guarantee syntax integrity. You may also create the possibility of
* malicious SQL injection. Be sure to properly use bind variables and/or
* escape literals when concatenated into SQL clauses!
*
* @see DSL#table(String)
*/
@Support
Table naturalJoin(String sql);
/**
* NATURAL JOIN
a table to this table.
*
* If this is not supported by your RDBMS, then jOOQ will try to simulate
* this behaviour using the information provided in this query.
*
* NOTE: When inserting plain SQL into jOOQ objects, you must
* guarantee syntax integrity. You may also create the possibility of
* malicious SQL injection. Be sure to properly use bind variables and/or
* escape literals when concatenated into SQL clauses!
*
* @see DSL#table(String, Object...)
*/
@Support
Table naturalJoin(String sql, Object... bindings);
/**
* NATURAL JOIN
a table to this table.
*
* If this is not supported by your RDBMS, then jOOQ will try to simulate
* this behaviour using the information provided in this query.
*
* NOTE: When inserting plain SQL into jOOQ objects, you must
* guarantee syntax integrity. You may also create the possibility of
* malicious SQL injection. Be sure to properly use bind variables and/or
* escape literals when concatenated into SQL clauses!
*
* @see DSL#table(String, QueryPart...)
*/
@Support
Table naturalJoin(String sql, QueryPart... parts);
/**
* NATURAL LEFT OUTER JOIN
a table to this table.
*
* If this is not supported by your RDBMS, then jOOQ will try to simulate
* this behaviour using the information provided in this query.
*/
@Support
Table naturalLeftOuterJoin(TableLike> table);
/**
* NATURAL LEFT OUTER JOIN
a table to this table.
*
* If this is not supported by your RDBMS, then jOOQ will try to simulate
* this behaviour using the information provided in this query.
*
* NOTE: When inserting plain SQL into jOOQ objects, you must
* guarantee syntax integrity. You may also create the possibility of
* malicious SQL injection. Be sure to properly use bind variables and/or
* escape literals when concatenated into SQL clauses!
*
* @see DSL#table(String)
*/
@Support
Table naturalLeftOuterJoin(String sql);
/**
* NATURAL LEFT OUTER JOIN
a table to this table.
*
* If this is not supported by your RDBMS, then jOOQ will try to simulate
* this behaviour using the information provided in this query.
*
* NOTE: When inserting plain SQL into jOOQ objects, you must
* guarantee syntax integrity. You may also create the possibility of
* malicious SQL injection. Be sure to properly use bind variables and/or
* escape literals when concatenated into SQL clauses!
*
* @see DSL#table(String, Object...)
*/
@Support
Table naturalLeftOuterJoin(String sql, Object... bindings);
/**
* NATURAL LEFT OUTER JOIN
a table to this table.
*
* If this is not supported by your RDBMS, then jOOQ will try to simulate
* this behaviour using the information provided in this query.
*
* NOTE: When inserting plain SQL into jOOQ objects, you must
* guarantee syntax integrity. You may also create the possibility of
* malicious SQL injection. Be sure to properly use bind variables and/or
* escape literals when concatenated into SQL clauses!
*
* @see DSL#table(String, QueryPart...)
*/
@Support
Table naturalLeftOuterJoin(String sql, QueryPart... parts);
/**
* NATURAL RIGHT OUTER JOIN
a table to this table.
*
* If this is not supported by your RDBMS, then jOOQ will try to simulate
* this behaviour using the information provided in this query.
*/
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
Table naturalRightOuterJoin(TableLike> table);
/**
* NATURAL RIGHT OUTER JOIN
a table to this table.
*
* If this is not supported by your RDBMS, then jOOQ will try to simulate
* this behaviour using the information provided in this query.
*
* NOTE: When inserting plain SQL into jOOQ objects, you must
* guarantee syntax integrity. You may also create the possibility of
* malicious SQL injection. Be sure to properly use bind variables and/or
* escape literals when concatenated into SQL clauses!
*
* @see DSL#table(String)
*/
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
Table naturalRightOuterJoin(String sql);
/**
* NATURAL RIGHT OUTER JOIN
a table to this table.
*
* If this is not supported by your RDBMS, then jOOQ will try to simulate
* this behaviour using the information provided in this query.
*
* NOTE: When inserting plain SQL into jOOQ objects, you must
* guarantee syntax integrity. You may also create the possibility of
* malicious SQL injection. Be sure to properly use bind variables and/or
* escape literals when concatenated into SQL clauses!
*
* @see DSL#table(String, Object...)
*/
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
Table naturalRightOuterJoin(String sql, Object... bindings);
/**
* NATURAL RIGHT OUTER JOIN
a table to this table.
*
* If this is not supported by your RDBMS, then jOOQ will try to simulate
* this behaviour using the information provided in this query.
*
* NOTE: When inserting plain SQL into jOOQ objects, you must
* guarantee syntax integrity. You may also create the possibility of
* malicious SQL injection. Be sure to properly use bind variables and/or
* escape literals when concatenated into SQL clauses!
*
* @see DSL#table(String, QueryPart...)
*/
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
Table naturalRightOuterJoin(String sql, QueryPart... parts);
// -------------------------------------------------------------------------
// XXX: APPLY clauses on tables
// -------------------------------------------------------------------------
/* [pro] xx
xxx
x xxxxxxxxxxx xxxxxxxxxxxx x xxxxx xx xxxx xxxxxx
xx
xxxxxxxxxx xxxxxxxxxx xxxxxxxxxx xxxxxx xx
xxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxx xxxxxxx
xxx
x xxxxxxxxxxx xxxxxxxxxxxx x xxxxx xx xxxx xxxxxx
x xxx
x xxxxxxxxxxxx xxxx xxxxxxxxx xxxxx xxx xxxx xxxx xxxxxxxx xxx xxxx
x xxxxxxxxx xxxxxx xxxxxxxxxx xxx xxx xxxx xxxxxx xxx xxxxxxxxxxx xx
x xxxxxxxxx xxx xxxxxxxxxx xx xxxx xx xxxxxxxx xxx xxxx xxxxxxxxx xxxxxx
x xxxxxx xxxxxxxx xxxx xxxxxxxxxxxx xxxx xxx xxxxxxxx
x
x xxxx xxxxxxxxxxxxxxxxx
xx
xxxxxxxxxx xxxxxxxxxx xxxxxxxxxx xxxxxx xx
xxxxxxxxxxxxx xxxxxxxxxxxxxxxxx xxxxx
xxx
x xxxxxxxxxxx xxxxxxxxxxxx x xxxxx xx xxxx xxxxxx
x xxx
x xxxxxxxxxxxx xxxx xxxxxxxxx xxxxx xxx xxxx xxxx xxxxxxxx xxx xxxx
x xxxxxxxxx xxxxxx xxxxxxxxxx xxx xxx xxxx xxxxxx xxx xxxxxxxxxxx xx
x xxxxxxxxx xxx xxxxxxxxxx xx xxxx xx xxxxxxxx xxx xxxx xxxxxxxxx xxxxxx
x xxxxxx xxxxxxxx xxxx xxxxxxxxxxxx xxxx xxx xxxxxxxx
x
x xxxx xxxxxxxxxxxxxxxxx xxxxxxxxxx
xx
xxxxxxxxxx xxxxxxxxxx xxxxxxxxxx xxxxxx xx
xxxxxxxxxxxxx xxxxxxxxxxxxxxxxx xxxx xxxxxxxxx xxxxxxxxxx
xxx
x xxxxxxxxxxx xxxxxxxxxxxx x xxxxx xx xxxx xxxxxx
x xxx
x xxxxxxxxxxxx xxxx xxxxxxxxx xxxxx xxx xxxx xxxx xxxxxxxx xxx xxxx
x xxxxxxxxx xxxxxx xxxxxxxxxx xxx xxx xxxx xxxxxx xxx xxxxxxxxxxx xx
x xxxxxxxxx xxx xxxxxxxxxx xx xxxx xx xxxxxxxx xxx xxxx xxxxxxxxx xxxxxx
x xxxxxx xxxxxxxx xxxx xxxxxxxxxxxx xxxx xxx xxxxxxxx
x
x xxxx xxxxxxxxxxxxxxxxx xxxxxxxxxxxxx
xx
xxxxxxxxxx xxxxxxxxxx xxxxxxxxxx xxxxxx xx
xxxxxxxxxxxxx xxxxxxxxxxxxxxxxx xxxx xxxxxxxxxxxx xxxxxxx
xxx
x xxxxxxxxxxx xxxxxxxxxxxx x xxxxx xx xxxx xxxxxx
xx
xxxxxxxxxx xxxxxxxxxx xxxxxxxxxx xxxxxx xx
xxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxx xxxxxxx
xxx
x xxxxxxxxxxx xxxxxxxxxxxx x xxxxx xx xxxx xxxxxx
x xxx
x xxxxxxxxxxxx xxxx xxxxxxxxx xxxxx xxx xxxx xxxx xxxxxxxx xxx xxxx
x xxxxxxxxx xxxxxx xxxxxxxxxx xxx xxx xxxx xxxxxx xxx xxxxxxxxxxx xx
x xxxxxxxxx xxx xxxxxxxxxx xx xxxx xx xxxxxxxx xxx xxxx xxxxxxxxx xxxxxx
x xxxxxx xxxxxxxx xxxx xxxxxxxxxxxx xxxx xxx xxxxxxxx
x
x xxxx xxxxxxxxxxxxxxxxx
xx
xxxxxxxxxx xxxxxxxxxx xxxxxxxxxx xxxxxx xx
xxxxxxxxxxxxx xxxxxxxxxxxxxxxxx xxxxx
xxx
x xxxxxxxxxxx xxxxxxxxxxxx x xxxxx xx xxxx xxxxxx
x xxx
x xxxxxxxxxxxx xxxx xxxxxxxxx xxxxx xxx xxxx xxxx xxxxxxxx xxx xxxx
x xxxxxxxxx xxxxxx xxxxxxxxxx xxx xxx xxxx xxxxxx xxx xxxxxxxxxxx xx
x xxxxxxxxx xxx xxxxxxxxxx xx xxxx xx xxxxxxxx xxx xxxx xxxxxxxxx xxxxxx
x xxxxxx xxxxxxxx xxxx xxxxxxxxxxxx xxxx xxx xxxxxxxx
x
x xxxx xxxxxxxxxxxxxxxxx xxxxxxxxxx
xx
xxxxxxxxxx xxxxxxxxxx xxxxxxxxxx xxxxxx xx
xxxxxxxxxxxxx xxxxxxxxxxxxxxxxx xxxx xxxxxxxxx xxxxxxxxxx
xxx
x xxxxxxxxxxx xxxxxxxxxxxx x xxxxx xx xxxx xxxxxx
x xxx
x xxxxxxxxxxxx xxxx xxxxxxxxx xxxxx xxx xxxx xxxx xxxxxxxx xxx xxxx
x xxxxxxxxx xxxxxx xxxxxxxxxx xxx xxx xxxx xxxxxx xxx xxxxxxxxxxx xx
x xxxxxxxxx xxx xxxxxxxxxx xx xxxx xx xxxxxxxx xxx xxxx xxxxxxxxx xxxxxx
x xxxxxx xxxxxxxx xxxx xxxxxxxxxxxx xxxx xxx xxxxxxxx
x
x xxxx xxxxxxxxxxxxxxxxx xxxxxxxxxxxxx
xx
xxxxxxxxxx xxxxxxxxxx xxxxxxxxxx xxxxxx xx
xxxxxxxxxxxxx xxxxxxxxxxxxxxxxx xxxx xxxxxxxxxxxx xxxxxxx
xx [/pro] */
// -------------------------------------------------------------------------
// XXX: Exotic and vendor-specific clauses on tables
// -------------------------------------------------------------------------
/**
* Specify a MySQL style table hint for query optimisation.
*
* Example:
*
*
* create.select()
* .from(BOOK.as("b").useIndex("MY_INDEX")
* .fetch();
*
*
* @see http://dev.mysql.com/doc/refman/5.7/en/index-hints.html
*/
@Support({ MARIADB, MYSQL })
Table useIndex(String... indexes);
/**
* Specify a MySQL style table hint for query optimisation.
*
* Example:
*
*
* create.select()
* .from(BOOK.as("b").useIndexForJoin("MY_INDEX")
* .fetch();
*
*
* @see http://dev.mysql.com/doc/refman/5.7/en/index-hints.html
*/
@Support({ MARIADB, MYSQL })
Table useIndexForJoin(String... indexes);
/**
* Specify a MySQL style table hint for query optimisation.
*
* Example:
*
*
* create.select()
* .from(BOOK.as("b").useIndexForOrderBy("MY_INDEX")
* .fetch();
*
*
* @see http://dev.mysql.com/doc/refman/5.7/en/index-hints.html
*/
@Support({ MARIADB, MYSQL })
Table useIndexForOrderBy(String... indexes);
/**
* Specify a MySQL style table hint for query optimisation.
*
* Example:
*
*
* create.select()
* .from(BOOK.as("b").useIndexForGroupBy("MY_INDEX")
* .fetch();
*
*
* @see http://dev.mysql.com/doc/refman/5.7/en/index-hints.html
*/
@Support({ MARIADB, MYSQL })
Table useIndexForGroupBy(String... indexes);
/**
* Specify a MySQL style table hint for query optimisation.
*
* Example:
*
*
* create.select()
* .from(BOOK.as("b").useIndex("MY_INDEX")
* .fetch();
*
*
* @see http://dev.mysql.com/doc/refman/5.7/en/index-hints.html
*/
@Support({ MARIADB, MYSQL })
Table ignoreIndex(String... indexes);
/**
* Specify a MySQL style table hint for query optimisation.
*
* Example:
*
*
* create.select()
* .from(BOOK.as("b").useIndexForJoin("MY_INDEX")
* .fetch();
*
*
* @see http://dev.mysql.com/doc/refman/5.7/en/index-hints.html
*/
@Support({ MARIADB, MYSQL })
Table ignoreIndexForJoin(String... indexes);
/**
* Specify a MySQL style table hint for query optimisation.
*
* Example:
*
*
* create.select()
* .from(BOOK.as("b").useIndexForOrderBy("MY_INDEX")
* .fetch();
*
*
* @see http://dev.mysql.com/doc/refman/5.7/en/index-hints.html
*/
@Support({ MARIADB, MYSQL })
Table ignoreIndexForOrderBy(String... indexes);
/**
* Specify a MySQL style table hint for query optimisation.
*
* Example:
*
*
* create.select()
* .from(BOOK.as("b").useIndexForGroupBy("MY_INDEX")
* .fetch();
*
*
* @see http://dev.mysql.com/doc/refman/5.7/en/index-hints.html
*/
@Support({ MARIADB, MYSQL })
Table ignoreIndexForGroupBy(String... indexes);
/**
* Specify a MySQL style table hint for query optimisation.
*
* Example:
*
*
* create.select()
* .from(BOOK.as("b").useIndex("MY_INDEX")
* .fetch();
*
*
* @see http://dev.mysql.com/doc/refman/5.7/en/index-hints.html
*/
@Support({ MARIADB, MYSQL })
Table forceIndex(String... indexes);
/**
* Specify a MySQL style table hint for query optimisation.
*
* Example:
*
*
* create.select()
* .from(BOOK.as("b").useIndexForJoin("MY_INDEX")
* .fetch();
*
*
* @see http://dev.mysql.com/doc/refman/5.7/en/index-hints.html
*/
@Support({ MARIADB, MYSQL })
Table forceIndexForJoin(String... indexes);
/**
* Specify a MySQL style table hint for query optimisation.
*
* Example:
*
*
* create.select()
* .from(BOOK.as("b").useIndexForOrderBy("MY_INDEX")
* .fetch();
*
*
* @see http://dev.mysql.com/doc/refman/5.7/en/index-hints.html
*/
@Support({ MARIADB, MYSQL })
Table forceIndexForOrderBy(String... indexes);
/**
* Specify a MySQL style table hint for query optimisation.
*
* Example:
*
*
* create.select()
* .from(BOOK.as("b").useIndexForGroupBy("MY_INDEX")
* .fetch();
*
*
* @see http://dev.mysql.com/doc/refman/5.7/en/index-hints.html
*/
@Support({ MARIADB, MYSQL })
Table forceIndexForGroupBy(String... indexes);
/* [pro] xx
xxx
x xxxxxxx x xxx xxxxxx xxxxx xxxxx xxxx xxx xxxxx xxxxxxxxxxxxx
x xxx
x xxxx xxxxx xxxxx xxxx xx xx xxxxxx xxxxxxxx xxxxx xx xxxxx xxx xx xxxxx
x xxxxxxxx xxxxx xxxxxxxx
x xxx
x xxxxxxxx
x xxx
x xxxxxxxxxxx
x xxxxxxxxxxxxxxx
x xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
x xxxxxxxxx
x xxxxxxxxxxxxx
x xxx
x xxx xxxxxx xxxxxxxxxxxxxxxxxx xxxxx xxxxxx xxx
x xxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxx xxx xxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxx
x
x xxxx xx
x xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
x xxxx xxxxxxxxxxxxxxxxxxxxxxxxxxx
x xxxx xxxxxxxxxxxxxxxxxxxxxxxxxxx
xx
xxxxxxxxxx xxxxxxxxxx xxxxxx xx
xxxxxxxx xxxxxxxxxxx xxxxxx
xxx
x xxxxxx x xxx xxxxxxxxxxxxxxxxxx xxxxxxxxx xxxx xxxx xxxxxx xxxxxxxx xx
x xxxx xxxxxxx xxxxx
x xxx
x xxxx xxx xxxx xxxxxxxx xx xxxx xxxx
x xxxx
x xxxx xxxxxx xxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxx
x xxxx xxxxxx xxxxxxxxxxxxxxxxxxxxx xxxx xxx xxxxxxxxxx xxxxxxxxxxxxxxx
x xxxxxxxxx xxxxxxxx xx xxxxx xxxx xxxxx xx xxxxxxxxxx xxxx xxx xxxxxxxxxx
x xxxxxxxxxxxxxxx
x xxxxx
x
x xxxxxx xxxxxxxxxxxxxxxxxx xxx xxxxxxxxx xxxxxxxxx xxxx xxx xxxxxxxxx
x xxxxxxx x xxx xxxxxx xx xxxxxx xxx xxxxxxxxxxxxxxxxxx xxxxxxxxxx
xx
xxxxxxxxxx xxxxxxxxxx xxxxxxxxx xx
xxxxxxxxxxxx xxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxx
xxx
x xxxxxx x xxx xxxxxxxxxxxxxxxxxx xxxxxxxxx xxxx xxxx xxxxxx xxxxxxxx xx
x xxxx xxxxxxx xxxxx
x xxx
x xxx xxxx xxxxxxxx xxx xxxxxx xxxxxxxxxxxxxxxxx
x
x xxxxxx xxxxxxxxxxxxxxxxxx xxx xxxxxxxxx xxxxxxxxx xxxx xxx xxxxxxxxx
x xxxxxxx x xxx xxxxxx xx xxxxxx xxx xxxxxxxxxxxxxxxxxx xxxxxxxxxx
x xxxx xxxxxxxxxxxxxxxx
xx
xxxxxxxxxx xxxxxxxxxx xxxxxxxxx xx
xxxxxxxxxxxx xxxxxxxxxxxxxxxxxx xxxxxxx xxxxxxxxx xxxxxxxxxxxxxxxxxxxx
xx [/pro] */
/**
* Create a new TABLE
reference from this table, applying
* relational division.
*
* Relational division is the inverse of a cross join operation. The
* following is an approximate definition of a relational division:
*
* Assume the following cross join / cartesian product
* C = A × B
*
* Then it can be said that
* A = C ÷ B
* B = C ÷ A
*
*
* With jOOQ, you can simplify using relational divisions by using the
* following syntax:
* C.divideBy(B).on(C.ID.equal(B.C_ID)).returning(C.TEXT)
*
*
* The above roughly translates to
* SELECT DISTINCT C.TEXT FROM C "c1"
* WHERE NOT EXISTS (
* SELECT 1 FROM B
* WHERE NOT EXISTS (
* SELECT 1 FROM C "c2"
* WHERE "c2".TEXT = "c1".TEXT
* AND "c2".ID = B.C_ID
* )
* )
*
*
* Or in plain text: Find those TEXT values in C whose ID's correspond to
* all ID's in B. Note that from the above SQL statement, it is immediately
* clear that proper indexing is of the essence. Be sure to have indexes on
* all columns referenced from the on(...)
and
* returning(...)
clauses.
*
* For more information about relational division and some nice, real-life
* examples, see
*
* - http
* ://en.wikipedia.org/wiki/Relational_algebra#Division
* - http://www.simple-talk.com/sql/t-sql-programming/divided-we-stand-the-
* sql-of-relational-division/
*
*
* This has been observed to work with all dialects
*/
@Support
DivideByOnStep divideBy(Table> divisor);
/* [pro] xx
xxx
x xxxxxx xx xxxxxx xxxxxxxxxxxxxxxxxx xxxxxxxxx xxxxxxxx xxxxx xxxxxx xxxx
x xxxx xxxxxx
xx
xxxxxxxxxx xxxxxx xx
xxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxx xxxxx
xxx
x xxxxxx xx xxxxxx xxxxxxxxxxxxxxxxxx xxxxxxxxx xxxxxxxx xxxxx xxxxxx xxxx
x xxxx xxxxxx
xx
xxxxxxxxxx xxxxxx xx
xxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxx xxxxxxx xxxxx
xxx
x xxxxxx xx xxxxxx xxxxxxxxxxxxxxxxxx xxxxxxxxx xxxxxxxx xxxxx xxxxxx xxxx
x xxxx xxxxxx
xx
xxxxxxxxxx xxxxxx xx
xxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxx
x xxxxxx xx xxxxxx xxxxxxxxxxxxxxxxxx xxxxxxxxx xxxxxxxx xxxxx xxxxxx xxxx
x xxxx xxxxxx
xx
xxxxxxxxxx xxxxxx xx
xxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxx
xxx
x xxxxxx xx xxxxxx xxxxxxxxxxxxxxxxxx xxxxxxxxx xxxxxxxx xxxxx xxxxxx xxxx
x xxxx xxxxxx
xx
xxxxxxxxxx xxxxxx xx
xxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxx
xxx
x xxxxxx xx xxxxxx xxxxxxxxxxxxxxxxxx xxxxxxxxx xxxxxxxx xxxxx xxxxxx xxxx
x xxxx xxxxxx
xx
xxxxxxxxxx xxxxxx xx
xxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxx
x xxxxxx xx xxxxxx xxxxxxxxxxxxxxxxxx xxxxxxxxx xxxxx xxxxxx xxxx xxxx
x xxxxxx
xx
xxxxxxxxxx xxxxxx xx
xxxxxxxx xxxxxxxxxxxxxx xxxxx
xxx
x xxxxxx xx xxxxxx xxxxxxxxxxxxxxxxxx xxxxxxxxx xxxxx xxxxxx xxxx xxxx
x xxxxxx
xx
xxxxxxxxxx xxxxxx xx
xxxxxxxx xxxxxxxxxxxxxxx xxxxxxx xxxxxxx xxxxx
xxx
x xxxxxx xx xxxxxx xxxxxxxxxxxxxxxxxx xxxxxxxxx xxxxx xxxxxx xxxx xxxx
x xxxxxx
xx
xxxxxxxxxx xxxxxx xx
xxxxxxxx xxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxx
xxx
x xxxxxx xx xxxxxx xxxxxxxxxxxxxxxxxx xxxxxxxxx xxxxx xxxxxx xxxx xxxx
x xxxxxx
xx
xxxxxxxxxx xxxxxx xx
xxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxx
xx [/pro] */
}