Package com.im.commons.db.columnhandling
Interface ColumnHandler<T>
-
- Type Parameters:
T
- The java type of values handled by thisColumnHandler
.
public interface ColumnHandler<T>
Instances of this interface can be created by usingDefaultRowMapperFactory
class. But that resides inijc.services.api
module.- Author:
- Tim Dudgeon
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
bindValue(java.sql.PreparedStatement stmt, int index, T value)
Binds a value to aPreparedStatement
using index based (?) placeholder.void
close()
Cleans up any resources after use.java.lang.String
createPlaceHolder()
Writes a placeholder to the SQL that will be used for aPreparedStaement
.java.lang.String
getColumnName()
int
getJdbcType()
org.springframework.jdbc.support.lob.LobHandler
getLobHandler()
DBDatabaseInfo.ColumnSQLType
getSqlType()
SQLWriter
getSqlWriter()
java.lang.Class<T>
getType()
T
readValue(java.sql.ResultSet rs)
void
setColumnName(java.lang.String columnName)
void
setJdbcType(int jdbcType)
void
setLobHandler(org.springframework.jdbc.support.lob.LobHandler lobHandler)
void
setSqlType(DBDatabaseInfo.ColumnSQLType sqlType)
void
setSqlWriter(SQLWriter sqlWriter)
java.lang.String
writeValue(T value)
Writes a value directly to SQL, quoting and escaping it as required.
-
-
-
Method Detail
-
getColumnName
java.lang.String getColumnName()
-
setColumnName
void setColumnName(java.lang.String columnName)
-
getJdbcType
int getJdbcType()
-
getSqlType
DBDatabaseInfo.ColumnSQLType getSqlType()
-
setSqlType
void setSqlType(DBDatabaseInfo.ColumnSQLType sqlType)
-
setJdbcType
void setJdbcType(int jdbcType)
-
setLobHandler
void setLobHandler(org.springframework.jdbc.support.lob.LobHandler lobHandler)
-
getLobHandler
org.springframework.jdbc.support.lob.LobHandler getLobHandler()
-
getSqlWriter
SQLWriter getSqlWriter()
-
setSqlWriter
void setSqlWriter(SQLWriter sqlWriter)
-
readValue
T readValue(java.sql.ResultSet rs) throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
bindValue
void bindValue(java.sql.PreparedStatement stmt, int index, T value) throws java.sql.SQLException
Binds a value to aPreparedStatement
using index based (?) placeholder.- Parameters:
stmt
- ThePreparedStatement
to set the value on.index
- The placeholder index where the value will be set.value
- The value to set, can benull
.- Throws:
java.sql.SQLException
- If the operation failed.
-
createPlaceHolder
java.lang.String createPlaceHolder()
Writes a placeholder to the SQL that will be used for aPreparedStaement
. Usually this is just "?" but in some cases might need to include the use of functions.- Returns:
- The placeholder SQL fragment that can be used in a SQL statement.
-
writeValue
java.lang.String writeValue(T value)
Writes a value directly to SQL, quoting and escaping it as required. There is no guarantee that this method will work for all data types (e.g. blob and binary column types) and is best restricted to use for simple text and numeric types.- Parameters:
value
- The value to write, can benull
.- Returns:
- The value literal suitable for including into a SQL select statements.
-
close
void close()
Cleans up any resources after use. Usually not needed, but can be needed in some cases such as the case of writing of Blobs
-
getType
java.lang.Class<T> getType()
- Returns:
- the actual type T of this columnHandler. Should return the same as T.
-
-