From 8c511337a88024b8e56643fe5d004bf2f832aaf3 Mon Sep 17 00:00:00 2001 From: lukaseder Date: Mon, 19 Nov 2018 10:09:20 +0100 Subject: [PATCH] [#8048] CustomQueryPart manual section should explain how to implement accept() --- .../resources/org/jooq/web/manual-3.10.xml | 50 +++------------ .../resources/org/jooq/web/manual-3.11.xml | 59 +++--------------- .../resources/org/jooq/web/manual-3.12.xml | 46 ++------------ .../resources/org/jooq/web/manual-3.4.xml | 61 +++---------------- .../resources/org/jooq/web/manual-3.5.xml | 61 +++---------------- .../resources/org/jooq/web/manual-3.6.xml | 59 +++--------------- .../resources/org/jooq/web/manual-3.7.xml | 59 +++--------------- .../resources/org/jooq/web/manual-3.8.xml | 59 +++--------------- .../resources/org/jooq/web/manual-3.9.xml | 59 +++--------------- 9 files changed, 72 insertions(+), 441 deletions(-) diff --git a/jOOQ-manual/src/main/resources/org/jooq/web/manual-3.10.xml b/jOOQ-manual/src/main/resources/org/jooq/web/manual-3.10.xml index 60efe895e4..8e32da81d4 100644 --- a/jOOQ-manual/src/main/resources/org/jooq/web/manual-3.10.xml +++ b/jOOQ-manual/src/main/resources/org/jooq/web/manual-3.10.xml @@ -10472,55 +10472,21 @@ public abstract class CustomRecord> extends TableRecord These classes are declared public and covered by jOOQ's integration tests. When you extend these classes, you will have to provide your own implementations for the method, as discussed before:

- + ctx);]]>

- An example for implementing multiplication. + An example for implementing custom multiplication.

-

- The above contract may be a bit tricky to understand at first. The best thing is to check out jOOQ source code and have a look at a couple of QueryParts, to see how it's done. Here's an example showing how to create a field multiplying another field by 2 -

+ +

+ Here's an example showing how to create a field multiplying another field by 2 +

IDx2 = new CustomField(BOOK.ID.getName(), BOOK.ID.getDataType()) { @Override - public void toSQL(RenderContext context) { - - // In inline mode, render the multiplication directly - if (context.inline()) { - context.sql(BOOK.ID).sql(" * 2"); - } - - // In non-inline mode, render a bind value - else { - context.sql(BOOK.ID).sql(" * ?"); - } - } - - @Override - public void bind(BindContext context) { - try { - - // Manually bind the value 2 - context.statement().setInt(context.nextIndex(), 2); - - // Alternatively, you could also write: - // context.bind(DSL.val(2)); - } - catch (SQLException e) { - throw new DataAccessException("Bind error", e); - } + public void accept(Context context) { + context.visit(BOOK.ID).sql(" * ").visit(DSL.val(2)); } }; diff --git a/jOOQ-manual/src/main/resources/org/jooq/web/manual-3.11.xml b/jOOQ-manual/src/main/resources/org/jooq/web/manual-3.11.xml index 0e69c6f36f..4ca0165f45 100644 --- a/jOOQ-manual/src/main/resources/org/jooq/web/manual-3.11.xml +++ b/jOOQ-manual/src/main/resources/org/jooq/web/manual-3.11.xml @@ -10703,64 +10703,21 @@ public class PostgresJSONGsonBinding implements Binding { If a SQL clause is too complex to express with jOOQ, you can extend either one of the following types for use directly in a jOOQ query:

- extends AbstractField {} -public abstract class CustomCondition extends AbstractCondition {} -public abstract class CustomTable> extends TableImpl {} -public abstract class CustomRecord> extends TableRecordImpl {}]]> - -

- These classes are declared public and covered by jOOQ's integration tests. When you extend these classes, you will have to provide your own implementations for the method, as discussed before: -

- - + ctx);]]>

- An example for implementing multiplication. + An example for implementing custom multiplication.

-

