Package org.objectweb.speedo.pobjects.map

Examples of org.objectweb.speedo.pobjects.map.C


    String F1_PREFIX = "f1_";
    PersistenceManager pm = pmf.getPersistenceManager();

    //Create  instances
    pm.currentTransaction().begin();
    C c = new C(1);
    ArrayList ds = new ArrayList(MAP_SIZE * 2);
    for(int i=0; i<MAP_SIZE; i++) {
      String f1 = F1_PREFIX + i;
      ds.add(new D(i, f1));
    }
    pm.makePersistent(c);
    pm.makePersistentAll(ds);
    pm.currentTransaction().commit();

    //Add into the map
    pm.currentTransaction().begin();
    Map m = c.getDkey2d();
    for(int i=0; i<MAP_SIZE; i++) {
      D d = (D) ds.get(i);
      m.put(d.getF1(), d);
    }
    c = null;
View Full Code Here


    public void test2() {
    int MAP_SIZE = 10;
    String F1_PREFIX = "f1_";
    PersistenceManager pm = pmf.getPersistenceManager();
    pm.currentTransaction().begin();
    C c = new C(1);
    Map m = c.getDkey2d();
    for(int i=0; i<MAP_SIZE; i++) {
      String f1 = "f1_" + i;
      D d = new D(i, f1);
      m.put(f1, d);
    }
View Full Code Here

    public void test3() {
    int MAP_SIZE = 10;
    String F1_PREFIX = "f1_";
    PersistenceManager pm = pmf.getPersistenceManager();
    pm.currentTransaction().begin();
    C c = new C(1);
    for(int i=0; i<MAP_SIZE; i++) {
      String f1 = "f1_" + i;
      D d = new D(i, f1);
      d.setMyc(c);
      pm.makePersistent(d);
View Full Code Here

              final int MAP_SIZE,
              final String F1_PREFIX) {
    pm.currentTransaction().begin();
    long id = MAP_SIZE/2;
    String f1 = F1_PREFIX + id;
    C c = (C) pm.getObjectById(pm.newObjectIdInstance(C.class, "1"), false);
    Object d = c.getDkey2d().get(f1);
    assertNotNull("No Object associated to the key '" + f1 + "'", d);
    assertTrue("Object associated to the key '" + f1 +"'", d instanceof D);
    assertEquals("Bad D identifier ", id, ((D) d).getMyid());
    assertNotNull("Bad D identifier ", ((D) d).getMyc());
    assertEquals("Bad C identifier ", 1, ((D) d).getMyc().getMyid());
    c = ((D) d).getMyc();
    ((D) d).setMyc(null);
    assertNull("The map contains again the D instance", c.getDkey2d().get(f1));
    pm.currentTransaction().commit();

    //Delete
    pm.currentTransaction().begin();
    pm.deletePersistent(d);
    pm.deletePersistentAll(c.getDkey2d().values());
    pm.deletePersistent(c);
    pm.currentTransaction().commit();
    pm.close();
  }
View Full Code Here

    String F1_PREFIX = "f1_";
    PersistenceManager pm = pmf.getPersistenceManager();

    //Create  instances
    pm.currentTransaction().begin();
    C c = new C(1);
    ArrayList ds = new ArrayList(MAP_SIZE * 2);
    for(int i=0; i<MAP_SIZE; i++) {
      String f1 = F1_PREFIX + i;
      ds.add(new D(i, f1));
    }
    pm.makePersistent(c);
    pm.makePersistentAll(ds);
    pm.currentTransaction().commit();

    //Add into the map
    pm.currentTransaction().begin();
    Map m = c.getDkey2d();
    for(int i=0; i<MAP_SIZE; i++) {
      D d = (D) ds.get(i);
      m.put(d.getF1(), d);
    }
    pm.currentTransaction().commit();
   
    pm.getFetchPlan().addGroup("all").removeGroup("default");
    C copyOfC = (C) pm.detachCopy(c);
    assertEquals("Not the same id for c and its detached copy", c.getMyid(), copyOfC.getMyid());
    Map mC = c.getDkey2d();
    Map mCopyOfC = copyOfC.getDkey2d();
    assertEquals("The maps' size should be the same.",mC.size(), mCopyOfC.size());
    Iterator itC = mC.values().iterator();
    Collection col = mCopyOfC.values();
    while(itC.hasNext()) {
      D dC = (D) itC.next();
View Full Code Here

TOP

Related Classes of org.objectweb.speedo.pobjects.map.C

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.