RE: How to combine two non-decomposed m:n mappings in one collection?

2004-01-05 Thread Coup, Robert Muir
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]

---BeginMessage---
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 

Re: How to combine two non-decomposed m:n mappings in one collection?

2004-01-05 Thread Patrick Scheuerer
Coup, Robert Muir wrote:

Hi,

Did you see my response to your other post? Please reply to the list.
No I didn't, sorry! I somehow gave up on this post...

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 :)
This sounds interesting. Just let me make sure I got it right:
I have to create a new table t_download_supportitemI which has a m:n mappings to 
t_download and and one to t_document (pretty much a replacement for t_pal_model) 
and t_pal_model has a 1:n mapping to t_pal_model_supportitemI... is that correct?

Thank you very much for your detailed examples!

Patrick

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


RE: How to combine two non-decomposed m:n mappings in one collection?

2004-01-05 Thread Coup, Robert Muir
Hi,



 This sounds interesting. Just let me make sure I got it right: I have
to create a new table t_download_supportitemI which has a m:n mappings
to 
 t_download and and one to t_document (pretty much a replacement for
t_pal_model) 

Well, I would call it t_pal_model_supportitemI, and its a replacement
for t_pal_model_document AND t_pal_model_download

 and t_pal_model has a 1:n mapping to t_pal_model_supportitemI... is
that correct?

That was the idea. OJB _should_ be able to figure it out based on the
extents and retrieve the document/download from the correct table. 


One fix (which is probably why you got confused):

 class-descriptor class=download table=t_download
   ... Field Descriptors ...
   collection-descriptor name=models
   element-class-ref=pal_model
   indirection-table=t_pal_model_supportitems

   
   fk-pointing-to-this-class column=SupportItemID/
   fk-pointing-to-element-class column=model_id/
   /collection-descriptor
 /class-descriptor

Tell us how you get on.

Rob :)


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



Re: How to combine two non-decomposed m:n mappings in one collection?

2004-01-05 Thread Patrick Scheuerer
Coup, Robert Muir wrote:

Well, I would call it t_pal_model_supportitemI, and its a replacement
for t_pal_model_document AND t_pal_model_download
I guess that's what I wanted to say :-)

Tell us how you get on.
To remove any potential for misunderstanding (and since I'm a visual person :-)) 
I uploaded a new version of the data model picture:

http://homepage.hispeed.ch/tabalooga/datamodel-redesign.jpg

Patrick

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


Re: How to combine two non-decomposed m:n mappings in one collection?

2004-01-05 Thread Patrick Scheuerer
As you can see on the picture i adopted your t_ prefix for tables :-) It makes 
the repository.xml a lot easier to read! I hope you don't have a copyright on it ;-)

I will let you know how I get along. Thanks again!

Patrick

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


RE: How to combine two non-decomposed m:n mappings in one collection?

2004-01-05 Thread Coup, Robert Muir
Hi,

 As you can see on the picture i adopted your t_ prefix for tables :-)
It makes 
 the repository.xml a lot easier to read! I hope you don't have a
copyright on it ;-)

Yes. Well, I also got sick of playing with tables named 'user' and
'group' in projects - they need to be specified as '[user]' and
'[group]' in SQL for a number of dbms'...

 To remove any potential for misunderstanding (and since I'm a visual
person :-)) 
 I uploaded a new version of the data model picture:
 http://homepage.hispeed.ch/tabalooga/datamodel-redesign.jpg

Hmmm... now I'm confused again. :) Ah, you snuck in some other changes -
keyword now relates to pal_model? Or maybe not...
*** Assuming you want keyword and pal_model separate ***

There's no need to define SupportItemI as a class with a table since it
has no fields. It just tells OJB that Document and Download are related
and can be referred to by other persistent classes as a SupportItemI

Now ignoring role, category, user_role, and user:

Tables required:
T_download
T_document
T_pal_model
T_pal_model_supportitem
T_keyword_supportitem

Java Classes required:
SupportItemI Interface
Download (implements SupportItemI)
Document (implements SupportItemI)
Pal_model
Keyword

OJB Repository:
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=keyword table=t_keyword
  ... Field Descriptors ...
  collection descriptor name=collectionOfSupportItemIs
element-class-ref=SupportItemI
indirection-table=t_keyword_supportitems

fk-pointing-to-this-class column=keyword_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_pal_model_supportitems

fk-pointing-to-this-class column=SupportItemID/
fk-pointing-to-element-class column=model_id/
  /collection-descriptor
  collection-descriptor name=keywords
element-class-ref=keyword
indirection-table=t_keyword_supportitems

fk-pointing-to-this-class column=SupportItemID/
fk-pointing-to-element-class column=keyword_id/
  /collection-descriptor
/class-descriptor

class-descriptor class=document table=t_document
  ... Field Descriptors ...
  collection-descriptor name=models
element-class-ref=pal_model
indirection-table=t_pal_model_supportitems

