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

BlobType

public class BlobType extends AbstractType
blob: A type that maps an SQL BLOB to a java.sql.Blob.
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("Blobs are not cacheable");
	
public java.lang.ObjectfromXMLNode(org.dom4j.Node xml, org.hibernate.engine.Mapping factory)

		throw new UnsupportedOperationException("todo");
	
public java.lang.Objectget(java.sql.ResultSet rs, java.lang.String name)

		Blob value = rs.getBlob(name);
		return rs.wasNull() ? null : new SerializableBlob(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 "blob";
	
public java.lang.ClassgetReturnedClass()

		return Blob.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)

		//Blobs are ignored by merge()
		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.BLOB);
		}
		else {
			
			if (value instanceof SerializableBlob) {
				value = ( (SerializableBlob) value ).getWrappedBlob();
			}
		
			final boolean useInputStream = session.getFactory().getDialect().useInputStreamToInsertBlob() && 
				(value instanceof BlobImpl);
			
			if ( useInputStream ) {
				BlobImpl blob = (BlobImpl) value;
				st.setBinaryStream( index, blob.getBinaryStream(), (int) blob.length() );
			}
			else {
				st.setBlob(index, (Blob) value);
			}
			
		}
		
	
public voidsetToXMLNode(org.dom4j.Node node, java.lang.Object value, org.hibernate.engine.SessionFactoryImplementor factory)

		throw new UnsupportedOperationException("todo");
	
public int[]sqlTypes(org.hibernate.engine.Mapping mapping)

		return new int[] { Types.BLOB };
	
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();