Example #1
0
        public override string GetSQL(object oo, Net.Vpc.Upa.Persistence.EntityExecutionContext context, Net.Vpc.Upa.Impl.Persistence.SQLManager sqlManager, Net.Vpc.Upa.Impl.Uql.ExpressionDeclarationList declarations) /* throws Net.Vpc.Upa.Exceptions.UPAException */
        {
            Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledEntityName o = (Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledEntityName)oo;
            Net.Vpc.Upa.Persistence.PersistenceStore persistenceStore    = context.GetPersistenceStore();
            string entityName = o.GetName();

            Net.Vpc.Upa.Entity e = context.GetPersistenceUnit().GetEntity(entityName);
            if (o.IsUseView() && e.NeedsView() && persistenceStore.IsViewSupported())
            {
                return(persistenceStore.GetValidIdentifier(persistenceStore.GetPersistenceName(e, Net.Vpc.Upa.Persistence.PersistenceNameType.IMPLICIT_VIEW)));
            }
            else
            {
                return(persistenceStore.GetValidIdentifier(persistenceStore.GetPersistenceName(e)));
            }
        }
Example #2
0
 protected internal virtual void AppendFrom(Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledSelect o, System.Text.StringBuilder sb, Net.Vpc.Upa.Persistence.EntityExecutionContext context, Net.Vpc.Upa.Impl.Persistence.SQLManager sqlManager, Net.Vpc.Upa.Impl.Uql.ExpressionDeclarationList declarations)
 {
     Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledNameOrSelect entity = o.GetEntity();
     if (entity == null)
     {
         string fns = GetFromNullString();
         if (fns != null)
         {
             sb.Append(" ");
             sb.Append(fns);
         }
     }
     else
     {
         sb.Append(" From ");
         if (entity is Net.Vpc.Upa.Expressions.Select)
         {
             sb.Append(sqlManager.GetSQL(entity, context, declarations));
         }
         else
         {
             Net.Vpc.Upa.Persistence.PersistenceStore persistenceStore             = context.GetPersistenceStore();
             Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledEntityName entityName = (Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledEntityName)entity;
             Net.Vpc.Upa.Entity e = context.GetPersistenceUnit().GetEntity(entityName.GetName());
             if (entityName.IsUseView() && e.NeedsView() && persistenceStore.IsViewSupported())
             {
                 Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledEntityName v = new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledEntityName(e.GetName(), true);
                 sb.Append(sqlManager.GetSQL(v, context, declarations));
             }
             else
             {
                 sb.Append(sqlManager.GetSQL(entityName, context, declarations));
             }
         }
     }
     if (o.GetEntityAlias() != null)
     {
         Net.Vpc.Upa.Persistence.PersistenceStore store = context.GetPersistenceStore();
         sb.Append(" ").Append(sqlManager.GetSQL(new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledVar(o.GetEntityAlias()), context, declarations));
     }
 }
Example #3
0
        public override string GetSQL(object oo, Net.Vpc.Upa.Persistence.EntityExecutionContext context, Net.Vpc.Upa.Impl.Persistence.SQLManager sqlManager, Net.Vpc.Upa.Impl.Uql.ExpressionDeclarationList declarations) /* throws Net.Vpc.Upa.Exceptions.UPAException */
        {
            Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledUpdate o  = (Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledUpdate)oo;
            Net.Vpc.Upa.Persistence.PersistenceStore persistenceStore = context.GetPersistenceStore();
            Net.Vpc.Upa.PersistenceUnit pu     = context.GetPersistenceUnit();
            Net.Vpc.Upa.Entity          entity = pu.GetEntity(o.GetEntity().GetName());
            //        String persistenceName = persistenceStore.getPersistenceName(entity);
            System.Text.StringBuilder sb = new System.Text.StringBuilder("Update " + sqlManager.GetSQL(new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledEntityName(entity.GetName()), context, declarations));
            string tableAlias            = o.GetEntityAlias();

            if (tableAlias != null)
            {
                sb.Append(" ");
                sb.Append(sqlManager.GetSQL(new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledVar(tableAlias), context, declarations));
            }
            sb.Append(" Set ");
            bool isFirst = true;
            int  max     = o.CountFields();

            for (int i = 0; i < max; i++)
            {
                Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledVar vv = o.GetField(i);
                Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledVar ev = null;
                Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledVar fv = null;
                if (vv.GetChild() == null)
                {
                    ev = null;
                    fv = vv;
                }
                else
                {
                    ev = vv;
                    fv = (Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledVar)vv.GetChild();
                }
                Net.Vpc.Upa.Impl.Uql.Compiledexpression.DefaultCompiledExpression fieldValue = o.GetFieldValue(i);
                //            Object referrer = vv.getReferrer();
                Net.Vpc.Upa.Field  f             = ((Net.Vpc.Upa.Field)fv.GetReferrer());
                Net.Vpc.Upa.Entity entityManager = f.GetEntity();
                System.Collections.Generic.IList <Net.Vpc.Upa.PrimitiveField> primFields = entityManager.ToPrimitiveFields <Net.Vpc.Upa.EntityPart>(new System.Collections.Generic.List <Net.Vpc.Upa.EntityPart>(new[] { (Net.Vpc.Upa.EntityPart)f }));
                foreach (Net.Vpc.Upa.PrimitiveField primField in primFields)
                {
                    if (isFirst)
                    {
                        isFirst = false;
                    }
                    else
                    {
                        sb.Append(", ");
                    }
                    if (ev != null)
                    {
                        sb.Append(sqlManager.GetSQL(new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledVar(ev.GetName()), context, declarations)).Append(".");
                    }
                    sb.Append(sqlManager.GetSQL(new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledVar(primField), context, declarations));
                    sb.Append("=").Append("(").Append(sqlManager.GetSQL(fieldValue, context, declarations)).Append(")");
                }
            }
            if (o.GetCondition() != null && o.GetCondition().IsValid())
            {
                sb.Append(" Where ").Append(sqlManager.GetSQL(o.GetCondition(), context, declarations));
            }
            if (persistenceStore.IsViewSupported() && entity.NeedsView() && o.GetEntity().IsUseView())
            {
                string implicitTableAlias = persistenceStore.GetPersistenceName("IT_" + entity.GetName(), Net.Vpc.Upa.Persistence.PersistenceNameType.ALIAS);
                sb.Append(" ");
                sb.Append(sqlManager.GetSQL(new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledEntityName(entity.GetName()), context, declarations)).Append(" ").Append(implicitTableAlias).Append(",").Append(sqlManager.GetSQL(new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledEntityName(entity.GetName(), true), context, declarations)).Append(" ").Append(sqlManager.GetSQL(new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledVar(tableAlias), context, declarations));
            }
            //            if (extraFrom != null)
            return(sb.ToString());
        }