Hi,
Here is a few questions regarding handling of 1:m and N:M relationships in
Castor.
Let's say I have three classes: Provider, Item, Part.
Relationships are these:
* one-to-many between Item and part Part
* many-to-many between Item and Provider

1. First question is regarding Castor requirement for bi-directional
associations.
These means that Item  class need to have collection of Parts and collection
of Providers, as well as the Provider need to have collection of Items and
Part need to have a reference to Item.
Is this correct?

2. Second, if I understand things correctly, when I load list of all Items -
the whole database will be loaded. 
If I want to avoid loading all Parts and Providers together with Items I
should use lazy loading.
Let's say that in my mapping for Item I have marked both Providers and Parts
lazy loaded.
Second question - what happens if I load list of Items, don't access any of
the Parts (to avoid their loading ) and then db.commit().
What will the Item.getParts() collection contain after commit?

3. Third and most important to me is on proper way of adding Parts (because
they depend of Items due to 1:M).
Can I add part like this:

        Item i = db.load(...);
        Part p = new Part(....);
        p.setItem(i);
        db.create(p);
        db.commit()

What is the proper way of adding many-side objects?

4. Will Castor "complain" if I don't specify relationships between classes
in mapping file? Could that cause some problems to Castor?
I assume that in this case, the foreign-key field in the Parts won't be
reference to Item, but of type the Item key is (int in my case).
Is this correct?
   

Regards,
Emir



----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-user

Reply via email to