Java Code Examples for org.hibernate.boot.model.relational.Database#locateNamespace()
The following examples show how to use
org.hibernate.boot.model.relational.Database#locateNamespace() .
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: 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 2
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 3
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 4
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 5
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 + "', ?)"; }