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

📄 collection.java

📁 hibernate-distribution-3.3.1.GA-dist.zip源码
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* * Hibernate, Relational Persistence for Idiomatic Java * * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as * indicated by the @author tags or express copyright attribution * statements applied by the authors.  All third-party contributions are * distributed under license by Red Hat Middleware LLC. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA  02110-1301  USA * */package org.hibernate.mapping;import java.util.Comparator;import java.util.HashMap;import java.util.HashSet;import java.util.Iterator;import java.util.Properties;import org.hibernate.FetchMode;import org.hibernate.MappingException;import org.hibernate.engine.Mapping;import org.hibernate.engine.ExecuteUpdateResultCheckStyle;import org.hibernate.type.CollectionType;import org.hibernate.type.Type;import org.hibernate.type.TypeFactory;import org.hibernate.util.ArrayHelper;import org.hibernate.util.EmptyIterator;import org.hibernate.util.ReflectHelper;/** * Mapping for a collection. Subclasses specialize to particular collection styles. *  * @author Gavin King */public abstract class Collection implements Fetchable, Value, Filterable {	public static final String DEFAULT_ELEMENT_COLUMN_NAME = "elt";	public static final String DEFAULT_KEY_COLUMN_NAME = "id";	private KeyValue key;	private Value element;	private Table collectionTable;	private String role;	private boolean lazy;	private boolean extraLazy;	private boolean inverse;	private boolean mutable = true;	private boolean subselectLoadable;	private String cacheConcurrencyStrategy;	private String cacheRegionName;	private String orderBy;	private String where;	private String manyToManyWhere;	private String manyToManyOrderBy;	private PersistentClass owner;	private String referencedPropertyName;	private String nodeName;	private String elementNodeName;	private boolean sorted;	private Comparator comparator;	private String comparatorClassName;	private boolean orphanDelete;	private int batchSize = -1;	private FetchMode fetchMode;	private boolean embedded = true;	private boolean optimisticLocked = true;	private Class collectionPersisterClass;	private String typeName;	private Properties typeParameters;	private final java.util.Map filters = new HashMap();	private final java.util.Map manyToManyFilters = new HashMap();	private final java.util.Set synchronizedTables = new HashSet();	private String customSQLInsert;	private boolean customInsertCallable;	private ExecuteUpdateResultCheckStyle insertCheckStyle;	private String customSQLUpdate;	private boolean customUpdateCallable;	private ExecuteUpdateResultCheckStyle updateCheckStyle;	private String customSQLDelete;	private boolean customDeleteCallable;	private ExecuteUpdateResultCheckStyle deleteCheckStyle;	private String customSQLDeleteAll;	private boolean customDeleteAllCallable;	private ExecuteUpdateResultCheckStyle deleteAllCheckStyle;	private String loaderName;	protected Collection(PersistentClass owner) {		this.owner = owner;	}	public boolean isSet() {		return false;	}	public KeyValue getKey() {		return key;	}	public Value getElement() {		return element;	}	public boolean isIndexed() {		return false;	}	public Table getCollectionTable() {		return collectionTable;	}	public void setCollectionTable(Table table) {		this.collectionTable = table;	}	public boolean isSorted() {		return sorted;	}	public Comparator getComparator() {		if ( comparator == null && comparatorClassName != null ) {			try {				setComparator( (Comparator) ReflectHelper.classForName( comparatorClassName ).newInstance() );			}			catch ( Exception e ) {				throw new MappingException(						"Could not instantiate comparator class [" + comparatorClassName						+ "] for collection " + getRole()  				);			}		}		return comparator;	}	public boolean isLazy() {		return lazy;	}	public void setLazy(boolean lazy) {		this.lazy = lazy;	}	public String getRole() {		return role;	}	public abstract CollectionType getDefaultCollectionType() throws MappingException;	public boolean isPrimitiveArray() {		return false;	}	public boolean isArray() {		return false;	}	public boolean hasFormula() {		return false;	}	public boolean isOneToMany() {		return element instanceof OneToMany;	}	public boolean isInverse() {		return inverse;	}	public String getOwnerEntityName() {		return owner.getEntityName();	}	public String getOrderBy() {		return orderBy;	}	public void setComparator(Comparator comparator) {		this.comparator = comparator;	}	public void setElement(Value element) {		this.element = element;	}	public void setKey(KeyValue key) {		this.key = key;	}	public void setOrderBy(String orderBy) {		this.orderBy = orderBy;	}	public void setRole(String role) {		this.role = role==null ? null : role.intern();	}	public void setSorted(boolean sorted) {		this.sorted = sorted;	}	public void setInverse(boolean inverse) {		this.inverse = inverse;	}	public PersistentClass getOwner() {		return owner;	}	public void setOwner(PersistentClass owner) {		this.owner = owner;	}	public String getWhere() {		return where;	}	public void setWhere(String where) {		this.where = where;	}	public String getManyToManyWhere() {		return manyToManyWhere;	}	public void setManyToManyWhere(String manyToManyWhere) {		this.manyToManyWhere = manyToManyWhere;	}	public String getManyToManyOrdering() {		return manyToManyOrderBy;	}	public void setManyToManyOrdering(String orderFragment) {		this.manyToManyOrderBy = orderFragment;	}	public boolean isIdentified() {		return false;	}	public boolean hasOrphanDelete() {		return orphanDelete;	}	public void setOrphanDelete(boolean orphanDelete) {		this.orphanDelete = orphanDelete;	}	public int getBatchSize() {		return batchSize;	}	public void setBatchSize(int i) {		batchSize = i;	}	public FetchMode getFetchMode() {		return fetchMode;	}	public void setFetchMode(FetchMode fetchMode) {		this.fetchMode = fetchMode;	}	public void setCollectionPersisterClass(Class persister) {		this.collectionPersisterClass = persister;	}	public Class getCollectionPersisterClass() {		return collectionPersisterClass;	}	public void validate(Mapping mapping) throws MappingException {		if ( getKey().isCascadeDeleteEnabled() && ( !isInverse() || !isOneToMany() ) ) {			throw new MappingException(				"only inverse one-to-many associations may use on-delete=\"cascade\": " 				+ getRole() );		}		if ( !getKey().isValid( mapping ) ) {			throw new MappingException(				"collection foreign key mapping has wrong number of columns: "				+ getRole()				+ " type: "				+ getKey().getType().getName() );		}		if ( !getElement().isValid( mapping ) ) {			throw new MappingException( 				"collection element mapping has wrong number of columns: "				+ getRole()				+ " type: "				+ getElement().getType().getName() );		}		checkColumnDuplication();				if ( elementNodeName!=null && elementNodeName.startsWith("@") ) {			throw new MappingException("element node must not be an attribute: " + elementNodeName );		}		if ( elementNodeName!=null && elementNodeName.equals(".") ) {			throw new MappingException("element node must not be the parent: " + elementNodeName );		}		if ( nodeName!=null && nodeName.indexOf('@')>-1 ) {			throw new MappingException("collection node must not be an attribute: " + elementNodeName );		}	}	private void checkColumnDuplication(java.util.Set distinctColumns, Iterator columns)			throws MappingException {

⌨️ 快捷键说明

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