Spring.NET 1.3.0 RC1 for .NET 2.0 API Reference

HibernateTemplate.Execute(T)(IHibernateCallback) Method

Execute the action specified by the given action object within a Session.

[Visual Basic]
Public NotOverridable Overloads Sub Execute(Of T)( _
   ByVal action As IHibernateCallback(Of T) _
) _
    Implements IHibernateOperations.Execute
[C#]
public T Execute<T>(
   IHibernateCallback<T> action
);

Parameters

action
The callback object that specifies the Hibernate action.

Return Value

a result object returned by the action, or null

Implements

IHibernateOperations.Execute

Remarks

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.

Exceptions

Exception TypeCondition
DataAccessExceptionIn case of Hibernate errors

See Also

HibernateTemplate Class | Spring.Data.NHibernate.Generic Namespace | HibernateTemplate.Execute(T) Overload List