5 Replies Latest reply on May 22, 2004 7:55 AM by ironbird

    Problem with One to One Unidirectional Relationship

    darpan Newbie

      Environment
      JDK 1.4.2, JBoss 3.2.3, MySQL

      Problem
      Unable to implement a One-to-One Unidirectional Relationship using CMP Entity Beans

      Error Stacktrace
      The EJB container is expecting a userDetails column in the UserLogin table which is not present. The UserLogin CMP EJB class contains a getUserDetails() and setUserDetails() method which is supposed to return a LocalInterface to the UserDetails CMP Entity bean. However, the following stacktrace is displayed

      09:56:41,066 ERROR [LogInterceptor] TransactionRolledbackLocalException in method: public abstract int com.bugzero.ejb.user.EBUserLoginLocal.getCid(), causedBy:
      java.sql.SQLException: Column not found, message from server: "Unknown column 'userDetails' in 'field list'"
      at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:1626)
      at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:886)
      at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:945)
      at com.mysql.jdbc.Connection.execSQL(Connection.java:1844)
      at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1458)
      at org.jboss.resource.adapter.jdbc.WrappedPreparedStatement.executeQuery(WrappedPreparedStatement.java:304)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCLoadEntityCommand.execute(JDBCLoadEntityCommand.java:158)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCLoadEntityCommand.execute(JDBCLoadEntityCommand.java:72)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.loadEntity(JDBCStoreManager.java:612)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.loadEntity(JDBCStoreManager.java:594)
      at org.jboss.ejb.plugins.CMPPersistenceManager.loadEntity(CMPPersistenceManager.java:381)
      at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.loadEntity(CachedConnectionInterceptor.java:352)
      at org.jboss.ejb.plugins.EntitySynchronizationInterceptor.invoke(EntitySynchronizationInterceptor.java:239)
      at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:185)
      at org.jboss.ejb.plugins.EntityReentranceInterceptor.invoke(EntityReentranceInterceptor.java:114)
      at org.jboss.ejb.plugins.EntityInstanceInterceptor.invoke(EntityInstanceInterceptor.java:163)
      at org.jboss.ejb.plugins.EntityLockInterceptor.invoke(EntityLockInterceptor.java:89)
      at org.jboss.ejb.plugins.EntityCreationInterceptor.invoke(EntityCreationInterceptor.java:54)
      at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:84)
      at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:267)
      at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:128)
      at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:118)
      at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:191)
      at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
      at org.jboss.ejb.EntityContainer.internalInvoke(EntityContainer.java:489)
      at org.jboss.ejb.Container.invoke(Container.java:700)
      at org.jboss.ejb.plugins.local.BaseLocalProxyFactory.invoke(BaseLocalProxyFactory.java:375)
      at org.jboss.ejb.plugins.local.EntityProxy.invoke(EntityProxy.java:38)
      at $Proxy45.getCid(Unknown Source)
      at com.bugzero.ejb.user.UserProfileBean.validateLogin(Unknown Source)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:324)
      at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionContainer.java:683)
      at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:185)
      at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:72)
      at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:84)
      at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:267)
      at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:128)
      at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:118)
      at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:191)
      at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
      at org.jboss.ejb.StatelessSessionContainer.internalInvoke(StatelessSessionContainer.java:331)
      at org.jboss.ejb.Container.invoke(Container.java:700)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:324)
      at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:546)
      at org.jboss.invocation.local.LocalInvoker.invoke(LocalInvoker.java:101)
      at org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterceptor.java:90)
      at org.jboss.proxy.TransactionInterceptor.invoke(TransactionInterceptor.java:46)
      at org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.java:45)
      at org.jboss.proxy.ejb.StatelessSessionInterceptor.invoke(StatelessSessionInterceptor.java:100)
      at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:85)

      Current Implementation Details
      The MySQL Database contains two tables viz. UserLogin and UserDetails created as follows:

      CREATE TABLE USERLOGIN (
      ID int(5) NOT NULL auto_increment,
      CID int(5) default '0',
      DEFPID int(5) unsigned default '0',
      FIRSTNAME varchar(40) NOT NULL default '',
      LASTNAME varchar(40) NOT NULL default '',
      JOBTITLE varchar(50) NOT NULL default '',
      EMAIL varchar(80) NOT NULL default '',
      USERID varchar(20) NOT NULL default '',
      PASSWD varchar(15) NOT NULL default '',
      AUTONOTIFY char(1) NOT NULL default '',
      PRIMARY KEY (ID)
      ) TYPE=InnoDB;

      CREATE TABLE USERDETAILS (
      ID int(5) NOT NULL auto_increment,
      UID int(5) NOT NULL default '0',
      COMPANY varchar(80) NOT NULL default '',
      BUSADDR varchar(80) NOT NULL default '',
      PHONE varchar(15) default '0',
      EXT varchar(5) default NULL,
      FAX tinyint(3) unsigned default '0',
      ROLE varchar(20) NOT NULL default '',
      PRIMARY KEY (ID)
      ) TYPE=InnoDB COMMENT='User Profile Details';

      NOTE: The UID column in USERDETAILS is the foreign key (although a FOREIGN Key constraint is not present at the table level) which will hold the value of ID column which is a PRIMARY KEY in USERLOGIN table.

      I have created the following entity bean classes to manage persistence for the above tables:

      CMP Classes related to UserLogin
      public interface EBUserLoginHome extends EJBHome
      {
      ...
      ...
      }

      public interface EBUserLoginLocal extends EJBLocalObject
      {
      ...
      ...
      public abstract EBUserDetailsLocal getUserDetails();
      public abstract void setUserDetails(EBUserDetailsLocal user);
      ...
      ...
      }

      public abstract class EBUserLoginBean implements EntityBean
      {
      ...
      ...
      public abstract EBUserDetailsLocal getUserDetails();
      public abstract void setUserDetails(EBUserDetailsLocal user);
      ...
      ...
      }

      public class EBUserLoginPK implements Serializable
      {
      ...
      ...
      }

      CMP Classes related to UserDetails

      public interface EBUserDetailsLocal extends EJBLocalObject
      {
      ...
      ...
      }

      public interface EBUserDetailsLocalHome extends EJBLocalHome{
      ...
      ...
      }

      public abstract class EBUserDetailsBean implements EntityBean{
      ...
      ...
      }

      public class EBUserDetailsPK implements Serializable{
      ...
      ...
      }

      Deployment Descriptors and JBOSSCMP-JDBC Settings
      EJB-JAR.XML
      <ejb-relation>
      <ejb-relation-name>UserLogin-UserDetails</ejb-relation-name>
      <ejb-relationship-role>
      <ejb-relationship-role-name>UserHasUserDetails</ejb-relationship-role-name>
      One

      <relationship-role-source>
      <ejb-name>EBUserLoginEJB</ejb-name>
      </relationship-role-source>

      <cmr-field>
      <cmr-field-name>userDetails</cmr-field-name>
      </cmr-field>
      </ejb-relationship-role>

      <ejb-relationship-role>
      <ejb-relationship-role-name>UserDetailsPartOfUserLogin</ejb-relationship-role-name>
      One

      <relationship-role-source>
      <ejb-name>EBUserDetailsEJB</ejb-name>
      </relationship-role-source>
      </ejb-relationship-role>
      </ejb-relation>

      JBOSSCMP-JDBC.XML

      <ejb-relation>
      <ejb-relation-name>UserLogin-UserDetails</ejb-relation-name>
      <foreign-key-mapping/>
      <ejb-relationship-role>
      <ejb-relationship-role-name>UserHasUserDetails</ejb-relationship-role-name>
      <key-fields>
      <key-field>
      <field-name>id</field-name>
      <column-name>uid</column-name>
      </key-field>
      </key-fields>
      </ejb-relationship-role>

      <ejb-relationship-role>
      <ejb-relationship-role-name>UserDetailsPartOfUserLogin</ejb-relationship-role-name>
      </ejb-relationship-role>
      </ejb-relation>


      NOTE: The multiplicity tag is getting removed during submitting of this POST and therefore you might see only "One" instead of (multiplicity)One(/multiplicity) in angled brackets

      I would appreciate if you could review the above mentioned details and provide inputs on what is wrong with the approach I am using to implement the One-to-One Unidirectional relationship. Also, please indicate in case any additional information is required.

        • 1. Re: Problem with One to One Unidirectional Relationship
          ironbird Newbie

          Your relationships seems OK. The error looks like userDetails is also declared as a cmp-field.
          Post your whole descriptors

          • 2. Re: Problem with One to One Unidirectional Relationship
            darpan Newbie

            NOTE: The multiplicity tag is getting removed during submitting of this POST and therefore you might see only "One" instead of (multiplicity)One(/multiplicity) in angled brackets

            The descriptors are as follows (relevant text has been color coded):

            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>
            JBoss BugZero Defect Tracking System
            <display-name>BugZero</display-name>
            <enterprise-beans>

            <ejb-name>EBUserLoginEJB</ejb-name>
            com.bugzero.ejb.user.EBUserLoginHome
            com.bugzero.ejb.user.EBUserLogin
            <local-home>com.bugzero.ejb.user.EBUserLoginLocalHome</local-home>
            com.bugzero.ejb.user.EBUserLoginLocal
            <ejb-class>com.bugzero.ejb.user.EBUserLoginBean</ejb-class>
            <persistence-type>Container</persistence-type>
            <prim-key-class>com.bugzero.ejb.user.EBUserLoginPK</prim-key-class>
            false

            <cmp-version>2.x</cmp-version>
            <abstract-schema-name>EBUserLoginBean</abstract-schema-name>
            <cmp-field>
            <field-name>id</field-name>
            </cmp-field>
            <cmp-field>
            <field-name>cid</field-name>
            </cmp-field>
            <cmp-field>
            <field-name>defpid</field-name>
            </cmp-field>
            <cmp-field>
            <field-name>firstname</field-name>
            </cmp-field>
            <cmp-field>
            <field-name>lastname</field-name>
            </cmp-field>
            <cmp-field>
            <field-name>jobtitle</field-name>
            </cmp-field>
            <cmp-field>
            <field-name>email</field-name>
            </cmp-field>
            <cmp-field>
            <field-name>userid</field-name>
            </cmp-field>
            <cmp-field>
            <field-name>passwd</field-name>
            </cmp-field>
            <cmp-field>
            <field-name>autonotify</field-name>
            </cmp-field>

            <query-method>
            <method-name>findByUseridAndPasswd</method-name>
            <method-params>
            <method-param>java.lang.String</method-param>
            <method-param>java.lang.String</method-param>
            </method-params>
            </query-method>
            <ejb-ql>
            <![CDATA[SELECT OBJECT(u) FROM EBUserLoginBean AS u WHERE u.userid = ?1 AND u.passwd = ?2]]>
            </ejb-ql>


            <query-method>
            <method-name>findAllUserLogins</method-name>
            <method-params></method-params>
            </query-method>
            <ejb-ql>
            <![CDATA[SELECT OBJECT(u) FROM EBUserLoginBean AS u]]>
            </ejb-ql>




            <ejb-name>EBUserDetailsEJB</ejb-name>
            <local-home>com.bugzero.ejb.user.EBUserDetailsLocalHome</local-home>
            com.bugzero.ejb.user.EBUserDetailsLocal
            <ejb-class>com.bugzero.ejb.user.EBUserDetailsBean</ejb-class>
            <persistence-type>Container</persistence-type>
            <prim-key-class>com.bugzero.ejb.user.EBUserDetailsPK</prim-key-class>
            false

            <cmp-version>2.x</cmp-version>
            <abstract-schema-name>EBUserDetailsBean</abstract-schema-name>
            <cmp-field>
            <field-name>id</field-name>
            </cmp-field>
            <cmp-field>
            <field-name>company</field-name>
            </cmp-field>
            <cmp-field>
            <field-name>busaddr</field-name>
            </cmp-field>
            <cmp-field>
            <field-name>phone</field-name>
            </cmp-field>
            <cmp-field>
            <field-name>ext</field-name>
            </cmp-field>
            <cmp-field>
            <field-name>fax</field-name>
            </cmp-field>
            <cmp-field>
            <field-name>role</field-name>
            </cmp-field>


            <ejb-name>EBCustomerEJB</ejb-name>
            <local-home>com.bugzero.ejb.cust.EBCustomerLocalHome</local-home>
            com.bugzero.ejb.cust.EBCustomerLocal
            <ejb-class>com.bugzero.ejb.cust.EBCustomerBean</ejb-class>
            <persistence-type>Container</persistence-type>
            <prim-key-class>com.bugzero.ejb.cust.EBCustomerPK</prim-key-class>
            false

            <cmp-version>2.x</cmp-version>
            <abstract-schema-name>EBCustomerBean</abstract-schema-name>
            <cmp-field>
            <field-name>id</field-name>
            </cmp-field>
            <cmp-field>
            <field-name>custname</field-name>
            </cmp-field>
            <cmp-field>
            <field-name>custaddr</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>zipcode</field-name>
            </cmp-field>
            <cmp-field>
            <field-name>country</field-name>
            </cmp-field>
            <cmp-field>
            <field-name>contact</field-name>
            </cmp-field>
            <cmp-field>
            <field-name>email</field-name>
            </cmp-field>
            <cmp-field>
            <field-name>phone</field-name>
            </cmp-field>
            <cmp-field>
            <field-name>ext</field-name>
            </cmp-field>
            <cmp-field>
            <field-name>fax</field-name>
            </cmp-field>
            <cmp-field>
            <field-name>website</field-name>
            </cmp-field>


            <query-method>
            <method-name>findAllCustomers</method-name>
            <method-params></method-params>
            </query-method>
            <ejb-ql>
            <![CDATA[SELECT OBJECT(c) FROM EBCustomerBean AS c]]>
            </ejb-ql>




            <ejb-name>EBProductEJB</ejb-name>
            <local-home>com.bugzero.ejb.prod.EBProductLocalHome</local-home>
            com.bugzero.ejb.prod.EBProductLocal
            <ejb-class>com.bugzero.ejb.prod.EBProductBean</ejb-class>
            <persistence-type>Container</persistence-type>
            <prim-key-class>com.bugzero.ejb.prod.EBProductPK</prim-key-class>
            false

            <cmp-version>2.x</cmp-version>
            <abstract-schema-name>EBProductBean</abstract-schema-name>
            <cmp-field>
            <field-name>id</field-name>
            </cmp-field>
            <cmp-field>
            <field-name>prodname</field-name>
            </cmp-field>
            <cmp-field>
            <field-name>price</field-name>
            </cmp-field>
            <cmp-field>
            <field-name>version</field-name>
            </cmp-field>
            <cmp-field>
            <field-name>buildno</field-name>
            </cmp-field>
            <cmp-field>
            <field-name>reldate</field-name>
            </cmp-field>
            <cmp-field>
            <field-name>features</field-name>
            </cmp-field>
            <cmp-field>
            <field-name>suppenv</field-name>
            </cmp-field>
            <cmp-field>
            <field-name>suppplat</field-name>
            </cmp-field>


            <query-method>
            <method-name>findAllProducts</method-name>
            <method-params></method-params>
            </query-method>
            <ejb-ql>
            <![CDATA[SELECT OBJECT(p) FROM EBProductBean AS p]]>
            </ejb-ql>




            <ejb-name>EBModuleEJB</ejb-name>
            <local-home>com.bugzero.ejb.prod.EBModuleLocalHome</local-home>
            com.bugzero.ejb.prod.EBModuleLocal
            <ejb-class>com.bugzero.ejb.prod.EBModuleBean</ejb-class>
            <persistence-type>Container</persistence-type>
            <prim-key-class>com.bugzero.ejb.prod.EBModulePK</prim-key-class>
            false

            <cmp-version>2.x</cmp-version>
            <abstract-schema-name>EBModuleBean</abstract-schema-name>
            <cmp-field>
            <field-name>id</field-name>
            </cmp-field>
            <cmp-field>
            <field-name>pid</field-name>
            </cmp-field>
            <cmp-field>
            <field-name>shortname</field-name>
            </cmp-field>
            <cmp-field>
            <field-name>descr</field-name>
            </cmp-field>

            <query-method>
            <method-name>findAllModules</method-name>
            <method-params></method-params>
            </query-method>
            <ejb-ql>
            <![CDATA[SELECT OBJECT(m) FROM EBModuleBean AS m]]>
            </ejb-ql>




            <ejb-name>UserProfileEJB</ejb-name>
            com.bugzero.ejb.user.UserProfileHome
            com.bugzero.ejb.user.UserProfile
            <local-home>com.bugzero.ejb.user.UserProfileLocalHome</local-home>
            com.bugzero.ejb.user.UserProfileLocal
            <ejb-class>com.bugzero.ejb.user.UserProfileBean</ejb-class>
            <session-type>Stateless</session-type>
            <transaction-type>Container</transaction-type>

            <!-- Local Lookups for the User Profile Session Bean -->
            <ejb-local-ref>
            <ejb-ref-name>EBUserLoginLocalEJB</ejb-ref-name>
            <ejb-ref-type>Entity</ejb-ref-type>
            <local-home>com.bugzero.ejb.user.EBUserLoginLocalHome</local-home>
            com.bugzero.ejb.user.EBUserLoginLocal
            <ejb-link>EBUserLoginEJB</ejb-link>
            </ejb-local-ref>

            <ejb-local-ref>
            <ejb-ref-name>EBUserDetailsLocalEJB</ejb-ref-name>
            <ejb-ref-type>Entity</ejb-ref-type>
            <local-home>com.bugzero.ejb.user.EBUserDetailsLocalHome</local-home>
            com.bugzero.ejb.user.EBUserDetailsLocal
            <ejb-link>EBUserDetailsEJB</ejb-link>
            </ejb-local-ref>



            <ejb-name>CustomerEJB</ejb-name>
            com.bugzero.ejb.cust.CustomerHome
            com.bugzero.ejb.cust.Customer
            <ejb-class>com.bugzero.ejb.cust.CustomerBean</ejb-class>
            <session-type>Stateless</session-type>
            <transaction-type>Container</transaction-type>

            <!-- Local Lookups for the User Profile Session Bean -->
            <ejb-local-ref>
            <ejb-ref-name>EBCustomerLocalEJB</ejb-ref-name>
            <ejb-ref-type>Entity</ejb-ref-type>
            <local-home>com.bugzero.ejb.cust.EBCustomerLocalHome</local-home>
            com.bugzero.ejb.cust.EBCustomerLocal
            <ejb-link>EBCustomerEJB</ejb-link>
            </ejb-local-ref>



            <ejb-name>ProductEJB</ejb-name>
            com.bugzero.ejb.prod.ProductHome
            com.bugzero.ejb.prod.Product
            <ejb-class>com.bugzero.ejb.prod.ProductBean</ejb-class>
            <session-type>Stateless</session-type>
            <transaction-type>Container</transaction-type>

            <!-- Local Lookups to Product Entity Bean for the Product Session Bean -->
            <ejb-local-ref>
            <ejb-ref-name>EBProductLocalEJB</ejb-ref-name>
            <ejb-ref-type>Entity</ejb-ref-type>
            <local-home>com.bugzero.ejb.prod.EBProductLocalHome</local-home>
            com.bugzero.ejb.prod.EBProductLocal
            <ejb-link>EBProductEJB</ejb-link>
            </ejb-local-ref>

            <!-- Local Lookups to Module Entity Bean for the Product Session Bean -->
            <ejb-local-ref>
            <ejb-ref-name>EBModuleLocalEJB</ejb-ref-name>
            <ejb-ref-type>Entity</ejb-ref-type>
            <local-home>com.bugzero.ejb.prod.EBModuleLocalHome</local-home>
            com.bugzero.ejb.prod.EBModuleLocal
            <ejb-link>EBModuleEJB</ejb-link>
            </ejb-local-ref>


            </enterprise-beans>

            Product-Module
            <ejb-relation>
            <ejb-relation-name>ProductsHaveModules</ejb-relation-name>

            <ejb-relationship-role>
            <ejb-relationship-role-name>ProductHasModules</ejb-relationship-role-name>
            One

            <relationship-role-source>
            <ejb-name>EBProductEJB</ejb-name>
            </relationship-role-source>
            <cmr-field>
            <cmr-field-name>modules</cmr-field-name>
            <cmr-field-type>java.util.Collection</cmr-field-type>
            </cmr-field>
            </ejb-relationship-role>

            <ejb-relationship-role>
            <ejb-relationship-role-name>ModulesInProduct</ejb-relationship-role-name>
            Many

            <relationship-role-source>
            <ejb-name>EBModuleEJB</ejb-name>
            </relationship-role-source>

            <cmr-field>
            <cmr-field-name>pid</cmr-field-name>
            </cmr-field>
            </ejb-relationship-role>
            </ejb-relation>

            <ejb-relation>
            <ejb-relation-name>UserLogin-UserDetails</ejb-relation-name>
            <ejb-relationship-role>
            <ejb-relationship-role-name>UserHasUserDetails</ejb-relationship-role-name>
            One

            <relationship-role-source>
            <ejb-name>EBUserLoginEJB</ejb-name>
            </relationship-role-source>

            <cmr-field>
            <cmr-field-name>userDetails</cmr-field-name>
            </cmr-field>
            </ejb-relationship-role>

            <ejb-relationship-role>
            <ejb-relationship-role-name>UserDetailsPartOfUserLogin</ejb-relationship-role-name>
            One

            <relationship-role-source>
            <ejb-name>EBUserDetailsEJB</ejb-name>
            </relationship-role-source>
            </ejb-relationship-role>
            </ejb-relation>

            </ejb-jar>

            JBOSSCMP-JDBC.XML
            <?xml version="1.0" encoding="UTF-8"?>
            <!DOCTYPE jbosscmp-jdbc SYSTEM "jbosscmp-jdbc_3_2.dtd">
            <!-- <!DOCTYPE jbosscmp-jdbc SYSTEM "C:\java\jboss-3.2.3\docs\dtd\jbosscmp-jdbc_3_2.dtd"> -->
            <jbosscmp-jdbc>


            java:/BugZeroDS
            <datasource-mapping>mySQL</datasource-mapping>
            <create-table>true</create-table>
            <remove-table>false</remove-table>


            <!--
            java:/PostgresDS
            <datasource-mapping>PostgreSQL</datasource-mapping>
            <create-table>true</create-table>
            <remove-table>false</remove-table>
            -->
            <enterprise-beans>
            <!-- User Login Mappings -->

            <ejb-name>EBUserLoginEJB</ejb-name>
            <table-name>USERLOGIN</table-name>
            <cmp-field>
            <field-name>id</field-name>
            <column-name>ID</column-name>
            <auto-increment/>
            </cmp-field>
            <cmp-field>
            <field-name>cid</field-name>
            <column-name>CID</column-name>
            </cmp-field>
            <cmp-field>
            <field-name>defpid</field-name>
            <column-name>DEFPID</column-name>
            </cmp-field>
            <cmp-field>
            <field-name>firstname</field-name>
            <column-name>FIRSTNAME</column-name>
            </cmp-field>
            <cmp-field>
            <field-name>lastname</field-name>
            <column-name>LASTNAME</column-name>
            </cmp-field>
            <cmp-field>
            <field-name>jobtitle</field-name>
            <column-name>JOBTITLE</column-name>
            </cmp-field>
            <cmp-field>
            <field-name>email</field-name>
            <column-name>EMAIL</column-name>
            </cmp-field>
            <cmp-field>
            <field-name>userid</field-name>
            <column-name>USERID</column-name>
            </cmp-field>
            <cmp-field>
            <field-name>passwd</field-name>
            <column-name>PASSWD</column-name>
            </cmp-field>
            <cmp-field>
            <field-name>autonotify</field-name>
            <column-name>AUTONOTIFY</column-name>
            </cmp-field>


            <!-- User Details Mappings -->

            <ejb-name>EBUserDetailsEJB</ejb-name>
            <table-name>USERDETAILS</table-name>
            <cmp-field>
            <field-name>id</field-name>
            <column-name>ID</column-name>
            <auto-increment/>
            </cmp-field>
            <!-- UID Field/Column is a CMR Field defining the relationship
            between UserLogin and UserDetails Tables
            <cmp-field>
            <field-name>uid</field-name>
            <column-name>UID</column-name>
            </cmp-field> -->
            <cmp-field>
            <field-name>company</field-name>
            <column-name>COMPANY</column-name>
            </cmp-field>
            <cmp-field>
            <field-name>busaddr</field-name>
            <column-name>BUSADDR</column-name>
            </cmp-field>
            <cmp-field>
            <field-name>phone</field-name>
            <column-name>PHONE</column-name>
            </cmp-field>
            <cmp-field>
            <field-name>ext</field-name>
            <column-name>EXT</column-name>
            </cmp-field>
            <cmp-field>
            <field-name>fax</field-name>
            <column-name>FAX</column-name>
            </cmp-field>
            <cmp-field>
            <field-name>role</field-name>
            <column-name>ROLE</column-name>
            </cmp-field>

            <!-- Customer Mappings -->

            <ejb-name>EBCustomerEJB</ejb-name>
            <table-name>CUSTOMER</table-name>
            <cmp-field>
            <field-name>id</field-name>
            <column-name>ID</column-name>
            <auto-increment/>
            </cmp-field>
            <cmp-field>
            <field-name>custname</field-name>
            <column-name>CUSTNAME</column-name>
            </cmp-field>
            <cmp-field>
            <field-name>custaddr</field-name>
            <column-name>CUSTADDR</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>zipcode</field-name>
            <column-name>ZIPCODE</column-name>
            </cmp-field>
            <cmp-field>
            <field-name>country</field-name>
            <column-name>COUNTRY</column-name>
            </cmp-field>
            <cmp-field>
            <field-name>contact</field-name>
            <column-name>CONTACT</column-name>
            </cmp-field>
            <cmp-field>
            <field-name>phone</field-name>
            <column-name>PHONE</column-name>
            </cmp-field>
            <cmp-field>
            <field-name>ext</field-name>
            <column-name>EXT</column-name>
            </cmp-field>
            <cmp-field>
            <field-name>fax</field-name>
            <column-name>FAX</column-name>
            </cmp-field>
            <cmp-field>
            <field-name>website</field-name>
            <column-name>WEBSITE</column-name>
            </cmp-field>


            <!-- Product Mappings -->

            <ejb-name>EBProductEJB</ejb-name>
            <table-name>PRODUCT</table-name>
            <cmp-field>
            <field-name>id</field-name>
            <column-name>ID</column-name>
            <auto-increment/>
            </cmp-field>
            <cmp-field>
            <field-name>prodname</field-name>
            <column-name>PRODNAME</column-name>
            </cmp-field>
            <cmp-field>
            <field-name>price</field-name>
            <column-name>PRICE</column-name>
            </cmp-field>
            <cmp-field>
            <field-name>version</field-name>
            <column-name>VERSION</column-name>
            </cmp-field>
            <cmp-field>
            <field-name>buildno</field-name>
            <column-name>BUILD</column-name>
            </cmp-field>
            <cmp-field>
            <field-name>reldate</field-name>
            <column-name>RELDATE</column-name>
            </cmp-field>
            <cmp-field>
            <field-name>features</field-name>
            <column-name>FEATURES</column-name>
            </cmp-field>
            <cmp-field>
            <field-name>suppenv</field-name>
            <column-name>SUPP_ENV</column-name>
            </cmp-field>
            <cmp-field>
            <field-name>suppplat</field-name>
            <column-name>SUPP_PLAT</column-name>
            </cmp-field>


            <!-- Module Mappings -->

            <ejb-name>EBModuleEJB</ejb-name>
            <table-name>MODULE</table-name>
            <cmp-field>
            <field-name>id</field-name>
            <column-name>ID</column-name>
            <auto-increment/>
            </cmp-field>
            <!-- PID Field/Column is a CMR Field defining the relationship
            between Product and Module Tables
            <cmp-field>
            <field-name>pid</field-name>
            <column-name>PID</column-name>
            </cmp-field>
            -->
            <cmp-field>
            <field-name>shortname</field-name>
            <column-name>SHORTNAME</column-name>
            </cmp-field>
            <cmp-field>
            <field-name>descr</field-name>
            <column-name>DESCR</column-name>
            </cmp-field>


            </enterprise-beans>


            <ejb-relation>
            <ejb-relation-name>UserLogin-UserDetails</ejb-relation-name>
            <foreign-key-mapping/>
            <ejb-relationship-role>
            <ejb-relationship-role-name>UserHasUserDetails</ejb-relationship-role-name>
            <key-fields>
            <key-field>
            <field-name>id</field-name>
            <column-name>USER_ID</column-name>
            </key-field>
            </key-fields>
            </ejb-relationship-role>

            <ejb-relationship-role>
            <ejb-relationship-role-name>UserDetailsPartOfUserLogin</ejb-relationship-role-name>
            </ejb-relationship-role>
            </ejb-relation>

            </jbosscmp-jdbc>

            • 3. Re: Problem with One to One Unidirectional Relationship
              ironbird Newbie

              First post:

              <ejb-relation>
              <ejb-relation-name>UserLogin-UserDetails</ejb-relation-name>
              <foreign-key-mapping/>
              <ejb-relationship-role>
              <ejb-relationship-role-name>UserHasUserDetails</ejb-relationship-role-name>
              <key-fields>
              <key-field>
              <field-name>id</field-name>
              <column-name>uid</column-name>
              </key-field>
              </key-fields>
              </ejb-relationship-role>
              
              <ejb-relationship-role>
              <ejb-relationship-role-name>UserDetailsPartOfUserLogin</ejb-relationship-role-name>
              </ejb-relationship-role>
              </ejb-relation>
              


              Second post:
              <ejb-relation>
              <ejb-relation-name>UserLogin-UserDetails</ejb-relation-name>
              <foreign-key-mapping/>
              <ejb-relationship-role>
              <ejb-relationship-role-name>UserHasUserDetails</ejb-relationship-role-name>
              <key-fields>
              <key-field>
              <field-name>id</field-name>
              <column-name>USER_ID</column-name>
              </key-field>
              </key-fields>
              </ejb-relationship-role>
              
              <ejb-relationship-role>
              <ejb-relationship-role-name>UserDetailsPartOfUserLogin</ejb-relationship-role-name>
              </ejb-relationship-role>
              </ejb-relation>
              


              1): use Quote and Code tags in your posts to see all the descriptors tags
              2): If you change your code at each post, nothing I can do for you !
              3):
              <!-- UID Field/Column is a CMR Field defining the relationship
              between UserLogin and UserDetails Tables
              <cmp-field>
              <field-name>uid</field-name>
              <column-name>UID</column-name>
              </cmp-field> -->
              

              Avoid declare foreign keys as cmp fields. I think you put comment tag between both posts. This can be the first error cause.


              • 4. Re: Problem with One to One Unidirectional Relationship
                darpan Newbie

                I understand what you're saying.

                The comment tag for UID always existed in my descriptor and have removed it now.

                After getting the one-to-one unidirectional problem, I tried implementing a bidirectional relationship which works fine. During the course of implementing this I had changed the column name which led to the discrepancy between the two posts.

                However, before making the second post I had changed my code once again to recheck whether I can implement a unidirectional relationship or do I still get the same problem. I had confirmed that I am still experiencing exactly the same problem as described in the first post although I've changed the column names between the two posts.

                Please help.

                • 5. Re: Problem with One to One Unidirectional Relationship
                  ironbird Newbie

                  I suggest you to adopt a pragmatic method. Nothing's logical in all this.
                  The first error talks about the getCid() getter, nothing to do with the usertDetails field. So:

                  - Keep a known configuration of your beans and relationships (DO NOT CHANGE BETWEEN POSTS).
                  - Activate CMP plugin traces adding

                  <category name="org.jboss.ejb.plugins">
                   <priority value="TRACE" class="org.jboss.logging.XLevel"/>
                  </category>
                  
                  in Log4j.xml
                  - Post the server log file content (or the appropriate snippet if too long)
                  - Post your exact descriptors (from your post : what the USER_ID column got to do with relationships ???)