Class BucketClobStringType

java.lang.Object
com.atlassian.hibernate.BucketClobStringType
All Implemented Interfaces:
Serializable, org.hibernate.usertype.UserType
Direct Known Subclasses:
CryptographicKeyType, CustomClobType

public class BucketClobStringType extends Object implements org.hibernate.usertype.UserType, Serializable
A custom UserType that maps stings to clobs.

This type supports custom handling for:

  • Oracle
  • MySQL
  • HSQL

This custom UserType contains a workaround for the Oracle Clob memory problem. To recap, the issue is that when dealing with Clobs, the oracle drivers will return strings with 64k char[] regardless of the amount of data they hold. So, to fix this we need to release that char[] as quickly as possible, via new String().

See Also:
  • Constructor Details

    • BucketClobStringType

      public BucketClobStringType()
  • Method Details

    • isUsingOracle

      public boolean isUsingOracle()
      Returns true if we are running with the Oracle hibernate dialect.
      Returns:
    • isUsingHSQL

      public boolean isUsingHSQL()
      Returns ture if we are running with the HSQL hibernate dialect.
      Returns:
    • isUsingMySQL

      public boolean isUsingMySQL()
      Returns true if we are running with the MySQL hibernate dialect.
      Returns:
    • getLobHandler

      protected org.springframework.jdbc.support.lob.LobHandler getLobHandler()
      Retrieve the configured LobHandler. This handler may vary with the hibernate dialect.
      Returns:
    • sqlTypes

      public int[] sqlTypes()
      Specified by:
      sqlTypes in interface org.hibernate.usertype.UserType
      Returns:
    • returnedClass

      public Class returnedClass()
      Specified by:
      returnedClass in interface org.hibernate.usertype.UserType
    • equals

      public boolean equals(Object x, Object y)
      Specified by:
      equals in interface org.hibernate.usertype.UserType
    • nullSafeGet

      public Object nullSafeGet(ResultSet rs, String[] names, org.hibernate.engine.spi.SharedSessionContractImplementor session, Object owner) throws SQLException
      Specified by:
      nullSafeGet in interface org.hibernate.usertype.UserType
      Throws:
      SQLException
    • nullSafeSet

      public void nullSafeSet(PreparedStatement st, Object value, int index, org.hibernate.engine.spi.SharedSessionContractImplementor session) throws org.hibernate.HibernateException, SQLException
      Specified by:
      nullSafeSet in interface org.hibernate.usertype.UserType
      Throws:
      org.hibernate.HibernateException
      SQLException
    • deepCopy

      public Object deepCopy(Object value)
      Specified by:
      deepCopy in interface org.hibernate.usertype.UserType
    • isMutable

      public boolean isMutable()
      Specified by:
      isMutable in interface org.hibernate.usertype.UserType
    • setUseSetClobAsString

      protected void setUseSetClobAsString(boolean b)
      Set the UseSetString property.
      Parameters:
      b - the value
      See Also:
      • useSetClobAsString
    • isUseSetClobAsString

      protected boolean isUseSetClobAsString()
      Get the UseSetString property.
      Returns:
      the value
      See Also:
      • useSetClobAsString
    • hashCode

      public int hashCode(Object x) throws org.hibernate.HibernateException
      Specified by:
      hashCode in interface org.hibernate.usertype.UserType
      Throws:
      org.hibernate.HibernateException
    • disassemble

      public Serializable disassemble(Object value) throws org.hibernate.HibernateException
      Specified by:
      disassemble in interface org.hibernate.usertype.UserType
      Throws:
      org.hibernate.HibernateException
    • assemble

      public Object assemble(Serializable cached, Object owner) throws org.hibernate.HibernateException
      Specified by:
      assemble in interface org.hibernate.usertype.UserType
      Throws:
      org.hibernate.HibernateException
    • replace

      public Object replace(Object original, Object target, Object owner) throws org.hibernate.HibernateException
      Specified by:
      replace in interface org.hibernate.usertype.UserType
      Throws:
      org.hibernate.HibernateException