Java Doc for HibernateTemplate.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
      org.springframework.orm.hibernate3.HibernateTemplate

HibernateTemplate
public class HibernateTemplate extends HibernateAccessor implements HibernateOperations(Code)
Helper class that simplifies Hibernate data access code. Automatically converts HibernateExceptions into DataAccessExceptions, following the org.springframework.dao exception hierarchy.

The central method is execute, supporting Hibernate access code implementing the HibernateCallback interface. It provides Hibernate Session handling such that neither the HibernateCallback implementation nor the calling code needs to explicitly care about retrieving/closing Hibernate Sessions, or handling Session lifecycle exceptions. For typical single step actions, there are various convenience methods (find, load, saveOrUpdate, delete).

Can be used within a service implementation via direct instantiation with a SessionFactory reference, or get prepared in an application context and given to services as bean reference. Note: The SessionFactory should always be configured as bean in the application context, in the first case given to the service directly, in the second case to the prepared template.

NOTE: As of Hibernate 3.0.1, transactional Hibernate access code can also be coded in plain Hibernate style. Hence, for newly started projects, consider adopting the standard Hibernate3 style of coding data access objects instead, based on org.hibernate.SessionFactory.getCurrentSession .

This class can be considered as direct alternative to working with the raw Hibernate3 Session API (through SessionFactory.getCurrentSession()). The major advantage is its automatic conversion to DataAccessExceptions as well as its capability to fall back to 'auto-commit' style behavior when used outside of transactions. Note that HibernateTemplate will perform its own Session management, not participating in a custom Hibernate CurrentSessionContext unless you explicitly switch HibernateTemplate.setAllowCreate "allowCreate" to "false".

LocalSessionFactoryBean is the preferred way of obtaining a reference to a specific Hibernate SessionFactory, at least in a non-EJB environment. The Spring application context will manage its lifecycle, initializing and shutting down the factory as part of the application.

Note that operations that return an Iterator (i.e. iterate) are supposed to be used within Spring-driven or JTA-driven transactions (with HibernateTransactionManager, JtaTransactionManager, or EJB CMT). Else, the Iterator won't be able to read results from its ResultSet anymore, as the underlying Hibernate Session will already have been closed.

Lazy loading will also just work with an open Hibernate Session, either within a transaction or within OpenSessionInViewFilter/Interceptor. Furthermore, some operations just make sense within transactions, for example: contains, evict, lock, flush, clear.
author:
   Juergen Hoeller
since:
   1.2
See Also:   HibernateTemplate.setSessionFactory
See Also:   HibernateCallback
See Also:   org.hibernate.Session
See Also:   LocalSessionFactoryBean
See Also:   HibernateTransactionManager
See Also:   org.springframework.transaction.jta.JtaTransactionManager
See Also:   org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
See Also:   org.springframework.orm.hibernate3.support.OpenSessionInViewInterceptor




Constructor Summary
public  HibernateTemplate()
     Create a new HibernateTemplate instance.
public  HibernateTemplate(SessionFactory sessionFactory)
     Create a new HibernateTemplate instance.
public  HibernateTemplate(SessionFactory sessionFactory, boolean allowCreate)
     Create a new HibernateTemplate instance.

Method Summary
protected  voidapplyNamedParameterToQuery(Query queryObject, String paramName, Object value)
     Apply the given name parameter to the given Query object.
public  intbulkUpdate(String queryString)
    
public  intbulkUpdate(String queryString, Object value)
    
public  intbulkUpdate(String queryString, Object[] values)
    
protected  voidcheckWriteOperationAllowed(Session session)
     Check whether write operations are allowed on the given Session.

Default implementation throws an InvalidDataAccessApiUsageException in case of FlushMode.NEVER/MANUAL.

public  voidclear()
    
public  voidcloseIterator(Iterator it)
    
public  booleancontains(Object entity)
    
protected  SessioncreateSessionProxy(Session session)
     Create a close-suppressing proxy for the given Hibernate Session.
public  voiddelete(Object entity)
    
public  voiddelete(Object entity, LockMode lockMode)
    
