I'm having some trouble to join 2 expressionList with an "or". This is an example of what I'm doing:
RelationGroup prg =...
ExpressionList<User> exp = User.find.where();
List<ExpressionList<User>> expressions = new ArrayList<ExpressionList<User>>()
List<String> relations = new ArrayList<String>()
while(prg != null){
if(prg.prevGroupRelation != null)
relations.add(prg.prevGroupRelation);
for(RelationAtt pra : prg.prAtt){
if(pra.rel.equals("eq"))
exp = exp.eq(pra.name, pra.value1 );
else if(pra.rel.equals("lt"))
exp = exp.lt(pra.name, pra.value1);
else if(pra.rel.equals("gt"))
exp = exp.gt(pra.name, pra.value1);
else if(pra.rel.equals("bw"))
exp = exp.gt(pra.name, pra.value1).lt(pra.name, pra.value2);
}
expression.add(exp);
prg=prg.nextPRG();
exp = new ExpressionList<User>();
}
for(i=0;i<expressions.count-1; i++)
if(relations[i].equals("or")){
//ToDo: (expressions[i]) or (expressions[i+1])
}else{
//ToDo: (expressions[i]) and (expressions[i+1])
}
I need to have something like:
select *
from tableName
where (varName1=value and varName2=value) or (varName3) or (varName4=value and varName5=value)
This is fully dynamic so the varNames can be any of the currently existing(because the queries are build by the user using a web page interface), so i can't use raw SQL that easily. Now i need to join prevExp and exp with an or/and and replace exp. The ExpressionList.or(exp, exp)
receive 2 Expressions.
Any help with this is appreciated thank you