public class BooleanYNColumnTranslator<R> extends AbstractColumnTranslator<R,java.lang.Boolean>
PreparedStatement.setString(int, String)
and ResultSet.getString(int)
.
"Y" is used for true and "N" is used for false.
Use this to override the standard translator attribute, translator in Column
annotation:
An alternative is to use@Column(translator=BooleanYNColumnTranslator.class) boolean someBoolean;
BooleanYNTranslator
:
@ImplicitType(translator=BooleanYNTranslator.class) boolean someBoolean;
Constructor and Description |
---|
BooleanYNColumnTranslator(RowField<R,java.lang.Boolean> rowField,
java.lang.String columnName)
Constructs for a
RowField and column name. |
Modifier and Type | Method and Description |
---|---|
void |
read(java.sql.ResultSet resultSet,
int columnIndex,
R row)
Reads column value from result set and sets in row object.
|
void |
write(java.sql.PreparedStatement preparedStatement,
int parameterIndex,
R row)
Gets column value from row and sets as parameter in prepared statement.
|
getColumnName, getField, getRowField, getTypeTranslator, isIdentity, isReadOnly, newInstance, setIdentity, setReadOnly, setTypeTranslator
public BooleanYNColumnTranslator(RowField<R,java.lang.Boolean> rowField, java.lang.String columnName) throws java.lang.Exception
RowField
and column name.rowField
- field within row class that contains the booleancolumnName
- sql column name associated with rowFieldjava.lang.Exception
- if errorpublic void write(java.sql.PreparedStatement preparedStatement, int parameterIndex, R row) throws java.lang.Exception
write
in interface ColumnTranslator<R>
write
in class AbstractColumnTranslator<R,java.lang.Boolean>
preparedStatement
- set column value as parameter in this statementparameterIndex
- set parameter at this indexrow
- get value from this rowjava.lang.Exception
- if errorpublic void read(java.sql.ResultSet resultSet, int columnIndex, R row) throws java.lang.Exception
read
in interface ColumnTranslator<R>
read
in class AbstractColumnTranslator<R,java.lang.Boolean>
resultSet
- read column from this result setcolumnIndex
- read value at this column index from result setrow
- set value in this rowjava.lang.Exception
- if error