Package javax.jdo

Examples of javax.jdo.FetchPlan


    }

    /** Set the default plus both fields as the fetch group.
     */
    protected void setBothGroup() {
        FetchPlan fp = getPM().getFetchPlan();
        fp.setGroups(bothGroup);
    }
View Full Code Here


        checkFetchGroup2(query);
        checkFetchGroup1(query);
    }

    private void checkSameFetchPlanInstances(Query query) {
        FetchPlan fetchPlan1 = query.getFetchPlan();
        FetchPlan fetchPlan2 = query.getFetchPlan();
        if (fetchPlan1 != fetchPlan2) {
            fail(ASSERTION_FAILED + "Calling getFetchPlan twice on the same " +
            "query instance results in two different fetch plan instances.");
        }
    }
View Full Code Here

     * Checks if the given query loads fields
     * assigned to fetchGroup1
     * @param query the query
     */
    private void checkFetchGroup1(Query query) {
        FetchPlan fetchplan = query.getFetchPlan();
        Collection fetchgroups = fetchplan.getGroups();
        assertTrue("FetchPlan should include fetchGroup1 and not fetchGroup2",
                fetchgroups.contains(FETCH_GROUP_1) &&
                !fetchgroups.contains(FETCH_GROUP_2));
    }
View Full Code Here

     * That fetch group loads field number2.
     * Finally, that fetch group is removed from the fetch plan again.
     * @param query the query
     */
    private void checkFetchGroup2(Query query) {
        FetchPlan fetchplan = query.getFetchPlan();
        fetchplan.addGroup(FETCH_GROUP_2);
        Collection fetchgroups = fetchplan.getGroups();
        try {
            assertTrue("FetchPlan should include fetchGroup1 and fetchGroup2",
                       fetchgroups.contains(FETCH_GROUP_1) &&
                       fetchgroups.contains(FETCH_GROUP_2));
        } finally {
View Full Code Here

     *   where field was not loaded
     */
    public void testDetachCopyAccessFieldNotInFetchPlan() {
        // datastore transaction, retainValues=false
        getPM().currentTransaction().begin();
        FetchPlan fp = pm.getFetchPlan();
        // Product field not in Fetch Plan
        fp.addGroup(CART_ENTRIES);
        fp.addGroup(CARTENTRY_CART);

        CartEntry cartEntryDetached = (CartEntry)pm.detachCopy(cartEntry1);
        try {
            Product prod = cartEntryDetached.getProduct();
            fail("Expected exception on access of field not in fetch plan" +
View Full Code Here

        pm.currentTransaction().commit();
    }

    /** */
    protected void setCartFetchGroups() {
        FetchPlan fp = getPM().getFetchPlan();
        fp.setGroups(CART_FETCH_GROUPS);
        fp.setMaxFetchDepth(2);
    }
View Full Code Here

    /** */
    public void testDetachmentOptions() {
        int expectedOptions =
                FetchPlan.DETACH_LOAD_FIELDS +
                FetchPlan.DETACH_UNLOAD_FIELDS;
        FetchPlan fp = getPM().getFetchPlan();
        int initialOptions = fp.getDetachmentOptions();
        if (FetchPlan.DETACH_LOAD_FIELDS != initialOptions) {
            failCompare(
                "testDetachmentOptions(): wrong getDetachmentOptions() " +
                    "after getPersistenceManager().",
                    FetchPlan.DETACH_LOAD_FIELDS, initialOptions);
        }
        fp.setDetachmentOptions(expectedOptions);
        int actualOptions = fp.getDetachmentOptions();
        if (expectedOptions != actualOptions) {
            failCompare(
                "testDetachmentOptions(): wrong getDetachmentOptions() " +
                    "after setDetachmentOptions().",
                    expectedOptions, actualOptions);
View Full Code Here

    }

    /** */
    public void testMaxFetchDepth() {
        int expectedMaxFetchDepth = 12;
        FetchPlan fp = getPM().getFetchPlan();
        fp.setMaxFetchDepth(expectedMaxFetchDepth);
        int actualMaxFetchDepth = fp.getMaxFetchDepth();
        if (expectedMaxFetchDepth != actualMaxFetchDepth) {
            failCompare(
                "testMaxFetchDepth(): wrong getMaxFetchDepth() " +
                    "after setMaxFetchDepth().",
                    expectedMaxFetchDepth, actualMaxFetchDepth);
View Full Code Here

    }

    /** */
    public void testFetchSize() {
        int expectedFetchSize = 12;
        FetchPlan fp = getPM().getFetchPlan();
        fp.setFetchSize(expectedFetchSize);
        int actualFetchSize = fp.getFetchSize();
        if (expectedFetchSize != actualFetchSize) {
            failCompare(
                "testFetchSize(): wrong getFetchSize() " +
                    "after setFetchSize().",
                    expectedFetchSize, actualFetchSize);
View Full Code Here

    /** */
    public void checkDefaultGroups() {
        Set expectedGroups = new HashSet();
        expectedGroups.add("default");
        FetchPlan fp = getPM().getFetchPlan();
        Collection groups = fp.getGroups();
        if (!setEquals(expectedGroups, groups)) {
            failCompare(
                "checkDefaultGroups(): wrong getGroups() " +
                    "after getPersistenceManager().",
                    expectedGroups, groups);
View Full Code Here

TOP

Related Classes of javax.jdo.FetchPlan

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.