R
- row classT
- type of field that is stored as SQL BLOB typepublic abstract class AbstractBlobColumnTranslator<R,T> extends AbstractColumnTranslator<R,T>
PreparedStatement.setBlob(int, Blob)
and
ResultSet.getBlob(int)
. Implement blobToField(Blob)
and fieldToBlob(Object)
to create a blob column translator for type T in row type R. AbstractColumnTranslator
is
the base class. See BlobExample and WidgetColumnTranslator2 for example of how
to use this class.Constructor and Description |
---|
AbstractBlobColumnTranslator(RowField<R,T> rowField,
java.lang.String columnName)
Constructs for a
RowField and column name. |
Modifier and Type | Method and Description |
---|---|
protected abstract T |
blobToField(java.sql.Blob blob)
Converts a
Blob object to a domain object for use by read(ResultSet, int, Object) . |
protected abstract java.sql.Blob |
fieldToBlob(T field)
Converts a domain object to a
Blob for use by write(PreparedStatement, int, Object) . |
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 AbstractBlobColumnTranslator(RowField<R,T> rowField, java.lang.String columnName) throws java.lang.Exception
RowField
and column name.rowField
- field within row class that contains the blobcolumnName
- 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,T>
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,T>
resultSet
- read column from this result setcolumnIndex
- read value at this column index from result setrow
- set value in this rowjava.lang.Exception
- if errorprotected abstract java.sql.Blob fieldToBlob(T field) throws java.lang.Exception
Blob
for use by write(PreparedStatement, int, Object)
.
Implement this method in a subclass to write type T that to database as a BLOB column type.field
- domain object that is stored in database as SQL BLOB typejava.lang.Exception
- if errorprotected abstract T blobToField(java.sql.Blob blob) throws java.lang.Exception
Blob
object to a domain object for use by read(ResultSet, int, Object)
.
Implement this method in a subclass to read type T from database as a BLOB column type.blob
- JDBC blobjava.lang.Exception
- if error