0 Replies Latest reply on Nov 23, 2003 11:43 PM by darshkp

    problem with 1 to1 CMR relationship

    darshkp Newbie

      I have a Customer CMP Bean which has a 1 to 1 unidirectional relationship with Address bean. When i try to create a new Customer, when i call setCMRField() method i am getting an exception. JBoss is treating the CMR relationship field a column in the DB and is giving an exception..

      find below the contents of the xml files. I have also pasted the exception below

      ejb-jar.xml

      <?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>
      <enterprise-beans>

      <display-name>CustomerCMPBean</display-name>
      <ejb-name>CustomerCMPBean</ejb-name>
      titan.CustomerCMPRemoteHome
      titan.CustomerCMPRemote
      <ejb-class>titan.CustomerCMPBean</ejb-class>
      <persistence-type>Container</persistence-type>
      <prim-key-class>java.lang.Integer</prim-key-class>
      False
      <cmp-version>2.x</cmp-version>
      <abstract-schema-name>CustomerCMPBean</abstract-schema-name>
      <cmp-field>
      <field-name>id</field-name>
      </cmp-field>
      <cmp-field>
      <field-name>lastName</field-name>
      </cmp-field>
      <cmp-field>
      <field-name>firstName</field-name>
      </cmp-field>
      <cmp-field>
      <field-name>hasGoodCredit</field-name>
      </cmp-field>
      <primkey-field>id</primkey-field>
      <resource-ref>

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


      <display-name>AddressCMPBean</display-name>
      <ejb-name>AddressCMPBean</ejb-name>
      <local-home>titan.AddressCMPHome</local-home>
      titan.AddressCMP
      <ejb-class>titan.AddressCMPBean</ejb-class>
      <persistence-type>Container</persistence-type>
      <prim-key-class>java.lang.Integer</prim-key-class>
      False
      <cmp-version>2.x</cmp-version>
      <abstract-schema-name>AddressCMPBean</abstract-schema-name>
      <cmp-field>
      <field-name>id</field-name>
      </cmp-field>
      <cmp-field>
      <field-name>street</field-name>
      </cmp-field>
      <cmp-field>
      <field-name>city</field-name>
      </cmp-field>
      <cmp-field>
      <field-name>state</field-name>
      </cmp-field>
      <cmp-field>
      <field-name>zip</field-name>
      </cmp-field>
      <primkey-field>id</primkey-field>
      <resource-ref>

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

      </enterprise-beans>

      <ejb-relation>
      <ejb-relation-name>customerCMPBean-addressCMPBean</ejb-relation-name>
      <ejb-relationship-role>
      customerCMPBean
      <ejb-relationship-role-name>CustomerCMPBeanRelationshipRole</ejb-relationship-role-name>
      One
      <relationship-role-source>
      customerCMPBean
      <ejb-name>CustomerCMPBean</ejb-name>
      </relationship-role-source>
      <cmr-field>
      addressCMPBean
      <cmr-field-name>homeAddress</cmr-field-name>
      </cmr-field>
      </ejb-relationship-role>
      <ejb-relationship-role>
      addressCMPBean
      <ejb-relationship-role-name>AddressCMPBeanRelationshipRole</ejb-relationship-role-name>
      One
      <relationship-role-source>
      addressCMPBean
      <ejb-name>AddressCMPBean</ejb-name>
      </relationship-role-source>
      </ejb-relationship-role>
      </ejb-relation>

      <assembly-descriptor>
      <container-transaction>

      <ejb-name>CustomerCMPBean</ejb-name>
      <method-name>*</method-name>

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

      <ejb-name>AddressCMPBean</ejb-name>
      <method-name>*</method-name>

      <trans-attribute>Required</trans-attribute>
      </container-transaction>
      </assembly-descriptor>
      </ejb-jar>

      --------------------------------------------------------
      jbosscmp-jdbc.xml


      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE jbosscmp-jdbc PUBLIC "-//JBoss//DTD JBOSSCMP-JDBC 3.0//EN" "http://www.jboss.org/j2ee/dtd/jbosscmp-jdbc_3_0.dtd">
      <jbosscmp-jdbc>
      <enterprise-beans>

      <ejb-name>CustomerCMPBean</ejb-name>
      java:/TitanDS
      <datasource-mapping>MS SQLSERVER2000</datasource-mapping>
      <create-table>false</create-table>
      <read-ahead>
      on-load
      <page-size>100</page-size>
      </read-ahead>
      <table-name>CUSTOMER</table-name>
      <cmp-field>
      <field-name>id</field-name>
      <column-name>ID</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>lastName</field-name>
      <column-name>LAST_NAME</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>firstName</field-name>
      <column-name>FIRST_NAME</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>hasGoodCredit</field-name>
      <column-name>HAS_GOOD_CREDIT</column-name>
      </cmp-field>


      <ejb-name>AddressCMPBean</ejb-name>
      java:/TitanDS
      <datasource-mapping>MS SQLSERVER2000</datasource-mapping>
      <create-table>false</create-table>
      <read-ahead>
      on-load
      <page-size>100</page-size>
      </read-ahead>
      <table-name>ADDRESS</table-name>
      <cmp-field>
      <field-name>id</field-name>
      <column-name>ID</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>street</field-name>
      <column-name>STREET</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>city</field-name>
      <column-name>CITY</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>state</field-name>
      <column-name>STATE</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>zip</field-name>
      <column-name>ZIP</column-name>
      </cmp-field>

      </enterprise-beans>

      <ejb-relation>
      <ejb-relation-name>customerCMPBean-addressCMPBean</ejb-relation-name>
      <foreign-key-mapping />
      <ejb-relationship-role>
      <ejb-relationship-role-name>CustomerCMPBeanRelationshipRole</ejb-relationship-role-name>
      <read-ahead>
      on-load
      <page-size>100</page-size>
      </read-ahead>
      </ejb-relationship-role>
      <ejb-relationship-role>
      <ejb-relationship-role-name>AddressCMPBeanRelationshipRole</ejb-relationship-role-name>
      <key-fields>
      <key-field>
      <field-name>id</field-name>
      <column-name>ID</column-name>
      </key-field>
      </key-fields>
      <read-ahead>
      on-load
      <page-size>100</page-size>
      </read-ahead>
      </ejb-relationship-role>
      </ejb-relation>

      </jbosscmp-jdbc>


      ---------------------------------------------------------------------



      can anybody help me out on this...

      Thanking You

      java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
      java.rmi.ServerException: EJBException:; nested exception is:
      javax.ejb.EJBException: Load relation failed; CausedByException is:
      [PC16]Invalid column name 'CustomerCMPBean_homeAddress'.
      at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:292)
      at sun.rmi.transport.Transport$1.run(Transport.java:148)
      at java.security.AccessController.doPrivileged(Native Method)
      at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
      at sun.rmi.transport.tcp.TCPTransport.handleMessages(