Package org.apache.openjpa.kernel.exps

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


    private Path getPath(JPQLNode node, boolean pcOnly, boolean inner) {
        // resolve the first element against the aliases map ...
        // i.e., the path "SELECT x.id FROM SomeClass x where x.id > 10"
        // will need to have "x" in the alias map in order to resolve
        Path path;

        final String name = firstChild(node).text;
        final Value val = getVariable(name, false);

        // handle the case where the class name is the alias
        // for the candidate (we don't use variables for this)
        if (name.equalsIgnoreCase(ctx().schemaAlias)) {
            if (ctx().subquery != null) {
                path = factory.newPath(ctx().subquery);
                path.setMetaData(ctx().subquery.getMetaData());
            } else {
                path = factory.newPath();
                path.setMetaData(ctx().meta);
            }
        } else if (getMetaDataForAlias(name) != null)
            path = newPath(null, getMetaDataForAlias(name));
        else if (val instanceof Path)
            path = (Path) val;
        else if (val.getMetaData() != null)
            path = newPath(val, val.getMetaData());
        else
            throw parseException(EX_USER, "path-invalid",
                new Object[]{ assemble(node), name }, null);

        // walk through the children and assemble the path
        boolean allowNull = !inner;
        for (int i = 1; i < node.children.length; i++) {
            if (path.isXPath()) {
                for (int j = i; j <node.children.length; j++)
                    path = (Path) traverseXPath(path, node.children[j].text);
                return path;
            }
            path = (Path) traversePath(path, node.children[i].text, pcOnly,
View Full Code Here


    private Value getValue(JPQLNode node) {
        return getValue(node, VAR_PATH);
    }

    private Path newPath(Value val, ClassMetaData meta) {
        Path path = val == null ? factory.newPath() : factory.newPath(val);
        if (meta != null)
            path.setMetaData(meta);
        return path;
    }
View Full Code Here

        if (cmd != null)
            return cmd;

        // we might be referencing a collection field of a subquery's parent
        if (isPath(node)) {
            Path path = getPath(node);
            FieldMetaData fmd = path.last();
            cmd = getFieldType(fmd);
            if (cmd == null && fmd.isElementCollection())
                cmd = fmd.getDefiningMetaData();
            return cmd;
        }
View Full Code Here

            if (node.id == JJTSUBSELECT) {
                if (n.id == JJTINNERJOIN) {
                    n = n.getChild(0);
                }
                if (n.id == JJTPATH) {
                    Path path = getPath(n);
                    FieldMetaData fmd = path.last();
                    ClassMetaData cmd = getFieldType(fmd);
                    if (cmd == null && fmd.isElementCollection())
                        cmd = fmd.getDefiningMetaData();
                    if (cmd != null) {
                        return cmd;
View Full Code Here

    protected void evalSetClause(QueryExpressions exps) {
        // handle SET field = value
        JPQLNode[] nodes = root().findChildrenByID(JJTUPDATEITEM);
        for (int i = 0; nodes != null && i < nodes.length; i++) {
            Path path = getPath(firstChild(nodes[i]));
            if (path.last().getValue().getEmbeddedMetaData() != null)
                throw parseException(EX_USER, "cant-bulk-update-embeddable",
                        new Object[]{assemble(firstChild(nodes[i]))}, null);

            JPQLNode lastChild = lastChild(nodes[i]);
            Value val = (lastChild.children == null)
View Full Code Here

        }
        else {
            subquery.setSubqAlias(alias);
        }

        Path subpath = factory.newPath(subquery);
        subpath.setSchemaAlias(path.getCorrelationVar());
        subpath.setMetaData(candidate);
        subquery.setMetaData(candidate);
        if (fmd.isElementCollection())
            exp = and(exp, bindVar);
        else
            exp = and(exp, factory.equal(path, subpath));
View Full Code Here

     * @return the Expression with the join condition added
     */
    private Expression addJoin(JPQLNode node, boolean inner, Expression exp) {
        // the type will be the declared type for the field
        JPQLNode firstChild = firstChild(node);
        Path path = null;
        if (firstChild.id == JJTQUALIFIEDPATH)
            path = (Path) getQualifiedPath(firstChild);
        else
            path = getPath(firstChild, false, inner);

View Full Code Here

            addSchemaToContext(alias, cmd);

            // check to see if the we are referring to a path in the from
            // clause, since we might be in a subquery against a collection
            if (isPath(left)) {
                Path path = getPath(left);
                return getSubquery(alias, path, exp);
            } else {
                // we have an alias: bind it as a variable
                Value var = getVariable(alias, true);
                var.setMetaData(cmd);
View Full Code Here

    private void checkEmbeddable(Value val) {
        checkEmbeddable(val, currentQuery());
    }
   
    public static void checkEmbeddable(Value val, String currentQuery) {
        Path path = val instanceof Path ? (Path) val : null;
        if (path == null)
            return;

        FieldMetaData fmd = path.last();
        if (fmd == null)
            return;

        ValueMetaData vm = fmd.isElementCollection() ? fmd.getElement()
            : fmd.getValue();
View Full Code Here

        // as well as setting the types for conversions, we also need to
        // ensure that any parameters are declared with the correct type,
        // since the JPA spec expects that these will be validated
        Parameter param = val1 instanceof Parameter ? (Parameter) val1
            : val2 instanceof Parameter ? (Parameter) val2 : null;
        Path path = val1 instanceof Path ? (Path) val1
            : val2 instanceof Path ? (Path) val2 : null;

        // we only check for parameter-to-path comparisons
        if (param == null || path == null || parameterTypes == null)
            return;

        FieldMetaData fmd = path.last();
        if (fmd == null)
            return;

        if (expected == null)
            checkEmbeddable(path, currentQuery);

        Class<?> type = path.getType();
        if (type == null)
            return;

        Object paramKey = param.getParameterKey();
        if (paramKey == null)
View Full Code Here

TOP

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

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.