Try adding the catId field to the default fetch group:
...
@Persistent(defaultFetchGroup = "true")
private Category catId;

Then, when you fetch a Company object, you should be able to call
company.getCatId() or whatever method you've set up to get a reference to
the corresponding Category object.

- Jason

On Tue, Aug 25, 2009 at 5:32 AM, java <[email protected]> wrote:

>
> Hello
>
> we have similar type of problem and code is
>
> there is company class model.
> public class Company implements ICompany {
>        private static final long serialVersionUID = 1L;
>
>        @PrimaryKey
>        @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
>        private Key id;
>
>        @Persistent
>        private String name;
>
>        @Persistent
>        private Category catId;
> }
>
>
> this is my category class model
> public class Category extends BaseObject implements ICategory {
>
>        private static final long serialVersionUID = 1L;
>
>        @PrimaryKey
>        @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
>        private Key id;
>
>        @Persistent
>        private String name;
>
>        @Persistent
>        private Key parent;
> }
>
> catId of company is foreign key.
>
> I want to retrieve company info with category details in single object
> how implement in jdo  . because in hibernate it joined automatically
> and get details in single object.
>
> I am trying to get the details of both in single object , but only
> company info. is coming and category id is coming , not coming
> category full details .
>
>
> On Jul 28, 2:47 am, "Jason (Google)" <[email protected]> wrote:
> > Hi Shishir. Given that you mention annotations, I'm assuming that you're
> > using JDO. Please let me know if I'm incorrect.
> > If you're using JDO, this becomes very easy. You shouldn't have to
> manually
> > create the Key objects for your AccountInfo instances since App Engine
> will
> > create this for you when you persist your Customer entities (assuming
> you're
> > modeling an owned relationship between Customer and AccountInfo). To
> fetch
> > all AccountInfo entities associated with a given Customer, just create an
> > accessor for the accounts field in your Customer class that you used to
> > persist the AccountInfo entities in the first place.
> >
> > See the documentation on Relationships for more information, and please
> let
> > me know if you have any more questions, and please feel free to paste
> your
> > JDO classes inline.
> >
> > http://code.google.com/appengine/docs/java/datastore/relationships.ht...
> >
> > Thanks,
> > - Jason
> >
> > On Sat, Jul 25, 2009 at 9:49 PM, [email protected] <
> >
> > [email protected]> wrote:
> >
> > > I have two classes; one is Customer and one is AccountInfo. A customer
> > > can have multiple account numbers. I use the KeyBuilder.addChild()
> > > method to create the AccountInfo keys. Now for each customer i wish to
> > > retrieve all the accounts. How can this be achieved if there is no
> > > foreign key reference in AccountInfo.
> >
> > > Secondly, if i have to create a foreign key reference of customerId in
> > > AccountInfo, how can it be done using annotations?
> >
> > > Regards,
> > > Shishir.
> >
>

--~--~---------~--~----~------------~-------~--~----~
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 [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-java?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to