r1779 - trunk/topia-persistence/src/main/java/org/nuiton/topia/framework
Author: fdesbois Date: 2010-01-25 20:09:13 +0100 (Mon, 25 Jan 2010) New Revision: 1779 Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaQuery.java Log: Ano #243 : the null is managed in TopiaQuery in add method if the paramValue is null Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaQuery.java =================================================================== --- trunk/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaQuery.java 2010-01-24 23:37:05 UTC (rev 1778) +++ trunk/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaQuery.java 2010-01-25 19:09:13 UTC (rev 1779) @@ -269,7 +269,9 @@ /** LESS OR EQUALS **/ LE("<="), /** IS NOT NULL **/ - NOT_NULL("IS NOT NULL"); + NOT_NULL("IS NOT NULL"), + /** IS NULL **/ + NULL("IS NULL"); protected String value; @@ -498,6 +500,8 @@ * Add an element to the query. The parameter will be automatically added. * The constraint is needed to determine what type of operation it is. * Ex : add("boat", Op.EQ, boat) means -> boat = :boat. + * If the paramValue is Null, the paramName will be added to the query + * with the constraint null (IS NULL). * * @param paramName the name of the parameter in the query (attribute of * the entity) @@ -506,6 +510,9 @@ * @return the TopiaQuery */ public TopiaQuery<E> add(String paramName, Op constraint, Object paramValue) { + if (paramValue == null) { + return add(paramName + " " + Op.NULL); + } String valueName = getValueName(paramName); parentheses = false; return add(paramName + " " + constraint + " :" + valueName).addParam(valueName, paramValue);
participants (1)
-
fdesbois@users.nuiton.org