KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > hibernate > FetchMode


1 //$Id: FetchMode.java,v 1.3 2004/12/24 03:11:02 oneovthafew Exp $
2
package org.hibernate;
3
4 import java.io.Serializable JavaDoc;
5 import java.util.HashMap JavaDoc;
6 import java.util.Map JavaDoc;
7
8 /**
9  * Represents an association fetching strategy. This is used
10  * together with the <tt>Criteria</tt> API to specify runtime
11  * fetching strategies.<br>
12  * <br>
13  * For HQL queries, use the <tt>FETCH</tt> keyword instead.
14  *
15  * @see Criteria#setFetchMode(java.lang.String, FetchMode)
16  * @author Gavin King
17  */

18 public final class FetchMode implements Serializable JavaDoc {
19     private final String JavaDoc name;
20     private static final Map JavaDoc INSTANCES = new HashMap JavaDoc();
21
22     private FetchMode(String JavaDoc name) {
23         this.name=name;
24     }
25     public String JavaDoc toString() {
26         return name;
27     }
28     /**
29      * Default to the setting configured in the mapping file.
30      */

31     public static final FetchMode DEFAULT = new FetchMode("DEFAULT");
32
33     /**
34      * Fetch using an outer join. Equivalent to <tt>fetch="join"</tt>.
35      */

36     public static final FetchMode JOIN = new FetchMode("JOIN");
37     /**
38      * Fetch eagerly, using a separate select. Equivalent to
39      * <tt>fetch="select"</tt>.
40      */

41     public static final FetchMode SELECT = new FetchMode("SELECT");
42
43     /**
44      * Fetch lazily. Equivalent to <tt>outer-join="false"</tt>.
45      * @deprecated use <tt>FetchMode.SELECT</tt>
46      */

47     public static final FetchMode LAZY = SELECT;
48     /**
49      * Fetch eagerly, using an outer join. Equivalent to
50      * <tt>outer-join="true"</tt>.
51      * @deprecated use <tt>FetchMode.JOIN</tt>
52      */

53     public static final FetchMode EAGER = JOIN;
54     
55     static {
56         INSTANCES.put( JOIN.name, JOIN );
57         INSTANCES.put( SELECT.name, SELECT );
58         INSTANCES.put( DEFAULT.name, DEFAULT );
59     }
60
61     private Object JavaDoc readResolve() {
62         return INSTANCES.get(name);
63     }
64
65 }
66
67
68
69
70
71
Popular Tags