ENTITY
- The entity being persisted.ENTITYBUILDER
- The builder class of the entity.B
- The type of the concrete class extending this.public abstract class AbstractDaoBuilder<ENTITY,ENTITYBUILDER,B extends AbstractDaoBuilder<?,?,?>> extends AbstractKeylessDaoBuilder<ENTITY,ENTITYBUILDER,B> implements DaoDescriptor<ENTITY,ENTITYBUILDER>, SchemaDescriptor<ENTITY,ENTITYBUILDER>
childrenDescriptors, columnCollection, daoBuilderHelper
Constructor and Description |
---|
AbstractDaoBuilder(String tableName,
Supplier<ENTITYBUILDER> supplier,
Function<ENTITYBUILDER,ENTITY> buildFunction) |
Modifier and Type | Method and Description |
---|---|
Dao<ENTITY> |
buildDao(Connection connection) |
Queries |
buildQueries() |
List<ChildrenDescriptor<ENTITY,?,ENTITYBUILDER,?>> |
childrenDescriptors()
The definitions of any entities that are owned by type
ENTITY |
ChildSelectStrategy |
childSelectStrategy() |
B |
notNull()
Sets the most recent column added to this DaoBuilder to prevent it allowing
nulls on inserts or updates.
|
ParentColumn<ENTITY,?,ENTITYBUILDER,?> |
parentColumn()
The parent column, if there is one, of the
ENTITY . |
B |
setSqlTypeName(String sqlTypeName)
Set the SQL type for the most recently added column.
|
List<List<String>> |
uniquenessConstraints()
A list of column name lists, each of which should be unique.
|
<CHILD,CHILDBUILDER> |
withChildren(Function<ENTITY,List<CHILD>> getter,
BiConsumer<ENTITYBUILDER,List<CHILD>> setter,
DaoDescriptor<CHILD,CHILDBUILDER> childDaoDescriptor)
Describes a relationship between the object
ENTITY and its several
child objects of type U . |
B |
withChildSelectStrategy(ChildSelectStrategy childSelectStrategy)
Set the method used for selecting for child elements of the entity.
|
B |
withParentColumn(String columnName)
Indicator that the column is a reference to an owning parent object.
|
<P> B |
withParentColumn(String columnName,
Function<ENTITY,P> getter,
BiConsumer<ENTITYBUILDER,P> setter)
Indicator that the column is a reference to an owning parent object.
|
B |
withUniqueConstraint(String... columnNames)
Describe a unique constraint on this entity.
|
buildFunction, getColumnCollection, supplier, tableName, withBigDecimalColumn, withBooleanColumn, withConvertedGenericColumn, withConvertingStringColumn, withGenericColumn, withInstantColumn, withIntegerBooleanColumn, withJoinColumn, withLongColumn, withStringBooleanColumn, withStringColumn
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
hasParent, parentColumnName, primaryKey, validateConsistencyOfJoinedSelectStrategies
allColumns, buildFunction, dataColumns, getColumnCollection, joinColumns, joinedSelectStrategies, nonJoinColumns, select, supplier, tableName
public AbstractDaoBuilder(String tableName, Supplier<ENTITYBUILDER> supplier, Function<ENTITYBUILDER,ENTITY> buildFunction)
public Dao<ENTITY> buildDao(Connection connection)
public <CHILD,CHILDBUILDER> B withChildren(Function<ENTITY,List<CHILD>> getter, BiConsumer<ENTITYBUILDER,List<CHILD>> setter, DaoDescriptor<CHILD,CHILDBUILDER> childDaoDescriptor)
ENTITY
and its several
child objects of type U
.
When hrorm inserts or updates objects with children it will attempt to
create, update, or delete child elements as necessary.
The above should be emphasized. For the purposes of persistence, Hrorm
treats child objects (and grandchild and further generations of objects
transitively) as wholly owned by the parent object. On an update or
delete of the parent, the child objects will be updated or deleted as
necessary. Imagine a schema with a recipe entity and an ingredient
entity. The ingredient entities are children of various recipes. If
the recipe for bechamel is deleted, it makes no sense to have an
orphaned ingredient entry for one cup of butter. It will therefore be
deleted.CHILD
- The type of the child data elements.CHILDBUILDER
- The type of the builder of child data elementsgetter
- The function on ENTITY
that returns the children.setter
- The function on ENTITY
that consumes the children.childDaoDescriptor
- The description of how the mapping for the subordinate elements
are persisted. Both Dao
and DaoBuilder
objects implement the DaoDescriptor
interface.public <P> B withParentColumn(String columnName, Function<ENTITY,P> getter, BiConsumer<ENTITYBUILDER,P> setter)
P
- The type of the parent object.columnName
- The name of the column that holds the foreign key reference.getter
- The function to call for setting the parent onto the child.setter
- The function to call for getting the parent from the child.public B withParentColumn(String columnName)
columnName
- The name of the column that holds the foreign key reference.public B notNull()
notNull
in class AbstractKeylessDaoBuilder<ENTITY,ENTITYBUILDER,B extends AbstractDaoBuilder<?,?,?>>
public B setSqlTypeName(String sqlTypeName)
VARCHAR2(100)
" instead of just "TEXT
" you
can do so here. This make no difference to the queries that hrorm generates
or how results are parsed.setSqlTypeName
in class AbstractKeylessDaoBuilder<ENTITY,ENTITYBUILDER,B extends AbstractDaoBuilder<?,?,?>>
sqlTypeName
- The name of the column in SQL.public B withUniqueConstraint(String... columnNames)
Schema
.withUniqueConstraint
in class AbstractKeylessDaoBuilder<ENTITY,ENTITYBUILDER,B extends AbstractDaoBuilder<?,?,?>>
columnNames
- the names of the columns that are to be uniquepublic List<List<String>> uniquenessConstraints()
SchemaDescriptor
uniquenessConstraints
in interface SchemaDescriptor<ENTITY,ENTITYBUILDER>
public ChildSelectStrategy childSelectStrategy()
childSelectStrategy
in interface DaoDescriptor<ENTITY,ENTITYBUILDER>
public B withChildSelectStrategy(ChildSelectStrategy childSelectStrategy)
childSelectStrategy
- The strategy to use during selects.public List<ChildrenDescriptor<ENTITY,?,ENTITYBUILDER,?>> childrenDescriptors()
DaoDescriptor
ENTITY
childrenDescriptors
in interface DaoDescriptor<ENTITY,ENTITYBUILDER>
public ParentColumn<ENTITY,?,ENTITYBUILDER,?> parentColumn()
DaoDescriptor
ENTITY
.parentColumn
in interface DaoDescriptor<ENTITY,ENTITYBUILDER>
public Queries buildQueries()
buildQueries
in interface SchemaDescriptor<ENTITY,ENTITYBUILDER>
Copyright © 2019. All rights reserved.