Package org.apache.openjpa.jdbc.kernel

Examples of org.apache.openjpa.jdbc.kernel.JDBCFetchConfigurationImpl$JDBCConfigurationState


        String hintName = "openjpa.FetchPlan.WriteLockMode";

        EntityManager em = emf.createEntityManager();
        OpenJPAEntityManager oem = (OpenJPAEntityManager)em.getDelegate();
        JDBCFetchPlan fPlan = (JDBCFetchPlan) oem.getFetchPlan();
        JDBCFetchConfigurationImpl fConfig = (JDBCFetchConfigurationImpl)
            ((EntityManagerImpl) oem).getBroker().getFetchConfiguration();
        if(inTransaction)
            em.getTransaction().begin();

        writeLockModeHintTest(fPlan, fConfig, hintName, "none",
View Full Code Here


    @SuppressWarnings("deprecation")
    private void similarLockTimeoutHintsTest(OpenJPAEntityManager oem, String winner,
        Object expected, Object... hintNvalues) {
        JDBCFetchPlan fPlan = (JDBCFetchPlan) oem.pushFetchPlan();
        JDBCFetchConfigurationImpl fConfig = (JDBCFetchConfigurationImpl) fPlan
            .getDelegate();

        for( int i = 0 ; i < hintNvalues.length ; i += 2) {
            fPlan.setHint((String)hintNvalues[i], hintNvalues[i+1]);
        }
        for( int i = 0 ; i < hintNvalues.length ; i += 2) {
            String hintName = (String)hintNvalues[i];
            Object expectedValue = hintNvalues[i+1];
            Object getValue = fPlan.getHint(hintName);
            if (hintName.equals(winner)) {
                assertEquals(expectedValue.getClass(), getValue.getClass());
                assertEquals(expectedValue, getValue);
            }
        }
        assertEquals(expected, fPlan.getLockTimeout());
        assertEquals(expected, fConfig.getLockTimeout());

        oem.popFetchPlan();
    }
View Full Code Here

    @SuppressWarnings("deprecation")
    private void similarQueryTimeoutHintsTest(OpenJPAEntityManager oem, String winner,
        Object expected, Object... hintNvalues) {
        JDBCFetchPlan fPlan = (JDBCFetchPlan) oem.pushFetchPlan();
        JDBCFetchConfigurationImpl fConfig = (JDBCFetchConfigurationImpl) fPlan
            .getDelegate();

        for( int i = 0 ; i < hintNvalues.length ; i += 2) {
            fPlan.setHint((String)hintNvalues[i], hintNvalues[i+1]);
        }
        for( int i = 0 ; i < hintNvalues.length ; i += 2) {
            String hintName = (String)hintNvalues[i];
            Object expectedValue = hintNvalues[i+1];
            Object getValue = fPlan.getHint(hintName);
            if (hintName.equals(winner)) {
                assertEquals(expectedValue.getClass(), getValue.getClass());
                assertEquals(expectedValue, getValue);
            }
        }
        assertEquals(expected, fPlan.getQueryTimeout());
        assertEquals(expected, fConfig.getQueryTimeout());

        oem.popFetchPlan();
    }
View Full Code Here

        LockModeType lockMode, int expectedSupportSQLCount,
        String expectedSupportSQL, int expectedNonSupportSQLCount,
        String expectedNonSupportSQL, int expectedVersionUpdateCount,
        String expectedVersionUpdateSQL) {
        OpenJPAEntityManager oem = (OpenJPAEntityManager) em.getDelegate();
        JDBCFetchConfigurationImpl fConfig = (JDBCFetchConfigurationImpl)
            ((EntityManagerImpl) oem).getBroker().getFetchConfiguration();
        DBDictionary dict = ((JDBCConfiguration) ((OpenJPAEntityManagerSPI) oem)
            .getConfiguration()).getDBDictionaryInstance();

        em.clear();
        resetSQL();
        int beforeIsolation = fConfig.getIsolation();
        em.find(LockEmployee.class, 1, lockMode);
        if (dict.supportsIsolationForUpdate() &&
            dict instanceof DB2Dictionary) {
            assertEquals(expectedSupportSQLCount, getSQLCount());
            assertAllSQLInOrder(expectedSupportSQL);
        } else {
            assertEquals(expectedNonSupportSQLCount, getSQLCount());
            assertAllSQLInOrder(expectedNonSupportSQL);
        }

        resetSQL();
        em.flush();
        assertEquals(expectedVersionUpdateCount, getSQLCount());
        if (expectedVersionUpdateSQL != null)
            assertAllSQLInOrder(expectedVersionUpdateSQL);

        assertEquals(beforeIsolation, fConfig.getIsolation());
    }
