Application Techniques



Writing EJB Expression-Style Finder Methods

How to write expression-style finder methods for CMP entity beans.

About this technique

Details

Category

Enterprise JavaBean Techniques

Description

You'll learn about:

Related reading

See the chapter on writing entity beans in the Programmer's Guide

Writing an expression-based finder method   Top of page

Expression-based finder methods are finders that can be defined using the SilverStream expression language. You define the finder expression during the EJB JAR deployment process.

Setting up

To set up, follow these steps:

Specifying the expression using the JAR Designer   Top of page

You can use the JAR Designer to do the following:

  1. In the Deployment pane, highlight the findByLikeness method and open the Property Inspector.

  2. Make sure Type is Expression.

  3. Open the Expression builder.

  4. Choose the companyid field.

  5. Choose the Like operator (from String Operators).

  6. Choose the javaLangString0 parameter.

    The expression builder presents the list of parameters included in the finder method's signature. The parameter names include the data type and the parameter's position as part of the variable name. For example, if the Finder method definition included another parameters, which was an integer, the expression builder would include javaLangInt1.

  7. Close the Property Inspector. The finder method is mapped.

Specifying the expression using the SilverCmd DeployEJB XML file    Top of page

To specify an expression-based finder method in the DeployEJB XML input file, you need to add entries for tags in the obj_FinderMethod subsection of the input file. The following example shows how to define the Company demo finder method described in the previous section.

  <obj_finderMethod> 
     <obj_method> 
       <name>findByLikeness</name> 
        <methodParams type="String"> 
          <el>java.lang.String</el> 
        </methodParams> 
     </obj_method> 
     <finderMethodType>Expression</finderMethodType> 
      <whereClause>Companies.companyname like 
                       javaLangString0</whereClause> 
  </obj_finderMethod> 





Copyright © 2000, SilverStream Software, Inc. All rights reserved.