C - the context typeI - the identifier typepublic class SqlColumnsHandler<C,I> extends Object implements ColumnsHandler<C,I>
ColumnsHandler for a SQL data source.| Constructor and Description |
|---|
SqlColumnsHandler(SqlColumnsHandlerConfig<C> config)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
int |
count(Predicate<C> predicate)
Returns the number of rows that match the provided predicate.
|
<D> boolean |
insert(D dependent,
DependentColumn<?,C,D>... columns)
Inserts the given values into a new row, as taken from the dependent object.
|
boolean |
insert(UpdateValues<C> updateValues)
Inserts the given values into a new row.
|
protected boolean |
performUpdateAction(PreparedStatement pst)
Wraps
PreparedStatement.executeUpdate() for UPDATE and INSERT statements and returns a boolean
based on its return value. |
DataSourceValues |
retrieve(I identifier,
Column<?,C>... columns)
Retrieves multiple values from a given row.
|
<T> DataSourceValue<T> |
retrieve(I identifier,
Column<T,C> column)
Retrieves the given column from a given row.
|
List<DataSourceValues> |
retrieve(Predicate<C> predicate,
Column<?,C>... columns)
Retrieves the given columns' values from all rows that satisfy the given predicate.
|
<T> List<T> |
retrieve(Predicate<C> predicate,
Column<T,C> column)
Retrieves a column's value for all rows that satisfy the given predicate.
|
<T> boolean |
update(I identifier,
Column<T,C> column,
T value)
Changes a column from a specific row to the given value.
|
<D> boolean |
update(I identifier,
D dependent,
DependentColumn<?,C,D>... columns)
Updates a row to have the values as retrieved from the dependent object.
|
boolean |
update(I identifier,
UpdateValues<C> updateValues)
Updates a row to have the given values.
|
<T> int |
update(Predicate<C> predicate,
Column<T,C> column,
T value)
Sets the given value to the provided column for all rows which match the predicate.
|
int |
update(Predicate<C> predicate,
UpdateValues<C> updateValues)
Updates all rows that match the given predicate with the provided values.
|
public SqlColumnsHandler(SqlColumnsHandlerConfig<C> config)
config - the SQL handler config to base the instance onpublic <T> DataSourceValue<T> retrieve(I identifier, Column<T,C> column) throws SQLException
ColumnsHandlerretrieve in interface ColumnsHandler<C,I>T - the column typeidentifier - the id of the row to look upcolumn - the column whose value should be retrievedSQLExceptionpublic DataSourceValues retrieve(I identifier, Column<?,C>... columns) throws SQLException
ColumnsHandlerretrieve in interface ColumnsHandler<C,I>identifier - the id of the row to look upcolumns - the columns to retrieveSQLExceptionpublic <T> List<T> retrieve(Predicate<C> predicate, Column<T,C> column) throws SQLException
ColumnsHandlerretrieve in interface ColumnsHandler<C,I>T - the column's value typepredicate - the predicate to fulfillcolumn - the column to retrieve from the matching rowsSQLExceptionpublic List<DataSourceValues> retrieve(Predicate<C> predicate, Column<?,C>... columns) throws SQLException
ColumnsHandlerretrieve in interface ColumnsHandler<C,I>predicate - the predicate to fulfillcolumns - the columns to retrieve from the matching rowsSQLExceptionpublic <T> boolean update(I identifier, Column<T,C> column, T value) throws SQLException
ColumnsHandlerupdate in interface ColumnsHandler<C,I>T - the column typeidentifier - the id of the row to modifycolumn - the column to modifyvalue - the value to set the column toSQLExceptionpublic boolean update(I identifier, UpdateValues<C> updateValues) throws SQLException
ColumnsHandlerupdate in interface ColumnsHandler<C,I>identifier - the id of the row to modifyupdateValues - the values to set on the rowSQLExceptionpublic <D> boolean update(I identifier, D dependent, DependentColumn<?,C,D>... columns) throws SQLException
ColumnsHandlerupdate in interface ColumnsHandler<C,I>D - the dependent typeidentifier - the id of the row to modifydependent - the dependent to get values fromcolumns - the columns to update in the rowSQLExceptionpublic <T> int update(Predicate<C> predicate, Column<T,C> column, T value) throws SQLException
ColumnsHandlerupdate in interface ColumnsHandler<C,I>T - the column typepredicate - the predicate to filter rows bycolumn - the column to modify on the matched rowsvalue - the new value to setSQLExceptionpublic int update(Predicate<C> predicate, UpdateValues<C> updateValues) throws SQLException
ColumnsHandlerupdate in interface ColumnsHandler<C,I>predicate - the predicate to filter rows byupdateValues - the values to set on the matched rowsSQLExceptionpublic boolean insert(UpdateValues<C> updateValues) throws SQLException
ColumnsHandlerinsert in interface ColumnsHandler<C,I>updateValues - the values to insertSQLExceptionpublic <D> boolean insert(D dependent,
DependentColumn<?,C,D>... columns)
throws SQLException
ColumnsHandlerinsert in interface ColumnsHandler<C,I>D - the dependent typedependent - the dependent to get values fromcolumns - the columns to insertSQLExceptionpublic int count(Predicate<C> predicate) throws SQLException
ColumnsHandlercount in interface ColumnsHandler<C,I>predicate - the predicate to test the rows forSQLExceptionprotected boolean performUpdateAction(PreparedStatement pst) throws SQLException
PreparedStatement.executeUpdate() for UPDATE and INSERT statements and returns a boolean
based on its return value.pst - the prepared statementIllegalStateException - if more than one row was updated (should never happen)SQLException - on SQL errorsCopyright © 2017–2024. All rights reserved.