Hi. I am having some issues trying to get my query (which contains named parameters) to work successfully. Consider the query;
SELECT * FROM A WHERE A.COL = :myParam
In my code I am setting the named parameter depending on some user input, in one case it is set such as;
Query sqlQuery = session.getNamedQuery("QueryName");
sqlQuery.setString("myParam", "M");
and that works fine. But when I want to retrieve all rows where the COL value is equal to '' then I can't get it to work. I have tried (individually);
sqlQuery.setString("myParam", null);
sqlQuery.setString("myParam", ""); // 2 double quotes
sqlQuery.setString("myParam", "''"); // double quote, 2 single quotes, double quote
None of those work, the query runs fine but it is returning 0 rows. Is there a way to set the named parameter to be an empty string?
Hibernate version: 3.1.3
Name and version of the database you are using: SQLServer 7
|