[hibernate-dev] sanitize input

tibi at dds.nl tibi at dds.nl
Wed Sep 28 10:25:43 EDT 2011



hi,

i have a strange problem.

when i sanitize my inputs the index is not used any more.

details:
i use mssql 2005
i have a query like this:

//NOT USING THE INDEX!
String queryStr = "select * from USER_ING_EOM with  
(index(NON_CLUSTERD_INDEX_MAIL)) ";
         queryStr += " where MAIL=? ";
         final Query query = session.createSQLQuery(queryStr);
         query.setText(0, content.getManagerEmail1());
         final List result = query.list();

//USING THE INDEX FINE!
String queryStr = "select * from USER_ING_EOM with  
(index(NON_CLUSTERD_INDEX_MAIL)) ";
         queryStr += " where MAIL='" + content.getManagerEmail1();
         final Query query = session.createSQLQuery(queryStr);
         query.setText(0, content.getManagerEmail1());
         final List result = query.list();

first i had hsql but that was not using the index either.

could it be that the sanitizing makes it unpossible for mssql 2005 to  
use the index?


thanks

tibi




More information about the hibernate-dev mailing list