Java Doc for HibernateAccessor.java in  » J2EE » spring-framework-2.5 » org » springframework » orm » hibernate3 » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » J2EE » spring framework 2.5 » org.springframework.orm.hibernate3 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.springframework.orm.hibernate3.HibernateAccessor

All known Subclasses:   org.springframework.orm.hibernate3.support.OpenSessionInViewInterceptor,  org.springframework.orm.hibernate3.HibernateTemplate,  org.springframework.orm.hibernate3.HibernateInterceptor,
HibernateAccessor
abstract public class HibernateAccessor implements InitializingBean,BeanFactoryAware(Code)
Base class for HibernateTemplate and HibernateInterceptor , defining common properties such as SessionFactory and flushing behavior.

Not intended to be used directly. See HibernateTemplate and HibernateInterceptor .
author:
   Juergen Hoeller
since:
   1.2
See Also:   HibernateTemplate
See Also:   HibernateInterceptor
See Also:   HibernateAccessor.setFlushMode



Field Summary
final public static  intFLUSH_ALWAYS
     Flushing before every query statement is rarely necessary.
final public static  intFLUSH_AUTO
     Automatic flushing is the default mode for a Hibernate Session.
final public static  intFLUSH_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  intFLUSH_EAGER
     Eager flushing leads to immediate synchronization with the database, even if in a transaction.
final public static  intFLUSH_NEVER
     Never flush is a good strategy for read-only units of work.
final protected  Loglogger
    


Method Summary
public  voidafterPropertiesSet()
    
protected  FlushModeapplyFlushMode(Session session, boolean existingTransaction)
     Apply the flush mode that's been specified for this accessor to the given Session.
public  DataAccessExceptionconvertHibernateAccessException(HibernateException ex)
     Convert the given HibernateException to an appropriate exception from the org.springframework.dao hierarchy.
protected  DataAccessExceptionconvertJdbcAccessException(JDBCException ex, SQLExceptionTranslator translator)
     Convert the given Hibernate JDBCException to an appropriate exception from the org.springframework.dao hierarchy, using the given SQLExceptionTranslator.
protected  DataAccessExceptionconvertJdbcAccessException(SQLException ex)
     Convert the given SQLException to an appropriate exception from the org.springframework.dao hierarchy.
protected  voiddisableFilters(Session session)
     Disable the specified filters on the given Session.
protected  voidenableFilters(Session session)
     Enable the specified filters on the given Session.
protected  voidflushIfNecessary(Session session, boolean existingTransaction)
     Flush the given Hibernate Session if necessary.
protected synchronized  SQLExceptionTranslatorgetDefaultJdbcExceptionTranslator()
     Obtain a default SQLExceptionTranslator, lazily creating it if necessary.
public  InterceptorgetEntityInterceptor()
     Return the current Hibernate entity interceptor, or null if none.
public  String[]getFilterNames()
     Return the names of Hibernate filters to be activated, if any.
public  intgetFlushMode()
     Return if a flush should be forced after executing the callback code.
public  SQLExceptionTranslatorgetJdbcExceptionTranslator()
     Return the JDBC exception translator for this instance, if any.
public  SessionFactorygetSessionFactory()
     Return the Hibernate SessionFactory that should be used to create Hibernate Sessions.
public  voidsetBeanFactory(BeanFactory beanFactory)
     The bean factory just needs to be known for resolving entity interceptor bean names.
