Java 类org.hibernate.engine.jdbc.spi.JdbcServices 实例源码

项目:lams    文件:TypeSafeActivator.java   
@SuppressWarnings({"unchecked", "UnusedParameters"})
private static void applyRelationalConstraints(ValidatorFactory factory, ActivationContext activationContext) {
    final Properties properties = activationContext.getConfiguration().getProperties();
    if ( ! ConfigurationHelper.getBoolean( BeanValidationIntegrator.APPLY_CONSTRAINTS, properties, true ) ){
        LOG.debug( "Skipping application of relational constraints from legacy Hibernate Validator" );
        return;
    }

    final Set<ValidationMode> modes = activationContext.getValidationModes();
    if ( ! ( modes.contains( ValidationMode.DDL ) || modes.contains( ValidationMode.AUTO ) ) ) {
        return;
    }

    applyRelationalConstraints(
            factory,
            activationContext.getConfiguration().createMappings().getClasses().values(),
            properties,
            activationContext.getServiceRegistry().getService( JdbcServices.class ).getDialect()
    );
}
项目:lams    文件:SchemaExport.java   
public SchemaExport(ServiceRegistry serviceRegistry, Configuration configuration) {
    this.connectionHelper = new SuppliedConnectionProviderConnectionHelper(
            serviceRegistry.getService( ConnectionProvider.class )
    );
    this.sqlStatementLogger = serviceRegistry.getService( JdbcServices.class ).getSqlStatementLogger();
    this.formatter = ( sqlStatementLogger.isFormat() ? FormatStyle.DDL : FormatStyle.NONE ).getFormatter();
    this.sqlExceptionHelper = serviceRegistry.getService( JdbcServices.class ).getSqlExceptionHelper();

    this.importFiles = ConfigurationHelper.getString(
            AvailableSettings.HBM2DDL_IMPORT_FILES,
            configuration.getProperties(),
            DEFAULT_IMPORT_FILE
    );

    final Dialect dialect = serviceRegistry.getService( JdbcServices.class ).getDialect();
    this.dropSQL = configuration.generateDropSchemaScript( dialect );
    this.createSQL = configuration.generateSchemaCreationScript( dialect );
}
项目:lams    文件:SchemaExport.java   
public SchemaExport(MetadataImplementor metadata) {
    ServiceRegistry serviceRegistry = metadata.getServiceRegistry();
    this.connectionHelper = new SuppliedConnectionProviderConnectionHelper(
            serviceRegistry.getService( ConnectionProvider.class )
    );
       JdbcServices jdbcServices = serviceRegistry.getService( JdbcServices.class );
    this.sqlStatementLogger = jdbcServices.getSqlStatementLogger();
    this.formatter = ( sqlStatementLogger.isFormat() ? FormatStyle.DDL : FormatStyle.NONE ).getFormatter();
    this.sqlExceptionHelper = jdbcServices.getSqlExceptionHelper();

    this.importFiles = ConfigurationHelper.getString(
            AvailableSettings.HBM2DDL_IMPORT_FILES,
            serviceRegistry.getService( ConfigurationService.class ).getSettings(),
            DEFAULT_IMPORT_FILE
    );

    final Dialect dialect = jdbcServices.getDialect();
    this.dropSQL = metadata.getDatabase().generateDropSchemaScript( dialect );
    this.createSQL = metadata.getDatabase().generateSchemaCreationScript( dialect );
}
项目:lams    文件:LogicalConnectionImpl.java   
/**
 * Constructs a LogicalConnectionImpl
 *
 * @param userSuppliedConnection The user-supplied connection
 * @param connectionReleaseMode The connection release mode to use
 * @param jdbcServices JdbcServices
 * @param jdbcConnectionAccess JDBC Connection access
 */
