R
- row classpublic class RowTranslator<R> extends ColumnsTranslator<R>
ColumnTranslator
objects
are created for each column based upon annotations on row class.
If no Column
annotation exists for a field, then column name is same as field
name and StandardColumnTranslator
is used.
If any of the following are true, then field is assumed to be cascaded:
TypeTranslator
Constructor and Description |
---|
RowTranslator(Table<R> table,
Row rowAnnotation)
Constructs for a table.
|
Modifier and Type | Method and Description |
---|---|
RowField<R,?> |
createRowField(java.lang.reflect.Field field)
Creates a
RowField object with the appropriate field access (either getter/setter method
or direct access). |
java.util.List<java.lang.reflect.Field> |
getCascadeFieldList()
Gets list of fields that are to be cascaded.
|
protected java.lang.reflect.Field |
getDeclaredField(java.lang.Class<?> clazz,
java.lang.String fieldName)
Recursively searches for declared field in superclass(es) of clazz and then clazz parameter.
|
java.lang.reflect.Field |
getDeclaredField(java.lang.String fieldName)
Gets a declared field of
ColumnsTranslator.getRowClass() . |
java.lang.reflect.Field[] |
getDeclaredFields()
Gets all of the declared fields for
ColumnsTranslator.getRowClass() . |
protected void |
getDeclaredFields(java.lang.Class<?> clazz,
java.util.List<java.lang.reflect.Field[]> classHierarchyFields)
Recursively searches for declared fields in super class(es) of clazz and then clazz parameter.
|
FieldAccessType |
getFieldAccessType()
Gets the field access type to use for all fields in row if no access type has been specified
for
Column . |
ColumnTranslator<R> |
getIdentityColumnTranslator()
Column translator used to set the value of a row column that is the identity column
for row.
|
PrimaryKeyWhereTranslator<R> |
getPrimaryKeyWhereTranslator()
Gets primary key translator for use in where clause.
|
java.lang.String |
getUnusedColumnInsertNamesSql()
Gets names of unused columns for insert statement.
|
java.lang.String |
getUnusedColumnInsertValuesSql()
Gets values for unused columns for insert statement.
|
java.lang.String |
getUnusedColumnUpdateSql()
Gets column=value for all unused columns for update statement.
|
protected void |
initColumnTranslators()
|
protected void |
initUnusedColumnSql(java.lang.Class<R> rowClass)
Process
UnusedColumns annotations. |
boolean |
isInheritedFields()
Reports if super class fields are used.
|
void |
setInheritedFields(boolean inheritedFields)
Sets if super class fields are used.
|
addColumnTranslator, createColumnParameterPhrase, createColumnPhrase, createParameterPhrase, getColumnTranslator, getColumnTranslatorList, getRowClass, initColumnTranslatorList, isIncluded, isIncludeIdentityColumns, isIncludeReadOnlyColumns, read, setIncludeIdentityColumns, setIncludeReadOnlyColumns, write
public RowTranslator(Table<R> table, Row rowAnnotation) throws TranslatorException
table
- table associated with this row translatorrowAnnotation
- row annotation on table or row classTranslatorException
- if errorpublic FieldAccessType getFieldAccessType()
Column
.Row.fieldAccess()
or
FieldAccessType.Default
if no Row
annotation was usedpublic RowField<R,?> createRowField(java.lang.reflect.Field field) throws TranslatorException
RowField
object with the appropriate field access (either getter/setter method
or direct access). Typically this method is used to create a field that will receive value from
a cascade.field
- create for this fieldRowField
TranslatorException
- if errorpublic ColumnTranslator<R> getIdentityColumnTranslator()
Column.identity()
.Column.identity()
public boolean isInheritedFields()
ColumnsTranslator.getRowClass()
Row.inhertedFields()
public void setInheritedFields(boolean inheritedFields)
inheritedFields
- true if fields used include super class fields; false to use only fields in ColumnsTranslator.getRowClass()
Row.inhertedFields()
public java.lang.reflect.Field[] getDeclaredFields()
ColumnsTranslator.getRowClass()
. Also gets declared fields for
subclass(es) if isInheritedFields()
is true. Subclass fields appear in array prior
to superclass fields.protected void getDeclaredFields(java.lang.Class<?> clazz, java.util.List<java.lang.reflect.Field[]> classHierarchyFields)
clazz
- get fields from this class and superclass(es)classHierarchyFields
- each class fields are added to this listpublic java.lang.reflect.Field getDeclaredField(java.lang.String fieldName)
ColumnsTranslator.getRowClass()
. Searches for declared fields in
subclass(es) of ColumnsTranslator.getRowClass()
if isInheritedFields()
is true. Subclasses
are searched prior to to super classes.fieldName
- get field for this nameprotected java.lang.reflect.Field getDeclaredField(java.lang.Class<?> clazz, java.lang.String fieldName)
clazz
- get fields from this class and superclass(es)fieldName
- get field for this nameprotected void initColumnTranslators() throws TranslatorException
Transient
and Cascade
annotations.
Versions prior to 1.9.2 did not allow type translators to be replaced. Starting with
version 1.9.2 and 2.3.2, this method will replace existing type translator with new
one ImplicitType.translator()
is different from existing.
TranslatorException
- if errorpublic java.util.List<java.lang.reflect.Field> getCascadeFieldList()
TypeTranslator
protected void initUnusedColumnSql(java.lang.Class<R> rowClass) throws TranslatorException
UnusedColumns
annotations.rowClass
- class of rowTranslatorException
- if errorpublic PrimaryKeyWhereTranslator<R> getPrimaryKeyWhereTranslator()
public java.lang.String getUnusedColumnInsertNamesSql()
public java.lang.String getUnusedColumnInsertValuesSql()
public java.lang.String getUnusedColumnUpdateSql()