fetchmode.java

来自「用Java实现的23个常用设计模式源代码」· Java 代码 · 共 60 行

JAVA
60
字号
//$Id: FetchMode.java,v 1.3 2003/06/15 12:45:04 oneovthafew Exp $package net.sf.hibernate;import java.io.Serializable;import java.util.HashMap;import java.util.Map;/** * Represents an association fetching strategy. This is used * together with the <tt>Criteria</tt> API to specify runtime  * fetching strategies.<br> * <br> * For HQL queries, use the <tt>FETCH</tt> keyword instead. * * @see Criteria#setFetchMode(java.lang.String, FetchMode) * @author Gavin King */public final class FetchMode implements Serializable {	private final int level;	private final String name;	private static final Map INSTANCES = new HashMap();		private FetchMode(int level, String name) {		this.level=level;		this.name=name;	}	public String toString() {		return name;	}	/**	 * Fetch lazily. Equivalent to <tt>outer-join="false"</tt>.	 */	public static final FetchMode LAZY = new FetchMode(1, "LAZY");	/**	 * Fetch eagerly, using an outer join. Equivalent to 	 * <tt>outer-join="true"</tt>.	 */	public static final FetchMode EAGER = new FetchMode(2, "EAGER");	/**	 * Default to the setting configured in the mapping file.	 */	public static final FetchMode DEFAULT = new FetchMode(0, "DEFAULT");		static {		INSTANCES.put( new Integer(LAZY.level), LAZY );		INSTANCES.put( new Integer(EAGER.level), EAGER );		INSTANCES.put( new Integer(DEFAULT.level), DEFAULT );	}		private Object readResolve() {		return INSTANCES.get( new Integer(level) );	}	}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?