public virtual IList List(CriteriaImpl criteria)
 {
     using (new SessionIdLoggingContext(SessionId))
     {
         var results = new List <object>();
         List(criteria, results);
         return(results);
     }
 }
Exemplo n.º 2
0
 public virtual async Task <IList> ListAsync(CriteriaImpl criteria, CancellationToken cancellationToken)
 {
     cancellationToken.ThrowIfCancellationRequested();
     using (new SessionIdLoggingContext(SessionId))
     {
         var results = new List <object>();
         await(ListAsync(criteria, results, cancellationToken)).ConfigureAwait(false);
         return(results);
     }
 }
Exemplo n.º 3
0
 public override IList List(CriteriaImpl criteria)
 {
     using (new SessionIdLoggingContext(SessionId))
     {
         // TODO pull up
         ArrayList results = new ArrayList();
         List(criteria, results);
         return(results);
     }
 }
Exemplo n.º 4
0
 public override IList <T> List <T>(CriteriaImpl criteria)
 {
     using (new SessionIdLoggingContext(SessionId))
     {
         // TODO pull up
         List <T> results = new List <T>();
         List(criteria, results);
         return(results);
     }
 }
Exemplo n.º 5
0
 public virtual async Task <IList <T> > ListAsync <T>(CriteriaImpl criteria, CancellationToken cancellationToken)
 {
     cancellationToken.ThrowIfCancellationRequested();
     using (BeginProcess())
     {
         var results = new List <T>();
         await(ListAsync(criteria, results, cancellationToken)).ConfigureAwait(false);
         return(results);
     }
 }
Exemplo n.º 6
0
        ��������public object Clone()
        ��������
        {
            ������������CriteriaImpl clone;

            ������������if(persistentClass != null)
            ������������ {
                ����������������clone = new CriteriaImpl(persistentClass, Alias, Session);
                ������������
            }
            ������������else
            ������������ {
                ����������������clone = new CriteriaImpl(entityOrClassName, Alias, Session);
                ������������
            }
            ������������CloneSubcriteria(clone);
            ������������foreach(KeyValuePair <string, FetchMode> de in fetchModes)
            ������������ {
                ����������������clone.fetchModes.Add(de.Key, de.Value);
                ������������
            }
            ������������foreach(KeyValuePair <string, LockMode> de in lockModes)
            ������������ {
                ����������������clone.lockModes.Add(de.Key, de.Value);
                ������������
            }
            ������������clone.maxResults  = maxResults;
            ������������clone.firstResult = firstResult;
            ������������clone.timeout     = timeout;
            ������������clone.fetchSize   = fetchSize;
            ������������clone.cacheable   = cacheable;
            ������������clone.cacheRegion = cacheRegion;
            ������������clone.SetProjection(projection);
            ������������CloneProjectCrtieria(clone);
            ������������clone.SetResultTransformer(resultTransformer);
            ������������clone.comment = comment;
            ������������if(flushMode.HasValue)
            ������������ {
                ����������������clone.SetFlushMode(flushMode.Value);
                ������������
            }
            ������������if(cacheMode.HasValue)
            ������������ {
                ����������������clone.SetCacheMode(cacheMode.Value);
                ������������
            }
            ������������return clone;

            ��������
        }
Exemplo n.º 7
0
            internal Subcriteria(CriteriaImpl root, ICriteria parent, string path, string alias, JoinType joinType, ICriterion withClause)
            {
                this.root       = root;
                this.parent     = parent;
                this.alias      = alias;
                this.path       = path;
                this.joinType   = joinType;
                this.withClause = withClause;

                root.subcriteriaList.Add(this);

                root.subcriteriaByPath[path] = this;
                SetAlias(alias);
            }
Exemplo n.º 8
0
 private void CloneProjectCrtieria(CriteriaImpl clone)
 {
     if (projectionCriteria != null)
     {
         if (projectionCriteria == this)
         {
             clone.projectionCriteria = clone;
         }
         else
         {
             ICriteria clonedProjectionCriteria = (ICriteria)projectionCriteria.Clone();
             clone.projectionCriteria = clonedProjectionCriteria;
         }
     }
 }
