FileDocCategorySizeDatePackage
Set.javaAPI DocHibernate 3.2.52349Mon Aug 01 11:29:34 BST 2005org.hibernate.mapping

Set

public class Set extends Collection
A set with no nullable element columns. It will have a primary key consisting of all table columns (ie. key columns + element columns).
author
Gavin King

Fields Summary
Constructors Summary
public Set(PersistentClass owner)
Constructor for Set.

param
owner

		super(owner);
	
Methods Summary
public java.lang.Objectaccept(ValueVisitor visitor)

		return visitor.accept(this);
	
voidcreatePrimaryKey()

		if ( !isOneToMany() ) {
			PrimaryKey pk = new PrimaryKey();
			pk.addColumns( getKey().getColumnIterator() );
			Iterator iter = getElement().getColumnIterator();
			while ( iter.hasNext() ) {
				Object selectable = iter.next();
				if ( selectable instanceof Column ) {
					Column col = (Column) selectable;
					if ( !col.isNullable() ) {
						pk.addColumn(col);
					}
				}
			}
			if ( pk.getColumnSpan()==getKey().getColumnSpan() ) { 
				//for backward compatibility, allow a set with no not-null 
				//element columns, using all columns in the row locater SQL
				//TODO: create an implicit not null constraint on all cols?
			}
			else {
				getCollectionTable().setPrimaryKey(pk);
			}
		}
		else {
			//create an index on the key columns??
		}
	
public org.hibernate.type.CollectionTypegetDefaultCollectionType()

		if ( isSorted() ) {
			return TypeFactory.sortedSet( getRole(), getReferencedPropertyName(), isEmbedded(), getComparator() );
		}
		else if ( hasOrder() ) {
			return TypeFactory.orderedSet( getRole(), getReferencedPropertyName(), isEmbedded() );
		}
		else {
			return TypeFactory.set( getRole(), getReferencedPropertyName(), isEmbedded() );
		}
	
public booleanisSet()

		return true;
	
public voidvalidate(org.hibernate.engine.Mapping mapping)

		super.validate( mapping );
		//for backward compatibility, disable this:
		/*Iterator iter = getElement().getColumnIterator();
		while ( iter.hasNext() ) {
			Column col = (Column) iter.next();
			if ( !col.isNullable() ) {
				return;
			}
		}
		throw new MappingException("set element mappings must have at least one non-nullable column: " + getRole() );*/