public LogicalConnectionImpl(
        Connection userSuppliedConnection,
        ConnectionReleaseMode connectionReleaseMode,
        JdbcServices jdbcServices,
        JdbcConnectionAccess jdbcConnectionAccess) {
    this(
            connectionReleaseMode,
            jdbcServices,
            jdbcConnectionAccess,
            (userSuppliedConnection != null),
            false,
            new ArrayList<ConnectionObserver>()
    );
    this.physicalConnection = userSuppliedConnection;
}
项目:lams    文件:LogicalConnectionImpl.java   
/**
 * Constructs a LogicalConnectionImpl.  This for used from deserialization
 */
private LogicalConnectionImpl(
        ConnectionReleaseMode connectionReleaseMode,
        JdbcServices jdbcServices,
        JdbcConnectionAccess jdbcConnectionAccess,
        boolean isUserSuppliedConnection,
        boolean isClosed,
        List<ConnectionObserver> observers) {
    this.connectionReleaseMode = determineConnectionReleaseMode(
            jdbcConnectionAccess, isUserSuppliedConnection, connectionReleaseMode
    );
    this.jdbcServices = jdbcServices;
    this.jdbcConnectionAccess = jdbcConnectionAccess;
    this.observers = observers;

    this.isUserSuppliedConnection = isUserSuppliedConnection;
    this.isClosed = isClosed;
}
项目:lams    文件:TemporaryTableBulkIdStrategy.java   
@Override
public void execute(Connection connection) {
    try {
        Statement statement = connection.createStatement();
        try {
            statement.executeUpdate( persister.getTemporaryIdTableDDL() );
            persister.getFactory()
                    .getServiceRegistry()
                    .getService( JdbcServices.class )
                    .getSqlExceptionHelper()
                    .handleAndClearWarnings( statement, CREATION_WARNING_HANDLER );
        }
        finally {
            try {
                statement.close();
            }
            catch( Throwable ignore ) {
                // ignore
            }
        }
    }
    catch( Exception e ) {
        log.debug( "unable to create temporary id table [" + e.getMessage() + "]" );
    }
}
项目:windup-rulesets    文件:CustomBuildIdDelegate.java   
@Override
public void execute(Connection connection) {
    try {
        Statement statement = connection.createStatement();
        try {
            statement.executeUpdate( persister.getTemporaryIdTableDDL() );
            persister.getFactory()
                    .getServiceRegistry()
                    .getService( JdbcServices.class )
                    .getSqlExceptionHelper()
                    .handleAndClearWarnings( statement, CREATION_WARNING_HANDLER );
        }
        finally {
            try {
                statement.close();
            }
            catch( Throwable ignore ) {
                // ignore
            }
        }
    }
    catch( Exception e ) {
        log.debug( "unable to create temporary id table [" + e.getMessage() + "]" );
    }
}
项目:lams    文件:SchemaUpdate.java   
public SchemaUpdate(ServiceRegistry serviceRegistry, Configuration cfg) throws HibernateException {
    this.configuration = cfg;

    final JdbcServices jdbcServices = serviceRegistry.getService( JdbcServices.class );
    this.dialect = jdbcServices.getDialect();
    this.connectionHelper = new SuppliedConnectionProviderConnectionHelper( jdbcServices.getConnectionProvider() );

    this.sqlExceptionHelper = new SqlExceptionHelper();
    this.sqlStatementLogger = jdbcServices.getSqlStatementLogger();
    this.formatter = ( sqlStatementLogger.isFormat() ? FormatStyle.DDL : FormatStyle.NONE ).getFormatter();
}
项目:lams    文件:BasicConnectionCreator.java   
protected JDBCException convertSqlException(String message, SQLException e) {
    // if JdbcServices#getSqlExceptionHelper is available, use it...
    final JdbcServices jdbcServices = serviceRegistry.getService( JdbcServices.class );
    if ( jdbcServices != null && jdbcServices.getSqlExceptionHelper() != null ) {
        return jdbcServices.getSqlExceptionHelper().convert( e, message, null );
    }

    // likely we are still in the process of initializing the ServiceRegistry, so use the simplified
    // SQLException conversion
    return simpleConverterAccess.getValue().convert( e, message, null );
}
项目:lams    文件:ResultSetReturnImpl.java   
/**
 * Constructs a ResultSetReturnImpl
 *
 * @param jdbcCoordinator The JdbcCoordinator
 */
