Usually you would do an equi-join between two simple fields of the same type like: select * from /Groups g, /Privileges p where p.Id=g.Id
select * from /Groups g, /Privileges p where p.Id=g.Id
where, the ID field in both regions are of type Integer.
But what if the relation between domain objects is one to many instead of one to one? This could be represented by a List of Integers on one of the objects. In this case it is not possible to join the List and Integer directly without a little tweak of the OQL:
select * from /Groups g, g.privID pid, /Privileges p where p.Id=pid
The general principle for navigating collections is by defining the collection with an alias in the FROM clause and then accessing the contained fields in the Where predicates. This OQL statement will return entries where Privilege ID, which is a simple Integer, is present in the Group List of Integers.
The attached zip contains 6 simple classes that show the join in action.
To run the sample follow these steps:
ListJoinLocator change the GemFire system property to reflect the GemFire installation locally ListJoinLocator.ListJoinGemFireServerListJoinDataPutter to generate test data in the regionsListJoinQueryClient to execute the join queryThere are no cache.xml files needed and configuration is done in Java. The server log is written to the project directory.