ENTITY - The type whose persistence is managed by this Dao.PARENT - The type of the parent (if any) of type ENTITY.BUILDER - The type of object that can build an ENTITY instance.PARENTBUILDER - The type of the object that can build a PARENT instance.public class DaoImpl<ENTITY,PARENT,BUILDER,PARENTBUILDER> extends Object implements Dao<ENTITY>, DaoDescriptor<ENTITY,BUILDER>
Dao implementation.
There is no good reason to directly construct this class yourself.
Use a DaoBuilder or IndirectDaoBuilder.
| Constructor and Description |
|---|
DaoImpl(Connection connection,
DaoDescriptor<ENTITY,BUILDER> daoDescriptor) |
| Modifier and Type | Method and Description |
|---|---|
void |
atomicDelete(ENTITY item)
Run a delete statement in the database within a transaction.
|
long |
atomicInsert(ENTITY item)
Insert a record into the database within a transaction that is
managed within the Dao.
|
void |
atomicUpdate(ENTITY item)
Run an update statement to change the values in the database associated
with an existing record.
|
Function<BUILDER,ENTITY> |
buildFunction() |
List<ChildrenDescriptor<ENTITY,?,BUILDER,?>> |
childrenDescriptors()
The definitions of any entities that are owned by type
ENTITY |
List<Column<ENTITY,BUILDER>> |
dataColumns()
The columns that contain the data that make up the object
|
void |
delete(ENTITY item)
Run a delete statement in the database.
|
long |
insert(ENTITY item)
Insert a record into the database.
|
List<JoinColumn<ENTITY,?,BUILDER,?>> |
joinColumns()
The columns that contain references to foreign keys to other objects
|
ParentColumn<ENTITY,PARENT,BUILDER,PARENTBUILDER> |
parentColumn() |
PrimaryKey<ENTITY,BUILDER> |
primaryKey()
The primary key for objects of type
ENTITY |
ENTITY |
select(long id)
Read a record from the database by its primary key.
|
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> |
selectMany(List<Long> ids)
Read several records from the database by their primary keys.
|
List<ENTITY> |
selectManyByColumns(ENTITY item,
String... columnNames)
Select multiple records from the database by some search criteria.
|
Supplier<BUILDER> |
supplier()
The mechanism to use to instantiate a new instance of type
ENTITY,
generally a no-argument constructor of the class. |
String |
tableName()
The name of the table that is used to persist type
ENTITY |
void |
update(ENTITY item)
Run an update statement to change the values in the database associated
with an existing record.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitallColumns, columnMap, dataColumnsWithParent, hasParentpublic DaoImpl(Connection connection, DaoDescriptor<ENTITY,BUILDER> daoDescriptor)
public String tableName()
DaoDescriptorENTITYtableName in interface DaoDescriptor<ENTITY,BUILDER>public List<Column<ENTITY,BUILDER>> dataColumns()
DaoDescriptordataColumns in interface DaoDescriptor<ENTITY,BUILDER>public List<JoinColumn<ENTITY,?,BUILDER,?>> joinColumns()
DaoDescriptorjoinColumns in interface DaoDescriptor<ENTITY,BUILDER>public Supplier<BUILDER> supplier()
DaoDescriptorENTITY,
generally a no-argument constructor of the class.supplier in interface DaoDescriptor<ENTITY,BUILDER>public PrimaryKey<ENTITY,BUILDER> primaryKey()
DaoDescriptorENTITYprimaryKey in interface DaoDescriptor<ENTITY,BUILDER>public List<ChildrenDescriptor<ENTITY,?,BUILDER,?>> childrenDescriptors()
DaoDescriptorENTITYchildrenDescriptors in interface DaoDescriptor<ENTITY,BUILDER>public ParentColumn<ENTITY,PARENT,BUILDER,PARENTBUILDER> parentColumn()
parentColumn in interface DaoDescriptor<ENTITY,BUILDER>public Function<BUILDER,ENTITY> buildFunction()
buildFunction in interface DaoDescriptor<ENTITY,BUILDER>public long atomicInsert(ENTITY item)
DaoConnection
when complete.atomicInsert in interface Dao<ENTITY>item - The instance to be inserted.public void atomicUpdate(ENTITY item)
DaoConnection
when complete.atomicUpdate in interface Dao<ENTITY>item - An instance of the class with a populated primary key field
and updated field values.public void atomicDelete(ENTITY item)
DaoConnection
when complete.atomicDelete in interface Dao<ENTITY>item - An instance of type ENTITY with a populated primary key.public long insert(ENTITY item)
DaoDepending 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.
public void update(ENTITY item)
Daopublic void delete(ENTITY item)
Daopublic ENTITY select(long id)
Daopublic List<ENTITY> selectMany(List<Long> ids)
DaoselectMany in interface Dao<ENTITY>ids - The primary keys of the records desired.public List<ENTITY> selectAll()
DaoNo laziness or caching is involved here. This simply tries to instantiate all the records it can based on the full table.
public ENTITY selectByColumns(ENTITY item, String... columnNames)
DaoselectByColumns in interface Dao<ENTITY>item - An instance of type ENTITY with populated values corresponding to the
column names to select by.columnNames - The names of the database columnspublic List<ENTITY> selectManyByColumns(ENTITY item, String... columnNames)
DaoselectManyByColumns in interface Dao<ENTITY>item - An instance of type ENTITY with populated values corresponding to the
column names to select by.columnNames - The names of the database columnsCopyright © 2018. All rights reserved.