// Make sure we have cleaned out the org for this data
deleteAll("Opportunity");
final String accName = "Account for testing subqueries";
deleteAll("Account", " a where a.name = '" + accName + "'");
OpportunityEntity opp1 = new OpportunityEntity();
opp1.setStageName("Prospecting");
opp1.setCloseDate(Calendar.getInstance().getTime());
opp1.setName("opp1 subquery");
OpportunityEntity opp2 = new OpportunityEntity();
opp2.setStageName("Prospecting");
opp2.setCloseDate(Calendar.getInstance().getTime());
opp2.setName("opp2 subquery");
AccountEntity parentAccount = new AccountEntity();
parentAccount.setName(accName);
opp1.setTheAccount(parentAccount);
opp2.setTheAccount(parentAccount);
addTestDataInTx(Lists.newArrayList(parentAccount, opp1, opp2));
List<AccountEntity> result =
em.createNativeQuery("select id, name, (select id, name, stageName from Opportunities) from Account "