Package org.apache.jdo.tck.pc.instancecallbacks

Examples of org.apache.jdo.tck.pc.instancecallbacks.InstanceCallbackClass


        InstanceCallbackClass.performPreStoreTests = true;
        t.begin();
        //  Create primaryObj which has a collection (children) of two objects and references another (nextObj).
        //  None of the other objects have a non-empty collection.  The also all have nextObj set to null.
        Date createTime = new Date();
        InstanceCallbackClass secondaryObj = new InstanceCallbackClass("secondaryObj", createTime, 2, 2.0, (short)-1, '2', null);
        InstanceCallbackClass primaryObj = new InstanceCallbackClass("primaryObj", createTime, 1, 1.0, (short)3, '1', secondaryObj);
        InstanceCallbackClass childA = new InstanceCallbackClass("childA", createTime, 3, 3.0, (short)-2, '3', null);
        InstanceCallbackClass childB = new InstanceCallbackClass("childB", createTime, 4, 4.0, (short)-3, '4', null);
        pm.makePersistent(primaryObj);
        primaryObj.addChild(childA);
        primaryObj.addChild(childB);
        t.commit();
View Full Code Here


        Calendar cal = Calendar.getInstance();
        cal.set(1999, 1, 15, 12, 0);
        Date createTime = cal.getTime();
        cal.set(2002, 1, 15, 12, 0);
        Date laterDate = cal.getTime();
        InstanceCallbackClass secondaryObj = new InstanceCallbackClass("secondaryObj", createTime, 2, 2.2, (short)-20, '2', null);
        InstanceCallbackClass primaryObj = new InstanceCallbackClass("primaryObj", laterDate, 1, 1.1, (short)-10, '1', secondaryObj);
        pm.makePersistent(primaryObj);
        pm.makePersistent(secondaryObj);
        Object secondaryObjId = pm.getObjectId(secondaryObj);
        Object primaryObjId = pm.getObjectId(primaryObj);
        t.commit();

        InstanceCallbackClass.performPreClearTests = true;
        t.begin();
        try {
            primaryObj = (InstanceCallbackClass)pm.getObjectById(primaryObjId, true);
            pm.retrieve(primaryObj); // load fields of primaryObj (make it persistent-clean)
       
        } catch (JDOUserException e) {
            fail(ASSERTION_FAILED, "Failed to find primaryObj created in previous transaction.  Got JDOUserException " + e);
            return;
        } catch (JDODataStoreException e) {
            fail(ASSERTION_FAILED, "Failed to find primaryObj created in previous transaction.  Got JDODataStoreException " + e);
           return;
        }
       
        secondaryObj = primaryObj.nextObj;
        if(secondaryObj == null) {
            fail(ASSERTION_FAILED, "Failed to find secondaryObj created in previous transaction using reference from primaryObj.");
            return;
        }
        pm.retrieve(secondaryObj);
       
        primaryObj.addChild(secondaryObj)// primaryObj contains one child;  secondaryObj contains none. primaryObj is now dirty
       
        cal.set(2005, 6, 28, 0, 0);
        Date stillLaterDate = cal.getTime();
        InstanceCallbackClass ternaryObj = new InstanceCallbackClass("ternaryObj", stillLaterDate, 3, 3.3, (short)-30, '3', null);
        pm.makePersistent(ternaryObj);
        ternaryObj.addChild(secondaryObj);
        ternaryObj.addChild(primaryObj);
        t.commit();
       
        // verify attributes in what was persistent-clean object--secondaryObj
        checkFieldValues(ASSERTION_FAILED, "jdoPreClear attribute access:  ", 2"secondaryObj", createTime, 2.2, (short)-20, '2');
View Full Code Here

TOP

Related Classes of org.apache.jdo.tck.pc.instancecallbacks.InstanceCallbackClass

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.