public  voiddeleteAll(Collection entities)
    
public  FilterenableFilter(String filterName)
    
public  voidevict(Object entity)
    
public  Objectexecute(HibernateCallback action)
    
public  Objectexecute(HibernateCallback action, boolean exposeNativeSession)
     Execute the action specified by the given action object within a Session.
public  ListexecuteFind(HibernateCallback action)
    
public  Listfind(String queryString)
    
public  Listfind(String queryString, Object value)
    
public  Listfind(String queryString, Object[] values)
    
public  ListfindByCriteria(DetachedCriteria criteria)
    
public  ListfindByCriteria(DetachedCriteria criteria, int firstResult, int maxResults)
    
public  ListfindByExample(Object exampleEntity)
    
public  ListfindByExample(String entityName, Object exampleEntity)
    
public  ListfindByExample(Object exampleEntity, int firstResult, int maxResults)
    
public  ListfindByExample(String entityName, Object exampleEntity, int firstResult, int maxResults)
    
public  ListfindByNamedParam(String queryString, String paramName, Object value)
    
public  ListfindByNamedParam(String queryString, String[] paramNames, Object[] values)
    
public  ListfindByNamedQuery(String queryName)
    
public  ListfindByNamedQuery(String queryName, Object value)
    
public  ListfindByNamedQuery(String queryName, Object[] values)
    
public  ListfindByNamedQueryAndNamedParam(String queryName, String paramName, Object value)
    
public  ListfindByNamedQueryAndNamedParam(String queryName, String[] paramNames, Object[] values)
    
public  ListfindByNamedQueryAndValueBean(String queryName, Object valueBean)
    
public  ListfindByValueBean(String queryString, Object valueBean)
    
public  voidflush()
    
public  Objectget(Class entityClass, Serializable id)
    
public  Objectget(Class entityClass, Serializable id, LockMode lockMode)
    
public  Objectget(String entityName, Serializable id)
    
public  Objectget(String entityName, Serializable id, LockMode lockMode)
    
public  intgetFetchSize()
     Return the fetch size specified for this HibernateTemplate.
public  intgetMaxResults()
     Return the maximum number of rows specified for this HibernateTemplate.
public  StringgetQueryCacheRegion()
     Return the name of the cache region for queries executed by this template.
protected  SessiongetSession()
     Return a Session for use by this template.
public  voidinitialize(Object proxy)
    
public  booleanisAllowCreate()
     Return if a new Session should be created if no thread-bound found.
public  booleanisAlwaysUseNewSession()
     Return whether to always use a new Hibernate Session for this template.
public  booleanisCacheQueries()
     Return whether to cache all queries executed by this template.
public  booleanisCheckWriteOperations()
     Return whether to check that the Hibernate Session is not in read-only mode in case of write operations (save/update/delete).
public  booleanisExposeNativeSession()
     Return whether to expose the native Hibernate Session to HibernateCallback code, or rather a Session proxy.
public  Iteratoriterate(String queryString)
    
public  Iteratoriterate(String queryString, Object value)
    
public  Iteratoriterate(String queryString, Object[] values)
    
public  Objectload(Class entityClass, Serializable id)
    
public  Objectload(Class entityClass, Serializable id, LockMode lockMode)
    
public  Objectload(String entityName, Serializable id)
    
public  Objectload(String entityName, Serializable id, LockMode lockMode)
    
public  voidload(Object entity, Serializable id)
    
public  ListloadAll(Class entityClass)
    
public  voidlock(Object entity, LockMode lockMode)
    
public  voidlock(String entityName, Object entity, LockMode lockMode)
    
public  Objectmerge(Object entity)
    
public  Objectmerge(String entityName, Object entity)
    
public  voidpersist(Object entity)
    
public  voidpersist(String entityName, Object entity)
    
protected  voidprepareCriteria(Criteria criteria)
     Prepare the given Criteria object, applying cache settings and/or a transaction timeout.
protected  voidprepareQuery(Query queryObject)
     Prepare the given Query object, applying cache settings and/or a transaction timeout.
