Hi,
And finally if I want to resume the solution:
Class A { Class QualifiedARef {
int A_id int qualifiedId
String name int A_id
QualifiedARef qualifiedARef String relationInfo
... A classARef
} ...
}
Table A Table QualifiedARef
------- -------------------
A_ID_PK: int QUALIFIEDAREF_ID_PK: int
NAME: varchar A_ID_FK: int
RELATION_INFO: varchar
<class-descriptor
class="A"
table="A"
>
<field-descriptor id="1"
name="A_id"
column="A_ID_PK"
jdbc-type="INTEGER"
primarykey="true"
autoincrement="true"
/>
<field-descriptor id="2"
name="name"
column="NAME"
jdbc-type="VARCHAR"
/>
<collection-descriptor
name="qualifiedARefs"
element-class-ref="QualifiedARef"
auto-retrieve="true"
auto-update="false"
indirection-table="QualifiedARef"
>
<fk-pointing-to-this-class column="QUALIFIEDAREF_ID_PK"/>
<fk-pointing-to-element-class column="A_ID_FK"/>
</collection-descriptor>
</class-descriptor>
<class-descriptor
class="QualifiedARef"
table="QualifiedARef"
>
<field-descriptor id="1"
name="qualifiedId"
column="QUALIFIEDAREF_ID_PK"
jdbc-type="INTEGER"
primarykey="true"
autoincrement="true"
/>
<field-descriptor id="2"
name="A_id"
column="A_ID_FK"
jdbc-type="INTEGER"
/>
<field-descriptor id="3"
name="relationInfo"
column="RELATION_INFO"
jdbc-type="VARCHAR"
/>
<reference-descriptor
name="classARef"
class-ref="A"
>
<foreignkey field-id-ref="2"/>
</reference-descriptor>
</class-descriptor>
So now I have a 1:N relationship between A and QualifiedARef. And I have my self
reference: class A can have a reference to another instance of class A or a collection
of class A.
Do you think that it could work?
Thank you
Regards
Sylvain
-----Message d'origine-----
De: Phil Warrick [mailto:[EMAIL PROTECTED]]
Date: lundi, 16. d�cembre 2002 17:29
�: OJB Users List
Objet: Re: OJB and recursive relationship
Sylvain,
> Phil,
>
> What OJB doesn't support exactly?
>
Sorry I was thinking about another (related) OJB limitation: M:N
relations can use an indirection table but 1:N relations cannot. In
your case for a reference you just need one more A field in the class
and table:
Class A {
int A_id
int qualifiedARefId
String name
QualifiedARef qualifiedARef
}
Table A
int A_id_PK
int QUALIFIEDAREFID
String NAME
<class-descriptor
class="A"
table="A"
>
<field-descriptor id="1"
name="A_id"
column="A_ID_PK"
jdbc-type="INTEGER"
primarykey="true"
autoincrement="true"
/>
<field-descriptor id="2"
name="qualifiedARefId"
column="QUALIFIEDAREFID"
jdbc-type="INTEGER"
/>
<field-descriptor id="2"
name="name"
column="NAME"
jdbc-type="VARCHAR"
/>
<reference-descriptor
name="qualifiedARef"
class-ref="QualifiedARef"
>
<foreignkey field-id-ref="2"/>
</reference-descriptor>
</class-descriptor>
Phil
[EMAIL PROTECTED] wrote:
> Sylvain
>
> -----Message d'origine-----
> De: Phil Warrick [mailto:[EMAIL PROTECTED]]
> Date: lundi, 16. d�cembre 2002 17:11
> Cc: OJB Users List
> Objet: Re: OJB and recursive relationship
>
>
> Sylvain,
>
> Actually my example wouldn't work for a reference (it needs access to
> the indirection table "QualifiedARef" and OJB doesn't support this yet
> AFAIK). A collection in the A class descriptor should work though:
>
> <collection-descriptor
> name="qualifiedARefs"
> element-class-ref="QualifiedARef"
> auto-retrieve="true"
> auto-update="false"
> indirection-table="QualifiedARef"
> >
> <fk-pointing-to-this-class column="QUALIFIEDAREF_PK"/>
> <fk-pointing-to-element-class column="A_ID_FK"/>
> </collection-descriptor>
>
> Phil
>
> Phil Warrick wrote:
>
>>Sylvain,
>>
>>Something like this?
>>
>><class-descriptor
>> class="A"
>> table="A"
>> >
>> <field-descriptor id="1"
>> name="A_id"
>> column="A_ID_PK"
>> jdbc-type="INTEGER"
>> primarykey="true"
>> autoincrement="true"
>> />
>> <field-descriptor id="2"
>> name="name"
>> column="NAME"
>> jdbc-type="VARCHAR"
>> />
>> <reference-descriptor
>> name="qualifiedARef"
>> class-ref="QualifiedARef"
>> >
>> <foreignkey field-id-ref="4"/>
>> </reference-descriptor>
>></class-descriptor>
>>
>><class-descriptor
>> class="QualifiedARef"
>> table="QualifiedARef"
>> >
>> <field-descriptor id="1"
>> name="qualifiedId"
>> column="QUALIFIEDAREF_PK"
>> jdbc-type="INTEGER"
>> primarykey="true"
>> autoincrement="true"
>> />
>> <field-descriptor id="2"
>> name="A_id"
>> column="A_ID_FK"
>> jdbc-type="INTEGER"
>> />
>> <field-descriptor id="3"
>> name="relationInfo"
>> column="RELATION_INFO"
>> jdbc-type="VARCHAR"
>> />
>> <reference-descriptor
>> name="classARef"
>> class-ref="A"
>> >
>> <foreignkey field-id-ref="2"/>
>> </reference-descriptor>
>></class-descriptor>
>>
>>Phil
>>
>>[EMAIL PROTECTED] wrote:
>>
>>
>>>Phil,
>>>
>>>Ok but how do you do the self-reference?
>>>
>>>Sorry I don't understand.
>>>
>>>Sylvain
>>>
>>>
>>>-----Message d'origine-----
>>>De: Phil Warrick [mailto:[EMAIL PROTECTED]]
>>>Date: lundi, 16. d�cembre 2002 16:43
>>>�: OJB Users List
>>>Objet: Re: OJB and recursive relationship
>>>
>>>
>>>Sylvain,
>>>
>>>Only one A fk is required in the QualifiedARef table:
>>>
>>>QualifiedARef
>>>-------------
>>>int qualifiedARef_PK
>>>String relationInfo
>>>int A_id_FK
>>>
>>>Phil
>>>
>>>
>>> >
>>>[EMAIL PROTECTED] wrote:
>>>
>>>
>>>>So, more in practise:
>>>>
>>>>Classes:
>>>>
>>>>Class A { Classe QualifiedARef {
>>>>int A_id int qualifiedId
>>>>String name A classARef
>>>>QualifiedARef qualifiedARef String relationInfo
>>>>... int A_id
>>>>} ....
>>>> }
>>>>
>>>>
>>>>Relationnal tables:
>>>>
>>>>A QualifiedARef
>>>>- -------------
>>>>int A_id_PK int qualifiedARef_PK
>>>>String name int A_id_class_ref_FK
>>>> String relationInfo
>>>> int A_id_FK
>>>>
>>>>
>>>>Am I on the right way?
>>>>is there a probem in the QualifiedARef table because there are 2 FK
>>>>for A??
>>>>
>>>>Thank you
>>>>Regards
>>>>Sylvain
>>>>
>>>>
>>>>
>>>>
>>>>-----Message d'origine-----
>>>>De: Phil Warrick [mailto:[EMAIL PROTECTED]]
>>>>Date: lundi, 16. d�cembre 2002 15:59
>>>>�: OJB Users List
>>>>Objet: Re: OJB and recursive relationship
>>>>
>>>>
>>>>Hi Sylvain,
>>>>
>>>>Yes, then class A instead has a reference to a class QualifiedARef
>>>>(or a collection of these). QualifiedARef holds the relation info
>>>>and a reference to the target A. If bidirectionality is important,
>>>>it can hold a reference to both of the As in the relation.
>>>>
>>>>Phil
>>>>
>>>>[EMAIL PROTECTED] wrote:
>>>>
>>>>
>>>>
>>>>>Hi Phil,
>>>>>
>>>>>Thank you for your answer.
>>>>>Is it also possible if you qualified this self reference (add
>>>>>information about relation)?
>>>>>
>>>>>For example if class A have a reference to another instance of class
>>>>>A and this reference has information like reference_name or
>>>>>something like that.
>>>>>
>>>>>Regards
>>>>>Sylvain
>>>>>
>>>>>-----Message d'origine-----
>>>>>De: Phil Warrick [mailto:[EMAIL PROTECTED]]
>>>>>Date: lundi, 16. d�cembre 2002 15:14
>>>>>�: OJB Users List
>>>>>Objet: Re: OJB and recursive relationship
>>>>>
>>>>>
>>>>>Hi Sylvain,
>>>>>
>>>>>OJB handles self references fine. In other words class A can have a
>>>>>reference to another instance of class A or a collection of class
>>>>>As. You may need to make these proxies if the graph is very large
>>>>>and you need to control the hits to the db.
>>>>>
>>>>>Phil
>>>>>
>>>>>[EMAIL PROTECTED] wrote:
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>>Hello,
>>>>>>
>>>>>>I have a situation with recursive relationship:
>>>>>>
>>>>>>I have a class Software that represents the softwares that could be
>>>>>>installed on my machine. Some of these softwares must have other
>>>>>>softwares installed before to be able to be installed.
>>>>>>So, I have a recurvive relationship here.
>>>>>>
>>>>>>How do you implement this relationship with OJB?
>>>>>>
>>>>>>Thank you
>>>>>>Sylvain
>>>>>>
>>>>>>--
>>>>>>To unsubscribe, e-mail:
>>>>>><mailto:[EMAIL PROTECTED]>
>>>>>>For additional commands, e-mail:
>>>>>><mailto:[EMAIL PROTECTED]>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>--
>>>>>To unsubscribe, e-mail:
>>>>><mailto:[EMAIL PROTECTED]>
>>>>>For additional commands, e-mail:
>>>>><mailto:[EMAIL PROTECTED]>
>>>>>
>>>>>
>>>>>--
>>>>>To unsubscribe, e-mail:
>>>>><mailto:[EMAIL PROTECTED]>
>>>>>For additional commands, e-mail:
>>>>><mailto:[EMAIL PROTECTED]>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>--
>>>>To unsubscribe, e-mail:
>>>><mailto:[EMAIL PROTECTED]>
>>>>For additional commands, e-mail:
>>>><mailto:[EMAIL PROTECTED]>
>>>>
>>>>
>>>>--
>>>>To unsubscribe, e-mail:
>>>><mailto:[EMAIL PROTECTED]>
>>>>For additional commands, e-mail:
>>>><mailto:[EMAIL PROTECTED]>
>>>
>>>
>>>
>>>
>>>
>>>--
>>>To unsubscribe, e-mail:
>>><mailto:[EMAIL PROTECTED]>
>>>For additional commands, e-mail:
>>><mailto:[EMAIL PROTECTED]>
>>>
>>>
>>>--
>>>To unsubscribe, e-mail:
>>><mailto:[EMAIL PROTECTED]>
>>>For additional commands, e-mail:
>>><mailto:[EMAIL PROTECTED]>
>>
>>
>
>
>
> --
> To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
>
>
> --
> To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>