Hibernate version : 3.3.1
We're encountering heavy performance problems that have been traced back to implicit conversion of query parameters, that cause SQL Server to ignore indexes and force it to recalculate query plans every single time.
All of the String fields in our application are mapped to varchar(255) through automatic schema generation. Yet all string parameters in queries, when executed, are translated to nvarchar(4000), which causes implicit conversion in SQL Server.
This seems to be a common problem in NHibernate : http://stackoverflow.com/questions/6626394/how-does-one-make-nhibernate-stop-using-nvarchar4000-for-insert-parameter-stri http://zvolkov.com/clog/2009/10/28?s=NHibernate+parameter+sizes+controversy
But we're using Hibernate. I've found this thread (http://stackoverflow.com/questions/5237280/getting-hibernate-and-sql-server-to-play-nice-with-varchar-and-nvarchar) that offers a solution to go from nvarchar(4000) to varchar(8000), but what we'd like is to match query parameter types and column types.
Is this possible ?
Thanks in advance.
|