public  voidrefresh(Object entity)
    
public  voidrefresh(Object entity, LockMode lockMode)
    
public  voidreplicate(Object entity, ReplicationMode replicationMode)
    
public  voidreplicate(String entityName, Object entity, ReplicationMode replicationMode)
    
public  Serializablesave(Object entity)
    
public  Serializablesave(String entityName, Object entity)
    
public  voidsaveOrUpdate(Object entity)
    
public  voidsaveOrUpdate(String entityName, Object entity)
    
public  voidsaveOrUpdateAll(Collection entities)
    
public  voidsetAllowCreate(boolean allowCreate)
     Set if a new Session should be created when no transactional Session can be found for the current thread. The default value is true.

HibernateTemplate is aware of a corresponding Session bound to the current thread, for example when using HibernateTransactionManager .

public  voidsetAlwaysUseNewSession(boolean alwaysUseNewSession)
     Set whether to always use a new Hibernate Session for this template. Default is "false"; if activated, all operations on this template will work on a new Hibernate Session even in case of a pre-bound Session (for example, within a transaction or OpenSessionInViewFilter).

Within a transaction, a new Hibernate Session used by this template will participate in the transaction through using the same JDBC Connection.

public  voidsetCacheQueries(boolean cacheQueries)
     Set whether to cache all queries executed by this template.
public  voidsetCheckWriteOperations(boolean checkWriteOperations)
     Set whether to check that the Hibernate Session is not in read-only mode in case of write operations (save/update/delete).

Default is "true", for fail-fast behavior when attempting write operations within a read-only transaction.

public  voidsetExposeNativeSession(boolean exposeNativeSession)
     Set whether to expose the native Hibernate Session to HibernateCallback code.
public  voidsetFetchSize(int fetchSize)
     Set the fetch size for this HibernateTemplate.
public  voidsetMaxResults(int maxResults)
     Set the maximum number of rows for this HibernateTemplate.
public  voidsetQueryCacheRegion(String queryCacheRegion)
     Set the name of the cache region for queries executed by this template.
public  voidupdate(Object entity)
    
public  voidupdate(Object entity, LockMode lockMode)
    
public  voidupdate(String entityName, Object entity)
    
public  voidupdate(String entityName, Object entity, LockMode lockMode)
    


Constructor Detail
HibernateTemplate
public HibernateTemplate()(Code)
Create a new HibernateTemplate instance.



HibernateTemplate
public HibernateTemplate(SessionFactory sessionFactory)(Code)
Create a new HibernateTemplate instance.
Parameters:
  sessionFactory - SessionFactory to create Sessions



HibernateTemplate
public HibernateTemplate(SessionFactory sessionFactory, boolean allowCreate)(Code)
Create a new HibernateTemplate instance.
Parameters:
  sessionFactory - SessionFactory to create Sessions
Parameters:
  allowCreate - if a non-transactional Session should be created when notransactional Session can be found for the current thread




Method Detail
applyNamedParameterToQuery
protected void applyNamedParameterToQuery(Query queryObject, String paramName, Object value) throws HibernateException(Code)
Apply the given name parameter to the given Query object.
Parameters:
  queryObject - the Query object
Parameters:
  paramName - the name of the parameter
Parameters:
  value - the value of the parameter
throws:
  HibernateException - if thrown by the Query object



bulkUpdate
public int bulkUpdate(String queryString) throws DataAccessException(Code)



bulkUpdate
public int bulkUpdate(String queryString, Object value) throws DataAccessException(Code)



bulkUpdate
public int bulkUpdate(String queryString, Object[] values) throws DataAccessException(Code)



checkWriteOperationAllowed
protected void checkWriteOperationAllowed(Session session) throws InvalidDataAccessApiUsageException(Code)
Check whether write operations are allowed on the given Session.

Default implementation throws an InvalidDataAccessApiUsageException in case of FlushMode.NEVER/MANUAL. Can be overridden in subclasses.
Parameters:
  session - current Hibernate Session
throws:
  InvalidDataAccessApiUsageException - if write operations are not allowed
