I'm getting an exception when I try to invoke andExp() on a Scalar expression:

Expression e=new ASTScalar(Boolean.TRUE);
e=e.andExp(ExpressionFactory.matchExp(propName + (i+1), t));

[v.1.2-dev July 19 2006] And: invalid child - Scalar
org.objectstyle.cayenne.exp.parser.AggregateConditionNode.jjtAddChild(AggregateConditionNode.java:125)
org.objectstyle.cayenne.exp.parser.SimpleNode.setOperand(SimpleNode.java:187)
org.objectstyle.cayenne.exp.Expression.joinExp(Expression.java:395)
org.objectstyle.cayenne.exp.Expression.andExp(Expression.java:405)

Some fiendishly clever code to work around horrid database structures
for implementing trees:

        /* returns the non-recursive list of children based upon the old
scheme for trees */
        public Expression getChildrenQualifierGeneric(
                        /* Name of property without the number suffix, e.g. 
"treataspecVc" */
                        String propName,
                        /* total number of levels, for e.g. treataspecVc==5 */
                        int totLevels)
        {
                try
                {
                        OgnlContext context = new OgnlContext();
                        Expression e=new ASTScalar(Boolean.TRUE);
                        
                        for (int i=0; i<totLevels; i++)
                        {
                                Object propObj;
                                propObj = Ognl.parseExpression(propName + 
(i+1));
                                String t=(String) Ognl.getValue(propObj, 
context, this);
                                if (t==null)
                                {
                                        
e=e.andExp(ExpressionFactory.noMatchExp(propName + (i+1), null));
                                        
e=e.andExp(ExpressionFactory.matchExp(propName + (i+2), null));
                                        return e;
                                } else if ((i+1)<totLevels)
                                {
                                        
e=e.andExp(ExpressionFactory.matchExp(propName + (i+1), t));
                                }
                        }
                        return new ASTScalar(Boolean.FALSE);
                } catch (OgnlException e)
                {
                        throw new RuntimeException(e);
                }
        }


--
Øyvind Harboe
http://www.zylin.com

Reply via email to