throw new EJBQLException(
"Second child of the MEMBER OF must be a collection path, got: "
+ expression.getChild(1));
}
EJBQLPath path = (EJBQLPath) expression.getChild(1);
// make sure the ID for the path does not overlap with other condition
// joins...
String id = path.getAbsolutePath();
String correlatedEntityId = path.getId();
ClassDescriptor correlatedEntityDescriptor = context
.getEntityDescriptor(correlatedEntityId);
String correlatedTableName = correlatedEntityDescriptor
.getEntity()
.getDbEntity()
.getFullyQualifiedName();
String correlatedTableAlias = context.getTableAlias(
correlatedEntityId,
correlatedTableName);
String subqueryId = context.createIdAlias(id);
ClassDescriptor targetDescriptor = context.getEntityDescriptor(subqueryId);
if (expression.isNegated()) {
context.append(" NOT");
}
context.append(" EXISTS (SELECT 1 FROM ");
String subqueryTableName = targetDescriptor
.getEntity()
.getDbEntity()
.getFullyQualifiedName();
String subqueryRootAlias = context.getTableAlias(subqueryId, subqueryTableName);
ObjRelationship relationship = (ObjRelationship) correlatedEntityDescriptor
.getEntity()
.getRelationship(path.getRelativePath());
if (relationship.getDbRelationshipPath().contains(".")) {
// if the DbRelationshipPath contains '.', the relationship is flattened
subqueryRootAlias = processFlattenedRelationShip(
subqueryRootAlias,