public interface CmIndexDefinition extends RepositoryObject, EngineObject, DependentObject
Using the properties on this class, you can:
Note that these properties are all SETTABLE_ONLY_ON_CREATE. Therefore, instances of
CmIndexDefinition
are immutable once created. To change an index, you must delete the existing CmIndexDefinition
instance
(which results in the index being dropped from the database), and then create a new instance with the required changes.
If you create a CmIndexDefinition
object for a manually created index (an index that a database administrator
created using the native database tools), the name specified for the CmIndexDefinition
object must be the same as the name
for the manually created index. The server will detect that the physical index already exists and, in such cases, will
update only the metadata in the tables (skipping the actual index creation but performing the index definition creation).
The following code creates a unique index on the columns representing the two properties cr1s, cr5s of the myCustomClass class. The columns appear in the index in the same order as the properties appear in the class definition.
// Get TableDefinition to add compound index. ClassDefinition classDef= Factory.ClassDefinition.fetchInstance(os, "myCustomClass", null); TableDefinition td = classDef.get_TableDefinition(); // Create CmIndexedColumnList for columns to be indexed. CmIndexedColumnList indCols = Factory.CmIndexedColumn.createList(); // Get PropertyDefinitions for class. PropertyDefinitionList propDefs = classDef.get_PropertyDefinitions(); // Iterate PropertiesDefinitionList in search of properties // that correspond with the two columns to be indexed. Iterator iter = propDefs.iterator(); while (iter.hasNext()) { PropertyDefinition propDef = (PropertyDefinition) iter.next(); if (propDef.get_SymbolicName().equals("cr1s") || propDef.get_SymbolicName().equals("cr5s")) { // Iterate column definitions to add target columns to list. ColumnDefinitionList colDefs = td.get_ColumnDefinitions(); Iterator iter2 = colDefs.iterator(); while (iter2.hasNext()) { ColumnDefinition colDef = (ColumnDefinition) iter2.next(); if (propDef.get_ColumnId().equals(colDef.get_Id())) { CmIndexedColumn indCol = Factory.CmIndexedColumn.createInstance(); indCol.set_ColumnName(colDef.get_ColumnName()); SortOrder sortValue = propName.equals("cr1s") ? SortOrder.ASCENDING : SortOrder.DESCENDING; indCol.set_SortOrder(sortValue); indCols.add(indCol); break; } } } } // Create CmIndexDefinition and set columns to be indexed and other properties. CmIndexDefinitionList indDefs = td.get_IndexDefinitions(); CmIndexDefinition indDef = Factory.CmIndexDefinition.createInstance(); indDef.set_RequiresUniqueElements(java.lang.Boolean.TRUE); indDef.set_ForCaseInsensitiveSearch(java.lang.Boolean.FALSE); indDef.set_IndexedColumns(indCols); indDefs.add(indDef); // Set index definition on table and save. td.set_IndexDefinitions(indDefs); td.save(RefreshMode.NO_REFRESH);
Modifier and Type | Method and Description |
---|---|
java.lang.String |
get_DatabaseIndexStorageLocation()
Returns the value of the DatabaseIndexStorageLocation property.
|
java.lang.Boolean |
get_ForCaseInsensitiveSearch()
Returns the value of the ForCaseInsensitiveSearch property.
|
Id |
get_Id()
Returns the value of the Id property.
|
CmIndexedColumnList |
get_IndexedColumns()
Returns the value of the IndexedColumns property.
|
java.lang.String |
get_IndexName()
Returns the value of the IndexName property.
|
java.lang.Boolean |
get_IsSystemOwned()
Returns the value of the IsSystemOwned property.
|
java.lang.Boolean |
get_RequiresUniqueElements()
Returns the value of the RequiresUniqueElements property.
|
void |
set_DatabaseIndexStorageLocation(java.lang.String value)
Sets the value of the DatabaseIndexStorageLocation property.
|
void |
set_ForCaseInsensitiveSearch(java.lang.Boolean value)
Sets the value of the ForCaseInsensitiveSearch property.
|
void |
set_IndexedColumns(CmIndexedColumnList value)
Sets the value of the IndexedColumns property.
|
void |
set_IndexName(java.lang.String value)
Sets the value of the IndexName property.
|
void |
set_RequiresUniqueElements(java.lang.Boolean value)
Sets the value of the RequiresUniqueElements property.
|
getObjectStore
get_ClassDescription, getClassName, getConnection, getProperties, getSuperClasses
Id get_Id()
java.lang.Boolean get_IsSystemOwned()
java.lang.String get_IndexName()
void set_IndexName(java.lang.String value)
java.lang.String get_DatabaseIndexStorageLocation()
void set_DatabaseIndexStorageLocation(java.lang.String value)
java.lang.Boolean get_RequiresUniqueElements()
void set_RequiresUniqueElements(java.lang.Boolean value)
java.lang.Boolean get_ForCaseInsensitiveSearch()
void set_ForCaseInsensitiveSearch(java.lang.Boolean value)
CmIndexedColumnList get_IndexedColumns()
void set_IndexedColumns(CmIndexedColumnList value)
© Copyright IBM Corporation 2006, 2015. All rights reserved.