Is andExp supported on Scalar booleans?

From: Øyvind Harboe (oyvind.harbo..ylin.com)
Date: Wed Aug 16 2006 - 16:47:23 EDT

  • Next message: Øyvind Harboe: "Cayenne does not throw an exception when an outer join is attempted"

    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
    



    This archive was generated by hypermail 2.0.0 : Wed Aug 16 2006 - 16:47:49 EDT