ENTITY
- The type of the data to be persisted.public interface KeylessDao<ENTITY>
KeylessDao
supports some operations for inserting
and selecting records in a database. Because a KeylessDao
has no knowledge of a primary key, it cannot perform all the operations
a full Dao
can. In particular, it cannot update or delete records.
Moreover, a keyless entity cannot be used in most relations. In general,
a complete Dao
should be preferred whenever possible.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(T identity,
BiFunction<T,ENTITY,T> accumulator,
Where where)
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.
|
BigDecimal |
runBigDecimalFunction(SqlFunction function,
String columnName,
Where where)
Computes an aggregated BigDecimal value, based on the select criteria specified
and the given SqlFunction and column name.
|
Long |
runLongFunction(SqlFunction function,
String columnName,
Where where)
Computes an aggregated
Long value, based on the select criteria specified
and the given SqlFunction and column name. |
List<ENTITY> |
select()
Read all the records in the database of type ENTITY.
|
List<ENTITY> |
select(ENTITY template,
Order order,
String... columnNames)
Select multiple records from the database by some search criteria in the
required order.
|
List<ENTITY> |
select(ENTITY template,
String... columnNames)
Select multiple records from the database by some search criteria.
|
List<ENTITY> |
select(Order order)
Read all the records in the database of type ENTITY in the
required order.
|
List<ENTITY> |
select(Where where)
Run a select in the data store for entities matching the given where predicates.
|
List<ENTITY> |
select(Where where,
Order order)
Run a select in the data store for entities matching the given where predicates
returned in the order specified.
|
<T,U,V> List<Triplet<T,U,V>> |
selectDistinct(String firstColumnName,
String secondColumnName,
String thirdColumnName,
Where where)
Select unique value triplets from the database for a particular triplet of columns.
|
<T,U> List<Pair<T,U>> |
selectDistinct(String firstColumnName,
String secondColumnName,
Where where)
Select unique value pairs from the database for a particular pair of columns.
|
<T> List<T> |
selectDistinct(String columnName,
Where where)
Select unique values from the database for a particular column.
|
ENTITY |
selectOne(ENTITY template,
String... columnNames)
Select a single record from the database by some search criteria.
|
ENTITY |
selectOne(Where where)
Select a single record from the database by some search criteria.
|
List<ENTITY> select()
No laziness or caching is involved here. This simply tries to instantiate all the records it can based on the full table.
List<ENTITY> select(Where where)
where
- The predicates to drive selection.List<ENTITY> select(Order order)
No laziness or caching is involved here. This simply tries to instantiate all the records it can based on the full table.
order
- The ordering to useList<ENTITY> select(Where where, Order order)
where
- The predicates to drive selection.order
- The ordering to useList<ENTITY> select(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> select(ENTITY template, Order order, 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.order
- The ordering to usecolumnNames
- The names of the database columnsENTITY selectOne(Where where)
If multiple records are found that match the given criteria, an exception will be thrown.
If no records are found, null
will be returned.
where
- The predicates to drive selection.ENTITY selectOne(ENTITY template, String... columnNames)
If multiple records are found that match the passed item, an exception will be thrown.
If no records are found, null
will be returned.
template
- An instance of type ENTITY with populated values corresponding to the
column names to select by.columnNames
- The names of the database columns<T> T foldingSelect(T identity, BiFunction<T,ENTITY,T> accumulator, Where where)
T
- The type of the value to be computed.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.where
- Predicates to drive selection of resultsLong 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.Long atomicInsert(ENTITY item)
Dao
. The Dao
will either commit or rollback
the transaction and close the underlying Connection
when complete.item
- The instance to be inserted.Long runLongFunction(SqlFunction function, String columnName, Where where)
Long
value, based on the select criteria specified
and the given SqlFunction
and column name.
Will run SQL that looks like this:
select FUNCTION(COLUMN) from TABLE where ...
function
- The function to runcolumnName
- The column to apply the function towhere
- Predicates to drive selection of resultsBigDecimal runBigDecimalFunction(SqlFunction function, String columnName, Where where)
Will run SQL that looks like this:
select FUNCTION(COLUMN) from TABLE where ...
function
- The function to runcolumnName
- The column to apply the function towhere
- Predicates to drive selection of results<T> List<T> selectDistinct(String columnName, Where where)
The response will be of the type associated with the class being persisted, not the database type.
T
- The type that this column represents, on the ENTITY
,
not necessarily the type of the database column.columnName
- The column to search for unique values.where
- Filters on the search.<T,U> List<Pair<T,U>> selectDistinct(String firstColumnName, String secondColumnName, Where where)
The response will be of the types associated with the class being persisted, not the database type.
T
- The type that the first column represents, on the ENTITY
,
not necessarily the type of the database column.U
- The type that the second column represents, on the ENTITY
,
not necessarily the type of the database column.firstColumnName
- The column name for to search for T
values.secondColumnName
- The column name for to search for U
values.where
- Filters on the search.<T,U,V> List<Triplet<T,U,V>> selectDistinct(String firstColumnName, String secondColumnName, String thirdColumnName, Where where)
The response will be of the types associated with the class being persisted, not the database type.
T
- The type that the first column represents, on the ENTITY
,
not necessarily the type of the database column.U
- The type that the second column represents, on the ENTITY
,
not necessarily the type of the database column.V
- The type that the second column represents, on the ENTITY
,
not necessarily the type of the database column.firstColumnName
- The column name for to search for T
values.secondColumnName
- The column name for to search for U
values.thirdColumnName
- The column name for to search for V
values.where
- Filters on the search.Copyright © 2019. All rights reserved.