Top Description Methods
org.jooq

public Interface AttachableQueryPart

extends Attachable, QueryPart
Known Direct Subinterfaces
org.jooq.Queries, org.jooq.Query
Known Direct Implementers
org.jooq.impl.AbstractAttachableQueryPart
Imports
java.sql.PreparedStatement, java.util.List, .Map, org.jooq.conf.ParamType, .Settings, .StatementType, org.jooq.impl.DSL, org.jetbrains.annotations.NotNull, .Nullable

A type that is both Attachable and a QueryPart.

In addition to being able to render SQL of possibly some unspecified dialect and with inlined bind values for debugging purposes via the QueryPart#toString() method, this type offers more fine-grained control over the SQL generation via ParamType, Configuration#dialect() and various Configuration#settings().

Author
Lukas Eder

Method Summary

Modifier and TypeMethod and Description
public @NotNull List<Object>
getBindValues()

Retrieve the bind values that will be bound by this Query.

public @Nullable Param<?>
getParam(String name)

Deprecated as a consequence of Param being deprecated.
Get a named parameter from the Query, provided its name.
public @NotNull Map<String, Param<?>>
getParams()

Get a Map of named parameters.

public @NotNull String
getSQL()

Retrieve the SQL code rendered by this Query.

public @NotNull String

Returns:

The generated SQL
getSQL
(ParamType
How to render parameters. This overrides values in Settings#getStatementType()
paramType
)

Retrieve the SQL code rendered by this Query.

Inherited from org.jooq.Attachable:
attachconfigurationdetach
Inherited from org.jooq.QueryPart:
equalshashCodetoString

Method Detail

getBindValuesback to summary
public @NotNull List<Object> getBindValues()

Retrieve the bind values that will be bound by this Query.

Unlike getParams(), which returns also inlined parameters, this returns only actual bind values that will render an actual bind value as a question mark "?"

Annotations
@NotNull
See Also
DSLContext#extractBindValues(QueryPart)
getParamback to summary
public @Nullable Param<?> getParam(String name)

Deprecated

as a consequence of Param being deprecated. See corresponding docs for further information.

Get a named parameter from the Query, provided its name.

Bind values created with DSL#val(Object) will have their bind index as name.

Annotations
@Nullable
See Also
Param, DSL#param(String, Object), DSLContext#extractParam(QueryPart, String)
getParamsback to summary
public @NotNull Map<String, Param<?>> getParams()

Get a Map of named parameters. The Map itself cannot be modified, but the Param elements allow for modifying bind values on an existing Query.

Bind values created with DSL#val(Object) will have their bind index as name.

Annotations
@NotNull
See Also
Param, DSL#param(String, Object), DSLContext#extractParams(QueryPart)
getSQLback to summary
public @NotNull String getSQL()

Retrieve the SQL code rendered by this Query.

Use this method, when you want to use jOOQ for object oriented query creation, but execute the query with some other technology, such as

  • JDBC
  • Spring Templates
  • JPA native queries
  • etc...

Note, this is the same as calling getSQL(ParamType). The parameter will depend on your DSLContext's Settings:

StatementType boolean parameter effect
StatementType#PREPARED_STATEMENT false (default) This will render bind variables to be used with a JDBC PreparedStatement. You can extract bind values from this Query using getBindValues()
StatementType#STATIC_STATEMENT true This will inline all bind variables in a statement to be used with a JDBC Statement

[#1520] Note that the query actually being executed might not contain any bind variables, in case the number of bind variables exceeds your SQL dialect's maximum number of supported bind variables. This is not reflected by this method, which will only use the Settings to decide whether to render bind values.

Annotations
@NotNull
See Also
getSQL(ParamType)
getSQLback to summary
public @NotNull String getSQL(ParamType paramType)

Retrieve the SQL code rendered by this Query.

[#1520] Note that the query actually being executed might not contain any bind variables, in case the number of bind variables exceeds your SQL dialect's maximum number of supported bind variables. This is not reflected by this method, which will only use paramType argument to decide whether to render bind values.

See getSQL() for more details.

Parameters
paramType:ParamType

How to render parameters. This overrides values in Settings#getStatementType()

Returns:@NotNull String

The generated SQL

Annotations
@NotNull