diff --git a/jOOQ-website/src/main/resources/manual-2.5.xml b/jOOQ-website/src/main/resources/manual-2.5.xml index 3007f3df3b..90e99170f6 100644 --- a/jOOQ-website/src/main/resources/manual-2.5.xml +++ b/jOOQ-website/src/main/resources/manual-2.5.xml @@ -893,6 +893,34 @@ SelectFinalStep select = create.select().from(AUTHOR); // Add the JOIN clause on the internal QueryObject representation SelectQuery query = select.getQuery(); query.addJoin(BOOK, BOOK.AUTHOR_ID.equal(AUTHOR.ID));]]> + +

Mutability

+

+ Note, that for historic reasons, the DSL API mixes mutable and immutable behaviour with respect to the internal representation of the being constructed. While creating , (such as functions) assumes immutable behaviour, creating does not. In other words, the following can be said: +

+ + + +

+ Mutability may be removed in a future version of jOOQ. +

@@ -2899,12 +2927,135 @@ create.insertInto(AUTHOR, AUTHOR.ID, AUTHOR.FIRST_NAME, AUTHOR.LAST_NAME)
Conditional expressions - + +

Conditions and their use cases in the jOOQ API

+

+ Conditions or conditional expressions are widely used in SQL and in the jOOQ API. They can be used in +

+ + +

Boolean types in SQL

+

+ Before SQL:1999, boolean types did not really exist in SQL. They were modelled by 0 and 1 numeric/char values. With SQL:1999, true booleans were introduced and are now supported by most databases. In short, these are possible boolean values: +

+ +

+ It is important to know that SQL differs from many other languages in the way it interprets the NULL boolean value. Most importantly, the following facts are to be remembered: +

+ +

+ For simplified NULL handling, please refer to the section about the . +

+

+ Note that jOOQ does not model these values as actual compatible. +

+
Condition building - + +

How to create conditional expressions with jOOQ

+

+ With jOOQ, most are built from , calling various methods on them. For instance, to build a , you can write the following expression: +

+ + + + + + +

Create conditions from the Factory

+

+ There are a few types of conditions, that can be created statically from the . These are: +

+
    +
  • , that allow you to phrase your own SQL string
  • +
  • The , a standalone predicate that creates a conditional expression
  • +
  • Constant TRUE and FALSE conditional expressions
  • +
+ +

Connect conditions using boolean operators

+

+ Conditions can also be connected using as will be discussed in a subsequent chapter. +

+
+
+ +
+ AND, OR boolean operators + +

Connecting conditions using boolean operators

+

+ In SQL, as in most other languages, can be connected using the AND and OR binary operators, as well as the NOT unary operator, to form new conditional expressions. In jOOQ, this is modelled as such: +

+ + + + + + +

+ The above example shows that the number of parentheses in Java can quickly explode. Proper indentation may become crucial in making such code readable. In order to understand how jOOQ composes combined conditional expressions, let's assign component expressions first: +

+ + + +

+ Here are all boolean operators on the interface: +

+ +) // Combine conditions with AND. Convenience for adding an exists predicate to the right-hand side +andNot(Condition) // Combine conditions with AND. Convenience for adding an inverted condition to the right-hand side +andNotExists(Select) // Combine conditions with AND. Convenience for adding an inverted exists predicate to the right-hand side + +or(Condition) // Combine conditions with OR +or(String) // Combine conditions with OR. Convenience for adding plain SQL to the right-hand side +or(String, Object...) // Combine conditions with OR. Convenience for adding plain SQL to the right-hand side +or(String, QueryPart...) // Combine conditions with OR. Convenience for adding plain SQL to the right-hand side +orExists(Select) // Combine conditions with OR. Convenience for adding an exists predicate to the right-hand side +orNot(Condition) // Combine conditions with OR. Convenience for adding an inverted condition to the right-hand side +orNotExists(Select) // Combine conditions with OR. Convenience for adding an inverted exists predicate to the right-hand side + +not() // Invert a condition]]> +
@@ -2918,7 +3069,7 @@ create.insertInto(AUTHOR, AUTHOR.ID, AUTHOR.FIRST_NAME, AUTHOR.LAST_NAME)
- Distinct predicate + DISTINCT predicate
@@ -2929,8 +3080,73 @@ create.insertInto(AUTHOR, AUTHOR.ID, AUTHOR.FIRST_NAME, AUTHOR.LAST_NAME)
LIKE predicate - - + +

The LIKE predicate

+

+ LIKE predicates are popular for simple wildcard-enabled pattern matching. Supported wildcards in all SQL databases are: +

+
    +
  • _: (single-character wildcard)
  • +
  • %: (multi-character wildcard)
  • +
+

+ With jOOQ, the LIKE predicate can be created from any as such: +

+ + + + + + +

Escaping operands with the LIKE predicate

+

+ Often, your pattern may contain any of the wildcard characters "_" and "%", in case of which you may want to escape them. jOOQ does not automatically escape patterns in like() and notLike() methods. Instead, you can explicitly define an escape character as such: +

+ + + + + + +

+ In the above predicate expressions, the exclamation mark character is passed as the escape character to escape wildcard characters "!_" and "!%", as well as to escape the escape character itself: "!!" +

+

+ Please refer to your database manual for more details about escaping patterns with the LIKE predicate. +

+ +

jOOQ's convenience methods using the LIKE predicate

+

+ In addition to the above, jOOQ provides a few convenience methods for common operations performed on strings using the LIKE predicate. Typical operations are "contains predicates", "starts with predicates", "ends with predicates", etc. Here is the full convenience API wrapping LIKE predicates: +

+ + + + + + +

+ Note, that jOOQ escapes % and _ characters in value in some of the above predicate implementations. For simplicity, this has been omitted in this manual. +

+
@@ -2943,8 +3159,8 @@ create.insertInto(AUTHOR, AUTHOR.ID, AUTHOR.FIRST_NAME, AUTHOR.LAST_NAME)
-
- AND, OR boolean operators +
+ ARRAY predicates