Package org.odmg

Examples of org.odmg.DMap


        String name = "testAdding";
        String namedObject = "testAdding_" + System.currentTimeMillis();
        TransactionExt tx = (TransactionExt) odmg.newTransaction();

        tx.begin();
        DMap map = odmg.newDMap();

        database.bind(map, namedObject);
        Article key1 = createArticle(name + "_key1");
        Article val1 = createArticle(name + "_val1");
        Article key2 = createArticle(name + "_key2");
        Article val2 = createArticle(name + "_val2");

        map.put(key1, val1);
        map.put(key2, val2);
        tx.commit();


        tx = (TransactionExt) odmg.newTransaction();
        tx.begin();
        tx.getBroker().clearCache();

        DMap mapA = (DMap) database.lookup(namedObject);
        assertNotNull(mapA);
        Article val1A = (Article) mapA.get(key1);
        assertNotNull(val1A);
        assertEquals(val1.getArticleId(), val1A.getArticleId());
        Article val2A = (Article) mapA.get(key2);
        assertNotNull(val2A);
        assertEquals(val2.getArticleId(), val2A.getArticleId());
        tx.commit();
    }
View Full Code Here


        String name = "testAdding";
        String namedObject = "testAdding_" + System.currentTimeMillis();
        TransactionExt tx = (TransactionExt) odmg.newTransaction();

        tx.begin();
        DMap map = odmg.newDMap();

        database.bind(map, namedObject);
        Article key1 = createArticle(name + "_key1");
        Article val1 = createArticle(name + "_val1");
        Article key2 = createArticle(name + "_key2");
        Article val2 = createArticle(name + "_val2");

        map.put(key1, val1);
        map.put(key2, val2);
        tx.commit();


        tx = (TransactionExt) odmg.newTransaction();
        tx.begin();
        tx.getBroker().clearCache();

        DMap mapA = (DMap) database.lookup(namedObject);
        assertNotNull(mapA);
        Article val1A = (Article) mapA.get(key1);
        assertNotNull(val1A);
        assertEquals(val1.getArticleId(), val1A.getArticleId());
        Article val2A = (Article) mapA.get(key2);
        assertNotNull(val2A);
        assertEquals(val2.getArticleId(), val2A.getArticleId());
        tx.commit();

        tx.begin();
        mapA.remove(key1);

        tx.checkpoint();

        mapA = (DMap) database.lookup(namedObject);
        assertNotNull(mapA);
        val1A = (Article) mapA.get(key1);
        assertNull(val1A);
        val2A = (Article) mapA.get(key2);
        assertNotNull(val2A);
        assertEquals(val2.getArticleId(), val2A.getArticleId());
        tx.commit();

        tx.begin();
        mapA.remove(key2);
        mapA.put(key2, val2);

        tx.checkpoint();

        mapA = (DMap) database.lookup(namedObject);
        assertNotNull(mapA);
        val1A = (Article) mapA.get(key1);
        assertNull(val1A);
        val2A = (Article) mapA.get(key2);
        assertNotNull(val2A);
        assertEquals(val2.getArticleId(), val2A.getArticleId());
        tx.commit();

        tx.begin();
        mapA.remove(key2);
        tx.commit();

        tx.begin();
        mapA = (DMap) database.lookup(namedObject);
        assertNotNull(mapA);
        val1A = (Article) mapA.get(key1);
        assertNull(val1A);
        val2A = (Article) mapA.get(key2);
        assertNull(val2A);
        tx.commit();
    }
View Full Code Here

        String name = "testAdding";
        String namedObject = "testAdding_" + System.currentTimeMillis();
        TransactionExt tx = (TransactionExt) odmg.newTransaction();

        tx.begin();
        DMap map = odmg.newDMap();

        database.bind(map, namedObject);
        Article key1 = createArticle(name + "_key1");
        Article val1 = createArticle(name + "_val1");
        Article key2 = createArticle(name + "_key2");
        Article val2 = createArticle(name + "_val2");

        map.put(key1, val1);
        map.put(key2, val2);
        tx.commit();


        tx = (TransactionExt) odmg.newTransaction();
        tx.begin();
        tx.getBroker().clearCache();

        DMap mapA = (DMap) database.lookup(namedObject);
        assertNotNull(mapA);
        Article val1A = (Article) mapA.get(key1);
        assertNotNull(val1A);
        assertEquals(val1.getArticleId(), val1A.getArticleId());
        Article val2A = (Article) mapA.get(key2);
        assertNotNull(val2A);
        assertEquals(val2.getArticleId(), val2A.getArticleId());
        tx.commit();
    }
