Subversion Repositories WebE

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
33 PointedEar 1
/*
2
 * Hibernate, Relational Persistence for Idiomatic Java
3
 *
4
 * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
5
 * indicated by the @author tags or express copyright attribution
6
 * statements applied by the authors.  All third-party contributions are
7
 * distributed under license by Red Hat Middleware LLC.
8
 *
9
 * This copyrighted material is made available to anyone wishing to use, modify,
10
 * copy, or redistribute it subject to the terms and conditions of the GNU
11
 * Lesser General Public License, as published by the Free Software Foundation.
12
 *
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15
 * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License
16
 * for more details.
17
 *
18
 * You should have received a copy of the GNU Lesser General Public License
19
 * along with this distribution; if not, write to:
20
 * Free Software Foundation, Inc.
21
 * 51 Franklin Street, Fifth Floor
22
 * Boston, MA  02110-1301  USA
23
 *
24
 */
25
package org.hibernate;
26
 
27
import java.io.Serializable;
28
import java.util.HashMap;
29
import java.util.Map;
30
 
31
/**
32
 * Represents an association fetching strategy. This is used
33
 * together with the <tt>Criteria</tt> API to specify runtime
34
 * fetching strategies.<br>
35
 * <br>
36
 * For HQL queries, use the <tt>FETCH</tt> keyword instead.
37
 *
38
 * @see Criteria#setFetchMode(java.lang.String, FetchMode)
39
 * @author Gavin King
40
 */
41
public final class FetchMode implements Serializable {
42
        private final String name;
43
        private static final Map INSTANCES = new HashMap();
44
 
45
        private FetchMode(String name) {
46
                this.name=name;
47
        }
48
        public String toString() {
49
                return name;
50
        }
51
        /**
52
         * Default to the setting configured in the mapping file.
53
         */
54
        public static final FetchMode DEFAULT = new FetchMode("DEFAULT");
55
 
56
        /**
57
         * Fetch using an outer join. Equivalent to <tt>fetch="join"</tt>.
58
         */
59
        public static final FetchMode JOIN = new FetchMode("JOIN");
60
        /**
61
         * Fetch eagerly, using a separate select. Equivalent to
62
         * <tt>fetch="select"</tt>.
63
         */
64
        public static final FetchMode SELECT = new FetchMode("SELECT");
65
 
66
        /**
67
         * Fetch lazily. Equivalent to <tt>outer-join="false"</tt>.
68
         * @deprecated use <tt>FetchMode.SELECT</tt>
69
         */
70
        public static final FetchMode LAZY = SELECT;
71
        /**
72
         * Fetch eagerly, using an outer join. Equivalent to
73
         * <tt>outer-join="true"</tt>.
74
         * @deprecated use <tt>FetchMode.JOIN</tt>
75
         */
76
        public static final FetchMode EAGER = JOIN;
77
 
78
        static {
79
                INSTANCES.put( JOIN.name, JOIN );
80
                INSTANCES.put( SELECT.name, SELECT );
81
                INSTANCES.put( DEFAULT.name, DEFAULT );
82
        }
83
 
84
        private Object readResolve() {
85
                return INSTANCES.get(name);
86
        }
87
 
88
}
89
 
90
 
91
 
92
 
93