org.hibernate.tool.schema.spi.SchemaManagementTool Java Examples
The following examples show how to use
org.hibernate.tool.schema.spi.SchemaManagementTool.
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: BaseReactiveTest.java From hibernate-reactive with GNU Lesser General Public License v2.1 | 6 votes |
private void mysqlConfiguration(StandardServiceRegistry registry) { registry.getService( ConnectionProvider.class ); //force the NoJdbcConnectionProvider to load first registry.getService( SchemaManagementTool.class ) .setCustomDatabaseGenerationTarget( new ReactiveGenerationTarget(registry) { @Override public void prepare() { super.prepare(); if ( dbType() == DBType.MYSQL ) { accept("set foreign_key_checks = 0"); } } @Override public void release() { if ( dbType() == DBType.MYSQL ) { accept("set foreign_key_checks = 1"); } super.release(); } } ); }
Example #2
Source File: SpannerServiceContributor.java From google-cloud-spanner-hibernate with GNU Lesser General Public License v2.1 | 6 votes |
@Override public void contribute(StandardServiceRegistryBuilder serviceRegistryBuilder) { serviceRegistryBuilder // The custom Hibernate schema management tool for Spanner. .addInitiator(new StandardServiceInitiator() { @Override public Service initiateService(Map configurationValues, ServiceRegistryImplementor registry) { return SCHEMA_MANAGEMENT_TOOL; } @Override public Class getServiceInitiated() { return SchemaManagementTool.class; } }) // The user agent JDBC connection property to identify the library. .applySetting("hibernate.connection.userAgent", HIBERNATE_API_CLIENT_LIB_TOKEN) // Create a unique index for a table if it does not already exist when in UPDATE mode. .applySetting( "hibernate.schema_update.unique_constraint_strategy", UniqueConstraintSchemaUpdateStrategy.RECREATE_QUIETLY) // Allows entities to be used with InheritanceType.JOINED in Spanner. .applySetting("hibernate.hql.bulk_id_strategy", InlineIdsOrClauseBulkIdStrategy.INSTANCE); }
Example #3
Source File: FastBootHibernateReactivePersistenceProvider.java From quarkus with Apache License 2.0 | 6 votes |
private StandardServiceRegistry rewireMetadataAndExtractServiceRegistry(RuntimeSettings runtimeSettings, RecordedState rs, String persistenceUnitName) { PreconfiguredReactiveServiceRegistryBuilder serviceRegistryBuilder = new PreconfiguredReactiveServiceRegistryBuilder( rs); registerVertxPool(persistenceUnitName, runtimeSettings, serviceRegistryBuilder); runtimeSettings.getSettings().forEach((key, value) -> { serviceRegistryBuilder.applySetting(key, value); }); for (ProvidedService<?> providedService : rs.getProvidedServices()) { serviceRegistryBuilder.addService(providedService); } StandardServiceRegistryImpl standardServiceRegistry = serviceRegistryBuilder.buildNewServiceRegistry(); standardServiceRegistry.getService(SchemaManagementTool.class) .setCustomDatabaseGenerationTarget(new ReactiveGenerationTarget(standardServiceRegistry)); return standardServiceRegistry; }
Example #4
Source File: SchemaValidator.java From lams with GNU General Public License v2.0 | 6 votes |
@SuppressWarnings("unchecked") public void validate(Metadata metadata, ServiceRegistry serviceRegistry) { LOG.runningSchemaValidator(); Map config = new HashMap(); config.putAll( serviceRegistry.getService( ConfigurationService.class ).getSettings() ); final SchemaManagementTool tool = serviceRegistry.getService( SchemaManagementTool.class ); final ExecutionOptions executionOptions = SchemaManagementToolCoordinator.buildExecutionOptions( config, ExceptionHandlerHaltImpl.INSTANCE ); tool.getSchemaValidator( config ).doValidation( metadata, executionOptions ); }
Example #5
Source File: NoJdbcConnectionProviderInitiator.java From hibernate-reactive with GNU Lesser General Public License v2.1 | 5 votes |
@Override public ConnectionProvider initiateService(Map configurationValues, ServiceRegistryImplementor registry) { ConnectionProvider provider = ConnectionProviderInitiator.INSTANCE.initiateService(configurationValues, registry); if (provider instanceof DriverManagerConnectionProviderImpl) { registry.getService( SchemaManagementTool.class ) .setCustomDatabaseGenerationTarget( new ReactiveGenerationTarget(registry) ); return NoJdbcConnectionProvider.INSTANCE; } return provider; }
Example #6
Source File: SchemaUpdate.java From lams with GNU General Public License v2.0 | 5 votes |
@SuppressWarnings("unchecked") public void execute(EnumSet<TargetType> targetTypes, Metadata metadata, ServiceRegistry serviceRegistry) { if ( targetTypes.isEmpty() ) { LOG.debug( "Skipping SchemaExport as no targets were specified" ); return; } exceptions.clear(); LOG.runningHbm2ddlSchemaUpdate(); Map config = new HashMap(); config.putAll( serviceRegistry.getService( ConfigurationService.class ).getSettings() ); config.put( AvailableSettings.HBM2DDL_DELIMITER, delimiter ); config.put( AvailableSettings.FORMAT_SQL, format ); final SchemaManagementTool tool = serviceRegistry.getService( SchemaManagementTool.class ); final ExceptionHandler exceptionHandler = haltOnError ? ExceptionHandlerHaltImpl.INSTANCE : new ExceptionHandlerCollectingImpl(); final ExecutionOptions executionOptions = SchemaManagementToolCoordinator.buildExecutionOptions( config, exceptionHandler ); final TargetDescriptor targetDescriptor = SchemaExport.buildTargetDescriptor( targetTypes, outputFile, serviceRegistry ); try { tool.getSchemaMigrator( config ).doMigration( metadata, executionOptions, targetDescriptor ); } finally { if ( exceptionHandler instanceof ExceptionHandlerCollectingImpl ) { exceptions.addAll( ( (ExceptionHandlerCollectingImpl) exceptionHandler ).getExceptions() ); } } }
Example #7
Source File: SchemaCreatorImpl.java From lams with GNU General Public License v2.0 | 5 votes |
public SchemaCreatorImpl(ServiceRegistry serviceRegistry, SchemaFilter schemaFilter) { SchemaManagementTool smt = serviceRegistry.getService( SchemaManagementTool.class ); if ( smt == null || !HibernateSchemaManagementTool.class.isInstance( smt ) ) { smt = new HibernateSchemaManagementTool(); ( (HibernateSchemaManagementTool) smt ).injectServices( (ServiceRegistryImplementor) serviceRegistry ); } this.tool = (HibernateSchemaManagementTool) smt; this.schemaFilter = schemaFilter; }
Example #8
Source File: SchemaManagementToolInitiator.java From lams with GNU General Public License v2.0 | 5 votes |
public SchemaManagementTool initiateService(Map configurationValues, ServiceRegistryImplementor registry) { final Object setting = configurationValues.get( AvailableSettings.SCHEMA_MANAGEMENT_TOOL ); SchemaManagementTool tool = registry.getService( StrategySelector.class ).resolveStrategy( SchemaManagementTool.class, setting ); if ( tool == null ) { tool = new HibernateSchemaManagementTool(); } return tool; }
Example #9
Source File: SchemaDropperImpl.java From lams with GNU General Public License v2.0 | 5 votes |
public SchemaDropperImpl(ServiceRegistry serviceRegistry, SchemaFilter schemaFilter) { SchemaManagementTool smt = serviceRegistry.getService( SchemaManagementTool.class ); if ( smt == null || !HibernateSchemaManagementTool.class.isInstance( smt ) ) { smt = new HibernateSchemaManagementTool(); ( (HibernateSchemaManagementTool) smt ).injectServices( (ServiceRegistryImplementor) serviceRegistry ); } this.tool = (HibernateSchemaManagementTool) smt; this.schemaFilter = schemaFilter; }
Example #10
Source File: SchemaExport.java From lams with GNU General Public License v2.0 | 4 votes |
public void doExecution( Action action, boolean needsJdbc, Metadata metadata, ServiceRegistry serviceRegistry, TargetDescriptor targetDescriptor) { Map config = new HashMap(); config.putAll( serviceRegistry.getService( ConfigurationService.class ).getSettings() ); config.put( AvailableSettings.HBM2DDL_DELIMITER, delimiter ); config.put( AvailableSettings.FORMAT_SQL, format ); config.put( AvailableSettings.HBM2DDL_IMPORT_FILES, importFiles ); final SchemaManagementTool tool = serviceRegistry.getService( SchemaManagementTool.class ); final ExceptionHandler exceptionHandler = haltOnError ? ExceptionHandlerHaltImpl.INSTANCE : new ExceptionHandlerCollectingImpl(); final ExecutionOptions executionOptions = SchemaManagementToolCoordinator.buildExecutionOptions( config, exceptionHandler ); final SourceDescriptor sourceDescriptor = new SourceDescriptor() { @Override public SourceType getSourceType() { return SourceType.METADATA; } @Override public ScriptSourceInput getScriptSourceInput() { return null; } }; try { if ( action.doDrop() ) { tool.getSchemaDropper( config ).doDrop( metadata, executionOptions, sourceDescriptor, targetDescriptor ); } if ( action.doCreate() ) { tool.getSchemaCreator( config ).doCreation( metadata, executionOptions, sourceDescriptor, targetDescriptor ); } } finally { if ( exceptionHandler instanceof ExceptionHandlerCollectingImpl ) { exceptions.addAll( ( (ExceptionHandlerCollectingImpl) exceptionHandler ).getExceptions() ); } } }
Example #11
Source File: SchemaManagementToolInitiator.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public Class<SchemaManagementTool> getServiceInitiated() { return SchemaManagementTool.class; }