public ResultSetReturnImpl(JdbcCoordinator jdbcCoordinator) {
    this.jdbcCoordinator = jdbcCoordinator;

    final JdbcServices jdbcServices = jdbcCoordinator.getTransactionCoordinator().getTransactionContext()
            .getTransactionEnvironment()
            .getJdbcServices();

    this.dialect = jdbcServices.getDialect();
    this.sqlStatementLogger = jdbcServices.getSqlStatementLogger();
    this.sqlExceptionHelper = jdbcServices.getSqlExceptionHelper();
}
项目:lams    文件:AbstractBatchImpl.java   
protected AbstractBatchImpl(BatchKey key, JdbcCoordinator jdbcCoordinator) {
    if ( key == null ) {
        throw new IllegalArgumentException( "batch key cannot be null" );
    }
    if ( jdbcCoordinator == null ) {
        throw new IllegalArgumentException( "JDBC coordinator cannot be null" );
    }
    this.key = key;
    this.jdbcCoordinator = jdbcCoordinator;

    this.transactionContext = jdbcCoordinator.getTransactionCoordinator().getTransactionContext();
    final JdbcServices jdbcServices = transactionContext.getTransactionEnvironment().getJdbcServices();
    this.sqlStatementLogger = jdbcServices.getSqlStatementLogger();
    this.sqlExceptionHelper = jdbcServices.getSqlExceptionHelper();
}
项目:lams    文件:TransactionEnvironmentImpl.java   
public TransactionEnvironmentImpl(SessionFactoryImpl sessionFactory) {
    this.sessionFactory = sessionFactory;
    this.statisticsImplementor = sessionFactory.getStatisticsImplementor();
    this.serviceRegistry = sessionFactory.getServiceRegistry();
    this.jdbcServices = serviceRegistry.getService( JdbcServices.class );
    this.jtaPlatform = serviceRegistry.getService( JtaPlatform.class );
    this.transactionFactory = serviceRegistry.getService( TransactionFactory.class );
}
项目:lams    文件:PersistentTableBulkIdStrategy.java   
@Override
public void prepare(
        JdbcServices jdbcServices,
        JdbcConnectionAccess connectionAccess,
        Mappings mappings,
        Mapping mapping,
        Map settings) {
    this.catalog = ConfigurationHelper.getString(
            CATALOG,
            settings,
            ConfigurationHelper.getString( AvailableSettings.DEFAULT_CATALOG, settings )
    );
    this.schema = ConfigurationHelper.getString(
            SCHEMA,
            settings,
            ConfigurationHelper.getString( AvailableSettings.DEFAULT_SCHEMA, settings )
    );
    this.cleanUpTables = ConfigurationHelper.getBoolean( CLEAN_UP_ID_TABLES, settings, false );

    final Iterator<PersistentClass> entityMappings = mappings.iterateClasses();
    final List<Table> idTableDefinitions = new ArrayList<Table>();
    while ( entityMappings.hasNext() ) {
        final PersistentClass entityMapping = entityMappings.next();
        final Table idTableDefinition = generateIdTableDefinition( entityMapping );
        idTableDefinitions.add( idTableDefinition );
    }
    exportTableDefinitions( idTableDefinitions, jdbcServices, connectionAccess, mappings, mapping );
}
项目:mycore    文件:MCRHibernateConfigHelper.java   
public static void checkEntityManagerFactoryConfiguration(EntityManagerFactory entityManagerFactory) {
    try {
        SessionFactoryImpl sessionFactoryImpl = entityManagerFactory.unwrap(SessionFactoryImpl.class);
        if (PostgreSQL9Dialect.class
            .isInstance(sessionFactoryImpl.getServiceRegistry().getService(JdbcServices.class).getDialect())) {
            //fix ClassLeftUnique and ClassRightUnique, as PostgreSQL cannot evaluate them on statement level
            modifyConstraints(sessionFactoryImpl);
        }
    } catch (PersistenceException e) {
        LogManager.getLogger()
            .warn("Unsupported EntityManagerFactory found: {}", entityManagerFactory.getClass().getName());
    }
}
项目:hibernate-single-table-bulk-id-strategy    文件:SingleGlobalTemporaryTableBulkIdStrategy.java   
@Override
public void prepare(JdbcServices jdbcServices, JdbcConnectionAccess connectionAccess, MetadataImplementor metadata, SessionFactoryOptions sessionFactoryOptions) {
    ConfigurationService configService = sessionFactoryOptions.getServiceRegistry().getService(ConfigurationService.class);
    this.fullyQualifiedTableName = Objects.requireNonNull(configService.getSetting(TABLE, String.class, null), "Property " + TABLE + " must be set.");
    this.idColumn = configService.getSetting(ID_COLUMN, String.class, "ID");
    this.discriminatorColumn = configService.getSetting(DISCRIMINATOR_COLUMN, String.class, "ENTITY_NAME");
    this.cleanRows = configService.getSetting(CLEAN_ROWS, StandardConverters.BOOLEAN, false);
}
项目:cte-multi-table-bulk-id-stategy    文件:CTEMultiTableBulkIdStrategy.java   
@Override
public void prepare(
        JdbcServices jdbcServices,
        JdbcConnectionAccess jdbcConnectionAccess,
        MetadataImplementor metadataImplementor,
        SessionFactoryOptions sessionFactoryOptions) {

}
项目:books    文件:DbOpenHelper.java   
public DbOpenHelper(ServiceRegistry serviceRegistry) throws HibernateException {
    final JdbcServices jdbcServices = serviceRegistry.getService(JdbcServices.class);
    connectionHelper = new SuppliedConnectionProviderConnectionHelper(jdbcServices.getConnectionProvider());

    sqlStatementLogger = jdbcServices.getSqlStatementLogger();
    formatter = (sqlStatementLogger.isFormat() ? FormatStyle.DDL : FormatStyle.NONE).getFormatter();
}
项目:lightmare    文件:TableGeneratorExt.java   
/**
    * Updates (or inserts) table column value with existing id
    * 
    * @param session
    * @param currentValue
    * @return {@link Serializable}
    */
   public Serializable generateIncrementally(final SessionImplementor session,
    final long currentValue) {

final SqlStatementLogger statementLogger = session.getFactory()
    .getServiceRegistry().getService(JdbcServices.class)
    .getSqlStatementLogger();
final AccessCallback callback = new AccessCallbackImpl(session,
    currentValue, statementLogger);

return optimizer.generate(callback);
   }
