/// <summary>
        /// Flushes the queue of stored attribute updates and commits the changes to the database
        /// </summary>
        private void CommitCurrentAttributeUpdates()
        {
            if (GlobalSession.IsOpen)
            {
                GlobalSession.Close();
            }

            using (IStatelessSession session = SessionFactory.OpenStatelessSession())
            {
                var transaction = session.BeginTransaction();
                foreach (KeyValuePair <Guid, Dictionary <string, object> > componentUpdate in ComponentAttributesToPersist)
                {
                    Guid componentGuid = componentUpdate.Key;
                    foreach (KeyValuePair <string, object> attributeUpdate in componentUpdate.Value)
                    {
                        String updateQuery = "update attributes_to_components set value = :newValue where componentID = :componentGuid AND attributeName = :attributeName";
                        IQuery sqlQuery    = session.CreateSQLQuery(updateQuery)
                                             .SetBinary("newValue", ObjectToByteArray(attributeUpdate.Value))
                                             .SetParameter("componentGuid", componentGuid)
                                             .SetParameter("attributeName", attributeUpdate.Key);
                        sqlQuery.ExecuteUpdate();
                    }
                }
                try
                {
                    transaction.Commit();
                }
                catch (Exception e)
                {
                    logger.WarnException("Failed to update Attribute", e);
                    transaction.Rollback();
                }
                finally
                {
                    session.Close();
                }
            }
        }
        /// <summary>
        /// Flushes the queue of stored entity updates and commits the changes to the database
        /// </summary>
        private void CommitCurrentEntityUpdates()
        {
            if (GlobalSession.IsOpen)
            {
                GlobalSession.Close();
            }

            using (ISession session = SessionFactory.OpenSession())
            {
                var transaction = session.BeginTransaction();
                foreach (Entity entity in EntitiesToPersist)
                {
                    try
                    {
                        session.SaveOrUpdate(entity);
                    }
                    catch (Exception e)
                    {
                        logger.LogException(LogLevel.Error, "Save or Update of Entity failed", e);
                    }
                }
                try
                {
                    transaction.Commit();
                }
                catch (Exception e)
                {
                    Console.WriteLine("Transaction to persist entities failed: " + e.Message);
                    transaction.Rollback();
                }
                finally
                {
                    session.Close();
                }
            }
        }