Hello.

I have a strange issue where I occasionally fail to update the Account
object in this method.

If I call the isEnabled() method (which returns true or false) before
I call makePersistent, the update always happens.

But if I don't 'access' the account object before makePersistent(),
the update doesn't happen.

I have no idea why this happens.

public final boolean enableAccount(final String key)
        {
                PersistenceManager pm =
PersistenceManagerFactoryUtils.getPersistenceManager(pmf, true);
                pm.setDetachAllOnCommit(true);

                final Query query = pm.newQuery(Account.class);
                query.setFilter("enableKey == enableKeyP");
                query.declareParameters("String enableKeyP");

                try
                {
                        List<Account> results = (List<Account>) 
query.execute(key);
                        if (results.iterator().hasNext())
                        {
                                for (Account account : results)
                                {
                                        if(!account.isEnabled())
                                        {
                                                account.setEnabled(true);
                                                pm.makePersistent(account);
                                                pm.close();
                                        }
                                }
                        }
                        else
                        {
                                return false;
                        }
                }
                catch (Exception e)
                {
                        LOGGER.warn("enableAccount() problem", e);
                        return false;
                }
                return true;
        }

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.

Reply via email to