I have written a query string for SQL Server I am executing as a NativeSQLQuery. I used indexed parameter binding and things are working perfectly until I bind a search parameter that is unicode. Then the match just fails. In my JDBC connection, I have the parameter set: sendStringParametersAsUnicode=false. If I remove this the query works fine. I set this because it was sending all parameters as unicode and causing full table scans since some columns were not unicode at all. The server then reported possible deadlocks. Once I set this the system started working fine.
As I bind my parameters to my query, is there any way I can give the query a hint to treat as unicode? I see where if I were using string literals I could do something like "mycolumn = N’somevalue’. Is there any way I can give it such a hint when binding my parameter?