1 Reply Latest reply on Jul 31, 2003 1:07 PM by Rajeev Chitamoor

    CMP newbie question

    Rajeev Chitamoor Newbie

      I am trying to get a basic CMP bean to work.
      When I try to lookit up using the findByPrimaryKey(), I get a

      FinderException: No Such Entity!.

      error message

      I am sure I am doing something stupid, or completely forgot something.

      I am using JBoss 3.2.1 with Oracle as the datastore. I turned on the tracing (in log4J),
      and the SQL select statement generated by the finder method seems okay.
      Not sure where else to look.

      Any suggestions would be aprreciated.

      ejb.xml:
      *******

      <![CDATA[ThemeBean is a CMP Entity Bean.]]>

      <ejb-name>Theme</ejb-name>

      <local-home>com.portblue.model.creation.resource.ThemeLocalHome</local-home>
      com.portblue.model.creation.resource.ThemeLocal

      <ejb-class>com.portblue.model.creation.resource.ThemeCMP</ejb-class>
      <persistence-type>Container</persistence-type>
      <prim-key-class>java.lang.Long</prim-key-class>
      true
      <cmp-version>2.x</cmp-version>
      <abstract-schema-name>Themes</abstract-schema-name>
      <cmp-field >
      <![CDATA[Primary key of this Theme.]]>
      <field-name>themeId</field-name>
      </cmp-field>
      <cmp-field >
      <![CDATA[Parent Theme of this Theme.]]>
      <field-name>parentId</field-name>
      </cmp-field>
      <cmp-field >
      <![CDATA[Name of this Theme.]]>
      <field-name>name</field-name>
      </cmp-field>
      <cmp-field >
      <![CDATA[Description of this Theme.]]>
      <field-name>description</field-name>
      </cmp-field>
      <primkey-field>themeId</primkey-field>


      <query-method>
      <method-name>findByName</method-name>
      <method-params>
      <method-param>java.lang.String</method-param>
      </method-params>
      </query-method>
      <ejb-ql><![CDATA[select object(t) from Themes t where t.name = ?1]]></ejb-ql>

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




      Jboss.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>

      <!--
      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 markup for those beans.
      -->


      <ejb-name>Theme</ejb-name>
      <table-name>Themes</table-name>

      <cmp-field>
      <field-name>themeId</field-name>
      <column-name>theme_id</column-name>

      </cmp-field>
      <cmp-field>
      <field-name>parentId</field-name>
      <column-name>parent_theme_id</column-name>

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

      </cmp-field>
      <cmp-field>
      <field-name>description</field-name>
      <column-name>descr</column-name>

      </cmp-field>



      </enterprise-beans>

      </jbosscmp-jdbc>


      public abstract class ThemeBean implements EntityBean {

      private EntityContext entityContext = null;

      public Long ejbCreate(ThemeModel themeModel) throws CreateException {
      ...
      }

      public void ejbPostCreate() throws CreateException {

      }

      public abstract Long getThemeId();

      public abstract Long getParentId();

      public abstract String getName();

      public abstract String getDescription();

      public abstract void setThemeId(Long themeId);

      public abstract void setParentId(Long parentThemeId);

      public abstract void setName(String themeName);

      public abstract void setDescription(String themeDescription);



      public void ejbRemove() throws RemoveException {}

      public void ejbLoad() {}

      public void ejbStore() {}

      public void ejbActivate() {}

      public void ejbPassivate() {}

      public void unsetEntityContext() {}

      public void setEntityContext(EntityContext entityContext) {}

      }



      public interface ThemeLocalHome
      extends javax.ejb.EJBLocalHome
      {

      public com.portblue.model.creation.resource.ThemeLocal create(com.portblue.model.creation.resource.ThemeModel themeModel)
      throws javax.ejb.CreateException;

      public com.portblue.model.creation.resource.ThemeLocal findByName(java.lang.String name)
      throws javax.ejb.FinderException;

      public com.portblue.model.creation.resource.ThemeLocal findByPrimaryKey(java.lang.Long pk)
      throws javax.ejb.FinderException;

      }