Package javax.jdo

Examples of javax.jdo.Transaction


        }
    }

    /** */
    private void runTestDeclareImports03(PersistenceManager pm) {
        Transaction tx = pm.currentTransaction();
        try {
            tx.begin();

            Query query = pm.newQuery();
            query.setClass(Company.class);
            query.setCandidates(pm.getExtent(Company.class, false));
            query.declareImports("import org.apache.jdo.tck.pc.company.Employee; import org.apache.jdo.tck.pc.company.Department");
            query.declareVariables("Department d; Employee e" );
            query.setFilter("departments.contains(d) && (d.employees.contains(e) && e.firstname==\"Michael\")");
            Object results = query.execute();

            // Just check whether query with import declarations compiles

            tx.commit();
            tx = null;
        }
        finally {
            if ((tx != null) && tx.isActive())
                tx.rollback();
        }
    }
View Full Code Here


    }

    /** */
    public void testPositive() {
        PersistenceManager pm = getPM();
        Transaction tx = pm.currentTransaction();
        try {
            tx.begin();

            Query query = pm.newQuery(PCPoint.class, inserted, "x ==2");
            Object results = query.execute();

            // check query result
            List expected = new ArrayList();
            PCPoint pc1 = new PCPoint(2, 2);
            expected.add(pc1);
            expected = getFromInserted(expected);
            printOutput(results, expected);
            checkQueryResultWithoutOrder(ASSERTION_FAILED, results, expected);
           
            tx.commit();
            tx = null;
        }
        finally {
            if ((tx != null) && tx.isActive())
                tx.rollback();
        }
    }
View Full Code Here

    }

    /** */
    public void testPositive() {
        PersistenceManager pm = getPM();
        Transaction tx = pm.currentTransaction();
        tx.begin();
        try {
            Query query = pm.newQuery(pm.getExtent(PCPoint.class, false), "x == 1");
            Object results = query.execute();

            // check query result
            List expected = new ArrayList();
            Object pcp1 = new PCPoint(1, 1);
            expected.add(pcp1);
            expected = getFromInserted(expected);
            printOutput(results, expected);
            checkQueryResultWithoutOrder(ASSERTION_FAILED, results, expected);

            tx.commit();
            tx = null;
        }
        finally {
            if ((tx != null) && tx.isActive())
                tx.rollback();
        }
    }
View Full Code Here

    /** */
    void runTestParenthesesMarkOperatorPrecedence01(PersistenceManager pm) {
        if(debug)
            logger.debug("\nExecuting Test ParenthesesMarkOperatorPrecedence01...");

        Transaction tx = pm.currentTransaction();
        try {
            tx.begin();

            Query query = pm.newQuery();
            query.setClass(PCPoint.class);
            query.setCandidates(pm.getExtent(PCPoint.class, false));
            query.setFilter("x == (1 + 1)");
            Object results = query.execute();

            // check query result
            List expected = new ArrayList();
            Object p3 = new PCPoint(2, 2);
            expected.add(p3);
            expected = getFromInserted(expected);
            printOutput(results, expected);
            checkQueryResultWithoutOrder(ASSERTION_FAILED, results, expected);
            if(debug)
                logger.debug("Test ParenthesesMarkOperatorPrecedence01 - Passed");

            tx.commit();
            tx = null;
        }
        finally {
            if ((tx != null) && tx.isActive())
                tx.rollback();
        }
    }
View Full Code Here

    /** */
    void runTestParenthesesMarkOperatorPrecedence02(PersistenceManager pm) {
        if(debug)
            logger.debug("\nExecuting Test ParenthesesMarkOperatorPrecedence01...");

        Transaction tx = pm.currentTransaction();
        try {
            tx.begin();

            Query query = pm.newQuery();
            query.setClass(PCPoint.class);
            query.setCandidates(pm.getExtent(PCPoint.class, false));
            query.setFilter("x == (1 + 1) * 2");
            Object results = query.execute();

            // check query result
            List expected = new ArrayList();
            Object p5 = new PCPoint(4, 4);
            expected.add(p5);
            expected = getFromInserted(expected);
            printOutput(results, expected);
            checkQueryResultWithoutOrder(ASSERTION_FAILED, results, expected);
            if(debug)
                logger.debug("Test ParenthesesMarkOperatorPrecedence02 - Passed");
           
            tx.commit();
            tx = null;
        }
        finally {
            if ((tx != null) && tx.isActive())
                tx.rollback();
        }
    }
