public abstract class CustomQueryPart extends Object
QueryPart
implementations in client code.
Client code may provide proper Condition
implementations extending
this useful base class. All necessary parts of the Condition
interface are already implemented. Only this method needs further
implementation: accept(Context)
.
Refer to that methods' Javadoc for further details about their expected behaviour.
Such custom QueryPart
implementations can be useful in any of
these scenarios:
QueryPart
in other custom
QueryPart
s, e.g. in CustomCondition
, CustomField
, CustomTable
, etc.QueryPart
in plain SQL methods, such
as DSL.condition(String, QueryPart...)
,
DSL.field(String, QueryPart...)
,
DSL.table(String, QueryPart...)
Modifier | Constructor and Description |
---|---|
protected |
CustomQueryPart() |
Modifier and Type | Method and Description |
---|---|
abstract void |
accept(Context<?> ctx)
Subclasses must implement this method.
|
void |
bind(BindContext context)
Deprecated.
- 3.4.0 - [#2694] - Use
QueryPartInternal.accept(Context) instead. |
Clause[] |
clauses(Context<?> ctx)
The
Clause s that are represented by this query part. |
protected DSLContext |
create()
Internal convenience method
|
protected DSLContext |
create(Configuration configuration)
Internal convenience method
|
protected DSLContext |
create(Context<?> ctx)
Internal convenience method
|
boolean |
declaresCTE()
Subclasses may override this
|
boolean |
declaresFields()
Subclasses may override this
|
boolean |
declaresTables()
Subclasses may override this
|
boolean |
declaresWindows()
Subclasses may override this
|
boolean |
equals(Object that)
Check whether this
QueryPart can be considered equal to
another QueryPart . |
boolean |
generatesCast()
Subclasses may override this
|
int |
hashCode()
Generate a hash code from this
QueryPart . |
void |
toSQL(RenderContext context)
Deprecated.
- 3.4.0 - [#2694] - Use
QueryPartInternal.accept(Context) instead. |
String |
toString()
Render a SQL string of this
QueryPart
For improved debugging, this renders a SQL string of this
QueryPart with inlined bind variables. |
protected DataAccessException |
translate(String sql,
SQLException e)
Internal convenience method
|
public abstract void accept(Context<?> ctx)
public final Clause[] clauses(Context<?> ctx)
QueryPartInternal
Clause
s that are represented by this query part.
QueryPart
s can specify several Clause
s for which an
event will be emitted before
(in forward
order) and after
(in reverse order) visiting
the the query part through Context.visit(QueryPart)
This method is for JOOQ INTERNAL USE only. Do not reference directly
Clause
s represented by this query part or
null
or an empty array if this query part does not
represent a clause.public final boolean declaresFields()
declaresFields
in interface QueryPartInternal
public final boolean declaresTables()
declaresTables
in interface QueryPartInternal
@Deprecated public final void toSQL(RenderContext context)
QueryPartInternal.accept(Context)
instead.QueryPartInternal
QueryPart
to a SQL string contained in
context.sql()
. The context
will contain
additional information about how to render this QueryPart
,
e.g. whether this QueryPart
should be rendered as a
declaration or reference, whether this QueryPart
's contained
bind variables should be inlined or replaced by '?'
, etc.toSQL
in interface QueryPartInternal
@Deprecated public final void bind(BindContext context) throws DataAccessException
QueryPartInternal.accept(Context)
instead.QueryPartInternal
QueryPart
to a PreparedStatement
This method is for JOOQ INTERNAL USE only. Do not reference directly
bind
in interface QueryPartInternal
context
- The context holding the next bind index and other information
for variable bindingDataAccessException
- If something went wrong while binding a
variablepublic boolean declaresWindows()
declaresWindows
in interface QueryPartInternal
public boolean declaresCTE()
declaresCTE
in interface QueryPartInternal
public boolean generatesCast()
generatesCast
in interface QueryPartInternal
public boolean equals(Object that)
QueryPart
QueryPart
can be considered equal to
another QueryPart
.
In general, QueryPart
equality is defined in terms of
QueryPart.toString()
equality. In other words, two query parts are
considered equal if their rendered SQL (with inlined bind variables) is
equal. This means that the two query parts do not necessarily have to be
of the same type.
Some QueryPart
implementations may choose to override this
behaviour for improved performance, as QueryPart.toString()
is an
expensive operation, if called many times.
public int hashCode()
QueryPart
QueryPart
.
In general, QueryPart
hash codes are the same as the hash
codes generated from QueryPart.toString()
. This guarantees consistent
behaviour with QueryPart.equals(Object)
Some QueryPart
implementations may choose to override this
behaviour for improved performance, as QueryPart.toString()
is an
expensive operation, if called many times.
public String toString()
QueryPart
QueryPart
For improved debugging, this renders a SQL string of this
QueryPart
with inlined bind variables. If you wish to gain
more control over the concrete SQL rendering of this
QueryPart
, use DSLContext.renderContext()
to obtain a
configurable render context for SQL rendering.
protected final DSLContext create()
protected final DSLContext create(Configuration configuration)
protected final DSLContext create(Context<?> ctx)
protected final DataAccessException translate(String sql, SQLException e)
Copyright © 2016. All Rights Reserved.