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,
String tableName,
Supplier<BUILDER> supplier,
PrimaryKey<ENTITY,BUILDER> primaryKey,
List<Column<ENTITY,BUILDER>> dataColumns,
List<JoinColumn<ENTITY,?,BUILDER,?>> joinColumns,
List<ChildrenDescriptor<ENTITY,?,BUILDER,?>> childrenDescriptors,
ParentColumn<ENTITY,PARENT,BUILDER,PARENTBUILDER> parentColumn,
Function<BUILDER,ENTITY> buildFunction) |
Modifier and Type | Method and Description |
---|---|
void |
atomicDelete(ENTITY item)
Run a delete statement in the database.
|
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.
|
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.
|
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, wait
allColumns, columnMap, dataColumnsWithParent, hasParent
public DaoImpl(Connection connection, String tableName, Supplier<BUILDER> supplier, PrimaryKey<ENTITY,BUILDER> primaryKey, List<Column<ENTITY,BUILDER>> dataColumns, List<JoinColumn<ENTITY,?,BUILDER,?>> joinColumns, List<ChildrenDescriptor<ENTITY,?,BUILDER,?>> childrenDescriptors, ParentColumn<ENTITY,PARENT,BUILDER,PARENTBUILDER> parentColumn, Function<BUILDER,ENTITY> buildFunction)
public String tableName()
DaoDescriptor
ENTITY
tableName
in interface DaoDescriptor<ENTITY,BUILDER>
public List<Column<ENTITY,BUILDER>> dataColumns()
DaoDescriptor
dataColumns
in interface DaoDescriptor<ENTITY,BUILDER>
public List<JoinColumn<ENTITY,?,BUILDER,?>> joinColumns()
DaoDescriptor
joinColumns
in interface DaoDescriptor<ENTITY,BUILDER>
public Supplier<BUILDER> supplier()
DaoDescriptor
ENTITY
,
generally a no-argument constructor of the class.supplier
in interface DaoDescriptor<ENTITY,BUILDER>
public PrimaryKey<ENTITY,BUILDER> primaryKey()
DaoDescriptor
ENTITY
primaryKey
in interface DaoDescriptor<ENTITY,BUILDER>
public List<ChildrenDescriptor<ENTITY,?,BUILDER,?>> childrenDescriptors()
DaoDescriptor
ENTITY
childrenDescriptors
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)
Dao
Connection
when complete.atomicInsert
in interface Dao<ENTITY>
item
- The instance to be inserted.public void atomicUpdate(ENTITY item)
Dao
Connection
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)
Dao
Connection
when complete.atomicDelete
in interface Dao<ENTITY>
item
- An instance of type ENTITY with a populated primary key.public long insert(ENTITY item)
Dao
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.
public void update(ENTITY item)
Dao
public void delete(ENTITY item)
Dao
public ENTITY select(long id)
Dao
public List<ENTITY> selectMany(List<Long> ids)
Dao
selectMany
in interface Dao<ENTITY>
ids
- The primary keys of the records desired.public List<ENTITY> selectAll()
Dao
public ENTITY selectByColumns(ENTITY item, String... columnNames)
Dao
selectByColumns
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)
Dao
selectManyByColumns
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.