Package org.apache.cayenne.ejbql

Examples of org.apache.cayenne.ejbql.EJBQLException


    public boolean visitIdentificationVariable(EJBQLExpression expression) {
        // this is a match on a variable, like "x = :x"

        ClassDescriptor descriptor = context.getEntityDescriptor(expression.getText());
        if (descriptor == null) {
            throw new EJBQLException("Invalid identification variable: "
                    + expression.getText());
        }

        DbEntity table = descriptor.getEntity().getDbEntity();
        String alias = context.getTableAlias(expression.getText(), table
                .getFullyQualifiedName());

        Collection<DbAttribute> pks = table.getPrimaryKeys();

        if (pks.size() == 1) {
            DbAttribute pk = pks.iterator().next();
            context.append(' ').append(alias).append('.').append(pk.getName());
        }
        else {
            throw new EJBQLException(
                    "Multi-column PK to-many matches are not yet supported.");
        }
        return false;
    }
View Full Code Here


            try {
                value = new Integer(text);
            }
            catch (NumberFormatException nfex) {
                throw new EJBQLException("Invalid integer: " + expression.getText());
            }

            String var = context.bindParameter(value);
            context.append(" #bind($").append(var).append(" 'INTEGER')");
        }
View Full Code Here

            try {
                value = new BigDecimal(text);
            }
            catch (NumberFormatException nfex) {
                throw new EJBQLException("Invalid decimal: " + expression.getText());
            }

            String var = context.bindParameter(value);
            context.append(" #bind($").append(var).append(" 'DECIMAL')");
        }
View Full Code Here

            String id = translator.idPath;
            if (id != null) {

                ClassDescriptor descriptor = context.getEntityDescriptor(id);
                if (descriptor == null) {
                    throw new EJBQLException("Unmapped id variable: " + id);
                }
                String pathChunk = translator.lastPathComponent;

                Property property = descriptor.getProperty(pathChunk);
                if (property instanceof AttributeProperty) {
View Full Code Here

            int elenent = 0;
            for (EJBQLPath path : paths) {
                String id = normalizeIdPath(path.getId());
                ClassDescriptor descriptor = descriptorsById.get(id);
                if (descriptor == null) {
                    throw new EJBQLException("Unmapped id variable: " + id);
                }

                StringBuilder buffer = new StringBuilder(id);

                ObjRelationship incoming = null;
View Full Code Here

            if (finishedChildIndex + 1 == expression.getChildrenCount()) {

                // resolve class descriptor
                ClassDescriptor descriptor = resolver.getClassDescriptor(entityName);
                if (descriptor == null) {
                    throw new EJBQLException("Unmapped abstract schema name: "
                            + entityName);
                }

                // per JPA spec, 4.4.2, "Identification variables are case insensitive."
                String id = normalizeIdPath(expression.getId());

                ClassDescriptor old = descriptorsById.put(id, descriptor);
                if (old != null && old != descriptor) {
                    throw new EJBQLException(
                            "Duplicate identification variable definition: "
                                    + id
                                    + ", it is already used for "
                                    + old.getEntity().getName());
                }
View Full Code Here

            if (finishedChildIndex + 1 < expression.getChildrenCount()) {
                this.id = ((EJBQLPath) expression).getId();
                this.descriptor = descriptorsById.get(id);

                if (descriptor == null) {
                    throw new EJBQLException("Unmapped id variable: " + id);
                }
            }

            return true;
        }
View Full Code Here

            if (property instanceof ArcProperty) {
                incoming = ((ArcProperty) property).getRelationship();
                descriptor = ((ArcProperty) property).getTargetDescriptor();
            }
            else {
                throw new EJBQLException("Incorrect relationship path: "
                        + expression.getText());
            }

            return true;
        }
View Full Code Here

                String aliasId = expression.getText();

                // map id variable to class descriptor
                ClassDescriptor old = descriptorsById.put(aliasId, descriptor);
                if (old != null && old != descriptor) {
                    throw new EJBQLException(
                            "Duplicate identification variable definition: "
                                    + aliasId
                                    + ", it is already used for "
                                    + old.getEntity().getName());
                }
View Full Code Here

            EJBQLTableId rhsId,
            String semantics) {

        List<DbRelationship> joinRelationships = context.getIncomingRelationships(rhsId);
        if (joinRelationships.isEmpty()) {
            throw new EJBQLException("No join configured for id " + rhsId);
        }

        // TODO: andrus, 4/8/2007 - support for flattened relationships
        DbRelationship incomingDB = joinRelationships.get(0);
View Full Code Here

TOP

Related Classes of org.apache.cayenne.ejbql.EJBQLException

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.