View Full Code Here

    /** */
    void runTestParenthesesMarkOperatorPrecedence03(PersistenceManager pm) {
        if(debug)
            logger.debug("\nExecuting Test ParenthesesMarkOperatorPrecedence03...");

        Transaction tx = pm.currentTransaction();
        try {
            tx.begin();

            Query query = pm.newQuery();
            query.setClass(PCPoint.class);
            query.setCandidates(pm.getExtent(PCPoint.class, false));
            query.setFilter("x == (9 - 1) * (3 + 5) / 32");
            Object results = query.execute();

            // check query result
            List expected = new ArrayList();
            Object p3 = new PCPoint(2, 2);
            expected.add(p3);
            expected = getFromInserted(expected);
            printOutput(results, expected);
            checkQueryResultWithoutOrder(ASSERTION_FAILED, results, expected);
            if(debug)
                logger.debug("Test ParenthesesMarkOperatorPrecedence03 - Passed");
           
            tx.commit();
            tx = null;
        }
        finally {
            if ((tx != null) && tx.isActive())
                tx.rollback();
        }
    }
View Full Code Here

    /** */
    void runTestParenthesesMarkOperatorPrecedence04(PersistenceManager pm) {
        if(debug)
            logger.debug("\nExecuting Test ParenthesesMarkOperatorPrecedence04...");

        Transaction tx = pm.currentTransaction();
        try {
            tx.begin();

            Query query = pm.newQuery();
            query.setClass(PCPoint.class);
            query.setCandidates(pm.getExtent(PCPoint.class, false));
            query.setFilter("x == 2 && y == 2");
            Object results = query.execute();

            // check query result
            List expected = new ArrayList();
            Object p3 = new PCPoint(2, 2);
            expected.add(p3);
            expected = getFromInserted(expected);
            printOutput(results, expected);
            checkQueryResultWithoutOrder(ASSERTION_FAILED, results, expected);
            if(debug)
                logger.debug("Test ParenthesesMarkOperatorPrecedence04 - Passed");

            tx.commit();
            tx = null;
        }
        finally {
            if ((tx != null) && tx.isActive())
                tx.rollback();
        }
    }
View Full Code Here

    /** */
    void runTestParenthesesMarkOperatorPrecedence05(PersistenceManager pm) {
        if(debug)
            logger.debug("\nExecuting Test ParenthesesMarkOperatorPrecedence05...");

        Transaction tx = pm.currentTransaction();
        try {
            tx.begin();

            Query query = pm.newQuery();
            query.setClass(PCPoint.class);
            query.setCandidates(pm.getExtent(PCPoint.class, false));
            query.setFilter("x == (1 + 1) || y == (1002 - 1000)");
       
            Object results = query.execute();

            // check query result
            List expected = new ArrayList();
            Object p3 = new PCPoint(2, 2);
            expected.add(p3);
            expected = getFromInserted(expected);
            printOutput(results, expected);
            checkQueryResultWithoutOrder(ASSERTION_FAILED, results, expected);
            if(debug)
                logger.debug("Test ParenthesesMarkOperatorPrecedence05 - Passed");

            tx.commit();
            tx = null;
        }
        finally {
            if ((tx != null) && tx.isActive())
                tx.rollback();
        }
    }
View Full Code Here

    /** */
    void runTestParenthesesMarkOperatorPrecedence06(PersistenceManager pm) {
        if(debug)
            logger.debug("\nExecuting Test ParenthesesMarkOperatorPrecedence06...");

        Transaction tx = pm.currentTransaction();
        try {
            tx.begin();

            Query query = pm.newQuery();
            query.setClass(PCPoint.class);
            query.setCandidates(pm.getExtent(PCPoint.class, false));
            query.setFilter("x == (1 * 2) && true");
            Object results = query.execute();

            // check query result
            List expected = new ArrayList();
            Object p3 = new PCPoint(2, 2);
            expected.add(p3);
            expected = getFromInserted(expected);
            printOutput(results, expected);
            checkQueryResultWithoutOrder(ASSERTION_FAILED, results, expected);
            if(debug)
                logger.debug("Test ParenthesesMarkOperatorPrecedence06 - Passed");

            tx.commit();
            tx = null;
        }
        finally {
            if ((tx != null) && tx.isActive())
                tx.rollback();
        }
    }
View Full Code Here

    /** */
    void runTestParenthesesMarkOperatorPrecedence07(PersistenceManager pm) {
        if(debug) logger.debug("\nExecuting Test ParenthesesMarkOperatorPrecedence07...");

        Transaction tx = pm.currentTransaction();
        try {
            tx.begin();

            Query query = pm.newQuery();
            query.setClass(PCPoint.class);
            query.setCandidates(pm.getExtent(PCPoint.class, false));
            query.setFilter("x == (10000 / 5000) || false");
            Object results = query.execute();

            // check query result
            List expected = new ArrayList();
            Object p3 = new PCPoint(2, 2);
            expected.add(p3);
            expected = getFromInserted(expected);
            printOutput(results, expected);
            checkQueryResultWithoutOrder(ASSERTION_FAILED, results, expected);
            if(debug) logger.debug("Test ParenthesesMarkOperatorPrecedence07 - Passed");

            tx.commit();
            tx = null;
        }
        finally {
            if ((tx != null) && tx.isActive())
                tx.rollback();
        }
    }
View Full Code Here

TOP

Related Classes of javax.jdo.Transaction

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.