/// <summary>
        /// Id가 <paramref name="id"/>인 엔티티를 조회합니다.
        /// </summary>
        public static T GetStateless <T>(object id, LockMode lockMode, ISession session) where T : IDataObject
        {
            var entity = default(T);

            NHWith.StatelessSessionNoTransaction(session,
                                                 stateless => entity = stateless.Get <T>(id, lockMode));
            return(entity);
        }
        /// <summary>
        /// Id가 <paramref name="id"/>인 엔티티를 조회합니다.
        /// </summary>
        public static T GetStateless <T>(object id, LockMode lockMode) where T : IDataObject
        {
            id.ShouldNotBeNull("id");

            var entity = default(T);

            NHWith.StatelessSessionNoTransaction(stateless => entity = stateless.Get <T>(id, lockMode));
            return(entity);
        }
        /// <summary>
        /// Id가 <paramref name="id"/>인 엔티티를 조회합니다.
        /// </summary>
        public static T GetStateless <T>(object id, ISession session) where T : IDataObject
        {
            id.ShouldNotBeNull("id");
            session.ShouldNotBeNull("session");

            var entity = default(T);

            NHWith.StatelessSessionNoTransaction(session, stateless => entity = stateless.Get <T>(id));

            return(entity);
        }
        /// <summary>
        /// Stateless Session 을 이용하여, <paramref name="criteria"/>에 해당하는 Entity를 조회합니다.
        /// </summary>
        public static IList <T> FindAllStateless <T>(this DetachedCriteria criteria, ISession session) where T : IDataObject
        {
            criteria.ShouldNotBeNull("criteria");
            criteria.ShouldNotBeNull("session");

            IList <T> result = null;

            NHWith.StatelessSessionNoTransaction(session,
                                                 stateless => { result = criteria.GetExecutableCriteria(stateless).List <T>(); });
            return(result ?? new List <T>());
        }
        /// <summary>
        /// 엔티티 컬렉션을 StatelessSession을 이용하여 Insert 합니다.
        /// </summary>
        /// <typeparam name="T">type of entity to insert</typeparam>
        /// <param name="entities">collection of entity to insert</param>
        /// <param name="session">nhibernate session</param>
        public static void InsertStateless <T>(this IEnumerable <T> entities, ISession session) where T : IDataObject
        {
            if (entities.ItemExists() == false)
            {
                return;
            }

            session.ShouldNotBeNull("session");

            if (IsDebugEnabled)
            {
                log.Debug("엔티티 컬렉션을 Stateless Session에서 Insert 합니다... entities=[{0}], session=[{1}]", entities, session);
            }

            NHWith.StatelessSessionNoTransaction(session,
                                                 stateless => entities.RunEach <T>(entity => stateless.Insert(entity)));
        }
        /// <summary>
        /// <paramref name="criteria"/>에 해당하는 엔티티가 존재하는지 검사합니다. 하나라도 있으면 True, 없으면 False
        /// </summary>
        public static bool ExistsStateless <T>(this DetachedCriteria criteria, ISession session) where T : IDataObject
        {
            criteria.ShouldNotBeNull("criteria");
            session.ShouldNotBeNull("session");

            var result = false;

            NHWith.StatelessSessionNoTransaction(session,
                                                 stateless => {
                result =
                    criteria
                    .SetMaxResults(1)
                    .GetExecutableCriteria(stateless)
                    .List <T>()
                    .Any();
            });

            return(result);
        }