本文整理了Java中org.hibernate.boot.model.relational.Namespace.getTables()
方法的一些代码示例,展示了Namespace.getTables()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Namespace.getTables()
方法的具体详情如下:
包路径:org.hibernate.boot.model.relational.Namespace
类名称:Namespace
方法名:getTables
暂无
代码示例来源:origin: hibernate/hibernate-orm
@Override
public java.util.Collection<Table> collectTableMappings() {
ArrayList<Table> tables = new ArrayList<>();
for ( Namespace namespace : database.getNamespaces() ) {
tables.addAll( namespace.getTables() );
}
return tables;
}
代码示例来源:origin: hibernate/hibernate-orm
@Override
public java.util.Collection<Table> collectTableMappings() {
ArrayList<Table> tables = new ArrayList<>();
for ( Namespace namespace : getDatabase().getNamespaces() ) {
tables.addAll( namespace.getTables() );
}
return tables;
}
代码示例来源:origin: hibernate/hibernate-orm
private void assertNoForeignKey(String foreignKeyName, String... columns) {
Set<String> columnSet = new LinkedHashSet<>( Arrays.asList( columns ) );
for ( Namespace namespace : metadata().getDatabase().getNamespaces() ) {
for ( org.hibernate.mapping.Table table : namespace.getTables() ) {
Iterator<org.hibernate.mapping.ForeignKey> fkItr = table.getForeignKeyIterator();
while ( fkItr.hasNext() ) {
org.hibernate.mapping.ForeignKey fk = fkItr.next();
assertFalse(
"ForeignKey [" + foreignKeyName + "] defined and shouldn't have been.",
foreignKeyName.equals( fk.getName() )
);
}
}
}
}
代码示例来源:origin: hibernate/hibernate-orm
@Override
protected void validateTables(
Metadata metadata,
DatabaseInformation databaseInformation,
ExecutionOptions options,
Dialect dialect,
Namespace namespace) {
for ( Table table : namespace.getTables() ) {
if ( schemaFilter.includeTable( table ) && table.isPhysicalTable() ) {
final TableInformation tableInformation = databaseInformation.getTableInformation(
table.getQualifiedTableName()
);
validateTable( table, tableInformation, metadata, options, dialect );
}
}
}
}
代码示例来源:origin: hibernate/hibernate-orm
@Override
protected void validateTables(
Metadata metadata,
DatabaseInformation databaseInformation,
ExecutionOptions options,
Dialect dialect, Namespace namespace) {
final NameSpaceTablesInformation tables = databaseInformation.getTablesInformation( namespace );
for ( Table table : namespace.getTables() ) {
if ( schemaFilter.includeTable( table ) && table.isPhysicalTable() ) {
validateTable(
table,
tables.getTableInformation( table ),
metadata,
options,
dialect
);
}
}
}
}
代码示例来源:origin: hibernate/hibernate-orm
private void applyConstraintDropping(
Namespace namespace,
Metadata metadata,
Formatter formatter,
ExecutionOptions options,
GenerationTarget... targets) {
final Dialect dialect = metadata.getDatabase().getJdbcEnvironment().getDialect();
if ( !dialect.dropConstraints() ) {
return;
}
for ( Table table : namespace.getTables() ) {
if ( !table.isPhysicalTable() ) {
continue;
}
if ( !schemaFilter.includeTable( table ) ) {
continue;
}
final Iterator fks = table.getForeignKeyIterator();
while ( fks.hasNext() ) {
final ForeignKey foreignKey = (ForeignKey) fks.next();
applySqlStrings(
dialect.getForeignKeyExporter().getSqlDropStrings( foreignKey, metadata ),
formatter,
options,
targets
);
}
}
}
代码示例来源:origin: hibernate/hibernate-orm
private void assertForeignKey(String foreignKeyName, String... columns) {
Set<String> columnSet = new LinkedHashSet<>( Arrays.asList( columns ) );
for ( Namespace namespace : metadata().getDatabase().getNamespaces() ) {
for ( org.hibernate.mapping.Table table : namespace.getTables() ) {
Iterator<org.hibernate.mapping.ForeignKey> fkItr = table.getForeignKeyIterator();
while ( fkItr.hasNext() ) {
org.hibernate.mapping.ForeignKey fk = fkItr.next();
if ( foreignKeyName.equals( fk.getName() ) ) {
assertEquals( "ForeignKey column count not like expected", columnSet.size(), fk.getColumnSpan() );
List<String> columnNames = fk.getColumns().stream().map(Column::getName).collect(Collectors.toList());
assertTrue(
"ForeignKey columns [" + columnNames + "] do not match expected columns [" + columnSet + "]",
columnSet.containsAll( columnNames )
);
return;
}
}
}
}
fail( "ForeignKey '" + foreignKeyName + "' could not be found!" );
}
代码示例来源:origin: hibernate/hibernate-orm
@Test
@TestForIssue(jiraKey = "HHH-12975")
public void testPrimaryKeyJoinColumnForeignKeyNoConstraint() {
for ( Namespace namespace : metadata().getDatabase().getNamespaces() ) {
for ( Table table : namespace.getTables() ) {
if ( "Car".equals( table.getName() ) ) {
assertEquals( 0, table.getForeignKeys().size() );
}
}
}
}
代码示例来源:origin: hibernate/hibernate-orm
@Test
@TestForIssue(jiraKey = "HHH-12975")
public void testMapsIdJoinColumnForeignKeyNoConstraint() {
for ( Namespace namespace : metadata().getDatabase().getNamespaces() ) {
for ( Table table : namespace.getTables() ) {
if ( "Post".equals( table.getName() ) ) {
assertEquals( 0, table.getForeignKeys().size() );
}
}
}
}
代码示例来源:origin: hibernate/hibernate-orm
@Test
public void testJoinTableForeignKeyToNonAuditTables() {
// there should only be references to REVINFO and not to the Customer or Address tables
for ( Table table : metadata().getDatabase().getDefaultNamespace().getTables() ) {
if ( table.getName().equals( "CustomerAddress_AUD" ) ) {
for ( org.hibernate.mapping.ForeignKey foreignKey : table.getForeignKeys().values() ) {
assertEquals( "REVINFO", foreignKey.getReferencedTable().getName() );
}
}
}
}
代码示例来源:origin: hibernate/hibernate-orm
@Test
public void testForeignKeyNameSetForMapsIdJoinColumn() {
for ( Namespace namespace : metadata().getDatabase().getNamespaces() ) {
for ( Table table : namespace.getTables() ) {
if ( table.getName().equals( "Post" ) ) {
Iterator<org.hibernate.mapping.ForeignKey> foreignKeyIterator = table.getForeignKeyIterator();
while ( foreignKeyIterator.hasNext() ) {
org.hibernate.mapping.ForeignKey foreignKey = foreignKeyIterator.next();
if ( foreignKey.getColumn( 0 ).getName().equals( "PD_ID" ) ) {
assertEquals( "FK_PD", foreignKey.getName() );
return;
}
}
}
}
}
fail( "Expected to find a Foreign Key mapped to column PD_ID but failed to locate it" );
}
}
代码示例来源:origin: hibernate/hibernate-orm
@Test
@TestForIssue( jiraKey = "HHH-9850" )
public void testNewGeneratorTableCreationOnDb2() {
StandardServiceRegistry ssr = new StandardServiceRegistryBuilder()
.applySetting( AvailableSettings.DIALECT, DB2Dialect.class.getName() )
.build();
try {
Metadata metadata = new MetadataSources( ssr )
.buildMetadata();
assertEquals( 0, metadata.getDatabase().getDefaultNamespace().getTables().size() );
TableGenerator generator = new TableGenerator();
Properties properties = new Properties();
generator.configure( IntegerType.INSTANCE, properties, ssr );
generator.registerExportables( metadata.getDatabase() );
assertEquals( 1, metadata.getDatabase().getDefaultNamespace().getTables().size() );
final Table table = metadata.getDatabase().getDefaultNamespace().getTables().iterator().next();
final String[] createCommands = new DB2Dialect().getTableExporter().getSqlCreateStrings( table, metadata );
assertContains( "sequence_name varchar(255) not null", createCommands[0] );
}
finally {
StandardServiceRegistryBuilder.destroy( ssr );
}
}
代码示例来源:origin: hibernate/hibernate-orm
.buildMetadata();
assertEquals( 0, metadata.getDatabase().getDefaultNamespace().getTables().size() );
assertEquals( 1, metadata.getDatabase().getDefaultNamespace().getTables().size() );
final Table table = metadata.getDatabase().getDefaultNamespace().getTables().iterator().next();
final String[] createCommands = new DB2Dialect().getTableExporter().getSqlCreateStrings( table, metadata );
assertContains( "sequence_name varchar(255) not null", createCommands[0] );
代码示例来源:origin: hibernate/hibernate-orm
@Test
public void testQualifiedNameSeparator() throws Exception {
Namespace.Name namespaceName = new Namespace.Name(
Identifier.toIdentifier( "DB1" ),
Identifier.toIdentifier( "PUBLIC" )
);
String expectedName = null;
for ( Namespace namespace : metadata().getDatabase().getNamespaces() ) {
if ( !namespace.getName().equals( namespaceName ) ) {
continue;
}
assertEquals( 1, namespace.getTables().size() );
expectedName = metadata().getDatabase().getJdbcEnvironment().getQualifiedObjectNameFormatter().format(
namespace.getTables().iterator().next().getQualifiedTableName(),
getDialect()
);
}
assertNotNull( expectedName );
SingleTableEntityPersister persister = (SingleTableEntityPersister) sessionFactory().getEntityPersister( Box.class.getName() );
assertEquals( expectedName, persister.getTableName() );
}
代码示例来源:origin: hibernate/hibernate-orm
int foundCount = 0;
for ( Namespace namespace : metadata().getDatabase().getNamespaces() ) {
for ( org.hibernate.mapping.Table table : namespace.getTables() ) {
Iterator fkItr = table.getForeignKeyIterator();
while (fkItr.hasNext()) {
代码示例来源:origin: hibernate/hibernate-orm
targets
);
for ( Table table : namespace.getTables() ) {
if ( schemaFilter.includeTable( table ) && table.isPhysicalTable() ) {
checkExportIdentifier( table, exportIdentifiers );
for ( Table table : namespace.getTables() ) {
if ( schemaFilter.includeTable( table ) && table.isPhysicalTable() ) {
final TableInformation tableInformation = tablesInformation.getTableInformation( table );
代码示例来源:origin: hibernate/hibernate-orm
);
final NameSpaceTablesInformation tables = existingDatabase.getTablesInformation( namespace );
for ( Table table : namespace.getTables() ) {
if ( schemaFilter.includeTable( table ) && table.isPhysicalTable() ) {
checkExportIdentifier( table, exportIdentifiers );
for ( Table table : namespace.getTables() ) {
if ( schemaFilter.includeTable( table ) && table.isPhysicalTable() ) {
final TableInformation tableInformation = tablesInformation.getTableInformation( table );
代码示例来源:origin: hibernate/hibernate-orm
@Test
public void testIdentifierGeneratorExtendsIdentityGenerator() {
final MetadataSources sources = new MetadataSources( serviceRegistry() );
sources.addAnnotatedClass( EntityBean.class );
final MetadataBuilder builder = sources.getMetadataBuilder();
final Metadata metadata = builder.build();
for ( final Namespace ns : metadata.getDatabase().getNamespaces() ) {
for ( final org.hibernate.mapping.Table table : ns.getTables() ) {
final KeyValue value = table.getIdentifierValue();
assertNotNull( "IdentifierValue was null", value );
assertTrue( value.isIdentityColumn( metadata.getIdentifierGeneratorFactory(), getDialect() ) );
}
}
Session s = openSession();
s.beginTransaction();
s.save( new EntityBean() );
s.getTransaction().commit();
s.close();
}
}
代码示例来源:origin: hibernate/hibernate-orm
if ( schemaFilter.includeNamespace( namespace ) ) {
final NameSpaceTablesInformation nameSpaceTablesInformation = tablesInformation.get( namespace );
for ( Table table : namespace.getTables() ) {
if ( schemaFilter.includeTable( table ) ) {
final TableInformation tableInformation = nameSpaceTablesInformation.getTableInformation( table );
代码示例来源:origin: hibernate/hibernate-orm
for ( Table table : namespace.getTables() ) {
if ( !table.isPhysicalTable() ) {
continue;
内容来源于网络,如有侵权,请联系作者删除!