identifiercollection.java
来自「好东西,hibernate-3.2.0,他是一开元的树杖hibernate-3.」· Java 代码 · 共 65 行
JAVA
65 行
//$Id: IdentifierCollection.java 4173 2004-08-08 04:56:01Z oneovthafew $
package org.hibernate.mapping;
import org.hibernate.MappingException;
import org.hibernate.engine.Mapping;
/**
* A collection with a synthetic "identifier" column
*/
public abstract class IdentifierCollection extends Collection {
public static final String DEFAULT_IDENTIFIER_COLUMN_NAME = "id";
private KeyValue identifier;
public IdentifierCollection(PersistentClass owner) {
super(owner);
}
public KeyValue getIdentifier() {
return identifier;
}
public void setIdentifier(KeyValue identifier) {
this.identifier = identifier;
}
public final boolean isIdentified() {
return true;
}
void createPrimaryKey() {
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 void validate(Mapping mapping) throws MappingException {
super.validate(mapping);
if ( !getIdentifier().isValid(mapping) ) {
throw new MappingException(
"collection id mapping has wrong number of columns: " +
getRole() +
" type: " +
getIdentifier().getType().getName()
);
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?