public abstract class AbstractBatchHandler<T> extends Object implements BatchHandler<T>
| Modifier and Type | Field and Description |
|---|---|
protected StatementBuilder<T> |
statementBuilder |
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractBatchHandler(JdbcConfiguration configuration) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
addObject(T object)
Adds an object to the BatchHandler.
|
void |
deleteObject(T object)
Deletes an object.
|
T |
findObject(T arg)
Retrieves an object, using the unique columns of the given object as argument.
|
void |
flush()
Flushes the BatchHandler by executing a potential remaining statement, and
closing the underlying statement object and the database connection.
|
protected String |
getAddObjectSql()
Use for testing purposes only.
|
abstract String |
getAutoIncrementColumn()
Returns the database auto-increment column name, null if none.
|
abstract List<String> |
getColumns()
Returns a list of columns for the table of this batch handler.
|
JdbcConfiguration |
getConfiguration()
Returns the current JdbcConfiguration.
|
abstract List<String> |
getIdentifierColumns()
Returns a list of primary key column names.
|
abstract List<Object> |
getIdentifierValues(T object)
Returns a list of values matching the unique columns for the given object.
|
protected List<Object> |
getObjectList(Object... items)
Returns a List of Object items.
|
protected List<String> |
getStringList(String... items)
Returns a List of String items.
|
abstract String |
getTableName()
Returns the database table name.
|
abstract List<String> |
getUniqueColumns()
Returns a list of unique column names.
|
abstract List<Object> |
getUniqueValues(T object)
Returns a list of values matching the unique columns for the given object.
|
abstract List<Object> |
getValues(T object)
Returns a list of values matching the columns for the given object.
|
BatchHandler<T> |
init()
Initializes the BatchHandler by acquiring a database connection, creating a
statement object and initializing a SQL statement.
|
abstract boolean |
isInclusiveUniqueColumns()
Indicates whether rows are unique across all unique columns (inclusive)
or unique for each individual unique column (exclusive).
|
abstract T |
mapRow(ResultSet resultSet)
Maps a ResultSet row to an object T.
|
boolean |
objectExists(T object)
Checks whether this object exists in the database or not.
|
void |
updateObject(T object)
Updates an object.
|
protected StatementBuilder<T> statementBuilder
protected AbstractBatchHandler(JdbcConfiguration configuration)
public final BatchHandler<T> init()
BatchHandlerinit in interface BatchHandler<T>public JdbcConfiguration getConfiguration()
BatchHandlergetConfiguration in interface BatchHandler<T>public final boolean addObject(T object)
BatchHandleraddObject in interface BatchHandler<T>object - the object to add.public final T findObject(T arg)
BatchHandlerfindObject in interface BatchHandler<T>arg - the argument object, identifier properties must be populated.public final void updateObject(T object)
BatchHandlerupdateObject in interface BatchHandler<T>object - the object to update.public final void deleteObject(T object)
BatchHandlerdeleteObject in interface BatchHandler<T>object - the object to delete.public final boolean objectExists(T object)
BatchHandlerobjectExists in interface BatchHandler<T>object - the object to check.public final void flush()
BatchHandlerflush in interface BatchHandler<T>protected List<String> getStringList(String... items)
items - the items.protected List<Object> getObjectList(Object... items)
items - the items.protected String getAddObjectSql()
public abstract String getTableName()
public abstract String getAutoIncrementColumn()
public abstract boolean isInclusiveUniqueColumns()
public abstract List<String> getIdentifierColumns()
public abstract List<Object> getIdentifierValues(T object)
object - the object.public abstract List<String> getUniqueColumns()
public abstract List<Object> getUniqueValues(T object)
object - the object.public abstract List<String> getColumns()
public abstract List<Object> getValues(T object)
object - the object.public abstract T mapRow(ResultSet resultSet) throws SQLException
resultSet - the result set.SQLException - if SQL operation failed.Copyright © 2016 UiO. All rights reserved.