I enclose also the Bean sources, to see the xdoclet tags.

Thank you for your time,

Marco
----- Original Message ----- 
From: "Marco Tedone" <[EMAIL PROTECTED]>
To: "JBoss-user-list" <[EMAIL PROTECTED]>
Sent: Sunday, June 22, 2003 7:35 PM
Subject: [JBoss-user] Problem writing an entity bean related to another.
Jboss 3.2.1


> Hi, I deployed two entity beans, People and Addresses, with a relationship
> 1:1.
>
> The key field of Addresses is called addressId.
>
> Following the CMP specs (I believe) I have all the abstract method in the
> People implementation bean for the People table and two abstract get/set
> methods for the Addresses bean.
>
> In the ejbCreate method, I set the People table fields, while in the
> ejbPostCreate I set the Addresses table fields.
>
> I tried to run the application, and I know because I debugged, that the
> ejbCreate method is executed (because it returns with null value).
>
> Jboss returns to me the following exception:
>
> 19:01:09,890 ERROR [People] Could not create entity
> java.sql.SQLException: Column not found,  message from server: "Unknown
> column 'addressId' in 'field list'"
>
> Because of the relationship, I think, Jboss waits for the Addresses key
> field, which is addressId. The problem is that I filled this value in the
> AddressData (Value Object).
>
> Have you got any idea, or could you please ask me for more resources, to
> solve this problem?
>
> Here I enclose jbosscm-jdbc.xml and ejb-jar.xml files.
>
> Thank you for your time,
>
> Marco
>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jbosscmp-jdbc PUBLIC "-//JBoss//DTD JBOSSCMP-JDBC 3.2//EN" "http://www.jboss.org/j2ee/dtd/jbosscmp-jdbc_3_2.dtd";>

<jbosscmp-jdbc>
   <defaults>
     <datasource>java:/Jemos_MySQL</datasource>
     <datasource-mapping>mySQL</datasource-mapping>
     <create-table>true</create-table>
   </defaults>

   <enterprise-beans>

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

      <entity>
         <ejb-name>People</ejb-name>
         <pk-constraint>true</pk-constraint>

         <cmp-field>
            <field-name>email</field-name>
			<not-null/>

        </cmp-field>
         <cmp-field>
            <field-name>password</field-name>
			<not-null/>

        </cmp-field>
         <cmp-field>
            <field-name>firstName</field-name>

        </cmp-field>
         <cmp-field>
            <field-name>lastName</field-name>

        </cmp-field>
         <cmp-field>
            <field-name>creationDate</field-name>
            <column-name>creationDate</column-name>

        </cmp-field>

<!-- jboss 3.2 features -->
<!-- optimistic locking does not express the exclusions needed -->
      </entity>

      <entity>
         <ejb-name>Addresses</ejb-name>
         <pk-constraint>true</pk-constraint>

         <cmp-field>
            <field-name>addressId</field-name>
			<not-null/>

        </cmp-field>
         <cmp-field>
            <field-name>address1</field-name>

        </cmp-field>
         <cmp-field>
            <field-name>address2</field-name>

        </cmp-field>
         <cmp-field>
            <field-name>address3</field-name>

        </cmp-field>
         <cmp-field>
            <field-name>zip</field-name>

        </cmp-field>
         <cmp-field>
            <field-name>city</field-name>

        </cmp-field>
         <cmp-field>
            <field-name>country</field-name>

        </cmp-field>
         <cmp-field>
            <field-name>creationDate</field-name>
            <column-name>creationDate</column-name>

        </cmp-field>

<!-- jboss 3.2 features -->
<!-- optimistic locking does not express the exclusions needed -->
      </entity>

      <entity>
         <ejb-name>Numerator</ejb-name>
         <pk-constraint>true</pk-constraint>

         <cmp-field>
            <field-name>module</field-name>
			<not-null/>

        </cmp-field>
         <cmp-field>
            <field-name>tabname</field-name>
			<not-null/>

        </cmp-field>
         <cmp-field>
            <field-name>number</field-name>
			<not-null/>

        </cmp-field>
         <cmp-field>
            <field-name>creationDate</field-name>
            <column-name>creationDate</column-name>

        </cmp-field>

