Package com.google.appengine.datanucleus.test.jdo

Examples of com.google.appengine.datanucleus.test.jdo.UnownedJDOManyToManySideA


      // Persist Side A
      UnownedJDOManyToManySideB b = new UnownedJDOManyToManySideB();
      pm.makePersistent(b);

      // Create and persist Side B with another Side A, plus the existing Side A
      UnownedJDOManyToManySideA a = new UnownedJDOManyToManySideA();
      UnownedJDOManyToManySideB b2 = new UnownedJDOManyToManySideB();
      b2.getAs().add(a);
      a.getBs().add(b2);
      a.getBs().add(b);
      b.getAs().add(a);
      pm.makePersistent(b2);
      pm.makePersistent(a);
    } catch (Exception e) {
      NucleusLogger.GENERAL.error("Exception in persist", e);
      fail("Exception in test : " + e.getMessage());
      return;
    } finally {
      if (pm.currentTransaction().isActive()) {
        pm.currentTransaction().rollback();
      }
      pm.close();
    }
    pmf.getDataStoreCache().evictAll();

    pm = pmf.getPersistenceManager();
    try {
      Query qa = pm.newQuery(UnownedJDOManyToManySideA.class);
      List<UnownedJDOManyToManySideA> results1 = (List<UnownedJDOManyToManySideA>) qa.execute();
      assertNotNull(results1);
      assertEquals("Incorrect number of side A", 1, results1.size());
      UnownedJDOManyToManySideA a = results1.iterator().next();
      Set<UnownedJDOManyToManySideB> bs = a.getBs();
      assertNotNull(bs);
      assertEquals("Incorrect number of side B for A", 2, bs.size());

      Query qb = pm.newQuery(UnownedJDOManyToManySideB.class);
      List<UnownedJDOManyToManySideB> results2 = (List<UnownedJDOManyToManySideB>) qb.execute();
View Full Code Here

TOP

Related Classes of com.google.appengine.datanucleus.test.jdo.UnownedJDOManyToManySideA

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.