| java.lang.Object org.springframework.orm.hibernate.HibernateAccessor
All known Subclasses: org.springframework.orm.hibernate.HibernateTemplate, org.springframework.orm.hibernate.support.OpenSessionInViewInterceptor, org.springframework.orm.hibernate.HibernateInterceptor,
Field Summary | |
final public static int | FLUSH_AUTO Automatic flushing is the default mode for a Hibernate Session. | final public static int | FLUSH_COMMIT Flushing at commit only is intended for units of work where no
intermediate flushing is desired, not even for find operations
that might involve already modified instances.
In case of an existing Session, FLUSH_COMMIT will turn the flush mode
to COMMIT for the scope of the current operation, resetting the previous
flush mode afterwards. | final public static int | FLUSH_EAGER Eager flushing leads to immediate synchronization with the database,
even if in a transaction. | final public static int | FLUSH_NEVER Never flush is a good strategy for read-only units of work. | final protected Log | logger |
Method Summary | |
public void | afterPropertiesSet() | protected FlushMode | applyFlushMode(Session session, boolean existingTransaction) Apply the flush mode that's been specified for this accessor
to the given Session. | public DataAccessException | convertHibernateAccessException(HibernateException ex) Convert the given HibernateException to an appropriate exception from the
org.springframework.dao hierarchy. | protected DataAccessException | convertJdbcAccessException(JDBCException ex) Convert the given JDBCException to an appropriate exception from the
org.springframework.dao hierarchy. | protected DataAccessException | convertJdbcAccessException(SQLException ex) Convert the given SQLException to an appropriate exception from the
org.springframework.dao hierarchy. | protected void | flushIfNecessary(Session session, boolean existingTransaction) Flush the given Hibernate Session if necessary. | public Interceptor | getEntityInterceptor() Return the current Hibernate entity interceptor, or null if none. | public int | getFlushMode() Return if a flush should be forced after executing the callback code. | public synchronized SQLExceptionTranslator | getJdbcExceptionTranslator() Return the JDBC exception translator for this instance. | public SessionFactory | getSessionFactory() Return the Hibernate SessionFactory that should be used to create
Hibernate Sessions. | public void | setBeanFactory(BeanFactory beanFactory) The bean factory just needs to be known for resolving entity interceptor
bean names. | public void | setEntityInterceptor(Interceptor entityInterceptor) Set a Hibernate entity interceptor that allows to inspect and change
property values before writing to and reading from the database.
Will get applied to any new Session created by this object.
Such an interceptor can either be set at the SessionFactory level,
i.e. | public void | setEntityInterceptorBeanName(String entityInterceptorBeanName) Set the bean name of a Hibernate entity interceptor that allows to inspect
and change property values before writing to and reading from the database.
Will get applied to any new Session created by this transaction manager.
Requires the bean factory to be known, to be able to resolve the bean
name to an interceptor instance on session creation. | public void | setFlushMode(int flushMode) Set the flush behavior to one of the constants in this class. | public void | setFlushModeName(String constantName) Set the flush behavior by the name of the respective constant
in this class, e.g. | public void | setJdbcExceptionTranslator(SQLExceptionTranslator jdbcExceptionTranslator) Set the JDBC exception translator for this instance. | public void | setSessionFactory(SessionFactory sessionFactory) Set the Hibernate SessionFactory that should be used to create
Hibernate Sessions. |
FLUSH_AUTO | final public static int FLUSH_AUTO(Code) | | Automatic flushing is the default mode for a Hibernate Session.
A session will get flushed on transaction commit, and on certain find
operations that might involve already modified instances, but not
after each unit of work like with eager flushing.
In case of an existing Session, FLUSH_AUTO will participate in the
existing flush mode, not modifying it for the current operation.
This in particular means that this setting will not modify an existing
flush mode NEVER, in contrast to FLUSH_EAGER.
See Also: HibernateAccessor.setFlushMode |
FLUSH_COMMIT | final public static int FLUSH_COMMIT(Code) | | Flushing at commit only is intended for units of work where no
intermediate flushing is desired, not even for find operations
that might involve already modified instances.
In case of an existing Session, FLUSH_COMMIT will turn the flush mode
to COMMIT for the scope of the current operation, resetting the previous
flush mode afterwards. The only exception is an existing flush mode
NEVER, which will not be modified through this setting.
See Also: HibernateAccessor.setFlushMode |
FLUSH_EAGER | final public static int FLUSH_EAGER(Code) | | Eager flushing leads to immediate synchronization with the database,
even if in a transaction. This causes inconsistencies to show up and throw
a respective exception immediately, and JDBC access code that participates
in the same transaction will see the changes as the database is already
aware of them then. But the drawbacks are:
- additional communication roundtrips with the database, instead of a
single batch at transaction commit;
- the fact that an actual database rollback is needed if the Hibernate
transaction rolls back (due to already submitted SQL statements).
In case of an existing Session, FLUSH_EAGER will turn the flush mode
to AUTO for the scope of the current operation and issue a flush at the
end, resetting the previous flush mode afterwards.
See Also: HibernateAccessor.setFlushMode |
FLUSH_NEVER | final public static int FLUSH_NEVER(Code) | | Never flush is a good strategy for read-only units of work.
Hibernate will not track and look for changes in this case,
avoiding any overhead of modification detection.
In case of an existing Session, FLUSH_NEVER will turn the flush mode
to NEVER for the scope of the current operation, resetting the previous
flush mode afterwards.
See Also: HibernateAccessor.setFlushMode |
logger | final protected Log logger(Code) | | Logger available to subclasses
|
afterPropertiesSet | public void afterPropertiesSet()(Code) | | |
applyFlushMode | protected FlushMode applyFlushMode(Session session, boolean existingTransaction)(Code) | | Apply the flush mode that's been specified for this accessor
to the given Session.
Parameters: session - the current Hibernate Session Parameters: existingTransaction - if executing within an existing transaction the previous flush mode to restore after the operation,or null if none See Also: HibernateAccessor.setFlushMode See Also: net.sf.hibernate.Session.setFlushMode |
convertJdbcAccessException | protected DataAccessException convertJdbcAccessException(JDBCException ex)(Code) | | Convert the given JDBCException to an appropriate exception from the
org.springframework.dao hierarchy. Can be overridden in subclasses.
Parameters: ex - JDBCException that occured, wrapping a SQLException the corresponding DataAccessException instance See Also: HibernateAccessor.setJdbcExceptionTranslator |
convertJdbcAccessException | protected DataAccessException convertJdbcAccessException(SQLException ex)(Code) | | Convert the given SQLException to an appropriate exception from the
org.springframework.dao hierarchy. Can be overridden in subclasses.
Note that a direct SQLException can just occur when callback code
performs direct JDBC access via Session.connection() .
Parameters: ex - the SQLException the corresponding DataAccessException instance See Also: HibernateAccessor.setJdbcExceptionTranslator See Also: net.sf.hibernate.Session.connection |
flushIfNecessary | protected void flushIfNecessary(Session session, boolean existingTransaction) throws HibernateException(Code) | | Flush the given Hibernate Session if necessary.
Parameters: session - the current Hibernate Session Parameters: existingTransaction - if executing within an existing transaction throws: HibernateException - in case of Hibernate flushing errors |
getFlushMode | public int getFlushMode()(Code) | | Return if a flush should be forced after executing the callback code.
|
getJdbcExceptionTranslator | public synchronized SQLExceptionTranslator getJdbcExceptionTranslator()(Code) | | Return the JDBC exception translator for this instance.
Creates a default SQLErrorCodeSQLExceptionTranslator or SQLStateSQLExceptionTranslator
for the specified SessionFactory, if no exception translator explicitly specified.
|
getSessionFactory | public SessionFactory getSessionFactory()(Code) | | Return the Hibernate SessionFactory that should be used to create
Hibernate Sessions.
|
setEntityInterceptor | public void setEntityInterceptor(Interceptor entityInterceptor)(Code) | | Set a Hibernate entity interceptor that allows to inspect and change
property values before writing to and reading from the database.
Will get applied to any new Session created by this object.
Such an interceptor can either be set at the SessionFactory level,
i.e. on LocalSessionFactoryBean, or at the Session level, i.e. on
HibernateTemplate, HibernateInterceptor, and HibernateTransactionManager.
It's preferable to set it on LocalSessionFactoryBean or HibernateTransactionManager
to avoid repeated configuration and guarantee consistent behavior in transactions.
See Also: HibernateAccessor.setEntityInterceptorBeanName See Also: LocalSessionFactoryBean.setEntityInterceptor See Also: HibernateTransactionManager.setEntityInterceptor |
setEntityInterceptorBeanName | public void setEntityInterceptorBeanName(String entityInterceptorBeanName)(Code) | | Set the bean name of a Hibernate entity interceptor that allows to inspect
and change property values before writing to and reading from the database.
Will get applied to any new Session created by this transaction manager.
Requires the bean factory to be known, to be able to resolve the bean
name to an interceptor instance on session creation. Typically used for
prototype interceptors, i.e. a new interceptor instance per session.
Can also be used for shared interceptor instances, but it is recommended
to set the interceptor reference directly in such a scenario.
Parameters: entityInterceptorBeanName - the name of the entity interceptor inthe bean factory See Also: HibernateAccessor.setBeanFactory See Also: HibernateAccessor.setEntityInterceptor |
setSessionFactory | public void setSessionFactory(SessionFactory sessionFactory)(Code) | | Set the Hibernate SessionFactory that should be used to create
Hibernate Sessions.
|
|
|