Package org.xorm.query

Examples of org.xorm.query.QueryImpl


            //logger.fine("Class Mapping Table: " + classMapping.getTable().getName());
            Class filterTargetClass = classMapping.getMappedClass();
            //logger.fine("Filter Target Class: " + filterTargetClass.getName());
           
            QueryImpl query = new QueryImpl(mgr);
            query.setClass(filterTargetClass);
            query.setFilter(mapping.getFilter());

            // We support the implicit "owner" parameter in filters.
            // The owner refers to the object instance off which the
            // collection field getter is being called.  We need to add
            // it to the parameters that we set on the query.
            String parameters = mapping.getParameters();
            ClassMapping ownerClassMapping = owner.getClassMapping();
            Class ownerClass = ownerClassMapping.getMappedClass();
            String ownerClassName = ownerClass.getName();
            //ownerClassName = ownerClassName.substring(ownerClassName.lastIndexOf('.') + 1);
            //logger.fine("OwnerClassName: " + ownerClassName);

            if (mapping.getImports() != null) {
                query.declareImports(mapping.getImports());
            }
            if (parameters == null || parameters.equals("")) {
                // No parameters, just this owner param
                parameters = ownerClassName + " owner";
            }
            else {
                // Append this owner param to the existing parameters
                parameters += ", " + ownerClassName + " owner";
            }
            logger.fine("Modified Parameters: " + parameters);
            query.declareParameters(parameters);

            if (mapping.getVariables() != null) {
                query.declareVariables(mapping.getVariables());
            }

            if (mapping.getOrdering() != null) {
                query.setOrdering(mapping.getOrdering());
            }

            query.compile();
            //logger.fine("Filter Query: " + query);

            BoundExpression bound = query.getBoundExpression();
            int paramCount = 0;
            if (args != null) {
                while (paramCount < args.length) {
                    bound.bindParameter(paramCount, args[paramCount]);
                    ++paramCount;
View Full Code Here


    }

    /** Returns a query built using JDOQL. */
    public Query newQuery(Class clazz, String filter) {
        assertNotClosed();
        Query q = new QueryImpl(this);
        q.setClass(clazz);
        q.setFilter(filter);
        return q;
    }
View Full Code Here

     * Returns a query for the specified class.  Without user
     * modification, when executed, returns all instances of the class.
     */
    public Query newQuery(Class clazz) {
        assertNotClosed();
        QueryImpl query = new QueryImpl(this);
        query.setClass(clazz);
        return query;
    }
View Full Code Here

     * modification, when executed, returns all instances of the class.
     * Note that XORM does not support subclasses at this time.
     */
    public Query newQuery(Extent extent) {
        assertNotClosed();
        QueryImpl query = new QueryImpl(this);
        query.setClass(extent.getCandidateClass());
        return query;
    }
View Full Code Here

     * that match the query filter (JDOQL expression).  Note that XORM
     * does not support subclasses at this time. 
     */
    public Query newQuery(Extent extent, String filter) {
        assertNotClosed();
        QueryImpl query = new QueryImpl(this);
        query.setClass(extent.getCandidateClass());
        query.setFilter(filter);
        return query;
    }
View Full Code Here

     * Creates a new query that the user must set values on
     * using the Query interface.
     */
    public Query newQuery() {
        assertNotClosed();
        return new QueryImpl(this);
    }
View Full Code Here

    /** Constructs a query by copying data from a previous query. */
    public Query newQuery(Object compiled) {
        assertNotClosed();
        if (compiled instanceof QueryImpl) {
            return new QueryImpl(this, (QueryImpl) compiled);
        }
        throw new UnsupportedOperationException();
    }
View Full Code Here

     * QueryLanguage.LANGUAGE.
     */
    public Query newQuery(String language, Object query) {
        assertNotClosed();
        if (QueryLanguage.LANGUAGE.equals(language)) {
            return new QueryImpl(this, (QueryLanguage) query);
        } else if (JDOQL_LANGUAGE.equals(language)) {
            return newQuery((Class) null, (String) query);
        } else if (CodeQuery.LANGUAGE.equals(language)) {
            // First try to get Expression directly.
            try {
                return new QueryImpl(this, new CodeParser((Class) query));
            } catch (Throwable e) {
                // Code could not be turned into JDOQL.
                return new CodeQuery(this, (Class) query);
            }
        }
View Full Code Here

TOP

Related Classes of org.xorm.query.QueryImpl

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.