Module io.helidon.dbclient.common
Package io.helidon.dbclient.common
Class AbstractStatement<S extends DbStatement<S,R>,R>
java.lang.Object
io.helidon.dbclient.common.AbstractStatement<S,R>
- Type Parameters:
S
- type of a subclassR
- the result type of the statement as returned byexecute()
- All Implemented Interfaces:
DbStatement<S,
R>
- Direct Known Subclasses:
MongoDbStatementDml
public abstract class AbstractStatement<S extends DbStatement<S,R>,R>
extends Object
implements DbStatement<S,R>
Common statement methods and fields.
-
Constructor Summary
ModifierConstructorDescriptionprotected
AbstractStatement
(DbStatementContext statementContext) Statement that handles parameters. -
Method Summary
Modifier and TypeMethodDescriptionAdd next parameter to the list of ordered parameters (e.g.Add next parameter to the map of named parameters (e.g.Context of the DB client.protected DbMapperManager
Db mapper manager.protected abstract String
dbType()
Type of this database to use in interceptor context.protected abstract R
doExecute
(Single<DbClientServiceContext> dbContext, CompletableFuture<Void> statementFuture, CompletableFuture<Long> queryFuture) Execute the statement against the database.execute()
Execute this statement using the parameters configured withparams
andaddParams
methods.indexedParam
(Object parameters) Configure parameters usingObject
instance with registered mapper.Get the indexed parameters of this statement.protected MapperManager
Mapper manager.protected S
me()
Returns this builder cast to the correct type.namedParam
(Object parameters) Configure parameters usingObject
instance with registered mapper.Get the named parameters of this statement.Configure parameters from aList
by order.Configure named parameters.protected ParamType
Type of parameters of this statement.protected String
Statement text.protected String
Statement name.protected DbStatementType
Type of this statement.protected void
update
(DbClientServiceContext dbContext) Update the client service context with the statement name, statement and statement parameters.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.helidon.dbclient.DbStatement
params
-
Constructor Details
-
AbstractStatement
Statement that handles parameters.- Parameters:
statementContext
- database statement configuration and context
-
-
Method Details
-
execute
Description copied from interface:DbStatement
Execute this statement using the parameters configured withparams
andaddParams
methods.- Specified by:
execute
in interfaceDbStatement<S extends DbStatement<S,
R>, R> - Returns:
- The result of this statement, never blocking.
-
statementType
Type of this statement.- Returns:
- statement type
-
doExecute
protected abstract R doExecute(Single<DbClientServiceContext> dbContext, CompletableFuture<Void> statementFuture, CompletableFuture<Long> queryFuture) Execute the statement against the database.- Parameters:
dbContext
- future that completes after all services are invokedstatementFuture
- future that should complete when the statement finishes executionqueryFuture
- future that should complete when the result set is fully read (if one exists), otherwise complete same as statementFuture- Returns:
- result of this db statement.
-
dbType
Type of this database to use in interceptor context.- Returns:
- type of this db
-
clientContext
Context of the DB client.- Returns:
- context with access to client wide configuration and runtime
-
params
Description copied from interface:DbStatement
Configure parameters from aList
by order. The statement must use indexed parameters and configure them by order in the provided array.- Specified by:
params
in interfaceDbStatement<S extends DbStatement<S,
R>, R> - Parameters:
parameters
- ordered parameters to set on this statement, never null- Returns:
- updated db statement
-
params
Description copied from interface:DbStatement
Configure named parameters. The statement must use named parameters and configure them from the provided map.- Specified by:
params
in interfaceDbStatement<S extends DbStatement<S,
R>, R> - Parameters:
parameters
- named parameters to set on this statement- Returns:
- updated db statement
-
namedParam
Description copied from interface:DbStatement
Configure parameters usingObject
instance with registered mapper. The statement must use named parameters and configure them from the map provided by mapper.- Specified by:
namedParam
in interfaceDbStatement<S extends DbStatement<S,
R>, R> - Parameters:
parameters
-Object
instance containing parameters- Returns:
- updated db statement
-
indexedParam
Description copied from interface:DbStatement
Configure parameters usingObject
instance with registered mapper. The statement must use indexed parameters and configure them by order in the array provided by mapper.- Specified by:
indexedParam
in interfaceDbStatement<S extends DbStatement<S,
R>, R> - Parameters:
parameters
-Object
instance containing parameters- Returns:
- updated db statement
-
addParam
Description copied from interface:DbStatement
Add next parameter to the list of ordered parameters (e.g. the ones that use?
in SQL).- Specified by:
addParam
in interfaceDbStatement<S extends DbStatement<S,
R>, R> - Parameters:
parameter
- next parameter to set on this statement- Returns:
- updated db statement
-
addParam
Description copied from interface:DbStatement
Add next parameter to the map of named parameters (e.g. the ones that use:name
in Helidon JDBC SQL integration).- Specified by:
addParam
in interfaceDbStatement<S extends DbStatement<S,
R>, R> - Parameters:
name
- name of parameterparameter
- value of parameter- Returns:
- updated db statement
-
paramType
Type of parameters of this statement.- Returns:
- indexed or named, or unknown in case it could not be yet defined
-
dbMapperManager
Db mapper manager.- Returns:
- mapper manager for DB types
-
mapperManager
Mapper manager.- Returns:
- generic mapper manager
-
namedParams
Get the named parameters of this statement.- Returns:
- name parameter map
- Throws:
IllegalStateException
- in case this statement is using indexed parameters
-
indexedParams
Get the indexed parameters of this statement.- Returns:
- parameter list
- Throws:
IllegalStateException
- in case this statement is using named parameters
-
statementName
Statement name.- Returns:
- name of this statement (never null, may be generated)
-
statement
Statement text.- Returns:
- text of this statement
-
update
Update the client service context with the statement name, statement and statement parameters.- Parameters:
dbContext
- client service context
-
me
Returns this builder cast to the correct type.- Returns:
- this as type extending this class
-