- The above contract may be a bit tricky to understand at first. The best thing is to check out jOOQ source code and have a look at a couple of QueryParts, to see how it's done. Here's an example showing how to create a field multiplying another field by 2 -

+ +

+ Here's an example showing how to create a field multiplying another field by 2 +

IDx2 = new CustomField(BOOK.ID.getName(), BOOK.ID.getDataType()) { @Override - public void toSQL(RenderContext context) { - - // In inline mode, render the multiplication directly - if (context.inline()) { - context.sql(BOOK.ID).sql(" * 2"); - } - - // In non-inline mode, render a bind value - else { - context.sql(BOOK.ID).sql(" * ?"); - } - } - - @Override - public void bind(BindContext context) { - try { - - // Manually bind the value 2 - context.statement().setInt(context.nextIndex(), 2); - - // Alternatively, you could also write: - // context.bind(DSL.val(2)); - } - catch (SQLException e) { - throw new DataAccessException("Bind error", e); - } + public void accept(Context context) { + context.visit(BOOK.ID).sql(" * ").visit(DSL.val(2)); } }; diff --git a/jOOQ-manual/src/main/resources/org/jooq/web/manual-3.12.xml b/jOOQ-manual/src/main/resources/org/jooq/web/manual-3.12.xml index f073b45e27..a7b9929b7f 100644 --- a/jOOQ-manual/src/main/resources/org/jooq/web/manual-3.12.xml +++ b/jOOQ-manual/src/main/resources/org/jooq/web/manual-3.12.xml @@ -10839,55 +10839,21 @@ public abstract class CustomRecord> extends TableRecord These classes are declared public and covered by jOOQ's integration tests. When you extend these classes, you will have to provide your own implementations for the method, as discussed before:

- + ctx);]]>

- An example for implementing multiplication. + An example for implementing custom multiplication.

+

- The above contract may be a bit tricky to understand at first. The best thing is to check out jOOQ source code and have a look at a couple of QueryParts, to see how it's done. Here's an example showing how to create a field multiplying another field by 2 + Here's an example showing how to create a field multiplying another field by 2

IDx2 = new CustomField(BOOK.ID.getName(), BOOK.ID.getDataType()) { @Override - public void toSQL(RenderContext context) { - - // In inline mode, render the multiplication directly - if (context.inline()) { - context.sql(BOOK.ID).sql(" * 2"); - } - - // In non-inline mode, render a bind value - else { - context.sql(BOOK.ID).sql(" * ?"); - } - } - - @Override - public void bind(BindContext context) { - try { - - // Manually bind the value 2 - context.statement().setInt(context.nextIndex(), 2); - - // Alternatively, you could also write: - // context.bind(DSL.val(2)); - } - catch (SQLException e) { - throw new DataAccessException("Bind error", e); - } + public void accept(Context context) { + context.visit(BOOK.ID).sql(" * ").visit(DSL.val(2)); } }; diff --git a/jOOQ-manual/src/main/resources/org/jooq/web/manual-3.4.xml b/jOOQ-manual/src/main/resources/org/jooq/web/manual-3.4.xml index 9594a6f9e8..97dc6daa4c 100644 --- a/jOOQ-manual/src/main/resources/org/jooq/web/manual-3.4.xml +++ b/jOOQ-manual/src/main/resources/org/jooq/web/manual-3.4.xml @@ -8838,69 +8838,26 @@ public final void bind(BindContext context) throws DataAccessException { If a SQL clause is too complex to express with jOOQ, you can extend either one of the following types for use directly in a jOOQ query:

- extends AbstractField {} -public abstract class CustomCondition extends AbstractCondition {} -public abstract class CustomTable> extends TableImpl {} -public abstract class CustomRecord> extends TableRecordImpl {}]]> - -

- These classes are declared public and covered by jOOQ's integration tests. When you extend these classes, you will have to provide your own implementations for the method, as discussed before: -

- - + ctx);]]>

- An example for implementing multiplication. + An example for implementing custom multiplication.

-

- The above contract may be a bit tricky to understand at first. The best thing is to check out jOOQ source code and have a look at a couple of QueryParts, to see how it's done. Here's an example showing how to create a field multiplying another field by 2 -