fk-pointing-to-this-class column=SupportItemID/
fk-pointing-to-element-class column=model_id/
  /collection-descriptor
  collection-descriptor name=keywords
element-class-ref=keyword
indirection-table=t_keyword_supportitems

fk-pointing-to-this-class column=SupportItemID/
fk-pointing-to-element-class column=keyword_id/
  /collection-descriptor
/class-descriptor


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


Coup, Robert Muir wrote:

 Well, I would call it t_pal_model_supportitemI, and its a replacement 
 for t_pal_model_document AND t_pal_model_download

I guess that's what I wanted to say :-)

 Tell us how you get on.

To remove any potential for misunderstanding (and since I'm a visual
person :-)) 
I uploaded a new version of the data model picture:

http://homepage.hispeed.ch/tabalooga/datamodel-redesign.jpg

Patrick


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


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



Re: How to combine two non-decomposed m:n mappings in one collection?

2004-01-05 Thread Patrick Scheuerer
Coup, Robert Muir wrote:

Hmmm... now I'm confused again. :) Ah, you snuck in some other changes -
keyword now relates to pal_model? Or maybe not...
*** Assuming you want keyword and pal_model separate ***
The scenario is this: a PalModel should have a collection of SupportItemsI and a 
Keyword should have a collection of support items.
Keyword doesn't relate to pal_model.

Something else just came to my mind: a category should also have a collection of 
SupportItemsI... h. now it get's tricky...

I'm going through your answer now...

Patrick

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


Re: How to combine two non-decomposed m:n mappings in one collection?

2004-01-05 Thread Patrick Scheuerer
... and now for something completely different:

do i even have define foreign key constraints in my database??? I'm having the 
impression that OJB is handling all the joins. Is it enough to have some loose 
tables in my DB ???

Patrick

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


RE: How to combine two non-decomposed m:n mappings in one collection?

2004-01-05 Thread Coup, Robert Muir
 ... and now for something completely different:
 
 do i even have define foreign key constraints in my 
 database??? I'm having the 
 impression that OJB is handling all the joins. Is it enough 
 to have some loose 
 tables in my DB ???


Well, it's up to you.

OJB can and will do it anyway. If you want to use the database from
somewhere else (ie. Not going through OJB - maybe direct JDBC or
whatever) then it is probably a good idea so your data doesn't get
screwed up (which will then confuse OJB). :)

Rob :)

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



RE: How to combine two non-decomposed m:n mappings in one collection?

2004-01-05 Thread Coup, Robert Muir
 The scenario is this: a PalModel should have a collection of 
 SupportItemsI and a 
 Keyword should have a collection of support items.
 Keyword doesn't relate to pal_model.

Okay. So what was in my last email should work :)

 Something else just came to my mind: a category should also 
 have a collection of 
 SupportItemsI... h. now it get's tricky...
 

class-descriptor class=category table=t_category
  ... Fields ...
  collection-descriptor name=collectionOfSupportItemIs
element-class-ref=SupportItemI

foreignkey-fieldref=category_id/
  /collection-descriptor  
/class-descriptor

And in download if you want to be able to navigate to category using a
'myCategory' field 
(if you only want to navigate from category to download, don't worry)

class-descriptor class=download table=t_download
  ... Fields including 'category_id' ...
  ... Other collections for model/keywords ...

  reference-descriptor 
name=myCategory
class-ref=category

foreignkey field-ref=category_id/
  /reference-descriptor   
/class-descriptor

And similarly for document and role if you need it...

Rob :)

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



RE: How to combine two non-decomposed m:n mappings in one collection?

2004-01-05 Thread Coup, Robert Muir
One more important thing.

Make sure your primary keys are unique across Documents _and_ Downloads.
Ie. If there is document #10 there should never be download #10

This is because they are in the same extent. If you retrieve a
collection of SupportItemI's then they need to have unique IDs, or a Bad
Thing(TM) will occur.

Depending on your DBMS, you can do this in a number of ways.
http://db.apache.org/ojb/sequencemanager.html explains it. 
Set the same sequence-name for the primary key fields for all classes in
an extent (download and document).

Rob :)

 -Original Message-
 From: Patrick Scheuerer [mailto:[EMAIL PROTECTED] 
 Sent: Tuesday, 6 January 2004 12:35 p.m.
 To: OJB Users List
 Subject: Re: How to combine two non-decomposed m:n mappings 
 in one collection?
 
 
 ... and now for something completely different:
 
 do i even have define foreign key constraints in my 
 database??? I'm having the 
 impression that OJB is handling all the joins. Is it enough 
 to have some loose 
 tables in my DB ???
 
 Patrick
 
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 

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



Re: How to combine two non-decomposed m:n mappings in one collection?

2004-01-05 Thread Patrick Scheuerer
Thank you very much for your time and effort Robert!

I'm trying to get your solution to work now (keep your fingers crossed! :-) )

Since this is all for my thesis paper you will get an honorable mention in the 
acknowledgment section :-)

Thanks again and I'll let you know If it works!

Take care, Patrick

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