See Also:   HibernateTemplate.setCheckWriteOperations
See Also:   HibernateTemplate.getFlushMode()
See Also:   HibernateTemplate.FLUSH_EAGER
See Also:   org.hibernate.Session.getFlushMode
See Also:   org.hibernate.FlushMode.NEVER
See Also:   org.hibernate.FlushMode.MANUAL




clear
public void clear() throws DataAccessException(Code)



closeIterator
public void closeIterator(Iterator it) throws DataAccessException(Code)



contains
public boolean contains(Object entity) throws DataAccessException(Code)



createSessionProxy
protected Session createSessionProxy(Session session)(Code)
Create a close-suppressing proxy for the given Hibernate Session. The proxy also prepares returned Query and Criteria objects.
Parameters:
  session - the Hibernate Session to create a proxy for the Session proxy
See Also:   org.hibernate.Session.close
See Also:   HibernateTemplate.prepareQuery
See Also:   HibernateTemplate.prepareCriteria



delete
public void delete(Object entity) throws DataAccessException(Code)



delete
public void delete(Object entity, LockMode lockMode) throws DataAccessException(Code)



deleteAll
public void deleteAll(Collection entities) throws DataAccessException(Code)



enableFilter
public Filter enableFilter(String filterName) throws IllegalStateException(Code)



evict
public void evict(Object entity) throws DataAccessException(Code)



execute
public Object execute(HibernateCallback action) throws DataAccessException(Code)



execute
public Object execute(HibernateCallback action, boolean exposeNativeSession) throws DataAccessException(Code)
Execute the action specified by the given action object within a Session.
Parameters:
  action - callback object that specifies the Hibernate action
Parameters:
  exposeNativeSession - whether to expose the native Hibernate Sessionto callback code a result object returned by the action, or null
throws:
  org.springframework.dao.DataAccessException - in case of Hibernate errors



executeFind
public List executeFind(HibernateCallback action) throws DataAccessException(Code)



find
public List find(String queryString) throws DataAccessException(Code)



find
public List find(String queryString, Object value) throws DataAccessException(Code)



find
public List find(String queryString, Object[] values) throws DataAccessException(Code)



findByCriteria
public List findByCriteria(DetachedCriteria criteria) throws DataAccessException(Code)



findByCriteria
public List findByCriteria(DetachedCriteria criteria, int firstResult, int maxResults) throws DataAccessException(Code)



findByExample
public List findByExample(Object exampleEntity) throws DataAccessException(Code)



findByExample
public List findByExample(String entityName, Object exampleEntity) throws DataAccessException(Code)



findByExample
public List findByExample(Object exampleEntity, int firstResult, int maxResults) throws DataAccessException(Code)



findByExample
public List findByExample(String entityName, Object exampleEntity, int firstResult, int maxResults) throws DataAccessException(Code)



findByNamedParam
public List findByNamedParam(String queryString, String paramName, Object value) throws DataAccessException(Code)



findByNamedParam
public List findByNamedParam(String queryString, String[] paramNames, Object[] values) throws DataAccessException(Code)



findByNamedQuery
public List findByNamedQuery(String queryName) throws DataAccessException(Code)



findByNamedQuery
public List findByNamedQuery(String queryName, Object value) throws DataAccessException(Code)



findByNamedQuery
public List findByNamedQuery(String queryName, Object[] values) throws DataAccessException(Code)



findByNamedQueryAndNamedParam
public List findByNamedQueryAndNamedParam(String queryName, String paramName, Object value) throws DataAccessException(Code)



findByNamedQueryAndNamedParam
public List findByNamedQueryAndNamedParam(String queryName, String[] paramNames, Object[] values) throws DataAccessException(Code)



findByNamedQueryAndValueBean
public List findByNamedQueryAndValueBean(String queryName, Object valueBean) throws DataAccessException(Code)



findByValueBean
public List findByValueBean(String queryString, Object valueBean) throws DataAccessException(Code)



flush
public void flush() throws DataAccessException(Code)



