3 Replies Latest reply on Jul 22, 2002 3:56 AM by Starco

    bidirectional One to Many relation problem with CMP-bean

    Starco Newbie

      Hello, all.

      JBoss3.0.0
      jdk 1.4.0

      How to organize bidirectional one-to-many relationalship between 2 beans in JBoss? Can I find a example somewhere?

      I tried do it. But I got the exception:
      java.sql.SQLException: ORA-00904: invalid column name
      for sql statement:
      Executing SQL: SELECT t0_complexar_atomicBO.ABOID FROM COMPLEXBO t1_bo, COMPLEXATOMICRELATION t3_complexar, ATOMICBOIDENTIFIER t2_complexar_atomicBOIdentifie, ATOMICBO t0_complexar_atomicBO WHERE (t1_bo.CBOID = ? AND t2_complexar_atomicBOIdentifie.identifier = ?) AND (t1_bo.CBOID=t3_complexar.CBOID AND t3_complexar.ABOIID=t2_complexar_atomicBOIdentifie.ABOIID AND t3_complexar.ABOID=t0_complexar_atomicBO.ABOID)

      I have no such columns. I have the following tables and columns:
      ComplexBO
      . CBOID (PK)
      . version
      ComplexAtomicRelation
      . id (PK)
      . CBOID (FK)
      There are corresponding entities and cmr-fields
      ComplexBO
      . complexAtomicRelations
      ComplexAtomicRelation
      . complexBO
      (As you see the names of tables and entities are coincide.)

      There is a piece from ejb-jar.xml:
      <ejb-relation>
      . <ejb-relation-name>CBOToComplexAtomicRelation</ejb-relation-name>
      . <ejb-relationship-role>
      .. complexBO
      .. <ejb-relationship-role-name>complexBO</ejb-relationship-role-name>
      .. One
      .. <relationship-role-source>
      ... complexBO
      ... <ejb-name>ComplexBO</ejb-name>
      .. </relationship-role-source>
      .. <cmr-field>
      ... complexAtomicRelation
      ... <cmr-field-name>complexAtomicRelations</cmr-field-name>
      ... <cmr-field-type>java.util.Collection</cmr-field-type>
      .. </cmr-field>
      . </ejb-relationship-role>
      . <ejb-relationship-role>
      .. complexAtomicRelation
      .. <ejb-relationship-role-name>complexAtomicRelations</ejb-relationship-role-name>
      .. Many
      .. <cascade-delete />
      .. <relationship-role-source>
      ... complexAtomicRelation
      ... <ejb-name>ComplexAtomicRelation</ejb-name>
      .. </relationship-role-source>
      .. <cmr-field>
      ... complexBO
      ... <cmr-field-name>complexBO</cmr-field-name>
      .. </cmr-field>
      . </ejb-relationship-role>
      </ejb-relation>

      There is a piece from jbosscmp-jdbc.xml:
      <ejb-relation>
      . <ejb-relation-name>CBOToComplexAtomicRelation</ejb-relation-name>
      . <foreign-key-mapping/>
      . <ejb-relationship-role>
      .. <ejb-relationship-role-name>complexBO</ejb-relationship-role-name>
      .. <key-fields>
      ... <key-field>
      .... <field-name>complexBOId</field-name>
      .... <column-name>CBOID</column-name>
      ... </key-field>
      .. </key-fields>
      . </ejb-relationship-role>
      . <ejb-relationship-role>
      .. <ejb-relationship-role-name>complexAtomicRelations</ejb-relationship-role-name>
      . </ejb-relationship-role>
      </ejb-relation>




      I think that I miss something in jbosscmp-jdbc.xml for the second (complexAtomicRelations) <ejb-relationship-role> clause.

      Thank in advance.