Building expression from Null strings

From: Cyril Godefroy (cgodefro..ac.com)
Date: Tue Oct 12 2004 - 09:35:14 EDT

  • Next message: Eric Schneider: "Re: Building expression from Null strings"

    I'm trying to do something around this:

    Expression qual = generateLikeExp("firstName", getSearchFirstName());
             qual =qual.andExp(generateLikeExp("lastName",
    getSearchLastName()));
             qual =qual.andExp(generateLikeExp("userName",
    getSearchUserName()));
             qual =qual.andExp(generateLikeExp("email", getSearchEmail()));
             SelectQuery query = new SelectQuery(Customer.class, qual);
    ...

        public Expression generateLikeExp(String attribute, String
    searchString){
             if(!searchString.equals("") && searchString != null){
                 return ExpressionFactory.likeIgnoreCaseExp(attribute, "%" +
    searchString + "%");
             } else {
                 return null;
             }
         }

    You see where this leads me... If getFirstName() returns null, then
    andExp() cannot be called on a null object.

    Is there an obvious way to go around this problem that I am not seeing?

    Tia,
    Cyril





    This archive was generated by hypermail 2.0.0 : Tue Oct 12 2004 - 09:35:25 EDT