项目:lemon    文件:SessionFactoryWrapper.java   
public JdbcServices getJdbcServices() {
    return sessionFactoryImplementor.getJdbcServices();
}
项目:lams    文件:SchemaValidator.java   
public SchemaValidator(ServiceRegistry serviceRegistry, Configuration cfg ) throws HibernateException {
    this.configuration = cfg;
    final JdbcServices jdbcServices = serviceRegistry.getService( JdbcServices.class );
    this.dialect = jdbcServices.getDialect();
    this.connectionHelper = new SuppliedConnectionProviderConnectionHelper( jdbcServices.getConnectionProvider() );
}
项目:lams    文件:JdbcServicesInitiator.java   
@Override
public Class<JdbcServices> getServiceInitiated() {
    return JdbcServices.class;
}
项目:lams    文件:JdbcServicesInitiator.java   
@Override
public JdbcServices initiateService(Map configurationValues, ServiceRegistryImplementor registry) {
    return new JdbcServicesImpl();
}
项目:lams    文件:LogicalConnectionImpl.java   
@Override
public JdbcServices getJdbcServices() {
    return jdbcServices;
}
项目:lams    文件:StandardRefCursorSupport.java   
/**
 * Hook for service registry to be able to inject JdbcServices
 *
 * @param jdbcServices The JdbcServices service
 */
