How do these user/userParam references relate to the Customer and Account lookups?
- by marmalade
In the following code example how do the user/userParam references relate to the Customer and Account lookups and what is the relationship between Customer and Account?
// PersistenceManager pm = ...;
Transaction tx = pm.currentTransaction();
User user = userService.currentUser();
List<Account> accounts = new ArrayList<Account>();
try {
tx.begin();
Query query = pm.newQuery("select from Customer " +
"where user == userParam " +
"parameters User userParam");
List<Customer> customers = (List<Customer>)
query.execute(user);
query = pm.newQuery("select from Account " +
"where parent-pk == keyParam " +
"parameters Key keyParam");
for (Customer customer : customers) {
accounts.addAll((List<Account>)
query.execute(customer.key));
}
} finally {
if (tx.isActive()) {
tx.rollback();
}
}