Package org.apache.openjpa.kernel.exps

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


        // 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


        throw parseException(EX_USER, "unknown-identifier",
            new Object[]{ name }, null);
    }

    private Path validateMapPath(JPQLNode node, JPQLNode id) {
        Path path = (Path) getValue(id);
        FieldMetaData fld = path.last();

        if (fld == null && ctx().subquery != null) {
            Value var = getVariable(id.text, false);
            if (var != null) {
                path = factory.newPath(var);
                fld = path.last();
            }
        }
       
        if (fld != null) {           
            // validate the field is of type java.util.Map
View Full Code Here

        return path;
    }

    private Value getGeneralIdentifier(JPQLNode node, boolean verifyEmbeddable) {
        JPQLNode id = onlyChild(node);
        Path path = validateMapPath(node, id);

        if (node.id == JJTKEY)
            path = (Path) factory.getKey(path);
        FieldMetaData fld = path.last();
        ClassMetaData meta = fld.getKey().getTypeMetaData();
        if (verifyEmbeddable &&
            (node.id == JJTKEY && meta != null && fld.getKey().isEmbedded()) ||
            (node.id == JJTVALUE && fld.isElementCollection() &&
                 fld.getElement().getEmbeddedMetaData() != null)) {
View Full Code Here

        return path;
    }

    private Value getQualifiedIdentifier(JPQLNode node) {
        JPQLNode id = onlyChild(node);              
        Path path = validateMapPath(node, id);

        if (node.id == JJTVALUE)
            return path;

        Value value = getValue(id);
View Full Code Here

    {
        int nChild = node.getChildCount();
        JPQLNode firstChild = firstChild(node);
        JPQLNode id = firstChild.id == JJTKEY ? onlyChild(firstChild) :
               firstChild;              
        Path path = validateMapPath(firstChild, id);

        if (firstChild.id == JJTIDENTIFIER)
            return getPath(node);

        FieldMetaData fld = path.last();
        path = (Path) factory.getKey(path);
        ClassMetaData meta = fld.getKey().getTypeMetaData();

        if (meta == null)
            throw parseException(EX_USER, "bad-qualified-path",
                new Object[]{ id.text }, null);
       
        path.setMetaData(meta);

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

    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 = null;

        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);

        path.setSchemaAlias(name);

        // 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,
                allowNull);
            if (ctx().getParent() != null && ctx().getVariable(path.getSchemaAlias()) == null) {
                path.setSubqueryContext(ctx(), name);
            }
       
            // all traversals but the first one will always be inner joins
            allowNull = false;
        }
View Full Code Here

            return getQualifiedIdentifier(onlyChild(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

        return path;
    }

    private Value getGeneralIdentifier(JPQLNode node, boolean verifyEmbeddable) {
        JPQLNode id = onlyChild(node);
        Path path = validateMapPath(node, id);

        if (node.id == JJTKEY)
            path = (Path) factory.getKey(path);
        FieldMetaData fld = path.last();
        ClassMetaData meta = fld.getKey().getTypeMetaData();
        if (verifyEmbeddable &&
            (node.id == JJTKEY && meta != null && fld.getKey().isEmbedded()) ||
            (node.id == JJTVALUE && fld.isElementCollection() &&
                 fld.getElement().getEmbeddedMetaData() != null)) {
View Full Code Here

        return path;
    }

    private Value getQualifiedIdentifier(JPQLNode node) {
        JPQLNode id = onlyChild(node);              
        Path path = validateMapPath(node, id);

        if (node.id == JJTVALUE)
            return path;

        Value value = getValue(id);
View Full Code Here

    {
        int nChild = node.getChildCount();
        JPQLNode firstChild = firstChild(node);
        JPQLNode id = firstChild.id == JJTKEY ? onlyChild(firstChild) :
               firstChild;              
        Path path = validateMapPath(firstChild, id);

        if (firstChild.id == JJTIDENTIFIER)
            return getPath(node);

        FieldMetaData fld = path.last();
        path = (Path) factory.getKey(path);
        ClassMetaData meta = fld.getKey().getTypeMetaData();

        if (meta == null)
            throw parseException(EX_USER, "bad-qualified-path",
                new Object[]{ id.text }, null);
       
        path.setMetaData(meta);

        // walk through the children and assemble the path
        boolean allowNull = !inner;
        for (int i = 1; i < nChild; i++) {
            path = (Path) traversePath(path, node.children[i].text, pcOnly,
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.