org.springframework.orm.hibernate3

## Class LocalDataSourceConnectionProvider

- java.lang.Object
- - org.springframework.orm.hibernate3.LocalDataSourceConnectionProvider

- All Implemented Interfaces:
    org.hibernate.connection.ConnectionProvider
  Direct Known Subclasses:
    LocalJtaDataSourceConnectionProvider, TransactionAwareDataSourceConnectionProvider

      public class LocalDataSourceConnectionProvider
      extends Object
      implements org.hibernate.connection.ConnectionProvider

  Hibernate connection provider for local DataSource instances in an application context. This provider will be used if LocalSessionFactoryBean's "dataSource" property is set without a Hibernate TransactionManagerLookup.
  Since:
    1.2
  Author:
    Juergen Hoeller
  See Also:
    `AbstractSessionFactoryBean.setDataSource(javax.sql.DataSource)`

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `LocalDataSourceConnectionProvider()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `close()` This implementation does nothing: We're dealing with an externally managed DataSource.
    `void` | `closeConnection(Connection con)` This implementation calls `DataSourceUtils.doCloseConnection(java.sql.Connection, javax.sql.DataSource)`, checking against a `SmartDataSource`.
    `void` | `configure(Properties props)`
    `Connection` | `getConnection()` This implementation delegates to the underlying DataSource.
    `DataSource` | `getDataSource()` Return the DataSource that this ConnectionProvider wraps.
    `protected DataSource` | `getDataSourceToUse(DataSource originalDataSource)` Return the DataSource to use for retrieving Connections.
    `boolean` | `supportsAggressiveRelease()` This implementation returns `false`: We cannot guarantee to receive the same Connection within a transaction, not even when dealing with a JNDI DataSource.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### LocalDataSourceConnectionProvider

          public LocalDataSourceConnectionProvider()

  - ### Method Detail

    - #### configure

          public void configure(Properties props)
                         throws HibernateException

      Specified by:
        `configure` in interface `org.hibernate.connection.ConnectionProvider`
      Throws:
        `HibernateException`

    - #### getDataSourceToUse

          protected DataSource getDataSourceToUse(DataSource originalDataSource)

      Return the DataSource to use for retrieving Connections.

      This implementation returns the passed-in DataSource as-is.

      Parameters:
        `originalDataSource` - the DataSource as configured by the user on LocalSessionFactoryBean
      Returns:
        the DataSource to actually retrieve Connections from (potentially wrapped)
      See Also:
        `AbstractSessionFactoryBean.setDataSource(javax.sql.DataSource)`

    - #### getDataSource

          public DataSource getDataSource()

      Return the DataSource that this ConnectionProvider wraps.

    - #### getConnection

          public Connection getConnection()
                                   throws SQLException

      This implementation delegates to the underlying DataSource.
      Specified by:
        `getConnection` in interface `org.hibernate.connection.ConnectionProvider`
      Throws:
        `SQLException`
      See Also:
        `DataSource.getConnection()`

    - #### closeConnection

          public void closeConnection(Connection con)
                               throws SQLException

      This implementation calls `DataSourceUtils.doCloseConnection(java.sql.Connection, javax.sql.DataSource)`, checking against a `SmartDataSource`.
      Specified by:
        `closeConnection` in interface `org.hibernate.connection.ConnectionProvider`
      Throws:
        `SQLException`

    - #### close

          public void close()

      This implementation does nothing: We're dealing with an externally managed DataSource.
      Specified by:
        `close` in interface `org.hibernate.connection.ConnectionProvider`

    - #### supportsAggressiveRelease

          public boolean supportsAggressiveRelease()

      This implementation returns `false`: We cannot guarantee to receive the same Connection within a transaction, not even when dealing with a JNDI DataSource.
      Specified by:
        `supportsAggressiveRelease` in interface `org.hibernate.connection.ConnectionProvider`