ENTITY
- The type of the data to be persisted.public interface KeylessDao<ENTITY>
KeylessDao
is an interface that allows basic, non-singular CRUD operations to be performed.
Using a KeylessDao
, you can insert, records individually, but select, update, and delete all are limited
to multi-row operations, as there is no Primary Key defined.Modifier and Type | Method and Description |
---|---|
Long |
atomicInsert(ENTITY item)
Insert a record into the database within a transaction that is
managed within the Dao.
|
<T> T |
foldingSelect(ENTITY template,
T identity,
BiFunction<T,ENTITY,T> accumulator,
String... columnNames)
Computes a result based on the entities found by a select statement
without realizing the entire list of found entities in memory.
|
Long |
insert(ENTITY item)
Insert a record into the database.
|
List<ENTITY> |
selectAll()
Read all the records in the database of type ENTITY.
|
ENTITY |
selectByColumns(ENTITY item,
String... columnNames)
Select a single record from the database by some search criteria.
|
List<ENTITY> |
selectManyByColumns(ENTITY template,
Map<String,Operator> columnNames)
Select multiple records from the database by some search criteria.
|
List<ENTITY> |
selectManyByColumns(ENTITY template,
String... columnNames)
Select multiple records from the database by some search criteria.
|
Long insert(ENTITY item)
Depending on how the Dao was constucted (whether from a regular
DaoBuilder
or an IndirectDaoBuilder
)
a particular instance of this class may or may not attempt
to mutate the state of the passed item by setting its primary
key.
item
- The instance to be inserted.List<ENTITY> selectAll()
No laziness or caching is involved here. This simply tries to instantiate all the records it can based on the full table.
List<ENTITY> selectManyByColumns(ENTITY template, String... columnNames)
The SQL generated will specify a select by the column names passed, where the values are equal to the values specified in the passed template object. All the values must match, as the where clause will be formed by joining the various column names with 'AND'.
template
- An instance of type ENTITY with populated values corresponding to the
column names to select by.columnNames
- The names of the database columnsList<ENTITY> selectManyByColumns(ENTITY template, Map<String,Operator> columnNames)
This method will perform a select on the database and return the results
found. The where clause will be generated to include tests of the column
names specified in the columnNames
parameter. Each entry in
that Map
should be accompanied by an Operation
specifying what comparison should be used, e.g. =, LIKE, >, etc.
template
- An instance of type ENTITY with populated values corresponding to the
column names to select by.columnNames
- The names of the database columns paired with the operation
that should be used to construct the SQL select statement.ENTITY selectByColumns(ENTITY item, String... columnNames)
item
- An instance of type ENTITY with populated values corresponding to the
column names to select by.columnNames
- The names of the database columnsLong atomicInsert(ENTITY item)
Connection
when complete.item
- The instance to be inserted.<T> T foldingSelect(ENTITY template, T identity, BiFunction<T,ENTITY,T> accumulator, String... columnNames)
T
- The type of the value to be computed.template
- An instance of type ENTITY with populated values corresponding to the
column names to select by.identity
- The identity element of the return type.accumulator
- A function that computes the desired value based on
the values seen thus far and the next instance
of the entity found in the result set.columnNames
- The names of the columns to include in the select where clause.Copyright © 2019. All rights reserved.