Why and when to perform this task
The EJB query language is used to specify a query over container-managed
entity beans. The language is similar to SQL. An EJB query is independent
of the bean's mapping to a persistent store.
An EJB query can be used in
three situations:
- To define a finder method of an EJB entity bean.
- To define a select method of an EJB entity bean.
- To dynamically specify a query using the executeQuery() dynamic
API.
Finder and select queries are specified in the bean's deployment descriptor
using the
<ejb-ql> tag. Queries specified in the deployment descriptor
are compiled into SQL during deployment. Dynamic queries require the interface
provided by WebSphere Business Integration Server Foundation.
WebSphere's
EJB query language is compliant with the EJB QL defined in Sun's EJB 2.0 specification
and has additional capabilities as listed in the topic Comparison of EJB 2.0 specification and WebSphere Query Language.
In
your WebSphere application, you can define an EJB query in the following ways:
![[5.0 only]](../../v50.gif)
![[Version 5.0.1]](../../v501.gif)
Application Assembly Tool. When
assembling an EJB 2.0 entity bean, specify the <ejb-ql> tag for
the finder() or select() method.
Assembly Toolkit. When defining an EJB 2.0
entity bean in an EJB deployment descriptor editor, on the Beans page
click Add under Queries and, in the Add Finder Descriptor wizard,
define a find or ejbSelect method. See the online Assembly
Toolkit information for documentation on wizard options.
- WebSphere Studio Application Developer. When defining an entity
bean, specify the <ejb-ql> tag for the finder or select method.
- Dynamic query service. Add the executeQuery() method to your application.
The dynamic query API is provided as a WebSphere Business Integration Server
Foundation extension to WebSphere Application Server.
Before using EJB query, familiarize yourself with query language
concepts, starting with the topic, EJB
Query Language.