SessionFactory.getCurrentSession()
is required for Hibernate access code that needs to support this transaction handling mechanism, with the SessionFactory being configured with {@link SpringSessionContext}. Supports custom isolation levels, and timeouts that get applied as Hibernate transaction timeouts.
This transaction manager is appropriate for applications that use a single Hibernate SessionFactory for transactional data access, but it also supports direct DataSource access within a transaction (i.e. plain JDBC code working with the same DataSource). This allows for mixing services which access Hibernate and services which use plain JDBC (without being aware of Hibernate)! Application code needs to stick to the same simple Connection lookup pattern as with {@link org.springframework.jdbc.datasource.DataSourceTransactionManager}(i.e. {@link org.springframework.jdbc.datasource.DataSourceUtils#getConnection}or going through a {@link org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy}).
Note: To be able to register a DataSource's Connection for plain JDBC code, this instance needs to be aware of the DataSource ( {@link #setDataSource}). The given DataSource should obviously match the one used by the given SessionFactory.
JTA (usually through {@link org.springframework.transaction.jta.JtaTransactionManager}) is necessary for accessing multiple transactional resources within the same transaction. The DataSource that Hibernate uses needs to be JTA-enabled in such a scenario (see container setup).
On JDBC 3.0, this transaction manager supports nested transactions via JDBC 3.0 Savepoints. The {@link #setNestedTransactionAllowed} "nestedTransactionAllowed"}flag defaults to "false", though, as nested transactions will just apply to the JDBC Connection, not to the Hibernate Session and its cached objects. You can manually set the flag to "true" if you want to use nested transactions for JDBC access code which participates in Hibernate transactions (provided that your JDBC driver supports Savepoints). Note that Hibernate itself does not support nested transactions! Hence, do not expect Hibernate access code to semantically participate in a nested transaction. @author Juergen Hoeller @since 3.1 @see #setSessionFactory @see #setDataSource @see org.hibernate.SessionFactory#getCurrentSession() @see org.springframework.jdbc.datasource.DataSourceUtils#getConnection @see org.springframework.jdbc.datasource.DataSourceUtils#releaseConnection @see org.springframework.jdbc.core.JdbcTemplate @see org.springframework.jdbc.datasource.DataSourceTransactionManager @see org.springframework.transaction.jta.JtaTransactionManager
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|