Java Doc for HibernateTemplate.java in  » J2EE » spring-framework-2.0.6 » org » springframework » orm » hibernate » 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.0.6 » org.springframework.orm.hibernate 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.springframework.orm.hibernate.HibernateAccessor
      org.springframework.orm.hibernate.HibernateTemplate

HibernateTemplate
public class HibernateTemplate extends HibernateAccessor implements HibernateOperations(Code)
Helper class that simplifies Hibernate data access code, and converts checked HibernateExceptions into unchecked DataAccessExceptions, following the org.springframework.dao exception hierarchy. Uses the same SQLExceptionTranslator mechanism as JdbcTemplate.

Typically used to implement data access or business logic services that use Hibernate within their implementation but are Hibernate-agnostic in their interface. The latter or code calling the latter only have to deal with domain objects, query objects, and org.springframework.dao exceptions.

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.

This class can be considered as direct alternative to working with the raw Hibernate Session API (through SessionFactoryUtils.getSession()). The major advantage is its automatic conversion to DataAccessExceptions, the major disadvantage that no checked application exceptions can get thrown from within data access code. Corresponding checks and the actual throwing of such exceptions can often be deferred to after callback execution, though.

Note that even if HibernateTransactionManager is used for transaction demarcation in higher-level services, all those services above the data access layer don't need to be Hibernate-aware. Setting such a special PlatformTransactionManager is a configuration issue: For example, switching to JTA is just a matter of Spring configuration (use JtaTransactionManager instead) that does not affect application code.

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.

Note: Spring's Hibernate support in this package requires Hibernate 2.1. Dedicated Hibernate3 support can be found in a separate package: org.springframework.orm.hibernate3.
author:
   Juergen Hoeller
since:
   02.05.2003
See Also:   HibernateTemplate.setSessionFactory
See Also:   HibernateTemplate.setJdbcExceptionTranslator
See Also:   HibernateCallback
See Also:   net.sf.hibernate.Session
See Also:   HibernateInterceptor
See Also:   LocalSessionFactoryBean
See Also:   org.springframework.jndi.JndiObjectFactoryBean
See Also:   org.springframework.jdbc.support.SQLExceptionTranslator
See Also:   HibernateTransactionManager
See Also:   org.springframework.transaction.jta.JtaTransactionManager
See Also:   org.springframework.orm.hibernate.support.OpenSessionInViewFilter
See Also:   org.springframework.orm.hibernate.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, Type type)
     Apply the given name parameter to the given Query object.
protected  voidcheckWriteOperationAllowed(Session session)
     Check whether write operations are allowed on the given Session.

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

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  intdelete(String queryString)
    
public  intdelete(String queryString, Object value, Type type)
    
public  intdelete(String queryString, Object[] values, Type[] types)
    
public  voiddeleteAll(Collection entities)
    
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 value, Type type)
    
public  Listfind(String queryString, Object[] values)
    
public  Listfind(String queryString, Object[] values, Type[] types)
    
public  ListfindByNamedParam(String queryString, String paramName, Object value)
    
public  ListfindByNamedParam(String queryString, String paramName, Object value, Type type)
    
public  ListfindByNamedParam(String queryString, String[] paramNames, Object[] values)
    
public  ListfindByNamedParam(String queryString, String[] paramNames, Object[] values, Type[] types)
    
public  ListfindByNamedQuery(String queryName)
    
public  ListfindByNamedQuery(String queryName, Object value)
    
public  ListfindByNamedQuery(String queryName, Object value, Type type)
    
public  ListfindByNamedQuery(String queryName, Object[] values)
    
public  ListfindByNamedQuery(String queryName, Object[] values, Type[] types)
    
public  ListfindByNamedQueryAndNamedParam(String queryName, String paramName, Object value)
    
public  ListfindByNamedQueryAndNamedParam(String queryName, String paramName, Object value, Type type)
    
public  ListfindByNamedQueryAndNamedParam(String queryName, String[] paramNames, Object[] values)
    
public  ListfindByNamedQueryAndNamedParam(String queryName, String[] paramNames, Object[] values, Type[] types)
    
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  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 value, Type type)
    
public  Iteratoriterate(String queryString, Object[] values)
    
public  Iteratoriterate(String queryString, Object[] values, Type[] types)
    
public  Objectload(Class entityClass, Serializable id)
    
public  Objectload(Class entityClass, Serializable id, LockMode lockMode)
    
public  voidload(Object entity, Serializable id)
    
public  ListloadAll(Class entityClass)
    
public  voidlock(Object entity, LockMode lockMode)
    
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  Serializablesave(Object entity)
    
public  voidsave(Object entity, Serializable id)
    
public  voidsaveOrUpdate(Object entity)
    
public  voidsaveOrUpdateAll(Collection entities)
    
public  ObjectsaveOrUpdateCopy(Object entity)
    
public  voidsetAllowCreate(boolean allowCreate)
     Set if a new Session should be created when no transactional Session can be found for the current thread.
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)
    


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, Type type) 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
Parameters:
  type - Hibernate type of the parameter (or null if none specified)
throws:
  HibernateException - if thrown by the Query object



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. 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:   net.sf.hibernate.Session.getFlushMode
See Also:   net.sf.hibernate.FlushMode.NEVER




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:   net.sf.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)



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



delete
public int delete(String queryString, Object value, Type type) throws DataAccessException(Code)



delete
public int delete(String queryString, Object[] values, Type[] types) throws DataAccessException(Code)



deleteAll
public void deleteAll(Collection entities) throws DataAccessException(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 value, Type type) throws DataAccessException(Code)



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



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



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



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



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



findByNamedParam
public List findByNamedParam(String queryString, String[] paramNames, Object[] values, Type[] types) 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 value, Type type) throws DataAccessException(Code)



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



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



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



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



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



findByNamedQueryAndNamedParam
public List findByNamedQueryAndNamedParam(String queryName, String[] paramNames, Object[] values, Type[] types) 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)



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).
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 value, Type type) throws DataAccessException(Code)



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



iterate
public Iterator iterate(String queryString, Object[] values, Type[] types) 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 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)



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)



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



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



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



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



saveOrUpdateCopy
public Object saveOrUpdateCopy(Object entity) 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.

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 found, which needs to be closed at the end of the operation. If false, an IllegalStateException will get thrown in this case.
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:   net.sf.hibernate.Query.setCacheable
See Also:   net.sf.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:   net.sf.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:   net.sf.hibernate.Query.setCacheRegion
See Also:   net.sf.hibernate.Criteria.setCacheRegion




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



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



Fields inherited from org.springframework.orm.hibernate.HibernateAccessor
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.hibernate.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)(Code)(Java Doc)
protected DataAccessException convertJdbcAccessException(SQLException ex)(Code)(Java Doc)
protected void flushIfNecessary(Session session, boolean existingTransaction) throws HibernateException(Code)(Java Doc)
public Interceptor getEntityInterceptor() throws IllegalStateException, BeansException(Code)(Java Doc)
public int getFlushMode()(Code)(Java Doc)
public synchronized 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 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.