Cayenne chain-chank problem

From: ςΡΒΙΓΛΙΚ εΧΗΕΞΙΚ (eryabitski..iasoft.ru)
Date: Fri May 21 2010 - 07:36:50 UTC

  • Next message: Andrus Adamchik: "Re: Cayenne chain-chank problem"

    Hello, here is example from tutorial for 2.0:

    String sql = "SELECT DISTINCT"
       + " #result('ARTIST_ID' 'int'),"
       + " #result('ARTIST_NAME' 'String'),"
       + " #result('DATE_OF_BIRTH' 'java.util.Date')"
       + " #result('IS_DEAD' 'java.util.Boolean')"
       + " FROM ARTIST t0"
       + " #chain('OR' 'WHERE') // start chain prefixed by WHERE,
                                                             // and joined by OR
       + " #chunk($name) ARTIST_NAME LIKE #bind($name) #end" //ARTIST_NAMEchunk"
       + " #chunk($id) ARTIST_ID > #bind($id) #end" // ARTIST_ID chunk"
       + " #chunk($isDead) IS_DEAD = #bind($isDead) #end" // IS_DEAD chunk"
       + " #end"; // end of chain
    SQLTemplate select = new SQLTemplate(Artist.class, sql, true);

    If I put in isDead true - everything is ok, but if I put false I got chat this condition is skipper because #chunk is actually checking condition of $isDead.

    Same thing if I put 0 in $id it will be false.

    So this example of tutorial is bad for Dead Artists or Artists with id == 0.
    Maybe it's a bug of #chunk directive and it should do only null check??

    Evgeny.



    This archive was generated by hypermail 2.0.0 : Fri May 21 2010 - 07:48:25 UTC