// good
}
}
public void testEmbedded_Parent() throws Exception {
TablePerClassParentWithEmbedded parent = new TablePerClassParentWithEmbedded();
parent.setAString("aString");
IsEmbeddedWithEmbeddedSuperclass embedded = new IsEmbeddedWithEmbeddedSuperclass();
embedded.setVal0("embedded val 0");
embedded.setVal1("embedded val 1");
parent.setEmbedded(embedded);
SubclassesJPA.IsEmbeddedBase
embeddedBase = new SubclassesJPA.IsEmbeddedBase();
embeddedBase.setVal0("embedded base val 0");
parent.setEmbeddedBase(embeddedBase);
beginTxn();
em.persist(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"));
em.close();
em = emf.createEntityManager();
beginTxn();
parent = em.find(parent.getClass(), parent.getId());
assertEmbeddedParentContents(parent);
commitTxn();
em.close();
em = emf.createEntityManager();
beginTxn();
Query q = em.createQuery("select from " + parent.getClass().getName() + " b where embedded.val1 = :p "
+ "order by embedded.val1 desc, embedded.val0 asc, embeddedBase.val0 desc");
q.setParameter("p", "embedded val 1");
parent = (TablePerClassParentWithEmbedded) q.getSingleResult();
assertEmbeddedParentContents(parent);
q = em.createQuery("select from " + parent.getClass().getName() + " b where embedded.val0 = :p "
+ "order by embedded.val1 desc, embedded.val0 asc, embeddedBase.val0 desc");
q.setParameter("p", "embedded val 0");
parent = (TablePerClassParentWithEmbedded) q.getSingleResult();
assertEmbeddedParentContents(parent);
q = em.createQuery("select from " + parent.getClass().getName() + " b where embeddedBase.val0 = :p "
+ "order by embedded.val1 desc, embedded.val0 asc, embeddedBase.val0 desc");
q.setParameter("p", "embedded base val 0");
parent = (TablePerClassParentWithEmbedded) q.getSingleResult();
assertEmbeddedParentContents(parent);
q = em.createQuery("select embedded.val1, embedded.val0, embeddedBase.val0 from " +
parent.getClass().getName() + " b where embeddedBase.val0 = :p "
+ "order by embedded.val1 desc, embedded.val0 asc, embeddedBase.val0 desc");
q.setParameter("p", "embedded base val 0");
Object[] result = (Object[]) q.getSingleResult();
assertEquals("embedded val 1", result[0]);