2 Replies Latest reply on Jan 10, 2002 11:29 AM by Maurizio Giunti

    CMP 2 Relations and JBoss

    Maurizio Giunti Newbie

      Hi,

      I am trying to implement a simple One to Many relation using Jboss 3.0 Alpha and a tool named EjbGen (http://www.beust.com/cedric/ejbgen/) which speeds up EJB creation and maintanance.
      I can create the correct sources (Beans, Local interfaces, ejb-jar.xml), compile and delpoy, but when I try to use the relation I get an exception like the following:

      Column not found: UTENTEEJB_ACCESSI_NAME in statement [SELECT numero FROM AccessoEJB WHERE UtenteEJB_accessi_name='giunti']; nested exception is:
      javax.ejb.EJBException: FindByForeignKey failed

      I am not a CMP 2.0 guru, but it seems that JBoss assume the existence of a the field UtenteEJB_accessi_home in the table Accessi, but it does not really create it (both Accesso and Utente are CMP 2.0 Entity Beans).

      Here follows a snippet from the ejb-jar.xml which seems correct to me:


      <ejb-relation>
      <ejb-relation-name>Utente-Accesso</ejb-relation-name>
      <ejb-relationship-role>
      <ejb-relationship-role-name>Accessi-di-un-Utente</ejb-relationship-role-name>
      Many
      <relationship-role-source>
      <ejb-name>AccessoEJB</ejb-name>
      </relationship-role-source>
      </ejb-relationship-role>
      <ejb-relationship-role>
      <ejb-relationship-role-name>Utente-ha-Accessi</ejb-relationship-role-name>
      One
      <relationship-role-source>
      <ejb-name>UtenteEJB</ejb-name>
      </relationship-role-source>
      <cmr-field>
      <cmr-field-name>accessi</cmr-field-name>
      <cmr-field-type>java.util.Collection</cmr-field-type>
      </cmr-field>
      </ejb-relationship-role>
      </ejb-relation>



      I can post sources too if you need.
      Can anybody help me?
      Thanks in advance.