get
public Object get(Class entityClass, Serializable id) throws DataAccessException(Code)



get
public Object get(Class entityClass, Serializable id, LockMode lockMode) throws DataAccessException(Code)



get
public Object get(String entityName, Serializable id) throws DataAccessException(Code)



get
public Object get(String entityName, Serializable id, LockMode lockMode) throws DataAccessException(Code)



getFetchSize
public int getFetchSize()(Code)
Return the fetch size specified for this HibernateTemplate.



getMaxResults
public int getMaxResults()(Code)
Return the maximum number of rows specified for this HibernateTemplate.



getQueryCacheRegion
public String getQueryCacheRegion()(Code)
Return the name of the cache region for queries executed by this template.



getSession
protected Session getSession()(Code)
Return a Session for use by this template.

Returns a new Session in case of "alwaysUseNewSession" (using the same JDBC Connection as a transactional Session, if applicable), a pre-bound Session in case of "allowCreate" turned off, and a pre-bound or new Session else (new only if no transactional or otherwise pre-bound Session exists). the Session to use (never null)
See Also:   SessionFactoryUtils.getSession
See Also:   SessionFactoryUtils.getNewSession
See Also:   HibernateTemplate.setAlwaysUseNewSession
See Also:   HibernateTemplate.setAllowCreate




initialize
public void initialize(Object proxy) throws DataAccessException(Code)



isAllowCreate
public boolean isAllowCreate()(Code)
Return if a new Session should be created if no thread-bound found.



isAlwaysUseNewSession
public boolean isAlwaysUseNewSession()(Code)
Return whether to always use a new Hibernate Session for this template.



isCacheQueries
public boolean isCacheQueries()(Code)
Return whether to cache all queries executed by this template.



isCheckWriteOperations
public boolean isCheckWriteOperations()(Code)
Return whether to check that the Hibernate Session is not in read-only mode in case of write operations (save/update/delete).



isExposeNativeSession
public boolean isExposeNativeSession()(Code)
Return whether to expose the native Hibernate Session to HibernateCallback code, or rather a Session proxy.



iterate
public Iterator iterate(String queryString) throws DataAccessException(Code)



iterate
public Iterator iterate(String queryString, Object value) throws DataAccessException(Code)



iterate
public Iterator iterate(String queryString, Object[] values) throws DataAccessException(Code)



load
public Object load(Class entityClass, Serializable id) throws DataAccessException(Code)



load
public Object load(Class entityClass, Serializable id, LockMode lockMode) throws DataAccessException(Code)



load
public Object load(String entityName, Serializable id) throws DataAccessException(Code)



load
public Object load(String entityName, Serializable id, LockMode lockMode) throws DataAccessException(Code)



load
public void load(Object entity, Serializable id) throws DataAccessException(Code)



loadAll
public List loadAll(Class entityClass) throws DataAccessException(Code)



lock
public void lock(Object entity, LockMode lockMode) throws DataAccessException(Code)



lock
public void lock(String entityName, Object entity, LockMode lockMode) throws DataAccessException(Code)



merge
public Object merge(Object entity) throws DataAccessException(Code)



merge
public Object merge(String entityName, Object entity) throws DataAccessException(Code)



persist
public void persist(Object entity) throws DataAccessException(Code)



persist
public void persist(String entityName, Object entity) throws DataAccessException(Code)



prepareCriteria
protected void prepareCriteria(Criteria criteria)(Code)
Prepare the given Criteria object, applying cache settings and/or a transaction timeout.
Parameters:
  criteria - the Criteria object to prepare
See Also:   HibernateTemplate.setCacheQueries
See Also:   HibernateTemplate.setQueryCacheRegion
See Also:   SessionFactoryUtils.applyTransactionTimeout



prepareQuery
protected void prepareQuery(Query queryObject)(Code)
Prepare the given Query object, applying cache settings and/or a transaction timeout.
Parameters:
  queryObject - the Query object to prepare
See Also:   HibernateTemplate.setCacheQueries
See Also:   HibernateTemplate.setQueryCacheRegion
See Also:   SessionFactoryUtils.applyTransactionTimeout



