T
this is not my name
I've been using iBatis sql maps in my J2EE application with great
results so far, but I've come across a bit of a roadblock, and my usual
savior, Google, hasn't been able to help me out of this one. The one
hits that seems to be exactly what I am looking for seems to have
vanished from the web:
http://www.mail-archive.com/[email protected]/msg00284.html
I can't seem to get queries that use the LIKE operator to work.
According to the sqlmap docs, this should work:
SELECT * FROM PRODUCT WHERE PRD_DESCRIPTION LIKE '%dog%'
OR
SELECT * FROM PRODUCT WHERE PRD_DESCRIPTION LIKE #value#
// description property == "%dog%"
When I run the SQL against my MySql db, I get results. When I run the
SQL using sqlMaps (substituting my String and the % operators for
#value#), I get no results. Here is my SQL (with table/column names
replaced):
select count(*) myCount from table_t
where field_f like '%45111q%'
in my sqlmap XML file, I have this SQL:
select count(*) myCount from table_t
where field_f like #value#
// (I know string appends waste mem)
I am passing in a String like this: String s = "%" + someStr + "%"
I have tried specifiying the parameterClass as java.lang.String as well
as not specifying at all.
I suspect the % sign is being escaped somehow, but cannot determine
this. Both my logging and MySQLs loggnig just show ? in the statement.
SqlMap logging shows this:
PreparedStatementLogProxy - {pstm-100121} Parameters:
[%h80111n6gb111c31o8zezojqdh111111%]
Has anyone managed to use LIKE successfully? It would be a huge help to
overcome this problem.
Thanks,
-BR
results so far, but I've come across a bit of a roadblock, and my usual
savior, Google, hasn't been able to help me out of this one. The one
hits that seems to be exactly what I am looking for seems to have
vanished from the web:
http://www.mail-archive.com/[email protected]/msg00284.html
I can't seem to get queries that use the LIKE operator to work.
According to the sqlmap docs, this should work:
SELECT * FROM PRODUCT WHERE PRD_DESCRIPTION LIKE '%dog%'
OR
SELECT * FROM PRODUCT WHERE PRD_DESCRIPTION LIKE #value#
// description property == "%dog%"
When I run the SQL against my MySql db, I get results. When I run the
SQL using sqlMaps (substituting my String and the % operators for
#value#), I get no results. Here is my SQL (with table/column names
replaced):
select count(*) myCount from table_t
where field_f like '%45111q%'
in my sqlmap XML file, I have this SQL:
select count(*) myCount from table_t
where field_f like #value#
// (I know string appends waste mem)
I am passing in a String like this: String s = "%" + someStr + "%"
I have tried specifiying the parameterClass as java.lang.String as well
as not specifying at all.
I suspect the % sign is being escaped somehow, but cannot determine
this. Both my logging and MySQLs loggnig just show ? in the statement.
SqlMap logging shows this:
PreparedStatementLogProxy - {pstm-100121} Parameters:
[%h80111n6gb111c31o8zezojqdh111111%]
Has anyone managed to use LIKE successfully? It would be a huge help to
overcome this problem.
Thanks,
-BR