# @ejbgen:finder Annotation

This tag specifies a finder method for a CMP entity bean. This tag is not used for the findByPrimaryKey method; this method is automatically created by WebLogic during build. For more information, see the Remarks section of the @ejbgen:file-generation Annotation.

## Scope

A class tag on a CMP entity bean.

## Syntax

@ejbgen:finder

[caching-name="CacheName"]

[comment="CommentText"]

ejb-ql="QueryLanguage"

[generate-on="Local/Remote"]

[group-name="GroupName"]

[id="TagID"]

[include-updates="True/False"]

[isolation-level="IsolationLevelOption"]

[max-elements="MaxNumber"]

[signature="ClassSignature"]

DEPRECATED [sql-select-distinct="True/False"]

[transaction-attribute="TransactionOption"]

[weblogic-ejb-ql="Query"]

## Attributes

caching-name

Optional. Specifies the name of an eager relationship caching definition. For more details, see the ejbgen:relationship-caching-element Annotation and Accelerating Entity Bean Data Access.

comment

Optional. Specifies a comment that will be added to the auto-generated finder Java method in the home interface(s).

ejb-ql

Required. Specifies the EJB QL statement for this query.

generate-on

Optional. Specifies in which home interface this finder method will be defined. Valid values are Local and Remote. If this attribute is not specified, the finder method will be auto-generated on both. For more information, see the Remarks below.

group-name

Optional. This attribute defines which group-name will be eagerly loaded when returning the results of the query. For more details, see Accelerating Entity Bean Data Access.

id

Optional. Specifies the ID of the tag. For more information, see EJBGen Tag Inheritance.

include-updates

Optional. Specifies whether updates made during the current transaction must be reflected in the result of a query. Valid values are True and False. When this attribute is left unspecified, it defaults to true. For more details, see Accelerating Entity Bean Data Access.

isolation-level

Optional. Specifies the transaction isolation level for this method. Valid values are TransactionSerializable, TransactionReadCommitted, TransactionReadUncommitted, and TransactionRepeatableRead. If not specified, the isolation level specified by an ejbgen:method-isolation-level-pattern Annotation might apply. Otherwise, the default isolation level of the underlying database is used.

max-elements

Optional. Specifies the maximum number of elements that should be returned by a query. When left unspecified, no maximum is set.

signature

Optional. Specifies the signature of the finder method as it will be defined in the home interface. Exceptions that might thrown by this method should not be specified, as they are added automatically during build. Any arguments should be fully qualified (such as java.lang.String).

sql-select-distinct

This attribute is deprecated. Please use the DISTINCT keyword in the EJB-QL instead.

transaction-attribute

Optional. Specifies the transaction attribute for this local method. Valid values are NotSupported, Supports, Required, RequiresNew, Mandatory, and Never. If not specified, the default transaction of the session or entity bean will be used.

weblogic-ejb-ql

Optional. Specifies the WebLogic QL statement for this query.

## Remarks

The following rules apply to this tag's use:

- The ejbgen:finder tag defines the entire finder method. In other words, unlike the ejbgen:select tag, the tag is not added to a method definition. To verify this, select a finder method in Design View and notice that in Source View the finder method equals the ejbgen:finder tag.

- When building an EJB, the ejbgen:file-generation tag specifies whether the local and/or remote business interface will be generated. If so, the finder method will be defined in this interface if the auto-generate attribute specifies this.

- Use either the ejb-ql or the weblogic-ejb-ql for the query executed for this finder method. When you specify queries for both attributes, the query specify for the ejb-ql attribute will be ignored.

Related Topics

@ejbgen:file-generation Annotation

How Do I: Add a Finder Method to an Entity Bean?

Finder Methods Sample

Query Methods and EJB-QL

@ejbgen:select Annotation