refresh
public void refresh(Object entity) throws DataAccessException(Code)



refresh
public void refresh(Object entity, LockMode lockMode) throws DataAccessException(Code)



replicate
public void replicate(Object entity, ReplicationMode replicationMode) throws DataAccessException(Code)



replicate
public void replicate(String entityName, Object entity, ReplicationMode replicationMode) throws DataAccessException(Code)



save
public Serializable save(Object entity) throws DataAccessException(Code)



save
public Serializable save(String entityName, Object entity) throws DataAccessException(Code)



saveOrUpdate
public void saveOrUpdate(Object entity) throws DataAccessException(Code)



saveOrUpdate
public void saveOrUpdate(String entityName, Object entity) throws DataAccessException(Code)



saveOrUpdateAll
public void saveOrUpdateAll(Collection entities) throws DataAccessException(Code)



setAllowCreate
public void setAllowCreate(boolean allowCreate)(Code)
Set if a new Session should be created when no transactional Session can be found for the current thread. The default value is true.

HibernateTemplate is aware of a corresponding Session bound to the current thread, for example when using HibernateTransactionManager . If allowCreate is true, a new non-transactional Session will be created if none is found, which needs to be closed at the end of the operation. If false, an IllegalStateException will get thrown in this case.

NOTE: As of Spring 2.5, switching allowCreate to false will delegate to Hibernate's org.hibernate.SessionFactory.getCurrentSession method, which - with Spring-based setup - will by default delegate to Spring's SessionFactoryUtils.getSession(sessionFactory, false). This mode also allows for custom Hibernate CurrentSessionContext strategies to be plugged in, whereas allowCreate set to true will always use a Spring-managed Hibernate Session.
See Also:   SessionFactoryUtils.getSession(SessionFactoryboolean)




setAlwaysUseNewSession
public void setAlwaysUseNewSession(boolean alwaysUseNewSession)(Code)
Set whether to always use a new Hibernate Session for this template. Default is "false"; if activated, all operations on this template will work on a new Hibernate Session even in case of a pre-bound Session (for example, within a transaction or OpenSessionInViewFilter).

Within a transaction, a new Hibernate Session used by this template will participate in the transaction through using the same JDBC Connection. In such a scenario, multiple Sessions will participate in the same database transaction.

Turn this on for operations that are supposed to always execute independently, without side effects caused by a shared Hibernate Session.




setCacheQueries
public void setCacheQueries(boolean cacheQueries)(Code)
Set whether to cache all queries executed by this template.

If this is "true", all Query and Criteria objects created by this template will be marked as cacheable (including all queries through find methods).

To specify the query region to be used for queries cached by this template, set the "queryCacheRegion" property.
See Also:   HibernateTemplate.setQueryCacheRegion
See Also:   org.hibernate.Query.setCacheable
See Also:   org.hibernate.Criteria.setCacheable




setCheckWriteOperations
public void setCheckWriteOperations(boolean checkWriteOperations)(Code)
Set whether to check that the Hibernate Session is not in read-only mode in case of write operations (save/update/delete).

Default is "true", for fail-fast behavior when attempting write operations within a read-only transaction. Turn this off to allow save/update/delete on a Session with flush mode NEVER.
See Also:   HibernateTemplate.setFlushMode
See Also:   HibernateTemplate.checkWriteOperationAllowed
See Also:   org.springframework.transaction.TransactionDefinition.isReadOnly




setExposeNativeSession
public void setExposeNativeSession(boolean exposeNativeSession)(Code)
Set whether to expose the native Hibernate Session to HibernateCallback code.

Default is "false": a Session proxy will be returned, suppressing close calls and automatically applying query cache settings and transaction timeouts.
See Also:   HibernateCallback
See Also:   org.hibernate.Session
See Also:   HibernateTemplate.setCacheQueries
See Also:   HibernateTemplate.setQueryCacheRegion
See Also:   HibernateTemplate.prepareQuery
See Also:   HibernateTemplate.prepareCriteria




