Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Enterprise JavaBeans™ Specification, Version 2.0 - Sun Microsystems.pdf
Скачиваний:
14
Добавлен:
24.05.2014
Размер:
2.71 Mб
Скачать

Sun Microsystems Inc.

Entity Bean Component Contract for Container Managed PersistenceEnterprise JavaBeans 2.0, Public Draft

Instance life cycle con-

9.6.7 Select methods

Select methods are special finder methods for internal use within entity bean instances, and are not specified in the entity bean’s home interface. They are abstract methods defined by the Bean Provider in the entity bean’s implementation class. The semantics of a select method, like those of a finder method, are defined by an EJB QL query string.

There are two types of select methods:

ejbSelect<METHOD>: This type of select method is used for queries which logically encompass all entity beans of the bean type. An ejbSelect<METHOD> is not based on the identity of the entity instance although the current instance is used to execute the query. Such select methods are similar to finder methods, but unlike finder methods, they can also return values of types other than entity objects. An ejbSelect<METHOD> can return values of any Java type other than that of a dependent object or entity bean class. The EJB QL string specified for the method must have a SELECT clause which designates the result type.

ejbSelect<Method>InEntity: This type of select method is used to execute queries which execute within the scope of a specific entity bean instance, hence the execution of this method is based on the entity’s identity. This type of method can return values of dependent objects in addition to the types of values that can be returned by an ejbSelect<METHOD>.

Select methods are executed using the instance on which the query is invoked. The entity identity is not used by the Persistence Manager in executing an ejbSelect<METHOD> method. The entity identity is used by the Persistence Manager in executing an ejbSelect<Method>InEntity method. For this reason an ejbSelect<Method>InEntity method must not be invoked from an ejbHome<METHOD> method.

The following table illustrates the semantics of finder and select methods.

Table 5

Comparison of finder and select methods

 

 

 

 

 

 

 

 

 

Global Scope

In Entity Scope

 

 

 

 

 

 

 

 

 

 

 

 

 

method: ejbFind<Method>

N/A

 

 

 

EJB QL: no SELECT clause

 

 

Exposed to Client

instance: arbitrary instance in pooled state

 

 

 

 

 

 

 

 

return values: entity objects of the same type

 

 

 

 

as entity bean

 

 

 

 

 

 

 

 

 

method: ejbSelect<METHOD>

method: ejbSelect<METHOD>InEntity

 

 

 

EJB QL: requires SELECT clause

EJB QL: requires SELECT clause

 

Internal Only

return values: must not be dependent object

return values: may be any value that can be

 

 

 

classes

selected by EJB QL

 

 

 

instance: current instance (could be arbitrary

instance: current instance

 

 

 

instance in pooled state)

 

 

 

 

 

 

5/31/00

154