+ +

+ Here's an example showing how to create a field multiplying another field by 2 +

IDx2 = new CustomField(BOOK.ID.getName(), BOOK.ID.getDataType()) { @Override - public void toSQL(RenderContext context) { - - // In inline mode, render the multiplication directly - if (context.inline()) { - context.sql(BOOK.ID).sql(" * 2"); - } - - // In non-inline mode, render a bind value - else { - context.sql(BOOK.ID).sql(" * ?"); - } - } - - @Override - public void bind(BindContext context) { - try { - - // Manually bind the value 2 - context.statement().setInt(context.nextIndex(), 2); - - // Alternatively, you could also write: - // context.bind(DSL.val(2)); - } - catch (SQLException e) { - throw new DataAccessException("Bind error", e); - } + public void accept(Context context) { + context.visit(BOOK.ID).sql(" * ").visit(DSL.val(2)); } }; // Use the above field in a SQL statement: -create.select(IDx2).from(BOOK).fetch();]]> +create.select(IDx2).from(BOOK);]]>

An example for implementing vendor-specific functions. diff --git a/jOOQ-manual/src/main/resources/org/jooq/web/manual-3.5.xml b/jOOQ-manual/src/main/resources/org/jooq/web/manual-3.5.xml index 9132021682..72e71a11cb 100644 --- a/jOOQ-manual/src/main/resources/org/jooq/web/manual-3.5.xml +++ b/jOOQ-manual/src/main/resources/org/jooq/web/manual-3.5.xml @@ -9235,69 +9235,26 @@ public final void bind(BindContext context) throws DataAccessException { If a SQL clause is too complex to express with jOOQ, you can extend either one of the following types for use directly in a jOOQ query:

- extends AbstractField {} -public abstract class CustomCondition extends AbstractCondition {} -public abstract class CustomTable> extends TableImpl {} -public abstract class CustomRecord> extends TableRecordImpl {}]]> - -

- These classes are declared public and covered by jOOQ's integration tests. When you extend these classes, you will have to provide your own implementations for the method, as discussed before: -

- - + ctx);]]>

- An example for implementing multiplication. + An example for implementing custom multiplication.

-

- The above contract may be a bit tricky to understand at first. The best thing is to check out jOOQ source code and have a look at a couple of QueryParts, to see how it's done. Here's an example showing how to create a field multiplying another field by 2 -

+ +

+ Here's an example showing how to create a field multiplying another field by 2 +

IDx2 = new CustomField(BOOK.ID.getName(), BOOK.ID.getDataType()) { @Override - public void toSQL(RenderContext context) { - - // In inline mode, render the multiplication directly - if (context.inline()) { - context.sql(BOOK.ID).sql(" * 2"); - } - - // In non-inline mode, render a bind value - else { - context.sql(BOOK.ID).sql(" * ?"); - } - } - - @Override - public void bind(BindContext context) { - try { - - // Manually bind the value 2 - context.statement().setInt(context.nextIndex(), 2); - - // Alternatively, you could also write: - // context.bind(DSL.val(2)); - } - catch (SQLException e) { - throw new DataAccessException("Bind error", e); - } + public void accept(Context context) { + context.visit(BOOK.ID).sql(" * ").visit(DSL.val(2)); } }; // Use the above field in a SQL statement: -create.select(IDx2).from(BOOK).fetch();]]> +create.select(IDx2).from(BOOK);]]>

An example for implementing vendor-specific functions. diff --git a/jOOQ-manual/src/main/resources/org/jooq/web/manual-3.6.xml b/jOOQ-manual/src/main/resources/org/jooq/web/manual-3.6.xml index c26be4485b..00886d87c7 100644 --- a/jOOQ-manual/src/main/resources/org/jooq/web/manual-3.6.xml +++ b/jOOQ-manual/src/main/resources/org/jooq/web/manual-3.6.xml @@ -9624,64 +9624,21 @@ public class PostgresJSONGsonBinding implements Binding { If a SQL clause is too complex to express with jOOQ, you can extend either one of the following types for use directly in a jOOQ query:

- extends AbstractField {} -public abstract class CustomCondition extends AbstractCondition {} -public abstract class CustomTable> extends TableImpl {} -public abstract class CustomRecord> extends TableRecordImpl {}]]> - -

- These classes are declared public and covered by jOOQ's integration tests. When you extend these classes, you will have to provide your own implementations for the method, as discussed before: -

- - + ctx);]]>

