org.sormula.translator
Class RowTranslator<R>

java.lang.Object
  extended by org.sormula.translator.ColumnsTranslator<R>
      extended by org.sormula.translator.RowTranslator<R>
Type Parameters:
R - row class

public class RowTranslator<R>
extends ColumnsTranslator<R>

Translates a row to prepared statement and from result set. ColumnTranslator objects are created for each column based upon annotations on row class. If no annotation exists for a member then column name is same as member name and StandardColumnTranslator is used.

Since:
1.0
Author:
Jeff Miller

Constructor Summary
RowTranslator(Table<R> table)
          Constructs for a table.
 
Method Summary
 ColumnTranslator<R> getIdentityColumnTranslator()
          Column translator used to set the value of a row column that is the identity column for row.
 NameTranslator getNameTranslator()
          Deprecated. 
 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()
          Process Transient and Cascade annotations.
protected  void initUnusedColumnSql(java.lang.Class<R> rowClass)
          Process UnusedColumns annotations.
 R newInstance()
          Deprecated. 
protected  TypeTranslator<?> readimplicitType(java.lang.reflect.AnnotatedElement... annotatedElements)
          Deprecated. 
protected  TypeTranslator<?> readImplicitType(java.lang.reflect.AnnotatedElement... annotatedElements)
          Deprecated. 
 
Methods inherited from class org.sormula.translator.ColumnsTranslator
addColumnTranslator, createColumnParameterPhrase, createColumnPhrase, createParameterPhrase, getColumnTranslator, getColumnTranslatorList, getRowClass, initColumnTranslatorList, isIncludeIdentityColumns, read, setIncludeIdentityColumns, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RowTranslator

public RowTranslator(Table<R> table)
              throws TranslatorException
Constructs for a table.

Parameters:
table - table associated with this row translator
Throws:
TranslatorException - if error
Since:
1.6 and 2.0
Method Detail

getIdentityColumnTranslator

public ColumnTranslator<R> getIdentityColumnTranslator()
Column translator used to set the value of a row column that is the identity column for row. Typically used by insert operations for column that is annotated with Column.identity().

Returns:
column translator for identity column; null if no identity column
See Also:
Column.identity()

initColumnTranslators

protected void initColumnTranslators()
                              throws TranslatorException
Process 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.

Throws:
TranslatorException - if error

readimplicitType

@Deprecated
protected TypeTranslator<?> readimplicitType(java.lang.reflect.AnnotatedElement... annotatedElements)
                                      throws TranslatorException
Deprecated. 

Do not use. Replaced with ImplicitTypeAnnotationReader.

Throws:
TranslatorException
Since:
1.6 and 2.0

readImplicitType

@Deprecated
protected TypeTranslator<?> readImplicitType(java.lang.reflect.AnnotatedElement... annotatedElements)
                                      throws TranslatorException
Deprecated. 

Do not use. Replaced with ImplicitTypeAnnotationReader. Searches any ImplicitType annotations and returns new instance of ImplicitType.translator() for the first one found.

Parameters:
annotatedElements - objects that may contain an ImplicitType annotation
Returns:
new TypeTranslator or null if no ImplicitType annotations
Throws:
TranslatorException - if error creating new instance of type translator
Since:
1.8 and 2.2

initUnusedColumnSql

protected void initUnusedColumnSql(java.lang.Class<R> rowClass)
                            throws TranslatorException
Process UnusedColumns annotations.

Parameters:
rowClass -
Throws:
TranslatorException

getNameTranslator

@Deprecated
public NameTranslator getNameTranslator()
Deprecated. 

Gets translator defined by Row.nameTranslator(). Use Table.getNameTranslators() instead of this method.

Returns:
translator for converting java names to sql names

newInstance

@Deprecated
public R newInstance()
              throws TranslatorException
Deprecated. 

Creates new instance of row object using zero-argument constructor. New instances are typically created by select operations when they are reading data from a result set. Moved to Table.

Returns:
object to hold one row
Throws:
TranslatorException - if new row instance cannot be created

getPrimaryKeyWhereTranslator

public PrimaryKeyWhereTranslator<R> getPrimaryKeyWhereTranslator()
Gets primary key translator for use in where clause.

Returns:
translator for primary key columns

getUnusedColumnInsertNamesSql

public java.lang.String getUnusedColumnInsertNamesSql()
Gets names of unused columns for insert statement.

Returns:
", uc1, uc2, uc3..." for all unused columns

getUnusedColumnInsertValuesSql

public java.lang.String getUnusedColumnInsertValuesSql()
Gets values for unused columns for insert statement.

Returns:
", v1, v2, v3..." for all unused columns

getUnusedColumnUpdateSql

public java.lang.String getUnusedColumnUpdateSql()
Gets column=value for all unused columns for update statement.

Returns:
", uc1=v1, uc2=v2, uc3=v3..." for all unused columns