⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 subclass.java

📁 用Java实现的23个常用设计模式源代码
💻 JAVA
字号:
//$Id: Subclass.java,v 1.10.2.2 2003/11/12 02:43:48 oneovthafew Exp $package net.sf.hibernate.mapping;import java.util.Collections;import java.util.Iterator;import net.sf.hibernate.MappingException;import net.sf.hibernate.cache.CacheConcurrencyStrategy;import net.sf.hibernate.engine.Mapping;import net.sf.hibernate.util.JoinedIterator;/** * A sublass in a table-per-subclass, or table-per-concrete-class * inheritance hierarchy. * @author Gavin King */public class Subclass extends PersistentClass {		private PersistentClass superclass;	private SimpleValue key;		public Subclass(PersistentClass superclass) {		this.superclass = superclass;	}		public CacheConcurrencyStrategy getCache() {		return getSuperclass().getCache();	}		public RootClass getRootClass() {		return getSuperclass().getRootClass();	}		public PersistentClass getSuperclass() {		return superclass;	}		public Property getIdentifierProperty() {		return getSuperclass().getIdentifierProperty();	}	public SimpleValue getIdentifier() {		return getSuperclass().getIdentifier();	}	public boolean hasIdentifierProperty() {		return getSuperclass().hasIdentifierProperty();	}	public Value getDiscriminator() {		return getSuperclass().getDiscriminator();	}	public boolean isMutable() {		return getSuperclass().isMutable();	}	public boolean isInherited() {		return true;	}	public boolean isPolymorphic() {		return true;	}		public void addProperty(Property p) {		super.addProperty(p);		getSuperclass().addSubclassProperty(p);	}	public void setTable(Table table) {		super.setTable(table);		getSuperclass().addSubclassTable(table);	}	public Iterator getPropertyClosureIterator() {		return new JoinedIterator( new Iterator[] {			getPropertyIterator(),			getSuperclass().getPropertyClosureIterator() }		);	}	public Iterator getTableClosureIterator() {		return new JoinedIterator( new Iterator[] {			getSuperclass().getTableClosureIterator(),			Collections.singleton( getTable() ).iterator()		} );	}	protected void addSubclassProperty(Property p) {		super.addSubclassProperty(p);		getSuperclass().addSubclassProperty(p);	}		protected void addSubclassTable(Table table) {		super.addSubclassTable(table);		getSuperclass().addSubclassTable(table);	}		public boolean isVersioned() {		return getSuperclass().isVersioned();	}	public Property getVersion() {		return getSuperclass().getVersion();	}		public boolean hasEmbeddedIdentifier() {		return getSuperclass().hasEmbeddedIdentifier();	}	public Class getClassPersisterClass() {		return getSuperclass().getClassPersisterClass();	}		public Table getRootTable() {		return getSuperclass().getRootTable();	}		public SimpleValue getKey() {		if (key==null) {			return getIdentifier();		}		else {			return key;		}	}		public boolean isExplicitPolymorphism() {		return getSuperclass().isExplicitPolymorphism();	}		/**	 * Sets the key.	 * @param key The key to set	 */	public void setKey(SimpleValue key) {		this.key = key;	}	/**	 * Sets the superclass.	 * @param superclass The superclass to set	 */	public void setSuperclass(PersistentClass superclass) {		this.superclass = superclass;	}		public String getWhere() {		return getSuperclass().getWhere();	}	public void validate(Mapping mapping) throws MappingException {		super.validate(mapping);		if ( key!=null && !key.isValid(mapping) ) {			throw new MappingException(				"subclass key mapping has wrong number of columns: " + 				getMappedClass().getName() +				" type: " + 				key.getType().getName()			);		}	}}

⌨️ 快捷键说明

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