Typically used to implement data access or business logic services that
+ use NHibernate within their implementation but are Hibernate-agnostic in their
+ interface. The latter or code calling the latter only have to deal with
+ domain objects.
+
+
The central method is Execute() supporting Hibernate access code which
+ implements the HibernateCallback interface. It provides NHibernate Session
+ handling such that neither the IHibernateCallback implementation nor the calling
+ code needs to explicitly care about retrieving/closing NHibernate 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 ISessionFactory reference, or get prepared in an application context
+ and given to services as an object reference. Note: The ISessionFactory should
+ always be configured as an object 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 a direct alternative to working with the raw
+ Hibernate Session API (through SessionFactoryUtils.Session).
+
+
+
LocalSessionFactoryObject is the preferred way of obtaining a reference
+ to a specific NHibernate ISessionFactory.
+
+
+ Sree Nivask (.NET)
+ Mark Pollack (.NET)
+
+
+
+ Base class for HibernateTemplate defining common
+ properties like SessionFactory and flushing behavior.
+
+
+
Not intended to be used directly. See HibernateTemplate.
+
+
+ Mark Pollack (.NET)
+
+
+
+ The instance for this class.
+
+
+
+
+ Initializes a new instance of the class.
+
+
+
+
+ Apply the flush mode that's been specified for this accessor
+ to the given Session.
+
+ The current Hibernate Session.
+ if set to true
+ if executing within an existing transaction.
+
+ the previous flush mode to restore after the operation,
+ or null if none
+
+
+
+
+ Flush the given Hibernate Session if necessary.
+
+ The current Hibernate Session.
+ if set to true
+ if executing within an existing transaction.
+
+
+
+ Convert the given HibernateException to an appropriate exception from the
+ org.springframework.dao hierarchy. Will automatically detect
+ wrapped ADO.NET Exceptions and convert them accordingly.
+
+ HibernateException that occured.
+
+ The corresponding DataAccessException instance
+
+
+ The default implementation delegates to SessionFactoryUtils
+ and convertAdoAccessException. Can be overridden in subclasses.
+
+
+
+
+ Converts the ADO.NET access exception to an appropriate exception from the
+ org.springframework.dao hierarchy. Can be overridden in subclasses.
+
+ ADOException that occured, wrapping underlying ADO.NET exception.
+
+ the corresponding DataAccessException instance
+
+
+
+
+ Converts the ADO.NET access exception 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 ADO.NET access via ISession.Connection().
+
+
+ The ADO.NET exception.
+ The corresponding DataAccessException instance
+
+
+
+ Prepare the given IQuery object, applying cache settings and/or
+ a transaction timeout.
+
+ The query object to prepare.
+
+
+
+ Apply the given name parameter to the given Query object.
+
+ The query object.
+ Name of the parameter
+ The value of the parameter
+ The NHibernate type of the parameter (or null if none specified)
+
+
+
+ Prepare the given Criteria object, applying cache settings and/or
+ a transaction timeout.
+
+
+ Note that for NHibernate 1.2 this only works if the
+ implementation is of the type CriteriaImpl, which should generally
+ be the case. The SetFetchSize method is not available on the
+ ICriteria interface
+
+ This is a no-op for NHibernate 1.0.x since
+ the SetFetchSize method is not on the ICriteria interface and
+ the implementation class is has internal access.
+
+ To remove the method completely for Spring's NHibernate 1.0
+ support while reusing code for NHibernate 1.2 would not be
+ possible. So now this ineffectual operation is left in tact for
+ NHibernate 1.0.2 support.
+
+ The criteria object to prepare
+
+
+
+ Ensure SessionFactory is not null
+
+ If SessionFactory property is null.
+
+
+
+ Gets or sets if a new Session should be created when no transactional Session
+ can be found for the current thread.
+
+
+ true if allowed to create non-transaction session;
+ otherwise, false.
+
+
+
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 InvalidOperationException will get thrown in this case.
+
+
+
+
+
+ Gets or sets a value indicating whether to always
+ use a new Hibernate Session for this template.
+
+ true if always use new session; otherwise, false.
+
+
+ Default is "false"; if activated, all operations on this template will
+ work on a new NHibernate ISession even in case of a pre-bound ISession
+ (for example, within a transaction).
+
+
Within a transaction, a new NHibernate ISession used by this template
+ will participate in the transaction through using the same ADO.NET
+ 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 NHibernate ISession.
+
+
+
+
+
+ Set whether to expose the native Hibernate Session to IHibernateCallback
+ code. Default is "false": a Session proxy will be returned,
+ suppressing close calls and automatically applying
+ query cache settings and transaction timeouts.
+
+ true if expose native session; otherwise, false.
+
+
+
+ Gets or sets the template flush mode.
+
+
+ Default is Auto. Will get applied to any new ISession
+ created by the template.
+
+ The template flush mode.
+
+
+
+ Gets or sets the entity interceptor that allows to inspect and change
+ property values before writing to and reading from the database.
+
+
+ Will get applied to any new ISession created by this object.
+
Such an interceptor can either be set at the ISessionFactory level,
+ i.e. on LocalSessionFactoryObject, or at the ISession level, i.e. on
+ HibernateTemplate, HibernateInterceptor, and HibernateTransactionManager.
+ It's preferable to set it on LocalSessionFactoryObject or HibernateTransactionManager
+ to avoid repeated configuration and guarantee consistent behavior in transactions.
+
+
+ The interceptor.
+
+
+
+ Set the object 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 object factory to be known, to be able to resolve the object
+ 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.
+
+
+ The name of the entity interceptor in the object factory/application context.
+
+
+
+ Gets or sets the session factory that should be used to create
+ NHibernate ISessions.
+
+ The session factory.
+
+
+
+ Set the object factory instance.
+
+ The object factory instance.
+
+
+
+ Gets or sets a value indicating whether to
+ cache all queries executed by this template.
+
+
+ If this is true, all IQuery and ICriteria 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.
+
+
+ true if cache queries; otherwise, false.
+
+
+
+ Gets or sets the name of the cache region for queries executed by this template.
+
+
+ If this is specified, it will be applied to all IQuery and ICriteria 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.
+
+
+ The query cache region.
+
+
+
+ Gets or sets the fetch size for this HibernateTemplate.
+
+ The size of the fetch.
+ 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 driver's default.
+
+
+
+
+ Gets or sets the maximum number of rows for this HibernateTemplate.
+
+ The max results.
+
+ 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 ADO.NET 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 driver's default.
+
+
+
+
+ Set the ADO.NET exception translator for this instance.
+ Applied to System.Data.Common.DbException (or provider specific exception type
+ in .NET 1.1) thrown by callback code, be it direct
+ DbException or wrapped Hibernate ADOExceptions.
+
The default exception translator is either a ErrorCodeExceptionTranslator
+ if a DbProvider is available, or a FalbackExceptionTranslator otherwise
+
+
+ The ADO exception translator.
+
+
+
+ Gets a Session for use by this template.
+
+ The session.
+
+ - Returns a new Session in case of "alwaysUseNewSession" (using the same ADO.NET connection as a transaction Session, if applicable)
+ - a pre-bound Session in case of "AllowCreate" is set to false (not the default)
+ - or a pre-bound Session or new Session if no transactional or other pre-bound Session exists.
+
+
+
+
+ Helper class to determine if the FlushMode enumeration
+ was changed from its default value
+
+
+
+
+ Initializes a new instance of the class.
+
+
+
+
+ Initializes a new instance of the class.
+
+ The flush mode.
+
+
+
+ Gets or sets a value indicating whether the FlushMode
+ property was set..
+
+ true if FlushMode was set; otherwise, false.
+
+
+
+ Gets or sets the FlushMode.
+
+ The FlushMode.
+
+
+
+ Interface that specifies a basic set of Hibernate operations.
+
+
+ Implemented by HibernateTemplate. Not often used, but a useful option
+ to enhance testability, as it can easily be mocked or stubbed.
+
Provides HibernateTemplate's data access methods that mirror
+ various Session methods. See the NHibernate ISession documentation
+ for details on those methods.
+
+
+
+ Sree Nivask (.NET)
+ Mark Pollack (.NET)
+
+
+
+ Interface that specifies a set of Hibernate operations that
+ are common across versions of Hibernate.
+
+
+ Base interface for generic and non generic IHibernateOperations interfaces
+ Not often used, but a useful option
+ to enhance testability, as it can easily be mocked or stubbed.
+
Provides HibernateTemplate's data access methods that mirror
+ various Session methods. See the NHibernate ISession documentation
+ for details on those methods.
+
+
+ Mark Pollack (.NET)
+
+
+
+
+ Remove all objects from the Session cache, and cancel all pending saves,
+ updates and deletes.
+
+ In case of Hibernate errors
+
+
+
+ Delete the given persistent instance.
+
+ The persistent instance to delete.
+ In case of Hibernate errors
+
+
+
+ Delete the given persistent instance.
+
+
+ Obtains the specified lock mode if the instance exists, implicitly
+ checking whether the corresponding database entry still exists
+ (throwing an OptimisticLockingFailureException if not found).
+
+ Tthe persistent instance to delete.
+ The lock mode to obtain.
+ In case of Hibernate errors
+
+
+
+ Delete all objects returned by the query.
+
+ a query expressed in Hibernate's query language.
+ The number of entity instances deleted.
+ In case of Hibernate errors
+
+
+
+ Delete all objects returned by the query.
+
+ a query expressed in Hibernate's query language.
+ The value of the parameter.
+ The Hibernate type of the parameter (or null).
+ The number of entity instances deleted.
+ In case of Hibernate errors
+
+
+
+ Delete all objects returned by the query.
+
+ a query expressed in Hibernate's query language.
+ The values of the parameters.
+ Hibernate types of the parameters (or null)
+ The number of entity instances deleted.
+ In case of Hibernate errors
+
+
+
+ Flush all pending saves, updates and deletes to the database.
+
+
+ Only invoke this for selective eager flushing, for example when ADO.NET code
+ needs to see certain changes within the same transaction. Else, it's preferable
+ to rely on auto-flushing at transaction completion.
+
+ In case of Hibernate errors
+
+
+
+ Load the persistent instance with the given identifier
+ into the given object, throwing an exception if not found.
+
+ Entity the object (of the target class) to load into.
+ An identifier of the persistent instance.
+ If object not found.
+ In case of Hibernate errors
+
+
+
+ Re-read the state of the given persistent instance.
+
+ The persistent instance to re-read.
+ In case of Hibernate errors
+
+
+
+ Re-read the state of the given persistent instance.
+ Obtains the specified lock mode for the instance.
+
+ The persistent instance to re-read.
+ The lock mode to obtain.
+ In case of Hibernate errors
+
+
+
+ Determines whether the given object is in the Session cache.
+
+ the persistence instance to check.
+
+ true if session cache contains the specified entity; otherwise, false.
+
+ In case of Hibernate errors
+
+
+
+ Remove the given object from the Session cache.
+
+ The persistent instance to evict.
+ In case of Hibernate errors
+
+
+
+ Obtain the specified lock level upon the given object, implicitly
+ checking whether the corresponding database entry still exists
+ (throwing an OptimisticLockingFailureException if not found).
+
+ The he persistent instance to lock.
+ The lock mode to obtain.
+ If not found
+ In case of Hibernate errors
+
+
+
+ Persist the given transient instance.
+
+ The transient instance to persist.
+ The generated identifier.
+ In case of Hibernate errors
+
+
+
+ Persist the given transient instance with the given identifier.
+
+ The transient instance to persist.
+ The identifier to assign.
+ In case of Hibernate errors
+
+
+
+ Update the given persistent instance.
+
+ The persistent instance to update.
+ In case of Hibernate errors
+
+
+
+ Update the given persistent instance.
+ Obtains the specified lock mode if the instance exists, implicitly
+ checking whether the corresponding database entry still exists
+ (throwing an OptimisticLockingFailureException if not found).
+
+ The persistent instance to update.
+ The lock mode to obtain.
+ In case of Hibernate errors
+
+
+
+ Save or update the given persistent instance,
+ according to its id (matching the configured "unsaved-value"?).
+
+ Tthe persistent instance to save or update
+ (to be associated with the Hibernate Session).
+ In case of Hibernate errors
+
+
+
+ Save or update the contents of given persistent object,
+ according to its id (matching the configured "unsaved-value"?).
+ Will copy the contained fields to an already loaded instance
+ with the same id, if appropriate.
+
+ The persistent object to save or update.
+ (not necessarily to be associated with the Hibernate Session)
+
+ The actually associated persistent object.
+ (either an already loaded instance with the same id, or the given object)
+ In case of Hibernate errors
+
+
+
+ Return the persistent instance of the given entity type
+ with the given identifier, or if not found.
+ Obtains the specified lock mode if the instance exists.
+
+ The object type to get.
+ The id of the object to get.
+ the persistent instance, or if not found
+ In case of Hibernate errors
+
+
+
+ Return the persistent instance of the given entity type
+ with the given identifier, or null if not found.
+ Obtains the specified lock mode if the instance exists.
+
+ The object type to get.
+ The lock mode to obtain.
+ The lock mode.
+ the persistent instance, or null if not found
+ In case of Hibernate errors
+
+
+
+ Return the persistent instance of the given entity class
+ with the given identifier, throwing an exception if not found.
+
+ The object type to load.
+ An identifier of the persistent instance.
+ The persistent instance
+ If not found
+ In case of Hibernate errors
+
+
+
+ Return the persistent instance of the given entity class
+ with the given identifier, throwing an exception if not found.
+ Obtains the specified lock mode if the instance exists.
+
+ The object type to load.
+ An identifier of the persistent instance.
+ The lock mode.
+ The persistent instance
+ If not found
+ In case of Hibernate errors
+
+
+
+ Return all persistent instances of the given entity class.
+ Note: Use queries or criteria for retrieving a specific subset.
+
+ The object type to load.
+ A generic List containing 0 or more persistent instances
+ In case of Hibernate errors
+
+
+
+ Execute a query for persistent instances.
+
+ The object type to find.
+ a query expressed in Hibernate's query language
+
+ a generic List containing 0 or more persistent instances
+
+ In case of Hibernate errors
+
+
+
+ Execute a query for persistent instances, binding
+ one value to a "?" parameter in the query string.
+
+ The object type to find.
+ a query expressed in Hibernate's query language
+ the value of the parameter
+
+ a generic List containing 0 or more persistent instances
+
+ In case of Hibernate errors
+
+
+
+ Execute a query for persistent instances, binding one value
+ to a "?" parameter of the given type in the query string.
+
+ The object type to find.
+ a query expressed in Hibernate's query language
+ The value of the parameter.
+ Hibernate type of the parameter (or null)
+
+ a generic List containing 0 or more persistent instances
+
+ In case of Hibernate errors
+
+
+
+ Execute a query for persistent instances, binding a
+ number of values to "?" parameters in the query string.
+
+ The object type to find.
+ a query expressed in Hibernate's query language
+ the values of the parameters
+ a generic List containing 0 or more persistent instances
+ In case of Hibernate errors
+
+
+
+ Execute a query for persistent instances, binding a number of
+ values to "?" parameters of the given types in the query string.
+
+ The object type to find.
+ A query expressed in Hibernate's query language
+ The values of the parameters
+ Hibernate types of the parameters (or null)
+
+ a generic List containing 0 or more persistent instances
+
+ In case of Hibernate errors
+ If values and types are not null and their lenths are not equal
+
+
+
+ Execute a query for persistent instances, binding
+ one value to a named parameter in the query string.
+
+ The object type to find.
+ The name of a Hibernate query in a mapping file
+ The name of the parameter
+ The value of the parameter
+ a generic List containing 0 or more persistent instances
+ In case of Hibernate errors
+
+
+
+ Execute a query for persistent instances, binding
+ one value to a named parameter in the query string.
+
+ The object type to find.
+ The name of a Hibernate query in a mapping file
+ The name of the parameter
+ The value of the parameter
+ Hibernate type of the parameter (or null)
+ A generic List containing 0 or more persistent instances
+ In case of Hibernate errors
+
+
+
+ Execute a query for persistent instances, binding a
+ number of values to named parameters in the query string.
+
+ The object type to find.
+ A query expressed in Hibernate's query language
+ The names of the parameters
+ The values of the parameters
+ A generic List containing 0 or more persistent instances
+ In case of Hibernate errors
+
+
+
+ Execute a query for persistent instances, binding a
+ number of values to named parameters in the query string.
+
+ The object type to find.
+ A query expressed in Hibernate's query language
+ The names of the parameters
+ The values of the parameters
+ Hibernate types of the parameters (or null)
+ A generic List containing 0 or more persistent instances
+ In case of Hibernate errors
+ If paramNames length is not equal to values length or
+ if paramNames length is not equal to types length (when types is not null)
+
+
+
+ Execute a named query for persistent instances.
+ A named query is defined in a Hibernate mapping file.
+
+ The object type to find.
+ The name of a Hibernate query in a mapping file
+ A generic List containing 0 or more persistent instances
+ In case of Hibernate errors
+
+
+
+ Execute a named query for persistent instances, binding
+ one value to a "?" parameter in the query string.
+ A named query is defined in a Hibernate mapping file.
+
+ The object type to find.
+ The name of a Hibernate query in a mapping file
+ The value of the parameter
+ A generic List containing 0 or more persistent instances
+ In case of Hibernate errors
+
+
+
+ Execute a named query for persistent instances, binding
+ one value to a "?" parameter in the query string.
+ A named query is defined in a Hibernate mapping file.
+
+ The object type to find.
+ The name of a Hibernate query in a mapping file
+ The value of the parameter
+ Hibernate type of the parameter (or null)
+ A generic List containing 0 or more persistent instances
+ In case of Hibernate errors
+
+
+
+ Execute a named query for persistent instances, binding a
+ number of values to "?" parameters in the query string.
+ A named query is defined in a Hibernate mapping file.
+
+ The object type to find.
+ The name of a Hibernate query in a mapping file
+ The values of the parameters
+ A generic List containing 0 or more persistent instances
+ In case of Hibernate errors
+
+
+
+ Execute a named query for persistent instances, binding a
+ number of values to "?" parameters in the query string.
+ A named query is defined in a Hibernate mapping file.
+
+ The object type to find.
+ The name of a Hibernate query in a mapping file
+ The values of the parameters
+ Hibernate types of the parameters (or null)
+ A generic List containing 0 or more persistent instances
+ In case of Hibernate errors
+ If values and types are not null and their lengths differ.
+
+
+
+ Execute a named query for persistent instances, binding
+ one value to a named parameter in the query string.
+ A named query is defined in a Hibernate mapping file.
+
+ The object type to find.
+ The name of a Hibernate query in a mapping file
+ Name of the parameter
+ The value of the parameter
+ A generic List containing 0 or more persistent instances
+ In case of Hibernate errors
+
+
+
+ Execute a named query for persistent instances, binding
+ one value to a named parameter in the query string.
+ A named query is defined in a Hibernate mapping file.
+
+ The object type to find.
+ The name of a Hibernate query in a mapping file
+ Name of the parameter
+ The value of the parameter
+ The Hibernate type of the parameter (or null)
+ A generic List containing 0 or more persistent instances
+ In case of Hibernate errors
+
+
+
+ Execute a named query for persistent instances, binding
+ number of values to named parameters in the query string.
+ A named query is defined in a Hibernate mapping file.
+
+ The object type to find.
+ The name of a Hibernate query in a mapping file
+ The names of the parameters
+ The values of the parameters.
+ A generic List containing 0 or more persistent instances
+ In case of Hibernate errors
+
+
+
+ Execute a named query for persistent instances, binding
+ number of values to named parameters in the query string.
+ A named query is defined in a Hibernate mapping file.
+
+ The object type to find.
+ The name of a Hibernate query in a mapping file
+ The names of the parameters
+ The values of the parameters.
+ Hibernate types of the parameters (or null)
+ A generic List containing 0 or more persistent instances
+ In case of Hibernate errors
+ If paramNames length is not equal to values length or
+ if paramNames length is not equal to types length (when types is not null)
+
+
+
+ Execute a named query for persistent instances, binding the properties
+ of the given object to named parameters in the query string.
+ A named query is defined in a Hibernate mapping file.
+
+ The object type to find.
+ The name of a Hibernate query in a mapping file
+ The values of the parameters
+ A generic List containing 0 or more persistent instances
+ In case of Hibernate errors
+
+
+
+ Execute a query for persistent instances, binding the properties
+ of the given object to named parameters in the query string.
+
+ The object type to find.
+ A query expressed in Hibernate's query language
+ The values of the parameters
+ A generic List containing 0 or more persistent instances
+ In case of Hibernate errors
+
+
+
+ Execute the action specified by the given action object within a Session.
+
+
+ Application exceptions thrown by the action object get propagated to the
+ caller (can only be unchecked). Hibernate exceptions are transformed into
+ appropriate DAO ones. Allows for returning the result object.
+
Note: Callback code is not supposed to handle transactions itself!
+ Use an appropriate transaction manager like HibernateTransactionManager.
+ Generally, callback code must not touch any Session lifecycle methods,
+ like close, disconnect, or reconnect, to let the template do its work.
+
+
+ The object type retrieved.
+ The delegate callback object that specifies the Hibernate action.
+ a result object returned by the action, or null
+
+ In case of Hibernate errors
+
+
+
+ Execute the action specified by the delegate within a Session.
+
+ The object type retrieved.
+ The HibernateDelegate that specifies the action
+ to perform.
+ if set to true expose the native hibernate session to
+ callback code.
+ a result object returned by the action, or null
+
+ In case of Hibernate errors
+
+
+
+ Execute the action specified by the given action object within a Session.
+
+ The object type retrieved.
+ The callback object that specifies the Hibernate action.
+
+ a result object returned by the action, or null
+
+
+ Application exceptions thrown by the action object get propagated to the
+ caller (can only be unchecked). Hibernate exceptions are transformed into
+ appropriate DAO ones. Allows for returning the result object.
+
Note: Callback code is not supposed to handle transactions itself!
+ Use an appropriate transaction manager like HibernateTransactionManager.
+ Generally, callback code must not touch any Session lifecycle methods,
+ like close, disconnect, or reconnect, to let the template do its work.
+
+
+ In case of Hibernate errors
+
+
+
+ Execute the action specified by the given action object within a Session.
+
+ The object type retrieved.
+ callback object that specifies the Hibernate action.
+ if set to true expose the native hibernate session to
+ callback code.
+
+ a result object returned by the action, or null
+
+ In case of Hibernate errors
+
+
+
+ Execute the action specified by the given action object within a Session.
+
+
+ Application exceptions thrown by the action object get propagated to the
+ caller (can only be unchecked). Hibernate exceptions are transformed into
+ appropriate DAO ones. Allows for returning the result object.
+
Note: Callback code is not supposed to handle transactions itself!
+ Use an appropriate transaction manager like HibernateTransactionManager.
+ Generally, callback code must not touch any Session lifecycle methods,
+ like close, disconnect, or reconnect, to let the template do its work.
+
+
+ The object type to find.
+ The delegate callback object that specifies the Hibernate action.
+ A generic IList returned by the action, or null
+
+ In case of Hibernate errors
+
+
+
+ Execute the action specified by the delegate within a Session.
+
+ The object type to find.
+ The FindHibernateDelegate that specifies the action
+ to perform.
+ if set to true expose the native hibernate session to
+ callback code.
+ A generic IList returned by the action, or null
+
+ In case of Hibernate errors
+
+
+
+ Execute the action specified by the given action object within a Session.
+
+ The object type to find.
+ The callback object that specifies the Hibernate action.
+
+ A generic IList returned by the action, or null
+
+
+ Application exceptions thrown by the action object get propagated to the
+ caller (can only be unchecked). Hibernate exceptions are transformed into
+ appropriate DAO ones. Allows for returning the result object.
+
Note: Callback code is not supposed to handle transactions itself!
+ Use an appropriate transaction manager like HibernateTransactionManager.
+ Generally, callback code must not touch any Session lifecycle methods,
+ like close, disconnect, or reconnect, to let the template do its work.
+
+
+
+
+
+ Execute the action specified by the given action object within a Session assuming that an IList is returned.
+
+ The object type to find.
+ callback object that specifies the Hibernate action.
+ if set to true expose the native hibernate session to
+ callback code.
+
+ an IList returned by the action, or null
+
+ In case of Hibernate errors
+
+
+
+ Initializes a new instance of the class.
+
+
+
+
+ Initializes a new instance of the class.
+
+ Allows creation of a new non-transactional session when no
+ transactional Session can be found for the current thread
+ The session factory to create sessions.
+
+
+
+ Initializes a new instance of the class.
+
+ The session factory to create sessions.
+ if set to true allow creation
+ of a new non-transactional session when no transactional Session can be found
+ for the current thread.
+
+
+
+ Remove all objects from the Session cache, and cancel all pending saves,
+ updates and deletes.
+
+
+
+
+ Delete the given persistent instance.
+
+ The persistent instance to delete.
+ In case of Hibernate errors
+
+
+
+ Delete the given persistent instance.
+
+ Tthe persistent instance to delete.
+ The lock mode to obtain.
+
+ Obtains the specified lock mode if the instance exists, implicitly
+ checking whether the corresponding database entry still exists
+ (throwing an OptimisticLockingFailureException if not found).
+
+ In case of Hibernate errors
+
+
+
+ Delete all objects returned by the query.
+
+ a query expressed in Hibernate's query language.
+ The number of entity instances deleted.
+ In case of Hibernate errors
+
+
+
+ Delete all objects returned by the query.
+
+ a query expressed in Hibernate's query language.
+ The value of the parameter.
+ The Hibernate type of the parameter (or null).
+ The number of entity instances deleted.
+ In case of Hibernate errors
+
+
+
+ Delete all objects returned by the query.
+
+ a query expressed in Hibernate's query language.
+ The values of the parameters.
+ Hibernate types of the parameters (or null)
+ The number of entity instances deleted.
+ In case of Hibernate errors
+
+
+
+ Flush all pending saves, updates and deletes to the database.
+
+
+ Only invoke this for selective eager flushing, for example when ADO.NET code
+ needs to see certain changes within the same transaction. Else, it's preferable
+ to rely on auto-flushing at transaction completion.
+
+ In case of Hibernate errors
+
+
+
+ Load the persistent instance with the given identifier
+ into the given object, throwing an exception if not found.
+
+ Entity the object (of the target class) to load into.
+ An identifier of the persistent instance.
+ If object not found.
+ In case of Hibernate errors
+
+
+
+ Re-read the state of the given persistent instance.
+
+ The persistent instance to re-read.
+ In case of Hibernate errors
+
+
+
+ Re-read the state of the given persistent instance.
+ Obtains the specified lock mode for the instance.
+
+ The persistent instance to re-read.
+ The lock mode to obtain.
+ In case of Hibernate errors
+
+
+
+ Determines whether the given object is in the Session cache.
+
+ the persistence instance to check.
+
+ true if session cache contains the specified entity; otherwise, false.
+
+ In case of Hibernate errors
+
+
+
+ Remove the given object from the Session cache.
+
+ The persistent instance to evict.
+ In case of Hibernate errors
+
+
+
+ Obtain the specified lock level upon the given object, implicitly
+ checking whether the corresponding database entry still exists
+ (throwing an OptimisticLockingFailureException if not found).
+
+ The he persistent instance to lock.
+ The lock mode to obtain.
+ If not found
+ In case of Hibernate errors
+
+
+
+ Persist the given transient instance.
+
+ The transient instance to persist.
+ The generated identifier.
+ In case of Hibernate errors
+
+
+
+ Persist the given transient instance with the given identifier.
+
+ The transient instance to persist.
+ The identifier to assign.
+ In case of Hibernate errors
+
+
+
+ Update the given persistent instance.
+
+ The persistent instance to update.
+ In case of Hibernate errors
+
+
+
+ Update the given persistent instance.
+ Obtains the specified lock mode if the instance exists, implicitly
+ checking whether the corresponding database entry still exists
+ (throwing an OptimisticLockingFailureException if not found).
+
+ The persistent instance to update.
+ The lock mode to obtain.
+ In case of Hibernate errors
+
+
+
+ Save or update the given persistent instance,
+ according to its id (matching the configured "unsaved-value"?).
+
+ Tthe persistent instance to save or update
+ (to be associated with the Hibernate Session).
+ In case of Hibernate errors
+
+
+
+ Save or update the contents of given persistent object,
+ according to its id (matching the configured "unsaved-value"?).
+ Will copy the contained fields to an already loaded instance
+ with the same id, if appropriate.
+
+ The persistent object to save or update.
+ (not necessarily to be associated with the Hibernate Session)
+
+ The actually associated persistent object.
+ (either an already loaded instance with the same id, or the given object)
+ In case of Hibernate errors
+
+
+
+ Return the persistent instance of the given entity type
+ with the given identifier, or null if not found.
+ Obtains the specified lock mode if the instance exists.
+
+ The object type to get.
+ The id of the object to get.
+ the persistent instance, or null if not found
+ In case of Hibernate errors
+
+
+
+ Return the persistent instance of the given entity type
+ with the given identifier, or null if not found.
+ Obtains the specified lock mode if the instance exists.
+
+ The object type to get.
+ The lock mode to obtain.
+ The lock mode.
+ the persistent instance, or null if not found
+ In case of Hibernate errors
+
+
+
+ Return the persistent instance of the given entity class
+ with the given identifier, throwing an exception if not found.
+
+ The object type to load.
+ An identifier of the persistent instance.
+ The persistent instance
+ If not found
+ In case of Hibernate errors
+
+
+
+ Return the persistent instance of the given entity class
+ with the given identifier, throwing an exception if not found.
+ Obtains the specified lock mode if the instance exists.
+
+ The object type to load.
+ An identifier of the persistent instance.
+ The lock mode.
+ The persistent instance
+ If not found
+ In case of Hibernate errors
+
+
+
+ Return all persistent instances of the given entity class.
+ Note: Use queries or criteria for retrieving a specific subset.
+
+ The object type to load.
+ A generic List containing 0 or more persistent instances
+ In case of Hibernate errors
+
+
+
+ Execute a query for persistent instances.
+
+ The object type to find.
+ a query expressed in Hibernate's query language
+
+ a generic List containing 0 or more persistent instances
+
+ In case of Hibernate errors
+
+
+
+ Execute a query for persistent instances, binding
+ one value to a "?" parameter in the query string.
+
+ The object type to find.
+ a query expressed in Hibernate's query language
+ the value of the parameter
+
+ a generic List containing 0 or more persistent instances
+
+ In case of Hibernate errors
+
+
+
+ Execute a query for persistent instances, binding one value
+ to a "?" parameter of the given type in the query string.
+
+ The object type to find.
+ a query expressed in Hibernate's query language
+ The value of the parameter.
+ Hibernate type of the parameter (or null)
+
+ a generic List containing 0 or more persistent instances
+
+ In case of Hibernate errors
+
+
+
+ Execute a query for persistent instances, binding a
+ number of values to "?" parameters in the query string.
+
+ The object type to find.
+ a query expressed in Hibernate's query language
+ the values of the parameters
+ a generic List containing 0 or more persistent instances
+ In case of Hibernate errors
+
+
+
+ Execute a query for persistent instances, binding a number of
+ values to "?" parameters of the given types in the query string.
+
+ The object type to find.
+ A query expressed in Hibernate's query language
+ The values of the parameters
+ Hibernate types of the parameters (or null)
+
+ a generic List containing 0 or more persistent instances
+
+ In case of Hibernate errors
+ If values and types are not null and their lengths are not equal
+
+
+
+ Execute a query for persistent instances, binding
+ one value to a named parameter in the query string.
+
+ The object type to find.
+ The name of a Hibernate query in a mapping file
+ The name of the parameter
+ The value of the parameter
+ a generic List containing 0 or more persistent instances
+ In case of Hibernate errors
+
+
+
+ Execute a query for persistent instances, binding
+ one value to a named parameter in the query string.
+
+ The object type to find.
+ The name of a Hibernate query in a mapping file
+ The name of the parameter
+ The value of the parameter
+ Hibernate type of the parameter (or null)
+ A generic List containing 0 or more persistent instances
+ In case of Hibernate errors
+
+
+
+ Execute a query for persistent instances, binding a
+ number of values to named parameters in the query string.
+
+ The object type to find.
+ A query expressed in Hibernate's query language
+ The names of the parameters
+ The values of the parameters
+ A generic List containing 0 or more persistent instances
+ In case of Hibernate errors
+
+
+
+ Execute a query for persistent instances, binding a
+ number of values to named parameters in the query string.
+
+ The object type to find.
+ A query expressed in Hibernate's query language
+ The names of the parameters
+ The values of the parameters
+ Hibernate types of the parameters (or null)
+ A generic List containing 0 or more persistent instances
+ In case of Hibernate errors
+ If paramNames length is not equal to values length or
+ if paramNames length is not equal to types length (when types is not null)
+
+
+
+ Execute a named query for persistent instances.
+ A named query is defined in a Hibernate mapping file.
+
+ The object type to find.
+ The name of a Hibernate query in a mapping file
+ A generic List containing 0 or more persistent instances
+ In case of Hibernate errors
+
+
+
+ Execute a named query for persistent instances, binding
+ one value to a "?" parameter in the query string.
+ A named query is defined in a Hibernate mapping file.
+
+ The object type to find.
+ The name of a Hibernate query in a mapping file
+ The value of the parameter
+ A generic List containing 0 or more persistent instances
+ In case of Hibernate errors
+
+
+
+ Execute a named query for persistent instances, binding
+ one value to a "?" parameter in the query string.
+ A named query is defined in a Hibernate mapping file.
+
+ The object type to find.
+ The name of a Hibernate query in a mapping file
+ The value of the parameter
+ Hibernate type of the parameter (or null)
+ A generic List containing 0 or more persistent instances
+ In case of Hibernate errors
+
+
+
+ Execute a named query for persistent instances, binding a
+ number of values to "?" parameters in the query string.
+ A named query is defined in a Hibernate mapping file.
+
+ The object type to find.
+ The name of a Hibernate query in a mapping file
+ The values of the parameters
+ A generic List containing 0 or more persistent instances
+ In case of Hibernate errors
+
+
+
+ Execute a named query for persistent instances, binding a
+ number of values to "?" parameters in the query string.
+ A named query is defined in a Hibernate mapping file.
+
+ The object type to find.
+ The name of a Hibernate query in a mapping file
+ The values of the parameters
+ Hibernate types of the parameters (or null)
+ A generic List containing 0 or more persistent instances
+ In case of Hibernate errors
+ If values and types are not null and their lengths differ.
+
+
+
+ Execute a named query for persistent instances, binding
+ one value to a named parameter in the query string.
+ A named query is defined in a Hibernate mapping file.
+
+ The object type to find.
+ The name of a Hibernate query in a mapping file
+ Name of the parameter
+ The value of the parameter
+ A generic List containing 0 or more persistent instances
+ In case of Hibernate errors
+
+
+
+ Execute a named query for persistent instances, binding
+ one value to a named parameter in the query string.
+ A named query is defined in a Hibernate mapping file.
+
+ The object type to find.
+ The name of a Hibernate query in a mapping file
+ Name of the parameter
+ The value of the parameter
+ The Hibernate type of the parameter (or null)
+ A generic List containing 0 or more persistent instances
+ In case of Hibernate errors
+
+
+
+ Execute a named query for persistent instances, binding
+ number of values to named parameters in the query string.
+ A named query is defined in a Hibernate mapping file.
+
+ The object type to find.
+ The name of a Hibernate query in a mapping file
+ The names of the parameters
+ The values of the parameters.
+ A generic List containing 0 or more persistent instances
+ In case of Hibernate errors
+
+
+
+ Execute a named query for persistent instances, binding
+ number of values to named parameters in the query string.
+ A named query is defined in a Hibernate mapping file.
+
+ The object type to find.
+ The name of a Hibernate query in a mapping file
+ The names of the parameters
+ The values of the parameters.
+ Hibernate types of the parameters (or null)
+ A generic List containing 0 or more persistent instances
+ In case of Hibernate errors
+ If paramNames length is not equal to values length or
+ if paramNames length is not equal to types length (when types is not null)
+
+
+
+ Execute a named query for persistent instances, binding the properties
+ of the given object to named parameters in the query string.
+ A named query is defined in a Hibernate mapping file.
+
+ The object type to find.
+ The name of a Hibernate query in a mapping file
+ The values of the parameters
+ A generic List containing 0 or more persistent instances
+ In case of Hibernate errors
+
+
+
+ Execute a query for persistent instances, binding the properties
+ of the given object to named parameters in the query string.
+
+ The object type to find.
+ A query expressed in Hibernate's query language
+ The values of the parameters
+ A generic List containing 0 or more persistent instances
+ In case of Hibernate errors
+
+
+
+ Execute the action specified by the given action object within a Session.
+
+
+ Application exceptions thrown by the action object get propagated to the
+ caller (can only be unchecked). Hibernate exceptions are transformed into
+ appropriate DAO ones. Allows for returning the result object.
+
Note: Callback code is not supposed to handle transactions itself!
+ Use an appropriate transaction manager like HibernateTransactionManager.
+ Generally, callback code must not touch any Session lifecycle methods,
+ like close, disconnect, or reconnect, to let the template do its work.
+
+
+ The object type retrieved.
+ The delegate callback object that specifies the Hibernate action.
+ a result object returned by the action, or null
+
+ In case of Hibernate errors
+
+
+
+ Execute the action specified by the delegate within a Session.
+
+ The object type retrieved.
+ The HibernateDelegate that specifies the action
+ to perform.
+ if set to true expose the native hibernate session to
+ callback code.
+ a result object returned by the action, or null
+
+ In case of Hibernate errors
+
+
+
+ Execute the action specified by the given action object within a Session.
+
+ The object type retrieved.
+ The callback object that specifies the Hibernate action.
+
+ a result object returned by the action, or null
+
+
+ Application exceptions thrown by the action object get propagated to the
+ caller (can only be unchecked). Hibernate exceptions are transformed into
+ appropriate DAO ones. Allows for returning the result object.
+
Note: Callback code is not supposed to handle transactions itself!
+ Use an appropriate transaction manager like HibernateTransactionManager.
+ Generally, callback code must not touch any Session lifecycle methods,
+ like close, disconnect, or reconnect, to let the template do its work.
+
+
+ In case of Hibernate errors
+
+
+
+ Execute the action specified by the given action object within a Session.
+
+ The object type retrieved.
+ callback object that specifies the Hibernate action.
+ if set to true expose the native hibernate session to
+ callback code.
+
+ a result object returned by the action, or null
+
+ In case of Hibernate errors
+
+
+
+ Execute the action specified by the given action object within a Session assuming that an IList is returned.
+
+ The object type to find.
+ callback object that specifies the Hibernate action.
+ if set to true expose the native hibernate session to
+ callback code.
+
+ an IList returned by the action, or null
+
+ In case of Hibernate errors
+
+
+
+ Execute the action specified by the given action object within a Session.
+
+
+ Application exceptions thrown by the action object get propagated to the
+ caller (can only be unchecked). Hibernate exceptions are transformed into
+ appropriate DAO ones. Allows for returning the result object.
+
Note: Callback code is not supposed to handle transactions itself!
+ Use an appropriate transaction manager like HibernateTransactionManager.
+ Generally, callback code must not touch any Session lifecycle methods,
+ like close, disconnect, or reconnect, to let the template do its work.
+
+
+ The object type to find.
+ The delegate callback object that specifies the Hibernate action.
+ A generic IList returned by the action, or null
+
+ In case of Hibernate errors
+
+
+
+ Execute the action specified by the delegate within a Session.
+
+ The object type to find.
+ The FindHibernateDelegate that specifies the action
+ to perform.
+ if set to true expose the native hibernate session to
+ callback code.
+ A generic IList returned by the action, or null
+
+ In case of Hibernate errors
+
+
+
+ Execute the action specified by the given action object within a Session.
+
+ The object type to find.
+ The callback object that specifies the Hibernate action.
+
+ A generic IList returned by the action, or null
+
+
+ Application exceptions thrown by the action object get propagated to the
+ caller (can only be unchecked). Hibernate exceptions are transformed into
+ appropriate DAO ones. Allows for returning the result object.
+
Note: Callback code is not supposed to handle transactions itself!
+ Use an appropriate transaction manager like HibernateTransactionManager.
+ Generally, callback code must not touch any Session lifecycle methods,
+ like close, disconnect, or reconnect, to let the template do its work.
+
+
+
+
+
+ Gets or sets if a new Session should be created when no transactional Session
+ can be found for the current thread.
+
+
+ true if allowed to create non-transaction session;
+ otherwise, false.
+
+
+
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 InvalidOperationException will get thrown in this case.
+
+
+
+
+
+ Gets or sets a value indicating whether to always
+ use a new Hibernate Session for this template.
+
+ true if always use new session; otherwise, false.
+
+
+ Default is "false"; if activated, all operations on this template will
+ work on a new NHibernate ISession even in case of a pre-bound ISession
+ (for example, within a transaction).
+
+
Within a transaction, a new NHibernate ISession used by this template
+ will participate in the transaction through using the same ADO.NET
+ 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 NHibernate ISession.
+
+
+
+
+
+ Set whether to expose the native Hibernate Session to IHibernateCallback
+ code. Default is "false": a Session proxy will be returned,
+ suppressing close calls and automatically applying
+ query cache settings and transaction timeouts.
+
+ true if expose native session; otherwise, false.
+
+
+
+ Gets or sets the template flush mode.
+
+
+ Default is Auto. Will get applied to any new ISession
+ created by the template.
+
+ The template flush mode.
+
+
+
+ Gets or sets the entity interceptor that allows to inspect and change
+ property values before writing to and reading from the database.
+
+
+ Will get applied to any new ISession created by this object.
+
Such an interceptor can either be set at the ISessionFactory level,
+ i.e. on LocalSessionFactoryObject, or at the ISession level, i.e. on
+ HibernateTemplate, HibernateInterceptor, and HibernateTransactionManager.
+ It's preferable to set it on LocalSessionFactoryObject or HibernateTransactionManager
+ to avoid repeated configuration and guarantee consistent behavior in transactions.
+
+
+ The interceptor.
+
+
+
+ Set the object 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 object factory to be known, to be able to resolve the object
+ 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.
+
+
+ The name of the entity interceptor in the object factory/application context.
+
+
+
+ Gets or sets the session factory that should be used to create
+ NHibernate ISessions.
+
+ The session factory.
+
+
+
+ Set the object factory instance.
+
+ The object factory instance
+
+
+
+ Gets or sets a value indicating whether to
+ cache all queries executed by this template.
+
+
+ If this is true, all IQuery and ICriteria 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.
+
+
+ true if cache queries; otherwise, false.
+
+
+
+ Gets or sets the name of the cache region for queries executed by this template.
+
+
+ If this is specified, it will be applied to all IQuery and ICriteria 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.
+
+
+ The query cache region.
+
+
+
+ Gets or sets the fetch size for this HibernateTemplate.
+
+ The size of the fetch.
+ 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 driver's default.
+
+
+
+
+ Gets or sets the maximum number of rows for this HibernateTemplate.
+
+ The max results.
+
+ 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 ADO.NET 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 driver's default.
+
+
+
+
+ Set the ADO.NET exception translator for this instance.
+ Applied to System.Data.Common.DbException (or provider specific exception type
+ in .NET 1.1) thrown by callback code, be it direct
+ DbException or wrapped Hibernate ADOExceptions.
+
The default exception translator is either a ErrorCodeExceptionTranslator
+ if a DbProvider is available, or a FalbackExceptionTranslator otherwise
+
+
+ The ADO exception translator.
+
+
+
+ Gets the classic hibernate template for access to non-generic methods.
+
+ The classic hibernate template.
+
+
+
+ Gets or sets the proxy factory.
+
+ This may be useful to set if you create many instances of
+ HibernateTemplate and/or HibernateDaoSupport. This allows the same
+ ProxyFactory implementation to be used thereby limiting the
+ number of dynamic proxy types created in the temporary assembly, which
+ are never garbage collected due to .NET runtime semantics.
+
+ The proxy factory.
+
+
+
+ Callback interface (Generic version) for NHibernate code.
+
+ The type of result object
+ To be used with HibernateTemplate execute
+ method. The typical implementation will call
+ Session.load/find/save/update to perform
+ some operations on persistent objects.
+
+
+ Sree Nivask (.NET)
+
+
+
+ Gets called by HibernateTemplate with an active
+ Hibernate Session. Does not need to care about activating or closing
+ the Session, or handling transactions.
+
+
+
+ Allows for returning a result object created within the callback, i.e.
+ a domain object or a collection of domain objects. Note that there's
+ special support for single step actions: see HibernateTemplate.find etc.
+
+
+ A result object.
+ The active Hibernate session
+
+
+
+ Gets called by HibernateTemplate with an active
+ Hibernate Session. Does not need to care about activating or closing
+ the Session, or handling transactions.
+
+
+
+ Allows for returning a result object created within the callback, i.e.
+ a domain object or a collection of domain objects. Note that there's
+ special support for single step actions: see HibernateTemplate.find etc.
+
+
+
+
+
+ Gets called by HibernateTemplate with an active
+ Hibernate Session. Does not need to care about activating or closing
+ the Session, or handling transactions.
+
+
+
+ Allows for returning a result object created within the callback, i.e.
+ a domain object or a collection of domain objects. Note that there's
+ special support for single step actions: see HibernateTemplate.find etc.
+
+
+
+
+
+ Callback interface (Generic version) for NHibernate code that
+ returns a List of objects.
+
+ The type of result object
+ To be used with HibernateTemplate execute
+ method. The typical implementation will call
+ Session.load/find/save/update to perform
+ some operations on persistent objects.
+
+ Sree Nivask (.NET)
+ Mark Pollack (.NET)
+
+
+
+ Gets called by HibernateTemplate with an active
+ Hibernate Session. Does not need to care about activating or closing
+ the Session, or handling transactions.
+
+
+
+ Allows for returning a result object created within the callback, i.e.
+ a domain object or a collection of domain objects. Note that there's
+ special support for single step actions: see HibernateTemplate.find etc.
+
+
+ Collection result object.
+
+
+
+ Gets called by HibernateTemplate with an active
+ Hibernate Session. Does not need to care about activating or closing
+ the Session, or handling transactions.
+
+
+
+ Allows for returning a result object created within the callback, i.e.
+ a domain object or a collection of domain objects. Note that there's
+ special support for single step actions: see HibernateTemplate.find etc.
+
+
+
+
+
+ Gets called by HibernateTemplate with an active
+ Hibernate Session. Does not need to care about activating or closing
+ the Session, or handling transactions.
+
+
+
+ Allows for returning a result object created within the callback, i.e.
+ a domain object or a collection of domain objects. Note that there's
+ special support for single step actions: see HibernateTemplate.find etc.
+
+
+
+
+
+ Gets called by HibernateTemplate with an active
+ Hibernate Session. Does not need to care about activating or closing
+ the Session, or handling transactions.
+
+
+
+ Allows for returning a result object created within the callback, i.e.
+ a domain object or a collection of domain objects. Note that there's
+ special support for single step actions: see HibernateTemplate.find etc.
+
+
+
+
+
+ Gets called by HibernateTemplate with an active
+ Hibernate Session. Does not need to care about activating or closing
+ the Session, or handling transactions.
+
+
+
+ Allows for returning a result object created within the callback, i.e.
+ a domain object or a collection of domain objects. Note that there's
+ special support for single step actions: see HibernateTemplate.find etc.
+
+
+
+
+
+ Gets called by HibernateTemplate with an active
+ Hibernate Session. Does not need to care about activating or closing
+ the Session, or handling transactions.
+
+
+
+ Allows for returning a result object created within the callback, i.e.
+ a domain object or a collection of domain objects. Note that there's
+ special support for single step actions: see HibernateTemplate.find etc.
+
+
+
+
+
+ Gets called by HibernateTemplate with an active
+ Hibernate Session. Does not need to care about activating or closing
+ the Session, or handling transactions.
+
+
+
+ Allows for returning a result object created within the callback, i.e.
+ a domain object or a collection of domain objects. Note that there's
+ special support for single step actions: see HibernateTemplate.find etc.
+
+
+
+
+
+ NHibnerations actions taken during the transaction lifecycle.
+
+ Mark Pollack (.NET)
+
+
+
+ The instance for this class.
+
+
+
+
+ Initializes a new instance of the class.
+
+
+
+
+ Suspend this synchronization.
+
+
+
+ Unbind Hibernate resources (SessionHolder) from
+
+ if managing any.
+
+
+
+
+
+ Resume this synchronization.
+
+
+
+ Rebind Hibernate resources from
+
+ if managing any.
+
+
+
+
+
+ Invoked before transaction commit (before
+ )
+
+
+ If the transaction is defined as a read-only transaction.
+
+
+
+ Can flush transactional sessions to the database.
+
+
+ Note that exceptions will get propagated to the commit caller and
+ cause a rollback of the transaction.
+
+
+
+
+
+ Invoked before transaction commit (before
+ )
+ Can e.g. flush transactional O/R Mapping sessions to the database
+
+
+
+ This callback does not mean that the transaction will actually be
+ commited. A rollback decision can still occur after this method
+ has been called. This callback is rather meant to perform work
+ that's only relevant if a commit still has a chance
+ to happen, such as flushing SQL statements to the database.
+
+
+ Note that exceptions will get propagated to the commit caller and cause a
+ rollback of the transaction.
+
+ (note: do not throw TransactionException subclasses here!)
+
+
+
+
+
+ Invoked after transaction commit/rollback.
+
+
+ Status according to
+
+
+ Can e.g. perform resource cleanup, in this case after transaction completion.
+
+ Note that exceptions will get propagated to the commit or rollback
+ caller, although they will not influence the outcome of the transaction.
+
+
+
+
+
+ Return the order value of this object, where a higher value means greater in
+ terms of sorting.
+
+
+
+ Normally starting with 0 or 1, with indicating
+ greatest. Same order values will result in arbitrary positions for the affected
+ objects.
+
+
+ Higher value can be interpreted as lower priority, consequently the first object
+ has highest priority.
+
+
+ The order value.
+
+
+
+ PlatformTransactionManager implementation for a single Hibernate SessionFactory.
+ Binds a Hibernate Session from the specified factory to the thread, potentially
+ allowing for one thread Session per factory
+
+
+ SessionFactoryUtils and HibernateTemplate are aware of thread-bound Sessions and participate in such
+ transactions automatically. Using either of those is required for Hibernate
+ access code that needs to support this transaction handling mechanism.
+
+ Supports custom isolation levels at the start of the transaction
+ , and timeouts that get applied as appropriate
+ Hibernate query timeouts. To support the latter, application code must either use
+ HibernateTemplate (which by default applies the timeouts) or call
+ SessionFactoryUtils.applyTransactionTimeout for each created
+ Hibernate Query object.
+
+ Note that you can specify a Spring IDbProvider instance which if shared with
+ a corresponding instance of AdoTemplate will allow for mixing ADO.NET/NHibernate
+ operations within a single transaction.
+
+ Mark Pollack (.NET)
+
+
+
+ Just needed for entityInterceptorBeanName.
+
+
+
+
+ Initializes a new instance of the class.
+
+
+
+
+ Initializes a new instance of the class.
+
+ The session factory.
+
+
+
+ Return the current transaction object.
+
+ The current transaction object.
+
+ If transaction support is not available.
+
+
+ In the case of lookup or system errors.
+
+
+
+
+ Check if the given transaction object indicates an existing,
+ i.e. already begun, transaction.
+
+
+ Transaction object returned by
+ .
+
+ True if there is an existing transaction.
+
+ In the case of system errors.
+
+
+
+
+ Begin a new transaction with the given transaction definition.
+
+
+ Transaction object returned by
+ .
+
+
+ instance, describing
+ propagation behavior, isolation level, timeout etc.
+
+
+ Does not have to care about applying the propagation behavior,
+ as this has already been handled by this abstract manager.
+
+
+ In the case of creation or system errors.
+
+
+
+
+ Suspend the resources of the current transaction.
+
+
+ Transaction object returned by
+ .
+
+
+ An object that holds suspended resources (will be kept unexamined for passing it into
+ .)
+
+
+ Transaction synchronization will already have been suspended.
+
+
+ If suspending is not supported by the transaction manager implementation.
+
+
+ in case of system errors.
+
+
+
+
+ Resume the resources of the current transaction.
+
+
+ Transaction object returned by
+ .
+
+
+ The object that holds suspended resources as returned by
+ .
+
+
+ Transaction synchronization will be resumed afterwards.
+
+
+ If suspending is not supported by the transaction manager implementation.
+
+
+ In the case of system errors.
+
+
+
+
+ Perform an actual commit on the given transaction.
+
+ The status representation of the transaction.
+
+
+ An implementation does not need to check the rollback-only flag.
+
+
+
+ In the case of system errors.
+
+
+
+
+ Perform an actual rollback on the given transaction.
+
+ The status representation of the transaction.
+
+ An implementation does not need to check the new transaction flag.
+
+
+ In the case of system errors.
+
+
+
+
+ Set the given transaction rollback-only. Only called on rollback
+ if the current transaction takes part in an existing one.
+
+ The status representation of the transaction.
+
+ In the case of system errors.
+
+
+
+
+ Gets the ADO.NET IDbTransaction object from the NHibernate ITransaction object.
+
+ The hibernate transaction.
+ The ADO.NET transaction. Null if could not get the transaction. Warning
+ messages will be logged in that case.
+
+
+
+ Convert the given HibernateException to an appropriate exception from
+ the Spring.Dao hierarchy. Can be overridden in subclasses.
+
+ The HibernateException that occured.
+ The corresponding DataAccessException instance
+
+
+
+ Convert the given ADOException to an appropriate exception from the
+ the Spring.Dao hierarchy. Can be overridden in subclasses.
+
+ The ADOException that occured, wrapping the underlying
+ ADO.NET thrown exception.
+ The translator to convert hibernate ADOExceptions.
+
+ The corresponding DataAccessException instance
+
+
+
+
+ Cleanup resources after transaction completion.
+
+ Transaction object returned by
+ .
+
+
+ This implemenation unbinds the SessionFactory and
+ DbProvider from thread local storage and closes the
+ ISession.
+
+
+ Called after
+ and
+
+ execution on any outcome.
+
+
+ Should not throw any exceptions but just issue warnings on errors.
+
+
+
+
+
+ Invoked by an
+ after it has injected all of an object's dependencies.
+
+
+
+ This method allows the object instance to perform the kind of
+ initialization only possible when all of it's dependencies have
+ been injected (set), and to throw an appropriate exception in the
+ event of misconfiguration.
+
+
+ Please do consult the class level documentation for the
+ interface for a
+ description of exactly when this method is invoked. In
+ particular, it is worth noting that the
+
+ and
+ callbacks will have been invoked prior to this method being
+ called.
+
+
+
+ In the event of misconfiguration (such as the failure to set a
+ required property) or if initialization fails.
+
+
+
+
+ Gets or sets the db provider.
+
+ The db provider.
+
+
+
+ Gets or sets a Hibernate entity interceptor that allows to inspect and change
+ property values before writing to and reading from the database.
+ When getting, return the current Hibernate entity interceptor, or null if none.
+
+ The entity interceptor.
+
+ Resolves an entity interceptor object name via the object factory,
+ if necessary.
+ Will get applied to any new Session created by this transaction manager.
+ Such an interceptor can either be set at the SessionFactory level,
+ i.e. on LocalSessionFactoryObject, or at the Session level, i.e. on
+ HibernateTemplate, HibernateInterceptor, and HibernateTransactionManager.
+ It's preferable to set it on LocalSessionFactoryObject or HibernateTransactionManager
+ to avoid repeated configuration and guarantee consistent behavior in transactions.
+
+ If object factory is null and need to get entity interceptor via object name.
+
+
+
+ Sets the object name of a Hibernate entity interceptor that
+ allows to inspect and change property values before writing to and reading from the database.
+
+ The name of the entity interceptor object.
+
+ Will get applied to any new Session created by this transaction manager.
+
Requires the object factory to be known, to be able to resolve the object
+ 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.
+
+
+
+
+
+ Gets or sets the ADO.NET exception translator for this transaction manager.
+
+
+ Applied to ADO.NET Exceptions (wrapped by Hibernate's ADOException)
+
+ The ADO exception translator.
+
+
+
+ Gets the default IAdoException translator, lazily creating it if nece
+
+ The default IAdoException translator.
+
+
+
+ Gets or sets the SessionFactory that this instance should manage transactions for.
+
+ The session factory.
+
+
+
+ Gets the resource factory that this transaction manager operates on,
+ For the HibenratePlatformTransactionManager this the SessionFactory
+
+ The SessionFactory.
+
+
+
+ Set whether to autodetect a ADO.NET connection used by the Hibernate SessionFactory,
+ if set via LocalSessionFactoryObject's DbProvider. Default is "true".
+
+
+ true if [autodetect data source]; otherwise, false.
+
+
+
Can be turned off to deliberately ignore an available IDbProvider,
+ to not expose Hibernate transactions as ADO.NET transactions for that IDbProvider.
+
+
+
+
+
+ The object factory just needs to be known for resolving entity interceptor
+ It does not need to be set for any other mode of operation.
+
+
+ Owning
+ (may not be ). The object can immediately
+ call methods on the factory.
+
+
+
+
+ Return whether the transaction is internally marked as rollback-only.
+
+
+ True of the transaction is marked as rollback-only.
+
+
+
+ Helper class that simplifies NHibernate data access code
+
+
+
Typically used to implement data access or business logic services that
+ use NHibernate within their implementation but are Hibernate-agnostic in their
+ interface. The latter or code calling the latter only have to deal with
+ domain objects.
+
+
The central method is Execute supporting Hibernate access code
+ implementing the HibernateCallback interface. It provides NHibernate Session
+ handling such that neither the IHibernateCallback implementation nor the calling
+ code needs to explicitly care about retrieving/closing NHibernate 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 ISessionFactory reference, or get prepared in an application context
+ and given to services as an object reference. Note: The ISessionFactory should
+ always be configured as an object 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.Session).
+
+
+
LocalSessionFactoryObject is the preferred way of obtaining a reference
+ to a specific NHibernate ISessionFactory.
+
+
+ Mark Pollack (.NET)
+
+
+
+ Interface that specifies a basic set of Hibernate operations.
+
+
+ Implemented by HibernateTemplate. Not often used, but a useful option
+ to enhance testability, as it can easily be mocked or stubbed.
+
Provides HibernateTemplate's data access methods that mirror
+ various Session methods. See the NHibernate ISession documentation
+ for details on those methods.
+
+
+
+ Mark Pollack (.NET)
+
+
+
+ Delete all given persistent instances.
+
+ The persistent instances to delete.
+
+ This can be combined with any of the find methods to delete by query
+ in two lines of code, similar to Session's delete by query methods.
+
+ In case of Hibernate errors
+
+
+
+ Execute the action specified by the given action object within a Session.
+
+
+ Application exceptions thrown by the action object get propagated to the
+ caller (can only be unchecked). Hibernate exceptions are transformed into
+ appropriate DAO ones. Allows for returning a result object, i.e. a domain
+ object or a collection of domain objects.
+
Note: Callback code is not supposed to handle transactions itself!
+ Use an appropriate transaction manager like HibernateTransactionManager.
+ Generally, callback code must not touch any Session lifecycle methods,
+ like close, disconnect, or reconnect, to let the template do its work.
+
+
+ The delegate callback object that specifies the Hibernate action.
+ a result object returned by the action, or null
+
+ In case of Hibernate errors
+
+
+
+ Execute the action specified by the given action object within a Session.
+
+
+ Application exceptions thrown by the action object get propagated to the
+ caller (can only be unchecked). Hibernate exceptions are transformed into
+ appropriate DAO ones. Allows for returning a result object, i.e. a domain
+ object or a collection of domain objects.
+
Note: Callback code is not supposed to handle transactions itself!
+ Use an appropriate transaction manager like HibernateTransactionManager.
+ Generally, callback code must not touch any Session lifecycle methods,
+ like close, disconnect, or reconnect, to let the template do its work.
+
+
+ The callback object that specifies the Hibernate action.
+ a result object returned by the action, or null
+
+ In case of Hibernate errors
+
+
+
+ Execute the specified action assuming that the result object is a List.
+
+
+ This is a convenience method for executing Hibernate find calls or
+ queries within an action.
+
+ The calback object that specifies the Hibernate action.
+ A IList returned by the action, or null
+
+ In case of Hibernate errors
+
+
+
+ Execute a query for persistent instances.
+
+ a query expressed in Hibernate's query language
+ a List containing 0 or more persistent instances
+ In case of Hibernate errors
+
+
+
+ Execute a query for persistent instances, binding
+ one value to a "?" parameter in the query string.
+
+ a query expressed in Hibernate's query language
+ the value of the parameter
+ a List containing 0 or more persistent instances
+ In case of Hibernate errors
+
+
+
+ Execute a query for persistent instances, binding one value
+ to a "?" parameter of the given type in the query string.
+
+ a query expressed in Hibernate's query language
+ The value of the parameter.
+ Hibernate type of the parameter (or null)
+ a List containing 0 or more persistent instances
+ In case of Hibernate errors
+
+
+
+ Execute a query for persistent instances, binding a
+ number of values to "?" parameters in the query string.
+
+ a query expressed in Hibernate's query language
+ the values of the parameters
+ a List containing 0 or more persistent instances
+ In case of Hibernate errors
+
+
+
+ Execute a query for persistent instances, binding a number of
+ values to "?" parameters of the given types in the query string.
+
+ A query expressed in Hibernate's query language
+ The values of the parameters
+ Hibernate types of the parameters (or null)
+ a List containing 0 or more persistent instances
+ In case of Hibernate errors
+ If values and types are not null and their lengths are not equal
+
+
+
+ Execute a query for persistent instances, binding
+ one value to a named parameter in the query string.
+
+ The name of a Hibernate query in a mapping file
+ The name of the parameter
+ The value of the parameter
+ a List containing 0 or more persistent instances
+ In case of Hibernate errors
+
+
+
+ Execute a query for persistent instances, binding
+ one value to a named parameter in the query string.
+
+ The name of a Hibernate query in a mapping file
+ The name of the parameter
+ The value of the parameter
+ Hibernate type of the parameter (or null)
+ A List containing 0 or more persistent instances
+ In case of Hibernate errors
+
+
+
+ Execute a query for persistent instances, binding a
+ number of values to named parameters in the query string.
+
+ A query expressed in Hibernate's query language
+ The names of the parameters
+ The values of the parameters
+ A List containing 0 or more persistent instances
+ In case of Hibernate errors
+
+
+
+ Execute a query for persistent instances, binding a
+ number of values to named parameters in the query string.
+
+ A query expressed in Hibernate's query language
+ The names of the parameters
+ The values of the parameters
+ Hibernate types of the parameters (or null)
+ A List containing 0 or more persistent instances
+ In case of Hibernate errors
+ If paramNames length is not equal to values length or
+ if paramNames length is not equal to types length (when types is not null)
+
+
+
+ Execute a named query for persistent instances.
+ A named query is defined in a Hibernate mapping file.
+
+ The name of a Hibernate query in a mapping file
+ A List containing 0 or more persistent instances
+ In case of Hibernate errors
+
+
+
+ Execute a named query for persistent instances, binding
+ one value to a "?" parameter in the query string.
+ A named query is defined in a Hibernate mapping file.
+
+ The name of a Hibernate query in a mapping file
+ The value of the parameter
+ A List containing 0 or more persistent instances
+ In case of Hibernate errors
+
+
+
+ Execute a named query for persistent instances, binding
+ one value to a "?" parameter in the query string.
+ A named query is defined in a Hibernate mapping file.
+
+ The name of a Hibernate query in a mapping file
+ The value of the parameter
+ Hibernate type of the parameter (or null)
+ A List containing 0 or more persistent instances
+ In case of Hibernate errors
+
+
+
+ Execute a named query for persistent instances, binding a
+ number of values to "?" parameters in the query string.
+ A named query is defined in a Hibernate mapping file.
+
+ The name of a Hibernate query in a mapping file
+ The values of the parameters
+ A List containing 0 or more persistent instances
+ In case of Hibernate errors
+
+
+
+ Execute a named query for persistent instances, binding a
+ number of values to "?" parameters in the query string.
+ A named query is defined in a Hibernate mapping file.
+
+ The name of a Hibernate query in a mapping file
+ The values of the parameters
+ Hibernate types of the parameters (or null)
+ A List containing 0 or more persistent instances
+ In case of Hibernate errors
+ If values and types are not null and their lengths differ.
+
+
+
+ Execute a named query for persistent instances, binding
+ one value to a named parameter in the query string.
+ A named query is defined in a Hibernate mapping file.
+
+ The name of a Hibernate query in a mapping file
+ Name of the parameter
+ The value of the parameter
+ A List containing 0 or more persistent instances
+ In case of Hibernate errors
+
+
+
+ Execute a named query for persistent instances, binding
+ one value to a named parameter in the query string.
+ A named query is defined in a Hibernate mapping file.
+
+ The name of a Hibernate query in a mapping file
+ Name of the parameter
+ The value of the parameter
+ The Hibernate type of the parameter (or null)
+ A List containing 0 or more persistent instances
+ In case of Hibernate errors
+
+
+
+ Execute a named query for persistent instances, binding
+ number of values to named parameters in the query string.
+ A named query is defined in a Hibernate mapping file.
+
+ The name of a Hibernate query in a mapping file
+ The names of the parameters
+ The values of the parameters.
+ A List containing 0 or more persistent instances
+ In case of Hibernate errors
+
+
+
+ Execute a named query for persistent instances, binding
+ number of values to named parameters in the query string.
+ A named query is defined in a Hibernate mapping file.
+
+ The name of a Hibernate query in a mapping file
+ The names of the parameters
+ The values of the parameters.
+ Hibernate types of the parameters (or null)
+ A List containing 0 or more persistent instances
+ In case of Hibernate errors
+ If paramNames length is not equal to values length or
+ if paramNames length is not equal to types length (when types is not null)
+
+
+
+ Execute a named query for persistent instances, binding the properties
+ of the given object to named parameters in the query string.
+ A named query is defined in a Hibernate mapping file.
+
+ The name of a Hibernate query in a mapping file
+ The values of the parameters
+ A List containing 0 or more persistent instances
+ In case of Hibernate errors
+
+
+
+ Execute a query for persistent instances, binding the properties
+ of the given object to named parameters in the query string.
+
+ A query expressed in Hibernate's query language
+ The values of the parameters
+ A List containing 0 or more persistent instances
+ In case of Hibernate errors
+
+
+
+ Return the persistent instance of the given entity type
+ with the given identifier, or null if not found.
+
+ a persistent type.
+ An identifier of the persistent instance.
+ the persistent instance, or null if not found
+ In case of Hibernate errors
+
+
+
+ Return the persistent instance of the given entity type
+ with the given identifier, or null if not found.
+ Obtains the specified lock mode if the instance exists.
+
+ A persistent class.
+ An identifier of the persistent instance.
+ The lock mode.
+ the persistent instance, or null if not found
+ the persistent instance, or null if not found
+ In case of Hibernate errors
+
+
+
+ Return the persistent instance of the given entity class
+ with the given identifier, throwing an exception if not found.
+
+ Type of the entity.
+ An identifier of the persistent instance.
+ The persistent instance
+ If not found
+ In case of Hibernate errors
+
+
+
+ Return the persistent instance of the given entity class
+ with the given identifier, throwing an exception if not found.
+ Obtains the specified lock mode if the instance exists.
+
+ Type of the entity.
+ An identifier of the persistent instance.
+ The lock mode.
+ The persistent instance
+ If not found
+ In case of Hibernate errors
+
+
+
+ Return all persistent instances of the given entity class.
+ Note: Use queries or criteria for retrieving a specific subset.
+
+ Type of the entity.
+ A List containing 0 or more persistent instances
+ In case of Hibernate errors
+
+
+
+ Save or update all given persistent instances,
+ according to its id (matching the configured "unsaved-value"?).
+
+ Tthe persistent instances to save or update
+ (to be associated with the Hibernate Session)he entities.
+ In case of Hibernate errors
+
+
+
+ The instance for this class.
+
+
+
+
+ Initializes a new instance of the class.
+
+
+
+
+ Initializes a new instance of the class.
+
+ The default for creating a new non-transactional
+ session when no transactional Session can be found for the current thread
+ is set to true.
+ The session factory to create sessions.
+
+
+
+ Initializes a new instance of the class.
+
+ The session factory to create sessions.
+ if set to true allow creation
+ of a new non-transactional when no transactional Session can be found
+ for the current thread.
+
+
+
+ Delegate function that clears the session.
+
+ The hibernate session.
+ null
+
+
+
+ Flush all pending saves, updates and deletes to the database.
+
+
+ Only invoke this for selective eager flushing, for example when ADO.NET code
+ needs to see certain changes within the same transaction. Else, it's preferable
+ to rely on auto-flushing at transaction completion.
+
+ In case of Hibernate errors
+
+
+
+ Return the persistent instance of the given entity type
+ with the given identifier, or null if not found.
+
+ The type.
+ An identifier of the persistent instance.
+ The persistent instance, or null if not found
+ In case of Hibernate errors
+
+
+
+ Return the persistent instance of the given entity type
+ with the given identifier, or null if not found.
+ Obtains the specified lock mode if the instance exists.
+
+ The type.
+ The lock mode to obtain.
+ The lock mode.
+ the persistent instance, or null if not found
+ the persistent instance, or null if not found
+ In case of Hibernate errors
+
+
+
+ Return the persistent instance of the given entity class
+ with the given identifier, throwing an exception if not found.
+
+ Type of the entity.
+ An identifier of the persistent instance.
+ The persistent instance
+ If not found
+ In case of Hibernate errors
+
+
+
+ Return the persistent instance of the given entity class
+ with the given identifier, throwing an exception if not found.
+ Obtains the specified lock mode if the instance exists.
+
+ Type of the entity.
+ An identifier of the persistent instance.
+ The lock mode.
+ The persistent instance
+ If not found
+ In case of Hibernate errors
+
+
+
+ Load the persistent instance with the given identifier
+ into the given object, throwing an exception if not found.
+
+ Entity the object (of the target class) to load into.
+ An identifier of the persistent instance.
+ If object not found.
+ In case of Hibernate errors
+
+
+
+ Return all persistent instances of the given entity class.
+ Note: Use queries or criteria for retrieving a specific subset.
+
+ Type of the entity.
+ A List containing 0 or more persistent instances
+ In case of Hibernate errors
+
+
+
+ Re-read the state of the given persistent instance.
+
+ The persistent instance to re-read.
+ In case of Hibernate errors
+
+
+
+ Re-read the state of the given persistent instance.
+ Obtains the specified lock mode for the instance.
+
+ The persistent instance to re-read.
+ The lock mode to obtain.
+ In case of Hibernate errors
+
+
+
+ Obtain the specified lock level upon the given object, implicitly
+ checking whether the corresponding database entry still exists
+ (throwing an OptimisticLockingFailureException if not found).
+
+ The he persistent instance to lock.
+ The lock mode to obtain.
+ If not found
+ In case of Hibernate errors
+
+
+
+ Persist the given transient instance.
+
+ The transient instance to persist.
+ The generated identifier.
+ In case of Hibernate errors
+
+
+
+ Persist the given transient instance with the given identifier.
+
+ The transient instance to persist.
+ The identifier to assign.
+ In case of Hibernate errors
+
+
+
+ Update the given persistent instance.
+
+ The persistent instance to update.
+ In case of Hibernate errors
+
+
+
+ Update the given persistent instance.
+ Obtains the specified lock mode if the instance exists, implicitly
+ checking whether the corresponding database entry still exists
+ (throwing an OptimisticLockingFailureException if not found).
+
+ The persistent instance to update.
+ The lock mode to obtain.
+ In case of Hibernate errors
+
+
+
+ Save or update the given persistent instance,
+ according to its id (matching the configured "unsaved-value"?).
+
+ Tthe persistent instance to save or update
+ (to be associated with the Hibernate Session).
+ In case of Hibernate errors
+
+
+
+ Save or update all given persistent instances,
+ according to its id (matching the configured "unsaved-value"?).
+
+ Tthe persistent instances to save or update
+ (to be associated with the Hibernate Session)he entities.
+ In case of Hibernate errors
+
+
+
+ Save or update the contents of given persistent object,
+ according to its id (matching the configured "unsaved-value"?).
+ Will copy the contained fields to an already loaded instance
+ with the same id, if appropriate.
+
+ The persistent object to save or update.
+ (not necessarily to be associated with the Hibernate Session)
+
+ The actually associated persistent object.
+ (either an already loaded instance with the same id, or the given object)
+ In case of Hibernate errors
+
+
+
+ Remove all objects from the Session cache, and cancel all pending saves,
+ updates and deletes.
+
+
+
+
+ Determines whether the given object is in the Session cache.
+
+ the persistence instance to check.
+
+ true if session cache contains the specified entity; otherwise, false.
+
+ In case of Hibernate errors
+
+
+
+ Remove the given object from the Session cache.
+
+ The persistent instance to evict.
+ In case of Hibernate errors
+
+
+
+ Delete the given persistent instance.
+
+ The persistent instance to delete.
+ In case of Hibernate errors
+
+
+
+ Delete the given persistent instance.
+
+ Tthe persistent instance to delete.
+ The lock mode to obtain.
+
+ Obtains the specified lock mode if the instance exists, implicitly
+ checking whether the corresponding database entry still exists
+ (throwing an OptimisticLockingFailureException if not found).
+
+ In case of Hibernate errors
+
+
+
+ Delete all objects returned by the query.
+
+ a query expressed in Hibernate's query language.
+ The number of entity instances deleted.
+ In case of Hibernate errors
+
+
+
+ Delete all objects returned by the query.
+
+ a query expressed in Hibernate's query language.
+ The value of the parameter.
+ The Hibernate type of the parameter (or null).
+ The number of entity instances deleted.
+ In case of Hibernate errors
+
+
+
+ Delete all objects returned by the query.
+
+ a query expressed in Hibernate's query language.
+ The values of the parameters.
+ Hibernate types of the parameters (or null)
+ The number of entity instances deleted.
+ In case of Hibernate errors
+ If length for argument values and types are not equal.
+
+
+
+ Delete all given persistent instances.
+
+ The persistent instances to delete.
+
+ This can be combined with any of the find methods to delete by query
+ in two lines of code, similar to Session's delete by query methods.
+
+ In case of Hibernate errors
+
+
+
+ Execute the action specified by the given action object within a Session.
+
+
+ Application exceptions thrown by the action object get propagated to the
+ caller (can only be unchecked). Hibernate exceptions are transformed into
+ appropriate DAO ones. Allows for returning a result object, i.e. a domain
+ object or a collection of domain objects.
+
Note: Callback code is not supposed to handle transactions itself!
+ Use an appropriate transaction manager like HibernateTransactionManager.
+ Generally, callback code must not touch any Session lifecycle methods,
+ like close, disconnect, or reconnect, to let the template do its work.
+
+
+ The delegate callback object that specifies the Hibernate action.
+ a result object returned by the action, or null
+
+ In case of Hibernate errors
+
+
+
+ Execute the action specified by the delegate within a Session.
+
+ The HibernateDelegate that specifies the action
+ to perform.
+ if set to true expose the native hibernate session to
+ callback code.
+ a result object returned by the action, or null
+
+
+
+
+ Execute the action specified by the given action object within a Session.
+
+ The callback object that specifies the Hibernate action.
+
+ a result object returned by the action, or null
+
+
+ Application exceptions thrown by the action object get propagated to the
+ caller (can only be unchecked). Hibernate exceptions are transformed into
+ appropriate DAO ones. Allows for returning a result object, i.e. a domain
+ object or a collection of domain objects.
+
Note: Callback code is not supposed to handle transactions itself!
+ Use an appropriate transaction manager like HibernateTransactionManager.
+ Generally, callback code must not touch any Session lifecycle methods,
+ like close, disconnect, or reconnect, to let the template do its work.
+
+
+ In case of Hibernate errors
+
+
+
+ Execute the specified action assuming that the result object is a List.
+
+
+ This is a convenience method for executing Hibernate find calls or
+ queries within an action.
+
+ The calback object that specifies the Hibernate action.
+ A IList returned by the action, or null
+
+ In case of Hibernate errors
+
+
+
+ Execute the action specified by the given action object within a Session.
+
+ callback object that specifies the Hibernate action.
+ if set to true expose the native hibernate session to
+ callback code.
+
+ a result object returned by the action, or null
+
+
+
+
+ Execute a query for persistent instances.
+
+ a query expressed in Hibernate's query language
+
+ a List containing 0 or more persistent instances
+
+ In case of Hibernate errors
+
+
+
+ Execute a query for persistent instances, binding
+ one value to a "?" parameter in the query string.
+
+ a query expressed in Hibernate's query language
+ the value of the parameter
+
+ a List containing 0 or more persistent instances
+
+ In case of Hibernate errors
+
+
+
+ Execute a query for persistent instances, binding one value
+ to a "?" parameter of the given type in the query string.
+
+ a query expressed in Hibernate's query language
+ The value of the parameter.
+ Hibernate type of the parameter (or null)
+
+ a List containing 0 or more persistent instances
+
+ In case of Hibernate errors
+
+
+
+ Execute a query for persistent instances, binding a
+ number of values to "?" parameters in the query string.
+
+ a query expressed in Hibernate's query language
+ the values of the parameters
+ a List containing 0 or more persistent instances
+ In case of Hibernate errors
+
+
+
+ Execute a query for persistent instances, binding a number of
+ values to "?" parameters of the given types in the query string.
+
+ A query expressed in Hibernate's query language
+ The values of the parameters
+ Hibernate types of the parameters (or null)
+
+ a List containing 0 or more persistent instances
+
+ In case of Hibernate errors
+ If values and types are not null and their lengths are not equal
+
+
+
+ Execute a query for persistent instances, binding
+ one value to a named parameter in the query string.
+
+ The name of a Hibernate query in a mapping file
+ The name of the parameter
+ The value of the parameter
+ a List containing 0 or more persistent instances
+ In case of Hibernate errors
+
+
+
+ Execute a query for persistent instances, binding
+ one value to a named parameter in the query string.
+
+ The name of a Hibernate query in a mapping file
+ The name of the parameter
+ The value of the parameter
+ Hibernate type of the parameter (or null)
+ A List containing 0 or more persistent instances
+ In case of Hibernate errors
+
+
+
+ Execute a query for persistent instances, binding a
+ number of values to named parameters in the query string.
+
+ A query expressed in Hibernate's query language
+ The names of the parameters
+ The values of the parameters
+ A List containing 0 or more persistent instances
+ In case of Hibernate errors
+
+
+
+ Execute a query for persistent instances, binding a
+ number of values to named parameters in the query string.
+
+ A query expressed in Hibernate's query language
+ The names of the parameters
+ The values of the parameters
+ Hibernate types of the parameters (or null)
+ A List containing 0 or more persistent instances
+ In case of Hibernate errors
+ If paramNames length is not equal to values length or
+ if paramNames length is not equal to types length (when types is not null)
+
+
+
+ Execute a named query for persistent instances.
+ A named query is defined in a Hibernate mapping file.
+
+ The name of a Hibernate query in a mapping file
+ A List containing 0 or more persistent instances
+ In case of Hibernate errors
+
+
+
+ Execute a named query for persistent instances, binding
+ one value to a "?" parameter in the query string.
+ A named query is defined in a Hibernate mapping file.
+
+ The name of a Hibernate query in a mapping file
+ The value of the parameter
+ A List containing 0 or more persistent instances
+ In case of Hibernate errors
+
+
+
+ Execute a named query for persistent instances, binding
+ one value to a "?" parameter in the query string.
+ A named query is defined in a Hibernate mapping file.
+
+ The name of a Hibernate query in a mapping file
+ The value of the parameter
+ Hibernate type of the parameter (or null)
+ A List containing 0 or more persistent instances
+ In case of Hibernate errors
+
+
+
+ Execute a named query for persistent instances, binding a
+ number of values to "?" parameters in the query string.
+ A named query is defined in a Hibernate mapping file.
+
+ The name of a Hibernate query in a mapping file
+ The values of the parameters
+ A List containing 0 or more persistent instances
+ In case of Hibernate errors
+
+
+
+ Execute a named query for persistent instances, binding a
+ number of values to "?" parameters in the query string.
+ A named query is defined in a Hibernate mapping file.
+
+ The name of a Hibernate query in a mapping file
+ The values of the parameters
+ Hibernate types of the parameters (or null)
+ A List containing 0 or more persistent instances
+ In case of Hibernate errors
+ If values and types are not null and their lengths differ.
+
+
+
+ Execute a named query for persistent instances, binding
+ one value to a named parameter in the query string.
+ A named query is defined in a Hibernate mapping file.
+
+ The name of a Hibernate query in a mapping file
+ Name of the parameter
+ The value of the parameter
+ A List containing 0 or more persistent instances
+ In case of Hibernate errors
+
+
+
+ Execute a named query for persistent instances, binding
+ one value to a named parameter in the query string.
+ A named query is defined in a Hibernate mapping file.
+
+ The name of a Hibernate query in a mapping file
+ Name of the parameter
+ The value of the parameter
+ The Hibernate type of the parameter (or null)
+ A List containing 0 or more persistent instances
+
+
+
+ Execute a named query for persistent instances, binding
+ number of values to named parameters in the query string.
+ A named query is defined in a Hibernate mapping file.
+
+ The name of a Hibernate query in a mapping file
+ The names of the parameters
+ The values of the parameters.
+ A List containing 0 or more persistent instances
+ In case of Hibernate errors
+
+
+
+ Execute a named query for persistent instances, binding
+ number of values to named parameters in the query string.
+ A named query is defined in a Hibernate mapping file.
+
+ The name of a Hibernate query in a mapping file
+ The names of the parameters
+ The values of the parameters.
+ Hibernate types of the parameters (or null)
+ A List containing 0 or more persistent instances
+ In case of Hibernate errors
+ If paramNames length is not equal to values length or
+ if paramNames length is not equal to types length (when types is not null)
+
+
+
+ Execute a named query for persistent instances, binding the properties
+ of the given object to named parameters in the query string.
+ A named query is defined in a Hibernate mapping file.
+
+ The name of a Hibernate query in a mapping file
+ The values of the parameters
+ A List containing 0 or more persistent instances
+ In case of Hibernate errors
+
+
+
+ Execute a query for persistent instances, binding the properties
+ of the given object to named parameters in the query string.
+
+ A query expressed in Hibernate's query language
+ The values of the parameters
+ A List containing 0 or more persistent instances
+ In case of Hibernate errors
+
+
+
+ Create a close-suppressing proxy for the given Hibernate Session.
+ The proxy also prepares returned Query and Criteria objects.
+
+ The session.
+ The session proxy.
+
+
+
+ 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.
+
+ The current Hibernate session.
+ If write operation is attempted in read-only mode
+
+
+
+
+ Compares if the flush mode enumerations, Spring's
+ TemplateFlushMode and NHibernates FlushMode have equal
+ settings.
+
+ The template flush mode.
+ The NHibernate flush mode.
+
+ Returns true if both are Never, Auto, or Commit, false
+ otherwise.
+
+
+
+
+ Gets or sets if a new Session should be created when no transactional Session
+ can be found for the current thread.
+
+
+ true if allowed to create non-transaction session;
+ otherwise, false.
+
+
+
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 InvalidOperationException will get thrown in this case.
+
+
+
+
+
+ Gets or sets a value indicating whether to always
+ use a new Hibernate Session for this template.
+
+ true if always use new session; otherwise, false.
+
+
+ Default is "false"; if activated, all operations on this template will
+ work on a new NHibernate ISession even in case of a pre-bound ISession
+ (for example, within a transaction).
+
+
Within a transaction, a new NHibernate ISession used by this template
+ will participate in the transaction through using the same ADO.NET
+ 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 NHibernate ISession.
+
+
+
+
+
+ Gets or sets the template flush mode.
+
+
+ Default is Auto. Will get applied to any new ISession
+ created by the template.
+
+ The template flush mode.
+
+
+
+ Gets or sets the entity interceptor that allows to inspect and change
+ property values before writing to and reading from the database.
+
+
+ Will get applied to any new ISession created by this object.
+
Such an interceptor can either be set at the ISessionFactory level,
+ i.e. on LocalSessionFactoryObject, or at the ISession level, i.e. on
+ HibernateTemplate, HibernateInterceptor, and HibernateTransactionManager.
+ It's preferable to set it on LocalSessionFactoryObject or HibernateTransactionManager
+ to avoid repeated configuration and guarantee consistent behavior in transactions.
+
+
+ The interceptor.
+ If object factory is not set and need to retrieve entity interceptor by name.
+
+
+
+ Gets or sets the name of the cache region for queries executed by this template.
+
+
+ If this is specified, it will be applied to all IQuery and ICriteria 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.
+
+
+ The query cache region.
+
+
+
+ Gets or sets a value indicating whether to
+ cache all queries executed by this template.
+
+
+ If this is true, all IQuery and ICriteria 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.
+
+
+ true if cache queries; otherwise, false.
+
+
+
+ Gets or sets the maximum number of rows for this HibernateTemplate.
+
+ The max results.
+
+ 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 ADO.NET 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 driver's default.
+
+
+
+
+ Set whether to expose the native Hibernate Session to IHibernateCallback
+ code. Default is "false": a Session proxy will be returned,
+ suppressing close calls and automatically applying
+ query cache settings and transaction timeouts.
+
+ true if expose native session; otherwise, false.
+
+
+
+ Gets or sets whether to check that the Hibernate Session is not in read-only mode
+ in case of write operations (save/update/delete).
+
+
+ true if check that the Hibernate Session is not in read-only mode
+ in case of write operations; otherwise, false.
+
+
+ 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.
+
+
+
+
+ Set the object 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 object factory to be known, to be able to resolve the object
+ 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.
+
+
+ The name of the entity interceptor in the object factory/application context.
+
+
+
+ Set the object factory instance.
+
+ The object factory instance
+
+
+
+ Gets or sets the session factory that should be used to create
+ NHibernate ISessions.
+
+ The session factory.
+
+
+
+ Gets or sets the fetch size for this HibernateTemplate.
+
+ The size of the fetch.
+ 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 driver's default.
+
+
+
+
+ Gets or sets the proxy factory.
+
+ This may be useful to set if you create many instances of
+ HibernateTemplate and/or HibernateDaoSupport. This allows the same
+ ProxyFactory implementation to be used thereby limiting the
+ number of dynamic proxy types created in the temporary assembly, which
+ are never garbage collected due to .NET runtime semantics.
+
+ The proxy factory.
+
+
+
+ Set the ADO.NET exception translator for this instance.
+ Applied to System.Data.Common.DbException (or provider specific exception type
+ in .NET 1.1) thrown by callback code, be it direct
+ DbException or wrapped Hibernate ADOExceptions.
+
The default exception translator is either a ErrorCodeExceptionTranslator
+ if a DbProvider is available, or a FalbackExceptionTranslator otherwise
+
+
+ The ADO exception translator.
+
+
+
+ Callback interface for NHibernate code.
+
+ To be used with HibernateTemplate execute
+ method. The typical implementation will call
+ Session.load/find/save/update to perform
+ some operations on persistent objects.
+
+ Mark Pollack (.NET)
+
+
+
+ Gets called by HibernateTemplate with an active
+ Hibernate Session. Does not need to care about activating or closing
+ the Session, or handling transactions.
+
+
+
+ Allows for returning a result object created within the callback, i.e.
+ a domain object or a collection of domain objects. Note that there's
+ special support for single step actions: see HibernateTemplate.find etc.
+
+
+ A result object, or null if none.
+
+
+
+ Gets called by HibernateTemplate with an active
+ Hibernate Session. Does not need to care about activating or closing
+ the Session, or handling transactions.
+
+
+
+ Allows for returning a result object created within the callback, i.e.
+ a domain object or a collection of domain objects. Note that there's
+ special support for single step actions: see HibernateTemplate.find etc.
+
+
+
+
+
+ Gets called by HibernateTemplate with an active
+ Hibernate Session. Does not need to care about activating or closing
+ the Session, or handling transactions.
+
+
+
+ Allows for returning a result object created within the callback, i.e.
+ a domain object or a collection of domain objects. Note that there's
+ special support for single step actions: see HibernateTemplate.find etc.
+
+
+
+
+
+ Gets called by HibernateTemplate with an active
+ Hibernate Session. Does not need to care about activating or closing
+ the Session, or handling transactions.
+
+
+
+ Allows for returning a result object created within the callback, i.e.
+ a domain object or a collection of domain objects. Note that there's
+ special support for single step actions: see HibernateTemplate.find etc.
+
+
+
+
+
+ Gets called by HibernateTemplate with an active
+ Hibernate Session. Does not need to care about activating or closing
+ the Session, or handling transactions.
+
+
+
+ Allows for returning a result object created within the callback, i.e.
+ a domain object or a collection of domain objects. Note that there's
+ special support for single step actions: see HibernateTemplate.find etc.
+
+
+
+
+
+ Gets called by HibernateTemplate with an active
+ Hibernate Session. Does not need to care about activating or closing
+ the Session, or handling transactions.
+
+
+
+ Allows for returning a result object created within the callback, i.e.
+ a domain object or a collection of domain objects. Note that there's
+ special support for single step actions: see HibernateTemplate.find etc.
+
+
+
+
+
+ Gets called by HibernateTemplate with an active
+ Hibernate Session. Does not need to care about activating or closing
+ the Session, or handling transactions.
+
+
+
+ Allows for returning a result object created within the callback, i.e.
+ a domain object or a collection of domain objects. Note that there's
+ special support for single step actions: see HibernateTemplate.find etc.
+
+
+
+
+
+ Gets called by HibernateTemplate with an active
+ Hibernate Session. Does not need to care about activating or closing
+ the Session, or handling transactions.
+
+
+
+ Allows for returning a result object created within the callback, i.e.
+ a domain object or a collection of domain objects. Note that there's
+ special support for single step actions: see HibernateTemplate.find etc.
+
+
+
+
+
+ Gets called by HibernateTemplate with an active
+ Hibernate Session. Does not need to care about activating or closing
+ the Session, or handling transactions.
+
+
+
+ Allows for returning a result object created within the callback, i.e.
+ a domain object or a collection of domain objects. Note that there's
+ special support for single step actions: see HibernateTemplate.find etc.
+
+
+
+
+
+ Gets called by HibernateTemplate with an active
+ Hibernate Session. Does not need to care about activating or closing
+ the Session, or handling transactions.
+
+
+
+ Allows for returning a result object created within the callback, i.e.
+ a domain object or a collection of domain objects. Note that there's
+ special support for single step actions: see HibernateTemplate.find etc.
+
+
+
+
+
+ Gets called by HibernateTemplate with an active
+ Hibernate Session. Does not need to care about activating or closing
+ the Session, or handling transactions.
+
+
+
+ Allows for returning a result object created within the callback, i.e.
+ a domain object or a collection of domain objects. Note that there's
+ special support for single step actions: see HibernateTemplate.find etc.
+
+
+
+
+
+ Gets called by HibernateTemplate with an active
+ Hibernate Session. Does not need to care about activating or closing
+ the Session, or handling transactions.
+
+
+
+ Allows for returning a result object created within the callback, i.e.
+ a domain object or a collection of domain objects. Note that there's
+ special support for single step actions: see HibernateTemplate.find etc.
+
+
+
+
+
+ Gets called by HibernateTemplate with an active
+ Hibernate Session. Does not need to care about activating or closing
+ the Session, or handling transactions.
+
+
+
+ Allows for returning a result object created within the callback, i.e.
+ a domain object or a collection of domain objects. Note that there's
+ special support for single step actions: see HibernateTemplate.find etc.
+
+
+
+
+
+ Gets called by HibernateTemplate with an active
+ Hibernate Session. Does not need to care about activating or closing
+ the Session, or handling transactions.
+
+
+
+ Allows for returning a result object created within the callback, i.e.
+ a domain object or a collection of domain objects. Note that there's
+ special support for single step actions: see HibernateTemplate.find etc.
+
+
+
+
+
+ Gets called by HibernateTemplate with an active
+ Hibernate Session. Does not need to care about activating or closing
+ the Session, or handling transactions.
+
+
+
+ Allows for returning a result object created within the callback, i.e.
+ a domain object or a collection of domain objects. Note that there's
+ special support for single step actions: see HibernateTemplate.find etc.
+
+
+
+
+
+ Gets called by HibernateTemplate with an active
+ Hibernate Session. Does not need to care about activating or closing
+ the Session, or handling transactions.
+
+
+
+ Allows for returning a result object created within the callback, i.e.
+ a domain object or a collection of domain objects. Note that there's
+ special support for single step actions: see HibernateTemplate.find etc.
+
+
+
+
+
+ Gets called by HibernateTemplate with an active
+ Hibernate Session. Does not need to care about activating or closing
+ the Session, or handling transactions.
+
+
+
+ Allows for returning a result object created within the callback, i.e.
+ a domain object or a collection of domain objects. Note that there's
+ special support for single step actions: see HibernateTemplate.find etc.
+
+
+
+
+
+ Gets called by HibernateTemplate with an active
+ Hibernate Session. Does not need to care about activating or closing
+ the Session, or handling transactions.
+
+
+
+ Allows for returning a result object created within the callback, i.e.
+ a domain object or a collection of domain objects. Note that there's
+ special support for single step actions: see HibernateTemplate.find etc.
+
+
+
+
+
+ Gets called by HibernateTemplate with an active
+ Hibernate Session. Does not need to care about activating or closing
+ the Session, or handling transactions.
+
+
+
+ Allows for returning a result object created within the callback, i.e.
+ a domain object or a collection of domain objects. Note that there's
+ special support for single step actions: see HibernateTemplate.find etc.
+
+
+
+
+
+ Gets called by HibernateTemplate with an active
+ Hibernate Session. Does not need to care about activating or closing
+ the Session, or handling transactions.
+
+
+
+ Allows for returning a result object created within the callback, i.e.
+ a domain object or a collection of domain objects. Note that there's
+ special support for single step actions: see HibernateTemplate.find etc.
+
+
+
+
+
+ Gets called by HibernateTemplate with an active
+ Hibernate Session. Does not need to care about activating or closing
+ the Session, or handling transactions.
+
+
+
+ Allows for returning a result object created within the callback, i.e.
+ a domain object or a collection of domain objects. Note that there's
+ special support for single step actions: see HibernateTemplate.find etc.
+
+
+
+
+
+ Hibernate-specific subclass of UncategorizedDataAccessException,
+ for ADO.NET exceptions that Hibernate rethrew and could not be
+ mapped into the DAO exception heirarchy.
+
+ Mark Pollack (.NET)
+
+
+
+ Initializes a new instance of the class.
+
+
+
+
+ Creates a new instance of the
+ class.
+
+
+ A message about the exception.
+
+
+
+
+ Creates a new instance of the
+ class.
+
+
+ A message about the exception.
+
+
+ The root exception from the underlying data access API - ADO.NET
+
+
+
+
+ Creates a new instance of the
+ class.
+
+
+ The
+ that holds the serialized object data about the exception being thrown.
+
+
+ The
+ that contains contextual information about the source or destination.
+
+
+
+
+ Gets called by HibernateTemplate with an active
+ Hibernate Session. Does not need to care about activating or closing
+ the Session, or handling transactions.
+
+
+
+ Allows for returning the result object created within the callback.
+ Note that there's special support for single step actions:
+ see HibernateTemplate.find etc.
+
+
+ The type of result object
+ Sree Nivask (.NET)
+
+
+
+ Convenient super class for Hibernate data access objects.
+
+
+ Requires a SessionFactory to be set, providing a HibernateTemplate
+ based on it to subclasses. Can alternatively be initialized directly with
+ a HibernateTemplate, to reuse the latter's settings such as the SessionFactory,
+ exception translator, flush mode, etc
+
+ This base call is mainly intended for HibernateTemplate usage.
+
+ This class will create its own HibernateTemplate if only a SessionFactory
+ is passed in. The "allowCreate" flag on that HibernateTemplate will be "true"
+ by default. A custom HibernateTemplate instance can be used through overriding
+ CreateHibernateTemplate.
+
+
+ Sree Nivask (.NET)
+ Mark Pollack (.NET)
+
+
+
+ Initializes a new instance of the class.
+
+
+
+
+ Create a HibernateTemplate for the given ISessionFactory.
+
+
+ Only invoked if populating the DAO with a ISessionFactory reference!
+
Can be overridden in subclasses to provide a HibernateTemplate instance
+ with different configuration, or a custom HibernateTemplate subclass.
+
+
+ The new HibernateTemplate instance
+
+
+
+ Check if the hibernate template property has been set.
+
+ If HibernateTemplate property is null.
+
+
+
+ Get a Hibernate Session, either from the current transaction or
+ a new one. The latter is only allowed if "allowCreate" is true.
+
+ Note that this is not meant to be invoked from HibernateTemplate code
+ but rather just in plain Hibernate code. Either rely on a thread-bound
+ Session (via HibernateInterceptor), or use it in combination with
+ ReleaseSession.
+
+ In general, it is recommended to use HibernateTemplate, either with
+ the provided convenience operations or with a custom HibernateCallback
+ that provides you with a Session to work on. HibernateTemplate will care
+ for all resource management and for proper exception conversion.
+
+
+ if a non-transactional Session should be created when no
+ transactional Session can be found for the current thread
+
+ Hibernate session.
+
+ If the Session couldn't be created
+
+
+ if no thread-bound Session found and allowCreate false
+
+
+
+
+
+ Convert the given HibernateException to an appropriate exception from the
+ org.springframework.dao hierarchy. Will automatically detect
+ wrapped ADO.NET Exceptions and convert them accordingly.
+
+ HibernateException that occured.
+
+ The corresponding DataAccessException instance
+
+
+ The default implementation delegates to SessionFactoryUtils
+ and convertAdoAccessException. Can be overridden in subclasses.
+
+
+
+
+ Close the given Hibernate Session, created via this DAO's SessionFactory,
+ if it isn't bound to the thread.
+
+
+ Typically used in plain Hibernate code, in combination with the
+ Session property and ConvertHibernateAccessException.
+
+ The session to close.
+
+
+
+ Gets or sets the hibernate template.
+
+ Set the HibernateTemplate for this DAO explicitly,
+ as an alternative to specifying a SessionFactory.
+
+ The hibernate template.
+
+
+
+ Gets or sets the session factory to be used by this DAO.
+ Will automatically create a HibernateTemplate for the given SessionFactory.
+
+ The session factory.
+
+
+
+ Get a Hibernate Session, either from the current transaction or a new one.
+ The latter is only allowed if the "allowCreate" setting of this object's
+ HibernateTemplate is true.
+
+
+
Note that this is not meant to be invoked from HibernateTemplate code
+ but rather just in plain Hibernate code. Use it in combination with
+ ReleaseSession.
+
+
In general, it is recommended to use HibernateTemplate, either with
+ the provided convenience operations or with a custom HibernateCallback
+ that provides you with a Session to work on. HibernateTemplate will care
+ for all resource management and for proper exception conversion.
+
+
+ The Hibernate session.
+
+
+
+ Hibernate-specific subclass of ObjectOptimisticLockingFailureException.
+
+
+ Converts Hibernate's StaleObjectStateException.
+
+ Mark Pollack (.NET)
+ $Id: HibernateOptimisticLockingFailureException.cs,v 1.2 2008/04/23 11:41:41 lahma Exp $
+
+
+
+
+ Initializes a new instance of the class.
+
+
+
+
+ Initializes a new instance of the class.
+
+ The ex.
+
+
+
+ Initializes a new instance of the class.
+
+ The StaleStateException.
+
+
+
+ Creates a new instance of the
+ class.
+
+
+ The
+ that holds the serialized object data about the exception being thrown.
+
+
+ The
+ that contains contextual information about the source or destination.
+
+
+
+
+ Enumeration for the various Hibernate flush modes.
+
+ Mark Pollack (.NET)
+
+
+ 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 ISession, TemplateFlushMode.Never will turn
+ the hibenrate flush mode
+ to FlushMode.Never for the scope of the current operation, resetting the previous
+ flush mode afterwards.
+
+
+
+
+ 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, TemplateFlushMode.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
+ hibernate flush mode FlushMode.Never, in contrast to TemplateFlushMode.Eager.
+
+
+
+
+
+ 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 ADO 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, TemplateFlushMode.Eager
+ will turn the NHibernate flush mode
+ to FlushMode.Auto for the scope of the current operation and issue a flush at the
+ end, resetting the previous flush mode afterwards.
+
+
+
+
+
+ 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, TemplateFlushMode.Commit
+ will turn the NHibernate flush mode
+ to FlushMode.Commit for the scope of the current operation, resetting the previous
+ flush mode afterwards. The only exception is an existing flush mode
+ FlushMode.Never, which will not be modified through this setting.
+
+
+
+
+
+ Holds the references and configuration settings for a instance.
+
+
+
+
+ Default value for property.
+
+
+
+
+ Default value for property.
+
+
+
+
+ Initialize a new instance of with default values.
+
+
+ Calling this constructor from your derived class leaves and
+ uninitialized. See and for more.
+
+
+
+
+ Initialize a new instance of with the given sessionFactory
+ and default values for all other settings.
+
+
+ The instance to be used for obtaining instances.
+
+
+ Calling this constructor marks all properties initialized.
+
+
+
+
+ Initialize a new instance of with the given values and references.
+
+
+ The instance to be used for obtaining instances.
+
+
+ Specify the to be set on each session provided by the instance.
+
+
+ Set whether to use a single session for each request. See property for details.
+
+
+ Specify the flushmode to be applied on each session provided by the instance.
+
+
+ Calling this constructor marks all properties initialized.
+
+
+
+
+ Override this method to resolve an instance according to your chosen strategy.
+
+
+
+
+ Override this method to resolve an instance according to your chosen strategy.
+
+
+
+
+ Gets the configured instance to be used.
+
+
+ If the entity interceptor is not set by the constructor, this property calls
+ to obtain an instance. This allows derived classes to
+ override the behaviour of how to obtain the concrete instance.
+
+
+
+
+ Gets the configured instance to be used.
+
+
+ If this property is requested for the first time, is called.
+ This allows derived classes to override the behaviour of how to obtain the concrete instance.
+
+ If the instance cannot be resolved.
+
+
+
+ Set whether to use a single session for each request. Default is "true".
+ If set to false, each data access operation or transaction will use
+ its own session (like without Open Session in View). Each of those
+ sessions will be registered for deferred close, though, actually
+ processed at request completion.
+
+
+
+
+ Gets or Sets the flushmode to be applied on each newly created session.
+
+
+ This property defaults to to ensure that modifying objects outside the boundaries
+ of a transaction will not be persisted. It is recommended to not change this value but wrap any modifying operation
+ within a transaction.
+
+
+
+
+ Implementation of SessionScope that associates a single session within the using scope.
+
+
+ It is recommended to be used in the following type of scenario:
+
+ using (new SessionScope())
+ {
+ ... do multiple operation, possibly in multiple transactions.
+ }
+
+ At the end of "using", the session is automatically closed. All transactions within the scope use the same session,
+ if you are using Spring's HibernateTemplate or using Spring's implementation of NHibernate 1.2's
+ ICurrentSessionContext interface.
+
+
+ It is assumed that the session factory object name is called "SessionFactory". In case that you named the object
+ in different way you can specify your can specify it in the application settings using the key
+ Spring.Data.NHibernate.Support.SessionScope.SessionFactoryObjectName. Values for EntityInterceptorObjectName
+ and SingleSessionMode can be specified similarly.
+
+
+ Note:
+ The session is managed on a per thread basis on the thread that opens the scope instance. This means that you must
+ never pass a reference to a instance over to another thread!
+
+
+ Robert M. (.NET)
+ Harald Radi (.NET)
+
+
+
+ The logging instance.
+
+
+
+
+ Initializes a new instance of the class in single session mode,
+ associating a session with the thread. The session is opened lazily on demand.
+
+
+
+
+ Initializes a new instance of the class.
+
+
+ If set to true associate a session with the thread. If false, another
+ collaborating class will associate the session with the thread, potentially by calling
+ the Open method on this class.
+
+
+
+
+ Initializes a new instance of the class.
+
+
+ The name of the configuration section to read configuration settings from.
+ See for more info.
+
+
+ If set to true associate a session with the thread. If false, another
+ collaborating class will associate the session with the thread, potentially by calling
+ the Open method on this class.
+
+
+
+
+ Initializes a new instance of the class.
+
+
+ The name of the configuration section to read configuration settings from.
+ See for more info.
+
+ The type, who's full name is used for prefixing appSetting keys
+
+ If set to true associate a session with the thread. If false, another
+ collaborating class will associate the session with the thread, potentially by calling
+ the Open method on this class.
+
+
+
+
+ Initializes a new instance of the class.
+
+
+ The instance to be used for obtaining instances.
+
+
+ If set to true associate a session with the thread. If false, another
+ collaborating class will associate the session with the thread, potentially by calling
+ the Open method on this class.
+
+
+
+
+ Initializes a new instance of the class.
+
+
+ The instance to be used for obtaining instances.
+
+
+ Specify the to be set on each session provided by this instance.
+
+
+ Set whether to use a single session for each request. See property for details.
+
+
+ Specify the flushmode to be applied on each session provided by this instance.
+
+
+ If set to true associate a session with the thread. If false, another
+ collaborating class will associate the session with the thread, potentially by calling
+ the Open method on this class.
+
+
+
+
+ Initializes a new instance of the class.
+
+ An instance holding the scope configuration
+
+ If set to true associate a session with the thread. If false, another
+ collaborating class will associate the session with the thread, potentially by calling
+ the Open method on this class.
+
+
+
+
+ Sets a flag, whether this scope is in "open" state on the current logical thread.
+
+
+
+
+ Gets/Sets a flag, whether this scope manages it's own session for the current logical thread or not.
+
+ false if session is managed by this module. false otherwise
+
+
+
+ Call Close(),
+
+
+
+
+ Opens a new session or participates in an existing session and
+ registers with spring's .
+
+
+
+
+ Close the current view's session and unregisters
+ from spring's .
+
+
+
+
+ Set whether to use a single session for each request. Default is "true".
+ If set to false, each data access operation or transaction will use
+ its own session (like without Open Session in View). Each of those
+ sessions will be registered for deferred close, though, actually
+ processed at request completion.
+
+
+
+
+ Gets the flushmode to be applied on each newly created session.
+
+
+ This property defaults to to ensure that modifying objects outside the boundaries
+ of a transaction will not be persisted. It is recommended to not change this value but wrap any modifying operation
+ within a transaction.
+
+
+
+
+ Get or set the configured SessionFactory
+
+
+
+
+ Get or set the configured EntityInterceptor
+
+
+
+
+ Gets a flag, whether this scope is in "open" state on the current logical thread.
+
+
+
+
+ Gets a flag, whether this scope manages it's own session for the current logical thread or not.
+
+
+
+
+ This sessionHolder creates a default session only if it is needed.
+
+
+ Although a NHibernateSession deferes creation of db-connections until they are really
+ needed, instantiation a session is imho still more expensive than this LazySessionHolder. (EE)
+
+
+
+
+ Session holder, wrapping a NHibernate ISession and a NHibernate Transaction.
+ HibernateTransactionManager binds instances of this class
+ to the thread, for a given ISessionFactory.
+
+
+ Note: This is an SPI class, not intended to be used by applications.
+
+ Mark Pollack (.NET)
+
+
+
+ May be used by derived classes to create an empty SessionHolder.
+
+
+ When using this ctor in your derived class, you MUST override !
+
+
+
+
+ Initializes a new instance of the class.
+
+ The session.
+
+
+
+ Initializes a new instance of the class.
+
+ The key to store the session under.
+ The hibernate session.
+
+
+
+ May be overridden in a derived class to e.g. lazily create a session
+
+
+
+
+ Gets the session given key identifier
+
+ The key.
+ A hibernate session
+
+
+
+ Gets the session given the key and removes the session from
+ the dictionary storage.
+
+ The key.
+ A hibernate session
+
+
+
+ Adds the session to the dictionary storage using the default key.
+
+ The hibernate session.
+
+
+
+ Adds the session to the dictionary storage using the supplied key.
+
+ The key.
+ The hibernate session.
+
+
+
+ Removes the session from the dictionary storage for the given key.
+
+ The key.
+ The session that was previously contained in the
+ dictionary storage.
+
+
+
+ Determines whether the holder the specified session.
+
+ The session.
+
+ true if the holder contains the specified session; otherwise, false.
+
+
+
+
+ Clear the transaction state of this resource holder.
+
+
+
+
+ Gets the session using the default key
+
+ The hibernate session.
+
+
+
+ Gets the first session based on iteration over
+ the IDictionary storage.
+
+ Any hibernate session.
+
+
+
+ Gets a value indicating whether dictionary of
+ hibernate sessions is empty.
+
+
+ true if this session holder is empty; otherwise, false.
+
+
+
+
+ Gets a value indicating whether this SessionHolder
+ does not hold non default session.
+
+
+ true if does not hold non default session; otherwise, false.
+
+
+
+
+ Gets or sets the hibernate transaction.
+
+ The transaction.
+
+
+
+ Gets or sets the ADO.NET Connection used to create the session.
+
+ The ADO.NET connection.
+
+
+
+ Gets or sets the previous flush mode.
+
+ The previous flush mode.
+
+
+
+ Gets a value indicating whether the PreviousFlushMode property
+ was set.
+
+
+ true if assigned PreviousFlushMode property; otherwise, false.
+
+
+
+
+ Gets the validated session.
+
+ The validated session.
+
+
+
+ Initialize a new instance.
+
+
+
+
+ Create a new session on demand
+
+
+
+
+ Ensure session is closed (if any) and remove circular references to avoid memory leaks!
+
+
+
+
+ Gets called by HibernateTemplate with an active
+ Hibernate Session. Does not need to care about activating or closing
+ the Session, or handling transactions.
+
+
+
+ Allows for returning a result object created within the callback, i.e.
+ a domain object or a collection of domain objects. Note that there's
+ special support for single step actions: see HibernateTemplate.find etc.
+
+
+
+
+
+ Provide support for the open session in view pattern for lazily loaded hibernate objects
+ used in ASP.NET pages.
+
+ jjx: http://forum.springframework.net/member.php?u=29
+ Mark Pollack (.NET)
+ Erich Eichinger
+ Harald Radi
+
+
+
+ Initializes a new instance of the class. Creates a SessionScope,
+ but does not yet associate a session with a thread, that is lef to the lifecycle of the request.
+
+
+
+
+ Register context handler and look up SessionFactoryObjectName under the application configuration key,
+ Spring.Data.NHibernate.Support.OpenSessionInViewModule.SessionFactoryObjectName if not using the default value
+ (i.e. sessionFactory) and look up the SingleSession setting under the application configuration key,
+ Spring.Data.NHibernate.Support.OpenSessionInViewModule.SingleSession if not using the default value of true.
+
+ The standard HTTP application context
+
+
+
+ A do nothing dispose method.
+
+
+
+
+ Hibernate-specific subclass of UncategorizedDataAccessException,
+ for Hibernate system errors that do not match any concrete
+ Spring.Dao exceptions.
+
+ Mark Pollack (.NET)
+
+
+
+ Initializes a new instance of the class.
+
+
+
+
+ Initializes a new instance of the class.
+
+ The cause.
+
+
+
+ Creates a new instance of the
+ class.
+
+
+ The
+ that holds the serialized object data about the exception being thrown.
+
+
+ The
+ that contains contextual information about the source or destination.
+
+
+
+
+ Hibernate-specific subclass of InvalidDataAccessResourceUsageException,
+ thrown on invalid HQL query syntax.
+
+ Mark Pollack (.NET)
+
+
+
+ Initializes a new instance of the class.
+
+
+
+
+ Initializes a new instance of the class.
+
+ The ex.
+
+
+
+ Creates a new instance of the
+ class.
+
+
+ The
+ that holds the serialized object data about the exception being thrown.
+
+
+ The
+ that contains contextual information about the source or destination.
+
+
+
+
+ Gets the query string that was invalid.
+
+ The query string that was invalid.
+
+
+
+ Gets called by HibernateTemplate with an active
+ Hibernate Session. Does not need to care about activating or closing
+ the Session, or handling transactions.
+
+
+
+ Allows for returning an IList of result objects created within the callback.
+ Note that there's special support for single step actions:
+ see HibernateTemplate.find etc.
+
+
+ The type of result object
+ Sree Nivask (.NET)
+
+
+
+ Hibernate-specific subclass of ObjectRetrievalFailureException.
+
+
+ Converts Hibernate's UnresolvableObjectException, ObjectNotFoundException,
+ ObjectDeletedException, and WrongClassException.
+
+ Mark Pollack (.NET)
+ $Id: HibernateObjectRetrievalFailureException.cs,v 1.1 2008/04/07 20:12:53 lahma Exp $
+
+
+
+ Initializes a new instance of the class.
+
+
+
+
+ Initializes a new instance of the class.
+
+ The ex.
+
+
+
+ Initializes a new instance of the class.
+
+ The ex.
+
+
+
+ Initializes a new instance of the class.
+
+ The ex.
+
+
+
+ Initializes a new instance of the class.
+
+ The ex.
+
+
+
+ Creates a new instance of the
+ class.
+
+
+ The
+ that holds the serialized object data about the exception being thrown.
+
+
+ The
+ that contains contextual information about the source or destination.
+
+
+
+
+ Convenient super class for Hibernate data access objects.
+
+
+ Requires a SessionFactory to be set, providing a HibernateTemplate
+ based on it to subclasses. Can alternatively be initialized directly with
+ a HibernateTemplate, to reuse the latter's settings such as the SessionFactory,
+ exception translator, flush mode, etc
+
+ This base call is mainly intended for HibernateTemplate usage.
+
+ This class will create its own HibernateTemplate if only a SessionFactory
+ is passed in. The "allowCreate" flag on that HibernateTemplate will be "true"
+ by default. A custom HibernateTemplate instance can be used through overriding
+ CreateHibernateTemplate.
+
+
+ Mark Pollack (.NET)
+
+
+
+ Initializes a new instance of the class.
+
+
+
+
+ Create a HibernateTemplate for the given ISessionFactory.
+
+
+ Only invoked if populating the DAO with a ISessionFactory reference!
+
Can be overridden in subclasses to provide a HibernateTemplate instance
+ with different configuration, or a custom HibernateTemplate subclass.
+
+
+
+
+
+ Check if the hibernate template property has been set.
+
+
+
+
+ Get a Hibernate Session, either from the current transaction or
+ a new one. The latter is only allowed if "allowCreate" is true.
+
+ Note that this is not meant to be invoked from HibernateTemplate code
+ but rather just in plain Hibernate code. Either rely on a thread-bound
+ Session (via HibernateInterceptor), or use it in combination with
+ ReleaseSession.
+
+ In general, it is recommended to use HibernateTemplate, either with
+ the provided convenience operations or with a custom HibernateCallback
+ that provides you with a Session to work on. HibernateTemplate will care
+ for all resource management and for proper exception conversion.
+
+
+ if a non-transactional Session should be created when no
+ transactional Session can be found for the current thread
+
+ Hibernate session.
+
+ If the Session couldn't be created
+
+
+ if no thread-bound Session found and allowCreate false
+
+
+
+
+
+ Convert the given HibernateException to an appropriate exception from the
+ org.springframework.dao hierarchy. Will automatically detect
+ wrapped ADO.NET Exceptions and convert them accordingly.
+
+ HibernateException that occured.
+
+ The corresponding DataAccessException instance
+
+
+ The default implementation delegates to SessionFactoryUtils
+ and convertAdoAccessException. Can be overridden in subclasses.
+
+
+
+
+ Close the given Hibernate Session, created via this DAO's SessionFactory,
+ if it isn't bound to the thread.
+
+
+ Typically used in plain Hibernate code, in combination with the
+ Session property and ConvertHibernateAccessException.
+
+ The session to close.
+
+
+
+ Gets or sets the hibernate template.
+
+ Set the HibernateTemplate for this DAO explicitly,
+ as an alternative to specifying a SessionFactory.
+
+ The hibernate template.
+
+
+
+ Gets or sets the session factory to be used by this DAO.
+ Will automatically create a HibernateTemplate for the given SessionFactory.
+
+ The session factory.
+
+
+
+ Get a Hibernate Session, either from the current transaction or a new one.
+ The latter is only allowed if the "allowCreate" setting of this object's
+ HibernateTemplate is true.
+
+
+
Note that this is not meant to be invoked from HibernateTemplate code
+ but rather just in plain Hibernate code. Use it in combination with
+ ReleaseSession.
+
+
In general, it is recommended to use HibernateTemplate, either with
+ the provided convenience operations or with a custom HibernateCallback
+ that provides you with a Session to work on. HibernateTemplate will care
+ for all resource management and for proper exception conversion.
+
+
+ The Hibernate session.
+
+
+
+ An IFactoryObject that creates a local Hibernate SessionFactory instance.
+ Behaves like a SessionFactory instance when used as bean reference,
+ e.g. for HibernateTemplate's "SessionFactory" property.
+
+
+ The typical usage will be to register this as singleton factory
+ in an application context and give objects references to application services
+ that need it.
+
+ Hibernate configuration settings can be set using the IDictionary property 'HibernateProperties'.
+
+
+ This class implements the interface,
+ as autodetected by Spring's
+ for AOP-based translation of PersistenceExceptionTranslationPostProcessor.
+ Hence, the presence of e.g. LocalSessionFactoryBean automatically enables
+ a PersistenceExceptionTranslationPostProcessor to translate Hibernate exceptions.
+
+
+ Mark Pollack (.NET)
+ $Id: LocalSessionFactoryObject.cs,v 1.2 2008/05/01 12:50:34 lahma Exp $
+
+
+
+ TODO: consider changing to NamevalueCollection for easier
+ cut-n-paste from existing App.config based configurations.
+
+
+
+
+ The shared instance for this class (and derived classes).
+
+
+
+
+ Initializes a new instance of the class.
+
+
+
+
+ Return the singleon session factory.
+
+ The singleon session factory.
+
+
+
+ Initialize the SessionFactory for the given or the
+ default location.
+
+
+
+
+ Close the SessionFactory on application context shutdown.
+
+
+
+
+ Subclasses can override this method to perform custom initialization
+ of the Configuration instance used for ISessionFactory creation.
+
+
+ The properties of this LocalSessionFactoryObject will be applied to
+ the Configuration object that gets returned here.
+
The default implementation creates a new Configuration instance.
+ A custom implementation could prepare the instance in a specific way,
+ or use a custom Configuration subclass.
+
+
+ The configuration instance.
+
+
+
+ To be implemented by subclasses that want to to register further mappings
+ on the Configuration object after this FactoryObject registered its specified
+ mappings.
+
+
+ Invoked before the BuildMappings call,
+ so that it can still extend and modify the mapping information.
+
+ the current Configuration object
+
+
+
+ To be implemented by subclasses that want to to perform custom
+ post-processing of the Configuration object after this FactoryObject
+ performed its default initialization.
+
+ The current configuration object.
+
+
+
+ Executes schema update if requested.
+
+
+
+
+ Execute schema drop script, determined by the Configuration object
+ used for creating the SessionFactory. A replacement for NHibernate's
+ SchemaExport class, to be invoked on application setup.
+
+
+ Fetch the LocalSessionFactoryBean itself rather than the exposed
+ SessionFactory to be able to invoke this method, e.g. via
+ LocalSessionFactoryObject lsfb = (LocalSessionFactoryObject) ctx.GetObject("mySessionFactory");.
+
+ Uses the SessionFactory that this bean generates for accessing a ADO.NET
+ connection to perform the script.
+
+
+
+
+
+ Execute schema creation script, determined by the Configuration object
+ used for creating the SessionFactory. A replacement for NHibernate's
+ SchemaExport class, to be invoked on application setup.
+
+
+ Fetch the LocalSessionFactoryObject itself rather than the exposed
+ SessionFactory to be able to invoke this method, e.g. via
+ LocalSessionFactoryObject lsfo = (LocalSessionFactoryObject) ctx.GetObject("mySessionFactory");.
+
+ Uses the SessionFactory that this bean generates for accessing a ADO.NET
+ connection to perform the script.
+
+
+
+
+
+ Execute schema update script, determined by the Configuration object
+ used for creating the SessionFactory. A replacement for NHibernate's
+ SchemaUpdate class, for automatically executing schema update scripts
+ on application startup. Can also be invoked manually.
+
+
+ Fetch the LocalSessionFactoryObject itself rather than the exposed
+ SessionFactory to be able to invoke this method, e.g. via
+ LocalSessionFactoryObject lsfo = (LocalSessionFactoryObject) ctx.GetObject("mySessionFactory");.
+
+ Uses the SessionFactory that this bean generates for accessing a ADO.NET
+ connection to perform the script.
+
+
+
+
+
+ Execute the given schema script on the given ADO.NET Connection.
+
+
+ Note that the default implementation will log unsuccessful statements
+ and continue to execute. Override the ExecuteSchemaStatement
+ method to treat failures differently.
+
+ The connection to use.
+ The SQL statement to execute.
+
+
+
+ Execute the given schema SQL on the given ADO.NET command.
+
+
+ Note that the default implementation will log unsuccessful statements
+ and continue to execute. Override this method to treat failures differently.
+
+
+
+
+
+
+ Subclasses can override this method to perform custom initialization
+ of the SessionFactory instance, creating it via the given Configuration
+ object that got prepared by this LocalSessionFactoryObject.
+
+
+
The default implementation invokes Configuration's BuildSessionFactory.
+ A custom implementation could prepare the instance in a specific way,
+ or use a custom ISessionFactory subclass.
+
+
+ The ISessionFactory instance.
+
+
+
+ Implementation of the PersistenceExceptionTranslator interface,
+ as autodetected by Spring's PersistenceExceptionTranslationPostProcessor.
+ Converts the exception if it is a HibernateException;
+ else returns null to indicate an unknown exception.
+ translate the given exception thrown by a persistence framework to a
+ corresponding exception from Spring's generic DataAccessException hierarchy,
+ if possible.
+
+ The exception thrown.
+
+ the corresponding DataAccessException (or null if the
+ exception could not be translated.
+
+
+
+
+
+ Convert the given HibernateException to an appropriate exception from the
+ Spring's DAO Exception hierarchy.
+ Will automatically apply a specified IAdoExceptionTranslator to a
+ Hibernate ADOException, else rely on Hibernate's default translation.
+
+ The Hibernate exception that occured.
+ A corresponding DataAccessException
+
+
+
+ Converts the ADO.NET access exception to an appropriate exception from the
+ org.springframework.dao hierarchy. Can be overridden in subclasses.
+
+ ADOException that occured, wrapping underlying ADO.NET exception.
+
+ the corresponding DataAccessException instance
+
+
+
+
+ Sets the assemblies to load that contain mapping files.
+
+ The mapping assemblies.
+
+
+
+ Sets the hibernate configuration files to load, i.e. hibernate.cfg.xml.
+
+
+
+
+ Sets the locations of Spring IResources that contain mapping
+ files.
+
+ The location of mapping resources.
+
+
+
+ Return the Configuration object used to build the SessionFactory.
+ Allows access to configuration metadata stored there (rarely needed).
+
+ The hibernate configuration.
+
+
+
+ Set NHibernate configuration properties, like "hibernate.dialect".
+
+ The hibernate properties.
+
+
Can be used to override values in a NHibernate XML config file,
+ or to specify all necessary properties locally.
+
+
Note: Do not specify a transaction provider here when using
+ Spring-driven transactions. It is also advisable to omit connection
+ provider settings and use a Spring-set IDbProvider instead.
+
+
+
+
+
+ Get or set the DataSource to be used by the SessionFactory.
+
+ The db provider.
+
+ If set, this will override corresponding settings in Hibernate properties.
+ Note: If this is set, the Hibernate settings should not define
+ a connection string
+ (hibernate.connection.connection_string) to avoid meaningless double configuration.
+
+
+
+
+
+ Gets or sets a value indicating whether to expose a transaction aware session factory.
+
+
+ true if want to expose transaction aware session factory; otherwise, false.
+
+
+
+
+ Set a NHibernate 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 factory.
+
Such an interceptor can either be set at the SessionFactory level, i.e. on
+ LocalSessionFactoryObject, or at the Session level, i.e. on HibernateTemplate,
+ HibernateInterceptor, and HibernateTransactionManager. It's preferable to set
+ it on LocalSessionFactoryObject or HibernateTransactionManager to avoid repeated
+ configuration and guarantee consistent behavior in transactions.
+
+
+
+
+
+
+ Set a Hibernate NamingStrategy for the SessionFactory, determining the
+ physical column and table names given the info in the mapping document.
+
+
+
+
+ Specify the Hibernate type definitions to register with the SessionFactory,
+ as Spring IObjectDefinition instances. This is an alternative to specifying
+ <typedef> elements in Hibernate mapping files.
+
Unfortunately, Hibernate itself does not define a complete object that
+ represents a type definition, hence the need for Spring's TypeDefinitionBean.
+ @see TypeDefinitionBean
+ @see org.hibernate.cfg.Mappings#addTypeDef(String, String, java.util.Properties)
+
+
+
+
+ Specify the NHibernate FilterDefinitions to register with the SessionFactory.
+ This is an alternative to specifying <filter-def> elements in
+ Hibernate mapping files.
+
+
+ Typically, the passed-in FilterDefinition objects will have been defined
+ as Spring FilterDefinitionFactoryBeans, probably as inner beans within the
+ LocalSessionFactoryObject definition.
+
+
+
+
+
+ Specify the cache strategies for entities (persistent classes or named entities).
+ This configuration setting corresponds to the <class-cache> entry
+ in the "hibernate.cfg.xml" configuration format.
+
+
+
+
+
+ Specify the cache strategies for persistent collections (with specific roles).
+ This configuration setting corresponds to the <collection-cache> entry
+ in the "hibernate.cfg.xml" configuration format.
+
+
+
+
+
+
+ Specify the NHibernate event listeners to register, with listener types
+ as keys and listener objects as values.
+
+ Instead of a single listener object, you can also pass in a list
+ or set of listeners objects as value.
+
+
+ listener objects as values
+
+ See the NHibernate documentation for further details on listener types
+ and associated listener interfaces.
+
+
+
+
+ Set whether to execute a schema update after SessionFactory initialization.
+
+ For details on how to make schema update scripts work, see the NHibernate
+ documentation, as this class leverages the same schema update script support
+ in as NHibernate's own SchemaUpdate tool.
+
+
+
+
+
+ Set the ADO.NET exception translator for this instance.
+ Applied to System.Data.Common.DbException (or provider specific exception type
+ in .NET 1.1) thrown by callback code, be it direct
+ DbException or wrapped Hibernate ADOExceptions.
+
The default exception translator is either a ErrorCodeExceptionTranslator
+ if a DbProvider is available, or a FalbackExceptionTranslator otherwise
+
+
+ The ADO exception translator.
+
+
+
+ Return the type or subclass.
+
+ The type created by this factory
+
+
+
+ Returns true
+
+ true
+
+
+
+ Convenient FactoryObject for defining Hibernate FilterDefinitions.
+ Exposes a corresponding Hibernate FilterDefinition object.
+
+
+
+
+ Typically defined as an inner object within a LocalSessionFactoryObject
+ definition, as the list element for the "filterDefinitions" object property.
+ For example:
+
+ Alternatively, specify an object id (or name) attribute for the inner object,
+ instead of the "FilterName" property.
+
+
+ Juergen Hoeller
+ Marko Lahma (.NET)
+
+
+ $Id: FilterDefiniitionFactoryObject.cs,v 1.1 2008/04/07 20:12:53 lahma Exp $
+
+
+
+ Initializes the filter definitions.
+
+
+
+
+ Returns the singleton filter definition.
+
+
+
+
+
+ Set the name of the filter.
+
+
+
+
+ Set the parameter types for the filter,
+ with parameter names as keys and type names as values.
+
+
+
+
+
+ Specify a default filter condition for the filter, if any.
+
+
+
+
+ If no explicit filter name has been specified, the object name of
+ the FilterDefinitionFactoryObject will be used.
+
+
+
+
+
+ Returns the type of the object this factory produces.
+
+
+
+
+ Returns whether this factory produces singletons, always true.
+
+
+
+
+ Helper class featuring methods for Hibernate Session handling,
+ allowing for reuse of Hibernate Session instances within transactions.
+ Also provides support for exception translation.
+
+ Mark Pollack (.NET)
+
+
+
+ The instance for this class.
+
+
+
+
+ The ordering value for synchronizaiton this session resources.
+ Set to be lower than ADO.NET synchronization.
+
+
+
+
+ Initializes a new instance of the class.
+
+
+
+
+ Get a new Hibernate Session from the given SessionFactory.
+ Will return a new Session even if there already is a pre-bound
+ Session for the given SessionFactory.
+
+
+ Within a transaction, this method will create a new Session
+ that shares the transaction's ADO.NET Connection. More specifically,
+ it will use the same ADO.NET Connection as the pre-bound Hibernate Session.
+
+ The session factory to create the session with.
+ The Hibernate entity interceptor, or null if none.
+ The new session.
+ If could not open Hibernate session
+
+
+
+ Get a Hibernate Session for the given SessionFactory. Is aware of and will
+ return any existing corresponding Session bound to the current thread, for
+ example when using HibernateTransactionManager. Will always create a new
+ Session otherwise.
+
+
+ Supports setting a Session-level Hibernate entity interceptor that allows
+ to inspect and change property values before writing to and reading from the
+ database. Such an interceptor can also be set at the SessionFactory level
+ (i.e. on LocalSessionFactoryObject), on HibernateTransactionManager, or on
+ HibernateInterceptor/HibernateTemplate.
+
+ The session factory to create the
+ session with.
+ Hibernate entity interceptor, or null if none.
+ AdoExceptionTranslator to use for flushing the
+ Session on transaction synchronization (can be null; only used when actually
+ registering a transaction synchronization).
+ The Hibernate Session
+
+ If the session couldn't be created.
+
+
+ If no thread-bound Session found and allowCreate is false.
+
+
+
+
+ Get a Hibernate Session for the given SessionFactory. Is aware of and will
+ return any existing corresponding Session bound to the current thread, for
+ example when using . Will create a new Session
+ otherwise, if allowCreate is true.
+
+ The session factory to create the session with.
+ if set to true create a non-transactional Session when no
+ transactional Session can be found for the current thread.
+ The hibernate session
+
+ If the session couldn't be created.
+
+
+ If no thread-bound Session found and allowCreate is false.
+
+
+
+
+ Get a Hibernate Session for the given SessionFactory.
+
+ Is aware of and will return any existing corresponding
+ Session bound to the current thread, for example whenusing
+ . Will create a new
+ Session otherwise, if "allowCreate" is true.
+
Throws the orginal HibernateException, in contrast to
+ .
+
+ The session factory.
+ if set to true [allow create].
+ The Hibernate Session
+
+ if the Session couldn't be created
+
+
+ If no thread-bound Session found and allowCreate is false.
+
+
+
+
+ Open a new Session from the factory.
+
+ The session factory to create the session with.
+ Hibernate entity interceptor, or null if none.
+ the newly opened session
+
+
+
+ Perform the actual closing of the Hibernate Session
+ catching and logging any cleanup exceptions thrown.
+
+ The hibernate session to close
+
+
+
+ Return whether the given Hibernate Session is transactional, that is,
+ bound to the current thread by Spring's transaction facilities.
+
+ The hibernate session to check
+ The session factory that the session
+ was created with, can be null.
+
+ true if the session transactional; otherwise, false.
+
+
+
+
+ Convert the given HibernateException to an appropriate exception from the
+ Spring.Dao hierarchy. Note that it is advisable to
+ handle AdoException specifically by using a AdoExceptionTranslator for the
+ underlying ADO.NET exception.
+
+ The Hibernate exception that occured.
+ DataAccessException instance
+
+
+
+ Close the given Session, created via the given factory,
+ if it is not managed externally (i.e. not bound to the thread).
+
+ The hibernate session to close
+ The hibernate SessionFactory that
+ the session was created with.
+
+
+
+ Close the given Session or register it for deferred close.
+
+ The session.
+ The session factory.
+
+
+
+ Initialize deferred close for the current thread and the given SessionFactory.
+ Sessions will not be actually closed on close calls then, but rather at a
+ processDeferredClose call at a finishing point (like request completion).
+
+ The session factory.
+
+
+
+ Return if deferred close is active for the current thread
+ and the given SessionFactory.
+ The session factory.
+
+ true if [is deferred close active] [the specified session factory]; otherwise, false.
+
+ If SessionFactory argument is null.
+
+
+
+ Process Sessions that have been registered for deferred close
+ for the given SessionFactory.
+
+ The session factory.
+ If there is no session factory associated with the thread.
+
+
+
+ Applies the current transaction timeout, if any, to the given
+ criteria object
+
+ The Hibernate Criteria object.
+ Hibernate SessionFactory that the Criteria was created for
+ (can be null).
+ If criteria argument is null.
+
+
+
+ Applies the current transaction timeout, if any, to the given
+ Hibenrate query object.
+
+ The Hibernate Query object.
+ Hibernate SessionFactory that the Query was created for
+ (can be null).
+ If query argument is null.
+
+
+
+ Gets the Spring IDbProvider given the ISessionFactory.
+
+ The matching is performed by comparing the assembly qualified
+ name string of the hibernate Driver.ConnectionType to those in
+ the DbProviderFactory definitions. No connections are created
+ in performing this comparison.
+ The session factory.
+ The corresponding IDbProvider, null if no mapping was found.
+ If DbProviderFactory's ApplicaitonContext is not
+ an instance of IConfigurableApplicaitonContext.
+
+
+
+ Create a IAdoExceptionTranslator from the given SessionFactory.
+
+ If a corresponding IDbProvider is found, a ErrorcodeExceptionTranslator
+ for the IDbProvider is created. Otherwise, a FallbackException is created.
+ The session factory to create the translator for
+ An IAdoExceptionTranslator
+
+
+
+ Holds the references and configuration settings for a instance.
+ References are resolved by looking up the given object names in the root obtained by .
+
+
+
+
+ The default session factory name to use when retrieving the Hibernate session factory from
+ the root context.
+
+
+
+
+ Initializes a new instance.
+
+ The type, who's name will be used to prefix setting variables with
+
+
+
+ Initializes a new instance.
+
+ The type, who's name will be used to prefix setting variables with
+ The configuration section to read setting variables from.
+
+
+
+ Initializes a new instance.
+
+ The type, who's name will be used to prefix setting variables with
+ The variable source to obtain settings from.
+
+
+
+ Resolve the entityInterceptor by looking up
+ in the root application context.
+
+ The resolved instance or
+
+
+
+ Resolve the by looking up
+ in the root application context.
+
+ The resolved instance or
+
+
+
+ Implementation of NHibernates 1.2's ICurrentSessionContext interface
+ that delegates to Spring's SessionFactoryUtils for providing a
+ Spirng-managed current Session.
+
+ Used by Spring's LocalSessionFactoryBean if told to expose
+ a transaction-aware SessionFactory.
+
This ICurrentSessionContext implementation can also be specified in
+ custom ISessionFactory setup through the
+ "hibernate.current_session_context_class" property, with the fully
+ qualified name of this class as value.