Package org.apache.openjpa.jdbc.kernel

Examples of org.apache.openjpa.jdbc.kernel.JDBCStore


        if (edata == null || !(edata instanceof ConnectionInfo))
            return null;

        Result result = ((ConnectionInfo) edata).result;
        if (result instanceof ResultSetResult) {
            JDBCStore store = ((ResultSetResult) result).getStore();
            for (SliceStoreManager slice : _slices) {
                if (slice == store) {
                    return slice.getName();
                }
            }
View Full Code Here


        throws Exception {
       
        EntityManager em = currentEntityManager();
        Broker broker = JPAFacadeHelper.toBroker(em);
      
        JDBCStore store = (JDBCStore)broker.getStoreManager();

        Connection conn = store.getConnection();
        Statement stmnt = conn.createStatement();
        ResultSet rs = stmnt.executeQuery("SELECT * FROM RAWSQL "
        + "ORDER BY INTFIELD");
        ResultSetResult res = new ResultSetResult(rs,
        store.getConfiguration().getDBDictionaryInstance());
        ResultObjectProvider rop = new GenericResultObjectProvider
        (RawSQL.class, store, null, res);
        ResultList rl = new EagerResultList(rop);
        check(rl, broker);
        rl.close();
View Full Code Here

        EntityManager em =emf.createEntityManager();
        startTx(em);
        RuntimeTest1 a = new RuntimeTest1("a-name", 10);
        em.persist(a);
        em.flush();
        JDBCStore store = (JDBCStore) getStoreManager(em, true);
        Connection conn = store.getConnection();
        ClassMapping mapping = store.getConfiguration().
                getMappingRepositoryInstance().getMapping(RuntimeTest1.class,
                null, true);
        FieldMapping fm = mapping.getFieldMapping("stringField");
        String tableName =
            store.getConfiguration().getDBDictionaryInstance().getFullName(
                    fm.getTable(), false);
        String colName = fm.getColumns()[0].getName();
        Statement st = conn.createStatement();
        ResultSet rs = st.executeQuery("SELECT " + colName + " FROM "
                + tableName + " WHERE " + colName + " = 'a-name'");
View Full Code Here

        if (edata == null || !(edata instanceof ConnectionInfo))
            return null;

        Result result = ((ConnectionInfo) edata).result;
        if (result instanceof ResultSetResult) {
            JDBCStore store = ((ResultSetResult) result).getStore();
            for (SliceStoreManager slice : _slices) {
                if (slice == store) {
                    return slice.getName();
                }
            }
View Full Code Here

        if (edata == null || !(edata instanceof ConnectionInfo))
            return null;

        Result result = ((ConnectionInfo) edata).result;
        if (result instanceof ResultSetResult) {
            JDBCStore store = ((ResultSetResult) result).getStore();
            for (SliceStoreManager slice : _slices) {
                if (slice == store) {
                    String sliceId = slice.getName();
                    sm.setImplData(sliceId, true);
                    return sliceId;
View Full Code Here

        EntityManager em =emf.createEntityManager();
        startTx(em);
        RuntimeTest1 a = new RuntimeTest1("a-name", 10);
        em.persist(a);
        em.flush();
        JDBCStore store = (JDBCStore) getStoreManager(em, true);
        Connection conn = store.getConnection();
        ClassMapping mapping = store.getConfiguration().
                getMappingRepositoryInstance().getMapping(RuntimeTest1.class,
                null, true);
        FieldMapping fm = mapping.getFieldMapping("stringField");
        String tableName = store.getConfiguration().getDBDictionaryInstance().getFullName(fm.getTable(), false);
        String colName = fm.getColumns()[0].getName();
        Statement st = conn.createStatement();
        ResultSet rs = st.executeQuery("SELECT " + colName + " FROM "
                + tableName + " WHERE " + colName + " = 'a-name'");
        int count = 0;
View Full Code Here

        if (edata == null || !(edata instanceof ConnectionInfo))
            return null;

        Result result = ((ConnectionInfo) edata).result;
        if (result instanceof ResultSetResult) {
            JDBCStore store = ((ResultSetResult) result).getStore();
            for (SliceStoreManager slice : _slices) {
                if (slice == store) {
                    return slice.getName();
                }
            }
View Full Code Here

    protected int count() {
        final ClassMapping[] elems = _strat.getIndependentElementMappings
            (false);
        final OpenJPAStateManager sm = assertOwner();
        final JDBCStore store = getStore();
        Union union = store.getSQLFactory().newUnion
            (Math.max(1, elems.length));
        union.select(new Union.Selector() {
            public void select(Select sel, int idx) {
                ClassMapping elem = (elems.length == 0) ? null : elems[idx];
                sel.whereForeignKey(_strat.getJoinForeignKey(elem),
                    sm.getObjectId(), _strat.getFieldMapping().
                    getDefiningMapping(), store);
            }
        });

        try {
            return union.getCount(store);
        } catch (SQLException se) {
            throw SQLExceptions.getStore(se, store.getDBDictionary());
        }
    }
View Full Code Here

    protected boolean has(final Object obj) {
        final ClassMapping[] elems = _strat.getIndependentElementMappings
            (false);
        final OpenJPAStateManager sm = assertOwner();
        final JDBCStore store = getStore();
        Union union = store.getSQLFactory().newUnion
            (Math.max(1, elems.length));
        union.select(new Union.Selector() {
            public void select(Select sel, int idx) {
                ClassMapping elem = (elems.length == 0) ? null : elems[idx];
                sel.whereForeignKey(_strat.getJoinForeignKey(elem),
                    sm.getObjectId(), _strat.getFieldMapping().
                    getDefiningMapping(), store);

                Object val = _strat.toDataStoreValue(obj, store);
                Column[] cols = _strat.getElementColumns(elem);
                Object[] vals = (cols.length == 1) ? null : (Object[]) val;
                SQLBuffer sql = new SQLBuffer(store.getDBDictionary());
                for (int i = 0; i < cols.length; i++) {
                    if (i > 0)
                        sql.append(" AND ");

                    sql.append(sel.getColumnAlias(cols[i]));
                    if (vals == null)
                        sql.append((val == null) ? " IS " : " = ").
                            appendValue(val, cols[i]);
                    else
                        sql.append((vals[i] == null) ? " IS " : " = ").
                            appendValue(vals[i], cols[i]);
                }
                sel.where(sql);
            }
        });

        try {
            return union.getCount(store) > 0;
        } catch (SQLException se) {
            throw SQLExceptions.getStore(se, store.getDBDictionary());
        }
    }
View Full Code Here

    }

    protected Iterator itr() {
        final ClassMapping[] elems = _strat.getIndependentElementMappings(true);
        final OpenJPAStateManager sm = assertOwner();
        final JDBCStore store = getStore();
        final JDBCFetchConfiguration fetch = store.getFetchConfiguration();
        final Joins[] resJoins = new Joins[Math.max(1, elems.length)];
        final FieldMapping fm = _strat.getFieldMapping();

        Union union = store.getSQLFactory().newUnion
            (Math.max(1, elems.length));
        if (fetch.getSubclassFetchMode(fm.getElementMapping().
            getTypeMapping()) != fetch.EAGER_JOIN)
            union.abortUnion();
        union.setLRS(true);
        union.select(new Union.Selector() {
            public void select(Select sel, int idx) {
                ClassMapping elem = (elems.length == 0) ? null : elems[idx];
                sel.whereForeignKey(_strat.getJoinForeignKey(elem),
                    sm.getObjectId(), fm.getDefiningMapping(), store);

                // order before select in case we're faking union with
                // multiple selects; order vals used to merge results
                fm.orderLocal(sel, elem, null);
                resJoins[idx] = _strat.joinElementRelation(sel.newJoins(),
                    elem);
                fm.orderRelation(sel, elem, resJoins[idx]);
                _strat.selectElement(sel, elem, store, fetch, fetch.EAGER_JOIN,
                    resJoins[idx]);
            }
        });

        try {
            Result res = union.execute(store, fetch);
            return new ResultIterator(sm, store, fetch, res, resJoins);
        } catch (SQLException se) {
            throw SQLExceptions.getStore(se, store.getDBDictionary());
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.openjpa.jdbc.kernel.JDBCStore

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.