Re: ExtendedType and IN operator

From: Chris Gamache (cgamach..mail.com)
Date: Tue Nov 27 2007 - 16:56:09 EST

  • Next message: Oilid Adsi: "Cayenneand Thread-Bound DataContext"

    Exact Cayenne Version is 2.0.3

    Here's the query builder...

            public static List selectMulti(final DataContext context,final
    ArrayList<UUID> userUuids, final Date fromDate, final Date toDate,
    final int status) {
                    
                    ArrayList<Expression> expList = new ArrayList<Expression>();
                    
                    //this is where the trouble is...
                    if (userUuids != null && userUuids.size() > 0)
    expList.add(ExpressionFactory.inExp(TodOrders.USER_UUID_PROPERTY,
    userUuids));

                    
                    if (fromDate != null && toDate != null) {
                            expList.add(ExpressionFactory.betweenExp(TodOrders.TRANS_DATE_PROPERTY,
    fromDate, toDate));
                    } else if (fromDate != null && toDate == null) {
                            expList.add(ExpressionFactory.greaterOrEqualExp(TodOrders.TRANS_DATE_PROPERTY,
    fromDate));
                    } else if (fromDate == null && toDate != null) {
                            expList.add(ExpressionFactory.lessOrEqualExp(TodOrders.TRANS_DATE_PROPERTY,
    toDate));
                    }
                    
                    if (status == 1) {
                            expList.add(ExpressionFactory.matchExp(TodOrders.FULFILLED_PROPERTY, null));
                    } else if (status == 2) {
                            expList.add(ExpressionFactory.noMatchExp(TodOrders.FULFILLED_PROPERTY,
    null));
                    }
                    SelectQuery orderQuery = new
    SelectQuery(TodOrders.class,ExpressionFactory.joinExp(Expression.AND,
    expList));
                    orderQuery.addOrdering(new Ordering(TodOrders.TRANS_DATE_PROPERTY, true));
                    
                    return context.performQuery(orderQuery);

            }

    On Nov 26, 2007 7:42 AM, Andrus Adamchik <andru..bjectstyle.org> wrote:
    > Chris,
    >
    > I vaguely remember this being a problem in the past and us fixing
    > it... I couldn't find any references via Google (having "IN" as a
    > keyword doesn't help). So could you post the code that builds the
    > query and the exact Cayenne version.
    >
    > Thanks
    > Andrus
    >
    >
    >
    > On Nov 23, 2007, at 3:39 AM, Chris Gamache wrote:
    >
    > > I'm using Cayenne2 and PostgreSQL.
    > >
    > > For any single R-value in a where clause, my ExtendedType is working
    > > wonderfully. But! If I create an expression which uses the operator
    > > IN, my ExtendedType doesn't seem to get called. In the query logger
    > > everything looks okay, but pgjdbc complains in the same way that it
    > > would if there were no exended type. That leads me to believe either
    > > that Cayenne is ignoring ExtendedTypes when it does the JDBC binding
    > > for the R-value list, or that I've left out a detail in my
    > > ExtendedType class which is the culprit. I can post my ExtendedType
    > > code and some code that misbehaves. Will that suffice, or would you
    > > need more?
    > >
    > > CG
    > >
    >
    >



    This archive was generated by hypermail 2.0.0 : Tue Nov 27 2007 - 16:57:09 EST