Exemplo n.º 9
0
            internal Subcriteria(CriteriaImpl root, ICriteria parent, string path, string alias, JoinType joinType, ICriterion withClause, string joinEntityName = null)
            {
                this.root       = root;
                this.parent     = parent;
                this.alias      = alias;
                this.path       = path;
                this.joinType   = joinType;
                this.withClause = withClause;
                JoinEntityName  = joinEntityName;
                hasRestrictions = withClause != null;

                root.subcriteriaList.Add(this);

                root.subcriteriaByPath[path] = this;
                SetAlias(alias);
            }
Exemplo n.º 10
0
            internal Subcriteria(CriteriaImpl root, ICriteria parent, string path, string alias, JoinType joinType)
            {
                this.root     = root;
                this.parent   = parent;
                this.alias    = alias;
                this.path     = path;
                this.joinType = joinType;

                root.subcriteriaList.Add(this);

                root.subcriteriaByPath[path] = this;
                if (alias != null)
                {
                    root.subcriteriaByAlias[alias] = this;
                }
            }
Exemplo n.º 11
0
        private void CloneSubcriteria(CriteriaImpl clone)
        {
            //we need to preserve the parent criteria, we rely on the ordering when creating the
            //subcriterias initially here, so we don't need to make more than a single pass
            Dictionary <ICriteria, ICriteria> newParents = new Dictionary <ICriteria, ICriteria>();

            newParents[this] = clone;

            foreach (Subcriteria subcriteria in IterateSubcriteria())
            {
                ICriteria currentParent;
                if (!newParents.TryGetValue(subcriteria.Parent, out currentParent))
                {
                    throw new AssertionFailure(
                              "Could not find parent for subcriteria in the previous subcriteria. If you see this error, it is a bug");
                }
                Subcriteria clonedSubCriteria =
                    new Subcriteria(clone, currentParent, subcriteria.Path, subcriteria.Alias, subcriteria.JoinType);
                clonedSubCriteria.SetLockMode(subcriteria.LockMode);
                newParents[subcriteria] = clonedSubCriteria;
            }

            // remap the orders
            foreach (OrderEntry orderEntry in IterateOrderings())
            {
                ICriteria currentParent;
                if (!newParents.TryGetValue(orderEntry.Criteria, out currentParent))
                {
                    throw new AssertionFailure(
                              "Could not find parent for order in the previous criteria. If you see this error, it is a bug");
                }
                currentParent.AddOrder(orderEntry.Order);
            }

            // remap the restrictions to appropriate criterias
            foreach (CriterionEntry criterionEntry in criteria)
            {
                ICriteria currentParent;
                if (!newParents.TryGetValue(criterionEntry.Criteria, out currentParent))
                {
                    throw new AssertionFailure(
                              "Could not find parent for restriction in the previous criteria. If you see this error, it is a bug.");
                }

                currentParent.Add(criterionEntry.Criterion);
            }
        }
Exemplo n.º 12
0
        public override async Task <IList <T> > ListAsync <T>(CriteriaImpl criteria, CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();
            using (BeginProcess())
            {
                // We need to flush the batcher. Otherwise it may have pending operations which will not already have reached the database,
                // and the query may yield stale data.
                await(FlushAsync(cancellationToken)).ConfigureAwait(false);

                string[] implementors = Factory.GetImplementors(criteria.EntityOrClassName);
                int      size         = implementors.Length;

                CriteriaLoader[] loaders = new CriteriaLoader[size];
                for (int i = 0; i < size; i++)
                {
                    loaders[size - 1 - i] = new CriteriaLoader(GetOuterJoinLoadable(implementors[i]), Factory,
                                                               criteria, implementors[i], EnabledFilters);
                }

                bool success = false;
                try
                {
                    var results = await(loaders.LoadAllToListAsync <T>(this, cancellationToken)).ConfigureAwait(false);
                    success = true;
                    return(results);
                }
                catch (OperationCanceledException) { throw; }
                catch (HibernateException)
                {
                    // Do not call Convert on HibernateExceptions
                    throw;
                }
                catch (Exception sqle)
                {
                    throw Convert(sqle, "Unable to perform find");
                }
                finally
                {
                    await(AfterOperationAsync(success, cancellationToken)).ConfigureAwait(false);
                    temporaryPersistenceContext.Clear();
                }
            }
        }
