Hi,

Did you see my response to your other post? Please reply to the list.

Cheers,

Rob :)

-----Original Message-----
From: Patrick Scheuerer [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, 6 January 2004 10:17 a.m.
To: OJB Users List
Subject: How to combine two non-decomposed m:n mappings in one
collection?


Hi,

I have the following problem:

I have a table keywords which has two non-decomposed m:n mappings to the
tables 
document and file. The latter two both implement the interface
SupportItem. In 
my Keyword class i would like to have a collection of all SupportItems
for this 
keyword.
Is it possible to declare two indirection-tables in a
collection-descriptor? If not, how could this be accomplished? Can OJB
handle such a case?

Thanks a lot!
Patrick


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

--- Begin Message ---
Hi Patrick.

Is the field doc_id in download_pal_model actually meant to be model_id?
Otherwise I am a touch confused :)

Also, I assume you've checked out the advanced O/R mapping stuff at
http://db.apache.org/ojb/tutorial3.html - if not, do it now!

Idea #1:
  For download -> model
<class-descriptor class="download" table="t_download">
  ... Field Descriptors ...

  <collection-descriptor name="models"
        element-class-ref="pal_model"
        indirection-table="t_download_pal_model"
        >
        <fk-pointing-to-this-class column="download_id"/>
        <fk-pointing-to-element-class column="model_id"/>
  </collection-descriptor>
</class-descriptor>
  And going from model -> download...
<class-descriptor class="model" table="t_model">
  ... Field Descriptors ...

  <collection-descriptor name="downloads"
        element-class-ref="download"
        indirection-table="t_download_pal_model"
        >
        <fk-pointing-to-this-class column="model_id"/>
        <fk-pointing-to-element-class column="download_id"/>
  </collection-descriptor>
</class-descriptor>

Okay, that's a simple non-decomposed M:N and you probably know that
already ... That doesn't really help with the single-collection issue at
all.


Idea #2:
How about:
<class-descriptor class="SupportItemI">
  <extent-class class-ref="Document"/>
  <extent-class class-ref="Download"/>
</class-descriptor>

<class-descriptor class="pal_model" table="t_pal_model">
  ... Field Descriptors ...
  <collection descriptor name="collectionOfSupportItemIs"
        element-class-ref="SupportItemI"
        indirection-table="t_pal_model_supportitems"
        >
        <fk-pointing-to-this-class column="model_id"/>
        <fk-pointing-to-element-class column="SupportItemID"/>
  </collection-descriptor>
</class-descriptor> 

<class-descriptor class="download" table="t_download">
  ... Field Descriptors ...
  <collection-descriptor name="models"
        element-class-ref="pal_model"
        indirection-table="t_download_pal_model"
        >
        <fk-pointing-to-this-class column="SupportItemID"/>
        <fk-pointing-to-element-class column="model_id"/>
  </collection-descriptor>
</class-descriptor>

You should be able to keep your object design the same and just modify
the tables a bit so there is one table for both relations... Still
non-decomposed :)

#3:
Implement pal_model_download and pal_model_document as classes,
extending a common class (ModelContents). Then ...

<class-descriptor class="ModelContents">
  <extent-class class-ref="pal_model_download"/>
  <extent-class class-ref="pal_model_document"/>
</class-descriptor>

<class-descriptor class="pal_model" table="t_pal_model">
  ... Field Descriptors ...
  <collection descriptor name="collectionOfSupportItemIs"
        element-class-ref="ModelContents"
        >
        <inverse-foreignkey field-ref="model_id"/>
  </collection-descriptor>
</class-descriptor> 

<class-descriptor class="download" table="t_download">
  ... Field Descriptors ...
  <collection-descriptor name="Models"
        element-class-ref="pal_model_download"
        >
        <inverse-foreignkey field-ref="download_id"/>
  </collection-descriptor>
</class-descriptor>

<class-descriptor class="pal_model_download"
table="t_pal_model_download">
  <field-descriptor name="model_id" ... />
  <field-descriptor name="download_id" ... />
  <reference-descriptor name="download"
        class-ref="download"
        >
        <foreignkey field-ref="download_id"/>
  </reference-descriptor>
  <reference-descriptor name="model"
        class-ref="model"
        >
        <foreignkey field-ref="model_id"/>
  </reference-descriptor>
</class-descriptor>

This will make the object model a bit harder, since
model.collectionOfSupportItemIs will return ModelContent objects, not
actual Downloads/Documents (i.e decomposed M:N) but you can keep the
existing table stuff.



Others may have better ideas :)

Good Luck,

Rob :)



-----Original Message-----
From: Patrick Scheuerer [mailto:[EMAIL PROTECTED] 
Sent: Friday, 2 January 2004 2:56 p.m.
To: OJB Users List
Subject: Mapping Question


Hi,

Please see the attached image of my data model for reference (I'm sorry
for the 
attachment but it's kind of complicated to describe the scenario
otherwise. A 
picture says more than a thousand words :-) ).

How do I map the relationship between pal_model - download and pal_model
- document? The corresponding value objects (DownloadVO and DocumentVO)
both implement the 
Interface SupportItemI.
My PalModelVO has a collection which holds all the SupportItemIs for a
PalModelVO.

How can I map a collection that gets it's data from two m-n
relationships? Can I 
specify two indirection tables? Do i have to change my data model?

Any comments and suggestions are welcome.

I wish everybody a peaceful, prosperous and happy new year! Patrick


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





--- End Message ---
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to