本文整理了Java中org.hibernate.mapping.Index
类的一些代码示例,展示了Index
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Index
类的具体详情如下:
包路径:org.hibernate.mapping.Index
类名称:Index
[英]A relational table index
[中]关系表索引
代码示例来源:origin: hibernate/hibernate-orm
@Override
public Iterator getIndexIterator() {
List indexes = new ArrayList();
Iterator iter = includedTable.getIndexIterator();
while ( iter.hasNext() ) {
Index parentIndex = (Index) iter.next();
Index index = new Index();
index.setName( getName() + parentIndex.getName() );
index.setTable( this );
index.addColumns( parentIndex.getColumnIterator() );
indexes.add( index );
}
return new JoinedIterator(
indexes.iterator(),
super.getIndexIterator()
);
}
代码示例来源:origin: hibernate/hibernate-orm
keyName = keyNameIdentifier.render( getDatabase().getJdbcEnvironment().getDialect() );
UniqueKey uk = table.getOrCreateUniqueKey( keyName );
for ( int i = 0; i < columns.length; i++ ) {
Column column = columns[i];
String order = orderings != null ? orderings[i] : null;
if ( table.containsColumn( column ) ) {
uk.addColumn( column, order );
unbound.remove( column );
keyName = keyNameIdentifier.render( getDatabase().getJdbcEnvironment().getDialect() );
Index index = table.getOrCreateIndex( keyName );
for ( int i = 0; i < columns.length; i++ ) {
Column column = columns[i];
String order = orderings != null ? orderings[i] : null;
if ( table.containsColumn( column ) ) {
index.addColumn( column, order );
unbound.remove( column );
代码示例来源:origin: hibernate/hibernate-orm
@Test
public void testCollectionTableIndex(){
PersistentClass entity = metadata().getEntityBinding( Car.class.getName() );
Property property = entity.getProperty( "otherDealers" );
Set set = (Set)property.getValue();
Table collectionTable = set.getCollectionTable();
Iterator<Index> itr = collectionTable.getIndexIterator();
assertTrue( itr.hasNext() );
Index index = itr.next();
assertFalse( itr.hasNext() );
assertTrue( "index name is not generated", StringHelper.isNotEmpty( index.getName() ) );
assertEquals( 1, index.getColumnSpan() );
Iterator<Column> columnIterator = index.getColumnIterator();
Column column = columnIterator.next();
assertEquals( "name", column.getName() );
assertSame( collectionTable, index.getTable() );
}
代码示例来源:origin: hibernate/hibernate-orm
public String sqlCreateString(Dialect dialect, Mapping mapping, String defaultCatalog, String defaultSchema)
throws HibernateException {
return buildSqlCreateIndexString(
dialect,
getQuotedName( dialect ),
getTable(),
getColumnIterator(),
columnOrderMap,
false,
defaultCatalog,
defaultSchema
);
}
代码示例来源:origin: hibernate/hibernate-orm
public Index getOrCreateIndex(String indexName) {
Index index = indexes.get( indexName );
if ( index == null ) {
index = new Index();
index.setName( indexName );
index.setTable( this );
indexes.put( indexName, index );
}
return index;
}
代码示例来源:origin: hibernate/hibernate-orm
@Override
public String getExportIdentifier() {
return StringHelper.qualify( getTable().getExportIdentifier(), "IDX-" + getName() );
}
}
代码示例来源:origin: org.hibernate/com.springsource.org.hibernate.core
while ( iter.hasNext() ) {
Table table = (Table) iter.next();
if ( table.isPhysicalTable() ) {
table.getName(),
( table.getSchema() == null ) ? defaultSchema : table.getSchema(),
( table.getCatalog() == null ) ? defaultCatalog : table.getCatalog(),
table.isQuoted()
final Index index = (Index) subIter.next();
if ( tableInfo != null && StringHelper.isNotEmpty( index.getName() ) ) {
final IndexMetadata meta = tableInfo.getIndexMetadata( index.getName() );
if ( meta != null ) {
continue;
index.sqlCreateString(
dialect,
mapping,
代码示例来源:origin: org.hibernate/hibernate-tools
try {
Map<String,Object> indexRs = null;
indexIterator = metaDataDialect.getIndexInfo(getCatalogForDBLookup(table.getCatalog(), defaultCatalog), getSchemaForDBLookup(table.getSchema(), defaultSchema), table.getName());
Index index = indexes.get(indexName);
if(index==null) {
index = new Index();
index.setName(indexName);
index.setTable(table);
table.addIndex(index);
indexes.put(indexName, index);
index.addColumn(column);
代码示例来源:origin: hibernate/hibernate-tools
Assert.assertEquals(
JdbcUtil.toIdentifier(this, "WITH_INDEX"),
JdbcUtil.toIdentifier(this, table.getName()));
Assert.assertNull("there should be no pk", table.getPrimaryKey() );
Iterator<Index> iterator = table.getIndexIterator();
int cnt=0;
while(iterator.hasNext() ) {
Assert.assertEquals(
JdbcUtil.toIdentifier(this, "MY_INDEX"),
JdbcUtil.toIdentifier(this, index.getName()));
Assert.assertEquals(2, index.getColumnSpan() );
Assert.assertSame(index.getTable(), table);
Iterator<Column> cols = index.getColumnIterator();
Column col1 = cols.next();
Column col2 = cols.next();
代码示例来源:origin: hibernate/hibernate-ogm
/**
* Constructor used for {@link Index}es.
*/
public MongoDBIndexSpec(Index index, Document options) {
this.indexType = determineIndexType( options );
this.options = prepareOptions( this.indexType, options, index.getName(), false );
this.collection = index.getTable().getName();
this.indexName = index.getName();
// TODO OGM-1080: the columnOrderMap is not accessible for an Index
this.addIndexKeys( index.getColumnIterator(), Collections.<Column, String>emptyMap() );
}
代码示例来源:origin: Jasig/uPortal
if ("table".equals(name)) {
for (final Column column : this.currentColumns.values()) {
this.currentTable.addColumn(column);
this.currentTable.setPrimaryKey(this.primaryKey);
this.tables.put(this.currentTable.getName(), this.currentTable);
this.tableColumnTypes.put(this.currentTable.getName(), this.currentColumnTypes);
this.primaryKey = null;
this.currentIndex.setName(itemName);
} else if (this.currentUnique != null) {
this.currentUnique.setName(itemName);
this.currentIndex.addColumn(column);
} else if (this.currentUnique != null) {
this.currentUnique.addColumn(column);
代码示例来源:origin: hibernate/hibernate-orm
private void addConstraintToColumn(final String columnName ) {
Column column = table.getColumn(
new Column(
buildingContext.getMetadataCollector().getPhysicalColumnName( table, columnName )
)
);
if ( column == null ) {
throw new AnnotationException(
"@Index references a unknown column: " + columnName
);
}
if ( unique ) {
table.getOrCreateUniqueKey( indexName ).addColumn( column );
}
else {
table.getOrCreateIndex( indexName ).addColumn( column );
}
}
代码示例来源:origin: org.hibernate/com.springsource.org.hibernate
public String sqlCreateString(Dialect dialect, Mapping mapping, String defaultCatalog, String defaultSchema)
throws HibernateException {
return buildSqlCreateIndexString(
dialect,
getName(),
getTable(),
getColumnIterator(),
false,
defaultCatalog,
defaultSchema
);
}
代码示例来源:origin: hibernate/hibernate-orm
@Test
public void testWithCustomNamingStrategy() throws Exception {
Metadata metadata = new MetadataSources( serviceRegistry )
.addAnnotatedClass(Address.class)
.addAnnotatedClass(Person.class)
.getMetadataBuilder()
.applyImplicitNamingStrategy( new LongIdentifierNamingStrategy() )
.build();
UniqueKey uniqueKey = metadata.getEntityBinding( Address.class.getName()).getTable().getUniqueKeyIterator().next();
assertEquals( expectedUniqueKeyName(), uniqueKey.getName() );
org.hibernate.mapping.ForeignKey foreignKey =
(org.hibernate.mapping.ForeignKey) metadata.getEntityBinding( Address.class.getName()).getTable().getForeignKeyIterator().next();
assertEquals( expectedForeignKeyName(), foreignKey.getName() );
org.hibernate.mapping.Index index = metadata.getEntityBinding( Address.class.getName()).getTable().getIndexIterator().next();
assertEquals( expectedIndexName(), index.getName() );
}
代码示例来源:origin: liquibase/liquibase-hibernate
@Override
protected void addTo(DatabaseObject foundObject, DatabaseSnapshot snapshot) throws DatabaseException, InvalidExampleException {
if (!snapshot.getSnapshotControl().shouldInclude(Index.class)) {
return;
}
if (foundObject instanceof Table) {
Table table = (Table) foundObject;
org.hibernate.mapping.Table hibernateTable = findHibernateTable(table, snapshot);
if (hibernateTable == null) {
return;
}
Iterator indexIterator = hibernateTable.getIndexIterator();
while (indexIterator.hasNext()) {
org.hibernate.mapping.Index hibernateIndex = (org.hibernate.mapping.Index) indexIterator.next();
Index index = new Index();
index.setTable(table);
index.setName(hibernateIndex.getName());
Iterator columnIterator = hibernateIndex.getColumnIterator();
while (columnIterator.hasNext()) {
org.hibernate.mapping.Column hibernateColumn = (org.hibernate.mapping.Column) columnIterator.next();
index.getColumns().add(new Column(hibernateColumn.getName()).setRelation(table));
}
LOG.info("Found index " + index.getName());
table.getIndexes().add(index);
}
}
}
代码示例来源:origin: hibernate/hibernate-orm
protected void applyIndexes(
Table table,
TableInformation tableInformation,
Dialect dialect,
Metadata metadata,
Formatter formatter,
ExecutionOptions options,
GenerationTarget... targets) {
final Exporter<Index> exporter = dialect.getIndexExporter();
final Iterator<Index> indexItr = table.getIndexIterator();
while ( indexItr.hasNext() ) {
final Index index = indexItr.next();
if ( !StringHelper.isEmpty( index.getName() ) ) {
IndexInformation existingIndex = null;
if ( tableInformation != null ) {
existingIndex = findMatchingIndex( index, tableInformation );
}
if ( existingIndex == null ) {
applySqlStrings(
false,
exporter.getSqlCreateStrings( index, metadata ),
formatter,
options,
targets
);
}
}
}
}
代码示例来源:origin: org.hibernate.ogm/hibernate-ogm-cassandra
private void processIndexes(CassandraDatastoreProvider datastoreProvider, Table table, List<String> primaryKeys) {
// cassandra won't allow table scanning, so we need to explicitly index for the fk relations:
Iterator<ForeignKey> fkMappings = table.getForeignKeyIterator();
while ( fkMappings.hasNext() ) {
ForeignKey foreignKey = fkMappings.next();
createSecondaryIndex( datastoreProvider, table, foreignKey.getName(), foreignKey.getColumnIterator() );
}
Iterator<Index> indexIterator = table.getIndexIterator();
while ( indexIterator.hasNext() ) {
Index index = indexIterator.next();
createSecondaryIndex( datastoreProvider, table, index.getName(), index.getColumnIterator() );
}
}
代码示例来源:origin: hibernate/hibernate-orm
final JdbcEnvironment jdbcEnvironment = metadata.getDatabase().getJdbcEnvironment();
final String tableName = jdbcEnvironment.getQualifiedObjectNameFormatter().format(
index.getTable().getQualifiedTableName(),
dialect
);
indexNameForCreation = jdbcEnvironment.getQualifiedObjectNameFormatter().format(
new QualifiedNameImpl(
index.getTable().getQualifiedTableName().getCatalogName(),
index.getTable().getQualifiedTableName().getSchemaName(),
jdbcEnvironment.getIdentifierHelper().toIdentifier( index.getQuotedName( dialect ) )
),
jdbcEnvironment.getDialect()
indexNameForCreation = index.getName();
final Iterator<Column> columnItr = index.getColumnIterator();
final Map<Column, String> columnOrderMap = index.getColumnOrderMap();
while ( columnItr.hasNext() ) {
final Column column = columnItr.next();
代码示例来源:origin: hibernate/hibernate-orm
final JdbcEnvironment jdbcEnvironment = metadata.getDatabase().getJdbcEnvironment();
final String tableName = jdbcEnvironment.getQualifiedObjectNameFormatter().format(
index.getTable().getQualifiedTableName(),
jdbcEnvironment.getDialect()
);
indexNameForCreation = jdbcEnvironment.getQualifiedObjectNameFormatter().format(
new QualifiedNameImpl(
index.getTable().getQualifiedTableName().getCatalogName(),
index.getTable().getQualifiedTableName().getSchemaName(),
jdbcEnvironment.getIdentifierHelper().toIdentifier( index.getName() )
),
jdbcEnvironment.getDialect()
indexNameForCreation = index.getName();
Iterator<Column> columnItr = index.getColumnIterator();
while ( columnItr.hasNext() ) {
final Column column = columnItr.next();
代码示例来源:origin: hibernate/hibernate-ogm
private void addIndex(Label label, Index index) {
if ( index != null ) {
if ( index.getName() != null ) {
log.cannotSetNameForIndex( index.getName() );
}
List<String> properties = CollectionHelper.toStream( index.getColumnIterator() )
.map( Column::getName ).collect( Collectors.toList() );
indexSpecs.add( new Neo4jIndexSpec( label, properties ) );
}
}
内容来源于网络,如有侵权,请联系作者删除!