Methods Summary |
---|
public java.lang.Object | accept(ValueVisitor visitor)
return visitor.accept(this);
|
public void | addColumn(Column column)
if ( !columns.contains(column) ) columns.add(column);
column.setValue(this);
column.setTypeIndex( columns.size()-1 );
|
public void | addFormula(Formula formula)
columns.add(formula);
|
public void | createForeignKey()
|
public void | createForeignKeyOfEntity(java.lang.String entityName)
if ( !hasFormula() && !"none".equals(getForeignKeyName())) {
ForeignKey fk = table.createForeignKey( getForeignKeyName(), getConstraintColumns(), entityName );
fk.setCascadeDeleteEnabled(cascadeDeleteEnabled);
}
|
public org.hibernate.id.IdentifierGenerator | createIdentifierGenerator(org.hibernate.dialect.Dialect dialect, java.lang.String defaultCatalog, java.lang.String defaultSchema, RootClass rootClass)
Properties params = new Properties();
//if the hibernate-mapping did not specify a schema/catalog, use the defaults
//specified by properties - but note that if the schema/catalog were specified
//in hibernate-mapping, or as params, they will already be initialized and
//will override the values set here (they are in identifierGeneratorProperties)
if ( defaultSchema!=null ) {
params.setProperty(PersistentIdentifierGenerator.SCHEMA, defaultSchema);
}
if ( defaultCatalog!=null ) {
params.setProperty(PersistentIdentifierGenerator.CATALOG, defaultCatalog);
}
//pass the entity-name, if not a collection-id
if (rootClass!=null) {
params.setProperty( IdentifierGenerator.ENTITY_NAME, rootClass.getEntityName() );
}
//init the table here instead of earlier, so that we can get a quoted table name
//TODO: would it be better to simply pass the qualified table name, instead of
// splitting it up into schema/catalog/table names
String tableName = getTable().getQuotedName(dialect);
params.setProperty( PersistentIdentifierGenerator.TABLE, tableName );
//pass the column name (a generated id almost always has a single column)
String columnName = ( (Column) getColumnIterator().next() ).getQuotedName(dialect);
params.setProperty( PersistentIdentifierGenerator.PK, columnName );
if (rootClass!=null) {
StringBuffer tables = new StringBuffer();
Iterator iter = rootClass.getIdentityTables().iterator();
while ( iter.hasNext() ) {
Table table= (Table) iter.next();
tables.append( table.getQuotedName(dialect) );
if ( iter.hasNext() ) tables.append(", ");
}
params.setProperty( PersistentIdentifierGenerator.TABLES, tables.toString() );
}
else {
params.setProperty( PersistentIdentifierGenerator.TABLES, tableName );
}
if (identifierGeneratorProperties!=null) {
params.putAll(identifierGeneratorProperties);
}
return IdentifierGeneratorFactory.create(
identifierGeneratorStrategy,
getType(),
params,
dialect
);
|
public boolean[] | getColumnInsertability()
boolean[] result = new boolean[ getColumnSpan() ];
int i = 0;
Iterator iter = getColumnIterator();
while ( iter.hasNext() ) {
Selectable s = (Selectable) iter.next();
result[i++] = !s.isFormula();
}
return result;
|
public java.util.Iterator | getColumnIterator()
return columns.iterator();
|
public int | getColumnSpan()
return columns.size();
|
public boolean[] | getColumnUpdateability()
return getColumnInsertability();
|
public java.util.List | getConstraintColumns()
return columns;
|
public org.hibernate.FetchMode | getFetchMode()
return FetchMode.SELECT;
|
public java.lang.String | getForeignKeyName()
return foreignKeyName;
|
public java.util.Properties | getIdentifierGeneratorProperties()
return identifierGeneratorProperties;
|
public java.lang.String | getIdentifierGeneratorStrategy()Returns the identifierGeneratorStrategy.
return identifierGeneratorStrategy;
|
public java.lang.String | getNullValue()
return nullValue;
|
public Table | getTable()
return table;
|
public org.hibernate.type.Type | getType()
if (typeName==null) {
throw new MappingException("No type name");
}
Type result = TypeFactory.heuristicType(typeName, typeParameters);
if (result==null) {
String msg = "Could not determine type for: " + typeName;
if(columns!=null && columns.size()>0) {
msg += ", for columns: " + columns;
}
throw new MappingException(msg);
}
return result;
|
public java.lang.String | getTypeName()
return typeName;
|
public java.util.Properties | getTypeParameters()
return typeParameters;
|
public boolean | hasFormula()
Iterator iter = getColumnIterator();
while ( iter.hasNext() ) {
Object o = iter.next();
if (o instanceof Formula) return true;
}
return false;
|
public boolean | isAlternateUniqueKey()
return alternateUniqueKey;
|
public boolean | isCascadeDeleteEnabled()
return cascadeDeleteEnabled;
|
public boolean | isIdentityColumn(org.hibernate.dialect.Dialect dialect)
return IdentifierGeneratorFactory.getIdentifierGeneratorClass(identifierGeneratorStrategy, dialect)
.equals(IdentityGenerator.class);
|
public boolean | isNullable()
if ( hasFormula() ) return true;
boolean nullable = true;
Iterator iter = getColumnIterator();
while ( iter.hasNext() ) {
if ( !( (Column) iter.next() ).isNullable() ) {
nullable = false;
return nullable; //shortcut
}
}
return nullable;
|
public boolean | isSimpleValue()
return true;
|
public boolean | isTypeSpecified()
return typeName!=null;
|
public boolean | isUpdateable()
//needed to satisfy KeyValue
return true;
|
public boolean | isValid(org.hibernate.engine.Mapping mapping)
return getColumnSpan()==getType().getColumnSpan(mapping);
|
public void | setAlternateUniqueKey(boolean unique)
this.alternateUniqueKey = unique;
|
public void | setCascadeDeleteEnabled(boolean cascadeDeleteEnabled)
this.cascadeDeleteEnabled = cascadeDeleteEnabled;
|
public void | setForeignKeyName(java.lang.String foreignKeyName)
this.foreignKeyName = foreignKeyName;
|
public void | setIdentifierGeneratorProperties(java.util.Properties identifierGeneratorProperties)Sets the identifierGeneratorProperties.
this.identifierGeneratorProperties = identifierGeneratorProperties;
|
public void | setIdentifierGeneratorStrategy(java.lang.String identifierGeneratorStrategy)Sets the identifierGeneratorStrategy.
this.identifierGeneratorStrategy = identifierGeneratorStrategy;
|
public void | setNullValue(java.lang.String nullValue)Sets the nullValue.
this.nullValue = nullValue;
|
public void | setTable(Table table)
this.table = table;
|
public void | setTypeName(java.lang.String type)
this.typeName = type;
|
public void | setTypeParameters(java.util.Properties parameterMap)
this.typeParameters = parameterMap;
|
public void | setTypeUsingReflection(java.lang.String className, java.lang.String propertyName)
if (typeName==null) {
if (className==null) {
throw new MappingException("you must specify types for a dynamic entity: " + propertyName);
}
typeName = ReflectHelper.reflectedPropertyClass(className, propertyName).getName();
}
|
public java.lang.String | toString()
return getClass().getName() + '(" + columns.toString() + ')";
|