4 Replies Latest reply on Jul 5, 2004 10:43 PM by Daniel O'Hare

    finder methods not working

    Daniel O'Hare Newbie

      Hi All-

      I have been searching for days to the solution to this problem- to no avail. I have a finder method: findByName(String name) and the requisite findByPrimaryKey(Integer key) methods in my home interface. The find by pk method works fine, the findByName does not. In the jboss log, I see sql being fired off for the find by pk, but not for the findByName method. It seems like jboss is not picking up the ejb-ql, even though it complains if I take the <ejb-ql> line out of the .

      I have created the required entries in my ejb-jar.xml and even made sure jboss was reading it by putting in bad xml to see if jboss generated errors which it did. I tried copying the same code into a META-INF\jbosscmp-jdbc.xml file and that didn't work either. Here are the code slices:

      public interface EntityTypeHome extends javax.ejb.EJBHome
      {
      public EntityType create(String type_name)
      throws CreateException, RemoteException;

      public Collection findByName(String type_name)
      throws FinderException, RemoteException;

      public EntityType findByPrimaryKey(Integer type_code)
      throws FinderException, RemoteException;
      }

      ejb-jar.xml:

      <?xml version="1.0"?>
      <!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 1.1//EN" "http://java.sun.com/j2ee/dtds/ejb-jar_1_1.dtd">
      <ejb-jar>
      <enterprise-beans>


      This bean represents an Entity Type.

      <ejb-name>Entity_Type</ejb-name>
      server.ejb.entity.systementity.EntityTypeHome
      server.ejb.entity.systementity.EntityType
      <ejb-class>server.ejb.entity.systementity.EntityTypeBean</ejb-class>
      <persistence-type>Container</persistence-type>
      False
      <cmp-version>2.x</cmp-version>
      <abstract-schema-name>entitytype</abstract-schema-name>
      <cmp-field><field-name>type_code</field-name></cmp-field>
      <cmp-field><field-name>type_name</field-name></cmp-field>
      <primkey-field>type_code</primkey-field>
      <prim-key-class>java.lang.Integer</prim-key-class>


      <query-method>
      <method-name>findByName</method-name>
      <method-params>
      <method-param>java.lang.String</method-param>
      </method-params>
      </query-method>
      <ejb-ql>SELECT OBJECT(o) FROM entitytype AS o WHERE o.type_name = ?1></ejb-ql>


      </enterprise-beans>

      <assembly-descriptor>
      <security-role>

      This role represents everyone who is allowed full access
      to the Entity Type bean.

      <role-name>everyone</role-name>
      </security-role>

      <method-permission>
      <role-name>everyone</role-name>

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

      </method-permission>

      <container-transaction>

      All methods require a transaction


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

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

      I took out the jbosscmp-jdbc.xml file from the jar again, as from my (extensive!) research into this problem, it has become apparent that JBoss should be able to read the ejb-ql from my ejb-jar.xml file anyway. If I am mistaken in this let me know- but this thing still didn't work, even with it in there.


      Any help is greatly appreciated, I'll buy the beer on Friday!!! ;0)

      Dan