Use EJB query
The EJBs query language is used to specify a query over container-managed entity beans. The language is similar to structured query language (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 method dynamic API.
Finder and select queries are specified in the bean's deployment descriptor using the <ejb-ql> tag; they are compiled into SQL during deployment. Dynamic queries are included within the application code itself.
The product's EJB query language is compliant with the EJB QL defined in Sun's EJB 2.1 and EJB 3.0 specifications and has additional capabilities as listed in the topic Comparison of EJB specification and WebSphere Query Language.
- Before using EJB query, familiarize theself with query language concepts, starting with the topic, EJB Query Language.
- Define an EJB query in one of the following ways:
- Rational Application Developer. When defining an entity bean, specify the <ejb-ql> tag for the finder or select method.
See about using Rational Application Developer see the assembly tool information center at http://wilson.boulder.ibm.com/infocenter/radhelp/v7r5mbeta/index.jsp?topic=/com.ibm.jee5.doc/topics/cejb3.html
- Dynamic query service. Add the executeQuery method to the application.
Example
See the topic Example: EJB queries.
EJB query language
Use the dynamic query service