Package com.atlassian.hibernate
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:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
BucketClobStringType.LobCreatorSynchronization
Callback for resource cleanup at the end of a transaction.
-
Constructor Summary
Constructors Constructor Description BucketClobStringType()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Object
assemble(Serializable cached, Object owner)
Object
deepCopy(Object value)
Serializable
disassemble(Object value)
boolean
equals(Object x, Object y)
protected org.springframework.jdbc.support.lob.LobHandler
getLobHandler()
Retrieve the configured LobHandler.int
hashCode(Object x)
boolean
isMutable()
protected boolean
isUseSetClobAsString()
Get the UseSetString property.boolean
isUsingHSQL()
Returns ture if we are running with the HSQL hibernate dialect.boolean
isUsingMySQL()
Returns true if we are running with the MySQL hibernate dialect.boolean
isUsingOracle()
Returns true if we are running with the Oracle hibernate dialect.Object
nullSafeGet(ResultSet rs, String[] names, org.hibernate.engine.spi.SharedSessionContractImplementor session, Object owner)
void
nullSafeSet(PreparedStatement st, Object value, int index, org.hibernate.engine.spi.SharedSessionContractImplementor session)
Object
replace(Object original, Object target, Object owner)
Class
returnedClass()
protected void
setUseSetClobAsString(boolean b)
Set the UseSetString property.int[]
sqlTypes()
-
-
-
Method Detail
-
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 interfaceorg.hibernate.usertype.UserType
- Returns:
-
returnedClass
public Class returnedClass()
- Specified by:
returnedClass
in interfaceorg.hibernate.usertype.UserType
-
equals
public boolean equals(Object x, Object y)
- Specified by:
equals
in interfaceorg.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 interfaceorg.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 interfaceorg.hibernate.usertype.UserType
- Throws:
org.hibernate.HibernateException
SQLException
-
deepCopy
public Object deepCopy(Object value)
- Specified by:
deepCopy
in interfaceorg.hibernate.usertype.UserType
-
isMutable
public boolean isMutable()
- Specified by:
isMutable
in interfaceorg.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 interfaceorg.hibernate.usertype.UserType
- Throws:
org.hibernate.HibernateException
-
disassemble
public Serializable disassemble(Object value) throws org.hibernate.HibernateException
- Specified by:
disassemble
in interfaceorg.hibernate.usertype.UserType
- Throws:
org.hibernate.HibernateException
-
assemble
public Object assemble(Serializable cached, Object owner) throws org.hibernate.HibernateException
- Specified by:
assemble
in interfaceorg.hibernate.usertype.UserType
- Throws:
org.hibernate.HibernateException
-
-