Menu

#122 Problem with two FK between two tables

open
EJB (58)
5
2003-11-06
2003-11-06
No

I have two tables:

Entidad (entity) and Pertenece (belongs to)

They try to model an abstract
user-group-parentgroup..... relation, with no limits
betwen belonging as far as a user doesn't belong to
other user, I keep track of the row being a group with
a flag atribute in the entidad table.

I have more tables and more relations, It doesn't
deploy on JBoss but if comment this relation in the
ejbjar.xml and jboss-jdbccmp.xml files it deploys fine
(wothout these relations)

And here comes the issue when I say I comment out this
realtion in the xml files is because when I launch
Xdoclet I get only one relation generated in the XML
files, One relation but with the two Fks in it!!!!!!
I have other similar relations but involving 3 tables (
one of them, as pertenece in thios case) is to model a
n_m relation, it came from the database design and in
several cases they contain aditional attributes (suchs
as IP, time-date etc), the case is that in those
realtions I get 2 relations in the XML files, not just one.

It seems to me that middlegen generated bad Xdoclet
code in the bean class, I think that the bad code comes
from the fact of having 2 realions betwen the sme
tables, I think it generates only one relation with the
two FKs.

This is the relation
Actually I think there should be two relations, one
with PKEntidad1 and one with PKEntidad2

<ejb-relation>

<ejb-relation-name>entidades-cmp20-pertenece-cmp20</ejb-relation-name>
<foreign-key-mapping/>

<ejb-relationship-role>

<ejb-relationship-role-name>pertenece-cmp20-has-entidades-cmp20</ejb-relationship-role-name>
<fk-constraint>true</fk-constraint>
<key-fields/>

</ejb-relationship-role>
<ejb-relationship-role>

<ejb-relationship-role-name>entidades-cmp20-has-pertenece-cmp20</ejb-relationship-role-name>
<key-fields>
<key-field>
<field-name>pkentidad</field-name>
<column-name>PKEntidad2</column-name>
</key-field>
<key-field>
<field-name>pkentidad</field-name>
<column-name>PKEntidad1</column-name>
</key-field>
</key-fields>

</ejb-relationship-role>
</ejb-relation>

Discussion

  • Jose Manuel Molina

    jdbc-cmp.xml

     
  • Jose Manuel Molina

     
  • Jose Manuel Molina

    EntidadBean.java

     
  • Jose Manuel Molina

    TablaBean.java

     

Log in to post a comment.