Package org.apache.cayenne.query

Examples of org.apache.cayenne.query.Query


    /**
     * Returns a named query or null if no query exists for a given name.
     */
    public synchronized Query lookupQuery(String name) {
        Query result = queryCache.get(name);

        if (result == null) {
            // reconstruct cache just in case some of the datamaps
            // have changed and now contain the required information
            constructCache();
View Full Code Here


        // Delete data from entities one by one
        Iterator it = entities.iterator();
        while (it.hasNext()) {
            DbEntity entity = (DbEntity) it.next();

            Query query = new SQLTemplate(entity, "DELETE FROM "
                    + entity.getFullyQualifiedName());

            // notify delegate that delete is about to happen
            if (delegate != null) {
                query = delegate.willCleanData(this, entity, query);
View Full Code Here

            SelectQuery select = new SelectQuery(entity);
            select.setFetchingDataRows(true);

            // delegate is allowed to substitute query
            Query query = (delegate != null) ? delegate.willPortEntity(
                    this,
                    entity,
                    select) : select;

            sourceNode.performQueries(Collections.singletonList(query), observer);
View Full Code Here

            }

            // 3. refresh query - this shouldn't normally happen as child datacontext
            // usually does a cascading refresh
            if (refreshQuery.getQuery() != null) {
                Query cachedQuery = refreshQuery.getQuery();

                String cacheKey = cachedQuery
                        .getMetaData(context.getEntityResolver())
                        .getCacheKey();
                context.getQueryCache().remove(cacheKey);

                this.response = domain.onQuery(context, cachedQuery);
View Full Code Here

    }

    public void testGetQuery() {
        // create a resolver with a single map
        DataMap m1 = new DataMap();
        Query q = new MockQuery("query1");
        m1.addQuery(q);

        EntityResolver resolver = new EntityResolver(Collections.singleton(m1));
        assertSame(q, resolver.getQuery("query1"));

        // check that the query added on-the-fly will be recognized
        assertNull(resolver.getQuery("query2"));

        Query q2 = new MockQuery("query2");
        m1.addQuery(q2);
        assertSame(q2, resolver.getQuery("query2"));
    }
View Full Code Here

     * Returns a named query associated with this DataMap.
     *
     * @since 1.1
     */
    public Query getQuery(String queryName) {
        Query query = queryMap.get(queryName);
        if (query != null) {
            return query;
        }

        return namespace != null ? namespace.getQuery(queryName) : null;
View Full Code Here

            }

            // 3. refresh query - this shouldn't normally happen as child datacontext
            // usually does a cascading refresh
            if (refreshQuery.getQuery() != null) {
                Query cachedQuery = refreshQuery.getQuery();

                String cacheKey = cachedQuery
                        .getMetaData(context.getEntityResolver())
                        .getCacheKey();
                context.getQueryCache().remove(cacheKey);

                this.response = domain.onQuery(context, cachedQuery);
View Full Code Here

    /**
     * Returns a named query or null if no query exists for a given name.
     */
    public synchronized Query lookupQuery(String name) {
        Query result = queryCache.get(name);

        if (result == null) {
            // reconstruct cache just in case some of the datamaps
            // have changed and now contain the required information
            constructCache();
View Full Code Here

        List finalQueries = new ArrayList(queries.size());

        Iterator it = queries.iterator();
        while (it.hasNext()) {
            Query query = (Query) it.next();

            query = filterThroughDelegateDeprecated(query);

            if (query != null) {
                finalQueries.add(query);
View Full Code Here

        // Delete data from entities one by one
        Iterator it = entities.iterator();
        while (it.hasNext()) {
            DbEntity entity = (DbEntity) it.next();

            Query query = new SQLTemplate(entity, "DELETE FROM "
                    + entity.getFullyQualifiedName());

            // notify delegate that delete is about to happen
            if (delegate != null) {
                query = delegate.willCleanData(this, entity, query);
View Full Code Here

TOP

Related Classes of org.apache.cayenne.query.Query

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.