+

Search Tips   |   Advanced Search

EJB Query IS OF TYPE predicate


The IS OF TYPE predicate is used to test the type of an Enterprise Java Beans (EJB) reference. It is similar in function to the Java instance of operator.

IS OF TYPE is used when several abstract beans have been grouped into an EJB inheritance hierarchy. The type names specified in the predicate are the bean abstract names. The ONLY option can be used to specify that the reference must be exactly this type and not a subtype.

identification-variable IS OF TYPE ( [ONLY] type-1, [ONLY] type-2, ..... )

 

Example: IS OF TYPE predicate

Suppose that bean ManagerBean is defined as a subtype of EmpBean and ExecutiveBean is a subtype of ManagerBean in an EJB inheritance hierarchy.

The following query returns employees as well as managers and executives:

SELECT  OBJECT(e) FROM EmpBean e

If we are interested in objects which are employees and not managers and not executives:

SELECT OBJECT(e) FROM EmpBean e WHERE e IS OF TYPE( ONLY EmpBean )

If we are interested in object which are managers or executives:

SELECT OBJECT(e) FROM EmpBean e WHERE e IS OF TYPE( ManagerBean)
The above query is equivalent to the following query:

SELECT  OBJECT(e) FROM ManagerBean e

If we are interested in managers only and not executives:

SELECT  OBJECT(e) FROM  EmpBean e WHERE e IS OF TYPE( ONLY ManagerBean)
or:

SELECT  OBJECT(e) FROM  ManagerBean e WHERE  e IS OF TYPE (ONLY ManagerBean)




Related concepts


EJB query language
WHERE clause

 

Related tasks


Use EJB query