jodd.db.type
Class SqlType<T>

java.lang.Object
  extended by jodd.db.type.SqlType<T>
Direct Known Subclasses:
BigDecimalSqlType, BigIntegerSqlType, BlobSqlType, ByteArraySqlType, ClobSqlType, DateSqlType, JDateTimeSqlType, NullAwareSqlType, SqlArraySqlType, SqlDateSqlType, SqlRefSqlType, StringSqlType, TimeSqlType, TimestampSqlType, URLSqlType

public abstract class SqlType<T>
extends java.lang.Object

SQL type.


Field Summary
protected  java.lang.Class<T> sqlType
           
 
Constructor Summary
protected SqlType()
           
 
Method Summary
abstract  T get(java.sql.ResultSet rs, int index, int dbSqlType)
          Returns value from result set.
protected
<E> E
prepareGetValue(T t, java.lang.Class<E> destinationType)
          Once when value is read from result set, prepare it to match destination type.
<E> E
readValue(java.sql.ResultSet rs, int index, java.lang.Class<E> destinationType, int dbSqlType)
          Reads value from database.
abstract  void set(java.sql.PreparedStatement st, int index, T value, int dbSqlType)
          Sets prepared statement value.
 void storeValue(java.sql.PreparedStatement st, int index, java.lang.Object value, int dbSqlType)
          Stores value in database.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

sqlType

protected java.lang.Class<T> sqlType
Constructor Detail

SqlType

protected SqlType()
Method Detail

set

public abstract void set(java.sql.PreparedStatement st,
                         int index,
                         T value,
                         int dbSqlType)
                  throws java.sql.SQLException
Sets prepared statement value.

Throws:
java.sql.SQLException

get

public abstract T get(java.sql.ResultSet rs,
                      int index,
                      int dbSqlType)
               throws java.sql.SQLException
Returns value from result set.

Parameters:
rs - result set
index - column index
dbSqlType - java.sql.Types hint
Throws:
java.sql.SQLException

storeValue

public void storeValue(java.sql.PreparedStatement st,
                       int index,
                       java.lang.Object value,
                       int dbSqlType)
                throws java.sql.SQLException
Stores value in database. Value is casted to sql type.

Throws:
java.sql.SQLException

readValue

public <E> E readValue(java.sql.ResultSet rs,
                       int index,
                       java.lang.Class<E> destinationType,
                       int dbSqlType)
            throws java.sql.SQLException
Reads value from database. Value is casted to destination type.

Parameters:
rs - result set
index - database column index
destinationType - property type
dbSqlType - hint for column sql type value
Throws:
java.sql.SQLException

prepareGetValue

protected <E> E prepareGetValue(T t,
                                java.lang.Class<E> destinationType)
Once when value is read from result set, prepare it to match destination type.

Parameters:
t - get value
destinationType - destination type


Copyright © 2003-2010 Jodd Team