FileDocCategorySizeDatePackage
ClobType.javaAPI DocHibernate 3.2.54576Mon Jul 25 01:53:10 BST 2005org.hibernate.type

ClobType

public class ClobType extends AbstractType
clob: A type that maps an SQL CLOB to a java.sql.Clob.
author
Gavin King

Fields Summary
Constructors Summary
Methods Summary
public intcompare(java.lang.Object x, java.lang.Object y, org.hibernate.EntityMode entityMode)

		return 0; //lobs cannot be compared
	
public java.lang.ObjectdeepCopy(java.lang.Object value, org.hibernate.EntityMode entityMode, org.hibernate.engine.SessionFactoryImplementor factory)

		return value;
	
public java.io.Serializabledisassemble(java.lang.Object value, org.hibernate.engine.SessionImplementor session, java.lang.Object owner)

		throw new UnsupportedOperationException("Clobs are not cacheable");
	
public java.lang.ObjectfromXMLNode(org.dom4j.Node xml, org.hibernate.engine.Mapping factory)

		return Hibernate.createClob( xml.getText() );
	
public java.lang.Objectget(java.sql.ResultSet rs, java.lang.String name)

		Clob value = rs.getClob(name);
		return rs.wasNull() ? null : new SerializableClob(value);
	
public intgetColumnSpan(org.hibernate.engine.Mapping mapping)

		return 1;
	
public intgetHashCode(java.lang.Object x, org.hibernate.EntityMode entityMode)

		return System.identityHashCode(x);
	
public java.lang.StringgetName()

		return "clob";
	
public java.lang.ClassgetReturnedClass()

		return Clob.class;
	
public booleanisDirty(java.lang.Object old, java.lang.Object current, boolean[] checkable, org.hibernate.engine.SessionImplementor session)

		return checkable[0] && isDirty(old, current, session);
	
public booleanisEqual(java.lang.Object x, java.lang.Object y, org.hibernate.EntityMode entityMode)

		return x == y;
	
public booleanisMutable()

		return false;
	
public java.lang.ObjectnullSafeGet(java.sql.ResultSet rs, java.lang.String name, org.hibernate.engine.SessionImplementor session, java.lang.Object owner)

		return get(rs, name);
	
public java.lang.ObjectnullSafeGet(java.sql.ResultSet rs, java.lang.String[] names, org.hibernate.engine.SessionImplementor session, java.lang.Object owner)

		return get( rs, names[0] );
	
public voidnullSafeSet(java.sql.PreparedStatement st, java.lang.Object value, int index, boolean[] settable, org.hibernate.engine.SessionImplementor session)

		if ( settable[0] ) set(st, value, index, session);
	
public voidnullSafeSet(java.sql.PreparedStatement st, java.lang.Object value, int index, org.hibernate.engine.SessionImplementor session)

		set(st, value, index, session);
	
public java.lang.Objectreplace(java.lang.Object original, java.lang.Object target, org.hibernate.engine.SessionImplementor session, java.lang.Object owner, java.util.Map copyCache)

		//Clobs are ignored by merge() operation
		return target;
	
public voidset(java.sql.PreparedStatement st, java.lang.Object value, int index, org.hibernate.engine.SessionImplementor session)

		
		if (value==null) {
			st.setNull(index, Types.CLOB);
		}
		else {
		
			if (value instanceof SerializableClob) {
				value = ( (SerializableClob) value ).getWrappedClob();
			}
		
			final boolean useReader = session.getFactory().getDialect().useInputStreamToInsertBlob() && 
				(value instanceof ClobImpl);
			
			if ( useReader ) {
				ClobImpl clob = (ClobImpl) value;
				st.setCharacterStream( index, clob.getCharacterStream(), (int) clob.length() );
			}
			else {
				st.setClob(index, (Clob) value);
			}
			
		}
		
	
public voidsetToXMLNode(org.dom4j.Node node, java.lang.Object value, org.hibernate.engine.SessionFactoryImplementor factory)

		if (value!=null) {
			Clob clob = (Clob) value;
			try {
				int len = (int) clob.length();
				node.setText( clob.getSubString(0, len) );
			}
			catch (SQLException sqle) {
				throw new HibernateException("could not read XML from Clob", sqle);
			}
		}
	
public int[]sqlTypes(org.hibernate.engine.Mapping mapping)

		return new int[] { Types.CLOB };
	
public boolean[]toColumnNullness(java.lang.Object value, org.hibernate.engine.Mapping mapping)

		return value==null ? ArrayHelper.FALSE : ArrayHelper.TRUE;
	
public java.lang.StringtoLoggableString(java.lang.Object value, org.hibernate.engine.SessionFactoryImplementor factory)

		return value==null ? "null" : value.toString();