예제 #1
0
 public override System.Collections.Generic.IList <T> GetValueList <T>(int index) /* throws Net.Vpc.Upa.Exceptions.UPAException */
 {
     if (!context.GetPersistenceUnit().GetPersistenceGroup().CurrentSessionExists())
     {
         if (sessionAwareInstance == null)
         {
             sessionAwareInstance = context.GetPersistenceUnit().GetPersistenceGroup().GetContext().MakeSessionAware <Net.Vpc.Upa.Impl.Persistence.DefaultQuery>(this);
         }
         return(sessionAwareInstance.GetValueList <T>(index));
     }
     try {
         Net.Vpc.Upa.Impl.Persistence.QueryExecutor queryExecutor = ExecuteQuery(Net.Vpc.Upa.Impl.Util.Filters.Fields2.READ);
         if (index < 0 || index > (queryExecutor.GetMetaData().GetFields()).Count)
         {
             throw new System.IndexOutOfRangeException("Invalid index " + index);
         }
         Net.Vpc.Upa.Impl.Persistence.ValueList <T> r = new Net.Vpc.Upa.Impl.Persistence.ValueList <T>(queryExecutor, index);
         allResults.Add(r);
         if (!IsLazyListLoadingEnabled())
         {
             //force loading
             r.LoadAll();
         }
         return(r);
     } catch (System.Exception e) {
         throw new Net.Vpc.Upa.Exceptions.FindException(e, new Net.Vpc.Upa.Types.I18NString("FindFailed"));
     }
 }
예제 #2
0
 public override System.Collections.Generic.IList <K2> GetIdList <K2>() /* throws Net.Vpc.Upa.Exceptions.UPAException */
 {
     if (!context.GetPersistenceUnit().GetPersistenceGroup().CurrentSessionExists())
     {
         if (sessionAwareInstance == null)
         {
             sessionAwareInstance = context.GetPersistenceUnit().GetPersistenceGroup().GetContext().MakeSessionAware <Net.Vpc.Upa.Impl.Persistence.DefaultQuery>(this);
         }
         return(sessionAwareInstance.GetIdList <K2>());
     }
     try {
         if ((query is Net.Vpc.Upa.Expressions.QueryStatement))
         {
             Net.Vpc.Upa.Entity entity = ResolveDefaultEntity();
             if (entity != null)
             {
                 Net.Vpc.Upa.Impl.Persistence.QueryExecutor            queryExecutor = ExecuteQuery(Net.Vpc.Upa.Filters.Fields.Id());
                 Net.Vpc.Upa.Impl.Persistence.SingleEntityKeyList <K2> r             = new Net.Vpc.Upa.Impl.Persistence.SingleEntityKeyList <K2>(queryExecutor, entity);
                 allResults.Add(r);
                 if (!IsLazyListLoadingEnabled())
                 {
                     //force loading
                     r.LoadAll();
                 }
                 return(r);
             }
         }
     } catch (System.Exception e) {
         throw new Net.Vpc.Upa.Exceptions.FindException(e, new Net.Vpc.Upa.Types.I18NString("FindFailed"));
     }
     throw new Net.Vpc.Upa.Exceptions.FindException(new Net.Vpc.Upa.Types.I18NString("InvalidQuery"));
 }
예제 #3
0
 public override bool IsEmpty() /* throws Net.Vpc.Upa.Exceptions.UPAException */
 {
     if (!context.GetPersistenceUnit().GetPersistenceGroup().CurrentSessionExists())
     {
         if (sessionAwareInstance == null)
         {
             sessionAwareInstance = context.GetPersistenceUnit().GetPersistenceGroup().GetContext().MakeSessionAware <Net.Vpc.Upa.Impl.Persistence.DefaultQuery>(this);
         }
         return(sessionAwareInstance.IsEmpty());
     }
     try {
         Net.Vpc.Upa.Impl.Persistence.QueryExecutor queryExecutor = ExecuteQuery(Net.Vpc.Upa.Impl.Util.Filters.Fields2.READ);
         Net.Vpc.Upa.Persistence.QueryResult        r             = null;
         try {
             r = queryExecutor.GetQueryResult();
             return(!r.HasNext());
         } finally {
             if (r != null)
             {
                 r.Close();
             }
         }
     } catch (System.Exception e) {
         throw new Net.Vpc.Upa.Exceptions.FindException(e, new Net.Vpc.Upa.Types.I18NString("FindFailed"));
     }
 }