Exemplo n.º 13
0
        public object Clone()
        {
            CriteriaImpl clone;

            if (persistentClass != null)
            {
                clone = new CriteriaImpl(persistentClass, Alias, Session);
            }
            else
            {
                clone = new CriteriaImpl(entityOrClassName, Alias, Session);
            }
            CloneSubcriteria(clone);
            foreach (KeyValuePair <string, FetchMode> de in fetchModes)
            {
                clone.fetchModes.Add(de.Key, de.Value);
            }
            foreach (KeyValuePair <string, LockMode> de in lockModes)
            {
                clone.lockModes.Add(de.Key, de.Value);
            }
            clone.maxResults  = maxResults;
            clone.firstResult = firstResult;
            clone.timeout     = timeout;
            clone.fetchSize   = fetchSize;
            clone.cacheable   = cacheable;
            clone.cacheRegion = cacheRegion;
            clone.SetProjection(projection);
            CloneProjectCrtieria(clone);
            clone.SetResultTransformer(resultTransformer);
            clone.comment  = comment;
            clone.readOnly = readOnly;
            if (flushMode.HasValue)
            {
                clone.SetFlushMode(flushMode.Value);
            }
            if (cacheMode.HasValue)
            {
                clone.SetCacheMode(cacheMode.Value);
            }
            return(clone);
        }
Exemplo n.º 14
0
        public override async Task ListAsync(CriteriaImpl criteria, IList results, CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();
            using (new SessionIdLoggingContext(SessionId))
            {
                CheckAndUpdateSessionStatus();
                string[] implementors = Factory.GetImplementors(criteria.EntityOrClassName);
                int      size         = implementors.Length;

                CriteriaLoader[] loaders = new CriteriaLoader[size];
                for (int i = 0; i < size; i++)
                {
                    loaders[i] = new CriteriaLoader(GetOuterJoinLoadable(implementors[i]), Factory,
                                                    criteria, implementors[i], EnabledFilters);
                }

                bool success = false;
                try
                {
                    for (int i = size - 1; i >= 0; i--)
                    {
                        ArrayHelper.AddAll(results, await(loaders[i].ListAsync(this, cancellationToken)).ConfigureAwait(false));
                    }
                    success = true;
                }
                catch (HibernateException)
                {
                    // Do not call Convert on HibernateExceptions
                    throw;
                }
                catch (Exception sqle)
                {
                    throw Convert(sqle, "Unable to perform find");
                }
                finally
                {
                    await(AfterOperationAsync(success, cancellationToken)).ConfigureAwait(false);
                }
                temporaryPersistenceContext.Clear();
            }
        }
Exemplo n.º 15
0
        ��������private void CloneProjectCrtieria(CriteriaImpl clone)
        ��������
        {
            ������������if(projectionCriteria != null)
            ������������ {
                ����������������if(projectionCriteria == this)
                ���������������� {
                    ��������������������clone.projectionCriteria = clone;
                    ����������������
                }
                ����������������else
                ���������������� {
                    ��������������������ICriteria clonedProjectionCriteria = (ICriteria)projectionCriteria.Clone();

                    ��������������������clone.projectionCriteria = clonedProjectionCriteria;
                    ����������������
                }
                ������������
            }
            ��������
        }
Exemplo n.º 16
0
            ������������internal Subcriteria(CriteriaImpl root, ICriteria parent, string path, string alias, JoinType joinType, ICriterion withClause)
            ������������
            {
                ����������������this.root       = root;
                ����������������this.parent     = parent;
                ����������������this.alias      = alias;
                ����������������this.path       = path;
                ����������������this.joinType   = joinType;
                ����������������this.withClause = withClause;
                �
                ����������������root.subcriteriaList.Add(this);

                �
                ����������������root.subcriteriaByPath[path] = this;

                ����������������if(alias != null)
                ���������������� {
                    ��������������������root.subcriteriaByAlias[alias] = this;
                    ����������������
                }
                ������������
            }
Exemplo n.º 17
0
        public override void List(CriteriaImpl criteria, IList results)
        {
            using (BeginProcess())
            {
                string[] implementors = Factory.GetImplementors(criteria.EntityOrClassName);
                int      size         = implementors.Length;

                CriteriaLoader[] loaders = new CriteriaLoader[size];
                for (int i = 0; i < size; i++)
                {
                    loaders[i] = new CriteriaLoader(GetOuterJoinLoadable(implementors[i]), Factory,
                                                    criteria, implementors[i], EnabledFilters);
                }

                bool success = false;
                try
                {
                    for (int i = size - 1; i >= 0; i--)
                    {
                        ArrayHelper.AddAll(results, loaders[i].List(this));
                    }
                    success = true;
                }
                catch (HibernateException)
                {
                    // Do not call Convert on HibernateExceptions
                    throw;
                }
                catch (Exception sqle)
                {
                    throw Convert(sqle, "Unable to perform find");
                }
                finally
                {
                    AfterOperation(success);
                }
                temporaryPersistenceContext.Clear();
            }
        }
