Each finder method in the component’s home interface requires a database query to select a set of primary keys. For example, the findByPrimaryKey method selects the key that matches the input parameter. A findAll method might return all keys in the table.
EJB Server can correctly infer the query required to execute
the findByPrimaryKey method. For other finder
methods, you must enter properties to specify the query. Display
the All Properties tab and define new properties for each finder
method. Name each property mapQuery:method
,
where method is the finder method name. For
the value, enter a query to select primary key values with a filter
appropriate for the semantics of the finder method. You can use
the following placeholders to represent column and table names and
parameter values:
Placeholder |
To indicate |
---|---|
[key] |
The table’s primary key (which can consist of multiple columns). |
[table] |
The name of the table. |
@param |
Reference the value of parameter param in the finder method’s IDL signature. If the component was imported from an EJB JAR file, the parameter names will not match those in the original Java implementation. Instead, they are p0, p1, and so forth. |
@param.fieldName |
If method parameter param is not a simple type, reference the value of field fieldName. |
The following are examples of queries using placeholders. This query returns all rows in a table:
select [key] from [table]
This query uses the value of the expiryDate parameter to filter a range of closingDate column values:
select [key] from [table] where closingDate < @expiryDate