Package org.eclipse.net4j.db.dml
Interface SQLStatement
public interface SQLStatement
An immutable adapter-compiled statement definition. Each call to
prepare(IDBConnection, ReuseProbability)
obtains a statement from the connection's existing cache; the returned statement remains caller-owned and must
be released using the normal Net4j DB lifecycle. This definition retains neither connection nor statement.
Configured parameter setters are retained through their parameter identities for the lifetime of this definition.- Since:
- 4.15
- Author:
- Eike Stepper
- No Implement
- This interface is not intended to be implemented by clients.
- No Extend
- This interface is not intended to be extended by clients.
-
Method Summary
Modifier and TypeMethodDescriptionintbind(PreparedStatement stmt, Object... values) Binds a sequence of values starting at JDBC position 1.intbindAll(PreparedStatement stmt, Object... values) Binds the complete statement and requires exactlygetParameterCount()values.voidbindDefault(PreparedStatement stmt, int index, SQLDefaultSetter setter) Binds the implementation-defined default for one parameter occurrence at a one-based JDBC index.voidbindDefault(PreparedStatement stmt, SQLParameter parameter, SQLDefaultSetter setter) Binds the implementation-defined default at every occurrence of a logical parameter identity, in generated SQL order.binder(PreparedStatement stmt) Creates an independent sequential binding cursor starting at JDBC position 1.binderFrom(PreparedStatement stmt, int startIndex) Creates an independent sequential binding cursor at the specified JDBC position.intbindFrom(PreparedStatement stmt, int startIndex, Object... values) Binds a partial sequence from the specified one-based position and returns its value count.voidbindParameter(PreparedStatement stmt, int index, Object value) Binds one value at a one-based placeholder index.<JAVA,JDBC>
voidbindParameter(PreparedStatement stmt, int index, JAVA value, Function<JAVA, JDBC> converter) Binds one value after applying a call-specific converter, bypassing all parameter-configured strategies.<JAVA> voidbindParameter(PreparedStatement stmt, int index, JAVA value, SQLValueSetter<? super JAVA> setter) Binds one value with a caller-supplied JDBC binding strategy.voidbindParameter(PreparedStatement stmt, SQLParameter parameter, Object value) Binds a logical parameter identity at every occurrence in generated SQL order.<JAVA,JDBC>
voidbindParameter(PreparedStatement stmt, SQLParameter parameter, JAVA value, Function<JAVA, JDBC> converter) Binds every occurrence of an identity after applying a call-specific converter.<JAVA> voidbindParameter(PreparedStatement stmt, SQLParameter parameter, JAVA value, SQLValueSetter<? super JAVA> setter) Binds a logical parameter identity at every occurrence in generated SQL order using a specialized setter.getParameter(int index) Returns the logical parameter identity at a one-based JDBC placeholder position.intReturns the number of JDBC placeholder occurrences in the statement.Returns the logical parameter identities in JDBC placeholder order.getSQL()Returns the SQL text generated by compilation.prepare(IDBConnection connection, int resultSetType, int resultSetConcurrency, IDBPreparedStatement.ReuseProbability reuseProbability) Prepares this statement with the requested JDBC result-set shape through the existing Net4j DB statement cache.prepare(IDBConnection connection, IDBPreparedStatement.ReuseProbability reuseProbability) Prepares this statement through the existing Net4j DB statement cache and supplied reuse policy.
-
Method Details
-
getSQL
String getSQL()Returns the SQL text generated by compilation.- Returns:
- compiled SQL text
-
getParameterCount
int getParameterCount()Returns the number of JDBC placeholder occurrences in the statement.- Returns:
- the placeholder count
-
getParameter
Returns the logical parameter identity at a one-based JDBC placeholder position. Repeated uses of one identity return the sameSQLParameterinstance at each position.- Parameters:
index- the one-based JDBC parameter position- Returns:
- the logical parameter identity for that occurrence
- Throws:
IllegalArgumentException- if the index is outside the statement's parameter range- Since:
- 4.15
-
getParameters
List<SQLParameter> getParameters()Returns the logical parameter identities in JDBC placeholder order. The returned list is immutable, contains one entry per placeholder occurrence, and preserves the identity of repeated parameters. Statements without placeholders return an empty list.- Returns:
- immutable parameter occurrences in JDBC order
- Since:
- 4.15
-
prepare
IDBPreparedStatement prepare(IDBConnection connection, IDBPreparedStatement.ReuseProbability reuseProbability) throws SQLException Prepares this statement through the existing Net4j DB statement cache and supplied reuse policy. The caller owns the returned statement and must release it according to the connection's normal lifecycle.- Parameters:
connection- the connection to prepare onreuseProbability- the existing statement-cache reuse hint- Returns:
- a prepared statement from the connection
- Throws:
SQLException- if JDBC reports a preparation failure
-
prepare
IDBPreparedStatement prepare(IDBConnection connection, int resultSetType, int resultSetConcurrency, IDBPreparedStatement.ReuseProbability reuseProbability) throws SQLException Prepares this statement with the requested JDBC result-set shape through the existing Net4j DB statement cache. The caller owns the returned statement and must release it according to the connection's normal lifecycle.- Parameters:
connection- the connection to prepare onresultSetType- the JDBC result-set typeresultSetConcurrency- the JDBC result-set concurrencyreuseProbability- the existing statement-cache reuse hint- Returns:
- a prepared statement from the connection
- Throws:
SQLException- if JDBC reports a preparation failure- Since:
- 4.15
-
binder
Creates an independent sequential binding cursor starting at JDBC position 1. Cursor state belongs to the returned object and is not retained by this compiled definition.- Parameters:
stmt- the JDBC statement to bind- Returns:
- a new cursor
- Throws:
NullPointerException- ifstmtisnull- Since:
- 4.15
-
binderFrom
Creates an independent sequential binding cursor at the specified JDBC position. Positions from 1 through parameter count plus one are valid; the final position supports empty sequences only.- Parameters:
stmt- the JDBC statement to bindstartIndex- the one-based next position- Returns:
- a new cursor
- Throws:
IllegalArgumentException- ifstartIndexis outside the valid rangeNullPointerException- ifstmtisnull- Since:
- 4.15
-
bind
Binds a sequence of values starting at JDBC position 1. Partial prefixes are allowed and the returned count is the number of bound positions. A single null value must be passed as(Object)null; a null varargs array is invalid. Existing bindings at other positions are unaffected, and callers must account for stale values when reusing statements.- Parameters:
stmt- the JDBC statementvalues- values in placeholder order- Returns:
- the number of values bound
- Throws:
SQLException- if JDBC binding failsIllegalArgumentException- if the sequence exceeds the remaining parameter rangeNullPointerException- ifstmtorvaluesisnull- Since:
- 4.15
-
bindFrom
Binds a partial sequence from the specified one-based position and returns its value count. The valid starting positions are 1 through the parameter count plus one; the final position is useful only for an empty sequence. Structural range checks happen before JDBC is changed.- Parameters:
stmt- the JDBC statementstartIndex- the one-based first positionvalues- the values to bind in occurrence order- Returns:
- the number of values bound
- Throws:
SQLException- if JDBC binding failsIllegalArgumentException- if the position or range is invalidNullPointerException- if the statement or values array isnull- Since:
- 4.15
-
bindAll
Binds the complete statement and requires exactlygetParameterCount()values. Structural count validation happens before JDBC is changed. A successful empty statement binding returns zero.- Parameters:
stmt- the JDBC statementvalues- one value for each placeholder occurrence- Returns:
- the number of values bound
- Throws:
SQLException- if JDBC binding failsIllegalArgumentException- if the number of values differs from the parameter countNullPointerException- if the statement or values array isnull- Since:
- 4.15
-
bindParameter
Binds one value at a one-based placeholder index. A configured setter receives the original value; otherwise default binding applies a configured converter to non-null values and uses explicit JDBC type before inferred field type for NULL. A failed operation leaves existing bindings untouched except for effects already made by JDBC.- Parameters:
stmt- the JDBC statementindex- the one-based placeholder indexvalue- the application value- Throws:
SQLException- if JDBC binding failsIllegalArgumentException- ifindexis outside the compiled parameter rangeNullPointerException- ifstmtisnull- Since:
- 4.15
-
bindParameter
void bindParameter(PreparedStatement stmt, SQLParameter parameter, Object value) throws SQLException Binds a logical parameter identity at every occurrence in generated SQL order. Matching uses object identity. Each occurrence keeps its own inferred field type; a failure at a later occurrence can leave earlier occurrences bound.- Parameters:
stmt- the JDBC statementparameter- the identity returned by a particularSQL.param()callvalue- the application value to bind at each occurrence- Throws:
SQLException- if JDBC binding failsIllegalArgumentException- if the parameter identity is absent from this statementNullPointerException- if a required argument isnull- Since:
- 4.15
-
bindDefault
Binds the implementation-defined default for one parameter occurrence at a one-based JDBC index. The setter performs the complete JDBC operation; configured parameter setters and converters are not consulted. This is distinct from binding a supplied value throughbindParameter(stmt, index, value), including a suppliednull. The default need not be SQLDEFAULTor SQL NULL. If the setter fails, any JDBC side effect it already performed is not rolled back.- Parameters:
stmt- the JDBC statementindex- the one-based placeholder indexsetter- the complete default-value binding operation- Throws:
SQLException- if the setter reports a binding failureIllegalArgumentException- ifindexis outside the compiled parameter rangeNullPointerException- ifstmtorsetterisnull- Since:
- 4.15
-
bindDefault
void bindDefault(PreparedStatement stmt, SQLParameter parameter, SQLDefaultSetter setter) throws SQLException Binds the implementation-defined default at every occurrence of a logical parameter identity, in generated SQL order. Matching uses object identity, and each call to the setter receives that occurrence's actual one-based JDBC index. The setter performs the complete JDBC operation; configured parameter setters and converters are not consulted. This is distinct from binding a supplied value throughbindParameter(stmt, parameter, value). The default need not be SQLDEFAULTor SQL NULL. If a later setter call fails, earlier JDBC effects are not rolled back.- Parameters:
stmt- the JDBC statementparameter- the logical parameter identitysetter- the complete default-value binding operation- Throws:
SQLException- if the setter reports a binding failureIllegalArgumentException- if the identity is absent from this statementNullPointerException- if a required argument isnull- Since:
- 4.15
-
bindParameter
<JAVA> void bindParameter(PreparedStatement stmt, int index, JAVA value, SQLValueSetter<? super JAVA> setter) throws SQLException Binds one value with a caller-supplied JDBC binding strategy. The setter replaces any strategy configured on the parameter, receives the original value includingnull, and owns the complete JDBC operation. This override does not modify the parameter or compiled statement.- Type Parameters:
JAVA- the application value type- Parameters:
stmt- the JDBC statementindex- the one-based placeholder indexvalue- the application valuesetter- the complete JDBC binding strategy- Throws:
SQLException- if JDBC binding failsIllegalArgumentException- ifindexis outside the compiled parameter rangeNullPointerException- if a required argument isnull- Since:
- 4.15
-
bindParameter
<JAVA> void bindParameter(PreparedStatement stmt, SQLParameter parameter, JAVA value, SQLValueSetter<? super JAVA> setter) throws SQLException Binds a logical parameter identity at every occurrence in generated SQL order using a specialized setter. The setter receives the original value once per occurrence, including null, and completely controls JDBC binding.- Type Parameters:
JAVA- the application value type- Parameters:
stmt- the JDBC statementparameter- the identity returned by a particularSQL.param()callvalue- the application value to bind at each occurrencesetter- the complete JDBC binding strategy- Throws:
SQLException- if JDBC binding failsIllegalArgumentException- if the parameter identity is absent from this statementNullPointerException- if a required argument isnull- Since:
- 4.15
-
bindParameter
<JAVA,JDBC> void bindParameter(PreparedStatement stmt, int index, JAVA value, Function<JAVA, JDBC> converter) throws SQLExceptionBinds one value after applying a call-specific converter, bypassing all parameter-configured strategies. A non-null input is converted before the usual JDBC binding. Null input bypasses conversion and uses the parameter's explicit or inferred JDBC NULL type.- Type Parameters:
JAVA- the application value typeJDBC- the converted value type- Parameters:
stmt- the JDBC statementindex- the one-based placeholder indexvalue- the original application valueconverter- the call-specific converter- Throws:
SQLException- if JDBC binding failsIllegalArgumentException- ifindexis outside the parameter rangeNullPointerException- if a required argument isnull- Since:
- 4.15
-
bindParameter
<JAVA,JDBC> void bindParameter(PreparedStatement stmt, SQLParameter parameter, JAVA value, Function<JAVA, JDBC> converter) throws SQLExceptionBinds every occurrence of an identity after applying a call-specific converter. The converter receives the original non-null application value once per occurrence; null bypasses conversion and follows the usual explicit or inferred JDBC NULL handling. The override does not change the parameter or compiled statement.- Type Parameters:
JAVA- the application value typeJDBC- the converted value type- Parameters:
stmt- the JDBC statementparameter- the logical parameter identityvalue- the original application valueconverter- the call-specific converter- Throws:
SQLException- if JDBC binding failsIllegalArgumentException- if the identity is absent from this statementNullPointerException- if a required argument isnull- Since:
- 4.15
-