@InjectService
@SuppressWarnings("UnusedDeclaration")
public void injectJdbcServices(JdbcServices jdbcServices) {
    this.jdbcServices = jdbcServices;
}
项目:lams    文件:TableStructure.java   
@Override
public AccessCallback buildCallback(final SessionImplementor session) {
    final SqlStatementLogger statementLogger = session.getFactory().getServiceRegistry()
            .getService( JdbcServices.class )
            .getSqlStatementLogger();
    final SessionEventListenerManager statsCollector = session.getEventListenerManager();

    return new AccessCallback() {
        @Override
        public IntegralDataTypeHolder getNextValue() {
            return session.getTransactionCoordinator().getTransaction().createIsolationDelegate().delegateWork(
                    new AbstractReturningWork<IntegralDataTypeHolder>() {
                        @Override
                        public IntegralDataTypeHolder execute(Connection connection) throws SQLException {
                            final IntegralDataTypeHolder value = makeValue();
                            int rows;
                            do {
                                final PreparedStatement selectStatement = prepareStatement( connection, selectQuery, statementLogger, statsCollector );
                                try {
                                    final ResultSet selectRS = executeQuery( selectStatement, statsCollector );
                                    if ( !selectRS.next() ) {
                                        final String err = "could not read a hi value - you need to populate the table: " + tableName;
                                        LOG.error( err );
                                        throw new IdentifierGenerationException( err );
                                    }
                                    value.initialize( selectRS, 1 );
                                    selectRS.close();
                                }
                                catch (SQLException sqle) {
                                    LOG.error( "could not read a hi value", sqle );
                                    throw sqle;
                                }
                                finally {
                                    selectStatement.close();
                                }


                                final PreparedStatement updatePS = prepareStatement( connection, updateQuery, statementLogger, statsCollector );
                                try {
                                    final int increment = applyIncrementSizeToSourceValues ? incrementSize : 1;
                                    final IntegralDataTypeHolder updateValue = value.copy().add( increment );
                                    updateValue.bind( updatePS, 1 );
                                    value.bind( updatePS, 2 );
                                    rows = executeUpdate( updatePS, statsCollector );
                                }
                                catch (SQLException e) {
                                    LOG.unableToUpdateQueryHiValue( tableName, e );
                                    throw e;
                                }
                                finally {
                                    updatePS.close();
                                }
                            } while ( rows == 0 );

                            accessCounter++;

                            return value;
                        }
                    },
                    true
            );
        }

        @Override
        public String getTenantIdentifier() {
            return session.getTenantIdentifier();
        }
    };
}
项目:lams    文件:TableGenerator.java   
protected IntegralDataTypeHolder generateHolder(final SessionImplementor session) {
    final SqlStatementLogger statementLogger = session.getFactory().getServiceRegistry()
            .getService( JdbcServices.class )
            .getSqlStatementLogger();
    final SessionEventListenerManager listeners = session.getEventListenerManager();

    return session.getTransactionCoordinator().getTransaction().createIsolationDelegate().delegateWork(
            new AbstractReturningWork<IntegralDataTypeHolder>() {
                @Override
                public IntegralDataTypeHolder execute(Connection connection) throws SQLException {
                    IntegralDataTypeHolder value = buildHolder();
                    int rows;

                    // The loop ensures atomicity of the select + update even for no transaction or
                    // read committed isolation level
                    do {
                        final PreparedStatement qps = prepareStatement( connection, query, statementLogger, listeners );
                        try {
                            ResultSet rs = executeQuery( qps, listeners );
                            if ( !rs.next() ) {
                                String err = "could not read a hi value - you need to populate the table: " + tableName;
                                LOG.error(err);
                                throw new IdentifierGenerationException(err);
                            }
                            value.initialize( rs, 1 );
                            rs.close();
                        }
                        catch (SQLException e) {
                            LOG.error("Could not read a hi value", e);
                            throw e;
                        }
                        finally {
                            qps.close();
                        }

                        final PreparedStatement ups = prepareStatement( connection, update, statementLogger, listeners );
                        try {
                            value.copy().increment().bind( ups, 1 );
                            value.bind( ups, 2 );
                            rows = executeUpdate( ups, listeners );
                        }
                        catch (SQLException sqle) {
                            LOG.error(LOG.unableToUpdateHiValue(tableName), sqle);
                            throw sqle;
                        }
                        finally {
                            ups.close();
                        }
                    }
                    while (rows==0);
                    return value;
                }
            },
            true
    );
}
项目:lams    文件:DefaultIdentifierGeneratorFactory.java   
@Override
public void injectServices(ServiceRegistryImplementor serviceRegistry) {
    this.dialect = serviceRegistry.getService( JdbcServices.class ).getDialect();
}
项目:lams    文件:TransactionEnvironmentImpl.java   
@Override
public JdbcServices getJdbcServices() {
    return jdbcServices;
}
项目:lams    文件:SessionFactoryImpl.java   
public JdbcServices getJdbcServices() {
    return jdbcServices;
}
项目:lams    文件:TemporaryTableBulkIdStrategy.java   
@Override
public void prepare(JdbcServices jdbcServices, JdbcConnectionAccess connectionAccess, Mappings mappings, Mapping mapping, Map settings) {
    // nothing to do
}
项目:lams    文件:TemporaryTableBulkIdStrategy.java   
@Override
public void release(JdbcServices jdbcServices, JdbcConnectionAccess connectionAccess) {
    // nothing to do
}
项目:hibernate-ogm-ignite    文件:IgniteDatastoreProvider.java   
@Override
public void injectServices(ServiceRegistryImplementor serviceRegistryImplementor) {
    this.jtaPlatform = serviceRegistryImplementor.getService( JtaPlatform.class );
    this.jdbcServices = serviceRegistryImplementor.getService( JdbcServices.class );
}
项目:hibernate-single-table-bulk-id-strategy    文件:SingleGlobalTemporaryTableBulkIdStrategy.java   
@Override
public void release(JdbcServices jdbcServices, JdbcConnectionAccess connectionAccess) {
}
项目:cte-multi-table-bulk-id-stategy    文件:CTEMultiTableBulkIdStrategy.java   
@Override
public void release(JdbcServices jdbcServices,
        JdbcConnectionAccess connectionAccess) {
    // nothing to do
}
项目:cte-multi-table-bulk-id-stategy    文件:CTEMultiTableBulkIdStrategy.java   
@Override
public void prepare(JdbcServices jdbcServices,
        JdbcConnectionAccess connectionAccess, Mappings arg2, Mapping arg3,
        Map arg4) {
    // nothing to do
}
项目:cte-multi-table-bulk-id-stategy    文件:CTEMultiTableBulkIdStrategy.java   
@Override
public void release(JdbcServices jdbcServices,
        JdbcConnectionAccess connectionAccess) {
    // nothing to do
}
项目:hibernate-dynamic-dialects    文件:SessionFactoryImpl.java   
public JdbcServices getJdbcServices() {
    return jdbcServices;
}
项目:jadira    文件:AbstractProxySharedSessionContractImplementor.java   
@Override
public JdbcServices getJdbcServices() {
    return target.getJdbcServices();
}
项目:lams    文件:TransactionEnvironment.java   
/**
 * Retrieve the JDBC services for this environment.
 *
 * @return The JDBC services
 */
public JdbcServices getJdbcServices();
项目:lams    文件:SessionFactoryImplementor.java   
/**
 * Get the JdbcServices.
 * @return the JdbcServices
 */
public JdbcServices getJdbcServices();