KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > hibernate > ScrollMode


1 //$Id: ScrollMode.java,v 1.1 2004/08/18 00:28:35 oneovthafew Exp $
2
package org.hibernate;
3
4 import java.io.Serializable JavaDoc;
5 import java.sql.ResultSet JavaDoc;
6 import java.util.HashMap JavaDoc;
7 import java.util.Map JavaDoc;
8
9 /**
10  * Specifies the type of JDBC scrollable result set to use
11  * underneath a <tt>ScrollableResults</tt>
12  *
13  * @see Query#scroll(ScrollMode)
14  * @see ScrollableResults
15  * @author Gavin King
16  */

17 public final class ScrollMode implements Serializable JavaDoc {
18     private final int resultSetType;
19     private final String JavaDoc name;
20     private static final Map JavaDoc INSTANCES = new HashMap JavaDoc();
21
22     private ScrollMode(int level, String JavaDoc name) {
23         this.resultSetType=level;
24         this.name=name;
25     }
26     
27     public String JavaDoc toString() {
28         return name;
29     }
30     
31     /**
32      * @return the JDBC result set type code
33      */

34     public int toResultSetType() {
35         return resultSetType;
36     }
37     
38     /**
39      * @see java.sql.ResultSet.TYPE_FORWARD_ONLY
40      */

41     public static final ScrollMode FORWARD_ONLY = new ScrollMode(ResultSet.TYPE_FORWARD_ONLY, "FORWARD_ONLY");
42     /**
43      * @see java.sql.ResultSet.TYPE_SCROLL_SENSITIVE
44      */

45     public static final ScrollMode SCROLL_SENSITIVE = new ScrollMode(ResultSet.TYPE_SCROLL_SENSITIVE, "SCROLL_SENSITIVE");
46     /**
47      * Note that since the Hibernate session acts as a cache, you
48      * might need to expicitly evict objects, if you need to see
49      * changes made by other transactions.
50      * @see java.sql.ResultSet.TYPE_SCROLL_INSENSITIVE
51      */

52     public static final ScrollMode SCROLL_INSENSITIVE = new ScrollMode(ResultSet.TYPE_SCROLL_INSENSITIVE, "SCROLL_INSENSITIVE");
53     
54     public boolean lessThan(ScrollMode other) {
55         return this.resultSetType<other.resultSetType;
56     }
57
58     static {
59         INSTANCES.put( FORWARD_ONLY.name, FORWARD_ONLY );
60         INSTANCES.put( SCROLL_INSENSITIVE.name, SCROLL_INSENSITIVE );
61         INSTANCES.put( SCROLL_SENSITIVE.name, SCROLL_SENSITIVE );
62     }
63
64     private Object JavaDoc readResolve() {
65         return INSTANCES.get(name);
66     }
67
68 }
69
70
71
72
73
74
75
Popular Tags