本文整理了Java中org.hibernate.mapping.Index.getName()
方法的一些代码示例,展示了Index.getName()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Index.getName()
方法的具体详情如下:
包路径:org.hibernate.mapping.Index
类名称:Index
方法名:getName
暂无
代码示例来源:origin: hibernate/hibernate-orm
public Index addIndex(Index index) {
Index current = indexes.get( index.getName() );
if ( current != null ) {
throw new MappingException( "Index " + index.getName() + " already exists!" );
}
indexes.put( index.getName(), index );
return index;
}
代码示例来源:origin: hibernate/hibernate-orm
@Override
public String toString() {
return getClass().getName() + "(" + getName() + ")";
}
代码示例来源:origin: hibernate/hibernate-orm
private IndexInformation findMatchingIndex(Index index, TableInformation tableInformation) {
return tableInformation.getIndex( Identifier.toIdentifier( index.getName() ) );
}
代码示例来源:origin: hibernate/hibernate-orm
@Override
public String getExportIdentifier() {
return StringHelper.qualify( getTable().getExportIdentifier(), "IDX-" + getName() );
}
}
代码示例来源: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
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: hibernate/hibernate-orm
@Override
public String[] getSqlDropStrings(Index index, Metadata metadata) {
if ( !dialect.dropConstraints() ) {
return NO_COMMANDS;
}
final JdbcEnvironment jdbcEnvironment = metadata.getDatabase().getJdbcEnvironment();
final String tableName = jdbcEnvironment.getQualifiedObjectNameFormatter().format(
index.getTable().getQualifiedTableName(),
dialect
);
final String indexNameForCreation;
if ( dialect.qualifyIndexName() ) {
indexNameForCreation = StringHelper.qualify( tableName, index.getName() );
}
else {
indexNameForCreation = index.getName();
}
return new String[] { "drop index " + indexNameForCreation };
}
}
代码示例来源:origin: hibernate/hibernate-orm
indexNameForCreation = index.getName();
代码示例来源:origin: hibernate/hibernate-orm
index.getTable().getQualifiedTableName().getCatalogName(),
index.getTable().getQualifiedTableName().getSchemaName(),
jdbcEnvironment.getIdentifierHelper().toIdentifier( index.getName() )
),
jdbcEnvironment.getDialect()
indexNameForCreation = index.getName();
代码示例来源:origin: hibernate/hibernate-orm
@Test
public void testSecondaryTableIndex(){
PersistentClass entity = metadata().getEntityBinding( Car.class.getName() );
Join join = (Join)entity.getJoinIterator().next();
Iterator<Index> itr = join.getTable().getIndexIterator();
assertTrue( itr.hasNext() );
Index index = itr.next();
assertFalse( itr.hasNext() );
assertTrue( "index name is not generated", StringHelper.isNotEmpty( index.getName() ) );
assertEquals( 2, index.getColumnSpan() );
Iterator<Column> columnIterator = index.getColumnIterator();
Column column = columnIterator.next();
assertEquals( "dealer_name", column.getName() );
column = columnIterator.next();
assertEquals( "rate", column.getName() );
assertSame( join.getTable(), index.getTable() );
}
代码示例来源: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
@Test
public void testJoinTableIndex(){
PersistentClass entity = metadata().getEntityBinding( Importer.class.getName() );
Property property = entity.getProperty( "cars" );
Bag set = (Bag)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( "importers_id", column.getName() );
assertSame( collectionTable, index.getTable() );
}
代码示例来源: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: hibernate/hibernate-orm
@Test
public void testTableIndex() {
PersistentClass entity = metadata().getEntityBinding( Car.class.getName() );
Iterator itr = entity.getTable().getUniqueKeyIterator();
assertTrue( itr.hasNext() );
UniqueKey uk = (UniqueKey) itr.next();
assertFalse( itr.hasNext() );
assertTrue( StringHelper.isNotEmpty( uk.getName() ) );
assertEquals( 2, uk.getColumnSpan() );
Column column = (Column) uk.getColumns().get( 0 );
assertEquals( "brand", column.getName() );
column = (Column) uk.getColumns().get( 1 );
assertEquals( "producer", column.getName() );
assertSame( entity.getTable(), uk.getTable() );
itr = entity.getTable().getIndexIterator();
assertTrue( itr.hasNext() );
Index index = (Index)itr.next();
assertFalse( itr.hasNext() );
assertEquals( "Car_idx", index.getName() );
assertEquals( 1, index.getColumnSpan() );
column = index.getColumnIterator().next();
assertEquals( "since", column.getName() );
assertSame( entity.getTable(), index.getTable() );
}
代码示例来源:origin: org.hibernate/com.springsource.org.hibernate.core
public Index addIndex(Index index) {
Index current = (Index) indexes.get( index.getName() );
if ( current != null ) {
throw new MappingException( "Index " + index.getName() + " already exists!" );
}
indexes.put( index.getName(), index );
return index;
}
代码示例来源:origin: org.hibernate/com.springsource.org.hibernate
public Index addIndex(Index index) {
Index current = (Index) indexes.get( index.getName() );
if ( current != null ) {
throw new MappingException( "Index " + index.getName() + " already exists!" );
}
indexes.put( index.getName(), index );
return index;
}
代码示例来源: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 ) );
}
}
代码示例来源:origin: hibernate/hibernate-ogm
private void validateIndexSpecsForIndexes(Table table, IndexOptions indexOptions, Set<String> forIndexNotReferenced) {
Iterator<Index> indexes = table.getIndexIterator();
while ( indexes.hasNext() ) {
Index index = indexes.next();
forIndexNotReferenced.remove( index.getName() );
MongoDBIndexSpec indexSpec = new MongoDBIndexSpec( index,
getIndexOptionDocument( table, indexOptions.getOptionForIndex( index.getName() ) ) );
if ( validateIndexSpec( indexSpec ) && thereIsNoUniqueConstraintOnSameColumns( indexSpec ) ) {
indexSpecs.add( indexSpec );
}
}
}
代码示例来源:origin: org.hibernate.ogm/hibernate-ogm-mongodb
private void validateIndexSpecsForIndexes(Table table, IndexOptions indexOptions, Set<String> forIndexNotReferenced) {
Iterator<Index> indexes = table.getIndexIterator();
while ( indexes.hasNext() ) {
Index index = indexes.next();
forIndexNotReferenced.remove( index.getName() );
MongoDBIndexSpec indexSpec = new MongoDBIndexSpec( index,
getIndexOptionDocument( table, indexOptions.getOptionForIndex( index.getName() ) ) );
if ( validateIndexSpec( indexSpec ) && thereIsNoUniqueConstraintOnSameColumns( indexSpec ) ) {
indexSpecs.add( indexSpec );
}
}
}
代码示例来源:origin: org.hibernate/com.springsource.org.hibernate.core
public String sqlCreateString(Dialect dialect, Mapping mapping, String defaultCatalog, String defaultSchema)
throws HibernateException {
return buildSqlCreateIndexString(
dialect,
getName(),
getTable(),
getColumnIterator(),
false,
defaultCatalog,
defaultSchema
);
}
内容来源于网络,如有侵权,请联系作者删除!