예제 #4
0
 public override int ExecuteNonQuery()
 {
     if (!context.GetPersistenceUnit().GetPersistenceGroup().CurrentSessionExists())
     {
         if (sessionAwareInstance == null)
         {
             sessionAwareInstance = context.GetPersistenceUnit().GetPersistenceGroup().GetContext().MakeSessionAware <Net.Vpc.Upa.Impl.Persistence.DefaultQuery>(this);
         }
         return(sessionAwareInstance.ExecuteNonQuery());
     }
     //
     Net.Vpc.Upa.Impl.Persistence.QueryExecutor queryExecutor = CreateNativeSQL(null);
     return(queryExecutor.Execute().GetResultCount());
 }
예제 #5
0
        public virtual System.Collections.Generic.IList <T> GetResultList <T>(Net.Vpc.Upa.Impl.Persistence.Result.QueryResultItemBuilder builder) /* throws Net.Vpc.Upa.Exceptions.UPAException */
        {
            if (!context.GetPersistenceUnit().GetPersistenceGroup().CurrentSessionExists())
            {
                if (sessionAwareInstance == null)
                {
                    sessionAwareInstance = context.GetPersistenceUnit().GetPersistenceGroup().GetContext().MakeSessionAware <Net.Vpc.Upa.Impl.Persistence.DefaultQuery>(this);
                }
                return(sessionAwareInstance.GetResultList <T>(builder));
            }
            try {
                Net.Vpc.Upa.Impl.Persistence.QueryExecutor queryExecutor = ExecuteQuery(Net.Vpc.Upa.Impl.Util.Filters.Fields2.READ);
                Net.Vpc.Upa.QueryFetchStrategy             fetchStrategy = (Net.Vpc.Upa.QueryFetchStrategy)Net.Vpc.Upa.Impl.FwkConvertUtils.GetMapValue <string, object>(queryExecutor.GetHints(), Net.Vpc.Upa.QueryHints.FETCH_STRATEGY);
                if (fetchStrategy == default(Net.Vpc.Upa.QueryFetchStrategy))
                {
                    fetchStrategy = Net.Vpc.Upa.QueryFetchStrategy.JOIN;
                }
                bool itemAsRecord     = builder is Net.Vpc.Upa.Impl.Persistence.Result.RecordQueryResultItemBuilder;
                bool relationAsRecord = false;
                bool supportCache     = false;
                Net.Vpc.Upa.Impl.Persistence.Result.QueryResultRelationLoader loader = null;
                switch (fetchStrategy)
                {
                case Net.Vpc.Upa.QueryFetchStrategy.JOIN:
                {
                    break;
                }

                case Net.Vpc.Upa.QueryFetchStrategy.SELECT:
                {
                    supportCache = true;
                    loader       = new Net.Vpc.Upa.Impl.Persistence.Result.QueryRelationLoaderSelectObject();
                    break;
                }
                }
                Net.Vpc.Upa.Impl.Persistence.QueryResultLazyList <T> r = new Net.Vpc.Upa.Impl.Persistence.Result.DefaultObjectQueryResultLazyList <T>(queryExecutor, fetchStrategy != Net.Vpc.Upa.QueryFetchStrategy.JOIN, itemAsRecord, relationAsRecord, supportCache, IsUpdatable(), loader, builder);
                allResults.Add(r);
                if (!IsLazyListLoadingEnabled())
                {
                    //force loading
                    r.LoadAll();
                }
                return(r);
            } catch (System.Exception e) {
                throw new Net.Vpc.Upa.Exceptions.FindException(e, new Net.Vpc.Upa.Types.I18NString("FindFailed"));
            }
        }
