Interface KeyGeneratorTypeHandler<T>
-
- Type Parameters:
T
- Name of KeyGeneratorTypeHandler interface.
- All Known Implementing Classes:
KeyGeneratorTypeHandlerBigDecimal
,KeyGeneratorTypeHandlerInteger
,KeyGeneratorTypeHandlerLong
,KeyGeneratorTypeHandlerShort
,KeyGeneratorTypeHandlerString
public interface KeyGeneratorTypeHandler<T>
Interface for various type handlers. The type handler handles integer, BigDecimal, Long and String values depending on the database engine.- Version:
- $Revision$ $Date: 2009-07-13 17:22:43 (Tue, 28 Jul 2009) $
- Author:
- Ahmad Hassan, Ralf Joachim
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description T
add(T value, int offset)
Adds the new Type Handler of type T to the provided handler instance at the provided offset.void
bindValue(java.sql.PreparedStatement stmt, int index, T value)
Binds the value in the sql preparedstatement at the provided index location.T
getNextValue(java.sql.ResultSet rs)
Gets the value from resultset by calling getValue method and then calls the increment method to increment the extracted value.T
getValue(java.sql.ResultSet rs)
Reads the resultset and return the extracted typehandler value from the resultset.T
increment(T value)
Increments the provided value by ONE.
-
-
-
Method Detail
-
getNextValue
T getNextValue(java.sql.ResultSet rs) throws PersistenceException, java.sql.SQLException
Gets the value from resultset by calling getValue method and then calls the increment method to increment the extracted value.- Parameters:
rs
- A ResultSet object.- Returns:
- Returns the new value after incrementing it.
- Throws:
PersistenceException
- If ResultSet is empty or if the type handler should fail when current row of the record set is not valid,java.sql.SQLException
- If database error occurs.
-
getValue
T getValue(java.sql.ResultSet rs) throws PersistenceException, java.sql.SQLException
Reads the resultset and return the extracted typehandler value from the resultset.- Parameters:
rs
- ResultSet object- Returns:
- Value extracted from the ResultSet.
- Throws:
PersistenceException
- If ResultSet is empty or if the type handler should fail when current row of the record set is not valid,java.sql.SQLException
- If database error occurs.
-
increment
T increment(T value)
Increments the provided value by ONE.- Parameters:
value
- value to be incremented.- Returns:
- Modified TypeHandler object with incremented value..
-
add
T add(T value, int offset)
Adds the new Type Handler of type T to the provided handler instance at the provided offset.- Parameters:
value
- Handler instance in which new value will be addedoffset
- Offset location. *- Returns:
- Modified object.
-
bindValue
void bindValue(java.sql.PreparedStatement stmt, int index, T value) throws java.sql.SQLException
Binds the value in the sql preparedstatement at the provided index location.- Parameters:
stmt
- A SQL PreparedStatement.index
- Index location for binding parameter to statement.value
- Value to be binded- Throws:
java.sql.SQLException
- If SQL error occurs in binding param to sql statement.
-
-