org.springframework.orm.hibernate3.support
Class AbstractLobType

java.lang.Object
  extended by org.springframework.orm.hibernate3.support.AbstractLobType
Direct Known Subclasses:
BlobByteArrayType, BlobSerializableType, BlobStringType, ClobStringType

public abstract class AbstractLobType
extends java.lang.Object

Abstract base class for Hibernate UserType implementations that map to LOBs. Retrieves the LobHandler to use from LocalSessionFactoryBean at config time.

For writing LOBs, either an active Spring transaction synchronization or an active JTA transaction (with "jtaTransactionManager" specified on LocalSessionFactoryBean or a Hibernate TransactionManagerLookup configured through the corresponding Hibernate property) is required.

Offers template methods for setting parameters and getting result values, passing in the LobHandler or LobCreator to use.

Since:
1.2
Author:
Juergen Hoeller
See Also:
LobHandler, LobCreator, LocalSessionFactoryBean.setLobHandler(org.springframework.jdbc.support.lob.LobHandler), LocalSessionFactoryBean.setJtaTransactionManager(TransactionManager)

Field Summary
private  TransactionManager jtaTransactionManager
           
private  LobHandler lobHandler
           
protected  Log logger
           
 
Constructor Summary
protected AbstractLobType()
          Constructor used by Hibernate: fetches config-time LobHandler and config-time JTA TransactionManager from LocalSessionFactoryBean.
protected AbstractLobType(LobHandler lobHandler, TransactionManager jtaTransactionManager)
          Constructor used for testing: takes an explicit LobHandler and an explicit JTA TransactionManager (can be null).
 
Method Summary
 java.lang.Object assemble(java.io.Serializable cached, java.lang.Object owner)
          This implementation returns the passed-in value as-is.
 java.lang.Object deepCopy(java.lang.Object value)
          This implementation returns the passed-in value as-is.
 java.io.Serializable disassemble(java.lang.Object value)
          This implementation returns the passed-in value as-is.
 boolean equals(java.lang.Object x, java.lang.Object y)
          This implementation delegates to the Hibernate EqualsHelper.
 int hashCode(java.lang.Object x)
          This implementation returns the hashCode of the given objectz.
 boolean isMutable()
          This implementation returns false.
 java.lang.Object nullSafeGet(java.sql.ResultSet rs, java.lang.String[] names, java.lang.Object owner)
          This implementation delegates to nullSafeGetInternal, passing in the LobHandler of this type.
protected abstract  java.lang.Object nullSafeGetInternal(java.sql.ResultSet rs, java.lang.String[] names, java.lang.Object owner, LobHandler lobHandler)
          Template method to extract a value from the given result set.
 void nullSafeSet(java.sql.PreparedStatement st, java.lang.Object value, int index)
          This implementation delegates to nullSafeSetInternal, passing in a transaction-synchronized LobCreator for the LobHandler of this type.
protected abstract  void nullSafeSetInternal(java.sql.PreparedStatement ps, int index, java.lang.Object value, LobCreator lobCreator)
          Template method to set the given parameter value on the given statement.
 java.lang.Object replace(java.lang.Object original, java.lang.Object target, java.lang.Object owner)
          This implementation returns the passed-in original as-is.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected final Log logger

lobHandler

private final LobHandler lobHandler

jtaTransactionManager

private final TransactionManager jtaTransactionManager
Constructor Detail

AbstractLobType

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

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

AbstractLobType

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

Method Detail

isMutable

public boolean isMutable()
This implementation returns false.


equals

public boolean equals(java.lang.Object x,
                      java.lang.Object y)
               throws HibernateException
This implementation delegates to the Hibernate EqualsHelper.

Throws:
HibernateException
See Also:
org.hibernate.util.EqualsHelper#equals

hashCode

public int hashCode(java.lang.Object x)
             throws HibernateException
This implementation returns the hashCode of the given objectz.

Throws:
HibernateException

deepCopy

public java.lang.Object deepCopy(java.lang.Object value)
                          throws HibernateException
This implementation returns the passed-in value as-is.

Throws:
HibernateException

disassemble

public java.io.Serializable disassemble(java.lang.Object value)
                                 throws HibernateException
This implementation returns the passed-in value as-is.

Throws:
HibernateException

assemble

public java.lang.Object assemble(java.io.Serializable cached,
                                 java.lang.Object owner)
                          throws HibernateException
This implementation returns the passed-in value as-is.

Throws:
HibernateException

replace

public java.lang.Object replace(java.lang.Object original,
                                java.lang.Object target,
                                java.lang.Object owner)
                         throws HibernateException
This implementation returns the passed-in original as-is.

Throws:
HibernateException

nullSafeGet

public final java.lang.Object nullSafeGet(java.sql.ResultSet rs,
                                          java.lang.String[] names,
                                          java.lang.Object owner)
                                   throws HibernateException,
                                          java.sql.SQLException
This implementation delegates to nullSafeGetInternal, passing in the LobHandler of this type.

Throws:
HibernateException
java.sql.SQLException
See Also:
nullSafeGetInternal(java.sql.ResultSet, java.lang.String[], java.lang.Object, org.springframework.jdbc.support.lob.LobHandler)

nullSafeSet

public final void nullSafeSet(java.sql.PreparedStatement st,
                              java.lang.Object value,
                              int index)
                       throws HibernateException,
                              java.sql.SQLException
This implementation delegates to nullSafeSetInternal, passing in a transaction-synchronized LobCreator for the LobHandler of this type.

Throws:
HibernateException
java.sql.SQLException
See Also:
nullSafeSetInternal(java.sql.PreparedStatement, int, java.lang.Object, org.springframework.jdbc.support.lob.LobCreator)

nullSafeGetInternal

protected abstract java.lang.Object nullSafeGetInternal(java.sql.ResultSet rs,
                                                        java.lang.String[] names,
                                                        java.lang.Object owner,
                                                        LobHandler lobHandler)
                                                 throws java.sql.SQLException,
                                                        java.io.IOException,
                                                        HibernateException
Template method to extract a value from the given result set.

Parameters:
rs - the ResultSet to extract from
names - the column names
owner - the containing entity
lobHandler - the LobHandler to use
Returns:
the extracted value
Throws:
java.sql.SQLException - if thrown by JDBC methods
java.io.IOException - if thrown by streaming methods
HibernateException - in case of any other exceptions

nullSafeSetInternal

protected abstract void nullSafeSetInternal(java.sql.PreparedStatement ps,
                                            int index,
                                            java.lang.Object value,
                                            LobCreator lobCreator)
                                     throws java.sql.SQLException,
                                            java.io.IOException,
                                            HibernateException
Template method to set the given parameter value on the given statement.

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
java.io.IOException - if thrown by streaming methods
HibernateException - in case of any other exceptions