public  voidsetEntityInterceptor(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  voidsetEntityInterceptorBeanName(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  voidsetFilterName(String filter)
     Set the name of a Hibernate filter to be activated for all Sessions that this accessor works with.
public  voidsetFilterNames(String[] filterNames)
     Set one or more names of Hibernate filters to be activated for all Sessions that this accessor works with.
public  voidsetFlushMode(int flushMode)
     Set the flush behavior to one of the constants in this class.
public  voidsetFlushModeName(String constantName)
     Set the flush behavior by the name of the respective constant in this class, e.g.
public  voidsetJdbcExceptionTranslator(SQLExceptionTranslator jdbcExceptionTranslator)
     Set the JDBC exception translator for this instance.
public  voidsetSessionFactory(SessionFactory sessionFactory)
     Set the Hibernate SessionFactory that should be used to create Hibernate Sessions.

Field Detail
FLUSH_ALWAYS
final public static int FLUSH_ALWAYS(Code)
Flushing before every query statement is rarely necessary. It is only available for special needs.

In case of an existing Session, FLUSH_ALWAYS will turn the flush mode to ALWAYS for the scope of the current operation, resetting the previous flush mode afterwards.
See Also:   HibernateAccessor.setFlushMode




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





Method Detail
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:   org.hibernate.Session.setFlushMode



convertHibernateAccessException
public DataAccessException convertHibernateAccessException(HibernateException ex)(Code)
Convert the given HibernateException to an appropriate exception from the org.springframework.dao hierarchy.

Will automatically apply a specified SQLExceptionTranslator to a Hibernate JDBCException, else rely on Hibernate's default translation.
Parameters:
  ex - HibernateException that occured a corresponding DataAccessException
See Also:   SessionFactoryUtils.convertHibernateAccessException
See Also:   HibernateAccessor.setJdbcExceptionTranslator




convertJdbcAccessException
protected DataAccessException convertJdbcAccessException(JDBCException ex, SQLExceptionTranslator translator)(Code)
Convert the given Hibernate JDBCException to an appropriate exception from the org.springframework.dao hierarchy, using the given SQLExceptionTranslator.
Parameters:
  ex - Hibernate JDBCException that occured
Parameters:
  translator - the SQLExceptionTranslator to use a corresponding DataAccessException



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:   org.hibernate.Session.connection




disableFilters
protected void disableFilters(Session session)(Code)
Disable the specified filters on the given Session.
Parameters:
  session - the current Hibernate Session
See Also:   HibernateAccessor.setFilterNames
See Also:   org.hibernate.Session.disableFilter(String)



enableFilters
protected void enableFilters(Session session)(Code)
Enable the specified filters on the given Session.
Parameters:
  session - the current Hibernate Session
See Also:   HibernateAccessor.setFilterNames
See Also:   org.hibernate.Session.enableFilter(String)



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



getDefaultJdbcExceptionTranslator
protected synchronized SQLExceptionTranslator getDefaultJdbcExceptionTranslator()(Code)
Obtain a default SQLExceptionTranslator, lazily creating it if necessary.

Creates a default org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator for the SessionFactory's underlying DataSource.




getEntityInterceptor
public Interceptor getEntityInterceptor() throws IllegalStateException, BeansException(Code)
Return the current Hibernate entity interceptor, or null if none. Resolves an entity interceptor bean name via the bean factory, if necessary.
throws:
  IllegalStateException - if bean name specified but no bean factory set
throws:
  org.springframework.beans.BeansException - if bean name resolution via the bean factory failed
See Also:   HibernateAccessor.setEntityInterceptor
See Also:   HibernateAccessor.setEntityInterceptorBeanName
See Also:   HibernateAccessor.setBeanFactory



getFilterNames
public String[] getFilterNames()(Code)
Return the names of Hibernate filters to be activated, if any.



getFlushMode
public int getFlushMode()(Code)
Return if a flush should be forced after executing the callback code.



getJdbcExceptionTranslator
public SQLExceptionTranslator getJdbcExceptionTranslator()(Code)
Return the JDBC exception translator for this instance, if any.



getSessionFactory
public SessionFactory getSessionFactory()(Code)
Return the Hibernate SessionFactory that should be used to create Hibernate Sessions.



setBeanFactory
public void setBeanFactory(BeanFactory beanFactory)(Code)
The bean factory just needs to be known for resolving entity interceptor bean names. It does not need to be set for any other mode of operation.
See Also:   HibernateAccessor.setEntityInterceptorBeanName



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




setFilterName
public void setFilterName(String filter)(Code)
Set the name of a Hibernate filter to be activated for all Sessions that this accessor works with.

This filter will be enabled at the beginning of each operation and correspondingly disabled at the end of the operation. This will work for newly opened Sessions as well as for existing Sessions (for example, within a transaction).
See Also:   HibernateAccessor.enableFilters(org.hibernate.Session)
See Also:   org.hibernate.Session.enableFilter(String)
See Also:   LocalSessionFactoryBean.setFilterDefinitions




setFilterNames
public void setFilterNames(String[] filterNames)(Code)
Set one or more names of Hibernate filters to be activated for all Sessions that this accessor works with.

Each of those filters will be enabled at the beginning of each operation and correspondingly disabled at the end of the operation. This will work for newly opened Sessions as well as for existing Sessions (for example, within a transaction).
See Also:   HibernateAccessor.enableFilters(org.hibernate.Session)
See Also:   org.hibernate.Session.enableFilter(String)
See Also:   LocalSessionFactoryBean.setFilterDefinitions




setFlushMode
public void setFlushMode(int flushMode)(Code)
Set the flush behavior to one of the constants in this class. Default is FLUSH_AUTO.
See Also:   HibernateAccessor.setFlushModeName
See Also:   HibernateAccessor.FLUSH_AUTO



setFlushModeName
public void setFlushModeName(String constantName)(Code)
Set the flush behavior by the name of the respective constant in this class, e.g. "FLUSH_AUTO". Default is "FLUSH_AUTO".
Parameters:
  constantName - name of the constant
See Also:   HibernateAccessor.setFlushMode
See Also:   HibernateAccessor.FLUSH_AUTO



setJdbcExceptionTranslator
public void setJdbcExceptionTranslator(SQLExceptionTranslator jdbcExceptionTranslator)(Code)
Set the JDBC exception translator for this instance.

Applied to any SQLException root cause of a Hibernate JDBCException, overriding Hibernate's default SQLException translation (which is based on Hibernate's Dialect for a specific target database).
Parameters:
  jdbcExceptionTranslator - the exception translator
See Also:   java.sql.SQLException
See Also:   org.hibernate.JDBCException
See Also:   org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator
See Also:   org.springframework.jdbc.support.SQLStateSQLExceptionTranslator




setSessionFactory
public void setSessionFactory(SessionFactory sessionFactory)(Code)
Set the Hibernate SessionFactory that should be used to create Hibernate Sessions.



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.