Package com.d3x.core.db
Class DatabaseOperation<T>
- java.lang.Object
-
- com.d3x.core.db.DatabaseOperation<T>
-
- Type Parameters:
T- the type for this operation
- Direct Known Subclasses:
DatabaseExecute
public abstract class DatabaseOperation<T> extends java.lang.ObjectA convenience base class for build database operations- Author:
- Xavier Witdouck
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.List<java.lang.Object>argsThe list of arguments for operation, if anyprivate DatabasedbThe database this operation is associated withprivate com.d3x.core.util.Option<java.lang.Integer>fetchSizeThe result set fetch sizeprivate com.d3x.core.util.Option<java.lang.Integer>limitThe max number of rows to includeprivate com.d3x.core.util.Option<java.lang.String>sqlThe SQL expression for this operationprivate com.d3x.core.util.Option<java.time.Duration>timeoutThe SQL operation optional timeout
-
Constructor Summary
Constructors Constructor Description DatabaseOperation(Database db)Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Targs(java.lang.Object... args)Binds arguments to this operationTfetchSize(int fetchSize)Sets the statement fetch size for this operation(package private) java.util.List<java.lang.Object>getArgs()The list of arguments for operation, if any(package private) DatabasegetDb()The database this operation is associated with(package private) com.d3x.core.util.Option<java.lang.Integer>getFetchSize()The result set fetch size(package private) com.d3x.core.util.Option<java.lang.Integer>getLimit()The max number of rows to include(package private) com.d3x.core.util.Option<java.lang.String>getSql()The SQL expression for this operation(package private) com.d3x.core.util.Option<java.time.Duration>getTimeout()The SQL operation optional timeoutTlimit(int limit)Sets the max number of records to include in operationTsql(java.lang.String sql)Binds a custom SQL statement to this operationTtimeout(java.time.Duration timeout)Sets the timeout for this operation
-
-
-
Field Detail
-
db
private Database db
The database this operation is associated with
-
args
private java.util.List<java.lang.Object> args
The list of arguments for operation, if any
-
sql
private com.d3x.core.util.Option<java.lang.String> sql
The SQL expression for this operation
-
timeout
private com.d3x.core.util.Option<java.time.Duration> timeout
The SQL operation optional timeout
-
fetchSize
private com.d3x.core.util.Option<java.lang.Integer> fetchSize
The result set fetch size
-
limit
private com.d3x.core.util.Option<java.lang.Integer> limit
The max number of rows to include
-
-
Constructor Detail
-
DatabaseOperation
DatabaseOperation(Database db)
Constructor- Parameters:
db- the database reference
-
-
Method Detail
-
sql
public T sql(java.lang.String sql)
Binds a custom SQL statement to this operation- Parameters:
sql- the SQL statement or classpath resource to SQL statement- Returns:
- this operation
-
args
public T args(java.lang.Object... args)
Binds arguments to this operation- Parameters:
args- the arguments for SQL string- Returns:
- this operation
-
timeout
public T timeout(java.time.Duration timeout)
Sets the timeout for this operation- Parameters:
timeout- the timeout, can be null- Returns:
- this operation
-
fetchSize
public T fetchSize(int fetchSize)
Sets the statement fetch size for this operation- Parameters:
fetchSize- the fetch size- Returns:
- this operation
- See Also:
ResultSet.setFetchSize(int)
-
limit
public T limit(int limit)
Sets the max number of records to include in operation- Parameters:
limit- the max number of records, must be > 0- Returns:
- this operation
-
getDb
Database getDb()
The database this operation is associated with
-
getArgs
java.util.List<java.lang.Object> getArgs()
The list of arguments for operation, if any
-
getSql
com.d3x.core.util.Option<java.lang.String> getSql()
The SQL expression for this operation
-
getTimeout
com.d3x.core.util.Option<java.time.Duration> getTimeout()
The SQL operation optional timeout
-
getFetchSize
com.d3x.core.util.Option<java.lang.Integer> getFetchSize()
The result set fetch size
-
getLimit
com.d3x.core.util.Option<java.lang.Integer> getLimit()
The max number of rows to include
-
-