KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > hibernate > type > AbstractLobType


1 //$Id: AbstractLobType.java,v 1.2 2005/07/25 08:00:17 epbernard Exp $
2
package org.hibernate.type;
3
4 import java.sql.PreparedStatement JavaDoc;
5 import java.sql.ResultSet JavaDoc;
6 import java.sql.SQLException JavaDoc;
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 /**
15  * @author Emmanuel Bernard
16  */

17 public abstract class AbstractLobType extends AbstractType {
18     public boolean isDirty(Object JavaDoc old, Object JavaDoc current, boolean[] checkable, SessionImplementor session)
19             throws HibernateException {
20         return checkable[0] ? ! isEqual( old, current, session.getEntityMode() ) : false;
21     }
22
23     @Override JavaDoc public boolean isEqual(Object JavaDoc x, Object JavaDoc y, EntityMode entityMode) {
24         return isEqual( x, y, entityMode, null);
25     }
26
27     @Override JavaDoc public int getHashCode(Object JavaDoc x, EntityMode entityMode) {
28         return getHashCode(x, entityMode, null);
29     }
30
31     public String JavaDoc 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 JavaDoc get(ResultSet JavaDoc rs, String JavaDoc name) throws SQLException JavaDoc;
40
41     public Object JavaDoc nullSafeGet(ResultSet JavaDoc rs, String JavaDoc[] names, SessionImplementor session, Object JavaDoc owner)
42             throws HibernateException, SQLException JavaDoc {
43         return get( rs, names[0] );
44     }
45
46     public Object JavaDoc nullSafeGet(ResultSet JavaDoc rs, String JavaDoc name, SessionImplementor session, Object JavaDoc owner)
47             throws HibernateException, SQLException JavaDoc {
48         return get( rs, name );
49     }
50
51     public void nullSafeSet(
52             PreparedStatement JavaDoc st, Object JavaDoc value, int index, boolean[] settable, SessionImplementor session
53             ) throws HibernateException, SQLException JavaDoc {
54         if ( settable[0] ) set(st, value, index, session);
55     }
56
57     protected abstract void set(PreparedStatement JavaDoc st, Object JavaDoc value, int index, SessionImplementor session) throws SQLException JavaDoc;
58
59     public void nullSafeSet(PreparedStatement JavaDoc st, Object JavaDoc value, int index, SessionImplementor session)
60             throws HibernateException, SQLException JavaDoc {
61         set( st, value, index, session );
62     }
63 }
64
Popular Tags