!--a11y-->
Specifying the Deployment Properties of
Finder/Select Queries 
The general and additional deployment properties of finder and select queries are stored in ejb-jar.xml and in persistent.xml. Some of the properties specified in persistent.xml can be used to optimize the performance of the entity beans.
The entity beans’ finder and select methods have been created.
...
1. Open the ejb-jar.xml.
2. In the right-hand pane, choose the Enterprise Beans tab.
3. Open the entity beans tree structure.
4. From your bean tree sub-structure, select query ® the corresponding query.
The finder and select methods created in the bean are automatically loaded as sub-nodes in the query tree structure.
5. Enter the following data:
Property |
Description |
Query method name |
The name of the finder or select method that uses the query. This field is completed automatically. |
Method parameters |
The parameters of the finder or select method. This field is completed automatically. |
Result Type Mapping |
Specifies whether the abstract schema type returned by the query for the select method will be mapped to an EJBLocalObject or EJBObject type. This property can be set only if the query is for a select method that returns entity objects. |
EJB QL Statement |
The EJB QL query string that defines the finder or select query. |
validate |
Checks whether the EJB QL query string specified in the EJB QL Statement field is correct according to the EJB specification. |
Description |
A description of the query. If your query cannot be expressed in EJB QL, use this field to describe the semantics of the query and leave the EJB QL field empty. |
...
1. Open the persistent.xml.
2. From the right-hand pane, choose the Entity Beans tab.
3. From your bean tree sub-structure, select query ® the corresponding query.
The finder and select methods created in the bean are automatically loaded as sub-nodes in the query tree structure.
4. Enter the following data:
Property |
Description |
Method parameters |
Displays the parameters of the method. This field is completed automatically and cannot be modified. |
Query uses EJB QL 2.1 enhancements |
Indicates that the query uses EJB QL 2.1. Use this option if you need to use ORDER BY, aggregate functions, or other EJB QL 2.1-specific features.
By default all queries are considered EJB 2.0 compatible. |
Use alternative SQL statements |
Use this option if your enterprise beans are developed according to EJB 1.1. If your beans are developed according to EJB 2.0, we do not recommend that you use this option. Describes the bean’s SQL finder methods. Use format ?i to specify the number of the parameter that should be used in place of the statement. Parameters are numbered from 1 to N.
select name_0,order_0 from myTable where order_0=?1 AND order_0=?2 If this statement describes EJB2.0, we recommend that you do not overwrite the default statement that was generated by the QL parser. You cannot change the default SQL statements of QL queries of select methods. If you specify this option for select methods, it will be ignored. The system will not detect whether this statement is correct, or whether it returns the wrong result type during the application’s deployment. However, the system will throw an exception at runtime when you try to execute the incorrect statement. |
You can optimize the performance of your finder and select queries by decreasing the interactions with the database. However, these settings depend on the logic of your entity bean and the results may vary.
These properties are specified for the corresponding query in persistent.xml on the same screen as the additional deployment properties described above.
...
Property |
Description |
Do not flush changes before query |
Switches off data storing before the execution of this finder/select method. This option adds the <switch-off-storing/> element for the corresponding query. |
Immediately load selected objects |
Loads from the database all fields of the affected entities when the finder/select method is executed and locks the entities in the database. If this option is not chosen, only the primary key fields are retrieved from the database. You can choose between the following options: · Do not immediately load selected objects · Immediately load selected objects · Immediately load selected objects and set read-locks · Immediately load selected objects and set write-locks This option adds the <load-selected-objects/> element for the corresponding query. For more information, see Locking. |
For more information, see Optimizations and Performance Tuning.
