* side criteria of the right hand expression of AND
* criteria of the ON expression of the join
* @return a join predicate object
*/
public static JoinPredicate example(JoinType joinType, String joinOnElement, String andJoinOnElement) {
JoinPredicate jp = example(joinType, joinOnElement);
List<Criteria> joinCrits = jp.getJoinCriteria();
List<Object> newJoinCrits = new ArrayList<Object>(1);
Expression le = new ElementSymbol("m.g1." + andJoinOnElement); //$NON-NLS-1$
Expression re = new ElementSymbol("m.g2." + andJoinOnElement); //$NON-NLS-1$
Criteria c1 = new CompareCriteria(le, CompareCriteria.EQ, re);
Iterator<Criteria> ci = joinCrits.iterator();
if (!ci.hasNext()) {
newJoinCrits.add(c1);
}
while (ci.hasNext()) {
Criteria crit = ci.next();
if ( ci.hasNext() ) newJoinCrits.add(crit);
else {
Criteria compundCrit = new CompoundCriteria(CompoundCriteria.AND, crit, c1);
newJoinCrits.add(compundCrit);
}
}
jp.setJoinCriteria(newJoinCrits);
return jp;
}