// 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]);