Skip Headers

Oracle® Application Server Containers for J2EE Enterprise JavaBeans Developer's Guide
10g Release 2 (10.1.2)
Part No. B15505-01
  Go To Documentation Library
Home
Go To Product List
Solution Area
Go To Table Of Contents
Contents
Go To Index
Index

Previous
Previous
Next
Next
 

Deployment Descriptor Semantics

The structure required for defining both types of query methods is the same in the deployment descriptor.

  1. You must define the <abstract-schema-name> element in the <entity> element for each entity bean referred to in the EJB QL statement. This element defines the name that identifies the entity bean in the EJB QL statement. Thus, if you define your <abstract-schema-name> as Employee, then the EJB QL uses Employee in its EJB QL to refer to the EmpBean entity bean.

  2. Define the <query> element for each query method (finder and select), except for the findByPrimaryKey finder method.


    Note:

    If you want to use the OC4J-specific syntax, you still start with configuring the EJB QL <query> element. Then, after deployment, you modify the query in the orion-ejb-jar.xml file to be the statement that you want.

    The <query> element has two main elements:

    • The <method-name> element identifies the finder or select method. The finder method is the same name as defined in the component home interfaces. The select method is the same name as defined in the bean class.

    • The <ejb-ql> element contains the EJB QL statement for this method.

Example 7-1 Employee FindAll Deployment Descriptor Definition

The following example shows the EmpBean entity bean definition.

<entity>
  <display-name>EmpBean</display-name>
  <ejb-name>EmpBean</ejb-name>
  ...
  <abstract-schema-name>Employee</abstract-schema-name>
  <cmp-field><field-name>empNo</field-name></cmp-field>
  <cmp-field><field-name>empName</field-name></cmp-field>
  <cmp-field><field-name>salary</field-name></cmp-field>
  <primkey-field>empNo</primkey-field>
    <prim-key-class>java.lang.Integer</prim-key-class>
    ...
    <query>
     <description></description>
      <query-method>
        <method-name>findAll</method-name>
        <method-params />
      </query-method>
     <ejb-ql>Select OBJECT(e) From Employee e</ejb-ql>
    </query>
<query>
 <description></description> 
 <query-method>
    <method-name>findByEmpNo</method-name>
    <method-params>
      <method-param>java.lang.Integer</method-param>
    </method-params>
  </query-method>
  <ejb-ql>SELECT OBJECT(e) FROM Employee e WHERE e.empNo = ?1
  </ejb-ql>
</query>
...
</entity>

The EJB QL statement for the findAll method is simple. It selects objects, identified by the variable e, from the Employee entity beans. Thus, it selects all Employee entity bean objects. The EJB QL statement for the findByEmpNo method selects all objects where the employee name is equal to the first input parameter to the method. After deployment, OC4J translates the EJB QL statements into <finder-method> elements in the orion-ejb-jar.xml file, as follows:

<finder-method query=""> /*the empty where clause finds all employees*/
<finder-method query="$empname = $1"> /*this finds all records where 	employee is equal to the first input parameter.*/

See "Finder Method Example" for more information and examples.