ENTITY
- The class that the KeylessDao
will support.BUILDER
- The class that builds the ENTITY
type.public class IndirectKeylessDaoBuilder<ENTITY,BUILDER> extends Object implements KeylessDaoDescriptor<ENTITY,BUILDER>
IndirectKeylessDaoBuilder
provides mechanisms for defining the relationship between
a Java type and the table that backs it.
Using this builder (as opposed to the DaoBuilder
or IndirectDaoBuilder
)
will allow support for entities that do not have primary keys, but that support comes at
a price. A KeylessDao
supports fewer methods than a standard Dao
and these entities cannot be joined to other objects or be children to other objects.
In general, the regular variants should be preferred
Modifier and Type | Field and Description |
---|---|
protected IndirectDaoBuilder<ENTITY,BUILDER> |
internalDaoBuilder |
Constructor and Description |
---|
IndirectKeylessDaoBuilder(org.hrorm.IndirectDaoBuilder.BuilderHolder<ENTITY,BUILDER> builderHolder) |
IndirectKeylessDaoBuilder(String table,
Supplier<BUILDER> supplier,
Function<BUILDER,ENTITY> buildFunction) |
Modifier and Type | Method and Description |
---|---|
KeylessDao<ENTITY> |
buildDao(Connection connection)
Creates a
Dao for performing CRUD operations of type ENTITY . |
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
|
List<JoinColumn<ENTITY,?,BUILDER,?>> |
joinColumns()
The columns that contain references to foreign keys to other objects
|
IndirectKeylessDaoBuilder<ENTITY,BUILDER> |
notNull()
Sets the most recent column added to this DaoBuilder to prevent it allowing
nulls on inserts or updates.
|
ParentColumn<ENTITY,?,BUILDER,?> |
parentColumn() |
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 |
IndirectKeylessDaoBuilder<ENTITY,BUILDER> |
withBigDecimalColumn(String columnName,
Function<ENTITY,BigDecimal> getter,
BiConsumer<BUILDER,BigDecimal> setter)
Describes a numeric data element with a decimal part.
|
IndirectKeylessDaoBuilder<ENTITY,BUILDER> |
withBooleanColumn(String columnName,
Function<ENTITY,Boolean> getter,
BiConsumer<BUILDER,Boolean> setter)
Describes a data element that represents a true/false value that is
backed by a SQL boolean column.
|
<U,UB> IndirectKeylessDaoBuilder<ENTITY,BUILDER> |
withChildren(Function<ENTITY,List<U>> getter,
BiConsumer<BUILDER,List<U>> setter,
DaoDescriptor<U,UB> daoDescriptor)
Describes a relationship between the object
ENTITY and its several
child objects of type U . |
<E> IndirectKeylessDaoBuilder<ENTITY,BUILDER> |
withConvertingStringColumn(String columnName,
Function<ENTITY,E> getter,
BiConsumer<BUILDER,E> setter,
Converter<E,String> converter)
Describes a data element with a particular type (like an enumeration) that
is persisted using a
String representation. |
IndirectKeylessDaoBuilder<ENTITY,BUILDER> |
withIntegerBooleanColumn(String columnName,
Function<ENTITY,Boolean> getter,
BiConsumer<BUILDER,Boolean> setter)
Describes a data element that represents a true/false value
and is backed by a column holding an integer value.
|
IndirectKeylessDaoBuilder<ENTITY,BUILDER> |
withIntegerColumn(String columnName,
Function<ENTITY,Long> getter,
BiConsumer<BUILDER,Long> setter)
Describes a numeric data element with no decimal or fractional part.
|
<U> IndirectKeylessDaoBuilder<ENTITY,BUILDER> |
withJoinColumn(String columnName,
Function<ENTITY,U> getter,
BiConsumer<BUILDER,U> setter,
DaoDescriptor<U,?> daoDescriptor)
Describes a data element that is represented by an
Object of some
other type U with its own table for persistence. |
IndirectKeylessDaoBuilder<ENTITY,BUILDER> |
withLocalDateTimeColumn(String columnName,
Function<ENTITY,LocalDateTime> getter,
BiConsumer<BUILDER,LocalDateTime> setter)
Describes a data element that represents a time stamp.
|
IndirectKeylessDaoBuilder<ENTITY,BUILDER> |
withParentColumn(String columnName)
Indicator that the column is a reference to an owning parent object.
|
<P> IndirectKeylessDaoBuilder<ENTITY,BUILDER> |
withParentColumn(String columnName,
Function<ENTITY,P> getter,
BiConsumer<BUILDER,P> setter)
Indicator that the column is a reference to an owning parent object.
|
IndirectKeylessDaoBuilder<ENTITY,BUILDER> |
withStringBooleanColumn(String columnName,
Function<ENTITY,Boolean> getter,
BiConsumer<BUILDER,Boolean> setter)
Describes a data element that represents a true/false value
and is backed by a column holding a String value.
|
IndirectKeylessDaoBuilder<ENTITY,BUILDER> |
withStringColumn(String columnName,
Function<ENTITY,String> getter,
BiConsumer<BUILDER,String> setter)
Describes a text or string data element.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
allColumns, dataColumnsWithParent, dataColumnsWithParent, hasParent, select
protected final IndirectDaoBuilder<ENTITY,BUILDER> internalDaoBuilder
public IndirectKeylessDaoBuilder(String table, Supplier<BUILDER> supplier, Function<BUILDER,ENTITY> buildFunction)
public String tableName()
KeylessDaoDescriptor
ENTITY
tableName
in interface KeylessDaoDescriptor<ENTITY,BUILDER>
public Supplier<BUILDER> supplier()
KeylessDaoDescriptor
ENTITY
,
generally a no-argument constructor of the class.supplier
in interface KeylessDaoDescriptor<ENTITY,BUILDER>
public List<Column<ENTITY,BUILDER>> dataColumns()
KeylessDaoDescriptor
dataColumns
in interface KeylessDaoDescriptor<ENTITY,BUILDER>
public List<ChildrenDescriptor<ENTITY,?,BUILDER,?>> childrenDescriptors()
KeylessDaoDescriptor
ENTITY
childrenDescriptors
in interface KeylessDaoDescriptor<ENTITY,BUILDER>
public ParentColumn<ENTITY,?,BUILDER,?> parentColumn()
parentColumn
in interface KeylessDaoDescriptor<ENTITY,BUILDER>
public List<JoinColumn<ENTITY,?,BUILDER,?>> joinColumns()
KeylessDaoDescriptor
joinColumns
in interface KeylessDaoDescriptor<ENTITY,BUILDER>
public Function<BUILDER,ENTITY> buildFunction()
buildFunction
in interface KeylessDaoDescriptor<ENTITY,BUILDER>
public KeylessDao<ENTITY> buildDao(Connection connection)
Dao
for performing CRUD operations of type ENTITY
.connection
- The SQL connection this Dao
will use
for its operations.Dao
.public IndirectKeylessDaoBuilder<ENTITY,BUILDER> withStringColumn(String columnName, Function<ENTITY,String> getter, BiConsumer<BUILDER,String> setter)
columnName
- The name of the column that holds the data element.getter
- The function on ENTITY
that returns the data element.setter
- The function on ENTITY
that consumes the data element.public IndirectKeylessDaoBuilder<ENTITY,BUILDER> withIntegerColumn(String columnName, Function<ENTITY,Long> getter, BiConsumer<BUILDER,Long> setter)
columnName
- The name of the column that holds the data element.getter
- The function on ENTITY
that returns the data element.setter
- The function on ENTITY
that consumes the data element.public IndirectKeylessDaoBuilder<ENTITY,BUILDER> withBigDecimalColumn(String columnName, Function<ENTITY,BigDecimal> getter, BiConsumer<BUILDER,BigDecimal> setter)
columnName
- The name of the column that holds the data element.getter
- The function on ENTITY
that returns the data element.setter
- The function on ENTITY
that consumes the data element.public <E> IndirectKeylessDaoBuilder<ENTITY,BUILDER> withConvertingStringColumn(String columnName, Function<ENTITY,E> getter, BiConsumer<BUILDER,E> setter, Converter<E,String> converter)
String
representation.E
- The type being converted for persistence.columnName
- The name of the column that holds the data element.getter
- The function on ENTITY
that returns the data element.setter
- The function on ENTITY
that consumes the data element.converter
- A mechanism for converting between a String
and
the type E
that the object contains.public IndirectKeylessDaoBuilder<ENTITY,BUILDER> withLocalDateTimeColumn(String columnName, Function<ENTITY,LocalDateTime> getter, BiConsumer<BUILDER,LocalDateTime> setter)
columnName
- The name of the column that holds the data element.getter
- The function on ENTITY
that returns the data element.setter
- The function on ENTITY
that consumes the data element.public IndirectKeylessDaoBuilder<ENTITY,BUILDER> withBooleanColumn(String columnName, Function<ENTITY,Boolean> getter, BiConsumer<BUILDER,Boolean> setter)
columnName
- The name of the column that holds the data element.getter
- The function on ENTITY
that returns the data element.setter
- The function on ENTITY
that consumes the data element.public IndirectKeylessDaoBuilder<ENTITY,BUILDER> withStringBooleanColumn(String columnName, Function<ENTITY,Boolean> getter, BiConsumer<BUILDER,Boolean> setter)
columnName
- The name of the column that holds the data element.getter
- The function on ENTITY
that returns the data element.setter
- The function on ENTITY
that consumes the data element.public IndirectKeylessDaoBuilder<ENTITY,BUILDER> withIntegerBooleanColumn(String columnName, Function<ENTITY,Boolean> getter, BiConsumer<BUILDER,Boolean> setter)
columnName
- The name of the column that holds the data element.getter
- The function on ENTITY
that returns the data element.setter
- The function on ENTITY
that consumes the data element.public <U> IndirectKeylessDaoBuilder<ENTITY,BUILDER> withJoinColumn(String columnName, Function<ENTITY,U> getter, BiConsumer<BUILDER,U> setter, DaoDescriptor<U,?> daoDescriptor)
Describes a data element that is represented by an Object
of some
other type U
with its own table for persistence.
Join columns describe entities that have their own independent existence and their persistence is a pre-requisite for the persistence of dependent objects.
Imagine a schema that describes cities and states. Every city entity should be assigned to exactly one state. If the city is modified or deleted, it has no repercusions to the state entity. The only thing that can happen is that the city is assigned to a new state.
U
- The type of the data element.columnName
- The name of the column with the foreign key to the other table.
This column must be an integer type and must reference the primary
key of the other table.getter
- The function on ENTITY
that returns the data element.setter
- The function on ENTITY
that consumes the data element.daoDescriptor
- The description of how the mapping for the subordinate element
is persisted. Both Dao
and DaoBuilder
objects implement the DaoDescriptor
interface.public <U,UB> IndirectKeylessDaoBuilder<ENTITY,BUILDER> withChildren(Function<ENTITY,List<U>> getter, BiConsumer<BUILDER,List<U>> setter, DaoDescriptor<U,UB> daoDescriptor)
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.
U
- The type of the child data elements.UB
- 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.daoDescriptor
- The description of how the mapping for the subordinate elements
are persisted. Both Dao
and DaoBuilder
objects implement the DaoDescriptor
interface.public <P> IndirectKeylessDaoBuilder<ENTITY,BUILDER> withParentColumn(String columnName, Function<ENTITY,P> getter, BiConsumer<BUILDER,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 IndirectKeylessDaoBuilder<ENTITY,BUILDER> withParentColumn(String columnName)
columnName
- The name of the column that holds the foreign key reference.public IndirectKeylessDaoBuilder<ENTITY,BUILDER> notNull()
Copyright © 2019. All rights reserved.