0 Replies Latest reply on Nov 27, 2006 11:58 AM by philc

    CMR over different datasources with EJB 2.1

    philc

      Using EJB 2.1, I have 2 CMP Entities persisted on 2 different datasources. Now I want to create a unidirectional many-to-one relationship where the many side sees the one side and the one side is blind. But, I get an EJBException wrapping an SQL error:

      javax.ejb.EJBException: Load relation failed; CausedByException is:
       ORA-00942: table or view does not exist
      

      I suspect from reading the JDBCCMRFieldBridge class that JBoss is using the datasource of one side to access the other side.
      Here is the JDBCCMRFieldBridge code:
       // Data Source
       if(metadata.getRelationMetaData().isTableMappingStyle())
       {
       dataSource = metadata.getRelationMetaData().getDataSource();
       }
       else
       {
       dataSource = hasForeignKey() ? entity.getDataSource() : relatedEntity.getDataSource();
       }
      

      It seems like the choice of datasource is based on having a foreign key or not. How can I define a relationship without foreign keys?

      Using xdoclet I defined the relationships this way, using target-XXXX to define the blind side of the relationship
       * @ejb.relation
       * name="Order-Security"
       * role-name="many-Orders-belong-to-one-Security"
       * target-role-name="one-Security-has-multiple-Orders"
       * target-ejb="Security"
       * target-multiple="yes"
       *
       * @jboss.relation
       * fk-constaint="false"
       * fk-column="SECURITY_ID"
       * related-pk-field="securityId"
      


      First of all, is CMR over different datasources supported in EJB 2.1? If not, does JBoss offer a work around?

      PS: Both entity beans work stand alone. I can execute create and finder method on them. I'm using JBoss 4.0.3SP1.