public Namespace locateNamespace(Identifier catalogName, Identifier schemaName) { if ( catalogName == null && schemaName == null ) { return getDefaultNamespace(); } final Namespace.Name name = new Namespace.Name( catalogName, schemaName ); Namespace namespace = namespaceMap.get( name ); if ( namespace == null ) { namespace = makeNamespace( name ); } return namespace; }
public Namespace adjustDefaultNamespace(Identifier catalogName, Identifier schemaName) { final Namespace.Name name = new Namespace.Name( catalogName, schemaName ); if ( implicitNamespace.getName().equals( name ) ) { return implicitNamespace; } Namespace namespace = namespaceMap.get( name ); if ( namespace == null ) { namespace = makeNamespace( name ); } implicitNamespace = namespace; return implicitNamespace; }
fks.add( new ForeignKeyInformationImpl( new Identifier( "objectId2id_2", false ), new ArrayList<>() ) ); Mockito.when( informationExtractor.getForeignKeys( Mockito.any() ) ).thenReturn( fks ); Name schemaName = new Name( new Identifier( "-", false ), new Identifier( "-", false ) ); QualifiedTableName tableName = new QualifiedTableName( schemaName, new Identifier( "-", false ) ); TableInformation tableInformation = new TableInformationImpl( informationExtractor, identifierHelper, tableName, false, null );
foreignKey.setReferencedTable( new Table( "table2" ) ); Name schemaName = new Name( new Identifier( "-", false ), new Identifier( "-", false ) ); InformationExtractor informationExtractor = Mockito.mock( InformationExtractor.class ); IdentifierHelper identifierHelper = new IdentifierHelperImpl();
foreignKey.setReferencedTable( new Table( "table2" ) ); Name schemaName = new Name( new Identifier( "-", false ), new Identifier( "-", false ) ); InformationExtractor informationExtractor = Mockito.mock( InformationExtractor.class ); IdentifierHelper identifierHelper = new IdentifierHelperImpl();
fks.add( new ForeignKeyInformationImpl( new Identifier( "objectId2id", false ), new ArrayList<>() ) ); Mockito.when( informationExtractor.getForeignKeys( Mockito.any() ) ).thenReturn( fks ); Name schemaName = new Name( new Identifier( "-", false ), new Identifier( "-", false ) ); QualifiedTableName tableName = new QualifiedTableName( schemaName, new Identifier( "-", false ) ); TableInformation tableInformation = new TableInformationImpl( informationExtractor, identifierHelper, tableName, false, null );
@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() ); }
public Namespace(PhysicalNamingStrategy physicalNamingStrategy, JdbcEnvironment jdbcEnvironment, Name name) { this.physicalNamingStrategy = physicalNamingStrategy; this.jdbcEnvironment = jdbcEnvironment; this.name = name; this.physicalName = new Name( physicalNamingStrategy .toPhysicalCatalogName( name.getCatalog(), jdbcEnvironment ), physicalNamingStrategy .toPhysicalSchemaName( name.getSchema(), jdbcEnvironment ) ); log.debugf( "Created database namespace [logicalName=%s, physicalName=%s]", name.toString(), physicalName.toString() ); }
private ColumnInformation getColumnInformation(String tableName, String columnName) { Name schemaName = new Name( new Identifier( "-", false ), new Identifier( "-", false ) ); TableInformation containingTableInformation = new TableInformationImpl( null, null, new QualifiedTableName( schemaName, new Identifier( tableName, false ) ), false, null ); Identifier columnIdentifier = new Identifier( columnName, false ); int typeCode = 0; String typeName = null; int columnSize = 0; int decimalDigits = 0; TruthValue nullable = null; ColumnInformationImpl columnInformation = new ColumnInformationImpl( containingTableInformation, columnIdentifier, typeCode, typeName, columnSize, decimalDigits, nullable ); return columnInformation; } }
public Database(MetadataBuildingOptions buildingOptions, JdbcEnvironment jdbcEnvironment) { this.serviceRegistry = buildingOptions.getServiceRegistry(); this.jdbcEnvironment = jdbcEnvironment; this.physicalNamingStrategy = buildingOptions.getPhysicalNamingStrategy(); this.dialect = determineDialect( buildingOptions ); this.implicitNamespace = makeNamespace( new Namespace.Name( toIdentifier( buildingOptions.getMappingDefaults().getImplicitCatalogName() ), toIdentifier( buildingOptions.getMappingDefaults().getImplicitSchemaName() ) ) ); }