3 Replies Latest reply on Jul 19, 2002 12:24 PM by andrea74m

    Relationship between two Entity Beans

    andrea74m

      I try to make a Select between two Entity Beans.
      When I try to use the method that contain la select Jboss gives this error:
      SQLFind failed: java.sql.SQLException: ERROR: No such attribute or function 'test'


      The Entity Beans e ejb-jar are:


      /*
      * ngWEPS, Web Enabled Printing Solution
      *
      * Include here a link o the entire
      * copyright notice
      *
      * $CVSHeader: ngWEPS/src/main/ejb/test/entity/ProvaEntityBean.java,v 1.1.1.1 2002/06/03 15:51:40 massimo Exp $.
      */
      package test.entity;

      import test.interfaces.InvalidValueException;
      import test.interfaces.*;
      import test.interfaces.ProvaSecondaData;
      import test.interfaces.ProvaSecondaPK;




      import test.interfaces.ServiceUnavailableException;
      // Only necessary because of a limitation by the EJBDoclet


      import java.sql.Date;
      import java.rmi.RemoteException;
      import java.util.Collection;
      import java.util.Iterator;

      import javax.ejb.CreateException;
      import javax.ejb.EJBException;
      import javax.ejb.EntityBean;
      import javax.ejb.EntityContext;
      import javax.ejb.FinderException;
      import javax.ejb.RemoveException;
      import javax.naming.Context;
      import javax.naming.InitialContext;
      import javax.naming.NamingException;
      import javax.rmi.PortableRemoteObject;

      /**
      * The Entity bean represents a TestEntity
      *
      *
      * @author $Author: Andrea $
      * @version $Revision: 1.1.1.1 $
      *
      * @ejb:bean
      * name="test/ProvaSeconda"
      * display-name="Entity Bean che lavora sulla tabella tblana"
      * type="CMP"
      * jndi-name="ejb/test/ProvaSeconda"
      *
      * schema="Prova1"
      * @ejb:relation
      * name="tblana-tblag"
      * role-name"ana-has-ag"
      * target-ejb="test/ProvaEntity"
      * target-role-name="ag-has-ana"
      *
      * @ejb:select
      * signature="java.util.Collection ejbSelectAgenti ( test.interfaces.ProvaSeconda provaseconda )"
      * query="SELECT OBJECT(o) FROM Prova1 AS o, IN (o.agente) AS l WHERE l.zona='Modena'"
      *
      *
      * @ejb:transaction
      * type="Required"
      *
      * @jboss:table-name
      * table-name="tblana"
      *
      * @jboss:create-table
      * create="false"
      *
      * @jboss:remove-table
      * remove="false"
      *
      * @ejb:resource-ref
      * res-name="PostgresDS"
      * res-type="javax.sql.DataSource"
      * res-auth="Container"
      *
      **/
      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="local"
      **/
      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="local"
      **/

      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 Collection ejbSelectAgenti(ProvaSeconda 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="remote"
      **/
      public Collection getAgenteSelezionato() throws FinderException{

      test.interfaces.ProvaSeconda provaseconda =
      (test.interfaces.ProvaSeconda)mContext.getEJBObject();
      System.out.println(provaseconda);

      return ejbSelectAgenti(provaseconda);


      }

      public abstract void setAgente(Collection agente);
      public abstract Collection getAgente();


      /**
      * Retrieve the TestEntity's id.
      *
      * @return Returns an int representing the id of this TestEntity.
      *
      * @ejb:persistent-field
      * @ejb:pk-field
      *
      * @jboss:column-name name="Idana"
      **/
      public abstract String getIdana();

      /**
      * Set the TestEntity's id.
      *
      * @param pId The id of this TestEntity. Is set at creation time.
      **/
      public abstract void setIdana( String pIdana );

      /**
      * Retrieve the TestEntity's FirstName.
      *
      * @return Returns an int representing the FirstName of this TestEntity.
      *
      * @ejb:persistent-field
      *
      * @jboss:column-name name="Surname"
      **/
      public abstract String getSurname();

      /**
      * Set the TestEntity's FirstName.
      *
      * @param pFirstName The FirstName of this TestEntity. Is set at creation time.
      **/
      public abstract void setSurname( String pSurname );
      /**
      * Retrieve the TestEntity's FirstName.
      *
      * @return Returns an int representing the FirstName of this TestEntity.
      *
      * @ejb:persistent-field
      *
      * @jboss:column-name name="Name"
      **/
      public abstract String getName();

      /**
      * Set the TestEntity's FirstName.
      *
      * @param pFirstName The FirstName of this TestEntity. Is set at creation time.
      **/
      public abstract void setName( String pName );

      /**
      * Retrieve the TestEntity's LastName.
      *
      * @return Returns an int representing the LastName of this TestEntity.
      *
      * @ejb:persistent-field
      *
      * @jboss:column-name name="Anades"
      **/
      public abstract String getAnades();

      /**
      * Set the TestEntity's LastName.
      *
      * @param pLastName The LastName of this TestEntity. Is set at creation time.
      **/
      public abstract void setAnades( String pAnades );

      /**
      * Retrieve the TestEntity's Password.
      *
      * @return Returns an int representing the Password of this TestEntity.
      *
      * @ejb:persistent-field
      *
      * @jboss:column-name name="Address"
      **/
      public abstract String getAddress();

      /**
      * Set the TestEntity's Password.
      *
      * @param pPassword The Password of this TestEntity
      **/
      public abstract void setAddress( String pAddress );

      /**
      * Retrieve the TestEntity's Email.
      *
      * @return Returns an int representing the Email of this TestEntity.
      *
      * @ejb:persistent-field
      *
      * @jboss:column-name name="Zip"
      **/
      public abstract String getZip();

      /**
      * Set the TestEntity's Email.
      *
      * @param pEmail The Email of this TestEntity. Is set at creation time.
      **/
      public abstract void setZip( String pZip );

      /**
      * @return Returns the Address of this TestEntity
      *
      * @ejb:persistent-field
      *
      * @jboss:column-name name="City"
      **/
      public abstract String getCity();

      /**
      * Specify the Address of this TestEntity
      *
      * @param pAddress Address of this TestEntity
      **/
      public abstract void setCity( String pCity );
      /**
      * Retrieve the TestEntity's Email.
      *
      * @return Returns an int representing the Email of this TestEntity.
      *
      * @ejb:persistent-field
      *
      * @jboss:column-name name="Prov"
      **/
      public abstract String getProv();

      /**
      * Set the TestEntity's Email.
      *
      * @param pEmail The Email of this TestEntity. Is set at creation time.
      **/
      public abstract void setProv( String pProv );

      /**
      * @return Returns the Address of this TestEntity
      *
      * @ejb:persistent-field
      *
      * @jboss:column-name name="Country"
      **/
      public abstract String getCountry();

      /**
      * Specify the Address of this TestEntity
      *
      * @param pAddress Address of this TestEntity
      **/
      public abstract void setCountry( String pCountry );

      /**
      * Retrieve the TestEntity's Email.
      *
      * @return Returns an int representing the Email of this TestEntity.
      *
      * @ejb:persistent-field
      *
      * @jboss:column-name name="Tipo"
      **/
      public abstract String getTipo();

      /**
      * Set the TestEntity's Email.
      *
      * @param pEmail The Email of this TestEntity. Is set at creation time.
      **/
      public abstract void setTipo( String pTipo );

      /**
      * @return Returns the Address of this TestEntity
      *
      * @ejb:persistent-field
      *
      * @jboss:column-name name="Codfi"
      **/
      public abstract String getCodfi();

      /**
      * Specify the Address of this TestEntity
      *
      * @param pAddress Address of this TestEntity
      **/
      public abstract void setCodfi( String pCodfi );



      /**
      * Retrieve the TestEntity's Email.
      *
      * @return Returns an int representing the Email of this TestEntity.
      *
      * @ejb:persistent-field
      *
      * @jboss:column-name name="Pariva"
      **/
      public abstract String getPariva();

      /**
      * Set the TestEntity's Email.
      *
      * @param pEmail The Email of this TestEntity. Is set at creation time.
      **/
      public abstract void setPariva( String pPariva );

      /**
      * @return Returns the Address of this TestEntity
      *
      * @ejb:persistent-field
      *
      * @jboss:column-name name="Tel1"
      **/
      public abstract String getTel1();

      /**
      * Specify the Address of this TestEntity
      *
      * @param pAddress Address of this TestEntity
      **/
      public abstract void setTel1( String pTel1 );
      /**
      * @return Returns the Address of this TestEntity
      *
      * @ejb:persistent-field
      *
      * @jboss:column-name name="Tel2"
      **/
      public abstract String getTel2();

      /**
      * Specify the Address of this TestEntity
      *
      * @param pAddress Address of this TestEntity
      **/
      public abstract void setTel2( String pTel2 );


      /**
      * Retrieve the TestEntity's Email.
      *
      * @return Returns an int representing the Email of this TestEntity.
      *
      * @ejb:persistent-field
      *
      * @jboss:column-name name="Telfax"
      **/
      public abstract String getTelfax();

      /**
      * Set the TestEntity's Email.
      *
      * @param pEmail The Email of this TestEntity. Is set at creation time.
      **/
      public abstract void setTelfax( String pTelfax );

      /**
      * @return Returns the Address of this TestEntity
      *
      * @ejb:persistent-field
      *
      * @jboss:column-name name="Email"
      **/
      public abstract String getEmail();

      /**
      * Specify the Address of this TestEntity
      *
      * @param pAddress Address of this TestEntity
      **/
      public abstract void setEmail( String pEmail );
      /**
      * Retrieve the TestEntity's Email.
      *
      * @return Returns an int representing the Email of this TestEntity.
      *
      * @ejb:persistent-field
      *
      * @jboss:column-name name="Web"
      **/
      public abstract String getWeb();

      /**
      * Set the TestEntity's Email.
      *
      * @param pEmail The Email of this TestEntity. Is set at creation time.
      **/
      public abstract void setWeb( String pWeb );

      /**
      * @return Returns the Address of this TestEntity
      *
      * @ejb:persistent-field
      *
      * @jboss:column-name name="Ishuman"
      **/
      public abstract Boolean getIshuman();

      /**
      * Specify the Address of this TestEntity
      *
      * @param pAddress Address of this TestEntity
      **/
      public abstract void setIshuman( Boolean pIshuman);

      // -------------------------------------------------------------------------
      // Framework Callbacks
      // -------------------------------------------------------------------------

      /**
      * Create a TestEntity based on the supplied TestEntity Value Object.
      *
      * @param pTestEntity The data used to create the TestEntity.
      *
      * @throws InvalidValueException If one of the values are not correct,
      * this will not roll back the transaction
      * because the caller has the chance to
      * fix the problem and try again
      * @throws EJBException If no new unique ID could be retrieved this will
      * rollback the transaction because there is no
      * hope to try again
      * @throws CreateException Because we have to do so (EJB spec.)
      *
      * @ejb:create-method view-type="remote"
      **/

      public ProvaSecondaPK ejbCreate( String pIdana,String pSurname,String pName,String pAnades,
      String pAddress, String pZip,String pCity,String pProv,String pCountry,String pTipo,
      String pCodfi, String pPariva,String pTel1,String pTel2,String pTelfax,String pEmail,
      String pWeb, Boolean pIshuman)
      throws
      InvalidValueException,
      EJBException,
      CreateException
      {

      setIdana(pIdana);
      setSurname(pSurname);
      setName(pName);
      setAnades(pAnades);
      setAddress(pAddress);
      setZip(pZip);
      setCity(pCity);
      setProv(pProv);
      setCountry(pCountry);
      setTipo(pTipo);
      setCodfi(pCodfi);
      setPariva(pPariva);
      setTel1(pTel1);
      setTel2(pTel2);
      setTelfax(pTelfax);
      setEmail(pEmail);
      setWeb(pWeb);
      setIshuman(pIshuman);


      return null;
      }

      public void ejbPostCreate( String pIdana,String pSurname,String pName,String pAnades,
      String pAddress, String pZip,String pCity,String pProv,String pCountry,String pTipo,
      String pCodfi, String pPariva,String pTel1,String pTel2,String pTelfax,String pEmail,
      String pWeb, Boolean pIshuman)
      {
      }

      public void setEntityContext( EntityContext lContext )
      {
      mContext = lContext;
      }

      public void unsetEntityContext()
      {
      mContext = null;
      }

      public void ejbActivate()
      {
      }

      public void ejbPassivate()
      {
      }

      public void ejbLoad()
      {
      }

      public void ejbStore()
      {
      }

      public void ejbRemove()
      throws
      RemoveException
      {
      }
      }



      LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL




      /*
      * ngWEPS, Web Enabled Printing Solution
      *
      * Include here a link o the entire
      * copyright notice
      *
      * $CVSHeader: ngWEPS/src/main/ejb/test/entity/ProvaEntityBean.java,v 1.1.1.1 2002/06/03 15:51:40 massimo Exp $.
      */
      package test.entity;

      import test.interfaces.InvalidValueException;
      import test.interfaces.ProvaEntityData;
      import test.interfaces.ProvaEntityPK;



      import test.interfaces.ServiceUnavailableException;
      // Only necessary because of a limitation by the EJBDoclet
      import test.interfaces.ProvaSessionEntity;
      import test.interfaces.ProvaSessionEntityHome;

      import java.sql.Date;
      import java.rmi.RemoteException;
      import java.util.Collection;
      import java.util.Iterator;

      import javax.ejb.CreateException;
      import javax.ejb.EJBException;
      import javax.ejb.EntityBean;
      import javax.ejb.EntityContext;
      import javax.ejb.FinderException;
      import javax.ejb.RemoveException;
      import javax.naming.Context;
      import javax.naming.InitialContext;
      import javax.naming.NamingException;
      import javax.rmi.PortableRemoteObject;

      /**
      * The Entity bean represents a TestEntity
      *
      * @author Andreas Schaefer
      * @author $Author: massimo $
      * @version $Revision: 1.1.1.1 $
      *
      * @ejb:bean
      * name="test/ProvaEntity"
      * display-name="Entity Bean che lavora sulla tabella tblag"
      * type="CMP"
      * jndi-name="ejb/test/ProvaEntity"
      *
      *
      * schema="Prova"
      * @ejb:transaction
      * type="Required"
      * @ejb:finder
      * signature="test.interfaces.ProvaEntity findAll()"
      *
      * @ejb:finder
      * signature="java.util.Collection findByZona( java.lang.String pZone)"
      *
      * @jboss:finder-query
      * name="findByZona"
      * query="Zona = {0}"
      *
      * @jboss:table-name
      * table-name="tblag"
      *
      * @jboss:create-table
      * create="false"
      *
      * @jboss:remove-table
      * remove="false"
      *
      * @ejb:resource-ref
      * res-name="PostgresDS"
      * res-type="javax.sql.DataSource"
      * res-auth="Container"
      *
      **/
      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)
      // -------------------------------------------------------------------------



      /**
      * Retrieve the TestEntity's id.
      *
      * @return Returns an int representing the id of this TestEntity.
      *
      * @ejb:persistent-field
      * @ejb:pk-field
      *
      * @jboss:column-name name="Idag"
      **/
      public abstract String getIdag();

      /**
      * Set the TestEntity's id.
      *
      * @param pId The id of this TestEntity. Is set at creation time.
      **/
      public abstract void setIdag( String pIdag );

      /**
      * Retrieve the TestEntity's FirstName.
      *
      * @return Returns an int representing the FirstName of this TestEntity.
      *
      * @ejb:persistent-field
      *
      * @jboss:column-name name="Zona"
      **/
      public abstract String getZona();

      /**
      * Set the TestEntity's FirstName.
      *
      * @param pFirstName The FirstName of this TestEntity. Is set at creation time.
      **/
      public abstract void setZona( String pZona );

      /**
      * Retrieve the TestEntity's LastName.
      *
      * @return Returns an int representing the LastName of this TestEntity.
      *
      * @ejb:persistent-field
      *
      * @jboss:column-name name="Pagamento"
      **/
      public abstract String getPagamento();

      /**
      * Set the TestEntity's LastName.
      *
      * @param pLastName The LastName of this TestEntity. Is set at creation time.
      **/
      public abstract void setPagamento( String pPagamento );

      /**
      * Retrieve the TestEntity's Password.
      *
      * @return Returns an int representing the Password of this TestEntity.
      *
      * @ejb:persistent-field
      *
      * @jboss:column-name name="Banca"
      **/
      public abstract String getBanca();

      /**
      * Set the TestEntity's Password.
      *
      * @param pPassword The Password of this TestEntity
      **/
      public abstract void setBanca( String pBanca );

      /**
      * Retrieve the TestEntity's Email.
      *
      * @return Returns an int representing the Email of this TestEntity.
      *
      * @ejb:persistent-field
      *
      * @jboss:column-name name="Abi"
      **/
      public abstract String getAbi();

      /**
      * Set the TestEntity's Email.
      *
      * @param pEmail The Email of this TestEntity. Is set at creation time.
      **/
      public abstract void setAbi( String pAbi );

      /**
      * @return Returns the Address of this TestEntity
      *
      * @ejb:persistent-field
      *
      * @jboss:column-name name="Cab"
      **/
      public abstract String getCab();

      /**
      * Specify the Address of this TestEntity
      *
      * @param pAddress Address of this TestEntity
      **/
      public abstract void setCab( String pCab );





      // -------------------------------------------------------------------------
      // Framework Callbacks
      // -------------------------------------------------------------------------

      /**
      * Create a TestEntity based on the supplied TestEntity Value Object.
      *
      * @param pTestEntity The data used to create the TestEntity.
      *
      * @throws InvalidValueException If one of the values are not correct,
      * this will not roll back the transaction
      * because the caller has the chance to
      * fix the problem and try again
      * @throws EJBException If no new unique ID could be retrieved this will
      * rollback the transaction because there is no
      * hope to try again
      * @throws CreateException Because we have to do so (EJB spec.)
      *
      * @ejb:create-method view-type="remote"
      **/

      public ProvaEntityPK ejbCreate( String pIdag,String pZona,String pPagamento,String pBanca,
      String pAbi, String pCab)
      throws
      InvalidValueException,
      EJBException,
      CreateException
      {

      setIdag(pIdag);
      setZona(pZona);
      setPagamento(pPagamento);
      setBanca(pBanca);
      setAbi(pAbi);
      setCab(pCab);

      return null;
      }

      public void ejbPostCreate(String pIdag,String pZona,String pPagamento,String pBanca,
      String pAbi, String pCab)
      {
      }

      public void setEntityContext( EntityContext lContext )
      {
      mContext = lContext;
      }

      public void unsetEntityContext()
      {
      mContext = null;
      }

      public void ejbActivate()
      {
      }

      public void ejbPassivate()
      {
      }

      public void ejbLoad()
      {
      }

      public void ejbStore()
      {
      }

      public void ejbRemove()
      throws
      RemoveException
      {
      }
      }

      LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL

      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd">

      <ejb-jar >

      No Description.
      <display-name>Generated by XDoclet</display-name>

      <enterprise-beans>

      <!-- Session Beans -->

      <![CDATA[Session Bean Template ATTENTION: Some of the XDoclet tags are hidden from XDoclet by adding a "--" between @ and the namespace.]]>
      <display-name>Bug ProvaSession Bean</display-name>

      <ejb-name>test/ProvaSession</ejb-name>

      test.interfaces.ProvaSessionHome
      test.interfaces.ProvaSession
      <ejb-class>test.session.ProvaSessionBean</ejb-class>
      <session-type>Stateless</session-type>
      <transaction-type>Container</transaction-type>

      <resource-ref>
      <res-ref-name>test/Mail</res-ref-name>
      <res-type>javax.mail.Session</res-type>
      <res-auth>Container</res-auth>
      </resource-ref>




      <![CDATA[Session Bean Template ATTENTION: Some of the XDoclet tags are hidden from XDoclet by adding a "--" between @ and the namespace.]]>
      <display-name>Bug ProvaSessionEntity Bean</display-name>

      <ejb-name>test/ProvaSessionEntity</ejb-name>

      test.interfaces.ProvaSessionEntityHome
      test.interfaces.ProvaSessionEntity
      <ejb-class>test.session.ProvaSessionEntityBean</ejb-class>
      <session-type>Stateless</session-type>
      <transaction-type>Container</transaction-type>

      <ejb-ref >
      <ejb-ref-name>ejb/test/ProvaSeconda</ejb-ref-name>
      <ejb-ref-type>Entity</ejb-ref-type>
      test.interfaces.ProvaSecondaHome
      test.interfaces.ProvaSeconda
      <ejb-link>test/ProvaSeconda</ejb-link>
      </ejb-ref>

      <resource-ref>
      <res-ref-name>test/Mail</res-ref-name>
      <res-type>javax.mail.Session</res-type>
      <res-auth>Container</res-auth>
      </resource-ref>



      <!--
      To add session beans that you have deployment descriptor info for, add
      a file to your merge directory called session-beans.xml that contains
      the markup for those beans.
      -->

      <!-- Entity Beans -->

      <![CDATA[The Entity bean represents a TestEntity]]>
      <display-name>Entity Bean che lavora sulla tabella tblag</display-name>

      <ejb-name>test/ProvaEntity</ejb-name>

      test.interfaces.ProvaEntityHome
      test.interfaces.ProvaEntity

      <ejb-class>test.entity.ProvaEntityCMP</ejb-class>
      <persistence-type>Container</persistence-type>
      <prim-key-class>test.interfaces.ProvaEntityPK</prim-key-class>
      False
      <cmp-version>2.x</cmp-version>
      <abstract-schema-name>Prova</abstract-schema-name>
      <cmp-field >
      <![CDATA[Retrieve the TestEntity's id.]]>
      <field-name>idag</field-name>
      </cmp-field>
      <cmp-field >
      <![CDATA[Retrieve the TestEntity's FirstName.]]>
      <field-name>zona</field-name>
      </cmp-field>
      <cmp-field >
      <![CDATA[Retrieve the TestEntity's LastName.]]>
      <field-name>pagamento</field-name>
      </cmp-field>
      <cmp-field >
      <![CDATA[Retrieve the TestEntity's Password.]]>
      <field-name>banca</field-name>
      </cmp-field>
      <cmp-field >
      <![CDATA[Retrieve the TestEntity's Email.]]>
      <field-name>abi</field-name>
      </cmp-field>
      <cmp-field >
      <![CDATA[]]>
      <field-name>cab</field-name>
      </cmp-field>

      <resource-ref>
      <res-ref-name>PostgresDS</res-ref-name>
      <res-type>javax.sql.DataSource</res-type>
      <res-auth>Container</res-auth>
      </resource-ref>




      <![CDATA[The Entity bean represents a TestEntity]]>
      <display-name>Entity Bean che lavora sulla tabella tblana</display-name>

      <ejb-name>test/ProvaSeconda</ejb-name>

      test.interfaces.ProvaSecondaHome
      test.interfaces.ProvaSeconda

      <ejb-class>test.entity.ProvaSecondaCMP</ejb-class>
      <persistence-type>Container</persistence-type>
      <prim-key-class>test.interfaces.ProvaSecondaPK</prim-key-class>
      False
      <cmp-version>2.x</cmp-version>
      <abstract-schema-name>Prova1</abstract-schema-name>
      <cmp-field >
      <![CDATA[Retrieve the TestEntity's id.]]>
      <field-name>idana</field-name>
      </cmp-field>
      <cmp-field >
      <![CDATA[Retrieve the TestEntity's FirstName.]]>
      <field-name>surname</field-name>
      </cmp-field>
      <cmp-field >
      <![CDATA[Retrieve the TestEntity's FirstName.]]>
      <field-name>name</field-name>
      </cmp-field>
      <cmp-field >
      <![CDATA[Retrieve the TestEntity's LastName.]]>
      <field-name>anades</field-name>
      </cmp-field>
      <cmp-field >
      <![CDATA[Retrieve the TestEntity's Password.]]>
      <field-name>address</field-name>
      </cmp-field>
      <cmp-field >
      <![CDATA[Retrieve the TestEntity's Email.]]>
      <field-name>zip</field-name>
      </cmp-field>
      <cmp-field >
      <![CDATA[]]>
      <field-name>city</field-name>
      </cmp-field>
      <cmp-field >
      <![CDATA[Retrieve the TestEntity's Email.]]>
      <field-name>prov</field-name>
      </cmp-field>
      <cmp-field >
      <![CDATA[]]>
      <field-name>country</field-name>
      </cmp-field>
      <cmp-field >
      <![CDATA[Retrieve the TestEntity's Email.]]>
      <field-name>tipo</field-name>
      </cmp-field>
      <cmp-field >
      <![CDATA[]]>
      <field-name>codfi</field-name>
      </cmp-field>
      <cmp-field >
      <![CDATA[Retrieve the TestEntity's Email.]]>
      <field-name>pariva</field-name>
      </cmp-field>
      <cmp-field >
      <![CDATA[]]>
      <field-name>tel1</field-name>
      </cmp-field>
      <cmp-field >
      <![CDATA[]]>
      <field-name>tel2</field-name>
      </cmp-field>
      <cmp-field >
      <![CDATA[Retrieve the TestEntity's Email.]]>
      <field-name>telfax</field-name>
      </cmp-field>
      <cmp-field >
      <![CDATA[]]>
      <field-name>email</field-name>
      </cmp-field>
      <cmp-field >
      <![CDATA[Retrieve the TestEntity's Email.]]>
      <field-name>web</field-name>
      </cmp-field>
      <cmp-field >
      <![CDATA[]]>
      <field-name>ishuman</field-name>
      </cmp-field>

      <resource-ref>
      <res-ref-name>PostgresDS</res-ref-name>
      <res-type>javax.sql.DataSource</res-type>
      <res-auth>Container</res-auth>
      </resource-ref>


      <query-method>
      <method-name>ejbSelectAgenti</method-name>
      <method-params>
      <method-param>test.interfaces.ProvaSeconda</method-param>
      </method-params>
      </query-method>
      <ejb-ql><![CDATA[SELECT OBJECT(o) FROM Prova1 AS o, IN (o.agente) AS l WHERE l.zona='Modena']]></ejb-ql>




      <!--
      To add entity beans that you have deployment descriptor info for, add
      a file to your merge directory called entity-beans.xml that contains
      the markup for those beans.
      -->

      <!-- Message Driven Beans -->
      <!--
      To add message driven beans that you have deployment descriptor info for, add
      a file to your merge directory called message-driven-beans.xml that contains
      the <message-driven></message-driven> markup for those beans.
      -->

      </enterprise-beans>

      <!-- Relationships -->


      <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>agente</cmr-field-name>

      </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>


      </ejb-relationship-role>

      </ejb-relation>


      <!-- Assembly Descriptor -->
      <assembly-descriptor >

      <!-- finder permissions -->

      <!-- finder permissions -->

      <!-- finder permissions -->

      <!-- finder permissions -->

      <!-- transactions -->
      <container-transaction >

      <ejb-name>test/ProvaEntity</ejb-name>
      <method-name>*</method-name>

      <trans-attribute>Required</trans-attribute>
      </container-transaction>
      <container-transaction >

      <ejb-name>test/ProvaSeconda</ejb-name>
      <method-name>*</method-name>

      <trans-attribute>Required</trans-attribute>
      </container-transaction>

      <!-- finder transactions -->
      </assembly-descriptor>

      </ejb-jar>




      THANKS
      GREATINGS
      Andrea

        • 1. Re: Relationship between two Entity Beans
          benw

          Andrea,

          It looks like it is an error with the SQL being generated by JBoss CMP, which means there is something wrong with your deployment descriptors. If you haven't done so, try setting JBoss (or the CMP engine) to log in DEBUG mode. You can then see the SQL that is actually being sent to database server. This should help you figure out what's the problem is.

          Ben

          • 2. Re: Relationship between two Entity Beans
            andrea74m

            Thank-you Ben.
            Greatings
            Andrea

            • 3. Re: Relationship between two Entity Beans
              andrea74m

              I undermark the part of entity bean where the ejbSelect is invoked.
              Do you think is ok?

              public Collection getAgenteSelezionato() throws FinderException{

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

              Collection c = ejbSelectAgenti(provaseconda);


              return c;

              }


              Greatings
              Thanks
              Andrea