|
Application Techniques |
How to write expression-style finder methods for CMP entity beans.
|
About this technique |
Details |
|---|---|
See the chapter on writing entity beans in the Programmer's Guide |
Expression-based finder methods are finders that can be defined using the SilverStream expression language. You define the finder expression during the EJB deployment process.
Setting up To set up, follow these steps:
Write a finder method declaration in the bean's home interface.
Add the bean class, the home, and remote interfaces to the EJB JAR.
Specifying the expression using the Deployment Plan Designer
In the Deployment pane, highlight the findByLikeness method and open the Property Inspector.
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.
The finder method is mapped.
Specifying the expression in the SilverCmd DeployEJB XML file
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>
The <whereClause> tag for an expression must use the SilverStream expression language syntax.
For more information on this syntax see the chapter on expressions in the PProgrammer's Guide.
|
Application Techniques |
Copyright © 2001, SilverStream Software, Inc. All rights reserved.