Class NamedQuery

java.lang.Object
io.github.connellite.jdbc.NamedQuery

public final class NamedQuery extends Object
Fluent builder that collects named-parameter bindings and materializes a fully bound NamedPreparedStatement only at prepare(Connection).

Unlike NamedPreparedStatement, this type does not call JDBC prepareStatement in a constructor. Bindings are stored first; SQL is parsed, optionally expanded, and only then prepared. That makes it possible to expand collection parameters into multiple JDBC placeholders before the statement is created.

The builder exposes the same set* methods as NamedPreparedStatement plus setCollection(String, Collection) for IN (...) style bindings. Scalar values are bound with the same JDBC setter semantics as NamedPreparedStatement when prepare(Connection) is called.

Collection parameters expand each SQL occurrence into a comma-separated list of positional placeholders. For example, WHERE id IN (:ids) with three values becomes WHERE id IN (?,?,?). If the same collection parameter appears more than once, each occurrence is expanded independently.

Use resolve() to inspect JDBC-ready SQL and bind values without creating a PreparedStatement. By default colon-prefixed parameters (:name) are parsed with ColonPrefixSqlParser; a custom SqlParser can be supplied via of(String, SqlParser).

prepareCall(Connection) materializes a NamedCallableStatement instead. OUT parameters are declared with registerOutParameter(String, int) and do not accept an IN value. An INOUT parameter is both set and registered.

See Also: