Show TOC Start of Content Area

Procedure documentation Specifying the Deployment Properties of Finder/Select Queries  Locate the document in its SAP Library structure

Use

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.

Prerequisites

The entity beans’ finder and select methods have been created.

Procedure

Specifying the General Deployment Properties

...

       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.

 

Specifying the Additional Deployment Properties

...

       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.

This graphic is explained in the accompanying text

By default all queries are considered EJB 2.0 compatible.

Use alternative SQL statements

Defines an SQL string that is going to be executed as a select statement in the corresponding finder method. Do not specify anything in this field if you are describing a select method – the value of this field will be ignored for select methods.

Use ?i to refer to the parameter that should be replaced. Parameters are numbered from 1 to N.

This graphic is explained in the accompanying text

select name_0,order_0 from myTable where order_0=?1 AND order_0=?2

In order to be portable, an application should use EJB QL syntax. The EJB Container will consider the statement specified in this field as a native SQL statement, will not parse or verify its correctness, and will execute/send it directly to the underlying data source.

Caution

-          Unchecked SQL statement might lead to a runtime error.

-          If you use this option, you must also specify the database vendor as native database connections will be used.

 

Optimizing the Finder and Select Queries

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.

 

 

End of Content Area