Class KeyGeneratorTypeHandlerBigDecimal
- java.lang.Object
-
- org.castor.cpa.persistence.sql.keygen.typehandler.KeyGeneratorTypeHandlerBigDecimal
-
- All Implemented Interfaces:
KeyGeneratorTypeHandler<java.math.BigDecimal>
public final class KeyGeneratorTypeHandlerBigDecimal extends java.lang.Object implements KeyGeneratorTypeHandler<java.math.BigDecimal>
Class implementing the KeyGeneratorTypeHandler for BigDecimal type.- Version:
- $Revision$ $Date: 2009-07-13 17:22:43 (Tue, 28 Jul 2009) $
- Author:
- Ahmad Hassan, Ralf Joachim
-
-
Constructor Summary
Constructors Constructor Description KeyGeneratorTypeHandlerBigDecimal(boolean fail)Construct an type handler for big decimal values.KeyGeneratorTypeHandlerBigDecimal(boolean fail, int allocationSize)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.math.BigDecimaladd(java.math.BigDecimal value, int offset)Adds the new Type Handler of type T to the provided handler instance at the provided offset.voidbindValue(java.sql.PreparedStatement stmt, int index, java.math.BigDecimal value)Binds the value in the sql preparedstatement at the provided index location.java.math.BigDecimalgetNextValue(java.sql.ResultSet rs)Gets the value from resultset by calling getValue method and then calls the increment method to increment the extracted value.java.math.BigDecimalgetValue(java.sql.ResultSet rs)Reads the resultset and return the extracted typehandler value from the resultset.java.math.BigDecimalincrement(java.math.BigDecimal value)Increments the provided value by ONE.
-
-
-
Constructor Detail
-
KeyGeneratorTypeHandlerBigDecimal
public KeyGeneratorTypeHandlerBigDecimal(boolean fail)
Construct an type handler for big decimal values.- Parameters:
fail-trueif the type handler should fail when current row of the record set is not valid,falseotherwise.
-
KeyGeneratorTypeHandlerBigDecimal
public KeyGeneratorTypeHandlerBigDecimal(boolean fail, int allocationSize)
-
-
Method Detail
-
getNextValue
public java.math.BigDecimal getNextValue(java.sql.ResultSet rs) throws PersistenceException, java.sql.SQLExceptionGets the value from resultset by calling getValue method and then calls the increment method to increment the extracted value.- Specified by:
getNextValuein interfaceKeyGeneratorTypeHandler<java.math.BigDecimal>- 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
public java.math.BigDecimal getValue(java.sql.ResultSet rs) throws PersistenceException, java.sql.SQLExceptionReads the resultset and return the extracted typehandler value from the resultset.- Specified by:
getValuein interfaceKeyGeneratorTypeHandler<java.math.BigDecimal>- 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
public java.math.BigDecimal increment(java.math.BigDecimal value)
Increments the provided value by ONE.- Specified by:
incrementin interfaceKeyGeneratorTypeHandler<java.math.BigDecimal>- Parameters:
value- value to be incremented.- Returns:
- Modified TypeHandler object with incremented value..
-
add
public java.math.BigDecimal add(java.math.BigDecimal value, int offset)Adds the new Type Handler of type T to the provided handler instance at the provided offset.- Specified by:
addin interfaceKeyGeneratorTypeHandler<java.math.BigDecimal>- Parameters:
value- Handler instance in which new value will be addedoffset- Offset location. *- Returns:
- Modified object.
-
bindValue
public void bindValue(java.sql.PreparedStatement stmt, int index, java.math.BigDecimal value) throws java.sql.SQLExceptionBinds the value in the sql preparedstatement at the provided index location.- Specified by:
bindValuein interfaceKeyGeneratorTypeHandler<java.math.BigDecimal>- 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.
-
-