Henry,

What's happening here is your Key is getting retrieved lazily. You need to
do a call announcerLoaded.getCountry() before you close the
PersistenceManager.

This behavior has been changed in 1.2.8. All the fields should be eager
populated.

On Thu, Dec 3, 2009 at 9:58 AM, Henry <[email protected]> wrote:

> The method which I have to retrieve the information of and announcer
> is this one...
>
> private Announcer getAnnouncerFromEmailAddress(String emailAddress)
> throws UnknownUserException {
>                Announcer announcerLoaded = null;
>                // Creating a PersistentManager to interact with the
> DataBase
>                 PersistenceManager pm = PMF.get().getPersistenceManager();
>                 // Query to check if the current user exists
>                Query query = pm.newQuery(Announcer.class);
>                // Set the filter
>                query.setFilter("emailAddress == emailAddressParam");
>                // Declare the parameter
>                query.declareParameters("String emailAddressParam");
>                // Run the query and check the result
>                try {
>                        List<Announcer> results = (List<Announcer>)
> query.execute
> (emailAddress);
>                        if (!results.isEmpty()) {
>                                announcerLoaded = results.get(0);
>                        } else {
>                                throw new UnknownUserException();
>                        }
>                } finally {
>                        pm.close();
>                }
>                return announcerLoaded;
>        }
>
> after execute the query, the field country is null.
>
> On Dec 2, 7:13 pm, "Ikai L (Google)" <[email protected]> wrote:
> > Do you have a reproducible test case or some code you can post?
> >
> >
> >
> > On Tue, Dec 1, 2009 at 5:02 AM, Henry <[email protected]> wrote:
> > > Hi Guys,
> >
> > > Im new at Google App Engine, I've the follow problem:
> > > When Im recovering a persistent class Announcer, it has one field
> > > (country) with NO VALUE...I thought that must to be for a bad mapping
> > > with the annotations creating the proper class, but I don't know how
> > > to do to get again the Key that I've stored. When Im storing the Key
> > > (country), it has value, I can see it in the Google App Engine
> > > DataViewer.
> > > This is my class with the annotations:
> >
> > > @PersistenceCapable(identityType = IdentityType.APPLICATION)
> > > public class Announcer {
> >
> > >        @PrimaryKey
> > >        @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
> > >        private Long id;
> > >        @Persistent
> > >        private String emailAddress;
> > >        @Persistent
> > >        private String password;
> > >        @Persistent
> > >        private String firstName;
> > >        @Persistent
> > >        private String lastName;
> > >        @Persistent
> > >        private Key country;
> >
> > > Anyone could help me?
> > > Im using Java and JDO.
> > > Thanks for advance.
> >
> > > --
> >
> > > You received this message because you are subscribed to the Google
> Groups
> > > "Google App Engine" group.
> > > To post to this group, send email to [email protected]
> .
> > > To unsubscribe from this group, send email to
> > > [email protected]<google-appengine%[email protected]>
> <google-appengine%[email protected]<google-appengine%[email protected]>
> >
> > > .
> > > For more options, visit this group at
> > >http://groups.google.com/group/google-appengine?hl=en.
> >
> > --
> > Ikai Lan
> > Developer Programs Engineer, Google App Engine
>
> --
>
> You received this message because you are subscribed to the Google Groups
> "Google App Engine" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<google-appengine%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/google-appengine?hl=en.
>
>
>


-- 
Ikai Lan
Developer Programs Engineer, Google App Engine

--

You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en.


Reply via email to