|
From: <aye...@us...> - 2009-05-08 06:07:06
|
Revision: 4266
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4266&view=rev
Author: ayenderahien
Date: 2009-05-08 06:07:00 +0000 (Fri, 08 May 2009)
Log Message:
-----------
whitespace & formatting change - spaces to tabs
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Engine/ISessionImplementor.cs
trunk/nhibernate/src/NHibernate/Impl/AbstractSessionImpl.cs
trunk/nhibernate/src/NHibernate/Impl/MultiCriteriaImpl.cs
trunk/nhibernate/src/NHibernate/Impl/MultiQueryImpl.cs
trunk/nhibernate/src/NHibernate/Impl/SessionIdLoggingContext.cs
trunk/nhibernate/src/NHibernate/Impl/SessionImpl.cs
trunk/nhibernate/src/NHibernate/Impl/StatelessSessionImpl.cs
trunk/nhibernate/src/NHibernate/Transaction/AdoTransaction.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Logs/LogsFixture.cs
Modified: trunk/nhibernate/src/NHibernate/Engine/ISessionImplementor.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Engine/ISessionImplementor.cs 2009-05-08 01:45:53 UTC (rev 4265)
+++ trunk/nhibernate/src/NHibernate/Engine/ISessionImplementor.cs 2009-05-08 06:07:00 UTC (rev 4266)
@@ -209,13 +209,13 @@
IInterceptor Interceptor { get; }
/// <summary> Retrieves the configured event listeners from this event source. </summary>
- EventListeners Listeners { get;}
+ EventListeners Listeners { get; }
- int DontFlushFromFind { get;}
+ int DontFlushFromFind { get; }
- ConnectionManager ConnectionManager { get;}
+ ConnectionManager ConnectionManager { get; }
- bool IsEventSource { get;}
+ bool IsEventSource { get; }
/// <summary>
/// Get the entity instance associated with the given <tt>Key</tt>,
@@ -224,9 +224,9 @@
object GetEntityUsingInterceptor(EntityKey key);
/// <summary> Get the persistence context for this session</summary>
- IPersistenceContext PersistenceContext { get;}
+ IPersistenceContext PersistenceContext { get; }
- CacheMode CacheMode { get;set;}
+ CacheMode CacheMode { get; set; }
/// <summary>
/// Is the <c>ISession</c> still open?
@@ -240,7 +240,7 @@
FlushMode FlushMode { get; set; }
- string FetchProfile { get;set;}
+ string FetchProfile { get; set; }
/// <summary> The best guess entity name for an entity not in an association</summary>
string BestGuessEntityName(object entity);
@@ -259,7 +259,7 @@
/// </summary>
/// <returns> True if the session is closed; false otherwise.
/// </returns>
- bool IsClosed { get;}
+ bool IsClosed { get; }
void Flush();
@@ -267,7 +267,7 @@
/// Does this <tt>Session</tt> have an active Hibernate transaction
/// or is there a JTA transaction in progress?
/// </summary>
- bool TransactionInProgress { get;}
+ bool TransactionInProgress { get; }
/// <summary>
/// Allow to get the ISession instance without having to
@@ -277,7 +277,7 @@
ISession GetSession();
/// <summary> Retrieve the entity mode in effect for this session. </summary>
- EntityMode EntityMode { get;}
+ EntityMode EntityMode { get; }
/// <summary> Execute a native SQL update or delete query</summary>
int ExecuteNativeUpdate(NativeSQLQuerySpecification specification, QueryParameters queryParameters);
@@ -285,10 +285,10 @@
/// <summary> Execute a HQL update or delete query</summary>
int ExecuteUpdate(string query, QueryParameters queryParameters);
- FutureCriteriaBatch FutureCriteriaBatch { get; }
+ FutureCriteriaBatch FutureCriteriaBatch { get; }
- FutureQueryBatch FutureQueryBatch { get; }
+ FutureQueryBatch FutureQueryBatch { get; }
- Guid SessionId { get; }
+ Guid SessionId { get; }
}
}
Modified: trunk/nhibernate/src/NHibernate/Impl/AbstractSessionImpl.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Impl/AbstractSessionImpl.cs 2009-05-08 01:45:53 UTC (rev 4265)
+++ trunk/nhibernate/src/NHibernate/Impl/AbstractSessionImpl.cs 2009-05-08 06:07:00 UTC (rev 4266)
@@ -26,18 +26,18 @@
[NonSerialized]
private ISessionFactoryImplementor factory;
- protected readonly Guid sessionId = Guid.NewGuid();
+ protected readonly Guid sessionId = Guid.NewGuid();
private bool closed;
private System.Transactions.Transaction ambientTransation;
private bool isAlreadyDisposed;
protected bool shouldCloseSessionOnDtcTransactionCompleted;
- private static readonly ILog logger = LogManager.GetLogger(typeof (AbstractSessionImpl));
+ private static readonly ILog logger = LogManager.GetLogger(typeof(AbstractSessionImpl));
- public Guid SessionId
- {
- get { return sessionId; }
- }
+ public Guid SessionId
+ {
+ get { return sessionId; }
+ }
protected bool TakingPartInDtcTransaction
{
@@ -58,10 +58,10 @@
public void Initialize()
{
- using(new SessionIdLoggingContext(sessionId))
- {
- CheckAndUpdateSessionStatus();
- }
+ using (new SessionIdLoggingContext(sessionId))
+ {
+ CheckAndUpdateSessionStatus();
+ }
}
public abstract void InitializeCollection(IPersistentCollection collection, bool writing);
@@ -108,20 +108,20 @@
public virtual IQuery GetNamedSQLQuery(string name)
{
- using (new SessionIdLoggingContext(sessionId))
- {
- CheckAndUpdateSessionStatus();
- NamedSQLQueryDefinition nsqlqd = factory.GetNamedSQLQuery(name);
- if (nsqlqd == null)
- {
- throw new MappingException("Named SQL query not known: " + name);
- }
- IQuery query = new SqlQueryImpl(nsqlqd, this,
- factory.QueryPlanCache.GetSQLParameterMetadata(nsqlqd.QueryString));
- query.SetComment("named native SQL query " + name);
- InitQuery(query, nsqlqd);
- return query;
- }
+ using (new SessionIdLoggingContext(sessionId))
+ {
+ CheckAndUpdateSessionStatus();
+ NamedSQLQueryDefinition nsqlqd = factory.GetNamedSQLQuery(name);
+ if (nsqlqd == null)
+ {
+ throw new MappingException("Named SQL query not known: " + name);
+ }
+ IQuery query = new SqlQueryImpl(nsqlqd, this,
+ factory.QueryPlanCache.GetSQLParameterMetadata(nsqlqd.QueryString));
+ query.SetComment("named native SQL query " + name);
+ InitQuery(query, nsqlqd);
+ return query;
+ }
}
public abstract IQueryTranslator[] GetQueries(string query, bool scalar);
@@ -147,33 +147,33 @@
public virtual IQuery GetNamedQuery(string queryName)
{
- using (new SessionIdLoggingContext(sessionId))
- {
- CheckAndUpdateSessionStatus();
- NamedQueryDefinition nqd = factory.GetNamedQuery(queryName);
- IQuery query;
- if (nqd != null)
- {
- string queryString = nqd.QueryString;
- query = new QueryImpl(queryString, nqd.FlushMode, this,
- GetHQLQueryPlan(queryString, false).ParameterMetadata);
- query.SetComment("named HQL query " + queryName);
- }
- else
- {
- NamedSQLQueryDefinition nsqlqd = factory.GetNamedSQLQuery(queryName);
- if (nsqlqd == null)
- {
- throw new MappingException("Named query not known: " + queryName);
- }
- query = new SqlQueryImpl(nsqlqd, this,
- factory.QueryPlanCache.GetSQLParameterMetadata(nsqlqd.QueryString));
- query.SetComment("named native SQL query " + queryName);
- nqd = nsqlqd;
- }
- InitQuery(query, nqd);
- return query;
- }
+ using (new SessionIdLoggingContext(sessionId))
+ {
+ CheckAndUpdateSessionStatus();
+ NamedQueryDefinition nqd = factory.GetNamedQuery(queryName);
+ IQuery query;
+ if (nqd != null)
+ {
+ string queryString = nqd.QueryString;
+ query = new QueryImpl(queryString, nqd.FlushMode, this,
+ GetHQLQueryPlan(queryString, false).ParameterMetadata);
+ query.SetComment("named HQL query " + queryName);
+ }
+ else
+ {
+ NamedSQLQueryDefinition nsqlqd = factory.GetNamedSQLQuery(queryName);
+ if (nsqlqd == null)
+ {
+ throw new MappingException("Named query not known: " + queryName);
+ }
+ query = new SqlQueryImpl(nsqlqd, this,
+ factory.QueryPlanCache.GetSQLParameterMetadata(nsqlqd.QueryString));
+ query.SetComment("named native SQL query " + queryName);
+ nqd = nsqlqd;
+ }
+ InitQuery(query, nqd);
+ return query;
+ }
}
public bool IsClosed
@@ -183,11 +183,11 @@
protected internal virtual void CheckAndUpdateSessionStatus()
{
- using (new SessionIdLoggingContext(sessionId))
- {
- ErrorIfClosed();
- EnlistInAmbientTransactionIfNeeded();
- }
+ using (new SessionIdLoggingContext(sessionId))
+ {
+ ErrorIfClosed();
+ EnlistInAmbientTransactionIfNeeded();
+ }
}
protected internal virtual void ErrorIfClosed()
@@ -212,186 +212,186 @@
protected internal void SetClosed()
{
- try
- {
- if (ambientTransation != null)
- ambientTransation.Dispose();
- }
- catch (Exception)
- {
- //ignore
- }
+ try
+ {
+ if (ambientTransation != null)
+ ambientTransation.Dispose();
+ }
+ catch (Exception)
+ {
+ //ignore
+ }
closed = true;
}
private void InitQuery(IQuery query, NamedQueryDefinition nqd)
{
- using (new SessionIdLoggingContext(sessionId))
- {
- query.SetCacheable(nqd.IsCacheable);
- query.SetCacheRegion(nqd.CacheRegion);
- if (nqd.Timeout != -1)
- {
- query.SetTimeout(nqd.Timeout);
- }
- if (nqd.FetchSize != -1)
- {
- query.SetFetchSize(nqd.FetchSize);
- }
- if (nqd.CacheMode.HasValue)
- query.SetCacheMode(nqd.CacheMode.Value);
+ using (new SessionIdLoggingContext(sessionId))
+ {
+ query.SetCacheable(nqd.IsCacheable);
+ query.SetCacheRegion(nqd.CacheRegion);
+ if (nqd.Timeout != -1)
+ {
+ query.SetTimeout(nqd.Timeout);
+ }
+ if (nqd.FetchSize != -1)
+ {
+ query.SetFetchSize(nqd.FetchSize);
+ }
+ if (nqd.CacheMode.HasValue)
+ query.SetCacheMode(nqd.CacheMode.Value);
- query.SetReadOnly(nqd.IsReadOnly);
- if (nqd.Comment != null)
- {
- query.SetComment(nqd.Comment);
- }
- query.SetFlushMode(nqd.FlushMode);
- }
+ query.SetReadOnly(nqd.IsReadOnly);
+ if (nqd.Comment != null)
+ {
+ query.SetComment(nqd.Comment);
+ }
+ query.SetFlushMode(nqd.FlushMode);
+ }
}
public virtual IQuery CreateQuery(string queryString)
{
- using (new SessionIdLoggingContext(sessionId))
- {
- CheckAndUpdateSessionStatus();
- QueryImpl query = new QueryImpl(queryString, this, GetHQLQueryPlan(queryString, false).ParameterMetadata);
- query.SetComment(queryString);
- return query;
- }
+ using (new SessionIdLoggingContext(sessionId))
+ {
+ CheckAndUpdateSessionStatus();
+ QueryImpl query = new QueryImpl(queryString, this, GetHQLQueryPlan(queryString, false).ParameterMetadata);
+ query.SetComment(queryString);
+ return query;
+ }
}
public virtual ISQLQuery CreateSQLQuery(string sql)
{
- using (new SessionIdLoggingContext(sessionId))
- {
- CheckAndUpdateSessionStatus();
- SqlQueryImpl query = new SqlQueryImpl(sql, this, factory.QueryPlanCache.GetSQLParameterMetadata(sql));
- query.SetComment("dynamic native SQL query");
- return query;
- }
+ using (new SessionIdLoggingContext(sessionId))
+ {
+ CheckAndUpdateSessionStatus();
+ SqlQueryImpl query = new SqlQueryImpl(sql, this, factory.QueryPlanCache.GetSQLParameterMetadata(sql));
+ query.SetComment("dynamic native SQL query");
+ return query;
+ }
}
protected internal virtual HQLQueryPlan GetHQLQueryPlan(string query, bool shallow)
{
- using (new SessionIdLoggingContext(sessionId))
- {
- return factory.QueryPlanCache.GetHQLQueryPlan(query, shallow, EnabledFilters);
- }
+ using (new SessionIdLoggingContext(sessionId))
+ {
+ return factory.QueryPlanCache.GetHQLQueryPlan(query, shallow, EnabledFilters);
+ }
}
protected internal virtual NativeSQLQueryPlan GetNativeSQLQueryPlan(NativeSQLQuerySpecification spec)
{
- using (new SessionIdLoggingContext(sessionId))
- {
- return factory.QueryPlanCache.GetNativeSQLQueryPlan(spec);
- }
+ using (new SessionIdLoggingContext(sessionId))
+ {
+ return factory.QueryPlanCache.GetNativeSQLQueryPlan(spec);
+ }
}
protected ADOException Convert(Exception sqlException, string message)
{
- using (new SessionIdLoggingContext(sessionId))
- {
- return ADOExceptionHelper.Convert(factory.SQLExceptionConverter, sqlException, message);
- }
+ using (new SessionIdLoggingContext(sessionId))
+ {
+ return ADOExceptionHelper.Convert(factory.SQLExceptionConverter, sqlException, message);
+ }
}
protected void AfterOperation(bool success)
{
- using (new SessionIdLoggingContext(sessionId))
- {
- if (!ConnectionManager.IsInActiveTransaction)
- {
- ConnectionManager.AfterNonTransactionalQuery(success);
- }
- }
+ using (new SessionIdLoggingContext(sessionId))
+ {
+ if (!ConnectionManager.IsInActiveTransaction)
+ {
+ ConnectionManager.AfterNonTransactionalQuery(success);
+ }
+ }
}
#region IEnlistmentNotification Members
void IEnlistmentNotification.Prepare(PreparingEnlistment preparingEnlistment)
{
- using (new SessionIdLoggingContext(sessionId))
- {
- try
- {
- using (var tx = new TransactionScope(ambientTransation))
- {
- BeforeTransactionCompletion(null);
- if (FlushMode != FlushMode.Never)
- {
- using (ConnectionManager.FlushingFromDtcTransaction)
- Flush();
- }
- logger.Debug("prepared for DTC transaction");
+ using (new SessionIdLoggingContext(sessionId))
+ {
+ try
+ {
+ using (var tx = new TransactionScope(ambientTransation))
+ {
+ BeforeTransactionCompletion(null);
+ if (FlushMode != FlushMode.Never)
+ {
+ using (ConnectionManager.FlushingFromDtcTransaction)
+ Flush();
+ }
+ logger.Debug("prepared for DTC transaction");
- tx.Complete();
- }
- preparingEnlistment.Prepared();
- }
- catch (Exception exception)
- {
- logger.Error("DTC transaction prepre phase failed", exception);
- preparingEnlistment.ForceRollback(exception);
+ tx.Complete();
+ }
+ preparingEnlistment.Prepared();
+ }
+ catch (Exception exception)
+ {
+ logger.Error("DTC transaction prepre phase failed", exception);
+ preparingEnlistment.ForceRollback(exception);
- }
- }
+ }
+ }
}
void IEnlistmentNotification.Commit(Enlistment enlistment)
{
- using (new SessionIdLoggingContext(sessionId))
- {
- logger.Debug("committing DTC transaction");
- // we have nothing to do here, since it is the actual
- // DB connection that will commit the transaction
- enlistment.Done();
- }
+ using (new SessionIdLoggingContext(sessionId))
+ {
+ logger.Debug("committing DTC transaction");
+ // we have nothing to do here, since it is the actual
+ // DB connection that will commit the transaction
+ enlistment.Done();
+ }
}
void IEnlistmentNotification.Rollback(Enlistment enlistment)
{
- using (new SessionIdLoggingContext(sessionId))
- {
- AfterTransactionCompletion(false, null);
- logger.Debug("rolled back DTC transaction");
- enlistment.Done();
- }
+ using (new SessionIdLoggingContext(sessionId))
+ {
+ AfterTransactionCompletion(false, null);
+ logger.Debug("rolled back DTC transaction");
+ enlistment.Done();
+ }
}
void IEnlistmentNotification.InDoubt(Enlistment enlistment)
{
- using (new SessionIdLoggingContext(sessionId))
- {
- AfterTransactionCompletion(false, null);
- logger.Debug("DTC transaction is in doubt");
- enlistment.Done();
- }
+ using (new SessionIdLoggingContext(sessionId))
+ {
+ AfterTransactionCompletion(false, null);
+ logger.Debug("DTC transaction is in doubt");
+ enlistment.Done();
+ }
}
- protected void EnlistInAmbientTransactionIfNeeded()
- {
- using (new SessionIdLoggingContext(sessionId))
- {
- if (ambientTransation != null)
- return;
- if (System.Transactions.Transaction.Current == null)
- return;
- ambientTransation = System.Transactions.Transaction.Current.Clone();
- logger.DebugFormat("enlisted into DTC transaction: {0}", ambientTransation.IsolationLevel);
- AfterTransactionBegin(null);
- ambientTransation.TransactionCompleted += delegate(object sender, TransactionEventArgs e)
- {
- bool wasSuccessful = e.Transaction.TransactionInformation.Status == TransactionStatus.Committed;
- AfterTransactionCompletion(wasSuccessful, null);
- if (shouldCloseSessionOnDtcTransactionCompleted)
- Dispose(true);
- };
- ambientTransation.EnlistVolatile(this, EnlistmentOptions.EnlistDuringPrepareRequired);
- }
- }
+ protected void EnlistInAmbientTransactionIfNeeded()
+ {
+ using (new SessionIdLoggingContext(sessionId))
+ {
+ if (ambientTransation != null)
+ return;
+ if (System.Transactions.Transaction.Current == null)
+ return;
+ ambientTransation = System.Transactions.Transaction.Current.Clone();
+ logger.DebugFormat("enlisted into DTC transaction: {0}", ambientTransation.IsolationLevel);
+ AfterTransactionBegin(null);
+ ambientTransation.TransactionCompleted += delegate(object sender, TransactionEventArgs e)
+ {
+ bool wasSuccessful = e.Transaction.TransactionInformation.Status == TransactionStatus.Committed;
+ AfterTransactionCompletion(wasSuccessful, null);
+ if (shouldCloseSessionOnDtcTransactionCompleted)
+ Dispose(true);
+ };
+ ambientTransation.EnlistVolatile(this, EnlistmentOptions.EnlistDuringPrepareRequired);
+ }
+ }
- protected abstract void Dispose(bool disposing);
+ protected abstract void Dispose(bool disposing);
#endregion
}
Modified: trunk/nhibernate/src/NHibernate/Impl/MultiCriteriaImpl.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Impl/MultiCriteriaImpl.cs 2009-05-08 01:45:53 UTC (rev 4265)
+++ trunk/nhibernate/src/NHibernate/Impl/MultiCriteriaImpl.cs 2009-05-08 06:07:00 UTC (rev 4266)
@@ -19,9 +19,9 @@
{
public class MultiCriteriaImpl : IMultiCriteria
{
- private static readonly ILog log = LogManager.GetLogger(typeof(MultiCriteriaImpl));
- private readonly IList<ICriteria> criteriaQueries = new List<ICriteria>();
- private readonly IList<System.Type> resultCollectionGenericType = new List<System.Type>();
+ private static readonly ILog log = LogManager.GetLogger(typeof(MultiCriteriaImpl));
+ private readonly IList<ICriteria> criteriaQueries = new List<ICriteria>();
+ private readonly IList<System.Type> resultCollectionGenericType = new List<System.Type>();
private readonly SessionImpl session;
private readonly ISessionFactoryImplementor factory;
@@ -65,33 +65,33 @@
public IList List()
{
- using (new SessionIdLoggingContext(session.SessionId))
- {
- bool cacheable = session.Factory.Settings.IsQueryCacheEnabled && isCacheable;
+ using (new SessionIdLoggingContext(session.SessionId))
+ {
+ bool cacheable = session.Factory.Settings.IsQueryCacheEnabled && isCacheable;
- CreateCriteriaLoaders();
- CombineCriteriaQueries();
+ CreateCriteriaLoaders();
+ CombineCriteriaQueries();
- if (log.IsDebugEnabled)
- {
- log.DebugFormat("Multi criteria with {0} criteria queries.", criteriaQueries.Count);
- for (int i = 0; i < criteriaQueries.Count; i++)
- {
- log.DebugFormat("Query #{0}: {1}", i, criteriaQueries[i]);
- }
- }
+ if (log.IsDebugEnabled)
+ {
+ log.DebugFormat("Multi criteria with {0} criteria queries.", criteriaQueries.Count);
+ for (int i = 0; i < criteriaQueries.Count; i++)
+ {
+ log.DebugFormat("Query #{0}: {1}", i, criteriaQueries[i]);
+ }
+ }
- if (cacheable)
- {
- criteriaResults = ListUsingQueryCache();
- }
- else
- {
- criteriaResults = ListIgnoreQueryCache();
- }
+ if (cacheable)
+ {
+ criteriaResults = ListUsingQueryCache();
+ }
+ else
+ {
+ criteriaResults = ListIgnoreQueryCache();
+ }
- return criteriaResults;
- }
+ return criteriaResults;
+ }
}
@@ -156,7 +156,7 @@
for (int i = 0; i < results.Count; i++)
{
CriteriaImpl critImp = criteriaQueries[i] as CriteriaImpl;
- if(critImp==null || critImp.ResultTransformer==null)
+ if (critImp == null || critImp.ResultTransformer == null)
continue;
results[i] = critImp.ResultTransformer.TransformList((IList)results[i]);
}
@@ -207,15 +207,15 @@
hydratedObjects[i] = entitySpan == 0 ? null : new ArrayList(entitySpan);
EntityKey[] keys = new EntityKey[entitySpan];
QueryParameters queryParameters = parameters[i];
- IList tmpResults;
- if (resultCollectionGenericType[i] == typeof(object))
- {
- tmpResults = new ArrayList();
- }
- else
- {
- tmpResults = (IList) Activator.CreateInstance(typeof (List<>).MakeGenericType(resultCollectionGenericType[i]));
- }
+ IList tmpResults;
+ if (resultCollectionGenericType[i] == typeof(object))
+ {
+ tmpResults = new ArrayList();
+ }
+ else
+ {
+ tmpResults = (IList)Activator.CreateInstance(typeof(List<>).MakeGenericType(resultCollectionGenericType[i]));
+ }
RowSelection selection = parameters[i].RowSelection;
createSubselects[i] = loader.IsSubselectLoadingEnabled;
@@ -341,7 +341,7 @@
}
return colIndex;
}
-
+
public IMultiCriteria Add(System.Type resultGenericListType, ICriteria criteria)
{
criteriaQueries.Add(criteria);
@@ -350,64 +350,64 @@
return this;
}
- public IMultiCriteria Add(ICriteria criteria)
+ public IMultiCriteria Add(ICriteria criteria)
{
- return Add<object>(criteria);
+ return Add<object>(criteria);
}
- public IMultiCriteria Add(string key, ICriteria criteria)
+ public IMultiCriteria Add(string key, ICriteria criteria)
{
- return Add<object>(key, criteria);
+ return Add<object>(key, criteria);
}
- public IMultiCriteria Add(DetachedCriteria detachedCriteria)
- {
- return Add<object>(detachedCriteria);
- }
+ public IMultiCriteria Add(DetachedCriteria detachedCriteria)
+ {
+ return Add<object>(detachedCriteria);
+ }
- public IMultiCriteria Add(string key, DetachedCriteria detachedCriteria)
- {
- return Add<object>(key, detachedCriteria);
- }
+ public IMultiCriteria Add(string key, DetachedCriteria detachedCriteria)
+ {
+ return Add<object>(key, detachedCriteria);
+ }
- public IMultiCriteria Add<T>(ICriteria criteria)
+ public IMultiCriteria Add<T>(ICriteria criteria)
{
criteriaQueries.Add(criteria);
- resultCollectionGenericType.Add(typeof(T));
+ resultCollectionGenericType.Add(typeof(T));
return this;
}
- public IMultiCriteria Add<T>(string key, ICriteria criteria)
+ public IMultiCriteria Add<T>(string key, ICriteria criteria)
{
ThrowIfKeyAlreadyExists(key);
criteriaQueries.Add(criteria);
criteriaResultPositions.Add(key, criteriaQueries.Count - 1);
- resultCollectionGenericType.Add(typeof(T));
+ resultCollectionGenericType.Add(typeof(T));
return this;
}
- public IMultiCriteria Add<T>(DetachedCriteria detachedCriteria)
+ public IMultiCriteria Add<T>(DetachedCriteria detachedCriteria)
{
criteriaQueries.Add(
detachedCriteria.GetExecutableCriteria(session)
);
- resultCollectionGenericType.Add(typeof (T));
+ resultCollectionGenericType.Add(typeof(T));
return this;
}
-
- public IMultiCriteria Add<T>(string key, DetachedCriteria detachedCriteria)
- {
- ThrowIfKeyAlreadyExists(key);
- criteriaQueries.Add(detachedCriteria.GetExecutableCriteria(session));
- criteriaResultPositions.Add(key, criteriaQueries.Count - 1);
- resultCollectionGenericType.Add(typeof(T));
- return this;
- }
-
+ public IMultiCriteria Add<T>(string key, DetachedCriteria detachedCriteria)
+ {
+ ThrowIfKeyAlreadyExists(key);
+ criteriaQueries.Add(detachedCriteria.GetExecutableCriteria(session));
+ criteriaResultPositions.Add(key, criteriaQueries.Count - 1);
+ resultCollectionGenericType.Add(typeof(T));
+
+ return this;
+ }
+
public IMultiCriteria SetCacheable(bool cachable)
{
isCacheable = cachable;
Modified: trunk/nhibernate/src/NHibernate/Impl/MultiQueryImpl.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Impl/MultiQueryImpl.cs 2009-05-08 01:45:53 UTC (rev 4265)
+++ trunk/nhibernate/src/NHibernate/Impl/MultiQueryImpl.cs 2009-05-08 06:07:00 UTC (rev 4266)
@@ -22,7 +22,7 @@
private static readonly ILog log = LogManager.GetLogger(typeof(MultiQueryImpl));
private readonly List<IQuery> queries = new List<IQuery>();
- private readonly List<IQueryTranslator> translators = new List<IQueryTranslator>(); private readonly IList<System.Type> resultCollectionGenericType = new List<System.Type>(); private readonly List<QueryParameters> parameters = new List<QueryParameters>(); private IList queryResults;
+ private readonly List<IQueryTranslator> translators = new List<IQueryTranslator>(); private readonly IList<System.Type> resultCollectionGenericType = new List<System.Type>(); private readonly List<QueryParameters> parameters = new List<QueryParameters>(); private IList queryResults;
private readonly Dictionary<string, int> criteriaResultPositions = new Dictionary<string, int>();
private string cacheRegion;
private int commandTimeout = RowSelection.NoValue;
@@ -288,13 +288,13 @@
}
return this;
}
-
- public IMultiQuery AddNamedQuery<T>(string key, string namedQuery)
- {
- ThrowIfKeyAlreadyExists(key);
- return Add<T>(key, session.GetNamedQuery(namedQuery));
- }
+ public IMultiQuery AddNamedQuery<T>(string key, string namedQuery)
+ {
+ ThrowIfKeyAlreadyExists(key);
+ return Add<T>(key, session.GetNamedQuery(namedQuery));
+ }
+
public IMultiQuery Add(System.Type resultGenericListType, IQuery query)
{
AddQueryForLaterExecutionAndReturnIndexOfQuery(resultGenericListType, query);
@@ -302,66 +302,66 @@
return this;
}
- public IMultiQuery Add(string key, IQuery query)
- {
- return Add<object>(key, query);
- }
+ public IMultiQuery Add(string key, IQuery query)
+ {
+ return Add<object>(key, query);
+ }
- public IMultiQuery Add(IQuery query)
- {
- return Add<object>(query);
- }
+ public IMultiQuery Add(IQuery query)
+ {
+ return Add<object>(query);
+ }
- public IMultiQuery Add(string key, string hql)
- {
- return Add<object>(key, hql);
- }
+ public IMultiQuery Add(string key, string hql)
+ {
+ return Add<object>(key, hql);
+ }
- public IMultiQuery Add(string hql)
- {
- return Add<object>(hql);
- }
+ public IMultiQuery Add(string hql)
+ {
+ return Add<object>(hql);
+ }
- public IMultiQuery AddNamedQuery(string namedQuery)
- {
- return AddNamedQuery<object>(namedQuery);
- }
+ public IMultiQuery AddNamedQuery(string namedQuery)
+ {
+ return AddNamedQuery<object>(namedQuery);
+ }
- public IMultiQuery AddNamedQuery(string key, string namedQuery)
- {
- return AddNamedQuery<object>(key, namedQuery);
- }
+ public IMultiQuery AddNamedQuery(string key, string namedQuery)
+ {
+ return AddNamedQuery<object>(key, namedQuery);
+ }
public IMultiQuery Add<T>(IQuery query)
- {
- AddQueryForLaterExecutionAndReturnIndexOfQuery(typeof(T), query);
- return this;
- }
+ {
+ AddQueryForLaterExecutionAndReturnIndexOfQuery(typeof(T), query);
+ return this;
+ }
- public IMultiQuery Add<T>(string key, IQuery query)
- {
- ThrowIfKeyAlreadyExists(key);
+ public IMultiQuery Add<T>(string key, IQuery query)
+ {
+ ThrowIfKeyAlreadyExists(key);
criteriaResultPositions.Add(key, AddQueryForLaterExecutionAndReturnIndexOfQuery(typeof(T), query));
- return this;
- }
+ return this;
+ }
- public IMultiQuery Add<T>(string hql)
- {
- return Add<T>(((ISession)session).CreateQuery(hql));
- }
+ public IMultiQuery Add<T>(string hql)
+ {
+ return Add<T>(((ISession)session).CreateQuery(hql));
+ }
- public IMultiQuery Add<T>(string key, string hql)
- {
- ThrowIfKeyAlreadyExists(key);
- return Add<T>(key, ((ISession)session).CreateQuery(hql));
- }
+ public IMultiQuery Add<T>(string key, string hql)
+ {
+ ThrowIfKeyAlreadyExists(key);
+ return Add<T>(key, ((ISession)session).CreateQuery(hql));
+ }
- public IMultiQuery AddNamedQuery<T>(string namedQuery)
- {
- return Add<T>(session.GetNamedQuery(namedQuery));
- }
+ public IMultiQuery AddNamedQuery<T>(string namedQuery)
+ {
+ return Add<T>(session.GetNamedQuery(namedQuery));
+ }
- public IMultiQuery SetCacheable(bool cacheable)
+ public IMultiQuery SetCacheable(bool cacheable)
{
isCacheable = cacheable;
return this;
@@ -378,30 +378,30 @@
/// </summary>
public IList List()
{
- using (new SessionIdLoggingContext(session.SessionId))
- {
- bool cacheable = session.Factory.Settings.IsQueryCacheEnabled && isCacheable;
- combinedParameters = CreateCombinedQueryParameters();
+ using (new SessionIdLoggingContext(session.SessionId))
+ {
+ bool cacheable = session.Factory.Settings.IsQueryCacheEnabled && isCacheable;
+ combinedParameters = CreateCombinedQueryParameters();
- if (log.IsDebugEnabled)
- {
- log.DebugFormat("Multi query with {0} queries.", queries.Count);
- for (int i = 0; i < queries.Count; i++)
- {
- log.DebugFormat("Query #{0}: {1}", i, queries[i]);
- }
- }
+ if (log.IsDebugEnabled)
+ {
+ log.DebugFormat("Multi query with {0} queries.", queries.Count);
+ for (int i = 0; i < queries.Count; i++)
+ {
+ log.DebugFormat("Query #{0}: {1}", i, queries[i]);
+ }
+ }
- try
- {
- Before();
- return cacheable ? ListUsingQueryCache() : ListIgnoreQueryCache();
- }
- finally
- {
- After();
- }
- }
+ try
+ {
+ Before();
+ return cacheable ? ListUsingQueryCache() : ListIgnoreQueryCache();
+ }
+ finally
+ {
+ After();
+ }
+ }
}
public IMultiQuery SetFlushMode(FlushMode mode)
@@ -492,15 +492,15 @@
{
IQueryTranslator translator = Translators[i];
QueryParameters parameter = Parameters[i];
- IList tempResults;
- if (resultCollectionGenericType[i] == typeof(object))
- {
- tempResults = new ArrayList();
- }
- else
- {
- tempResults = (IList)Activator.CreateInstance(typeof(List<>).MakeGenericType(resultCollectionGenericType[i]));
- }
+ IList tempResults;
+ if (resultCollectionGenericType[i] == typeof(object))
+ {
+ tempResults = new ArrayList();
+ }
+ else
+ {
+ tempResults = (IList)Activator.CreateInstance(typeof(List<>).MakeGenericType(resultCollectionGenericType[i]));
+ }
int entitySpan = translator.Loader.EntityPersisters.Length;
hydratedObjects[i] = entitySpan > 0 ? new ArrayList() : null;
RowSelection selection = parameter.RowSelection;
@@ -542,8 +542,8 @@
keys,
false);
- tempResults.Add(result);
-
+ tempResults.Add(result);
+
if (createSubselects[i])
{
subselectResultKeys[i].Add(keys);
@@ -682,7 +682,7 @@
{
if (queryResults == null)
{
- queryResults= List();
+ queryResults = List();
}
if (!criteriaResultPositions.ContainsKey(key))
Modified: trunk/nhibernate/src/NHibernate/Impl/SessionIdLoggingContext.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Impl/SessionIdLoggingContext.cs 2009-05-08 01:45:53 UTC (rev 4265)
+++ trunk/nhibernate/src/NHibernate/Impl/SessionIdLoggingContext.cs 2009-05-08 06:07:00 UTC (rev 4266)
@@ -3,49 +3,49 @@
namespace NHibernate.Impl
{
- public class SessionIdLoggingContext : IDisposable
- {
- private readonly object oldSessonId;
+ public class SessionIdLoggingContext : IDisposable
+ {
+ private readonly object oldSessonId;
- public SessionIdLoggingContext(Guid id)
- {
- oldSessonId = SessionId;
- SessionId = id;
- }
+ public SessionIdLoggingContext(Guid id)
+ {
+ oldSessonId = SessionId;
+ SessionId = id;
+ }
- /// <summary>
- /// Error handling in this case will only kick in if we cannot set values on the TLS
- /// this is usally the case if we are called from the finalizer, since this is something
- /// that we do only for logging, we ignore the error.
- /// </summary>
- private static object SessionId
- {
- get
- {
- try
- {
- return ThreadContext.Properties["sessionId"];
- }
- catch (Exception)
- {
- return null;
- }
- }
- set
- {
- try
- {
- ThreadContext.Properties["sessionId"] = value;
- }
- catch (Exception)
- {
- }
- }
- }
+ /// <summary>
+ /// Error handling in this case will only kick in if we cannot set values on the TLS
+ /// this is usally the case if we are called from the finalizer, since this is something
+ /// that we do only for logging, we ignore the error.
+ /// </summary>
+ private static object SessionId
+ {
+ get
+ {
+ try
+ {
+ return ThreadContext.Properties["sessionId"];
+ }
+ catch (Exception)
+ {
+ return null;
+ }
+ }
+ set
+ {
+ try
+ {
+ ThreadContext.Properties["sessionId"] = value;
+ }
+ catch (Exception)
+ {
+ }
+ }
+ }
- public void Dispose()
- {
- SessionId = oldSessonId;
- }
- }
+ public void Dispose()
+ {
+ SessionId = oldSessonId;
+ }
+ }
}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/Impl/SessionImpl.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Impl/SessionImpl.cs 2009-05-08 01:45:53 UTC (rev 4265)
+++ trunk/nhibernate/src/NHibernate/Impl/SessionImpl.cs 2009-05-08 06:07:00 UTC (rev 4266)
@@ -42,15 +42,18 @@
private readonly long timestamp;
- private CacheMode cacheMode= CacheMode.Normal;
+ private CacheMode cacheMode = CacheMode.Normal;
private FlushMode flushMode = FlushMode.Auto;
private readonly IInterceptor interceptor;
- [NonSerialized] private readonly EntityMode entityMode = EntityMode.Poco;
+ [NonSerialized]
+ private readonly EntityMode entityMode = EntityMode.Poco;
- [NonSerialized] private FutureCriteriaBatch futureCriteriaBatch;
- [NonSerialized] private FutureQueryBatch futureQueryBatch;
+ [NonSerialized]
+ private FutureCriteriaBatch futureCriteriaBatch;
+ [NonSerialized]
+ private FutureQueryBatch futureQueryBatch;
[NonSerialized]
private readonly EventListeners listeners;
@@ -63,20 +66,24 @@
[NonSerialized]
private int dontFlushFromFind;
- [NonSerialized] private readonly IDictionary<string, IFilter> enabledFilters = new Dictionary<string, IFilter>();
+ [NonSerialized]
+ private readonly IDictionary<string, IFilter> enabledFilters = new Dictionary<string, IFilter>();
[NonSerialized]
private readonly StatefulPersistenceContext persistenceContext;
-
+
[NonSerialized]
private readonly ISession rootSession;
[NonSerialized]
- private IDictionary<EntityMode,ISession> childSessionsByEntityMode;
+ private IDictionary<EntityMode, ISession> childSessionsByEntityMode;
- [NonSerialized] private readonly bool flushBeforeCompletionEnabled;
- [NonSerialized] private readonly bool autoCloseSessionEnabled;
- [NonSerialized] private readonly ConnectionReleaseMode connectionReleaseMode;
+ [NonSerialized]
+ private readonly bool flushBeforeCompletionEnabled;
+ [NonSerialized]
+ private readonly bool autoCloseSessionEnabled;
+ [NonSerialized]
+ private readonly ConnectionReleaseMode connectionReleaseMode;
#region System.Runtime.Serialization.ISerializable Members
@@ -133,7 +140,7 @@
}
info.AddValue("factory", Factory, typeof(SessionFactoryImpl));
- info.AddValue("persistenceContext", persistenceContext, typeof (StatefulPersistenceContext));
+ info.AddValue("persistenceContext", persistenceContext, typeof(StatefulPersistenceContext));
info.AddValue("actionQueue", actionQueue, typeof(ActionQueue));
info.AddValue("timestamp", timestamp);
info.AddValue("flushMode", flushMode);
@@ -195,35 +202,35 @@
ConnectionReleaseMode connectionReleaseMode)
: base(factory)
{
- using (new SessionIdLoggingContext(sessionId))
- {
- if (interceptor == null)
- throw new AssertionFailure("The interceptor can not be null.");
+ using (new SessionIdLoggingContext(sessionId))
+ {
+ if (interceptor == null)
+ throw new AssertionFailure("The interceptor can not be null.");
- rootSession = null;
- this.timestamp = timestamp;
- this.entityMode = entityMode;
- this.interceptor = interceptor;
- listeners = factory.EventListeners;
- actionQueue = new ActionQueue(this);
- persistenceContext = new StatefulPersistenceContext(this);
- this.flushBeforeCompletionEnabled = flushBeforeCompletionEnabled;
- this.autoCloseSessionEnabled = autoCloseSessionEnabled;
- this.connectionReleaseMode = connectionReleaseMode;
- connectionManager = new ConnectionManager(this, connection, connectionReleaseMode, interceptor);
+ rootSession = null;
+ this.timestamp = timestamp;
+ this.entityMode = entityMode;
+ this.interceptor = interceptor;
+ listeners = factory.EventListeners;
+ actionQueue = new ActionQueue(this);
+ persistenceContext = new StatefulPersistenceContext(this);
+ this.flushBeforeCompletionEnabled = flushBeforeCompletionEnabled;
+ this.autoCloseSessionEnabled = autoCloseSessionEnabled;
+ this.connectionReleaseMode = connectionReleaseMode;
+ connectionManager = new ConnectionManager(this, connection, connectionReleaseMode, interceptor);
- if (factory.Statistics.IsStatisticsEnabled)
- {
- factory.StatisticsImplementor.OpenSession();
- }
+ if (factory.Statistics.IsStatisticsEnabled)
+ {
+ factory.StatisticsImplementor.OpenSession();
+ }
- if (log.IsDebugEnabled)
- {
- log.Debug("opened session at timestamp: " + timestamp);
- }
+ if (log.IsDebugEnabled)
+ {
+ log.Debug("opened session at timestamp: " + timestamp);
+ }
- CheckAndUpdateSessionStatus();
- }
+ CheckAndUpdateSessionStatus();
+ }
}
/// <summary>
@@ -232,58 +239,58 @@
/// <param name="parent">The parent Session</param>
/// <param name="entityMode">The entity mode</param>
private SessionImpl(SessionImpl parent, EntityMode entityMode)
- :base (parent.Factory)
+ : base(parent.Factory)
{
- using (new SessionIdLoggingContext(sessionId))
- {
- rootSession = parent;
- timestamp = parent.timestamp;
- connectionManager = parent.connectionManager;
- interceptor = parent.interceptor;
- listeners = parent.listeners;
- actionQueue = new ActionQueue(this);
- this.entityMode = entityMode;
- persistenceContext = new StatefulPersistenceContext(this);
- flushBeforeCompletionEnabled = false;
- autoCloseSessionEnabled = false;
- connectionReleaseMode = parent.ConnectionReleaseMode; // NH different
+ using (new SessionIdLoggingContext(sessionId))
+ {
+ rootSession = parent;
+ timestamp = parent.timestamp;
+ connectionManager = parent.connectionManager;
+ interceptor = parent.interceptor;
+ listeners = parent.listeners;
+ actionQueue = new ActionQueue(this);
+ this.entityMode = entityMode;
+ persistenceContext = new StatefulPersistenceContext(this);
+ flushBeforeCompletionEnabled = false;
+ autoCloseSessionEnabled = false;
+ connectionReleaseMode = parent.ConnectionReleaseMode; // NH different
- if (Factory.Statistics.IsStatisticsEnabled)
- Factory.StatisticsImplementor.OpenSession();
+ if (Factory.Statistics.IsStatisticsEnabled)
+ Factory.StatisticsImplementor.OpenSession();
- log.Debug("opened session [" + entityMode + "]");
+ log.Debug("opened session [" + entityMode + "]");
- CheckAndUpdateSessionStatus();
- }
+ CheckAndUpdateSessionStatus();
+ }
}
- public override FutureCriteriaBatch FutureCriteriaBatch
- {
- get
- {
- if (futureCriteriaBatch == null)
- futureCriteriaBatch = new FutureCriteriaBatch(this);
- return futureCriteriaBatch;
- }
- internal set
- {
- futureCriteriaBatch = value;
- }
- }
+ public override FutureCriteriaBatch FutureCriteriaBatch
+ {
+ get
+ {
+ if (futureCriteriaBatch == null)
+ futureCriteriaBatch = new FutureCriteriaBatch(this);
+ return futureCriteriaBatch;
+ }
+ internal set
+ {
+ futureCriteriaBatch = value;
+ }
+ }
- public override FutureQueryBatch FutureQueryBatch
- {
- get
- {
- if (futureQueryBatch == null)
- futureQueryBatch = new FutureQueryBatch(this);
- return futureQueryBatch;
- }
- internal set
- {
- futureQueryBatch = value;
- }
- }
+ public override FutureQueryBatch FutureQueryBatch
+ {
+ get
+ {
+ if (futureQueryBatch == null)
+ futureQueryBatch = new FutureQueryBatch(this);
+ return futureQueryBatch;
+ }
+ internal set
+ {
+ futureQueryBatch = value;
+ }
+ }
/// <summary></summary>
public override IBatcher Batcher
@@ -319,47 +326,47 @@
/// <summary></summary>
public IDbConnection Close()
{
- using (new SessionIdLoggingContext(sessionId))
- {
- log.Debug("closing session");
- if (IsClosed)
- {
- throw new SessionException("Session was already closed");
- }
+ using (new SessionIdLoggingContext(sessionId))
+ {
+ log.Debug("closing session");
+ if (IsClosed)
+ {
+ throw new SessionException("Session was already closed");
+ }
- if (Factory.Statistics.IsStatisticsEnabled)
- {
- Factory.StatisticsImplementor.CloseSession();
- }
+ if (Factory.Statistics.IsStatisticsEnabled)
+ {
+ Factory.StatisticsImplementor.CloseSession();
+ }
- try
- {
- try
- {
- if (childSessionsByEntityMode != null)
- {
- foreach (KeyValuePair<EntityMode, ISession> pair in childSessionsByEntityMode)
- {
- pair.Value.Close();
- }
- }
- }
- catch
- {
- // just ignore
- }
+ try
+ {
+ try
+ {
+ if (childSessionsByEntityMode != null)
+ {
+ foreach (KeyValuePair<EntityMode, ISession> pair in childSessionsByEntityMode)
+ {
+ pair.Value.Close();
+ }
+ }
+ }
+ catch
+ {
+ // just ignore
+ }
- if (rootSession == null)
- return connectionManager.Close();
- else
- return null;
- }
- finally
- {
- SetClosed();
- Cleanup();
- }
- }
+ if (rootSession == null)
+ return connectionManager.Close();
+ else
+ return null;
+ }
+ finally
+ {
+ SetClosed();
+ Cleanup();
+ }
+ }
}
/// <summary>
@@ -369,74 +376,74 @@
/// </summary>
public override void AfterTransactionCompletion(bool success, ITransaction tx)
{
- using (new SessionIdLoggingContext(sessionId))
- {
- log.Debug("transaction completion");
- if (Factory.Statistics.IsStatisticsEnabled)
- {
- Factory.StatisticsImplementor.EndTransaction(success);
- }
+ using (new SessionIdLoggingContext(sessionId))
+ {
+ log.Debug("transaction completion");
+ if (Factory.Statistics.IsStatisticsEnabled)
+ {
+ Factory.StatisticsImplementor.EndTransaction(success);
+ }
- connectionManager.AfterTransaction();
- persistenceContext.AfterTransactionCompletion();
- actionQueue.AfterTransactionCompletion(success);
- if (rootSession == null)
- {
- try
- {
- interceptor.AfterTransactionCompletion(tx);
- }
- catch (Exception t)
- {
- log.Error("exception in interceptor afterTransactionCompletion()", t);
- }
- }
+ connectionManager.AfterTransaction();
+ persistenceContext.AfterTransactionCompletion();
+ actionQueue.AfterTransactionCompletion(success);
+ if (rootSession == null)
+ {
+ try
+ {
+ interceptor.AfterTransactionCompletion(tx);
+ }
+ catch (Exception t)
+ {
+ log.Error("exception in interceptor afterTransactionCompletion()", t);
+ }
+ }
- //if (autoClear)
- // Clear();
- }
+ //if (autoClear)
+ // Clear();
+ }
}
private void Cleanup()
{
- using (new SessionIdLoggingContext(sessionId))
- {
- persistenceContext.Clear();
- }
+ using (new SessionIdLoggingContext(sessionId))
+ {
+ persistenceContext.Clear();
+ }
}
public LockMode GetCurrentLockMode(object obj)
{
- using (new SessionIdLoggingContext(sessionId))
- {
- CheckAndUpdateSessionStatus();
+ using (new SessionIdLoggingContext(sessionId))
+ {
+ CheckAndUpdateSessionStatus();
- if (obj == null)
- {
- throw new ArgumentNullException("obj", "null object passed to GetCurrentLockMode");
- }
- if (obj is INHibernateProxy)
- {
- obj = ((INHibernateProxy) obj).HibernateLazyInitializer.GetImplementation(this);
- if (obj == null)
- {
- return LockMode.None;
- }
- }
+ if (obj == null)
+ {
+ throw new ArgumentNullException("obj", "null object passed to GetCurrentLockMode");
+ }
+ if (obj is INHibernateProxy)
+ {
+ obj = ((INHibernateProxy)obj).HibernateLazyInitializer.GetImplementation(this);
+ if (obj == null)
+ {
+ return LockMode.None;
+ }
+ }
- EntityEntry e = persistenceContext.GetEntry(obj);
- if (e == null)
- {
- throw new TransientObjectException("Given object not associated with the session");
- }
+ EntityEntry e = persistenceContext.GetEntry(obj);
+ if (e == null)
+ {
+ throw new TransientObjectException("Given object not associated with the session");
+ }
- if (e.Status != Status.Loaded)
- {
- throw new ObjectDeletedException("The given object was deleted", e.Id, e.EntityName);
- }
- return e.LockMode;
- }
+ if (e.Status != Status.Loaded)
+ {
+ throw new ObjectDeletedException("The given object was deleted", e.Id, e.EntityName);
+ }
+ return e.LockMode;
+ }
}
public override bool IsOpen
@@ -453,16 +460,16 @@
{
using (new SessionIdLoggingContext(sessionId))
{
- return FireSave(new SaveOrUpdateEvent(null, obj, this));
+ return FireSave(new SaveOrUpdateEvent(null, obj, this));
}
}
public object Save(string entityName, object obj)
{
- using (new SessionIdLoggingContext(sessionId))
- {
- return FireSave(new SaveOrUpdateEvent(entityName, obj, this));
- }
+ using (new SessionIdLoggingContext(sessionId))
+ {
+ return FireSave(new SaveOrUpdateEvent(entityName, obj, this));
+ }
}
/// <summary>
@@ -472,10 +479,10 @@
/// <param name="id"></param>
public void Save(object obj, object id)
{
- using (new SessionIdLoggingContext(sessionId))
- {
- FireSave(new SaveOrUpdateEvent(null, obj, id, this));
- }
+ using (new SessionIdLoggingContext(sessionId))
+ {
+ FireSave(new SaveOrUpdateEvent(null, obj, id, this));
+ }
}
/// <summary>
@@ -484,59 +491,59 @@
/// <param name="obj"></param>
public void Delete(object obj)
{
- using (new SessionIdLoggingContext(sessionId))
- {
- FireDelete(new DeleteEvent(obj, this));
- }
+ using (new SessionIdLoggingContext(sessionId))
+ {
+ FireDelete(new DeleteEvent(obj, this));
+ }
}
/// <summary> Delete a persistent object (by explicit entity name)</summary>
public void Delete(string entityName, object obj)
{
- using (new SessionIdLoggingContext(sessionId))
- {
- FireDelete(new DeleteEvent(entityName, obj, this));
- }
+ using (new SessionIdLoggingContext(sessionId))
+ {
+ FireDelete(new DeleteEvent(entityName, obj, this));
+ }
}
public void Update(object obj)
{
- using (new SessionIdLoggingContext(sessionId))
- {
- FireUpdate(new SaveOrUpdateEvent(null, obj, this));
- }
+ using (new SessionIdLoggingContext(sessionId))
+ {
+ FireUpdate(new SaveOrUpdateEvent(null, obj, this));
+ }
}
public void Update(string entityName, object obj)
{
- using (new SessionIdLoggingContext(sessionId))
- {
- FireUpdate(new SaveOrUpdateEvent(entityName, obj, this));
- }
+ using (new SessionIdLoggingContext(sessionId))
+ {
+ FireUpdate(new SaveOrUpdateEvent(entityName, obj, this));
+ }
}
public void SaveOrUpdate(object obj)
{
- using (new SessionIdLoggingContext(sessionId))
- {
- FireSaveOrUpdate(new SaveOrUpdateEvent(null, obj, this));
- }
+ using (new SessionIdLoggingContext(sessionId))
+ {
+ FireSaveOrUpdate(new SaveOrUpdateEvent(null, obj, this));
+ }
}
public void SaveOrUpdate(string entityName, object obj)
{
- using (new SessionIdLoggingContext(sessionId))
- {
- FireSaveOrUpdate(new SaveOrUpdateEvent(entityName, obj, this));
- }
+ using (new SessionIdLoggingContext(sessionId))
+ {
+ FireSaveOrUpdate(new SaveOrUpdateEvent(entityName, obj, this));
+ }
}
public void Update(object obj, object id)
{
- using (new SessionIdLoggingContext(sessionId))
- {
- FireUpdate(new SaveOrUpdateEvent(null, obj, id, this));
- }
+ using (new SessionIdLoggingContext(sessionId))
+ {
+ FireUpdate(new SaveOrUpdateEvent(null, obj, id, this));
+ }
}
private static readonly object[] NoArgs = new object[0];
@@ -549,219 +556,219 @@
/// <returns></returns>
public IList Find(string query)
{
- using (new SessionIdLoggingContext(sessionId))
- {
- return List(query, new QueryParameters());
- }
+ using (new SessionIdLoggingContext(sessionId))
+ {
+ return List(query, new QueryParameters());
+ }
}
public IList Find(string query, object value, IType type)
{
- using (new SessionIdLoggingContext(sessionId))
- {
- return List(query, new QueryParameters(type, value));
- }
+ using (new SessionIdLoggingContext(sessionId))
+ {
+ return List(query, new QueryParameters(type, value));
+ }
}
public IList Find(string query, object[] values, IType[] types)
{
- using (new SessionIdLoggingContext(sessionId))
- {
- return List(query, new QueryParameters(types, values));
- }
+ using (new SessionIdLoggingContext(sessionId))
+ {
+ return List(query, new QueryParameters(types, values));
+ }
}
public override IList List(string query, QueryParameters parameters)
{
- using (new SessionIdLoggingContext(sessionId))
- {
- IList results = new ArrayList();
- List(query, parameters, results);
- return results;
- }
+ using (new SessionIdLoggingContext(sessionId))
+ {
+ IList results = new ArrayList();
+ List(query, parameters, results);
+ return results;
+ }
}
public override IList<T> List<T>(string query, QueryParameters parameters)
{
- using (new SessionIdLoggingContext(sessionId))
- {
- List<T> results = new List<T>();
- List(query, parameters, results);
- return results;
- }
+ using (new SessionIdLoggingContext(sessionId))
+ {
+ List<T> results = new List<T>();
+ List(query, parameters, results);
+ return results;
+ }
}
- public override void List(string query, QueryParameters queryParameters, IList results)
- {
- using (new SessionIdLoggingContext(sessionId))
- {
- CheckAndUpdateSessionStatus();
- queryParameters.ValidateParameters();
- HQLQueryPlan plan = GetHQLQueryPlan(query, false);
- AutoFlushIfRequired(plan.QuerySpaces);
+ public override void List(string query, QueryParameters queryParameters, IList results)
+ {
+ using (new SessionIdLoggingContext(sessionId))
+ {
+ CheckAndUpdateSessionStatus();
+ queryParameters.ValidateParameters();
+ HQLQueryPlan plan = GetHQLQueryPlan(query, false);
+ AutoFlushIfRequired(plan.QuerySpaces);
- bool success = false;
- dontFlushFromFind++; //stops flush being called multiple times if this method is recursively called
- try
- {
- plan.PerformList(queryParameters, this, results);
- success = true;
- }
- catch (HibernateException)
- {
- // Do not call Convert on HibernateExceptions
- throw;
- }
- catch (Exception e)
- {
- throw Convert(e, "Could not execute query");
- }
- finally
- {
- dontFlushFromFind--;
- AfterOperation(success);
- }
- }
- }
+ bool success = false;
+ dontFlushFromFind++; //stops flush being called multiple times if this method is recursively called
+ try
+ {
+ plan.PerformList(queryParameters, this, results);
+ success = true;
+ }
+ catch (HibernateException)
+ {
+ // Do not call Convert on HibernateExceptions
+ throw;
+ }
+ catch (Exception e)
+ {
+ throw Convert(e, "Could not execute query");
+ }
+ finally
+ {
+ dontFlushFromFind--;
+ AfterOperation(success);
+ }
+ }
+ }
- public override IQueryTranslator[] GetQueries(string query, bool scalar)
+ public override IQueryTranslator[] GetQueries(string query, bool scalar)
{
- using (new SessionIdLoggingContext(sessionId))
- {
- HQLQueryPlan plan = Factory.QueryPlanCache.GetHQLQueryPlan(query, scalar, enabledFilters);
- AutoFlushIfRequired(plan.QuerySpaces);
- return plan.Translators;
- }
+ using (new SessionIdLoggingContext(sessionId))
+ {
+ HQLQueryPlan plan = Factory.QueryP...
[truncated message content] |