Exemplo n.º 18
0
 protected virtual IList GetResultList(IList results)
 {
     if (resultTransformer != null)
     {
         for (int i = 0; i < results.Count; i++)
         {
             results[i] = resultTransformer.TransformList((IList)results[i]);
         }
     }
     else
     {
         for (int i = 0; i < results.Count; i++)
         {
             CriteriaImpl critImp = criteriaQueries[i] as CriteriaImpl;
             if (critImp == null || critImp.ResultTransformer == null)
             {
                 continue;
             }
             results[i] = critImp.ResultTransformer.TransformList((IList)results[i]);
         }
     }
     return(results);
 }
Exemplo n.º 19
0
        /// <summary>
        /// Copy all the internal attributes of the given CriteriaImpl
        /// except alter the root persistent class type to be the given one.
        /// </summary>
        /// <param name="persistentClass"></param>
        /// <param name="original"></param>
        public CriteriaImpl(System.Type persistentClass, CriteriaImpl original)
        {
            this.persistentClass = persistentClass;

            this.classByAlias = original.classByAlias;
            this.classByAlias[CriteriaUtil.RootAlias] = persistentClass;

            this.criteria               = original.criteria;
            this.orderings              = original.orderings;
            this.fetchModes             = original.fetchModes;
            this.associationPathByAlias = original.associationPathByAlias;
            this.aliasByAssociationPath = original.aliasByAssociationPath;
            this.lockModes              = original.lockModes;
            this.maxResults             = original.maxResults;
            this.firstResult            = original.firstResult;
            this.timeout           = original.timeout;
            this.fetchSize         = original.fetchSize;
            this.session           = original.session;
            this.resultTransformer = original.resultTransformer;
            this.counter           = original.counter;
            this.cacheable         = original.cacheable;
            this.cacheRegion       = original.cacheRegion;
        }
Exemplo n.º 20
0
 ������������internal Subcriteria(CriteriaImpl root, ICriteria parent, string path, JoinType joinType)
 ���������������� : this(root, parent, path, null, joinType)
 {
 }
Exemplo n.º 21
0
 public override IList <T> List <T>(CriteriaImpl criteria);
Exemplo n.º 22
0
 public abstract Task ListAsync(CriteriaImpl criteria, IList results, CancellationToken cancellationToken);
Exemplo n.º 23
0
        //{
        //	ArrayHelper.AddAll(results, List(criteria));
        //}

        public virtual async Task <IList> ListAsync(CriteriaImpl criteria, CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();
            return((await(ListAsync <object>(criteria, cancellationToken)).ConfigureAwait(false)).ToIList());
        }
Exemplo n.º 24
0
 internal Subcriteria(CriteriaImpl root, ICriteria parent, string path, string alias, JoinType joinType)
     : this(root, parent, path, alias, joinType, null)
 {
 }
Exemplo n.º 25
0
 public override IList List(CriteriaImpl criteria);
Exemplo n.º 26
0
 internal Subcriteria(CriteriaImpl parent, string rootAlias, string rootPath)
 {
     this.parent    = parent;
     this.rootAlias = rootAlias;
     this.rootPath  = rootPath;
 }
Exemplo n.º 27
0
 public override void List(CriteriaImpl criteria, IList results);
Exemplo n.º 28
0
 //TODO 6.0: Remove (use base class implementation)
 public override async Task ListAsync(CriteriaImpl criteria, IList results, CancellationToken cancellationToken)
 {
     cancellationToken.ThrowIfCancellationRequested();
     ArrayHelper.AddAll(results, await(ListAsync(criteria, cancellationToken)).ConfigureAwait(false));
 }
Exemplo n.º 29
0
 //TODO 6.0: Remove (use base class implementation)
 public override void List(CriteriaImpl criteria, IList results)
 {
     ArrayHelper.AddAll(results, List(criteria));
 }
 public abstract void List(CriteriaImpl criteria, IList results);