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

Examples of com.google.appengine.datanucleus.test.jdo.SubclassesJDO.CompleteTableParentWithEmbedded


      // good
    }
  }

  public void testEmbedded_Parent() throws Exception {
    CompleteTableParentWithEmbedded parent = new CompleteTableParentWithEmbedded();
    parent.setAString("aString");
    SubclassesJDO.IsEmbeddedOnly embedded = new SubclassesJDO.IsEmbeddedOnly();
    embedded.setVal0("embedded val 0");
    embedded.setVal1("embedded val 1");
    parent.setEmbedded(embedded);
    SubclassesJDO.IsEmbeddedOnlyBase embeddedBase = new SubclassesJDO.IsEmbeddedOnlyBase();
    embeddedBase.setVal0("embedded base val 0");
    parent.setEmbeddedBase(embeddedBase);
    beginTxn();
    pm.makePersistent(parent);
    commitTxn();
    Key key = KeyFactory.createKey(kindForClass(parent.getClass()), parent.getId());
    Entity e = ds.get(key);
    assertEquals("aString", e.getProperty("aString"));
    assertEquals("embedded val 0", e.getProperty("val0"));
    assertEquals("embedded val 1", e.getProperty("val1"));
    assertEquals("embedded base val 0", e.getProperty("VAL0"));
    pm.close();
    pm = pmf.getPersistenceManager();
    beginTxn();
    parent = pm.getObjectById(parent.getClass(), parent.getId());
    assertEmbeddedParentContents(parent);
    commitTxn();
    pm.close();
    pm = pmf.getPersistenceManager();
    beginTxn();
    Query q = pm.newQuery(
        "select from " + parent.getClass().getName() + " where embedded.val1 == :p "
        + "order by embedded.val1 desc, embedded.val0 asc, embeddedBase.val0 desc");
    q.setUnique(true);
    parent = (CompleteTableParentWithEmbedded) q.execute("embedded val 1");
    assertEmbeddedParentContents(parent);

    q = pm.newQuery(
        "select from " + parent.getClass().getName() + " where embedded.val0 == :p "
        + "order by embedded.val1 desc, embedded.val0 asc, embeddedBase.val0 desc");
    q.setUnique(true);
    parent = (CompleteTableParentWithEmbedded) q.execute("embedded val 0");
    assertEmbeddedParentContents(parent);

    q = pm.newQuery(
        "select from " + parent.getClass().getName() + " where embeddedBase.val0 == :p "
        + "order by embedded.val1 desc, embedded.val0 asc, embeddedBase.val0 desc");
    q.setUnique(true);
    parent = (CompleteTableParentWithEmbedded) q.execute("embedded base val 0");
    assertEmbeddedParentContents(parent);

    q = pm.newQuery("select embedded.val1, embedded.val0, embeddedBase.val0 from " +
                    parent.getClass().getName() + " where embeddedBase.val0 == :p "
        + "order by embedded.val1 desc, embedded.val0 asc, embeddedBase.val0 desc");
    q.setUnique(true);
    Object[] result = (Object[]) q.execute("embedded base val 0");
    assertEquals("embedded val 1", result[0]);
    assertEquals("embedded val 0", result[1]);
View Full Code Here


    assertEquals("embedded base val 2", child.getEmbeddedBase2().getVal2());
    assertEmbeddedParentContents(child);
  }

  private void assertEmbeddedParentContents(Object obj) {
    CompleteTableParentWithEmbedded parentWithEmbedded = (CompleteTableParentWithEmbedded) obj;
    assertEquals("aString", parentWithEmbedded.getAString());
    assertEquals("embedded val 0", parentWithEmbedded.getEmbedded().getVal0());
    assertEquals("embedded val 1", parentWithEmbedded.getEmbedded().getVal1());
    assertEquals("embedded base val 0", parentWithEmbedded.getEmbeddedBase().getVal0());
  }
View Full Code Here

TOP

Related Classes of com.google.appengine.datanucleus.test.jdo.SubclassesJDO.CompleteTableParentWithEmbedded

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.