예제 #6
0
 public override System.Collections.Generic.IList <Net.Vpc.Upa.Key> GetKeyList() /* throws Net.Vpc.Upa.Exceptions.UPAException */
 {
     if (!context.GetPersistenceUnit().GetPersistenceGroup().CurrentSessionExists())
     {
         if (sessionAwareInstance == null)
         {
             sessionAwareInstance = context.GetPersistenceUnit().GetPersistenceGroup().GetContext().MakeSessionAware <Net.Vpc.Upa.Impl.Persistence.DefaultQuery>(this);
         }
         return(sessionAwareInstance.GetKeyList());
     }
     if ((query is Net.Vpc.Upa.Expressions.QueryStatement))
     {
         Net.Vpc.Upa.Entity entity = ResolveDefaultEntity();
         if (entity != null)
         {
             Net.Vpc.Upa.Impl.Util.ConvertedList <object, Net.Vpc.Upa.Key> r = new Net.Vpc.Upa.Impl.Util.ConvertedList <object, Net.Vpc.Upa.Key>(GetIdList <K2>(), new Net.Vpc.Upa.Impl.IdToKeyConverter <object>(entity));
             allResults.Add(r);
             return(r);
         }
     }
     throw new Net.Vpc.Upa.Exceptions.FindException(new Net.Vpc.Upa.Types.I18NString("InvalidQuery"));
 }
예제 #7
0
 public override System.Collections.Generic.IList <T> GetValueList <T>(string name) /* throws Net.Vpc.Upa.Exceptions.UPAException */
 {
     if (!context.GetPersistenceUnit().GetPersistenceGroup().CurrentSessionExists())
     {
         if (sessionAwareInstance == null)
         {
             sessionAwareInstance = context.GetPersistenceUnit().GetPersistenceGroup().GetContext().MakeSessionAware <Net.Vpc.Upa.Impl.Persistence.DefaultQuery>(this);
         }
         return(sessionAwareInstance.GetValueList <T>(name));
     }
     try {
         Net.Vpc.Upa.Impl.Persistence.QueryExecutor queryExecutor = ExecuteQuery(Net.Vpc.Upa.Impl.Util.Filters.Fields2.READ);
         System.Collections.Generic.IList <Net.Vpc.Upa.Persistence.ResultField> ne = queryExecutor.GetMetaData().GetFields();
         int index = -1;
         for (int i = 0; i < (ne).Count; i++)
         {
             if (name.Equals(ne[i].GetAlias()))
             {
                 index = i;
                 break;
             }
         }
         if (index < 0)
         {
             throw new System.Exception("Field " + name + " not found");
         }
         Net.Vpc.Upa.Impl.Persistence.ValueList <T> r = new Net.Vpc.Upa.Impl.Persistence.ValueList <T>(queryExecutor, index);
         if (!IsLazyListLoadingEnabled())
         {
             //force loading
             r.LoadAll();
         }
         allResults.Add(r);
         return(r);
     } catch (System.Exception e) {
         throw new Net.Vpc.Upa.Exceptions.FindException(e, new Net.Vpc.Upa.Types.I18NString("FindFailed"));
     }
 }
예제 #8
0
 public override System.Collections.Generic.IList <T> GetTypeList <T>(System.Type type, params string [] fields) /* throws Net.Vpc.Upa.Exceptions.UPAException */
 {
     if (!context.GetPersistenceUnit().GetPersistenceGroup().CurrentSessionExists())
     {
         if (sessionAwareInstance == null)
         {
             sessionAwareInstance = context.GetPersistenceUnit().GetPersistenceGroup().GetContext().MakeSessionAware <Net.Vpc.Upa.Impl.Persistence.DefaultQuery>(this);
         }
         return(sessionAwareInstance.GetTypeList <T>(type, fields));
     }
     try {
         Net.Vpc.Upa.Impl.Persistence.QueryExecutor queryExecutor = ExecuteQuery(Net.Vpc.Upa.Impl.Util.Filters.Fields2.READ);
         Net.Vpc.Upa.Impl.Persistence.TypeList <T>  r             = new Net.Vpc.Upa.Impl.Persistence.TypeList <T>(queryExecutor, type, fields);
         allResults.Add(r);
         if (!IsLazyListLoadingEnabled())
         {
             //force loading
             r.LoadAll();
         }
         return(r);
     } catch (System.Exception e) {
         throw new Net.Vpc.Upa.Exceptions.FindException(e, new Net.Vpc.Upa.Types.I18NString("FindFailed"));
     }
 }