View Full Code Here

        String name = "testAdding";
        String namedObject = "testAdding_" + System.currentTimeMillis();
        TransactionExt tx = (TransactionExt) odmg.newTransaction();

        tx.begin();
        DMap map = odmg.newDMap();

        database.bind(map, namedObject);
        Article key1 = createArticle(name + "_key1");
        Article val1 = createArticle(name + "_val1");
        Article key2 = createArticle(name + "_key2");
        Article val2 = createArticle(name + "_val2");

        map.put(key1, val1);
        map.put(key2, val2);
        tx.commit();


        tx = (TransactionExt) odmg.newTransaction();
        tx.begin();
        tx.getBroker().clearCache();

        DMap mapA = (DMap) database.lookup(namedObject);
        assertNotNull(mapA);
        Article val1A = (Article) mapA.get(key1);
        assertNotNull(val1A);
        assertEquals(val1.getArticleId(), val1A.getArticleId());
        Article val2A = (Article) mapA.get(key2);
        assertNotNull(val2A);
        assertEquals(val2.getArticleId(), val2A.getArticleId());
        tx.commit();

        tx.begin();
        mapA.remove(key1);

        tx.checkpoint();

        mapA = (DMap) database.lookup(namedObject);
        assertNotNull(mapA);
        val1A = (Article) mapA.get(key1);
        assertNull(val1A);
        val2A = (Article) mapA.get(key2);
        assertNotNull(val2A);
        assertEquals(val2.getArticleId(), val2A.getArticleId());
        tx.commit();

        tx.begin();
        mapA.remove(key2);
        mapA.put(key2, val2);

        tx.checkpoint();

        mapA = (DMap) database.lookup(namedObject);
        assertNotNull(mapA);
        val1A = (Article) mapA.get(key1);
        assertNull(val1A);
        val2A = (Article) mapA.get(key2);
        assertNotNull(val2A);
        assertEquals(val2.getArticleId(), val2A.getArticleId());
        tx.commit();

        tx.begin();
        mapA.remove(key2);
        tx.commit();

        tx.begin();
        mapA = (DMap) database.lookup(namedObject);
        assertNotNull(mapA);
        val1A = (Article) mapA.get(key1);
        assertNull(val1A);
        val2A = (Article) mapA.get(key2);
        assertNull(val2A);
        tx.commit();
    }
View Full Code Here

        db.open(databaseName, Database.OPEN_READ_WRITE);


        Transaction tx = odmg.newTransaction();
        tx.begin();
        DMap map = odmg.newDMap();
        PersistenceBroker broker = ((HasBroker) tx).getBroker();
        String name = null;
        try
        {
            // name = "the_dmap_" + (broker.getUniqueId(DMapImpl.class, "id") - 1);
            name = "the_dmap_" + System.currentTimeMillis();
        }
        catch (PersistenceBrokerException e)
        {
        }
        db.bind(map, name);
        Article key1 = createArticle(odmg);
        Article val1 = createArticle(odmg);
        Article key2 = createArticle(odmg);
        Article val2 = createArticle(odmg);

        map.put(key1, val1);
        map.put(key2, val2);
        tx.commit();


        tx = odmg.newTransaction();
        tx.begin();

        broker = ((HasBroker) tx).getBroker();
        broker.clearCache();

        DMap mapA = (DMap) db.lookup(name);
        Article val1A = (Article) mapA.get(key1);
        assertEquals(val1.getArticleId(), val1A.getArticleId());
        Article val2A = (Article) mapA.get(key2);
        assertEquals(val2.getArticleId(), val2A.getArticleId());
        tx.commit();
    }
View Full Code Here

TOP

Related Classes of org.odmg.DMap

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.