Declaring Finders

JBoss automatically generates the following finders if they are declared in the Home interface:

where FieldName is the name of a field in your bean.

JOnAS can only automatically generate the findByPrimaryKey method so you will have to declare the other finder methods in jonas-ejb-jar.xml for CMP1.X or in ejb-jar.xml for CMP2.X. Example 2-11 illustrates how to declare findByFieldName and findAll finders for JOnAS using CMP1.1.

Example 2-11. CMP1.1 findByFieldName and findAll Declaration

<jonas-ejb-jar>
  <jonas-entity>
    <ejb-name>EJB Name</ejb-name>
    <jdbc-mapping>
      <finder-method-jdbc-mapping>
        <jonas-method>
          <method-name>findByFieldName</method-name>
        </jonas-method>
        <jdbc-where-clause>where fieldName=?</jdbc-where-clause>
      </finder-method-jdbc-mapping>

      <finder-method-jdbc-mapping>
        <jonas-method>
          <method-name>findAll</method-name>
        </jonas-method>
        <jdbc-where-clause></jdbc-where-clause>
      </finder-method-jdbc-mapping>
    </jdbc-mapping>
  </jonas-entity>
</jonas-ejb-jar>