Package org.apache.ofbiz.entity.jdbc
Class JdbcValueHandler<T>
java.lang.Object
org.apache.ofbiz.entity.jdbc.JdbcValueHandler<T>
- Direct Known Subclasses:
JdbcValueHandler.ArrayJdbcValueHandler
,JdbcValueHandler.BigDecimalJdbcValueHandler
,JdbcValueHandler.BlobJdbcValueHandler
,JdbcValueHandler.BooleanJdbcValueHandler
,JdbcValueHandler.ByteArrayJdbcValueHandler
,JdbcValueHandler.ClobJdbcValueHandler
,JdbcValueHandler.DateJdbcValueHandler
,JdbcValueHandler.DoubleJdbcValueHandler
,JdbcValueHandler.FloatJdbcValueHandler
,JdbcValueHandler.IntegerJdbcValueHandler
,JdbcValueHandler.LongJdbcValueHandler
,JdbcValueHandler.ObjectJdbcValueHandler
,JdbcValueHandler.RowIdJdbcValueHandler
,JdbcValueHandler.ShortJdbcValueHandler
,JdbcValueHandler.StringJdbcValueHandler
,JdbcValueHandler.TimeJdbcValueHandler
,JdbcValueHandler.TimestampJdbcValueHandler
An object that handles getting/setting column values in JDBC
PreparedStatement
and ResultSet
objects.-
Nested Class Summary
Modifier and TypeClassDescriptionprotected static class
Ajava.sql.Array
JDBC value handler.protected static class
Ajava.math.BigDecimal
JDBC value handler.protected static class
Ajava.sql.Blob
JDBC value handler.protected static class
Ajava.lang.Boolean
JDBC value handler.protected static class
Abyte[]
JDBC value handler.protected static class
Ajava.sql.Clob
JDBC value handler.protected static class
Ajava.sql.Date
JDBC value handler.protected static class
Ajava.lang.Double
JDBC value handler.protected static class
Ajava.lang.Float
JDBC value handler.protected static class
Ajava.lang.Integer
JDBC value handler.protected static class
Ajava.lang.Long
JDBC value handler.protected static class
Ajava.lang.Object
JDBC value handler.protected static class
Ajava.sql.RowId
JDBC value handler.protected static class
Ajava.lang.Short
JDBC value handler.protected static class
Ajava.lang.String
JDBC value handler.protected static class
Ajava.sql.Time
JDBC value handler.protected static class
Ajava.sql.Timestamp
JDBC value handler. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected abstract void
castAndSetValue
(PreparedStatement ps, int parameterIndex, T obj) Sets a value in aPreparedStatement
.protected JdbcValueHandler<T>
create
(int sqlType) Create jdbc value handler.static JdbcValueHandler<?>
getInstance
(String javaType, String sqlType) Returns theJdbcValueHandler
that corresponds to a field type.int
Returns the SQL type for this handler.abstract T
Returns a value from aResultSet
.protected abstract JdbcValueHandler<T>
newInstance
(int sqlType) Returns a new instance of the object - initialized with the specified SQL type.protected static String
parseSqlType
(String sqlType) protected static byte[]
serializeObject
(Object obj) void
setValue
(PreparedStatement ps, int parameterIndex, T obj) Sets a value in aPreparedStatement
.
-
Constructor Details
-
JdbcValueHandler
protected JdbcValueHandler(int sqlType)
-
-
Method Details
-
getInstance
Returns theJdbcValueHandler
that corresponds to a field type.- Parameters:
javaType
- The Java type specified in fieldtype*.xmlsqlType
- The SQL type specified in fieldtype*.xml- Returns:
- A
JdbcValueHandler
instance
-
parseSqlType
-
serializeObject
- Throws:
SQLException
-
castAndSetValue
protected abstract void castAndSetValue(PreparedStatement ps, int parameterIndex, T obj) throws SQLException Sets a value in aPreparedStatement
. Theobj
argument is converted to the correct data type. Subclasses override this method to castobj
to the correct data type and call the appropriatePreparedStatement.setXxx
method.- Parameters:
ps
-parameterIndex
-obj
-- Throws:
SQLException
-
create
Create jdbc value handler.- Parameters:
sqlType
- the sql type- Returns:
- the jdbc value handler
-
getSqlType
public int getSqlType()Returns the SQL type for this handler.- Returns:
- return the SQL type
- See Also:
-
java.sql.Types
-
getValue
Returns a value from aResultSet
. The returned object is converted to the Java data type specified in the fieldtype file.- Parameters:
rs
- the ResultSet objectcolumnIndex
- the column index- Returns:
- get value from result set
- Throws:
SQLException
-
newInstance
Returns a new instance of the object - initialized with the specified SQL type.- Parameters:
sqlType
- the sql type- Returns:
- returns a new instance
-
getJavaClass
-
setValue
Sets a value in aPreparedStatement
. Theobj
argument is converted to the correct data type.- Parameters:
ps
-parameterIndex
-obj
-- Throws:
SQLException
-