setFetchSize
public void setFetchSize(int fetchSize)(Code)
Set the fetch size for this HibernateTemplate. This is important for processing large result sets: Setting this higher than the default value will increase processing speed at the cost of memory consumption; setting this lower can avoid transferring row data that will never be read by the application.

Default is 0, indicating to use the JDBC driver's default.




setMaxResults
public void setMaxResults(int maxResults)(Code)
Set the maximum number of rows for this HibernateTemplate. This is important for processing subsets of large result sets, avoiding to read and hold the entire result set in the database or in the JDBC driver if we're never interested in the entire result in the first place (for example, when performing searches that might return a large number of matches).

Default is 0, indicating to use the JDBC driver's default.




setQueryCacheRegion
public void setQueryCacheRegion(String queryCacheRegion)(Code)
Set the name of the cache region for queries executed by this template.

If this is specified, it will be applied to all Query and Criteria objects created by this template (including all queries through find methods).

The cache region will not take effect unless queries created by this template are configured to be cached via the "cacheQueries" property.
See Also:   HibernateTemplate.setCacheQueries
See Also:   org.hibernate.Query.setCacheRegion
See Also:   org.hibernate.Criteria.setCacheRegion




update
public void update(Object entity) throws DataAccessException(Code)



update
public void update(Object entity, LockMode lockMode) throws DataAccessException(Code)



update
public void update(String entityName, Object entity) throws DataAccessException(Code)



update
public void update(String entityName, Object entity, LockMode lockMode) throws DataAccessException(Code)



Fields inherited from org.springframework.orm.hibernate3.HibernateAccessor
final public static int FLUSH_ALWAYS(Code)(Java Doc)
final public static int FLUSH_AUTO(Code)(Java Doc)
final public static int FLUSH_COMMIT(Code)(Java Doc)
final public static int FLUSH_EAGER(Code)(Java Doc)
final public static int FLUSH_NEVER(Code)(Java Doc)
final protected Log logger(Code)(Java Doc)

Methods inherited from org.springframework.orm.hibernate3.HibernateAccessor
public void afterPropertiesSet()(Code)(Java Doc)
protected FlushMode applyFlushMode(Session session, boolean existingTransaction)(Code)(Java Doc)
public DataAccessException convertHibernateAccessException(HibernateException ex)(Code)(Java Doc)
protected DataAccessException convertJdbcAccessException(JDBCException ex, SQLExceptionTranslator translator)(Code)(Java Doc)
protected DataAccessException convertJdbcAccessException(SQLException ex)(Code)(Java Doc)
protected void disableFilters(Session session)(Code)(Java Doc)
protected void enableFilters(Session session)(Code)(Java Doc)
protected void flushIfNecessary(Session session, boolean existingTransaction) throws HibernateException(Code)(Java Doc)
protected synchronized SQLExceptionTranslator getDefaultJdbcExceptionTranslator()(Code)(Java Doc)
public Interceptor getEntityInterceptor() throws IllegalStateException, BeansException(Code)(Java Doc)
public String[] getFilterNames()(Code)(Java Doc)
public int getFlushMode()(Code)(Java Doc)
public SQLExceptionTranslator getJdbcExceptionTranslator()(Code)(Java Doc)
public SessionFactory getSessionFactory()(Code)(Java Doc)
public void setBeanFactory(BeanFactory beanFactory)(Code)(Java Doc)
public void setEntityInterceptor(Interceptor entityInterceptor)(Code)(Java Doc)
public void setEntityInterceptorBeanName(String entityInterceptorBeanName)(Code)(Java Doc)
public void setFilterName(String filter)(Code)(Java Doc)
public void setFilterNames(String[] filterNames)(Code)(Java Doc)
public void setFlushMode(int flushMode)(Code)(Java Doc)
public void setFlushModeName(String constantName)(Code)(Java Doc)
public void setJdbcExceptionTranslator(SQLExceptionTranslator jdbcExceptionTranslator)(Code)(Java Doc)
public void setSessionFactory(SessionFactory sessionFactory)(Code)(Java Doc)

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.