How do these user/userParam references relate to the Customer and Account lookups?

Posted by marmalade on Stack Overflow See other posts from Stack Overflow or by marmalade
Published on 2010-03-31T08:46:46Z Indexed on 2010/03/31 9:43 UTC
Read the original article Hit count: 340

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();
        }
    }

© Stack Overflow or respective owner

How do these user/userParam references relate to the Customer and Account lookups?

Posted by plath on Stack Overflow See other posts from Stack Overflow or by plath
Published on 2010-03-31T08:01:14Z Indexed on 2010/03/31 8:43 UTC
Read the original article Hit count: 340

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();
        }
    }

© Stack Overflow or respective owner

Related posts about google-app-engine

Related posts about java