diff --git a/jOOQ/src/main/java/org/jooq/impl/Factory.java b/jOOQ/src/main/java/org/jooq/impl/Factory.java
index 3b74defb62..431a2e5159 100644
--- a/jOOQ/src/main/java/org/jooq/impl/Factory.java
+++ b/jOOQ/src/main/java/org/jooq/impl/Factory.java
@@ -399,10 +399,6 @@ public class Factory {
return new NameImpl(qualifiedName);
}
- // -------------------------------------------------------------------------
- // XXX Plain SQL object factory
- // -------------------------------------------------------------------------
-
/**
* Create a qualified schema, given its schema name
*
@@ -428,6 +424,143 @@ public class Factory {
return new SchemaImpl(name);
}
+ /**
+ * Create a qualified table, given its table name
+ *
+ * This constructs a table reference given the table's qualified name. jOOQ
+ * will render the table name according to your
+ * {@link Settings#getRenderNameStyle()} settings. Choose
+ * {@link RenderNameStyle#QUOTED} to prevent syntax errors and/or SQL
+ * injection.
+ *
+ * Example:
+ * // This table...
+ * tableByName("MY_SCHEMA", "MY_TABLE");
+ *
+ * // ... will render this SQL on SQL Server with RenderNameStyle.QUOTED set
+ * [MY_SCHEMA].[MY_TABLE]
+ *
+ *
+ * @param qualifiedName The various parts making up your table's reference
+ * name.
+ * @return A table referenced by tableName
+ */
+ @Support
+ public static Table tableByName(String... qualifiedName) {
+ return new QualifiedTable(qualifiedName);
+ }
+
+ /**
+ * Create a qualified field, given its (qualified) field name.
+ *
+ * This constructs a field reference given the field's qualified name. jOOQ
+ * will render the field name according to your
+ * {@link Settings#getRenderNameStyle()} settings. Choose
+ * {@link RenderNameStyle#QUOTED} to prevent syntax errors and/or SQL
+ * injection.
+ *
+ * Example:
+ * // This field...
+ * fieldByName("MY_SCHEMA", "MY_TABLE", "MY_FIELD");
+ *
+ * // ... will render this SQL on SQL Server with RenderNameStyle.QUOTED set
+ * [MY_SCHEMA].[MY_TABLE].[MY_FIELD]
+ *
+ *
+ * Another example:
+ * create.select(field("length({1})", Integer.class, fieldByName("TITLE")))
+ * .from(tableByName("T_BOOK"))
+ * .fetch();
+ *
+ * // ... will execute this SQL on SQL Server:
+ * select length([TITLE]) from [T_BOOK]
+ *
+ *
+ * @param qualifiedName The various parts making up your field's reference
+ * name.
+ * @return A field referenced by fieldName
+ */
+ @Support
+ public static Field fieldByName(String... qualifiedName) {
+ return fieldByName(Object.class, qualifiedName);
+ }
+
+ /**
+ * Create a qualified field, given its (qualified) field name.
+ *
+ * This constructs a field reference given the field's qualified name. jOOQ
+ * will render the field name according to your
+ * {@link Settings#getRenderNameStyle()} settings. Choose
+ * {@link RenderNameStyle#QUOTED} to prevent syntax errors and/or SQL
+ * injection.
+ *
+ * Example:
+ * // This field...
+ * fieldByName("MY_SCHEMA", "MY_TABLE", "MY_FIELD");
+ *
+ * // ... will render this SQL on SQL Server with RenderNameStyle.QUOTED set
+ * [MY_SCHEMA].[MY_TABLE].[MY_FIELD]
+ *
+ *
+ * Another example:
+ * create.select(field("length({1})", Integer.class, fieldByName("TITLE")))
+ * .from(tableByName("T_BOOK"))
+ * .fetch();
+ *
+ * // ... will execute this SQL on SQL Server:
+ * select length([TITLE]) from [T_BOOK]
+ *
+ *
+ * @param qualifiedName The various parts making up your field's reference
+ * name.
+ * @param type The type of the returned field
+ * @return A field referenced by fieldName
+ */
+ @Support
+ public static Field fieldByName(Class type, String... qualifiedName) {
+ return fieldByName(getDataType(type), qualifiedName);
+ }
+
+ /**
+ * Create a qualified field, given its (qualified) field name.
+ *
+ * This constructs a field reference given the field's qualified name. jOOQ
+ * will render the field name according to your
+ * {@link Settings#getRenderNameStyle()} settings. Choose
+ * {@link RenderNameStyle#QUOTED} to prevent syntax errors and/or SQL
+ * injection.
+ *
+ * Example:
+ * // This field...
+ * fieldByName("MY_SCHEMA", "MY_TABLE", "MY_FIELD");
+ *
+ * // ... will render this SQL on SQL Server with RenderNameStyle.QUOTED set
+ * [MY_SCHEMA].[MY_TABLE].[MY_FIELD]
+ *
+ *
+ * Another example:
+ * create.select(field("length({1})", Integer.class, fieldByName("TITLE")))
+ * .from(tableByName("T_BOOK"))
+ * .fetch();
+ *
+ * // ... will execute this SQL on SQL Server:
+ * select length([TITLE]) from [T_BOOK]
+ *
+ *
+ * @param qualifiedName The various parts making up your field's reference
+ * name.
+ * @param type The type of the returned field
+ * @return A field referenced by fieldName
+ */
+ @Support
+ public static Field fieldByName(DataType type, String... qualifiedName) {
+ return new QualifiedField(type, qualifiedName);
+ }
+
+ // -------------------------------------------------------------------------
+ // XXX Plain SQL object factory
+ // -------------------------------------------------------------------------
+
/**
* A custom SQL clause that can render arbitrary table expressions.
*
@@ -528,133 +661,6 @@ public class Factory {
return new SQLTable(sql, parts);
}
- /**
- * Create a qualified table, given its table name
- *
- * This constructs a table reference given the table's qualified name. jOOQ
- * will render the table name according to your
- * {@link Settings#getRenderNameStyle()} settings. Choose
- * {@link RenderNameStyle#QUOTED} to prevent syntax errors and/or SQL
- * injection.
- *
- * Example:
- * // This table...
- * tableByName("MY_SCHEMA", "MY_TABLE");
- *
- * // ... will render this SQL on SQL Server with RenderNameStyle.QUOTED set
- * [MY_SCHEMA].[MY_TABLE]
- *
- *
- * @param qualifiedName The various parts making up your table's reference
- * name.
- * @return A table referenced by tableName
- */
- @Support
- public static Table tableByName(String... qualifiedName) {
- return new QualifiedTable(qualifiedName);
- }
-
- /**
- * A custom SQL clause that can render arbitrary SQL elements.
- *
- * This is useful for constructing more complex SQL syntax elements wherever
- * Field types are expected. An example for this is MySQL's
- * GROUP_CONCAT aggregate function, which has MySQL-specific
- * keywords that are hard to reflect in jOOQ's DSL:
- * GROUP_CONCAT([DISTINCT] expr [,expr ...]
- * [ORDER BY {unsigned_integer | col_name | expr}
- * [ASC | DESC] [,col_name ...]]
- * [SEPARATOR str_val])
- *
- *
- * The above MySQL function can be expressed as such:
- * field("GROUP_CONCAT(DISTINCT {0} ORDER BY {1} ASC DEPARATOR '-')", expr1, expr2);
- *
- *
- * 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! One way to escape
- * literals is to use {@link #name(String...)} and similar methods
- *
- * @param sql The SQL clause, containing {numbered placeholders} where query
- * parts can be injected
- * @param parts The {@link QueryPart} objects that are rendered at the
- * {numbered placeholder} locations
- * @return A field wrapping the plain SQL
- */
- public static Field field(String sql, QueryPart... parts) {
- return new SQLField(sql, SQLDataType.OTHER, parts);
- }
-
- /**
- * A custom SQL clause that can render arbitrary SQL elements.
- *
- * This is useful for constructing more complex SQL syntax elements wherever
- * Field types are expected. An example for this is MySQL's
- * GROUP_CONCAT aggregate function, which has MySQL-specific
- * keywords that are hard to reflect in jOOQ's DSL:
- * GROUP_CONCAT([DISTINCT] expr [,expr ...]
- * [ORDER BY {unsigned_integer | col_name | expr}
- * [ASC | DESC] [,col_name ...]]
- * [SEPARATOR str_val])
- *
- *
- * The above MySQL function can be expressed as such:
- * field("GROUP_CONCAT(DISTINCT {0} ORDER BY {1} ASC DEPARATOR '-')", expr1, expr2);
- *
- *
- * 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! One way to escape
- * literals is to use {@link #name(String...)} and similar methods
- *
- * @param sql The SQL clause, containing {numbered placeholders} where query
- * parts can be injected
- * @param type The field type
- * @param parts The {@link QueryPart} objects that are rendered at the
- * {numbered placeholder} locations
- * @return A field wrapping the plain SQL
- */
- public static Field field(String sql, Class type, QueryPart... parts) {
- return new SQLField(sql, getDataType(type), parts);
- }
-
- /**
- * A custom SQL clause that can render arbitrary SQL elements.
- *
- * This is useful for constructing more complex SQL syntax elements wherever
- * Field types are expected. An example for this is MySQL's
- * GROUP_CONCAT aggregate function, which has MySQL-specific
- * keywords that are hard to reflect in jOOQ's DSL:
- * GROUP_CONCAT([DISTINCT] expr [,expr ...]
- * [ORDER BY {unsigned_integer | col_name | expr}
- * [ASC | DESC] [,col_name ...]]
- * [SEPARATOR str_val])
- *
- *
- * The above MySQL function can be expressed as such:
- * field("GROUP_CONCAT(DISTINCT {0} ORDER BY {1} ASC DEPARATOR '-')", expr1, expr2);
- *
- *
- * 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! One way to escape
- * literals is to use {@link #name(String...)} and similar methods
- *
- * @param sql The SQL clause, containing {numbered placeholders} where query
- * parts can be injected
- * @param type The field type
- * @param parts The {@link QueryPart} objects that are rendered at the
- * {numbered placeholder} locations
- * @return A field wrapping the plain SQL
- */
- public static Field field(String sql, DataType type, QueryPart... parts) {
- return new SQLField(sql, type, parts);
- }
-
/**
* A PlainSQLField is a field that can contain user-defined plain SQL,
* because sometimes it is easier to express things directly in SQL, for
@@ -813,110 +819,104 @@ public class Factory {
}
/**
- * Create a qualified field, given its (qualified) field name.
+ * A custom SQL clause that can render arbitrary SQL elements.
*
- * This constructs a field reference given the field's qualified name. jOOQ
- * will render the field name according to your
- * {@link Settings#getRenderNameStyle()} settings. Choose
- * {@link RenderNameStyle#QUOTED} to prevent syntax errors and/or SQL
- * injection.
+ * This is useful for constructing more complex SQL syntax elements wherever
+ * Field types are expected. An example for this is MySQL's
+ * GROUP_CONCAT aggregate function, which has MySQL-specific
+ * keywords that are hard to reflect in jOOQ's DSL:
+ * GROUP_CONCAT([DISTINCT] expr [,expr ...]
+ * [ORDER BY {unsigned_integer | col_name | expr}
+ * [ASC | DESC] [,col_name ...]]
+ * [SEPARATOR str_val])
+ *
*
- * Example:
- * // This field...
- * fieldByName("MY_SCHEMA", "MY_TABLE", "MY_FIELD");
- *
- * // ... will render this SQL on SQL Server with RenderNameStyle.QUOTED set
- * [MY_SCHEMA].[MY_TABLE].[MY_FIELD]
+ * The above MySQL function can be expressed as such:
+ * field("GROUP_CONCAT(DISTINCT {0} ORDER BY {1} ASC DEPARATOR '-')", expr1, expr2);
*
*
- * Another example:
- * create.select(field("length({1})", Integer.class, fieldByName("TITLE")))
- * .from(tableByName("T_BOOK"))
- * .fetch();
+ * 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! One way to escape
+ * literals is to use {@link #name(String...)} and similar methods
*
- * // ... will execute this SQL on SQL Server:
- * select length([TITLE]) from [T_BOOK]
- *
- *
- * @param qualifiedName The various parts making up your field's reference
- * name.
- * @return A field referenced by fieldName
+ * @param sql The SQL clause, containing {numbered placeholders} where query
+ * parts can be injected
+ * @param parts The {@link QueryPart} objects that are rendered at the
+ * {numbered placeholder} locations
+ * @return A field wrapping the plain SQL
*/
- @Support
- public static Field fieldByName(String... qualifiedName) {
- return fieldByName(Object.class, qualifiedName);
+ public static Field field(String sql, QueryPart... parts) {
+ return new SQLField(sql, SQLDataType.OTHER, parts);
}
/**
- * Create a qualified field, given its (qualified) field name.
+ * A custom SQL clause that can render arbitrary SQL elements.
*
- * This constructs a field reference given the field's qualified name. jOOQ
- * will render the field name according to your
- * {@link Settings#getRenderNameStyle()} settings. Choose
- * {@link RenderNameStyle#QUOTED} to prevent syntax errors and/or SQL
- * injection.
+ * This is useful for constructing more complex SQL syntax elements wherever
+ * Field types are expected. An example for this is MySQL's
+ * GROUP_CONCAT aggregate function, which has MySQL-specific
+ * keywords that are hard to reflect in jOOQ's DSL:
+ * GROUP_CONCAT([DISTINCT] expr [,expr ...]
+ * [ORDER BY {unsigned_integer | col_name | expr}
+ * [ASC | DESC] [,col_name ...]]
+ * [SEPARATOR str_val])
+ *
*
- * Example:
- * // This field...
- * fieldByName("MY_SCHEMA", "MY_TABLE", "MY_FIELD");
- *
- * // ... will render this SQL on SQL Server with RenderNameStyle.QUOTED set
- * [MY_SCHEMA].[MY_TABLE].[MY_FIELD]
+ * The above MySQL function can be expressed as such:
+ * field("GROUP_CONCAT(DISTINCT {0} ORDER BY {1} ASC DEPARATOR '-')", expr1, expr2);
*
*
- * Another example:
- * create.select(field("length({1})", Integer.class, fieldByName("TITLE")))
- * .from(tableByName("T_BOOK"))
- * .fetch();
+ * 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! One way to escape
+ * literals is to use {@link #name(String...)} and similar methods
*
- * // ... will execute this SQL on SQL Server:
- * select length([TITLE]) from [T_BOOK]
- *
- *
- * @param qualifiedName The various parts making up your field's reference
- * name.
- * @param type The type of the returned field
- * @return A field referenced by fieldName
+ * @param sql The SQL clause, containing {numbered placeholders} where query
+ * parts can be injected
+ * @param type The field type
+ * @param parts The {@link QueryPart} objects that are rendered at the
+ * {numbered placeholder} locations
+ * @return A field wrapping the plain SQL
*/
- @Support
- public static Field fieldByName(Class type, String... qualifiedName) {
- return fieldByName(getDataType(type), qualifiedName);
+ public static Field field(String sql, Class type, QueryPart... parts) {
+ return new SQLField(sql, getDataType(type), parts);
}
/**
- * Create a qualified field, given its (qualified) field name.
+ * A custom SQL clause that can render arbitrary SQL elements.
*
- * This constructs a field reference given the field's qualified name. jOOQ
- * will render the field name according to your
- * {@link Settings#getRenderNameStyle()} settings. Choose
- * {@link RenderNameStyle#QUOTED} to prevent syntax errors and/or SQL
- * injection.
+ * This is useful for constructing more complex SQL syntax elements wherever
+ * Field types are expected. An example for this is MySQL's
+ * GROUP_CONCAT aggregate function, which has MySQL-specific
+ * keywords that are hard to reflect in jOOQ's DSL:
+ * GROUP_CONCAT([DISTINCT] expr [,expr ...]
+ * [ORDER BY {unsigned_integer | col_name | expr}
+ * [ASC | DESC] [,col_name ...]]
+ * [SEPARATOR str_val])
+ *
*
- * Example:
- * // This field...
- * fieldByName("MY_SCHEMA", "MY_TABLE", "MY_FIELD");
- *
- * // ... will render this SQL on SQL Server with RenderNameStyle.QUOTED set
- * [MY_SCHEMA].[MY_TABLE].[MY_FIELD]
+ * The above MySQL function can be expressed as such:
+ * field("GROUP_CONCAT(DISTINCT {0} ORDER BY {1} ASC DEPARATOR '-')", expr1, expr2);
*
*
- * Another example:
- * create.select(field("length({1})", Integer.class, fieldByName("TITLE")))
- * .from(tableByName("T_BOOK"))
- * .fetch();
+ * 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! One way to escape
+ * literals is to use {@link #name(String...)} and similar methods
*
- * // ... will execute this SQL on SQL Server:
- * select length([TITLE]) from [T_BOOK]
- *
- *
- * @param qualifiedName The various parts making up your field's reference
- * name.
- * @param type The type of the returned field
- * @return A field referenced by fieldName
+ * @param sql The SQL clause, containing {numbered placeholders} where query
+ * parts can be injected
+ * @param type The field type
+ * @param parts The {@link QueryPart} objects that are rendered at the
+ * {numbered placeholder} locations
+ * @return A field wrapping the plain SQL
*/
- @Support
- public static Field fieldByName(DataType type, String... qualifiedName) {
- return new QualifiedField(type, qualifiedName);
+ public static Field field(String sql, DataType type, QueryPart... parts) {
+ return new SQLField(sql, type, parts);
}
/**