View Full Code Here

        LockModeType lockMode, int expectedSupportSQLCount,
        String expectedSupportSQL, int expectedNonSupportSQLCount,
        String expectedNonSupportSQL, int expectedVersionUpdateCount,
        String expectedVersionUpdateSQL) {
        OpenJPAEntityManager oem = (OpenJPAEntityManager) em.getDelegate();
        JDBCFetchConfigurationImpl fConfig = (JDBCFetchConfigurationImpl)
            ((EntityManagerImpl) oem).getBroker().getFetchConfiguration();
        DBDictionary dict = ((JDBCConfiguration) ((OpenJPAEntityManagerSPI) oem)
            .getConfiguration()).getDBDictionaryInstance();

        em.clear();
        LockEmployee employee = em.find(LockEmployee.class, 1);
        resetSQL();
        int beforeIsolation = fConfig.getIsolation();
        em.refresh(employee, lockMode);
        if (dict.supportsIsolationForUpdate() &&
            dict instanceof DB2Dictionary) {
            assertEquals(expectedSupportSQLCount, getSQLCount());
            assertAllSQLInOrder(expectedSupportSQL);
        } else {
            assertEquals(expectedNonSupportSQLCount, getSQLCount());
            assertAllSQLInOrder(expectedNonSupportSQL);
        }

        resetSQL();
        em.flush();
        assertEquals(expectedVersionUpdateCount, getSQLCount());
        if (expectedVersionUpdateSQL != null)
            assertAllSQLInOrder(expectedVersionUpdateSQL);

        assertEquals(beforeIsolation, fConfig.getIsolation());
    }
View Full Code Here

        LockModeType lockMode, int expectedSupportSQLCount,
        String expectedSupportSQL, int expectedNonSupportSQLCount,
        String expectedNonSupportSQL, int expectedVersionUpdateCount,
        String expectedVersionUpdateSQL) {
        OpenJPAEntityManager oem = (OpenJPAEntityManager) em.getDelegate();
        JDBCFetchConfigurationImpl fConfig = (JDBCFetchConfigurationImpl)
            ((EntityManagerImpl) oem).getBroker().getFetchConfiguration();
        DBDictionary dict = ((JDBCConfiguration) ((OpenJPAEntityManagerSPI) oem)
            .getConfiguration()).getDBDictionaryInstance();

        em.clear();
        LockEmployee employee = em.find(LockEmployee.class, 1);
        resetSQL();
        int beforeIsolation = fConfig.getIsolation();
        em.lock(employee, lockMode);
        if (dict.supportsIsolationForUpdate() &&
            dict instanceof DB2Dictionary) {
            assertEquals(expectedSupportSQLCount, getSQLCount());
            if (expectedSupportSQL != null)
                assertAllSQLInOrder(expectedSupportSQL);
        } else {
            assertEquals(expectedNonSupportSQLCount, getSQLCount());
            if (expectedNonSupportSQL != null)
                assertAllSQLInOrder(expectedNonSupportSQL);
        }
       
        resetSQL();
        em.flush();
        assertEquals(expectedVersionUpdateCount, getSQLCount());
        if (expectedVersionUpdateSQL != null)
            assertAllSQLInOrder(expectedVersionUpdateSQL);

        assertEquals(beforeIsolation, fConfig.getIsolation());
    }
View Full Code Here

                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];
View Full Code Here

        String hintName = "openjpa.jdbc.EagerFetchMode";

        EntityManager em = emf.createEntityManager();
        OpenJPAEntityManager oem = (OpenJPAEntityManager) em.getDelegate();
        JDBCFetchPlan fPlan = (JDBCFetchPlan) oem.getFetchPlan();
        JDBCFetchConfigurationImpl fConfig = (JDBCFetchConfigurationImpl)
            ((EntityManagerImpl) oem).getBroker().getFetchConfiguration();

        eagerFetchModeHintTest(fPlan, fConfig, hintName, String
            .valueOf(EagerFetchModes.EAGER_NONE), FetchMode.NONE,
            EagerFetchModes.EAGER_NONE);
