Package org.apache.openjpa.kernel.exps

Examples of org.apache.openjpa.kernel.exps.Context


        if (lctx.cloneFrom == cloneFrom)
            return lctx;
        java.util.List<Context> subselCtxs = lctx.getSubselContexts();
        if (subselCtxs != null) {
            for (Context subselCtx : subselCtxs) {
                Context ctx = getThreadLocalContext(subselCtx, cloneFrom);
                if (ctx != null)
                    return ctx;
            }
        }
        return null;
View Full Code Here


        }
        return newCtx;
    }

    private static Context clone(Context orig, Context parent) {
        Context myParent = null;
        if (parent == null) {
            Context origParent = orig.getParent();
            if (origParent != null)
                myParent = clone(orig.getParent(), null);
        } else
            myParent = parent;

        Context newCtx = new Context(orig.parsed, null, myParent);
        newCtx.from = orig.from;
        newCtx.meta = orig.meta;
        newCtx.schemaAlias = orig.schemaAlias;
        newCtx.setSchemas(orig.getSchemas());
        newCtx.setVariables(orig.getVariables());
        newCtx.cloneFrom = orig;
        Object select = orig.getSelect();
        if (select != null)
            newCtx.setSelect(((SelectImpl)select).clone(newCtx));
        newCtx.subquery = orig.subquery;
        List<Context> subsels = orig.getSubselContexts();
        if (subsels != null) {
            for (Context subsel : subsels)
                newCtx.addSubselContext(clone(subsel, newCtx));
        }

        return newCtx;       
    }
View Full Code Here

        String alias = _schemaAlias;
        if (isPathInThisContext(pj) || table.isAssociation())         
            alias = null;

        // find the context where this alias is defined
        Context ctx = (alias != null) ?
            _ctx.findContext(alias) : null;
        if (ctx != null)
            sel = (SelectImpl) ctx.getSelect();

        if (!create)
            i = sel.findAlias(table, key)// find in parent and in myself
        else
            i = sel.getAlias(table, key); // find in myself
        if (i != null)
            return i;
       
        if (create) { // create here
            i = sel.createAlias(table, key);
        } else if (ctx != null && ctx != ctx()) { // create in other select
            i = ((SelectImpl)ctx.getSelect()).createAlias(table, key);
        }

        return i;
    }
View Full Code Here

        return i;
    }

    private boolean isPathInThisContext(PathJoins pj) {
        // currCtx is set from Action, it is reset to null after the PCPath initialization
        Context currCtx = pj == null ? null : ((PathJoinsImpl)pj).context;
       
        // lastCtx is set to currCtx after the SelectJoins.join. pj.lastCtx and pj.path string are
        // the last snapshot of pj. They will be used together for later table alias resolution in
        // the getColumnAlias().
        Context lastCtx = pj == null ? null : ((PathJoinsImpl)pj).lastContext;
        Context thisCtx = currCtx == null ? lastCtx : currCtx;
        String corrVar = pj == null ? null : pj.getCorrelatedVariable();
       
        return (pj != null && pj.path() != null &&
            (corrVar == null || (thisCtx != null && ctx() == thisCtx)));
    }
View Full Code Here

            // don't let the get alias methods see that a var has been set
            // until we get past the local table
            String var = this.var;
            this.var = null;
            Context ctx = context;
            context = null;

            int alias1 = _sel.getTableIndex(localTable, this, true);
            this.append(var);
            this.append(correlatedVar);
View Full Code Here

            int subs, boolean inverse, boolean toMany, boolean outer) {
            // don't let the get alias methods see that a var has been set
            // until we get past the local table
            String var = this.var;
            this.var = null;
            Context ctx = context;
            context = null;

            // get first table alias before updating path; if there is a from
            // select then we shouldn't actually create a join object, since
            // the joins will all be done in the from select
View Full Code Here

     * Populate a kernel expression tree by translating the components of this
     * receiver with the help of the given {@link ExpressionFactory}.
     */
    QueryExpressions getQueryExpressions(ExpressionFactory factory) {
        _contexts = new Stack<Context>();
        Context context = new Context(null, null, null);
        _contexts.push(context);
        return new CriteriaExpressionBuilder().getQueryExpressions(factory, this);
    }   
View Full Code Here

    public void addToContext(ExpressionFactory factory, MetamodelImpl model, CriteriaQueryImpl<?> q) {
        String alias = q.getAlias(this);
        Value var = factory.newBoundVariable(alias, AbstractExpressionBuilder.TYPE_OBJECT);
        var.setMetaData(_entity.meta);
        Context currContext = q.ctx();
        currContext.addSchema(alias, _entity.meta);
        currContext.addVariable(alias, var);
        if (currContext.schemaAlias == null)
            currContext.schemaAlias = alias;
    }
View Full Code Here

        String alias = q.getAlias(this);
        ClassMetaData candidate = getCandidate();
        _subq = factory.newSubquery(candidate, subclasses, alias);
        _subq.setMetaData(candidate);
        Stack<Context> contexts = getContexts();
        Context context = new Context(null, _subq, contexts.peek());
        contexts.push(context);
        _delegate.setContexts(contexts);
        QueryExpressions subexp = exprBuilder.getQueryExpressions(factory, _delegate);
        _subq.setQueryExpressions(subexp);
        if (subexp.projections.length > 0)
View Full Code Here

                if (action.op == Action.GET_XPATH)
                    break;
            }
            prevaction = action;
            if (prevaction != null && prevaction.context != null) {
                Context jCtx = JDBCStoreQuery.getThreadLocalContext(prevaction.context);
                pstate.joins = pstate.joins.setJoinContext(jCtx);
            }
        }
        if (_varName != null)
            pstate.joins = pstate.joins.setVariable(_varName);
View Full Code Here

TOP

Related Classes of org.apache.openjpa.kernel.exps.Context

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.