FileDocCategorySizeDatePackage
Index.javaAPI DocHibernate 3.2.53540Mon Oct 30 19:18:40 GMT 2006org.hibernate.mapping

Index

public class Index extends Object implements Serializable, RelationalModel
A relational table index
author
Gavin King

Fields Summary
private Table
table
private List
columns
private String
name
Constructors Summary
Methods Summary
public voidaddColumn(Column column)

		if ( !columns.contains( column ) ) columns.add( column );
	
public voidaddColumns(java.util.Iterator extraColumns)

		while ( extraColumns.hasNext() ) addColumn( (Column) extraColumns.next() );
	
public static java.lang.StringbuildSqlCreateIndexString(org.hibernate.dialect.Dialect dialect, java.lang.String name, Table table, java.util.Iterator columns, boolean unique, java.lang.String defaultCatalog, java.lang.String defaultSchema)

		//TODO handle supportsNotNullUnique=false, but such a case does not exist in the wild so far
		StringBuffer buf = new StringBuffer( "create" )
				.append( unique ?
						" unique" :
						"" )
				.append( " index " )
				.append( dialect.qualifyIndexName() ?
						name :
						StringHelper.unqualify( name ) )
				.append( " on " )
				.append( table.getQualifiedName( dialect, defaultCatalog, defaultSchema ) )
				.append( " (" );
		Iterator iter = columns;
		while ( iter.hasNext() ) {
			buf.append( ( (Column) iter.next() ).getQuotedName( dialect ) );
			if ( iter.hasNext() ) buf.append( ", " );
		}
		buf.append( ")" );
		return buf.toString();
	
public static java.lang.StringbuildSqlDropIndexString(org.hibernate.dialect.Dialect dialect, Table table, java.lang.String name, java.lang.String defaultCatalog, java.lang.String defaultSchema)

		return "drop index " +
				StringHelper.qualify(
						table.getQualifiedName( dialect, defaultCatalog, defaultSchema ),
						name
				);
	
public booleancontainsColumn(Column column)

param
column
return
true if this constraint already contains a column with same name.

		return columns.contains( column );
	
public java.util.IteratorgetColumnIterator()

		return columns.iterator();
	
public intgetColumnSpan()

		return columns.size();
	
public java.lang.StringgetName()

		return name;
	
public TablegetTable()

		return table;
	
public voidsetName(java.lang.String name)

		this.name = name;
	
public voidsetTable(Table table)

		this.table = table;
	
public java.lang.StringsqlConstraintString(org.hibernate.dialect.Dialect dialect)

		StringBuffer buf = new StringBuffer( " index (" );
		Iterator iter = getColumnIterator();
		while ( iter.hasNext() ) {
			buf.append( ( (Column) iter.next() ).getQuotedName( dialect ) );
			if ( iter.hasNext() ) buf.append( ", " );
		}
		return buf.append( ')" ).toString();
	
public java.lang.StringsqlCreateString(org.hibernate.dialect.Dialect dialect, org.hibernate.engine.Mapping mapping, java.lang.String defaultCatalog, java.lang.String defaultSchema)


	         
			  
		return buildSqlCreateIndexString(
				dialect,
				getName(),
				getTable(),
				getColumnIterator(),
				false,
				defaultCatalog,
				defaultSchema
		);
	
public java.lang.StringsqlDropString(org.hibernate.dialect.Dialect dialect, java.lang.String defaultCatalog, java.lang.String defaultSchema)

		return "drop index " +
				StringHelper.qualify(
						table.getQualifiedName( dialect, defaultCatalog, defaultSchema ),
						name
				);
	
public java.lang.StringtoString()

		return getClass().getName() + "(" + getName() + ")";