For the XDoclet ojb module we had the idea of also creating database
foreignkeys for the indirection table of m:n collections.
However there might be a problem with inheritance, so I figured I ask the
db experts how foreignkeys should be defined in this case.
Consider this simple example :
/** @ojb.class */
public class A
{
/** @ojb.field primarykey="true" */
private int id;
/** @ojb.collection element-class-ref="B"
* foreignkey="AID"
* indirection-table="A_B"
*/
private java.util.List bs;
}
/** @ojb.class */
public class B
{
/** @ojb.field primarykey="true" */
private String id;
/** @ojb.collection element-class-ref="A"
* foreignkey="BID"
* indirection-table="A_B"
*/
private java.util.List as;
}
/** @ojb.class */
public class C extends B
{}
Now, should the resulting torque schema could look like this:
<database name="ojbtest">
<table name="A">
<column name="id"
javaName="id"
type="INTEGER"
primaryKey="true"
required="true"
/>
</table>
<table name="A_B">
<column name="AID"
type="INTEGER"
/>
<column name="BID"
type="VARCHAR"
size="24"
/>
<foreign-key foreignTable="A">
<reference local="AID" foreign="id"/>
</foreign-key>
<foreign-key foreignTable="B">
<reference local="BID" foreign="id"/>
</foreign-key>
</table>
<table name="B">
<column name="id"
javaName="id"
type="VARCHAR"
primaryKey="true"
required="true"
size="24"
/>
</table>
<table name="C">
<column name="id"
javaName="id"
type="VARCHAR"
primaryKey="true"
required="true"
size="24"
/>
</table>
</database>
or should there also be database foreignkeys for table A_B to the table C
?
Tom
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]