Package org.hibernate.engine.jdbc.spi

Examples of org.hibernate.engine.jdbc.spi.JdbcConnectionAccess


        AvailableSettings.SCHEMA_GEN_CONNECTION
    );

    if ( providedConnection != null ) {
      return new JdbcConnectionContext(
          new JdbcConnectionAccess() {
            @Override
            public Connection obtainConnection() throws SQLException {
              return providedConnection;
            }

            @Override
            public void releaseConnection(Connection connection) throws SQLException {
              // do nothing
            }

            @Override
            public boolean supportsAggressiveRelease() {
              return false;
            }
          },
          sqlStatementLogger
      );
    }

    final ConnectionProvider connectionProvider = serviceRegistry.getService( ConnectionProvider.class );
    if ( connectionProvider != null ) {
      return new JdbcConnectionContext(
          new JdbcConnectionAccess() {
            @Override
            public Connection obtainConnection() throws SQLException {
              return connectionProvider.getConnection();
            }
View Full Code Here


    }
    return rtn;
  }

  private JdbcConnectionAccess buildLocalConnectionAccess() {
    return new JdbcConnectionAccess() {
      @Override
      public Connection obtainConnection() throws SQLException {
        return settings.getMultiTenancyStrategy() == MultiTenancyStrategy.NONE
            ? serviceRegistry.getService( ConnectionProvider.class ).getConnection()
            : serviceRegistry.getService( MultiTenantConnectionProvider.class ).getAnyConnection();
View Full Code Here

    this.serviceRegistry = serviceRegistry;
  }

  @Override
  public void configure(Map configValues) {
    final JdbcConnectionAccess jdbcConnectionAccess = buildJdbcConnectionAccess( configValues );
    final DialectFactory dialectFactory = serviceRegistry.getService( DialectFactory.class );

    Dialect dialect = null;
    LobCreatorBuilder lobCreatorBuilder = null;

    boolean metaSupportsRefCursors = false;
    boolean metaSupportsNamedParams = false;
    boolean metaSupportsScrollable = false;
    boolean metaSupportsGetGeneratedKeys = false;
    boolean metaSupportsBatchUpdates = false;
    boolean metaReportsDDLCausesTxnCommit = false;
    boolean metaReportsDDLInTxnSupported = true;
    String extraKeywordsString = "";
    int sqlStateType = -1;
    boolean lobLocatorUpdateCopy = false;
    String catalogName = null;
    String schemaName = null;
    final LinkedHashSet<TypeInfo> typeInfoSet = new LinkedHashSet<TypeInfo>();

    // 'hibernate.temp.use_jdbc_metadata_defaults' is a temporary magic value.
    // The need for it is intended to be alleviated with future development, thus it is
    // not defined as an Environment constant...
    //
    // it is used to control whether we should consult the JDBC metadata to determine
    // certain Settings default values; it is useful to *not* do this when the database
    // may not be available (mainly in tools usage).
    final boolean useJdbcMetadata = ConfigurationHelper.getBoolean( "hibernate.temp.use_jdbc_metadata_defaults", configValues, true );
    if ( useJdbcMetadata ) {
      try {
        final Connection connection = jdbcConnectionAccess.obtainConnection();
        try {
          final DatabaseMetaData meta = connection.getMetaData();
          if ( LOG.isDebugEnabled() ) {
            LOG.debugf(
                "Database ->\n"
                    + "       name : %s\n"
                    + "    version : %s\n"
                    + "      major : %s\n"
                    + "      minor : %s",
                meta.getDatabaseProductName(),
                meta.getDatabaseProductVersion(),
                meta.getDatabaseMajorVersion(),
                meta.getDatabaseMinorVersion()
            );
            LOG.debugf(
                "Driver ->\n"
                    + "       name : %s\n"
                    + "    version : %s\n"
                    + "      major : %s\n"
                    + "      minor : %s",
                meta.getDriverName(),
                meta.getDriverVersion(),
                meta.getDriverMajorVersion(),
                meta.getDriverMinorVersion()
            );
            LOG.debugf( "JDBC version : %s.%s", meta.getJDBCMajorVersion(), meta.getJDBCMinorVersion() );
          }

          metaSupportsRefCursors = StandardRefCursorSupport.supportsRefCursors( meta );
          metaSupportsNamedParams = meta.supportsNamedParameters();
          metaSupportsScrollable = meta.supportsResultSetType( ResultSet.TYPE_SCROLL_INSENSITIVE );
          metaSupportsBatchUpdates = meta.supportsBatchUpdates();
          metaReportsDDLCausesTxnCommit = meta.dataDefinitionCausesTransactionCommit();
          metaReportsDDLInTxnSupported = !meta.dataDefinitionIgnoredInTransactions();
          metaSupportsGetGeneratedKeys = meta.supportsGetGeneratedKeys();
          extraKeywordsString = meta.getSQLKeywords();
          sqlStateType = meta.getSQLStateType();
          lobLocatorUpdateCopy = meta.locatorsUpdateCopy();
          typeInfoSet.addAll( TypeInfo.extractTypeInfo( meta ) );

          dialect = dialectFactory.buildDialect(
              configValues,
              new DialectResolutionInfoSource() {
                @Override
                public DialectResolutionInfo getDialectResolutionInfo() {
                  try {
                    return new DatabaseMetaDataDialectResolutionInfoAdapter( connection.getMetaData() );
                  }
                  catch ( SQLException sqlException ) {
                    throw new HibernateException(
                        "Unable to access java.sql.DatabaseMetaData to determine appropriate Dialect to use",
                        sqlException
                    );
                  }
                }
              }
          );

          catalogName = connection.getCatalog();
          final SchemaNameResolver schemaNameResolver = determineExplicitSchemaNameResolver( configValues );
          if ( schemaNameResolver == null ) {
// todo : add dialect method
//            schemaNameResolver = dialect.getSchemaNameResolver();
          }
          if ( schemaNameResolver != null ) {
            schemaName = schemaNameResolver.resolveSchemaName( connection );
          }
          lobCreatorBuilder = new LobCreatorBuilder( configValues, connection );
        }
        catch ( SQLException sqle ) {
          LOG.unableToObtainConnectionMetadata( sqle.getMessage() );
        }
        finally {
          if ( connection != null ) {
            jdbcConnectionAccess.releaseConnection( connection );
          }
        }
      }
      catch ( SQLException sqle ) {
        LOG.unableToObtainConnectionToQueryMetadata( sqle.getMessage() );
View Full Code Here

    this.serviceRegistry = serviceRegistry;
  }

  @Override
  public void configure(Map configValues) {
    final JdbcConnectionAccess jdbcConnectionAccess = buildJdbcConnectionAccess( configValues );
    final DialectFactory dialectFactory = serviceRegistry.getService( DialectFactory.class );

    Dialect dialect = null;
    LobCreatorBuilder lobCreatorBuilder = null;

    boolean metaSupportsScrollable = false;
    boolean metaSupportsGetGeneratedKeys = false;
    boolean metaSupportsBatchUpdates = false;
    boolean metaReportsDDLCausesTxnCommit = false;
    boolean metaReportsDDLInTxnSupported = true;
    String extraKeywordsString = "";
    int sqlStateType = -1;
    boolean lobLocatorUpdateCopy = false;
    String catalogName = null;
    String schemaName = null;
    LinkedHashSet<TypeInfo> typeInfoSet = new LinkedHashSet<TypeInfo>();

    // 'hibernate.temp.use_jdbc_metadata_defaults' is a temporary magic value.
    // The need for it is intended to be alleviated with future development, thus it is
    // not defined as an Environment constant...
    //
    // it is used to control whether we should consult the JDBC metadata to determine
    // certain Settings default values; it is useful to *not* do this when the database
    // may not be available (mainly in tools usage).
    boolean useJdbcMetadata = ConfigurationHelper.getBoolean( "hibernate.temp.use_jdbc_metadata_defaults", configValues, true );
    if ( useJdbcMetadata ) {
      try {
        Connection connection = jdbcConnectionAccess.obtainConnection();
        try {
          DatabaseMetaData meta = connection.getMetaData();
          if(LOG.isDebugEnabled()) {
            LOG.debugf( "Database ->\n" + "       name : %s\n" + "    version : %s\n" + "      major : %s\n" + "      minor : %s",
                  meta.getDatabaseProductName(),
                  meta.getDatabaseProductVersion(),
                  meta.getDatabaseMajorVersion(),
                  meta.getDatabaseMinorVersion()
            );
            LOG.debugf( "Driver ->\n" + "       name : %s\n" + "    version : %s\n" + "      major : %s\n" + "      minor : %s",
                  meta.getDriverName(),
                  meta.getDriverVersion(),
                  meta.getDriverMajorVersion(),
                  meta.getDriverMinorVersion()
            );
            LOG.debugf( "JDBC version : %s.%s", meta.getJDBCMajorVersion(), meta.getJDBCMinorVersion() );
          }

          metaSupportsScrollable = meta.supportsResultSetType( ResultSet.TYPE_SCROLL_INSENSITIVE );
          metaSupportsBatchUpdates = meta.supportsBatchUpdates();
          metaReportsDDLCausesTxnCommit = meta.dataDefinitionCausesTransactionCommit();
          metaReportsDDLInTxnSupported = !meta.dataDefinitionIgnoredInTransactions();
          metaSupportsGetGeneratedKeys = meta.supportsGetGeneratedKeys();
          extraKeywordsString = meta.getSQLKeywords();
          sqlStateType = meta.getSQLStateType();
          lobLocatorUpdateCopy = meta.locatorsUpdateCopy();
          typeInfoSet.addAll( TypeInfoExtracter.extractTypeInfo( meta ) );

          dialect = dialectFactory.buildDialect( configValues, connection );

          catalogName = connection.getCatalog();
          SchemaNameResolver schemaNameResolver = determineExplicitSchemaNameResolver( configValues );
          if ( schemaNameResolver == null ) {
// todo : add dialect method
//            schemaNameResolver = dialect.getSchemaNameResolver();
          }
          if ( schemaNameResolver != null ) {
            schemaName = schemaNameResolver.resolveSchemaName( connection );
          }
          lobCreatorBuilder = new LobCreatorBuilder( configValues, connection );
        }
        catch ( SQLException sqle ) {
          LOG.unableToObtainConnectionMetadata( sqle.getMessage() );
        }
        finally {
          if ( connection != null ) {
            jdbcConnectionAccess.releaseConnection( connection );
          }
        }
      }
      catch ( SQLException sqle ) {
        LOG.unableToObtainConnectionToQueryMetadata( sqle.getMessage() );
View Full Code Here

    this.serviceRegistry = serviceRegistry;
  }

  @Override
  public void configure(Map configValues) {
    final JdbcConnectionAccess jdbcConnectionAccess = buildJdbcConnectionAccess( configValues );
    final DialectFactory dialectFactory = serviceRegistry.getService( DialectFactory.class );

    Dialect dialect = null;
    LobCreatorBuilder lobCreatorBuilder = null;

    boolean metaSupportsScrollable = false;
    boolean metaSupportsGetGeneratedKeys = false;
    boolean metaSupportsBatchUpdates = false;
    boolean metaReportsDDLCausesTxnCommit = false;
    boolean metaReportsDDLInTxnSupported = true;
    String extraKeywordsString = "";
    int sqlStateType = -1;
    boolean lobLocatorUpdateCopy = false;
    String catalogName = null;
    String schemaName = null;
    LinkedHashSet<TypeInfo> typeInfoSet = new LinkedHashSet<TypeInfo>();

    // 'hibernate.temp.use_jdbc_metadata_defaults' is a temporary magic value.
    // The need for it is intended to be alleviated with future development, thus it is
    // not defined as an Environment constant...
    //
    // it is used to control whether we should consult the JDBC metadata to determine
    // certain Settings default values; it is useful to *not* do this when the database
    // may not be available (mainly in tools usage).
    boolean useJdbcMetadata = ConfigurationHelper.getBoolean( "hibernate.temp.use_jdbc_metadata_defaults", configValues, true );
    if ( useJdbcMetadata ) {
      try {
        Connection connection = jdbcConnectionAccess.obtainConnection();
        try {
          DatabaseMetaData meta = connection.getMetaData();
          if(LOG.isDebugEnabled()) {
            LOG.debugf( "Database ->\n" + "       name : %s\n" + "    version : %s\n" + "      major : %s\n" + "      minor : %s",
                  meta.getDatabaseProductName(),
                  meta.getDatabaseProductVersion(),
                  meta.getDatabaseMajorVersion(),
                  meta.getDatabaseMinorVersion()
            );
            LOG.debugf( "Driver ->\n" + "       name : %s\n" + "    version : %s\n" + "      major : %s\n" + "      minor : %s",
                  meta.getDriverName(),
                  meta.getDriverVersion(),
                  meta.getDriverMajorVersion(),
                  meta.getDriverMinorVersion()
            );
            LOG.debugf( "JDBC version : %s.%s", meta.getJDBCMajorVersion(), meta.getJDBCMinorVersion() );
          }

          metaSupportsScrollable = meta.supportsResultSetType( ResultSet.TYPE_SCROLL_INSENSITIVE );
          metaSupportsBatchUpdates = meta.supportsBatchUpdates();
          metaReportsDDLCausesTxnCommit = meta.dataDefinitionCausesTransactionCommit();
          metaReportsDDLInTxnSupported = !meta.dataDefinitionIgnoredInTransactions();
          metaSupportsGetGeneratedKeys = meta.supportsGetGeneratedKeys();
          extraKeywordsString = meta.getSQLKeywords();
          sqlStateType = meta.getSQLStateType();
          lobLocatorUpdateCopy = meta.locatorsUpdateCopy();
          typeInfoSet.addAll( TypeInfoExtracter.extractTypeInfo( meta ) );

          dialect = dialectFactory.buildDialect( configValues, connection );

          catalogName = connection.getCatalog();
          SchemaNameResolver schemaNameResolver = determineExplicitSchemaNameResolver( configValues );
          if ( schemaNameResolver == null ) {
// todo : add dialect method
//            schemaNameResolver = dialect.getSchemaNameResolver();
          }
          if ( schemaNameResolver != null ) {
            schemaName = schemaNameResolver.resolveSchemaName( connection );
          }
          lobCreatorBuilder = new LobCreatorBuilder( configValues, connection );
        }
        catch ( SQLException sqle ) {
          LOG.unableToObtainConnectionMetadata( sqle.getMessage() );
        }
        finally {
          if ( connection != null ) {
            jdbcConnectionAccess.releaseConnection( connection );
          }
        }
      }
      catch ( SQLException sqle ) {
        LOG.unableToObtainConnectionToQueryMetadata( sqle.getMessage() );
View Full Code Here

    this.transactionEnvironment = new TransactionEnvironmentImpl( this );
    this.observer.sessionFactoryCreated( this );
  }

  private JdbcConnectionAccess buildLocalConnectionAccess() {
    return new JdbcConnectionAccess() {
      @Override
      public Connection obtainConnection() throws SQLException {
        return settings.getMultiTenancyStrategy() == MultiTenancyStrategy.NONE
            ? serviceRegistry.getService( ConnectionProvider.class ).getConnection()
            : serviceRegistry.getService( MultiTenantConnectionProvider.class ).getAnyConnection();
View Full Code Here

        AvailableSettings.SCHEMA_GEN_CONNECTION
    );

    if ( providedConnection != null ) {
      return new JdbcConnectionContext(
          new JdbcConnectionAccess() {
            @Override
            public Connection obtainConnection() throws SQLException {
              return providedConnection;
            }

            @Override
            public void releaseConnection(Connection connection) throws SQLException {
              // do nothing
            }

            @Override
            public boolean supportsAggressiveRelease() {
              return false;
            }
          },
          sqlStatementLogger
      );
    }

    final ConnectionProvider connectionProvider = serviceRegistry.getService( ConnectionProvider.class );
    if ( connectionProvider != null ) {
      return new JdbcConnectionContext(
          new JdbcConnectionAccess() {
            @Override
            public Connection obtainConnection() throws SQLException {
              return connectionProvider.getConnection();
            }
View Full Code Here

    this.transactionEnvironment = new TransactionEnvironmentImpl( this );
    this.observer.sessionFactoryCreated( this );
  }

  private JdbcConnectionAccess buildLocalConnectionAccess() {
    return new JdbcConnectionAccess() {
      @Override
      public Connection obtainConnection() throws SQLException {
        return settings.getMultiTenancyStrategy() == MultiTenancyStrategy.NONE
            ? serviceRegistry.getService( ConnectionProvider.class ).getConnection()
            : serviceRegistry.getService( MultiTenantConnectionProvider.class ).getAnyConnection();
View Full Code Here

    this.serviceRegistry = serviceRegistry;
  }

  @Override
  public void configure(Map configValues) {
    final JdbcConnectionAccess jdbcConnectionAccess = buildJdbcConnectionAccess( configValues );
    final DialectFactory dialectFactory = serviceRegistry.getService( DialectFactory.class );

    Dialect dialect = null;
    LobCreatorBuilder lobCreatorBuilder = null;

    boolean metaSupportsScrollable = false;
    boolean metaSupportsGetGeneratedKeys = false;
    boolean metaSupportsBatchUpdates = false;
    boolean metaReportsDDLCausesTxnCommit = false;
    boolean metaReportsDDLInTxnSupported = true;
    String extraKeywordsString = "";
    int sqlStateType = -1;
    boolean lobLocatorUpdateCopy = false;
    String catalogName = null;
    String schemaName = null;
    LinkedHashSet<TypeInfo> typeInfoSet = new LinkedHashSet<TypeInfo>();

    // 'hibernate.temp.use_jdbc_metadata_defaults' is a temporary magic value.
    // The need for it is intended to be alleviated with future development, thus it is
    // not defined as an Environment constant...
    //
    // it is used to control whether we should consult the JDBC metadata to determine
    // certain Settings default values; it is useful to *not* do this when the database
    // may not be available (mainly in tools usage).
    boolean useJdbcMetadata = ConfigurationHelper.getBoolean( "hibernate.temp.use_jdbc_metadata_defaults", configValues, true );
    if ( useJdbcMetadata ) {
      try {
        Connection connection = jdbcConnectionAccess.obtainConnection();
        try {
          DatabaseMetaData meta = connection.getMetaData();
          if(LOG.isDebugEnabled()) {
            LOG.debugf( "Database ->\n" + "       name : %s\n" + "    version : %s\n" + "      major : %s\n" + "      minor : %s",
                  meta.getDatabaseProductName(),
                  meta.getDatabaseProductVersion(),
                  meta.getDatabaseMajorVersion(),
                  meta.getDatabaseMinorVersion()
            );
            LOG.debugf( "Driver ->\n" + "       name : %s\n" + "    version : %s\n" + "      major : %s\n" + "      minor : %s",
                  meta.getDriverName(),
                  meta.getDriverVersion(),
                  meta.getDriverMajorVersion(),
                  meta.getDriverMinorVersion()
            );
            LOG.debugf( "JDBC version : %s.%s", meta.getJDBCMajorVersion(), meta.getJDBCMinorVersion() );
          }

          metaSupportsScrollable = meta.supportsResultSetType( ResultSet.TYPE_SCROLL_INSENSITIVE );
          metaSupportsBatchUpdates = meta.supportsBatchUpdates();
          metaReportsDDLCausesTxnCommit = meta.dataDefinitionCausesTransactionCommit();
          metaReportsDDLInTxnSupported = !meta.dataDefinitionIgnoredInTransactions();
          metaSupportsGetGeneratedKeys = meta.supportsGetGeneratedKeys();
          extraKeywordsString = meta.getSQLKeywords();
          sqlStateType = meta.getSQLStateType();
          lobLocatorUpdateCopy = meta.locatorsUpdateCopy();
          typeInfoSet.addAll( TypeInfoExtracter.extractTypeInfo( meta ) );

          dialect = dialectFactory.buildDialect( configValues, connection );

          catalogName = connection.getCatalog();
          SchemaNameResolver schemaNameResolver = determineExplicitSchemaNameResolver( configValues );
          if ( schemaNameResolver == null ) {
// todo : add dialect method
//            schemaNameResolver = dialect.getSchemaNameResolver();
          }
          if ( schemaNameResolver != null ) {
            schemaName = schemaNameResolver.resolveSchemaName( connection );
          }
          lobCreatorBuilder = new LobCreatorBuilder( configValues, connection );
        }
        catch ( SQLException sqle ) {
          LOG.unableToObtainConnectionMetadata( sqle.getMessage() );
        }
        finally {
          if ( connection != null ) {
            jdbcConnectionAccess.releaseConnection( connection );
          }
        }
      }
      catch ( SQLException sqle ) {
        LOG.unableToObtainConnectionToQueryMetadata( sqle.getMessage() );
View Full Code Here

        AvailableSettings.SCHEMA_GEN_CONNECTION
    );

    if ( providedConnection != null ) {
      return new JdbcConnectionContext(
          new JdbcConnectionAccess() {
            @Override
            public Connection obtainConnection() throws SQLException {
              return providedConnection;
            }

            @Override
            public void releaseConnection(Connection connection) throws SQLException {
              // do nothing
            }

            @Override
            public boolean supportsAggressiveRelease() {
              return false;
            }
          },
          sqlStatementLogger
      );
    }

    final ConnectionProvider connectionProvider = serviceRegistry.getService( ConnectionProvider.class );
    if ( connectionProvider != null ) {
      return new JdbcConnectionContext(
          new JdbcConnectionAccess() {
            @Override
            public Connection obtainConnection() throws SQLException {
              return connectionProvider.getConnection();
            }
View Full Code Here

TOP

Related Classes of org.hibernate.engine.jdbc.spi.JdbcConnectionAccess

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.