org.hibernate.boot.model.relational.Database Java Examples
The following examples show how to use
org.hibernate.boot.model.relational.Database.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SpannerForeignKeyExporterTests.java From google-cloud-spanner-hibernate with GNU Lesser General Public License v2.1 | 6 votes |
private static Metadata setupMetadataMock() { Metadata metadata = mock(Metadata.class); Database database = mock(Database.class); JdbcEnvironment jdbcEnvironment = mock(JdbcEnvironment.class); QualifiedObjectNameFormatter qualifiedObjectNameFormatter = mock(QualifiedObjectNameFormatter.class); when(metadata.getDatabase()).thenReturn(database); when(database.getJdbcEnvironment()).thenReturn(jdbcEnvironment); when(jdbcEnvironment.getQualifiedObjectNameFormatter()) .thenReturn(qualifiedObjectNameFormatter); when(qualifiedObjectNameFormatter.format(any(QualifiedTableName.class), any())) .thenAnswer(invocation -> ((QualifiedTableName) invocation.getArguments()[0]).getTableName().getCanonicalName()); return metadata; }
Example #2
Source File: AbstractSchemaMigrator.java From lams with GNU General Public License v2.0 | 6 votes |
protected void migrateTable( Table table, TableInformation tableInformation, Dialect dialect, Metadata metadata, Formatter formatter, ExecutionOptions options, GenerationTarget... targets) { final Database database = metadata.getDatabase(); //noinspection unchecked applySqlStrings( false, table.sqlAlterStrings( dialect, metadata, tableInformation, getDefaultCatalogName( database, dialect ), getDefaultSchemaName( database, dialect ) ), formatter, options, targets ); }
Example #3
Source File: SequenceStructure.java From lams with GNU General Public License v2.0 | 6 votes |
protected void buildSequence(Database database) { final int sourceIncrementSize = getSourceIncrementSize(); final Namespace namespace = database.locateNamespace( logicalQualifiedSequenceName.getCatalogName(), logicalQualifiedSequenceName.getSchemaName() ); Sequence sequence = namespace.locateSequence( logicalQualifiedSequenceName.getObjectName() ); if ( sequence != null ) { sequence.validate( initialValue, sourceIncrementSize ); } else { sequence = namespace.createSequence( logicalQualifiedSequenceName.getObjectName(), initialValue, sourceIncrementSize ); } this.sequenceName = database.getJdbcEnvironment().getQualifiedObjectNameFormatter().format( sequence.getName(), database.getJdbcEnvironment().getDialect() ); }
Example #4
Source File: ReactiveGeneratorWrapper.java From hibernate-reactive with GNU Lesser General Public License v2.1 | 5 votes |
@Override public void registerExportables(Database database) { if (generator instanceof ExportableProducer) { ((ExportableProducer) generator).registerExportables( database ); } if (reactiveGenerator instanceof ExportableProducer) { ((ExportableProducer) reactiveGenerator).registerExportables( database ); } }
Example #5
Source File: Ejb3Column.java From lams with GNU General Public License v2.0 | 5 votes |
protected void addColumnBinding(SimpleValue value) { final String logicalColumnName; if ( StringHelper.isNotEmpty( this.logicalColumnName ) ) { logicalColumnName = this.logicalColumnName; } else { final ObjectNameNormalizer normalizer = context.getObjectNameNormalizer(); final Database database = context.getMetadataCollector().getDatabase(); final ImplicitNamingStrategy implicitNamingStrategy = context.getBuildingOptions() .getImplicitNamingStrategy(); final Identifier implicitName = normalizer.normalizeIdentifierQuoting( implicitNamingStrategy.determineBasicColumnName( new ImplicitBasicColumnNameSource() { @Override public AttributePath getAttributePath() { return AttributePath.parse( propertyName ); } @Override public boolean isCollectionElement() { return false; } @Override public MetadataBuildingContext getBuildingContext() { return context; } } ) ); logicalColumnName = implicitName.render( database.getDialect() ); } context.getMetadataCollector().addColumnNameBinding( value.getTable(), logicalColumnName, getMappingColumn() ); }
Example #6
Source File: InFlightMetadataCollectorImpl.java From lams with GNU General Public License v2.0 | 5 votes |
@Override public Database getDatabase() { // important to delay this instantiation until as late as possible. if ( database == null ) { this.database = new Database( options ); } return database; }
Example #7
Source File: SequenceGenerator.java From lams with GNU General Public License v2.0 | 5 votes |
@Override public void registerExportables(Database database) { final Namespace namespace = database.locateNamespace( logicalQualifiedSequenceName.getCatalogName(), logicalQualifiedSequenceName.getSchemaName() ); Sequence sequence = namespace.locateSequence( logicalQualifiedSequenceName.getObjectName() ); if ( sequence != null ) { sequence.validate( 1, 1 ); } else { sequence = namespace.createSequence( logicalQualifiedSequenceName.getObjectName(), 1, 1 ); } final JdbcEnvironment jdbcEnvironment = database.getJdbcEnvironment(); final Dialect dialect = jdbcEnvironment.getDialect(); this.sequenceName = jdbcEnvironment.getQualifiedObjectNameFormatter().format( sequence.getName(), dialect ); this.sql = jdbcEnvironment.getDialect().getSequenceNextValString( sequenceName ); }
Example #8
Source File: ExportableColumn.java From lams with GNU General Public License v2.0 | 5 votes |
public ExportableColumn( Database database, Table table, String name, BasicType type, String dbTypeDeclaration) { super( name ); setValue( new ValueImpl( this, table, type, database ) ); setSqlType( dbTypeDeclaration ); }
Example #9
Source File: ExportableColumn.java From lams with GNU General Public License v2.0 | 5 votes |
public ExportableColumn(Database database, Table table, String name, BasicType type) { this( database, table, name, type, database.getDialect().getTypeName( type.sqlTypes( null )[0] ) ); }
Example #10
Source File: MetadataExtractorIntegrator.java From tutorials with MIT License | 4 votes |
public Database getDatabase() { return database; }
Example #11
Source File: MetadataExtractorIntegrator.java From high-performance-java-persistence with Apache License 2.0 | 4 votes |
public Database getDatabase() { return database; }
Example #12
Source File: MetadataImpl.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public Database getDatabase() { return database; }
Example #13
Source File: MetadataImpl.java From lams with GNU General Public License v2.0 | 4 votes |
MetadataImpl( UUID uuid, MetadataBuildingOptions metadataBuildingOptions, MutableIdentifierGeneratorFactory identifierGeneratorFactory, Map<String, PersistentClass> entityBindingMap, Map<Class, MappedSuperclass> mappedSuperclassMap, Map<String, Collection> collectionBindingMap, Map<String, TypeDefinition> typeDefinitionMap, Map<String, FilterDefinition> filterDefinitionMap, Map<String, FetchProfile> fetchProfileMap, Map<String, String> imports, Map<String, IdentifierGeneratorDefinition> idGeneratorDefinitionMap, Map<String, NamedQueryDefinition> namedQueryMap, Map<String, NamedSQLQueryDefinition> namedNativeQueryMap, Map<String, NamedProcedureCallDefinition> namedProcedureCallMap, Map<String, ResultSetMappingDefinition> sqlResultSetMappingMap, Map<String, NamedEntityGraphDefinition> namedEntityGraphMap, Map<String, SQLFunction> sqlFunctionMap, java.util.Collection<DomainDataRegionConfigImpl.Builder> cacheRegionConfigBuilders, Database database, BootstrapContext bootstrapContext) { this.uuid = uuid; this.metadataBuildingOptions = metadataBuildingOptions; this.identifierGeneratorFactory = identifierGeneratorFactory; this.entityBindingMap = entityBindingMap; this.mappedSuperclassMap = mappedSuperclassMap; this.collectionBindingMap = collectionBindingMap; this.typeDefinitionMap = typeDefinitionMap; this.filterDefinitionMap = filterDefinitionMap; this.fetchProfileMap = fetchProfileMap; this.imports = imports; this.idGeneratorDefinitionMap = idGeneratorDefinitionMap; this.namedQueryMap = namedQueryMap; this.namedNativeQueryMap = namedNativeQueryMap; this.namedProcedureCallMap = namedProcedureCallMap; this.sqlResultSetMappingMap = sqlResultSetMappingMap; this.namedEntityGraphMap = namedEntityGraphMap; this.sqlFunctionMap = sqlFunctionMap; this.cacheRegionConfigBuilders = cacheRegionConfigBuilders; this.database = database; this.bootstrapContext = bootstrapContext; }
Example #14
Source File: ObjectNameNormalizer.java From lams with GNU General Public License v2.0 | 4 votes |
protected Database database() { if ( database == null ) { database = getBuildingContext().getMetadataCollector().getDatabase(); } return database; }
Example #15
Source File: AbstractDelegatingMetadata.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public Database getDatabase() { return delegate.getDatabase(); }
Example #16
Source File: ExportableColumn.java From lams with GNU General Public License v2.0 | 4 votes |
public ValueImpl(ExportableColumn column, Table table, BasicType type, Database database) { this.column = column; this.table = table; this.type = type; this.database = database; }
Example #17
Source File: CompositeNestedGeneratedValueGenerator.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public void registerExportables(Database database) { for (GenerationPlan plan : generationPlans) { plan.registerExportables( database ); } }
Example #18
Source File: MultipleHiLoPerTableGenerator.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public void registerExportables(Database database) { final Namespace namespace = database.locateNamespace( qualifiedTableName.getCatalogName(), qualifiedTableName.getSchemaName() ); Table table = namespace.locateTable( qualifiedTableName.getObjectName() ); if ( table == null ) { table = namespace.createTable( qualifiedTableName.getObjectName(), false ); // todo : note sure the best solution here. do we add the columns if missing? other? table.setPrimaryKey( new PrimaryKey( table ) ); final Column pkColumn = new ExportableColumn( database, table, segmentColumnName, StringType.INSTANCE, database.getDialect().getTypeName( Types.VARCHAR, keySize, 0, 0 ) ); pkColumn.setNullable( false ); table.addColumn( pkColumn ); table.getPrimaryKey().addColumn( pkColumn ); final Column valueColumn = new ExportableColumn( database, table, valueColumnName, LongType.INSTANCE ); table.addColumn( valueColumn ); } final JdbcEnvironment jdbcEnvironment = database.getJdbcEnvironment(); // allow physical naming strategies a chance to kick in tableName = jdbcEnvironment.getQualifiedObjectNameFormatter().format( table.getQualifiedTableName(), jdbcEnvironment.getDialect() ); query = "select " + valueColumnName + " from " + jdbcEnvironment.getDialect().appendLockHint( LockMode.PESSIMISTIC_WRITE, tableName ) + " where " + segmentColumnName + " = '" + segmentName + "'" + jdbcEnvironment.getDialect().getForUpdateString(); update = "update " + tableName + " set " + valueColumnName + " = ? where " + valueColumnName + " = ? and " + segmentColumnName + " = '" + segmentName + "'"; insert = "insert into " + tableName + "(" + segmentColumnName + ", " + valueColumnName + ") " + "values('" + segmentName + "', ?)"; }
Example #19
Source File: SequenceStructure.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public void registerExportables(Database database) { buildSequence( database ); this.sql = database.getJdbcEnvironment().getDialect().getSequenceNextValString( sequenceName ); }
Example #20
Source File: TableStructure.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public void registerExportables(Database database) { final JdbcEnvironment jdbcEnvironment = database.getJdbcEnvironment(); final Dialect dialect = jdbcEnvironment.getDialect(); final Namespace namespace = database.locateNamespace( logicalQualifiedTableName.getCatalogName(), logicalQualifiedTableName.getSchemaName() ); Table table = namespace.locateTable( logicalQualifiedTableName.getObjectName() ); if ( table == null ) { table = namespace.createTable( logicalQualifiedTableName.getObjectName(), false ); } this.tableNameText = jdbcEnvironment.getQualifiedObjectNameFormatter().format( table.getQualifiedTableName(), dialect ); this.valueColumnNameText = logicalValueColumnNameIdentifier.render( dialect ); this.selectQuery = "select " + valueColumnNameText + " as id_val" + " from " + dialect.appendLockHint( LockMode.PESSIMISTIC_WRITE, tableNameText ) + dialect.getForUpdateString(); this.updateQuery = "update " + tableNameText + " set " + valueColumnNameText + "= ?" + " where " + valueColumnNameText + "=?"; ExportableColumn valueColumn = new ExportableColumn( database, table, valueColumnNameText, LongType.INSTANCE ); table.addColumn( valueColumn ); table.addInitCommand( new InitCommand( "insert into " + tableNameText + " values ( " + initialValue + " )" ) ); }
Example #21
Source File: TableGenerator.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public void registerExportables(Database database) { final Dialect dialect = database.getJdbcEnvironment().getDialect(); final Namespace namespace = database.locateNamespace( qualifiedTableName.getCatalogName(), qualifiedTableName.getSchemaName() ); Table table = namespace.locateTable( qualifiedTableName.getObjectName() ); if ( table == null ) { table = namespace.createTable( qualifiedTableName.getObjectName(), false ); // todo : note sure the best solution here. do we add the columns if missing? other? final Column segmentColumn = new ExportableColumn( database, table, segmentColumnName, StringType.INSTANCE, dialect.getTypeName( Types.VARCHAR, segmentValueLength, 0, 0 ) ); segmentColumn.setNullable( false ); table.addColumn( segmentColumn ); // lol table.setPrimaryKey( new PrimaryKey( table ) ); table.getPrimaryKey().addColumn( segmentColumn ); final Column valueColumn = new ExportableColumn( database, table, valueColumnName, LongType.INSTANCE ); table.addColumn( valueColumn ); } // allow physical naming strategies a chance to kick in this.renderedTableName = database.getJdbcEnvironment().getQualifiedObjectNameFormatter().format( table.getQualifiedTableName(), dialect ); table.addInitCommand( generateInsertInitCommand() ); this.selectQuery = buildSelectQuery( dialect ); this.updateQuery = buildUpdateQuery(); this.insertQuery = buildInsertQuery(); }
Example #22
Source File: SequenceStyleGenerator.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public void registerExportables(Database database) { databaseStructure.registerExportables( database ); }
Example #23
Source File: AbstractSchemaMigrator.java From lams with GNU General Public License v2.0 | 4 votes |
private String getDefaultSchemaName(Database database, Dialect dialect) { final Identifier identifier = database.getDefaultNamespace().getPhysicalName().getSchema(); return identifier == null ? null : identifier.render( dialect ); }
Example #24
Source File: AbstractSchemaMigrator.java From lams with GNU General Public License v2.0 | 4 votes |
private String getDefaultCatalogName(Database database, Dialect dialect) { final Identifier identifier = database.getDefaultNamespace().getPhysicalName().getCatalog(); return identifier == null ? null : identifier.render( dialect ); }
Example #25
Source File: Component.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public void registerExportables(Database database) { if ( ExportableProducer.class.isInstance( subGenerator ) ) { ( (ExportableProducer) subGenerator ).registerExportables( database ); } }
Example #26
Source File: PrevalidatedQuarkusMetadata.java From quarkus with Apache License 2.0 | 4 votes |
@Override public Database getDatabase() { return metadata.getDatabase(); }
Example #27
Source File: Metadata.java From lams with GNU General Public License v2.0 | 2 votes |
/** * Retrieve the database model. * * @return The database model. */ Database getDatabase();