- An example for implementing multiplication. + An example for implementing custom multiplication.

-

- The above contract may be a bit tricky to understand at first. The best thing is to check out jOOQ source code and have a look at a couple of QueryParts, to see how it's done. Here's an example showing how to create a field multiplying another field by 2 -

+ +

+ Here's an example showing how to create a field multiplying another field by 2 +

IDx2 = new CustomField(BOOK.ID.getName(), BOOK.ID.getDataType()) { @Override - public void toSQL(RenderContext context) { - - // In inline mode, render the multiplication directly - if (context.inline()) { - context.sql(BOOK.ID).sql(" * 2"); - } - - // In non-inline mode, render a bind value - else { - context.sql(BOOK.ID).sql(" * ?"); - } - } - - @Override - public void bind(BindContext context) { - try { - - // Manually bind the value 2 - context.statement().setInt(context.nextIndex(), 2); - - // Alternatively, you could also write: - // context.bind(DSL.val(2)); - } - catch (SQLException e) { - throw new DataAccessException("Bind error", e); - } + public void accept(Context context) { + context.visit(BOOK.ID).sql(" * ").visit(DSL.val(2)); } }; diff --git a/jOOQ-manual/src/main/resources/org/jooq/web/manual-3.7.xml b/jOOQ-manual/src/main/resources/org/jooq/web/manual-3.7.xml index 4885a9c4bf..a12da5211e 100644 --- a/jOOQ-manual/src/main/resources/org/jooq/web/manual-3.7.xml +++ b/jOOQ-manual/src/main/resources/org/jooq/web/manual-3.7.xml @@ -9896,64 +9896,21 @@ public class PostgresJSONGsonBinding implements Binding { If a SQL clause is too complex to express with jOOQ, you can extend either one of the following types for use directly in a jOOQ query:

- extends AbstractField {} -public abstract class CustomCondition extends AbstractCondition {} -public abstract class CustomTable> extends TableImpl {} -public abstract class CustomRecord> extends TableRecordImpl {}]]> - -

- These classes are declared public and covered by jOOQ's integration tests. When you extend these classes, you will have to provide your own implementations for the method, as discussed before: -

- - + ctx);]]>

- An example for implementing multiplication. + An example for implementing custom multiplication.

-

- The above contract may be a bit tricky to understand at first. The best thing is to check out jOOQ source code and have a look at a couple of QueryParts, to see how it's done. Here's an example showing how to create a field multiplying another field by 2 -

+ +

+ Here's an example showing how to create a field multiplying another field by 2 +

IDx2 = new CustomField(BOOK.ID.getName(), BOOK.ID.getDataType()) { @Override - public void toSQL(RenderContext context) { - - // In inline mode, render the multiplication directly - if (context.inline()) { - context.sql(BOOK.ID).sql(" * 2"); - } - - // In non-inline mode, render a bind value - else { - context.sql(BOOK.ID).sql(" * ?"); - } - } - - @Override - public void bind(BindContext context) { - try { - - // Manually bind the value 2 - context.statement().setInt(context.nextIndex(), 2); - - // Alternatively, you could also write: - // context.bind(DSL.val(2)); - } - catch (SQLException e) { - throw new DataAccessException("Bind error", e); - } + public void accept(Context context) { + context.visit(BOOK.ID).sql(" * ").visit(DSL.val(2)); } }; diff --git a/jOOQ-manual/src/main/resources/org/jooq/web/manual-3.8.xml b/jOOQ-manual/src/main/resources/org/jooq/web/manual-3.8.xml index edf1bf259b..c94d45117c 100644 --- a/jOOQ-manual/src/main/resources/org/jooq/web/manual-3.8.xml +++ b/jOOQ-manual/src/main/resources/org/jooq/web/manual-3.8.xml @@ -10120,64 +10120,21 @@ public class PostgresJSONGsonBinding implements Binding { If a SQL clause is too complex to express with jOOQ, you can extend either one of the following types for use directly in a jOOQ query:

- extends AbstractField {} -public abstract class CustomCondition extends AbstractCondition {} -public abstract class CustomTable> extends TableImpl {} -public abstract class CustomRecord> extends TableRecordImpl {}]]> - -

