1
//$Id: IdentifierCollection.java 4173 2004-08-08 04:56:01Z oneovthafew $
2
package org.hibernate.mapping;
4
import org.hibernate.MappingException;
5
import org.hibernate.engine.Mapping;
8
* A collection with a synthetic "identifier" column
10
public abstract class IdentifierCollection extends Collection {
12
public static final String DEFAULT_IDENTIFIER_COLUMN_NAME = "id";
14
private KeyValue identifier;
16
public IdentifierCollection(PersistentClass owner) {
20
public KeyValue getIdentifier() {
23
public void setIdentifier(KeyValue identifier) {
24
this.identifier = identifier;
26
public final boolean isIdentified() {
30
void createPrimaryKey() {
31
if ( !isOneToMany() ) {
32
PrimaryKey pk = new PrimaryKey();
33
pk.addColumns( getIdentifier().getColumnIterator() );
34
getCollectionTable().setPrimaryKey(pk);
37
// don't create a unique key, 'cos some
38
// databases don't like a UK on nullable
40
//getCollectionTable().createUniqueKey( getIdentifier().getConstraintColumns() );
42
// create an index on the key columns??
45
public void validate(Mapping mapping) throws MappingException {
46
super.validate(mapping);
47
if ( !getIdentifier().isValid(mapping) ) {
48
throw new MappingException(
49
"collection id mapping has wrong number of columns: " +
52
getIdentifier().getType().getName()