KickJava   Java API By Example, From Geeks To Geeks.

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


1 //$Id: AdaptedImmutableType.java,v 1.2 2005/06/20 09:17:00 oneovthafew 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
11 /**
12  * Optimize a mutable type, if the user promises not to mutable the
13  * instances.
14  *
15  * @author Gavin King
16  */

17 public class AdaptedImmutableType extends ImmutableType {
18     
19     private final NullableType mutableType;
20
21     public AdaptedImmutableType(NullableType mutableType) {
22         this.mutableType = mutableType;
23     }
24
25     public Object JavaDoc get(ResultSet JavaDoc rs, String JavaDoc name) throws HibernateException, SQLException JavaDoc {
26         return mutableType.get(rs, name);
27     }
28
29     public void set(PreparedStatement JavaDoc st, Object JavaDoc value, int index) throws HibernateException,
30             SQLException JavaDoc {
31         mutableType.set(st, value, index);
32     }
33
34     public int sqlType() {
35         return mutableType.sqlType();
36     }
37
38     public String JavaDoc toString(Object JavaDoc value) throws HibernateException {
39         return mutableType.toString(value);
40     }
41
42     public Object JavaDoc fromStringValue(String JavaDoc xml) throws HibernateException {
43         return mutableType.fromStringValue(xml);
44     }
45
46     public Class JavaDoc getReturnedClass() {
47         return mutableType.getReturnedClass();
48     }
49
50     public String JavaDoc getName() {
51         return "imm_" + mutableType.getName();
52     }
53     
54     public boolean isEqual(Object JavaDoc x, Object JavaDoc y) {
55         return mutableType.isEqual(x, y);
56     }
57
58     public int getHashCode(Object JavaDoc x, EntityMode entityMode) {
59         return mutableType.getHashCode(x, entityMode);
60     }
61     
62     public int compare(Object JavaDoc x, Object JavaDoc y, EntityMode entityMode) {
63         return mutableType.compare(x, y, entityMode);
64     }
65 }
66
Popular Tags