FileDocCategorySizeDatePackage
IdentifierCollection.javaAPI DocHibernate 3.2.51445Sat Aug 07 23:56:02 BST 2004org.hibernate.mapping

IdentifierCollection

public abstract class IdentifierCollection extends Collection
A collection with a synthetic "identifier" column

Fields Summary
public static final String
DEFAULT_IDENTIFIER_COLUMN_NAME
private KeyValue
identifier
Constructors Summary
public IdentifierCollection(PersistentClass owner)


	   
		super(owner);
	
Methods Summary
voidcreatePrimaryKey()

		if ( !isOneToMany() ) {
			PrimaryKey pk = new PrimaryKey();
			pk.addColumns( getIdentifier().getColumnIterator() );
			getCollectionTable().setPrimaryKey(pk);
		}
		else {
			// don't create a unique key, 'cos some
			// databases don't like a UK on nullable
			// columns
			//getCollectionTable().createUniqueKey( getIdentifier().getConstraintColumns() );
		}
		// create an index on the key columns??
	
public KeyValuegetIdentifier()

		return identifier;
	
public final booleanisIdentified()

		return true;
	
public voidsetIdentifier(KeyValue identifier)

		this.identifier = identifier;
	
public voidvalidate(org.hibernate.engine.Mapping mapping)

		super.validate(mapping);
		if ( !getIdentifier().isValid(mapping) ) {
			throw new MappingException(
				"collection id mapping has wrong number of columns: " +
				getRole() +
				" type: " +
				getIdentifier().getType().getName()
			);
		}