Examples of JDBCFetchPlan


Examples of org.apache.openjpa.persistence.jdbc.JDBCFetchPlan

    public void testJdbcResultSetTypeHint() {
        String hintName = "openjpa.jdbc.ResultSetType";

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

        resultSetTypeHintTest(fPlan, fConfig, hintName, String
            .valueOf(ResultSet.TYPE_FORWARD_ONLY), ResultSetType.FORWARD_ONLY,
            ResultSet.TYPE_FORWARD_ONLY);
        resultSetTypeHintTest(fPlan, fConfig, hintName,
            ResultSet.TYPE_FORWARD_ONLY, ResultSetType.FORWARD_ONLY,
            ResultSet.TYPE_FORWARD_ONLY);

        resultSetTypeHintTest(fPlan, fConfig, hintName, String
            .valueOf(ResultSet.TYPE_SCROLL_SENSITIVE),
            ResultSetType.SCROLL_SENSITIVE, ResultSet.TYPE_SCROLL_SENSITIVE);
        resultSetTypeHintTest(fPlan, fConfig, hintName,
            ResultSet.TYPE_SCROLL_SENSITIVE, ResultSetType.SCROLL_SENSITIVE,
            ResultSet.TYPE_SCROLL_SENSITIVE);

        resultSetTypeHintTest(fPlan, fConfig, hintName, String
            .valueOf(ResultSet.TYPE_SCROLL_INSENSITIVE),
            ResultSetType.SCROLL_INSENSITIVE,
            ResultSet.TYPE_SCROLL_INSENSITIVE);
        resultSetTypeHintTest(fPlan, fConfig, hintName,
            ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSetType.SCROLL_INSENSITIVE,
            ResultSet.TYPE_SCROLL_INSENSITIVE);

        try {
            fPlan.setHint(hintName, "xxxxx");
            fPlan.setHint(hintName, "yyyyy");
            fail("Expecting a a IllegalArgumentException.");
        } catch (Exception e) {
            assertTrue("Caught expected exception",
                IllegalArgumentException.class.isAssignableFrom(e.getClass()));
        }
        try {
            fPlan.setHint(hintName, "12345");
            fPlan.setHint(hintName, "67890");
            fail("Expecting a a IllegalArgumentException.");
        } catch (Exception e) {
            assertTrue("Caught expected exception",
                IllegalArgumentException.class.isAssignableFrom(e.getClass()));
        }
        try {
            fPlan.setHint(hintName, -1);
            fPlan.setHint(hintName, -2);
            fail("Expecting a a IllegalArgumentException.");
        } catch (Exception e) {
            assertTrue("Caught expected exception",
                IllegalArgumentException.class.isAssignableFrom(e.getClass()));
        }
        try {
            fPlan.setHint(hintName, FetchConfiguration.DEFAULT);
            assertEquals(ResultSet.TYPE_FORWARD_ONLY, fConfig
                .getResultSetType());
        } catch (Exception e) {
            fail("Unexpected " + e.getClass().getName());
        }
View Full Code Here

Examples of org.apache.openjpa.persistence.jdbc.JDBCFetchPlan

    public void testFetchPlanSubclassFetchModeHint() {
        String hintName = "openjpa.FetchPlan.SubclassFetchMode";

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

        subclassFetchModeHintTest(fPlan, fConfig, hintName, "none",
            FetchMode.NONE, EagerFetchModes.EAGER_NONE);
        subclassFetchModeHintTest(fPlan, fConfig, hintName, FetchMode.NONE
            .name(), FetchMode.NONE, EagerFetchModes.EAGER_NONE);
        subclassFetchModeHintTest(fPlan, fConfig, hintName, FetchMode.NONE,
            FetchMode.NONE, EagerFetchModes.EAGER_NONE);

        subclassFetchModeHintTest(fPlan, fConfig, hintName, "parallel",
            FetchMode.PARALLEL, EagerFetchModes.EAGER_PARALLEL);
        subclassFetchModeHintTest(fPlan, fConfig, hintName, FetchMode.PARALLEL
            .name(), FetchMode.PARALLEL, EagerFetchModes.EAGER_PARALLEL);
        subclassFetchModeHintTest(fPlan, fConfig, hintName, FetchMode.PARALLEL,
            FetchMode.PARALLEL, EagerFetchModes.EAGER_PARALLEL);

        subclassFetchModeHintTest(fPlan, fConfig, hintName, "join",
            FetchMode.JOIN, EagerFetchModes.EAGER_JOIN);
        subclassFetchModeHintTest(fPlan, fConfig, hintName, FetchMode.JOIN
            .name(), FetchMode.JOIN, EagerFetchModes.EAGER_JOIN);
        subclassFetchModeHintTest(fPlan, fConfig, hintName, FetchMode.JOIN,
            FetchMode.JOIN, EagerFetchModes.EAGER_JOIN);

        try {
            fPlan.setHint(hintName, "xxxxx");
            fPlan.setHint(hintName, "yyyyy");
            fail("Expecting a a IllegalArgumentException.");
        } catch (Exception e) {
            assertTrue("Caught expected exception",
                IllegalArgumentException.class.isAssignableFrom(e.getClass()));
        }
        try {
            fPlan.setHint(hintName, "12345");
            fPlan.setHint(hintName, "67890");
            fail("Expecting a a IllegalArgumentException.");
        } catch (Exception e) {
            assertTrue("Caught expected exception",
                IllegalArgumentException.class.isAssignableFrom(e.getClass()));
        }
        try {
            fPlan.setHint(hintName, -1);
            fPlan.setHint(hintName, -2);
            fail("Expecting a a IllegalArgumentException.");
        } catch (Exception e) {
            assertTrue("Caught expected exception",
                IllegalArgumentException.class.isAssignableFrom(e.getClass()));
        }
View Full Code Here

Examples of org.apache.openjpa.persistence.jdbc.JDBCFetchPlan

    public void testJdbcSubclassFetchModeHint() {
        String hintName = "openjpa.jdbc.SubclassFetchMode";

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

        subclassFetchModeHintTest(fPlan, fConfig, hintName, String
            .valueOf(EagerFetchModes.EAGER_NONE), FetchMode.NONE,
            EagerFetchModes.EAGER_NONE);
        subclassFetchModeHintTest(fPlan, fConfig, hintName,
            EagerFetchModes.EAGER_NONE, FetchMode.NONE,
            EagerFetchModes.EAGER_NONE);

        subclassFetchModeHintTest(fPlan, fConfig, hintName, String
            .valueOf(EagerFetchModes.EAGER_PARALLEL), FetchMode.PARALLEL,
            EagerFetchModes.EAGER_PARALLEL);
        subclassFetchModeHintTest(fPlan, fConfig, hintName,
            EagerFetchModes.EAGER_PARALLEL, FetchMode.PARALLEL,
            EagerFetchModes.EAGER_PARALLEL);

        subclassFetchModeHintTest(fPlan, fConfig, hintName, String
            .valueOf(EagerFetchModes.EAGER_JOIN), FetchMode.JOIN,
            EagerFetchModes.EAGER_JOIN);
        subclassFetchModeHintTest(fPlan, fConfig, hintName,
            EagerFetchModes.EAGER_JOIN, FetchMode.JOIN,
            EagerFetchModes.EAGER_JOIN);

        try {
            fPlan.setHint(hintName, "xxxxx");
            fPlan.setHint(hintName, "yyyyy");
            fail("Expecting a a IllegalArgumentException.");
        } catch (Exception e) {
            assertTrue("Caught expected exception",
                IllegalArgumentException.class.isAssignableFrom(e.getClass()));
        }
        try {
            fPlan.setHint(hintName, "12345");
            fPlan.setHint(hintName, "67890");
            fail("Expecting a a IllegalArgumentException.");
        } catch (Exception e) {
            assertTrue("Caught expected exception",
                IllegalArgumentException.class.isAssignableFrom(e.getClass()));
        }
        try {
            fPlan.setHint(hintName, -1);
            fPlan.setHint(hintName, -2);
            fail("Expecting a a IllegalArgumentException.");
        } catch (Exception e) {
            assertTrue("Caught expected exception",
                IllegalArgumentException.class.isAssignableFrom(e.getClass()));
        }
        try {
            fPlan.setHint(hintName, FetchConfiguration.DEFAULT);
            assertEquals(EagerFetchModes.EAGER_JOIN, fConfig
                .getSubclassFetchMode());
        } catch (Exception e) {
            fail("Unexpected " + e.getClass().getName());
        }
View Full Code Here

Examples of org.apache.openjpa.persistence.jdbc.JDBCFetchPlan

    public void testFlushBeforeQueriesHint() {
        String hintName = "openjpa.FlushBeforeQueries";

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

        flushBeforeQueriesHintTest(fPlan, fConfig, hintName, String
            .valueOf(QueryFlushModes.FLUSH_TRUE), QueryFlushModes.FLUSH_TRUE);
        flushBeforeQueriesHintTest(fPlan, fConfig, hintName,
            QueryFlushModes.FLUSH_TRUE, QueryFlushModes.FLUSH_TRUE);

        flushBeforeQueriesHintTest(fPlan, fConfig, hintName, String
            .valueOf(QueryFlushModes.FLUSH_FALSE), QueryFlushModes.FLUSH_FALSE);
        flushBeforeQueriesHintTest(fPlan, fConfig, hintName,
            QueryFlushModes.FLUSH_FALSE, QueryFlushModes.FLUSH_FALSE);

        flushBeforeQueriesHintTest(fPlan, fConfig, hintName, String
            .valueOf(QueryFlushModes.FLUSH_WITH_CONNECTION),
            QueryFlushModes.FLUSH_WITH_CONNECTION);
        flushBeforeQueriesHintTest(fPlan, fConfig, hintName,
            QueryFlushModes.FLUSH_WITH_CONNECTION,
            QueryFlushModes.FLUSH_WITH_CONNECTION);

        try {
            fPlan.setHint(hintName, "xxxxx");
            fPlan.setHint(hintName, "yyyyy");
            fail("Expecting a a IllegalArgumentException.");
        } catch (Exception e) {
            assertTrue("Caught expected exception",
                IllegalArgumentException.class.isAssignableFrom(e.getClass()));
        }
        try {
            fPlan.setHint(hintName, "12345");
            fPlan.setHint(hintName, "67890");
            fail("Expecting a a IllegalArgumentException.");
        } catch (Exception e) {
            assertTrue("Caught expected exception",
                IllegalArgumentException.class.isAssignableFrom(e.getClass()));
        }
        try {
            fPlan.setHint(hintName, -1);
            fPlan.setHint(hintName, -2);
            fail("Expecting a a IllegalArgumentException.");
        } catch (Exception e) {
            assertTrue("Caught expected exception",
                IllegalArgumentException.class.isAssignableFrom(e.getClass()));
        }
        try {
            fPlan.setHint(hintName, FetchConfiguration.DEFAULT);
            fConfig.getFlushBeforeQueries();
            assertEquals(QueryFlushModes.FLUSH_TRUE, fConfig
                .getFlushBeforeQueries());
        } catch (Exception e) {
            fail("Unexpected " + e.getClass().getName());
View Full Code Here

Examples of org.apache.openjpa.persistence.jdbc.JDBCFetchPlan

    public void testReadLockLevelHint() {
        String hintName = "openjpa.ReadLockLevel";

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

        readLockLevelHintTest(fPlan, fConfig, hintName, String
            .valueOf(MixedLockLevels.LOCK_NONE), LockModeType.NONE,
            MixedLockLevels.LOCK_NONE);
        readLockLevelHintTest(fPlan, fConfig, hintName,
            MixedLockLevels.LOCK_NONE, LockModeType.NONE,
            MixedLockLevels.LOCK_NONE);

        readLockLevelHintTest(fPlan, fConfig, hintName, String
            .valueOf(MixedLockLevels.LOCK_READ), LockModeType.READ,
            MixedLockLevels.LOCK_READ);
        readLockLevelHintTest(fPlan, fConfig, hintName,
            MixedLockLevels.LOCK_READ, LockModeType.READ,
            MixedLockLevels.LOCK_READ);

        readLockLevelHintTest(fPlan, fConfig, hintName, String
            .valueOf(MixedLockLevels.LOCK_WRITE), LockModeType.WRITE,
            MixedLockLevels.LOCK_WRITE);
        readLockLevelHintTest(fPlan, fConfig, hintName,
            MixedLockLevels.LOCK_WRITE, LockModeType.WRITE,
            MixedLockLevels.LOCK_WRITE);

        readLockLevelHintTest(fPlan, fConfig, hintName, String
            .valueOf(MixedLockLevels.LOCK_OPTIMISTIC), LockModeType.OPTIMISTIC,
            MixedLockLevels.LOCK_OPTIMISTIC);
        readLockLevelHintTest(fPlan, fConfig, hintName,
            MixedLockLevels.LOCK_OPTIMISTIC, LockModeType.OPTIMISTIC,
            MixedLockLevels.LOCK_OPTIMISTIC);

        readLockLevelHintTest(fPlan, fConfig, hintName, String
            .valueOf(MixedLockLevels.LOCK_OPTIMISTIC_FORCE_INCREMENT),
            LockModeType.OPTIMISTIC_FORCE_INCREMENT,
            MixedLockLevels.LOCK_OPTIMISTIC_FORCE_INCREMENT);
        readLockLevelHintTest(fPlan, fConfig, hintName,
            MixedLockLevels.LOCK_OPTIMISTIC_FORCE_INCREMENT,
            LockModeType.OPTIMISTIC_FORCE_INCREMENT,
            MixedLockLevels.LOCK_OPTIMISTIC_FORCE_INCREMENT);

        readLockLevelHintTest(fPlan, fConfig, hintName,
            String.valueOf(MixedLockLevels.LOCK_PESSIMISTIC_READ),
            LockModeType.PESSIMISTIC_READ,
            MixedLockLevels.LOCK_PESSIMISTIC_READ);
        readLockLevelHintTest(fPlan, fConfig, hintName,
            MixedLockLevels.LOCK_PESSIMISTIC_READ,
            LockModeType.PESSIMISTIC_READ,
            MixedLockLevels.LOCK_PESSIMISTIC_READ);

        readLockLevelHintTest(fPlan, fConfig, hintName,
            String.valueOf(MixedLockLevels.LOCK_PESSIMISTIC_WRITE),
            LockModeType.PESSIMISTIC_WRITE,
            MixedLockLevels.LOCK_PESSIMISTIC_WRITE);
        readLockLevelHintTest(fPlan, fConfig, hintName,
            MixedLockLevels.LOCK_PESSIMISTIC_WRITE,
            LockModeType.PESSIMISTIC_WRITE,
            MixedLockLevels.LOCK_PESSIMISTIC_WRITE);

        readLockLevelHintTest(fPlan, fConfig, hintName, String
            .valueOf(MixedLockLevels.LOCK_PESSIMISTIC_FORCE_INCREMENT),
            LockModeType.PESSIMISTIC_FORCE_INCREMENT,
            MixedLockLevels.LOCK_PESSIMISTIC_FORCE_INCREMENT);
        readLockLevelHintTest(fPlan, fConfig, hintName,
            MixedLockLevels.LOCK_PESSIMISTIC_FORCE_INCREMENT,
            LockModeType.PESSIMISTIC_FORCE_INCREMENT,
            MixedLockLevels.LOCK_PESSIMISTIC_FORCE_INCREMENT);

        try {
            fPlan.setHint(hintName, "xxxxx");
            fPlan.setHint(hintName, "yyyyy");
            fail("Expecting a a IllegalArgumentException.");
        } catch (Exception e) {
            assertTrue("Caught expected exception",
                IllegalArgumentException.class.isAssignableFrom(e.getClass()));
        }
        try {
            fPlan.setHint(hintName, "12345");
            fPlan.setHint(hintName, "67890");
            fail("Expecting a a IllegalArgumentException.");
        } catch (Exception e) {
            assertTrue("Caught expected exception",
                IllegalArgumentException.class.isAssignableFrom(e.getClass()));
        }
        try {
            fPlan.setHint(hintName, -1);
            fPlan.setHint(hintName, -2);
            fail("Expecting a a IllegalArgumentException.");
        } catch (Exception e) {
            assertTrue("Caught expected exception",
                IllegalArgumentException.class.isAssignableFrom(e.getClass()));
        }
        try {
            fPlan.setHint(hintName, FetchConfiguration.DEFAULT);
            assertEquals(MixedLockLevels.LOCK_READ, fConfig.getReadLockLevel());
        } catch (Exception e) {
            fail("Unexpected " + e.getClass().getName());
        }
        em.getTransaction().rollback();
View Full Code Here

Examples of org.apache.openjpa.persistence.jdbc.JDBCFetchPlan

    public void testWriteLockLevelHint() {
        String hintName = "openjpa.WriteLockLevel";

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

        writeLockLevelHintTest(fPlan, fConfig, hintName, String
            .valueOf(MixedLockLevels.LOCK_NONE), LockModeType.NONE,
            MixedLockLevels.LOCK_NONE);
        writeLockLevelHintTest(fPlan, fConfig, hintName,
            MixedLockLevels.LOCK_NONE, LockModeType.NONE,
            MixedLockLevels.LOCK_NONE);

        writeLockLevelHintTest(fPlan, fConfig, hintName, String
            .valueOf(MixedLockLevels.LOCK_READ), LockModeType.READ,
            MixedLockLevels.LOCK_READ);
        writeLockLevelHintTest(fPlan, fConfig, hintName,
            MixedLockLevels.LOCK_READ, LockModeType.READ,
            MixedLockLevels.LOCK_READ);

        writeLockLevelHintTest(fPlan, fConfig, hintName, String
            .valueOf(MixedLockLevels.LOCK_WRITE), LockModeType.WRITE,
            MixedLockLevels.LOCK_WRITE);
        writeLockLevelHintTest(fPlan, fConfig, hintName,
            MixedLockLevels.LOCK_WRITE, LockModeType.WRITE,
            MixedLockLevels.LOCK_WRITE);

        writeLockLevelHintTest(fPlan, fConfig, hintName, String
            .valueOf(MixedLockLevels.LOCK_OPTIMISTIC), LockModeType.OPTIMISTIC,
            MixedLockLevels.LOCK_OPTIMISTIC);
        writeLockLevelHintTest(fPlan, fConfig, hintName,
            MixedLockLevels.LOCK_OPTIMISTIC, LockModeType.OPTIMISTIC,
            MixedLockLevels.LOCK_OPTIMISTIC);

        writeLockLevelHintTest(fPlan, fConfig, hintName, String
            .valueOf(MixedLockLevels.LOCK_OPTIMISTIC_FORCE_INCREMENT),
            LockModeType.OPTIMISTIC_FORCE_INCREMENT,
            MixedLockLevels.LOCK_OPTIMISTIC_FORCE_INCREMENT);
        writeLockLevelHintTest(fPlan, fConfig, hintName,
            MixedLockLevels.LOCK_OPTIMISTIC_FORCE_INCREMENT,
            LockModeType.OPTIMISTIC_FORCE_INCREMENT,
            MixedLockLevels.LOCK_OPTIMISTIC_FORCE_INCREMENT);

        writeLockLevelHintTest(fPlan, fConfig, hintName,
            String.valueOf(MixedLockLevels.LOCK_PESSIMISTIC_READ),
            LockModeType.PESSIMISTIC_READ,
            MixedLockLevels.LOCK_PESSIMISTIC_READ);
        writeLockLevelHintTest(fPlan, fConfig, hintName,
            MixedLockLevels.LOCK_PESSIMISTIC_READ,
            LockModeType.PESSIMISTIC_READ,
            MixedLockLevels.LOCK_PESSIMISTIC_READ);

        writeLockLevelHintTest(fPlan, fConfig, hintName,
            String.valueOf(MixedLockLevels.LOCK_PESSIMISTIC_WRITE),
            LockModeType.PESSIMISTIC_WRITE,
            MixedLockLevels.LOCK_PESSIMISTIC_WRITE);
        writeLockLevelHintTest(fPlan, fConfig, hintName,
            MixedLockLevels.LOCK_PESSIMISTIC_WRITE,
            LockModeType.PESSIMISTIC_WRITE,
            MixedLockLevels.LOCK_PESSIMISTIC_WRITE);

        writeLockLevelHintTest(fPlan, fConfig, hintName, String
            .valueOf(MixedLockLevels.LOCK_PESSIMISTIC_FORCE_INCREMENT),
            LockModeType.PESSIMISTIC_FORCE_INCREMENT,
            MixedLockLevels.LOCK_PESSIMISTIC_FORCE_INCREMENT);
        writeLockLevelHintTest(fPlan, fConfig, hintName,
            MixedLockLevels.LOCK_PESSIMISTIC_FORCE_INCREMENT,
            LockModeType.PESSIMISTIC_FORCE_INCREMENT,
            MixedLockLevels.LOCK_PESSIMISTIC_FORCE_INCREMENT);

        try {
            fPlan.setHint(hintName, "xxxxx");
            fPlan.setHint(hintName, "yyyyy");
            fail("Expecting a a IllegalArgumentException.");
        } catch (Exception e) {
            assertTrue("Caught expected exception",
                IllegalArgumentException.class.isAssignableFrom(e.getClass()));
        }
        try {
            fPlan.setHint(hintName, "12345");
            fPlan.setHint(hintName, "67890");
            fail("Expecting a a IllegalArgumentException.");
        } catch (Exception e) {
            assertTrue("Caught expected exception",
                IllegalArgumentException.class.isAssignableFrom(e.getClass()));
        }
        try {
            fPlan.setHint(hintName, -1);
            fPlan.setHint(hintName, -2);
            fail("Expecting a a IllegalArgumentException.");
        } catch (Exception e) {
            assertTrue("Caught expected exception",
                IllegalArgumentException.class.isAssignableFrom(e.getClass()));
        }
        try {
            fPlan.setHint(hintName, FetchConfiguration.DEFAULT);
            assertEquals(MixedLockLevels.LOCK_WRITE, fConfig
                .getWriteLockLevel());
        } catch (Exception e) {
            fail("Unexpected " + e.getClass().getName());
        }
View Full Code Here

Examples of org.apache.openjpa.persistence.jdbc.JDBCFetchPlan

    private void fetchPlanReadLockModeHint(boolean inTransaction) {
        String hintName = "openjpa.FetchPlan.ReadLockMode";

        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();

        readLockModeHintTest(fPlan, fConfig, hintName, "none",
            LockModeType.NONE, MixedLockLevels.LOCK_NONE);
        readLockModeHintTest(fPlan, fConfig, hintName, LockModeType.NONE,
            LockModeType.NONE, MixedLockLevels.LOCK_NONE);
        readLockModeHintTest(fPlan, fConfig, hintName,
            LockModeType.NONE.name(), LockModeType.NONE,
            MixedLockLevels.LOCK_NONE);

        readLockModeHintTest(fPlan, fConfig, hintName, "read",
            LockModeType.READ, MixedLockLevels.LOCK_READ);
        readLockModeHintTest(fPlan, fConfig, hintName, LockModeType.READ,
            LockModeType.READ, MixedLockLevels.LOCK_READ);
        readLockModeHintTest(fPlan, fConfig, hintName,
            LockModeType.READ.name(), LockModeType.READ,
            MixedLockLevels.LOCK_READ);

        readLockModeHintTest(fPlan, fConfig, hintName, "write",
            LockModeType.WRITE, MixedLockLevels.LOCK_WRITE);
        readLockModeHintTest(fPlan, fConfig, hintName, LockModeType.WRITE,
            LockModeType.WRITE, MixedLockLevels.LOCK_WRITE);
        readLockModeHintTest(fPlan, fConfig, hintName, LockModeType.WRITE
            .name(), LockModeType.WRITE, MixedLockLevels.LOCK_WRITE);

        readLockModeHintTest(fPlan, fConfig, hintName, "optimistic",
            LockModeType.OPTIMISTIC, MixedLockLevels.LOCK_OPTIMISTIC);
        readLockModeHintTest(fPlan, fConfig, hintName, LockModeType.OPTIMISTIC,
            LockModeType.OPTIMISTIC, MixedLockLevels.LOCK_OPTIMISTIC);
        readLockModeHintTest(fPlan, fConfig, hintName, LockModeType.OPTIMISTIC
            .name(), LockModeType.OPTIMISTIC, MixedLockLevels.LOCK_OPTIMISTIC);

        readLockModeHintTest(fPlan, fConfig, hintName,
            "optimistic-force-increment",
            LockModeType.OPTIMISTIC_FORCE_INCREMENT,
            MixedLockLevels.LOCK_OPTIMISTIC_FORCE_INCREMENT);
        readLockModeHintTest(fPlan, fConfig, hintName,
            LockModeType.OPTIMISTIC_FORCE_INCREMENT,
            LockModeType.OPTIMISTIC_FORCE_INCREMENT,
            MixedLockLevels.LOCK_OPTIMISTIC_FORCE_INCREMENT);
        readLockModeHintTest(fPlan, fConfig, hintName,
            LockModeType.OPTIMISTIC_FORCE_INCREMENT.name(),
            LockModeType.OPTIMISTIC_FORCE_INCREMENT,
            MixedLockLevels.LOCK_OPTIMISTIC_FORCE_INCREMENT);

        readLockModeHintTest(fPlan, fConfig, hintName,
            "pessimistic-read", LockModeType.PESSIMISTIC_READ,
            MixedLockLevels.LOCK_PESSIMISTIC_READ);
        readLockModeHintTest(fPlan, fConfig, hintName,
            LockModeType.PESSIMISTIC_READ, LockModeType.PESSIMISTIC_READ,
            MixedLockLevels.LOCK_PESSIMISTIC_READ);
        readLockModeHintTest(fPlan, fConfig, hintName,
            LockModeType.PESSIMISTIC_READ.name(),
            LockModeType.PESSIMISTIC_READ,
            MixedLockLevels.LOCK_PESSIMISTIC_READ);

        readLockModeHintTest(fPlan, fConfig, hintName,
            "pessimistic-write", LockModeType.PESSIMISTIC_WRITE,
            MixedLockLevels.LOCK_PESSIMISTIC_WRITE);
        readLockModeHintTest(fPlan, fConfig, hintName,
            LockModeType.PESSIMISTIC_WRITE, LockModeType.PESSIMISTIC_WRITE,
            MixedLockLevels.LOCK_PESSIMISTIC_WRITE);
        readLockModeHintTest(fPlan, fConfig, hintName,
            LockModeType.PESSIMISTIC_WRITE.name(),
            LockModeType.PESSIMISTIC_WRITE,
            MixedLockLevels.LOCK_PESSIMISTIC_WRITE);

        readLockModeHintTest(fPlan, fConfig, hintName,
            "pessimistic-force-increment",
            LockModeType.PESSIMISTIC_FORCE_INCREMENT,
            MixedLockLevels.LOCK_PESSIMISTIC_FORCE_INCREMENT);
        readLockModeHintTest(fPlan, fConfig, hintName,
            LockModeType.PESSIMISTIC_FORCE_INCREMENT,
            LockModeType.PESSIMISTIC_FORCE_INCREMENT,
            MixedLockLevels.LOCK_PESSIMISTIC_FORCE_INCREMENT);
        readLockModeHintTest(fPlan, fConfig, hintName,
            LockModeType.PESSIMISTIC_FORCE_INCREMENT.name(),
            LockModeType.PESSIMISTIC_FORCE_INCREMENT,
            MixedLockLevels.LOCK_PESSIMISTIC_FORCE_INCREMENT);

        try {
            fPlan.setHint(hintName, "xxxxx");
            fPlan.setHint(hintName, "yyyyy");
            fail("Expecting a a IllegalArgumentException.");
        } catch (Exception e) {
            assertTrue("Caught expected exception",
                IllegalArgumentException.class.isAssignableFrom(e.getClass()));
        }
        try {
            fPlan.setHint(hintName, "12345");
            fPlan.setHint(hintName, "67890");
            fail("Expecting a a IllegalArgumentException.");
        } catch (Exception e) {
            assertTrue("Caught expected exception",
                IllegalArgumentException.class.isAssignableFrom(e.getClass()));
        }
        try {
            fPlan.setHint(hintName, -1);
            fPlan.setHint(hintName, -2);
            fail("Expecting a a IllegalArgumentException.");
        } catch (Exception e) {
            assertTrue("Caught expected exception",
                IllegalArgumentException.class.isAssignableFrom(e.getClass()));
        }
View Full Code Here

Examples of org.apache.openjpa.persistence.jdbc.JDBCFetchPlan

    private void fetchPlanWriteLockModeHint(boolean inTransaction) {
        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",
            LockModeType.NONE, MixedLockLevels.LOCK_NONE);
        writeLockModeHintTest(fPlan, fConfig, hintName, LockModeType.NONE,
            LockModeType.NONE, MixedLockLevels.LOCK_NONE);
        writeLockModeHintTest(fPlan, fConfig, hintName, LockModeType.NONE
            .name(), LockModeType.NONE, MixedLockLevels.LOCK_NONE);

        writeLockModeHintTest(fPlan, fConfig, hintName, "read",
            LockModeType.READ, MixedLockLevels.LOCK_READ);
        writeLockModeHintTest(fPlan, fConfig, hintName, LockModeType.READ,
            LockModeType.READ, MixedLockLevels.LOCK_READ);
        writeLockModeHintTest(fPlan, fConfig, hintName, LockModeType.READ
            .name(), LockModeType.READ, MixedLockLevels.LOCK_READ);

        writeLockModeHintTest(fPlan, fConfig, hintName, "write",
            LockModeType.WRITE, MixedLockLevels.LOCK_WRITE);
        writeLockModeHintTest(fPlan, fConfig, hintName, LockModeType.WRITE,
            LockModeType.WRITE, MixedLockLevels.LOCK_WRITE);
        writeLockModeHintTest(fPlan, fConfig, hintName, LockModeType.WRITE
            .name(), LockModeType.WRITE, MixedLockLevels.LOCK_WRITE);

        writeLockModeHintTest(fPlan, fConfig, hintName,
            "optimistic", LockModeType.OPTIMISTIC,
            MixedLockLevels.LOCK_OPTIMISTIC);
        writeLockModeHintTest(fPlan, fConfig, hintName,
            LockModeType.OPTIMISTIC, LockModeType.OPTIMISTIC,
            MixedLockLevels.LOCK_OPTIMISTIC);
        writeLockModeHintTest(fPlan, fConfig, hintName, LockModeType.OPTIMISTIC
            .name(), LockModeType.OPTIMISTIC, MixedLockLevels.LOCK_OPTIMISTIC);

        writeLockModeHintTest(fPlan, fConfig, hintName,
            "optimistic-force-increment",
            LockModeType.OPTIMISTIC_FORCE_INCREMENT,
            MixedLockLevels.LOCK_OPTIMISTIC_FORCE_INCREMENT);
        writeLockModeHintTest(fPlan, fConfig, hintName,
            LockModeType.OPTIMISTIC_FORCE_INCREMENT,
            LockModeType.OPTIMISTIC_FORCE_INCREMENT,
            MixedLockLevels.LOCK_OPTIMISTIC_FORCE_INCREMENT);
        writeLockModeHintTest(fPlan, fConfig, hintName,
            LockModeType.OPTIMISTIC_FORCE_INCREMENT.name(),
            LockModeType.OPTIMISTIC_FORCE_INCREMENT,
            MixedLockLevels.LOCK_OPTIMISTIC_FORCE_INCREMENT);

        writeLockModeHintTest(fPlan, fConfig, hintName,
            "pessimistic-read", LockModeType.PESSIMISTIC_READ,
            MixedLockLevels.LOCK_PESSIMISTIC_READ);
        writeLockModeHintTest(fPlan, fConfig, hintName,
            LockModeType.PESSIMISTIC_READ, LockModeType.PESSIMISTIC_READ,
            MixedLockLevels.LOCK_PESSIMISTIC_READ);
        writeLockModeHintTest(fPlan, fConfig, hintName,
            LockModeType.PESSIMISTIC_READ.name(),
            LockModeType.PESSIMISTIC_READ,
            MixedLockLevels.LOCK_PESSIMISTIC_READ);

        writeLockModeHintTest(fPlan, fConfig, hintName,
            "pessimistic-write", LockModeType.PESSIMISTIC_WRITE,
            MixedLockLevels.LOCK_PESSIMISTIC_WRITE);
        writeLockModeHintTest(fPlan, fConfig, hintName,
            LockModeType.PESSIMISTIC_WRITE, LockModeType.PESSIMISTIC_WRITE,
            MixedLockLevels.LOCK_PESSIMISTIC_WRITE);
        writeLockModeHintTest(fPlan, fConfig, hintName,
            LockModeType.PESSIMISTIC_WRITE.name(),
            LockModeType.PESSIMISTIC_WRITE,
            MixedLockLevels.LOCK_PESSIMISTIC_WRITE);

        writeLockModeHintTest(fPlan, fConfig, hintName,
            "pessimistic-force-increment",
            LockModeType.PESSIMISTIC_FORCE_INCREMENT,
            MixedLockLevels.LOCK_PESSIMISTIC_FORCE_INCREMENT);
        writeLockModeHintTest(fPlan, fConfig, hintName,
            LockModeType.PESSIMISTIC_FORCE_INCREMENT,
            LockModeType.PESSIMISTIC_FORCE_INCREMENT,
            MixedLockLevels.LOCK_PESSIMISTIC_FORCE_INCREMENT);
        writeLockModeHintTest(fPlan, fConfig, hintName,
            LockModeType.PESSIMISTIC_FORCE_INCREMENT.name(),
            LockModeType.PESSIMISTIC_FORCE_INCREMENT,
            MixedLockLevels.LOCK_PESSIMISTIC_FORCE_INCREMENT);

        try {
            fPlan.setHint(hintName, "xxxxx");
            fPlan.setHint(hintName, "yyyyy");
            fail("Expecting a a IllegalArgumentException.");
        } catch (Exception e) {
            assertTrue("Caught expected exception",
                IllegalArgumentException.class.isAssignableFrom(e.getClass()));
        }
        try {
            fPlan.setHint(hintName, "12345");
            fPlan.setHint(hintName, "67890");
            fail("Expecting a a IllegalArgumentException.");
        } catch (Exception e) {
            assertTrue("Caught expected exception",
                IllegalArgumentException.class.isAssignableFrom(e.getClass()));
        }
        try {
            fPlan.setHint(hintName, -1);
            fPlan.setHint(hintName, -2);
            fail("Expecting a a IllegalArgumentException.");
        } catch (Exception e) {
            assertTrue("Caught expected exception",
                IllegalArgumentException.class.isAssignableFrom(e.getClass()));
        }
View Full Code Here

Examples of org.apache.openjpa.persistence.jdbc.JDBCFetchPlan

    }

    @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

Examples of org.apache.openjpa.persistence.jdbc.JDBCFetchPlan

    }

    @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
TOP
Copyright © 2018 www.massapi.com. 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.