Skip Headers

# ejb-jar.xml Finder Options

Previous

Next

The `ejb-jar.xml` file contains a project's EJB entity bean information, including definitions for any finders used for the beans. To create and maintain the `ejb-jar.xml` file, use either a text editor or TopLink Workbench.

The `entity` tag encapsulates a definition for an EJB entity bean. Each bean has its own `entity` tag that contains several other tags that define bean functionality, including bean finders.

Example: A Simple Finder Within the ejb-jar.xml File illustrates the structure of a typical finder defined within the `ejb-jar.xml` file.

Note: Use a combination of an escape character and a double-quote ( \" ) when defining your query using EJB QL. For more information on correct query syntax, see a note at the end of Configuring Named Query Selection Criteria.

A Simple Finder Within the ejb-jar.xml File

    <entity>...    <query>        <query-method>            <method-name>findLargeAccounts</method-name>                <method-params>                <method-param>double</method-param>            </method-params>        </query-method>    <ejb-ql><![CDATA[SELECT OBJECT(account) FROM AccountBean account WHERE       account.balance > ?1]]></ejb-ql>    </query>...</entity>

The `entity` tag contains zero or more `query` elements. Each `query` tag corresponds to a finder method defined on the bean's home or local `Home` interface.

Note:

You can share a single query between both `Home` interfaces, as follows:

- Define the same finder (same name, return type, and parameters) on both `Home` interfaces.

- Include a single `query` element in the `ejb-jar.xml` file.

Here are the elements defined in the `query` section of the `ejb-jar.xml` file:

- `description` (optional): Provides a description of the finder.

- `query-method`: Specifies the method for a finder or `ejbSelect` query.

- `method-name`: Specifies the name of a finder or select method in the entity bean implementation class.

- `method-params`: Contains a list of the fully qualified Java type names of the method parameters.

- `method-param`: Contains the fully qualified Java type name of a method parameter.

- `result-type-mapping` (optional): Specifies how to map an abstract schema type returned by a query for an `ejbSelect` method. You can map the type to an `EJBLocalObject` or `EJBObject` type. Valid values are `Local` or `Remote`.

- `ejb-ql`: Used for all EJB QL finders. It contains the EJB QL query string that defines the finder or `ejbSelect` query. Leave this element empty for non-EJB QL finders.