You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by BOUESSAY Christian <cb...@businessdecision.com> on 2004/09/22 10:29:52 UTC
Collection + foreignkey missing
Hello,
There is an association (1:n) between 2 classes:
/**
* @ojb.class
* @ojb.field name="idOM" jdbc-type="INTEGER"
*/
public class Label {
/**
* @ojb.field primarykey="true"
*/
private int id;
// ...
}
/**
* @ojb.class
*/
class OM {
/**
* @ojb.field primarykey="true"
*/
private int id;
/**
* @ojb.collection element-class-ref="Label"
* foreignkey="idOM"
*/
private Collection labels;
// ...
}
In the repository_user.xml :
<collection-descriptor
name="labels"
element-class-ref="Label"
>
<inverse-foreignkey field-ref="idOM"/>
</collection-descriptor>
In the project-schema.xml, there is no <foreign-key> declaration for the table OM ...
What did I miss?
Christian
(I'm a newbie with OJB/xdoclet.
I didn't found it in the archive, neither in the docs...)
Re: Collection foreignkey missing
Posted by Thomas Paradies <pa...@transit-online.de>.
Christian,
if project-schema.xml means torque-schema.xml have look at Tom's reply
http://nagoya.apache.org/eyebrowse/ReadMsg?listName=ojb-user@db.apache.org&msgNo=14428
Thomas
BOUESSAY Christian wrote:
>
> Hello,
>
> There is an association (1:n) between 2 classes:
>
> /**
> * @ojb.class
> * @ojb.field name="idOM" jdbc-type="INTEGER"
> */
> public class Label {
> /**
> * @ojb.field primarykey="true"
> */
> private int id;
>
> // ...
> }
>
> /**
> * @ojb.class
> */
> class OM {
>
> /**
> * @ojb.field primarykey="true"
> */
> private int id;
>
> /**
> * @ojb.collection element-class-ref="Label"
> * foreignkey="idOM"
> */
> private Collection labels;
>
> // ...
> }
>
> In the repository_user.xml :
> <collection-descriptor
> name="labels"
> element-class-ref="Label"
> >
> <inverse-foreignkey field-ref="idOM"/>
> </collection-descriptor>
>
> In the project-schema.xml, there is no <foreign-key> declaration for the table OM ...
>
> What did I miss?
>
> Christian
>
> (I'm a newbie with OJB/xdoclet.
> I didn't found it in the archive, neither in the docs...)
--
+----------------------------------+-----------------------------------+
| tranSIT GmbH | phone: +49 3677 8451 11 |
| Langewiesener Str. 32 | fax: +49 3677 8451 2211 |
| 98693 Ilmenau | mobile: +49 172 3676031 |
| Germany | |
+----------------------------------+-----------------------------------+
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
Re: Collection + foreignkey missing
Posted by Thomas Dudziak <to...@first.fhg.de>.
Christian Pesch wrote:
> Are there plans to implement this?
Erm, yes, but I don't know when ;-( I'm a bit swamped at the moment ...
Tom
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
Re: Collection + foreignkey missing
Posted by Christian Pesch <ch...@coremedia.com>.
Thomas Dudziak wrote:
> [..]
> Implementing this analysis therefore requires determining what cases
> can possibly arise and then quite some implementation work (esp. unit
> tests).
Are there plans to implement this?
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
Re: Collection + foreignkey missing
Posted by Thomas Dudziak <to...@first.fhg.de>.
Christian Pesch wrote:
> Could you explain, where the complexity comes from?
> The requirement to define foreign keys on the database schema seems
> reasonable to me. At least, I've copied the schema definition in my
> application
> and added foreign key constraints to it.
>
> Maybe one could take some assumptions and eliminate the need for a
> manual step
> in a simple setup without redirection tables and inheritance and ...?
The problem comes from the necessity to analyze whether a foreignkey can
be placed safely or not. For instance, you cannot define a foreignkey
constraint upon an indirection table if this table is used by a normal
class descriptor as well. It can get even more complex if you have
inheritance for one end of the collection, say via super-references
(which is only implicit in the repository).
Implementing this analysis therefore requires determining what cases can
possibly arise and then quite some implementation work (esp. unit tests).
Tom
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
Re: Collection + foreignkey missing
Posted by Christian Pesch <ch...@coremedia.com>.
Thomas Dudziak wrote:
> BOUESSAY Christian wrote:
>
>> There is an association (1:n) between 2 classes:
>> [..]
>> In the project-schema.xml, there is no <foreign-key> declaration for
>> the table OM ...
>>
>> What did I miss?
>
> For collections, the generation of foreignkeys in the database is
> currently not supported due to the complexities involved when having
> indirection tables, inheritance etc.
Could you explain, where the complexity comes from?
The requirement to define foreign keys on the database schema seems
reasonable to me. At least, I've copied the schema definition in my
application
and added foreign key constraints to it.
Maybe one could take some assumptions and eliminate the need for a
manual step
in a simple setup without redirection tables and inheritance and ...?
Christian
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
Re: Collection + foreignkey missing
Posted by Thomas Dudziak <to...@first.fhg.de>.
BOUESSAY Christian wrote:
>Hello,
>
>There is an association (1:n) between 2 classes:
>
>
>/**
> * @ojb.class
> * @ojb.field name="idOM" jdbc-type="INTEGER"
> */
>public class Label {
> /**
> * @ojb.field primarykey="true"
> */
> private int id;
>
> // ...
>}
>
>
>/**
> * @ojb.class
> */
>class OM {
>
> /**
> * @ojb.field primarykey="true"
> */
> private int id;
>
> /**
> * @ojb.collection element-class-ref="Label"
> * foreignkey="idOM"
> */
> private Collection labels;
>
> // ...
>}
>
>
>In the repository_user.xml :
><collection-descriptor
> name="labels"
> element-class-ref="Label"
>
>
> <inverse-foreignkey field-ref="idOM"/>
></collection-descriptor>
>
>
>In the project-schema.xml, there is no <foreign-key> declaration for the table OM ...
>
>What did I miss?
>
>
For collections, the generation of foreignkeys in the database is
currently not supported due to the complexities involved when having
indirection tables, inheritance etc.
Tom
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org