de.mathema.pride
Class PreparedStatementAccess
java.lang.Object
de.mathema.pride.PreparedStatementAccess
public class PreparedStatementAccess
- extends java.lang.Object
This class holds meta information about access methods to
JDBC prepared statements. It is required for PriDE's generic way
of writing record fields to the database.
- Author:
- Jan Lessner
Method Summary |
static void |
init()
Initialize the class by the default type mappings below. |
static void |
putMethod(java.lang.String methodName,
java.lang.Class paramType)
|
static void |
putMethod(java.lang.String methodName,
java.lang.Class functionParamType,
java.lang.Class valueType)
Adds a prepared statement access method for a specified type |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
REVISION_ID
public static final java.lang.String REVISION_ID
- See Also:
- Constant Field Values
PreparedStatementAccess
public PreparedStatementAccess()
putMethod
public static void putMethod(java.lang.String methodName,
java.lang.Class paramType)
throws java.lang.NoSuchMethodException
- Throws:
java.lang.NoSuchMethodException
putMethod
public static void putMethod(java.lang.String methodName,
java.lang.Class functionParamType,
java.lang.Class valueType)
throws java.lang.NoSuchMethodException
- Adds a prepared statement access method for a specified type
- Parameters:
methodName
- Name of the access method to register. The
method is assumed to be applicable to the PreparedStatement class
for access by integer index.functionParamType
- Type of parameter to be passed to the
prepared statement access method denoted by parameter methodName.valueType
- Type of value returned by a getter method of a
source object. This parameter is required to express mappings like
Float -> float. If it is null, the functionParamType is used.
- Throws:
java.lang.NoSuchMethodException
- if the specified method is not
available for class java.sql.ResultSet
init
public static void init()
throws java.lang.NoSuchMethodException
- Initialize the class by the default type mappings below.
As a difference to the corresponding function in
ResultSetAccess
there is no mapping for java.util.Date as this type is not supported
as input for prepared statements parameters. As a work around you may
provide additional getter methods in you entity, providing a conversion
to either java.sql.Date or java.sql.Timestamp.
- String -> setString
- Enum -> setString
- java.util.Date -> setTimestamp
- java.sql.Date -> setDate
- java.sql.Timestamp -> setTimestamp
- Integer/int -> setInt
- Float/float -> setFloat
- Double/double -> setDouble
- Boolean/boolean -> setBoolean
- BigDecimal -> setBigDecimal
- Long/long -> setLong
- Short/short -> setShort
- byte[] -> setBytes
- Byte/byte -> setByte
- Blob -> setBlob
- Clob -> setClob
- Map -> setObject, for Postgres only
- Any array type -> setArray, for Postgres only
- Throws:
java.lang.NoSuchMethodException