Hi hari,

Yes, calling account.isEnabled() before makePersistent() seems to be
required for the update to happen, but I'm not sure how this relates
to the issue of lazy-loading you mentioned. This is a detachable
entity (pm.setDetachAllOnCommit(true) + annotation). Maybe that has
something to do with it?

- Chris

On Sep 30, 4:56 am, Hariharan Anantharaman
<hariharan.ananthara...@gmail.com> wrote:
> Strange.
> I remember reading that JDO does lazy loading. That means unless you access
> the same, the object data is not physically loaded. But isn't set enabled
> means accessing the object?
>
> ~hari
>
> On Sep 30, 2010 2:17 AM, "Chris" <xop...@gmail.com> wrote:
>
> 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<google-appengine-java%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group 
> athttp://groups.google.com/group/google-appengine-java?hl=en.

-- 
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