public interface BindParameterConverter
Connection.createStatement(String)
and bind operations(bind
and bindNull
).Modifier and Type | Interface and Description |
---|---|
static interface |
BindParameterConverter.BindOperation
Represent bind operation(
bind and bindNull ). |
Modifier and Type | Method and Description |
---|---|
static BindParameterConverter |
create()
Create default
BindParameterConverter . |
default void |
onBind(BindInfo info,
io.r2dbc.spi.Statement proxyStatement,
BindParameterConverter.BindOperation defaultBinding)
Callback method for bind operations(
bind and bindNull ) on Statement before actually performing those methods. |
default String |
onCreateStatement(String query,
StatementInfo info)
Convert the given query to another one at
Connection.createStatement(String) . |
static BindParameterConverter create()
BindParameterConverter
.default String onCreateStatement(String query, StatementInfo info)
Connection.createStatement(String)
.
This method will be called when Connection.createStatement(String)
is called(before actually
performing), and the returned query will be used as its input.
Additionally, in this method, any information can be stored in StatementInfo.getValueStore()
and they will be available at onBind(BindInfo, Statement, BindOperation)
.
Typical usage would be parsing the parameters in query and convert it to the parameter placeholder that target
database supports. In addition, construct a map that contains parameter indexes by the place holder to avoid parsing
query again at onBind(BindInfo, Statement, BindOperation)
.
For example, convert a query that uses colon prefix for named parameters: "INSERT INTO names (first_name) VALUES (:FIRST_NAME)" to "INSERT INTO names (first_name) VALUES (?)", and construct a map ":FIRST_NAME" = 0 (index).
query
- original queryinfo
- contextual information for Connection.createStatement(String)
.default void onBind(BindInfo info, io.r2dbc.spi.Statement proxyStatement, BindParameterConverter.BindOperation defaultBinding)
bind
and bindNull
) on Statement
before actually performing those methods.
Implementation of this method can modify the actual behavior.
When calling the defaultBinding.proceed()
performs the actual invocation of original bind operation, and returns proxy Statement
.
To skip actual invocation of the original bind operation, simply returns proxyStatement
.info
- contextual information for bind
and bindNull
.proxyStatement
- proxy Statement
.defaultBinding
- perform default bind operations and returns a result of proxy Statement
Copyright © 2025. All rights reserved.