- These classes are declared public and covered by jOOQ's integration tests. When you extend these classes, you will have to provide your own implementations for the method, as discussed before: -

- - + ctx);]]>

- An example for implementing multiplication. + An example for implementing custom multiplication.

-

- The above contract may be a bit tricky to understand at first. The best thing is to check out jOOQ source code and have a look at a couple of QueryParts, to see how it's done. Here's an example showing how to create a field multiplying another field by 2 -

+ +

+ Here's an example showing how to create a field multiplying another field by 2 +

IDx2 = new CustomField(BOOK.ID.getName(), BOOK.ID.getDataType()) { @Override - public void toSQL(RenderContext context) { - - // In inline mode, render the multiplication directly - if (context.inline()) { - context.sql(BOOK.ID).sql(" * 2"); - } - - // In non-inline mode, render a bind value - else { - context.sql(BOOK.ID).sql(" * ?"); - } - } - - @Override - public void bind(BindContext context) { - try { - - // Manually bind the value 2 - context.statement().setInt(context.nextIndex(), 2); - - // Alternatively, you could also write: - // context.bind(DSL.val(2)); - } - catch (SQLException e) { - throw new DataAccessException("Bind error", e); - } + public void accept(Context context) { + context.visit(BOOK.ID).sql(" * ").visit(DSL.val(2)); } }; diff --git a/jOOQ-manual/src/main/resources/org/jooq/web/manual-3.9.xml b/jOOQ-manual/src/main/resources/org/jooq/web/manual-3.9.xml index 49ee6062c5..4c08356922 100644 --- a/jOOQ-manual/src/main/resources/org/jooq/web/manual-3.9.xml +++ b/jOOQ-manual/src/main/resources/org/jooq/web/manual-3.9.xml @@ -10251,64 +10251,21 @@ public class PostgresJSONGsonBinding implements Binding { If a SQL clause is too complex to express with jOOQ, you can extend either one of the following types for use directly in a jOOQ query:

- extends AbstractField {} -public abstract class CustomCondition extends AbstractCondition {} -public abstract class CustomTable> extends TableImpl {} -public abstract class CustomRecord> extends TableRecordImpl {}]]> - -

- These classes are declared public and covered by jOOQ's integration tests. When you extend these classes, you will have to provide your own implementations for the method, as discussed before: -

- - + ctx);]]>

- An example for implementing multiplication. + An example for implementing custom multiplication.

-

- The above contract may be a bit tricky to understand at first. The best thing is to check out jOOQ source code and have a look at a couple of QueryParts, to see how it's done. Here's an example showing how to create a field multiplying another field by 2 -

+ +

+ Here's an example showing how to create a field multiplying another field by 2 +

IDx2 = new CustomField(BOOK.ID.getName(), BOOK.ID.getDataType()) { @Override - public void toSQL(RenderContext context) { - - // In inline mode, render the multiplication directly - if (context.inline()) { - context.sql(BOOK.ID).sql(" * 2"); - } - - // In non-inline mode, render a bind value - else { - context.sql(BOOK.ID).sql(" * ?"); - } - } - - @Override - public void bind(BindContext context) { - try { - - // Manually bind the value 2 - context.statement().setInt(context.nextIndex(), 2); - - // Alternatively, you could also write: - // context.bind(DSL.val(2)); - } - catch (SQLException e) { - throw new DataAccessException("Bind error", e); - } + public void accept(Context context) { + context.visit(BOOK.ID).sql(" * ").visit(DSL.val(2)); } };