View Full Code Here

        String hintName = "openjpa.FetchPlan.JoinSyntax";

        EntityManager em = emf.createEntityManager();
        OpenJPAEntityManager oem = (OpenJPAEntityManager)em.getDelegate();
        JDBCFetchPlan fPlan = (JDBCFetchPlan) oem.getFetchPlan();
        JDBCFetchConfigurationImpl fConfig = (JDBCFetchConfigurationImpl)
            ((EntityManagerImpl) oem).getBroker().getFetchConfiguration();

        joinSyntaxHintTest(fPlan, fConfig, hintName, "sql92",
            JoinSyntax.SQL92, JoinSyntaxes.SYNTAX_SQL92);
        joinSyntaxHintTest(fPlan, fConfig, hintName, JoinSyntax.SQL92.name(),
View Full Code Here

        String hintName = "openjpa.jdbc.JoinSyntax";

        EntityManager em = emf.createEntityManager();
        OpenJPAEntityManager oem = (OpenJPAEntityManager) em.getDelegate();
        JDBCFetchPlan fPlan = (JDBCFetchPlan) oem.getFetchPlan();
        JDBCFetchConfigurationImpl fConfig = (JDBCFetchConfigurationImpl)
            ((EntityManagerImpl) oem).getBroker().getFetchConfiguration();

        joinSyntaxHintTest(fPlan, fConfig, hintName, String
            .valueOf(JoinSyntaxes.SYNTAX_SQL92), JoinSyntax.SQL92,
            JoinSyntaxes.SYNTAX_SQL92);
        joinSyntaxHintTest(fPlan, fConfig, hintName, JoinSyntaxes.SYNTAX_SQL92,
            JoinSyntax.SQL92, JoinSyntaxes.SYNTAX_SQL92);

        joinSyntaxHintTest(fPlan, fConfig, hintName, String
            .valueOf(JoinSyntaxes.SYNTAX_TRADITIONAL), JoinSyntax.TRADITIONAL,
            JoinSyntaxes.SYNTAX_TRADITIONAL);
        joinSyntaxHintTest(fPlan, fConfig, hintName,
            JoinSyntaxes.SYNTAX_TRADITIONAL, JoinSyntax.TRADITIONAL,
            JoinSyntaxes.SYNTAX_TRADITIONAL);

        joinSyntaxHintTest(fPlan, fConfig, hintName, String
            .valueOf(JoinSyntaxes.SYNTAX_DATABASE), JoinSyntax.DATABASE,
            JoinSyntaxes.SYNTAX_DATABASE);
        joinSyntaxHintTest(fPlan, fConfig, hintName,
            JoinSyntaxes.SYNTAX_DATABASE, JoinSyntax.DATABASE,
            JoinSyntaxes.SYNTAX_DATABASE);

        try {
            fPlan.setHint(hintName, "xxxxx", false);
            fPlan.setHint(hintName, "yyyyy", true);
            fail("Expecting a IllegalArgumentException.");
        } catch (Exception e) {
            assertTrue("Caught expected exception",
                IllegalArgumentException.class.isAssignableFrom(e.getClass()));
        }
        try {
            fPlan.setHint(hintName, "12345", false);
            fPlan.setHint(hintName, "67890", true);
            fail("Expecting a IllegalArgumentException.");
        } catch (Exception e) {
            assertTrue("Caught expected exception",
                IllegalArgumentException.class.isAssignableFrom(e.getClass()));
        }
        try {
            fPlan.setHint(hintName, -1, false);
            fPlan.setHint(hintName, -2, true);
            fail("Expecting a IllegalArgumentException.");
        } catch (Exception e) {
            assertTrue("Caught expected exception",
                IllegalArgumentException.class.isAssignableFrom(e.getClass()));
        }
        try {
            fPlan.setHint(hintName, FetchConfiguration.DEFAULT, true);
            assertEquals(fConfig.getJoinSyntax(),
                ((JDBCConfiguration) fConfig.getContext().getConfiguration())
                    .getDBDictionaryInstance().joinSyntax);
        } catch (Exception e) {
            fail("Unexpected " + e.getClass().getName());
        }
        em.close();
View Full Code Here

TOP

Related Classes of org.apache.openjpa.jdbc.kernel.JDBCFetchConfigurationImpl$JDBCConfigurationState

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.