+

Search Tips   |   Advanced Search

EJB Query XREL keyword


The XREL keyword is used to build relationships independent of how the data was retrieved. XREL is valid only in EJBs Mediator queries. XREL does not retrieve additional data, it only builds relationships from data already retrieved by the select statements. The relationships can be one-to-one, one-to-many, many-to-one, or many-to-many. The relationships can be unidirectional or bidirectional. If we specify a bidirectional relationship in an XREL, the inverse relationship is also established in addition to the specified relationship.

xrel := XREL identification_variable . { single_valued_cmr_field | collection_valued_cmr_field }
              [ , identification_variable . { single_valued_cmr_field | collection_valued_cmr_field } ]*

 

Examples: XREL keyword

This example retrieves all employees and all departments, and establishes the emps and mgr relationships.

select e.name from EmpBean e
  select  d.name from DeptBean d
  xrel  d.emps, d.mgr

Notice that the employees are retrieved through d.emps relationship, xrel d.mgr is to establish the mgr relationship for those employees who are also a manager.

 select  d.name from DeptBean d
   select e.name from in(d.emps) e
   xrel  d.mgr  




Related concepts


EJB query language

 

Related tasks


Use EJB query
Use the dynamic query service