<!-- jboss 3.2 features -->
<!-- optimistic locking does not express the exclusions needed -->
      </entity>

   </enterprise-beans>

  <relationships>
    <ejb-relation>
      <ejb-relation-name>People-Addresses</ejb-relation-name>

      <ejb-relationship-role>
          <ejb-relationship-role-name>1-People-1-Address</ejb-relationship-role-name>
          <fk-constraint>false</fk-constraint>
		  <key-fields/>

      </ejb-relationship-role>
      <ejb-relationship-role>
          <ejb-relationship-role-name>1-Address-1-People</ejb-relationship-role-name>
          <key-fields>
             <key-field>
               <field-name>addressId</field-name>
               <column-name>addressId</column-name>
             </key-field>
          </key-fields>

      </ejb-relationship-role>
    </ejb-relation>
  </relationships>

</jbosscmp-jdbc>
<?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 >

   <description><![CDATA[No Description.]]></description>
   <display-name>Generated by XDoclet</display-name>

   <enterprise-beans>

      <!-- Session Beans -->
      <session >
         <description><![CDATA[Session Bean which represent a DB Manager for People table]]></description>

         <ejb-name>PeopleDbManager</ejb-name>

         <home>org.jemos.core.framework.ejbs.interfaces.PeopleDbManagerHome</home>
         <remote>org.jemos.core.framework.ejbs.interfaces.PeopleDbManager</remote>
         <ejb-class>org.jemos.core.framework.ejbs.sessions.PeopleDbManagerSession</ejb-class>
         <session-type>Stateful</session-type>
         <transaction-type>Container</transaction-type>

      </session>

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

      <!-- Entity Beans -->
      <entity >
         <description><![CDATA[]]></description>

         <ejb-name>People</ejb-name>

         <local-home>org.jemos.core.framework.ejbs.interfaces.PeopleLocalHome</local-home>
         <local>org.jemos.core.framework.ejbs.interfaces.PeopleLocal</local>

         <ejb-class>org.jemos.core.framework.ejbs.entities.PeopleCMP</ejb-class>
         <persistence-type>Container</persistence-type>
         <prim-key-class>org.jemos.core.framework.ejbs.interfaces.PeopleKey</prim-key-class>
         <reentrant>true</reentrant>
         <cmp-version>2.x</cmp-version>
         <abstract-schema-name>People</abstract-schema-name>
         <cmp-field >
            <description><![CDATA[]]></description>
            <field-name>email</field-name>
         </cmp-field>
         <cmp-field >
            <description><![CDATA[]]></description>
            <field-name>password</field-name>
         </cmp-field>
         <cmp-field >
            <description><![CDATA[]]></description>
            <field-name>firstName</field-name>
         </cmp-field>
         <cmp-field >
            <description><![CDATA[]]></description>
            <field-name>lastName</field-name>
         </cmp-field>
         <cmp-field >
            <description><![CDATA[The creation-date of the entity.]]></description>
            <field-name>creationDate</field-name>
         </cmp-field>

         <ejb-local-ref >
            <ejb-ref-name>Addresses</ejb-ref-name>
            <ejb-ref-type>Entity</ejb-ref-type>
            <local-home>org.jemos.core.framework.ejbs.interfaces.AddressesLocalHome</local-home>
            <local>org.jemos.core.framework.ejbs.interfaces.AddressesLocal</local>
            <ejb-link>Addresses</ejb-link>
         </ejb-local-ref>

	  <!-- Write a file named ejb-finders-PeopleBean.xml if you want to define extra finders. -->
      </entity>

      <entity >
         <description><![CDATA[]]></description>

         <ejb-name>Addresses</ejb-name>

         <local-home>org.jemos.core.framework.ejbs.interfaces.AddressesLocalHome</local-home>
         <local>org.jemos.core.framework.ejbs.interfaces.AddressesLocal</local>

         <ejb-class>org.jemos.core.framework.ejbs.entities.AddressesCMP</ejb-class>
         <persistence-type>Container</persistence-type>
         <prim-key-class>org.jemos.core.framework.ejbs.interfaces.AddressesKey</prim-key-class>
         <reentrant>False</reentrant>
         <cmp-version>2.x</cmp-version>
         <abstract-schema-name>Addresses</abstract-schema-name>
         <cmp-field >
            <description><![CDATA[]]></description>
            <field-name>addressId</field-name>
         </cmp-field>
         <cmp-field >
            <description><![CDATA[]]></description>
            <field-name>address1</field-name>
         </cmp-field>
         <cmp-field >
            <description><![CDATA[]]></description>
            <field-name>address2</field-name>
         </cmp-field>
         <cmp-field >
            <description><![CDATA[]]></description>
            <field-name>address3</field-name>
         </cmp-field>
         <cmp-field >
            <description><![CDATA[]]></description>
            <field-name>zip</field-name>
         </cmp-field>
         <cmp-field >
            <description><![CDATA[]]></description>
            <field-name>city</field-name>
         </cmp-field>
         <cmp-field >
            <description><![CDATA[]]></description>
            <field-name>country</field-name>
         </cmp-field>
         <cmp-field >
            <description><![CDATA[The creation-date of the entity.]]></description>
            <field-name>creationDate</field-name>
         </cmp-field>

	  <!-- Write a file named ejb-finders-AddressesBean.xml if you want to define extra finders. -->
      </entity>

      <entity >
         <description><![CDATA[]]></description>

         <ejb-name>Numerator</ejb-name>

         <local-home>org.jemos.core.framework.ejbs.interfaces.NumeratorLocalHome</local-home>
         <local>org.jemos.core.framework.ejbs.interfaces.NumeratorLocal</local>

         <ejb-class>org.jemos.core.framework.ejbs.entities.NumeratorCMP</ejb-class>
         <persistence-type>Container</persistence-type>
         <prim-key-class>org.jemos.core.framework.ejbs.interfaces.NumeratorKey</prim-key-class>
         <reentrant>False</reentrant>
         <cmp-version>2.x</cmp-version>
         <abstract-schema-name>Numerator</abstract-schema-name>
         <cmp-field >
            <description><![CDATA[]]></description>
            <field-name>module</field-name>
         </cmp-field>
         <cmp-field >
            <description><![CDATA[]]></description>
            <field-name>tabname</field-name>
         </cmp-field>
         <cmp-field >
            <description><![CDATA[]]></description>
            <field-name>number</field-name>
         </cmp-field>
         <cmp-field >
            <description><![CDATA[The creation-date of the entity.]]></description>
            <field-name>creationDate</field-name>
         </cmp-field>

	  <!-- Write a file named ejb-finders-NumeratorBean.xml if you want to define extra finders. -->
      </entity>

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

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

   </enterprise-beans>

   <!-- Relationships -->
   <relationships >
      <ejb-relation >
         <ejb-relation-name>People-Addresses</ejb-relation-name>

         <ejb-relationship-role >
            <ejb-relationship-role-name>1-People-1-Address</ejb-relationship-role-name>
            <multiplicity>One</multiplicity>
            <relationship-role-source >
               <ejb-name>People</ejb-name>
            </relationship-role-source>
            <cmr-field >
               <cmr-field-name>addresses</cmr-field-name>
            </cmr-field>
         </ejb-relationship-role>

         <ejb-relationship-role >
            <ejb-relationship-role-name>1-Address-1-People</ejb-relationship-role-name>
            <multiplicity>One</multiplicity>
            <relationship-role-source >
               <ejb-name>Addresses</ejb-name>
            </relationship-role-source>
         </ejb-relationship-role>

      </ejb-relation>
   </relationships>

   <!-- Assembly Descriptor -->
   <assembly-descriptor >
     <!--
       To add additional assembly descriptor info here, add a file to your
       XDoclet merge directory called assembly-descriptor.xml that contains
       the <assembly-descriptor></assembly-descriptor> markup.
     -->

   <!-- finder permissions -->

   <!-- finder permissions -->

   <!-- finder permissions -->

   <!-- finder permissions -->

   <!-- transactions -->

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

</ejb-jar>

Attachment: PeopleBean.java
Description: Binary data

Attachment: AddressesBean.java
Description: Binary data

Reply via email to