0 Replies Latest reply on Feb 21, 2004 8:33 PM by flashwindcn

    cmr feild return null

    flashwindcn Newbie

      I am using jboss3.2.3 with sql 2000. I have one SessionBean and two EntityBean. They work fine, but have a small question! I have a jsp to execute finder method, as following:
      Collection c2 = eCardAdminLocal.getAllECard2("type1", "name9");

      if (c!=null) {
      Iterator iterator2 = c2.iterator();
      while (iterator2.hasNext())
      {
      ECardLocal eCardLocal2 = (ECardLocal) iterator2.next();
      out.println(eCardLocal2.getSenderEmail());
      out.println(eCardLocal2.getSenderName());
      out.println(eCardLocal2.getMessage());
      out.println(eCardLocal2.getECardTemplate());
      }
      }
      getSenderEmail(), getSenderName(), getMessage() are correct, but getECardTemplate() return null!!

      jsp file display's message as following:
      email9 name9 message9 null

      who can tell me Why!
      Thanks!!

      my configuration and java files:

      ECardLocal.java

      public interface ECardLocal extends javax.ejb.EJBLocalObject {
      public void setECardTemplate(ECardTemplateLocal eCardTemplate);
      public ECardTemplateLocal getECardTemplate();
      }

      ECardBean.java

      abstract public class ECardBean implements EntityBean {

      public abstract void setECardTemplate(ECardTemplateLocal eCardTemplate);

      public abstract ECardTemplateLocal getECardTemplate();

      }


      ECardTemplateLocal.java

      public interface ECardTemplateLocal extends javax.ejb.EJBLocalObject {
      public void setECards(Collection eCard);
      public Collection getECards();
      }

      ECardTemplateBean.java

      abstract public class ECardTemplateBean implements EntityBean {

      public abstract void setECards(Collection eCard);

      public abstract Collection getECards();

      }


      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>ECardBean</display-name>
      <ejb-name>ECardBean</ejb-name>
      <local-home>mycompany.ejb.ECardLocalHome</local-home>
      mycompany.ejb.ECardLocal
      <ejb-class>mycompany.ejb.ECardBean</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>ECard</abstract-schema-name>
      <cmp-field>
      <field-name>cardID</field-name>
      </cmp-field>
      <cmp-field>
      <field-name>templateID</field-name>
      </cmp-field>
      <cmp-field>
      <field-name>senderName</field-name>
      </cmp-field>
      <cmp-field>
      <field-name>senderEmail</field-name>
      </cmp-field>
      <cmp-field>
      <field-name>message</field-name>
      </cmp-field>
      <primkey-field>cardID</primkey-field>

      <query-method>
      <method-name>findAllECardByTemplateIDAndSenderName</method-name>
      <method-params>
      <method-param>java.lang.String</method-param>
      <method-param>java.lang.String</method-param>
      </method-params>
      </query-method>
      <ejb-ql>select object(c) from ECard as c where c.eCardTemplate.type = ?1 and c.senderName = ?2</ejb-ql>



      <display-name>ECardTemplateBean</display-name>
      <ejb-name>ECardTemplateBean</ejb-name>
      <local-home>mycompany.ejb.ECardTemplateLocalHome</local-home>
      mycompany.ejb.ECardTemplateLocal
      <ejb-class>mycompany.ejb.ECardTemplateBean</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>ECardTemplate</abstract-schema-name>
      <cmp-field>
      <field-name>templateID</field-name>
      </cmp-field>
      <cmp-field>
      <field-name>type</field-name>
      </cmp-field>
      <cmp-field>
      <field-name>path</field-name>
      </cmp-field>
      <primkey-field>templateID</primkey-field>

      </enterprise-beans>

      <ejb-relation>
      <ejb-relation-name>ECard-ECardTemplate</ejb-relation-name>
      <ejb-relationship-role>
      eCardBean
      <ejb-relationship-role-name>ecard-belongs-to-ecardtemplate</ejb-relationship-role-name>
      Many
      <relationship-role-source>
      eCardBean
      <ejb-name>ECardBean</ejb-name>
      </relationship-role-source>
      <cmr-field>
      eCardTemplateBean
      <cmr-field-name>eCardTemplate</cmr-field-name>
      </cmr-field>
      </ejb-relationship-role>
      <ejb-relationship-role>
      eCardTemplateBean
      <ejb-relationship-role-name>ecardtemplate-has-ecards</ejb-relationship-role-name>
      One
      <relationship-role-source>
      eCardTemplateBean
      <ejb-name>ECardTemplateBean</ejb-name>
      </relationship-role-source>
      <cmr-field>
      eCardBean
      <cmr-field-name>eCards</cmr-field-name>
      <cmr-field-type>java.util.Collection</cmr-field-type>
      </cmr-field>
      </ejb-relationship-role>
      </ejb-relation>


      </ejb-jar>


      jbosscmp-jdbc.xml

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

      <ejb-name>ECardBean</ejb-name>
      <table-name>ECard</table-name>
      <cmp-field>
      <field-name>cardID</field-name>
      <column-name>CardID</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>templateID</field-name>
      <column-name>TemplateID</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>senderName</field-name>
      <column-name>SenderName</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>senderEmail</field-name>
      <column-name>SenderEmail</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>message</field-name>
      <column-name>Message</column-name>
      </cmp-field>


      <ejb-name>ECardTemplateBean</ejb-name>
      <table-name>ECardTemplate</table-name>
      <cmp-field>
      <field-name>templateID</field-name>
      <column-name>TemplateID</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>type</field-name>
      <column-name>Type</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>path</field-name>
      <column-name>Path</column-name>
      </cmp-field>

      </enterprise-beans>

      <ejb-relation>
      <ejb-relation-name>ECard-ECardTemplate</ejb-relation-name>
      <foreign-key-mapping />
      <ejb-relationship-role>
      <ejb-relationship-role-name>ecard-belongs-to-ecardtemplate</ejb-relationship-role-name>
      <key-fields />
      </ejb-relationship-role>
      <ejb-relationship-role>
      <ejb-relationship-role-name>ecardtemplate-has-ecards</ejb-relationship-role-name>
      <key-fields>
      <key-field>
      <field-name>templateID</field-name>
      <column-name>TemplateID</column-name>
      </key-field>
      </key-fields>
      </ejb-relationship-role>
      </ejb-relation>

      </jbosscmp-jdbc>