Package org.apache.openjpa.jdbc.sql

Examples of org.apache.openjpa.jdbc.sql.SelectImpl$Selects


        final Joins[] resJoins = new Joins[rels.length];

        //cache union for field here
        //select data for this sm
        Union union = null;
        SelectImpl sel = null;
        List parmList = null;

        if (!((JDBCStoreManager)store).isQuerySQLCacheOn())
            union = newUnion(sm, store, fetch, rels, subs, resJoins);
        else {
            if (relationFieldUnionCache == null) {
                relationFieldUnionCache =
                    ((JDBCStoreManager) store)
                        .getCacheMapFromQuerySQLCache(RelationFieldStrategy.class);
            }
            boolean found = true;
            JDBCFetchConfiguration fetchClone = new JDBCFetchConfigurationImpl();
            fetchClone.copy(fetch);
            JDBCStoreManager.SelectKey selKey =
                new JDBCStoreManager.SelectKey(null, field, fetch);
            Object[] obj = relationFieldUnionCache.get(selKey);
            if (obj != null) {
                union = (Union) obj[0];
                resJoins[0] = (Joins)obj[1];
            } else {
                synchronized(relationFieldUnionCache) {
                    obj = relationFieldUnionCache.get(selKey);
                    if (obj != null) {
                        union = (Union) obj[0];
                        resJoins[0] = (Joins) obj[1];
                    } else {
                        // select related mapping columns; joining from the
                        // related type back to our fk table if not an inverse
                        // mapping (in which case we can just make sure the
                        // inverse cols == our pk values)
                        union = newUnion(sm, store, fetch, rels, subs,
                                resJoins);
                        found = false;               
                    }
                    sel = ((LogicalUnion.UnionSelect)union.getSelects()[0]).
                        getDelegate();
                    SQLBuffer buf = sel.getSQL();
                    if (buf == null) {
                      ((SelectImpl)sel).setSQL(store, fetch);
                        found = false;
                    }

                    // only cache the union when elems length is 1 for now
                    if (!found && rels.length == 1) {
                        Object[] obj1 = new Object[2];
                        obj1[0] = union;
                        obj1[1] = resJoins[0];
                        ((JDBCStoreManager)store).addToSqlCache(
                            relationFieldUnionCache, selKey, obj1);
                    }
                }
            }
            Log log = store.getConfiguration().
                getLog(JDBCConfiguration.LOG_JDBC);
            if (log.isTraceEnabled()){
                if (found)
                    log.trace(_loc.get("cache-hit", field, this.getClass()));                       
                else
                    log.trace(_loc.get("cache-missed", field, this.getClass()));
            }

            parmList = new ArrayList();
            ClassMapping mapping = field.getDefiningMapping();
            Object oid = sm.getObjectId();
            Column[] cols = mapping.getPrimaryKeyColumns();
            if (sel == null)
                sel = ((LogicalUnion.UnionSelect)union.getSelects()[0]).
                getDelegate();

            sel.wherePrimaryKey(mapping, cols, cols, oid, store,
              null, null, parmList);
        }
       
        Result res = union.execute(store, fetch, parmList);
        try {
View Full Code Here


                    if (j == size - 1) {
                        nextBits.set(sels.size());
                        sel.select(vert.getPrimaryKeyColumns(), null);
                        sels.add(sel);
                    } else {
                        SelectImpl selClone = (SelectImpl)sel.fullClone(1);
                        selClone.select(vert.getPrimaryKeyColumns(), null);
                        sels.add(selClone);
                    }
                }
            } else {
                for (int j = 0; j < verts.length; j++) {
View Full Code Here

                }
                dict.setTimeouts(stmnt, fetch, false);

                ResultSet rs = stmnt.executeQuery();
               
                SelectImpl cachedSelect = pq.getSelect();
                Result res = cachedSelect.getEagerResult(conn, stmnt, rs, store, fetch, false, null);
               
                if (getQueryExpressions()[0].projections.length > 0) {
                    ExpContext ctx = new ExpContext(store, params, fetch);
                    QueryExpressionsState state = (QueryExpressionsState)getQueryExpressions()[0].state;
                    rop = new PreparedProjectionResultObjectProvider(cachedSelect, getQueryExpressions(),
View Full Code Here

     * mapping. The given Select may not be amenable for caching and then a null
     * value is returned.
     */
    static FinderQueryImpl newFinder(ClassMapping mapping,
        SelectExecutor select) {
        SelectImpl impl = extractImplementation(select);
        if (impl == null)
            return null;
        SQLBuffer buffer = impl.getSQL();
        Column[] pkCols = mapping.getPrimaryKeyColumns();
        boolean canCache = pkCols.length == buffer.getParameters().size();
        return (canCache)
            ? new FinderQueryImpl(mapping, impl, buffer) : null;
    }
View Full Code Here

                    if (j == size - 1) {
                        nextBits.set(sels.size());
                        sel.select(vert.getPrimaryKeyColumns(), null);
                        sels.add(sel);
                    } else {
                        SelectImpl selClone = (SelectImpl)sel.fullClone(1);
                        selClone.select(vert.getPrimaryKeyColumns(), null);
                        sels.add(selClone);
                    }
                }
            } else {
                for (int j = 0; j < verts.length; j++) {
View Full Code Here

        boolean found = true;
        final ClassMapping[] elems = getIndependentElementMappings(true);
        final Joins[] resJoins = new Joins[Math.max(1, elems.length)];
        List parmList = null;
        Union union = null;
        SelectImpl sel = null;
        Map<JDBCStoreManager.SelectKey, Object[]> storeCollectionUnionCache = null;
        JDBCStoreManager.SelectKey selKey = null;
        if (!((JDBCStoreManager)store).isQuerySQLCacheOn() || elems.length > 1)
            union = newUnion(sm, store, fetch, elems, resJoins);
        else {
            parmList = new ArrayList();
            JDBCFetchConfiguration fetchClone = new JDBCFetchConfigurationImpl();
            fetchClone.copy(fetch);
          
            // to specify the type so that no cast is needed
            storeCollectionUnionCache = ((JDBCStoreManager)store).
                getCacheMapFromQuerySQLCache(StoreCollectionFieldStrategy.class);
            selKey =
                new JDBCStoreManager.SelectKey(null, field, fetchClone);
            Object[] objs = storeCollectionUnionCache.get(selKey);
            if (objs != null) {
                union = (Union) objs[0];
                resJoins[0] = (Joins) objs[1];
            }
            else {
                synchronized(storeCollectionUnionCache) {
                    objs = storeCollectionUnionCache.get(selKey);
                    if (objs == null) {
                        // select data for this sm
                        union = newUnion(sm, store, fetch, elems, resJoins);
                        found = false;
                    } else {
                        union = (Union) objs[0];
                        resJoins[0] = (Joins) objs[1];
                    }

                    sel = ((LogicalUnion.UnionSelect)union.getSelects()[0]).
                        getDelegate();
                    if (sel.getSQL() == null) {
                      ((SelectImpl)sel).setSQL(store, fetch);
                        found = false;
                    }

                    // only cache the union when elems length is 1 for now
                    if (!found) {
                        Object[] objs1 = new Object[2];
                        objs1[0] = union;
                        objs1[1] = resJoins[0];
                        ((JDBCStoreManager)store).addToSqlCache(
                            storeCollectionUnionCache, selKey, objs1);
                     }
                }
            }
           
            Log log = store.getConfiguration().
                getLog(JDBCConfiguration.LOG_JDBC);
            if (log.isTraceEnabled()) {
                if (found)
                    log.trace(_loc.get("cache-hit", field, this.getClass()));
                else
                    log.trace(_loc.get("cache-missed", field, this.getClass()));
            }
           
            ClassMapping mapping = field.getDefiningMapping();
            Object oid = sm.getObjectId();
            Column[] cols = mapping.getPrimaryKeyColumns();
            if (sel == null)
                sel = ((LogicalUnion.UnionSelect)union.getSelects()[0]).
                getDelegate();

            sel.wherePrimaryKey(mapping, cols, cols, oid, store,
                  null, null, parmList);
            List nonFKParams = sel.getSQL().getNonFKParameters();
            if (nonFKParams != null && nonFKParams.size() > 0)
                parmList.addAll(nonFKParams);
        }
       
        // create proxy
View Full Code Here

        final Joins[] resJoins = new Joins[rels.length];

        //cache union for field here
        //select data for this sm
        Union union = null;
        SelectImpl sel = null;
        List parmList = null;

        if (!((JDBCStoreManager)store).isQuerySQLCacheOn())
            union = newUnion(sm, store, fetch, rels, subs, resJoins);
        else {
            Map<JDBCStoreManager.SelectKey, Object[]> relationFieldUnionCache =
                ((JDBCStoreManager)store).getCacheMapFromQuerySQLCache(
                RelationFieldStrategy.class);
            boolean found = true;
            JDBCFetchConfiguration fetchClone = new JDBCFetchConfigurationImpl();
            fetchClone.copy(fetch);
            JDBCStoreManager.SelectKey selKey =
                new JDBCStoreManager.SelectKey(null, field, fetch);
            Object[] obj = relationFieldUnionCache.get(selKey);
            if (obj != null) {
                union = (Union) obj[0];
                resJoins[0] = (Joins)obj[1];
            } else {
                synchronized(relationFieldUnionCache) {
                    obj = relationFieldUnionCache.get(selKey);
                    if (obj != null) {
                        union = (Union) obj[0];
                        resJoins[0] = (Joins) obj[1];
                    } else {
                        // select related mapping columns; joining from the
                        // related type back to our fk table if not an inverse
                        // mapping (in which case we can just make sure the
                        // inverse cols == our pk values)
                        union = newUnion(sm, store, fetch, rels, subs,
                                resJoins);
                        found = false;               
                    }
                    sel = ((LogicalUnion.UnionSelect)union.getSelects()[0]).
                        getDelegate();
                    SQLBuffer buf = sel.getSQL();
                    if (buf == null) {
                      ((SelectImpl)sel).setSQL(store, fetch);
                        found = false;
                    }

                    // only cache the union when elems length is 1 for now
                    if (!found && rels.length == 1) {
                        Object[] obj1 = new Object[2];
                        obj1[0] = union;
                        obj1[1] = resJoins[0];
                        ((JDBCStoreManager)store).addToSqlCache(
                            relationFieldUnionCache, selKey, obj1);
                    }
                }
            }
            Log log = store.getConfiguration().
                getLog(JDBCConfiguration.LOG_JDBC);
            if (log.isTraceEnabled()){
                if (found)
                    log.trace(_loc.get("cache-hit", field, this.getClass()));                       
                else
                    log.trace(_loc.get("cache-missed", field, this.getClass()));
            }

            parmList = new ArrayList();
            ClassMapping mapping = field.getDefiningMapping();
            Object oid = sm.getObjectId();
            Column[] cols = mapping.getPrimaryKeyColumns();
            if (sel == null)
                sel = ((LogicalUnion.UnionSelect)union.getSelects()[0]).
                getDelegate();

            sel.wherePrimaryKey(mapping, cols, cols, oid, store,
              null, null, parmList);
        }
       
        Result res = union.execute(store, fetch, parmList);
        try {
View Full Code Here

        final Joins[] resJoins = new Joins[rels.length];

        //cache union for field here
        //select data for this sm
        Union union = null;
        SelectImpl sel = null;
        List parmList = null;

        if (!((JDBCStoreManager)store).isQuerySQLCacheOn())
            union = newUnion(sm, store, fetch, rels, subs, resJoins);
        else {
            Map<JDBCStoreManager.SelectKey, Object[]> relationFieldUnionCache =
                ((JDBCStoreManager)store).getCacheMapFromQuerySQLCache(
                RelationFieldStrategy.class);
            boolean found = true;
            JDBCFetchConfiguration fetchClone = new JDBCFetchConfigurationImpl();
            fetchClone.copy(fetch);
            JDBCStoreManager.SelectKey selKey =
                new JDBCStoreManager.SelectKey(null, field, fetch);
            Object[] obj = relationFieldUnionCache.get(selKey);
            if (obj != null) {
                union = (Union) obj[0];
                resJoins[0] = (Joins)obj[1];
            } else {
                synchronized(relationFieldUnionCache) {
                    obj = relationFieldUnionCache.get(selKey);
                    if (obj != null) {
                        union = (Union) obj[0];
                        resJoins[0] = (Joins) obj[1];
                    } else {
                        // select related mapping columns; joining from the
                        // related type back to our fk table if not an inverse
                        // mapping (in which case we can just make sure the
                        // inverse cols == our pk values)
                        union = newUnion(sm, store, fetch, rels, subs,
                                resJoins);
                        found = false;               
                    }
                    sel = ((LogicalUnion.UnionSelect)union.getSelects()[0]).
                        getDelegate();
                    SQLBuffer buf = sel.getSQL();
                    if (buf == null) {
                      ((SelectImpl)sel).setSQL(store, fetch);
                        found = false;
                    }

                    // only cache the union when elems length is 1 for now
                    if (!found && rels.length == 1) {
                        Object[] obj1 = new Object[2];
                        obj1[0] = union;
                        obj1[1] = resJoins[0];
                        ((JDBCStoreManager)store).addToSqlCache(
                            relationFieldUnionCache, selKey, obj1);
                    }
                }
            }
            Log log = store.getConfiguration().
                getLog(JDBCConfiguration.LOG_JDBC);
            if (log.isTraceEnabled()){
                if (found)
                    log.trace(_loc.get("cache-hit", field, this.getClass()));                       
                else
                    log.trace(_loc.get("cache-missed", field, this.getClass()));
            }

            parmList = new ArrayList();
            ClassMapping mapping = field.getDefiningMapping();
            Object oid = sm.getObjectId();
            Column[] cols = mapping.getPrimaryKeyColumns();
            if (sel == null)
                sel = ((LogicalUnion.UnionSelect)union.getSelects()[0]).
                getDelegate();

            sel.wherePrimaryKey(mapping, cols, cols, oid, store,
              null, null, parmList);
        }
       
        Result res = union.execute(store, fetch, parmList);
        try {
View Full Code Here

     * mapping. The given Select may not be amenable for caching and then a null
     * value is returned.
     */
    static FinderQueryImpl newFinder(ClassMapping mapping,
        SelectExecutor select) {
        SelectImpl impl = extractImplementation(select);
        if (impl == null)
            return null;
        SQLBuffer buffer = impl.getSQL();
        Column[] pkCols = mapping.getPrimaryKeyColumns();
        boolean canCache = pkCols.length == buffer.getParameters().size();
        return (canCache)
            ? new FinderQueryImpl(mapping, impl, buffer) : null;
    }
View Full Code Here

                }
                dict.setTimeouts(stmnt, fetch, false);

                ResultSet rs = stmnt.executeQuery();
               
                SelectImpl cachedSelect = pq.getSelect();
                Result res = cachedSelect.getEagerResult(conn, stmnt, rs, store, fetch, false, null);
               
                if (getQueryExpressions()[0].projections.length > 0) {
                    ExpContext ctx = new ExpContext(store, params, fetch);
                    QueryExpressionsState state = (QueryExpressionsState)getQueryExpressions()[0].state;
                    rop = new PreparedProjectionResultObjectProvider(cachedSelect, getQueryExpressions(),
View Full Code Here

TOP

Related Classes of org.apache.openjpa.jdbc.sql.SelectImpl$Selects

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.