Hello

This is my test case :

        Long catId = Long.parseLong("23");
        ICategory catObj = catDao.get(catId);
        ICompany comp = new Company("Test compamy", catObj);
        comp = compDao.save(comp);


This is interface for category type :
public interface ICategory {

    public Key getId();

    public String getName();

    public void setName(String name);

    public Key getParent();
}


This is company interface for company type
public interface ICompany {
    public Key getId();
    public Key getCatId();
    public String getName();
    public void setName(String name);
}


This is my company model
   @PrimaryKey
    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
    private Key id;

    @Persistent
    private String name;

    *...@persistent(defaultFetchGroup="true")
    private Key catId; *
* what I should do write there "key type " or "Icategory type"*;


because when I add company so select category from select box and get the id
of category and after that I have to save company belong to category and
when I get the company details so category details must be come with
company. please check my test case. if any doubt so ask me. the main problem
is that can I persist  *   "private Icategory catId *" or what have to do
???

Thanks in advance and helping me out from this problem



On Thu, Aug 27, 2009 at 2:34 AM, Jason (Google) <apija...@google.com> wrote:

> 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 <rohit82.j...@gmail.com> 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)" <apija...@google.com> 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, shishirm...@gmail.com <
>> >
>> > shishirm...@gmail.com> 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.
>>
>>
>
> >
>


-- 
Rohit Jain
9313239880

--~--~---------~--~----~------------~-------~--~----~
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-java@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