7 Replies Latest reply on Aug 2, 2002 9:58 AM by Peter

    Relation between two entity bean

    Andrea Newbie

      I try to make a relationship between two Entity Beans.
      When I Try to use ejbSelect method JBoss give me this error:

      SQLFind failed: java.sql.SQLException: ERROR: No such attribute or function 'localprovaseconda'

      The two entity bean and ejb-jar.xml are:

      ============================================================


      <ejb-relation>
      <ejb-relation-name>tblana-tblag</ejb-relation-name>
      <ejb-relationship-role>
      <ejb-relationship-role-name>ana-has-ag</ejb-relationship-role-name>
      One
      <relationship-role-source>
      <ejb-name>test/ProvaSeconda</ejb-name>
      </relationship-role-source>
      <cmr-field>
      <cmr-field-name>anagr</cmr-field-name>
      <cmr-field-type>java.util.Collection</cmr-field-type>
      </cmr-field>
      </ejb-relationship-role>
      <ejb-relationship-role>
      <ejb-relationship-role-name>ag-has-ana</ejb-relationship-role-name>
      Many
      <relationship-role-source>
      <ejb-name>test/ProvaEntity</ejb-name>
      </relationship-role-source>
      <cmr-field>
      <cmr-field-name>localProvaSeconda</cmr-field-name>
      </cmr-field>
      </ejb-relationship-role>
      </ejb-relation>


      =========================================================
      public abstract class ProvaEntityBean
      implements EntityBean
      {

      // -------------------------------------------------------------------------
      // Members
      // -------------------------------------------------------------------------

      public EntityContext mContext;

      // -------------------------------------------------------------------------
      // Methods
      // -------------------------------------------------------------------------

      /**
      * Store the data within the provided data object into this bean.
      *
      * @param pTestEntity The Value Object containing the TestEntity values
      *
      * @ejb:interface-method view-type="local"
      **/
      public void setValueObject( ProvaEntityData pProvaEntity )
      throws
      InvalidValueException
      {
      // Check for Data Integrity in the Value Object
      setIdag( pProvaEntity.getIdag() );
      setZona( pProvaEntity.getZona() );
      setPagamento( pProvaEntity.getPagamento() );
      setBanca( pProvaEntity.getBanca() );
      setAbi( pProvaEntity.getAbi() );
      setCab( pProvaEntity.getCab() );
      }

      /**
      * Create and return a TestEntity data object populated with the data from
      * this bean.
      *
      * @return Returns a TestEntity value object containing the data within this
      * bean.
      *
      * @ejb:interface-method view-type="local"
      **/

      public ProvaEntityData getValueObject() {
      ProvaEntityData lData = new ProvaEntityData();

      lData.setIdag( getIdag() );
      lData.setZona( getZona() );
      lData.setPagamento( getPagamento() );
      lData.setBanca( getBanca() );
      lData.setAbi( getAbi() );
      lData.setCab( getCab() );

      return lData;
      }


      // -------------------------------------------------------------------------
      // Properties (Getters/Setters)
      // -------------------------------------------------------------------------




      public abstract void setLocalProvaSeconda(LocalProvaSeconda prova);



      public abstract LocalProvaSeconda getLocalProvaSeconda();

      ==========================================================

      public abstract class ProvaSecondaBean
      implements EntityBean
      {

      // -------------------------------------------------------------------------
      // Members
      // -------------------------------------------------------------------------

      public EntityContext mContext;

      // -------------------------------------------------------------------------
      // Methods
      // -------------------------------------------------------------------------

      /**
      * Store the data within the provided data object into this bean.
      *
      * @param pTestEntity The Value Object containing the TestEntity values
      *
      * @ejb:interface-method view-type="remote"
      **/
      public void setValueObject1( ProvaSecondaData pProvaSeconda )
      throws
      InvalidValueException
      {
      // Check for Data Integrity in the Value Object
      setIdana( pProvaSeconda.getIdana() );
      setSurname( pProvaSeconda.getSurname() );
      setName( pProvaSeconda.getName() );
      setAnades( pProvaSeconda.getAnades() );
      setAddress( pProvaSeconda.getAddress() );
      setZip( pProvaSeconda.getZip() );
      setCity( pProvaSeconda.getCity() );
      setProv( pProvaSeconda.getProv() );
      setCountry( pProvaSeconda.getCountry() );
      setTipo( pProvaSeconda.getTipo() );
      setCodfi( pProvaSeconda.getCodfi() );
      setPariva( pProvaSeconda.getPariva() );
      setTel1( pProvaSeconda.getTel1() );
      setTel2( pProvaSeconda.getTel2() );
      setTelfax( pProvaSeconda.getTelfax() );
      setEmail( pProvaSeconda.getEmail() );
      setWeb( pProvaSeconda.getWeb() );
      setIshuman( pProvaSeconda.getIshuman() );







      }

      /**
      * Create and return a TestEntity data object populated with the data from
      * this bean.
      *
      * @return Returns a TestEntity value object containing the data within this
      * bean.
      *
      * @ejb:interface-method view-type="remote"
      **/

      public ProvaSecondaData getValueObject1() {
      ProvaSecondaData lData = new ProvaSecondaData();

      lData.setIdana( getIdana() );
      lData.setSurname( getSurname() );
      lData.setName( getName() );
      lData.setAnades( getAnades() );
      lData.setAddress( getAddress() );
      lData.setZip( getZip() );
      lData.setCity( getCity() );
      lData.setProv( getProv() );
      lData.setCountry( getCountry() );
      lData.setTipo( getTipo() );
      lData.setCodfi( getCodfi() );
      lData.setPariva( getPariva() );
      lData.setTel1( getTel1() );
      lData.setTel2( getTel2() );
      lData.setTelfax( getTelfax() );
      lData.setEmail( getEmail() );
      lData.setWeb( getWeb() );
      lData.setIshuman( getIshuman() );

      return lData;
      }




      // -------------------------------------------------------------------------
      // Properties (Getters/Setters)
      // -------------------------------------------------------------------------
      public abstract void setAnagr(java.util.Collection anagrs);



      public abstract Collection getAnagr();


      public abstract Collection ejbSelectAnagr(test.interfaces.LocalProvaSeconda provaseconda)
      throws FinderException;


      /**
      * Create and return a TestEntity data object populated with the data from
      * this bean.
      *
      * @return Returns a TestEntity value object containing the data within this
      * bean.
      *
      * @ejb:interface-method view-type="local"
      **/
      public java.util.Collection getAgenteSelezionato() throws FinderException{

      LocalProvaSeconda provaseconda = (test.interfaces.LocalProvaSeconda)mContext.getEJBLocalObject();
      System.out.println(provaseconda);



      return ejbSelectAnagr(provaseconda);

      }


      Thanks
      Greatings
      Andrea