1 package org.hibernate.type; 3 4 import java.sql.PreparedStatement ; 5 import java.sql.ResultSet ; 6 import java.sql.SQLException ; 7 8 import org.hibernate.EntityMode; 9 import org.hibernate.HibernateException; 10 import org.hibernate.MappingException; 11 import org.hibernate.engine.Mapping; 12 import org.hibernate.engine.SessionImplementor; 13 14 17 public abstract class AbstractLobType extends AbstractType { 18 public boolean isDirty(Object old, Object current, boolean[] checkable, SessionImplementor session) 19 throws HibernateException { 20 return checkable[0] ? ! isEqual( old, current, session.getEntityMode() ) : false; 21 } 22 23 @Override public boolean isEqual(Object x, Object y, EntityMode entityMode) { 24 return isEqual( x, y, entityMode, null); 25 } 26 27 @Override public int getHashCode(Object x, EntityMode entityMode) { 28 return getHashCode(x, entityMode, null); 29 } 30 31 public String getName() { 32 return this.getClass().getName(); 33 } 34 35 public int getColumnSpan(Mapping mapping) throws MappingException { 36 return 1; 37 } 38 39 protected abstract Object get(ResultSet rs, String name) throws SQLException ; 40 41 public Object nullSafeGet(ResultSet rs, String [] names, SessionImplementor session, Object owner) 42 throws HibernateException, SQLException { 43 return get( rs, names[0] ); 44 } 45 46 public Object nullSafeGet(ResultSet rs, String name, SessionImplementor session, Object owner) 47 throws HibernateException, SQLException { 48 return get( rs, name ); 49 } 50 51 public void nullSafeSet( 52 PreparedStatement st, Object value, int index, boolean[] settable, SessionImplementor session 53 ) throws HibernateException, SQLException { 54 if ( settable[0] ) set(st, value, index, session); 55 } 56 57 protected abstract void set(PreparedStatement st, Object value, int index, SessionImplementor session) throws SQLException ; 58 59 public void nullSafeSet(PreparedStatement st, Object value, int index, SessionImplementor session) 60 throws HibernateException, SQLException { 61 set( st, value, index, session ); 62 } 63 } 64 | Popular Tags |