![]() |
Queries can be defined and stored for the finder methods of Enterprise JavaBeans (EJB) in Studio. Types of queries defined are:
SQL queries are designed specific to a data resource and driver. Multiple queries can be defined for a single data resource and driver. Using any of the following methods opens Input Query dialog or the Query Wizard, where the queries can be designed:
This document describes how to define Queries in Studio.
SQL queries can be defined only for CMP 1.1 beans, and Query Wizard comes up only when the selected module is either EJB 1.1 or a Java module.
Based on the information provided here, the wizard attempts to connect to the database. When connection is established, the next panel appears which allows you to specify the tables to be queried. If connect attempt fails, the Status box displays a message. In such case, verify the data resource name and driver settings.
The Query name is used to map finder methods when defining or deploying entity beans. To add the tables to be queried from Available tables list, click Right arrow button. To delete an existing table, select it in Selected Tables list and click Left arrow button. Click Next.
The third panel in Query Wizard, Specify Search Criteria is used to create a search criterion for a Query.
This panel is the first to come up when Query Wizard is brought up using Bean Wizard, as the table and resource to be used is already defined. Click Prev button to modify. Add the search criterion defined to the WHERE Clause table by clicking Add. Use and/or toggle text in the WHERE Clause table to join all clauses. To remove a search criterion that has been added, click Delete. If the Query contains a parameter to be given at runtime, Query results tab will not display the results. Specifying output fields and sorting Query results
.
This panel displays the generated SQL Query. Click Finish to generate the query.
The Query is stored in the Bean Properties file. Deploying the module or JAR containing the bean, generates a file called queries.props, and stores it in the specific Module or JAR.
Query Viewer can be brought up from inside Deploy Tool. Open the required archive in Deploy Tool and select a bean node. In the right panel, select Finder Queries tab, and click Import. The Query Viewer dialog allows to:
Pick the Query name from Designed Queries table in Query Viewer dialog. The query is displayed in Generated SQL table. To remove a Query, select it and click Delete. Names of Queries defined are listed in Select Query dropdown in the Define Finder Methods dialog that appears while defining an EJB using Bean Wizard.
Clicking Import in the Query Viewer panel opens Import Queries dialog.
Browse for the props file that contains Queries you want to import. Select the props file to view the Queries. Select queries to import and click OK. An imported Query is highlighted in blue in Import Query dialog along with the generated SQL statement. Duplicate Queries cannot be imported into Studio.
EJB QL queries can be defined only for CMP 2.0 beans, and Input Query panel comes up only when the selected module is an EJB 2.0 module.
Enter the EJB QL query in the Input Query panel and click OK to finish.
| Pramati Technologies © Copyright |
|