Package org.objectweb.speedo.pobjects.collection

Examples of org.objectweb.speedo.pobjects.collection.G


  public void testA() {
    int NBOBJ = 10;
    PersistenceManager pm = pmf.getPersistenceManager();
    pm.currentTransaction().begin();
    G g = new G("g1_testA");
    Collection hs = g.getHs();
    for(int i=0; i<NBOBJ; i++) {
      H h = new H("hid_" + i);
      h.setH1("h1_testA");
      hs.add(h);
    }
    pm.makePersistent(g);
    g = null;
    hs = null;
    pm.currentTransaction().commit();
    pm.evictAll();
    pm.close();
    pm = pmf.getPersistenceManager();
    pm.evictAll();
    pm.currentTransaction().begin();
    H h0 = (H) pm.getObjectById(pm.newObjectIdInstance(H.class, "hid_0"), false);
    assertNotNull("Null h0", h0);
    g = h0.getG();
    assertNotNull("Null g", g);
    pm.deletePersistentAll(g.getHs());
    pm.deletePersistent(g);
    pm.currentTransaction().commit();
    pm.close();

  }
View Full Code Here


  public void testCollectionElementLoadingWithPrefetch() {
    int NBOBJ = 2;
    PersistenceManager pm = pmf.getPersistenceManager();
    //create persistent instances
    pm.currentTransaction().begin();
    G g = new G("g1_testCollectionElementLoadingWithPrefetch");
    Collection hs = g.getHs();
    for(int i=0; i<NBOBJ; i++) {
      H h = new H("hid_" + i);
      h.setH1("h1_testCollectionElementLoadingWithPrefetch");
      hs.add(h);
    }
    hs = null;
    pm.makePersistent(g);
    Object g_oid = pm.getObjectId(g);
    g = null;
    pm.currentTransaction().commit();

    //evict all instances
    pm.evictAll();

    pm.currentTransaction().begin();
    Query q = pm.newQuery(H.class);
    q.declareParameters("String p1");
    q.setFilter("hid == p1");
    Object o = new ArrayList(((Collection) q.execute("hid_" + (NBOBJ-1))));
    q.closeAll();
   
    g = (G) pm.getObjectById(g_oid, false);
    for (Iterator iter = g.getHs().iterator(); iter.hasNext();) {
            iter.next();
    }
    pm.currentTransaction().commit();

    //Clean up
    pm.currentTransaction().begin();
    pm.deletePersistentAll(g.getHs());
    pm.deletePersistent(g);
    pm.currentTransaction().commit();
    pm.close();

  }
View Full Code Here

TOP

Related Classes of org.objectweb.speedo.pobjects.collection.G

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.