ENTITY
- The entity being persisted.ENTITYBUILDER
- The builder class of the entity.B
- The type of the concrete class extending this.public abstract class AbstractKeylessDaoBuilder<ENTITY,ENTITYBUILDER,B extends AbstractKeylessDaoBuilder<?,?,?>> extends Object implements KeylessDaoDescriptor<ENTITY,ENTITYBUILDER>
Modifier and Type | Field and Description |
---|---|
protected List<ChildrenDescriptor<ENTITY,?,ENTITYBUILDER,?>> |
childrenDescriptors |
protected ColumnCollection<ENTITY,ENTITYBUILDER> |
columnCollection |
protected DaoBuilderHelper<ENTITY,ENTITYBUILDER> |
daoBuilderHelper |
Constructor and Description |
---|
AbstractKeylessDaoBuilder(String tableName,
Supplier<ENTITYBUILDER> supplier,
Function<ENTITYBUILDER,ENTITY> buildFunction) |
Modifier and Type | Method and Description |
---|---|
Function<ENTITYBUILDER,ENTITY> |
buildFunction()
The mechanism for building a new entity instance.
|
ColumnCollection<ENTITY,ENTITYBUILDER> |
getColumnCollection() |
B |
notNull()
Sets the most recent column added to this DaoBuilder to prevent it allowing
nulls on inserts or updates.
|
B |
setSqlTypeName(String sqlTypeName)
Set the SQL type for the most recently added column.
|
Supplier<ENTITYBUILDER> |
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 |
B |
withBigDecimalColumn(String columnName,
Function<ENTITY,BigDecimal> getter,
BiConsumer<ENTITYBUILDER,BigDecimal> setter)
Describes a numeric data element with a decimal part.
|
B |
withBooleanColumn(String columnName,
Function<ENTITY,Boolean> getter,
BiConsumer<ENTITYBUILDER,Boolean> setter)
Describes a data element that represents a true/false value that is
backed by a SQL boolean column.
|
<T,U> B |
withConvertedGenericColumn(String columnName,
Function<ENTITY,U> getter,
BiConsumer<ENTITYBUILDER,U> setter,
GenericColumn<T> genericColumn,
Converter<U,T> converter)
Describes a data element of type
U that can be stored in
a GenericColumn that stores objects of type T . |
<E> B |
withConvertingStringColumn(String columnName,
Function<ENTITY,E> getter,
BiConsumer<ENTITYBUILDER,E> setter,
Converter<E,String> converter)
Describes a data element with a particular type (like an enumeration) that
is persisted using a
String representation. |
<T> B |
withGenericColumn(String columnName,
Function<ENTITY,T> getter,
BiConsumer<ENTITYBUILDER,T> setter,
GenericColumn<T> genericColumn)
Describes a data element of type
T that can be stored in
a GenericColumn . |
B |
withInstantColumn(String columnName,
Function<ENTITY,Instant> getter,
BiConsumer<ENTITYBUILDER,Instant> setter)
Describes a data element that represents a time stamp.
|
B |
withIntegerBooleanColumn(String columnName,
Function<ENTITY,Boolean> getter,
BiConsumer<ENTITYBUILDER,Boolean> setter)
Describes a data element that represents a true/false value
and is backed by a column holding an integer value.
|
<U> B |
withJoinColumn(String columnName,
Function<ENTITY,U> getter,
BiConsumer<ENTITYBUILDER,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. |
B |
withLongColumn(String columnName,
Function<ENTITY,Long> getter,
BiConsumer<ENTITYBUILDER,Long> setter)
Describes a numeric data element with no decimal or fractional part.
|
B |
withStringBooleanColumn(String columnName,
Function<ENTITY,Boolean> getter,
BiConsumer<ENTITYBUILDER,Boolean> setter)
Describes a data element that represents a true/false value
and is backed by a column holding a String value.
|
B |
withStringColumn(String columnName,
Function<ENTITY,String> getter,
BiConsumer<ENTITYBUILDER,String> setter) |
B |
withUniqueConstraint(String... columnNames)
Describe a unique constraint on this entity.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
allColumns, dataColumns, joinColumns, joinedSelectStrategies, nonJoinColumns, select
protected final ColumnCollection<ENTITY,ENTITYBUILDER> columnCollection
protected final DaoBuilderHelper<ENTITY,ENTITYBUILDER> daoBuilderHelper
protected final List<ChildrenDescriptor<ENTITY,?,ENTITYBUILDER,?>> childrenDescriptors
public AbstractKeylessDaoBuilder(String tableName, Supplier<ENTITYBUILDER> supplier, Function<ENTITYBUILDER,ENTITY> buildFunction)
public String tableName()
KeylessDaoDescriptor
ENTITY
tableName
in interface KeylessDaoDescriptor<ENTITY,ENTITYBUILDER>
public Supplier<ENTITYBUILDER> supplier()
KeylessDaoDescriptor
ENTITY
,
generally a no-argument constructor of the class.supplier
in interface KeylessDaoDescriptor<ENTITY,ENTITYBUILDER>
public ColumnCollection<ENTITY,ENTITYBUILDER> getColumnCollection()
getColumnCollection
in interface KeylessDaoDescriptor<ENTITY,ENTITYBUILDER>
public Function<ENTITYBUILDER,ENTITY> buildFunction()
KeylessDaoDescriptor
buildFunction
in interface KeylessDaoDescriptor<ENTITY,ENTITYBUILDER>
public B withStringColumn(String columnName, Function<ENTITY,String> getter, BiConsumer<ENTITYBUILDER,String> setter)
public B withLongColumn(String columnName, Function<ENTITY,Long> getter, BiConsumer<ENTITYBUILDER,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 B withBigDecimalColumn(String columnName, Function<ENTITY,BigDecimal> getter, BiConsumer<ENTITYBUILDER,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> B withConvertingStringColumn(String columnName, Function<ENTITY,E> getter, BiConsumer<ENTITYBUILDER,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 B withInstantColumn(String columnName, Function<ENTITY,Instant> getter, BiConsumer<ENTITYBUILDER,Instant> 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 B withBooleanColumn(String columnName, Function<ENTITY,Boolean> getter, BiConsumer<ENTITYBUILDER,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 B withStringBooleanColumn(String columnName, Function<ENTITY,Boolean> getter, BiConsumer<ENTITYBUILDER,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 B withIntegerBooleanColumn(String columnName, Function<ENTITY,Boolean> getter, BiConsumer<ENTITYBUILDER,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> B withJoinColumn(String columnName, Function<ENTITY,U> getter, BiConsumer<ENTITYBUILDER,U> setter, DaoDescriptor<U,?> daoDescriptor)
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 B notNull()
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.sqlTypeName
- The name of the column in SQL.public <T> B withGenericColumn(String columnName, Function<ENTITY,T> getter, BiConsumer<ENTITYBUILDER,T> setter, GenericColumn<T> genericColumn)
T
that can be stored in
a GenericColumn
.
This interface exists to allow clients to inject whatever column types they need into Hrorm.
T
- The type of the data element on the entity.columnName
- The name of the column in the table that holds the data element.getter
- The function to call to get the value from an object instance.setter
- The function to call to set the value onto an object instance.genericColumn
- The column that supports type T
.public <T,U> B withConvertedGenericColumn(String columnName, Function<ENTITY,U> getter, BiConsumer<ENTITYBUILDER,U> setter, GenericColumn<T> genericColumn, Converter<U,T> converter)
U
that can be stored in
a GenericColumn
that stores objects of type T
.
This interface exists to allow clients to inject whatever column types they need into Hrorm.
T
- The type of the data element that can be persisted.U
- The type of the data element as it exists on the entity object.columnName
- The name of the column in the table that holds the data element.getter
- The function to call to get the value from an object instance.setter
- The function to call to set the value onto an object instance.genericColumn
- The column that supports type T
.converter
- A converter that can translate between types T
and U
.public B withUniqueConstraint(String... columnNames)
Schema
.columnNames
- the names of the columns that are to be uniqueCopyright © 2019. All rights reserved.