org.springframework.orm.hibernate.support
Class ClobStringType

java.lang.Object
  extended byorg.springframework.orm.hibernate.support.AbstractLobType
      extended byorg.springframework.orm.hibernate.support.ClobStringType
All Implemented Interfaces:
net.sf.hibernate.UserType

public class ClobStringType
extends AbstractLobType

Hibernate UserType implementation for Strings that get mapped to CLOBs. Retrieves the LobHandler to use from LocalSessionFactoryBean at config time.

Particularly useful for storing Strings with more than 4000 characters in an Oracle database (only possible via CLOBs), in combination with OracleLobHandler.

Can also be defined in generic Hibernate mappings, as DefaultLobCreator will work with most JDBC-compliant databases respectively drivers. In this case, the field type does not have to be CLOB: For databases like MySQL and MS SQL Server, any large enough text type will work.

Since:
12.01.2004
Author:
Juergen Hoeller
See Also:
LobHandler, LocalSessionFactoryBean.setLobHandler(org.springframework.jdbc.support.lob.LobHandler)

Field Summary
 
Fields inherited from class org.springframework.orm.hibernate.support.AbstractLobType
logger
 
Constructor Summary
  ClobStringType()
          Constructor used by Hibernate: fetches config-time LobHandler and config-time JTA TransactionManager from LocalSessionFactoryBean.
protected ClobStringType(LobHandler lobHandler, javax.transaction.TransactionManager jtaTransactionManager)
          Constructor used for testing: takes an explicit LobHandler and an explicit JTA TransactionManager (can be null).
 
Method Summary
protected  java.lang.Object nullSafeGetInternal(java.sql.ResultSet rs, int index, LobHandler lobHandler)
          Template method to extract a value from the given result set.
protected  void nullSafeSetInternal(java.sql.PreparedStatement ps, int index, java.lang.Object value, LobCreator lobCreator)
          Template method to set the given value on the given statement.
 java.lang.Class returnedClass()
           
 int[] sqlTypes()
           
 
Methods inherited from class org.springframework.orm.hibernate.support.AbstractLobType
deepCopy, equals, isMutable, nullSafeGet, nullSafeSet
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClobStringType

public ClobStringType()
Constructor used by Hibernate: fetches config-time LobHandler and config-time JTA TransactionManager from LocalSessionFactoryBean.

See Also:
LocalSessionFactoryBean.getConfigTimeLobHandler(), LocalSessionFactoryBean.getConfigTimeTransactionManager()

ClobStringType

protected ClobStringType(LobHandler lobHandler,
                         javax.transaction.TransactionManager jtaTransactionManager)
Constructor used for testing: takes an explicit LobHandler and an explicit JTA TransactionManager (can be null).

Method Detail

sqlTypes

public int[] sqlTypes()

returnedClass

public java.lang.Class returnedClass()

nullSafeGetInternal

protected java.lang.Object nullSafeGetInternal(java.sql.ResultSet rs,
                                               int index,
                                               LobHandler lobHandler)
                                        throws java.sql.SQLException
Description copied from class: AbstractLobType
Template method to extract a value from the given result set.

Specified by:
nullSafeGetInternal in class AbstractLobType
Parameters:
rs - the ResultSet to extract from
index - the index in the ResultSet
lobHandler - the LobHandler to use
Returns:
the extracted value
Throws:
java.sql.SQLException - if thrown by JDBC methods

nullSafeSetInternal

protected void nullSafeSetInternal(java.sql.PreparedStatement ps,
                                   int index,
                                   java.lang.Object value,
                                   LobCreator lobCreator)
                            throws java.sql.SQLException
Description copied from class: AbstractLobType
Template method to set the given value on the given statement.

Specified by:
nullSafeSetInternal in class AbstractLobType
Parameters:
ps - the PreparedStatement to set on
index - the statement parameter index
value - the value to set
lobCreator - the LobCreator to use
Throws:
java.sql.SQLException - if thrown by JDBC methods


Copyright (C) 2003-2004 The Spring Framework Project.