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
Constructor and Description |
---|
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()
The mechanism for building a new entity instance.
|
ColumnCollection<ENTITY,BUILDER> |
getColumnCollection() |
IndirectKeylessDaoBuilder<ENTITY,BUILDER> |
notNull()
Sets the most recent column added to this DaoBuilder to prevent it allowing
nulls on inserts or updates.
|
IndirectKeylessDaoBuilder<ENTITY,BUILDER> |
setSqlTypeName(String sqlTypeName)
Set the SQL type for the most recently added column.
|
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.
|
<T,U> IndirectKeylessDaoBuilder<ENTITY,BUILDER> |
withConvertedGenericColumn(String columnName,
Function<ENTITY,U> getter,
BiConsumer<BUILDER,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> 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. |
<T> IndirectKeylessDaoBuilder<ENTITY,BUILDER> |
withGenericColumn(String columnName,
Function<ENTITY,T> getter,
BiConsumer<BUILDER,T> setter,
GenericColumn<T> genericColumn)
Describes a data element of type
T that can be stored in
a GenericColumn . |
IndirectKeylessDaoBuilder<ENTITY,BUILDER> |
withInstantColumn(String columnName,
Function<ENTITY,Instant> getter,
BiConsumer<BUILDER,Instant> setter)
Describes a data element that represents a time stamp.
|
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> |
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, dataColumns, joinColumns, nonJoinColumns, select
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 ColumnCollection<ENTITY,BUILDER> getColumnCollection()
getColumnCollection
in interface KeylessDaoDescriptor<ENTITY,BUILDER>
public Function<BUILDER,ENTITY> buildFunction()
KeylessDaoDescriptor
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> withInstantColumn(String columnName, Function<ENTITY,Instant> getter, BiConsumer<BUILDER,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 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 IndirectKeylessDaoBuilder<ENTITY,BUILDER> notNull()
public IndirectKeylessDaoBuilder<ENTITY,BUILDER> 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> IndirectKeylessDaoBuilder<ENTITY,BUILDER> withGenericColumn(String columnName, Function<ENTITY,T> getter, BiConsumer<BUILDER,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> IndirectKeylessDaoBuilder<ENTITY,BUILDER> withConvertedGenericColumn(String columnName, Function<ENTITY,U> getter, BiConsumer<BUILDER,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
.Copyright © 2019. All rights reserved.