T
- The item whose persistence is managed by this Dao
public class DaoImpl<T,P> extends Object implements Dao<T>, DaoDescriptor<T>
Dao
implementation.
There is no good reason to directly construct this class yourself.
Use a DaoBuilder
.
Constructor and Description |
---|
DaoImpl(Connection connection,
String tableName,
Supplier<T> supplier,
PrimaryKey<T> primaryKey,
List<TypedColumn<T>> dataColumns,
List<JoinColumn<T,?>> joinColumns,
List<ChildrenDescriptor<T,?>> childrenDescriptors,
ParentColumnI<T,P> parentColumn) |
Modifier and Type | Method and Description |
---|---|
void |
atomicDelete(T item)
Run a delete statement in the database.
|
long |
atomicInsert(T item)
Insert a record into the database within a transaction that is
managed within the Dao.
|
void |
atomicUpdate(T item)
Run an update statement to change the values in the database associated
with an existing record.
|
List<ChildrenDescriptor<T,?>> |
childrenDescriptors()
The definitions of any entities that are owned by type
T |
List<TypedColumn<T>> |
dataColumns()
The columns that contain the data that make up the object
|
void |
delete(T item)
Run a delete statement in the database.
|
String |
deleteSql(T item) |
long |
insert(T item)
Insert a record into the database.
|
List<JoinColumn<T,?>> |
joinColumns()
The columns that contain references to foreign keys to other objects
|
ParentColumnI<T,P> |
parentColumn() |
PrimaryKey<T> |
primaryKey()
The primary key for objects of type
T |
T |
select(long id)
Read a record from the database.
|
List<T> |
selectAll()
Read all the records in the database of type T.
|
T |
selectByColumns(T item,
String... columnNames)
Select a single record from the database by some search criteria.
|
List<T> |
selectMany(List<Long> ids)
Read several records from the database.
|
List<T> |
selectManyByColumns(T item,
String... columnNames)
Select multiple records from the database by some search criteria.
|
Supplier<T> |
supplier()
The mechanism to use to instantiate a new instance of type
T ,
generally a no-argument constructor of the class. |
String |
tableName()
The name of the table that is used to persist type
T |
void |
update(T 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<T> supplier, PrimaryKey<T> primaryKey, List<TypedColumn<T>> dataColumns, List<JoinColumn<T,?>> joinColumns, List<ChildrenDescriptor<T,?>> childrenDescriptors, ParentColumnI<T,P> parentColumn)
public String tableName()
DaoDescriptor
T
tableName
in interface DaoDescriptor<T>
public List<TypedColumn<T>> dataColumns()
DaoDescriptor
dataColumns
in interface DaoDescriptor<T>
public List<JoinColumn<T,?>> joinColumns()
DaoDescriptor
joinColumns
in interface DaoDescriptor<T>
public Supplier<T> supplier()
DaoDescriptor
T
,
generally a no-argument constructor of the class.supplier
in interface DaoDescriptor<T>
public PrimaryKey<T> primaryKey()
DaoDescriptor
T
primaryKey
in interface DaoDescriptor<T>
public List<ChildrenDescriptor<T,?>> childrenDescriptors()
DaoDescriptor
T
childrenDescriptors
in interface DaoDescriptor<T>
public ParentColumnI<T,P> parentColumn()
parentColumn
in interface DaoDescriptor<T>
public long atomicInsert(T item)
Dao
Connection
when complete.atomicInsert
in interface Dao<T>
item
- The instance to be inserted.public void atomicUpdate(T item)
Dao
Connection
when complete.atomicUpdate
in interface Dao<T>
item
- An instance of the class with a populated primary key field
and updated field values.public void atomicDelete(T item)
Dao
Connection
when complete.atomicDelete
in interface Dao<T>
item
- An instance of type T with a populated primary key.public long insert(T item)
Dao
public void update(T item)
Dao
public void delete(T item)
Dao
public T select(long id)
Dao
public List<T> selectMany(List<Long> ids)
Dao
selectMany
in interface Dao<T>
ids
- The primary keys of the records desired.public List<T> selectAll()
Dao
public T selectByColumns(T item, String... columnNames)
Dao
selectByColumns
in interface Dao<T>
item
- An instance of type T with populated values corresponding to the
column names to select by.columnNames
- The names of the database columnspublic List<T> selectManyByColumns(T item, String... columnNames)
Dao
selectManyByColumns
in interface Dao<T>
item
- An instance of type T with populated values corresponding to the
column names to select by.columnNames
- The names of the database columnsCopyright © 2018. All rights reserved.