Package com.google.appengine.datanucleus.test.jpa.SingleTableInheritanceJPA

Examples of com.google.appengine.datanucleus.test.jpa.SingleTableInheritanceJPA.Parent


    testCreateAndFindParentAndChildren(NEW_EM_START_END);
  }
  @SuppressWarnings("unchecked")
  private void testCreateAndFindParentAndChildren(StartEnd startEnd) throws Exception {
    //  create Parent
    Parent p = newParent(startEnd, "Parent");
    Long pId = p.getId();
    Key pKey = KeyFactory.createKey(PARENT_KIND, pId);
   
    //  verify Parent entity
    Entity pe = ds.get(pKey);
    Assert.assertEquals(pKey, pe.getKey());
    Assert.assertEquals("P", pe.getProperty("DTYPE"));
    Assert.assertEquals("Parent", pe.getProperty("parentStr"));
    Assert.assertEquals(2, pe.getProperties().size());
   
    //  verify Parent object
    startEnd.start();
    p = em.find(Parent.class, pId);
    Assert.assertEquals(pId, p.getId());
    Assert.assertEquals("Parent", p.getParentStr());
    startEnd.end();

    //  create Child11
    Child11 c11 = newChild11(startEnd, "Child11", 11);
    Long c11Id = c11.getId();
View Full Code Here


  @SuppressWarnings("unchecked")
  private void testQueryParent(StartEnd startEnd) {
    Map<String, String> props = new HashMap<String, String>();
    props.put("datanucleus.appengine.getExtentCanReturnSubclasses", Boolean.TRUE.toString());
    switchDatasource(EntityManagerFactoryName.transactional_ds_non_transactional_ops_not_allowed, props);
    Parent p = newParent(startEnd, "Parent");
    Long pId = p.getId();

    Child21 c21 = newChild21(startEnd, "Child21", 21L);
    Long c21Id = c21.getId();
   
    startEnd.start();
    Query q = em.createQuery("select from " + Parent.class.getName() + " b where id = :id");
    q.setParameter("id", pId);
    List<Parent> r = (List<Parent>)q.getResultList();
    Assert.assertEquals(1, r.size());
    p = r.get(0);
    Assert.assertEquals(pId, p.getId());
    Assert.assertEquals("Parent", p.getParentStr());
    startEnd.end();

    startEnd.start();
    q = em.createQuery("select from " + Parent.class.getName() + " b where id = :id");
    q.setParameter("id", c21Id);
View Full Code Here

    Child12 c12 = newChild12(startEnd, "B", 112, 211, 8.15f, new Embedded1("Embedded1"),
  new Child11Many("Child12(2)/Child11Many"));
    Long c12Id = c12.getId();
   
    Parent p = newParent(startEnd, "C");
    Long pId = p.getId();

    Child21 c21 = newChild21(startEnd, "D", 121L);
    Long c21Id = c21.getId();

    Child22 c22 = newChild22(startEnd, "E", "Child22", Boolean.TRUE, null);
    Long c22Id = c22.getId();
   
    Assert.assertEquals(5, countForKind(PARENT_KIND));
   
    if (em.isOpen()) {
      em.close();
    }
    em = emf.createEntityManager();
   
    startEnd.start();
    Query q = em.createQuery("select p from " + Parent.class.getName() + " p order by parentStr desc");
    List<Parent> r = (List<Parent>)q.getResultList();
    Assert.assertEquals(5, r.size());

    c22 = (Child22)r.get(0);
    Assert.assertEquals(c22Id, c22.getId());
    Assert.assertEquals("E", c22.getParentStr());
    Assert.assertEquals("Child22", c22.getChild22Str());
    Assert.assertEquals(Boolean.TRUE, c22.getValue());

    c21 = (Child21)r.get(1);
    Assert.assertEquals(c21Id, c21.getId());
    Assert.assertEquals("D", c21.getParentStr());
    Assert.assertEquals(121L, c21.getChild21Long());

    p = r.get(2);
    Assert.assertEquals(pId, p.getId());
    Assert.assertEquals("C", p.getParentStr());
   
    c12 = (Child12)r.get(3);
    Assert.assertEquals(c12Id, c12.getId());
    Assert.assertEquals("B", c12.getParentStr());
    Assert.assertEquals(new Integer(112), c12.getChild11Integer());
View Full Code Here

    Long c11Id = c11.getId();

    Child12 c12 = newChild12(startEnd, "A", 211, 112, 8.15f, null);
    Long c12_0_Id = c12.getId();
   
    Parent p = newParent(startEnd, "A");
    Long pId = p.getId();

    c12 = newChild12(startEnd, "B", 2211, 2112, 47.11f, null);
    Long c12_1_Id = c12.getId();
   
    startEnd.start();
View Full Code Here

      // good
    }
  }

  private Parent newParent(StartEnd startEnd, String parentStr) {
    Parent p = new Parent();
    p.setParentStr(parentStr);
   
    makePersistent(p, startEnd);
    return p;
  }
View Full Code Here

TOP

Related Classes of com.google.appengine.datanucleus.test.jpa.SingleTableInheritanceJPA.Parent

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.