I have a Query in hibernate which I believe is because of the VARCHAR and NVARCHAR discrepancies in the driver and MsSql discussed here Getting Hibernate and SQL Server to play nice with VARCHAR and NVARCHAR. I understand that this issue is not with Hibernate but am confused by the way hibernate deals with the code below .
When we ran the Queries below (using set parameter and without it), on a DB with VARCHAR column type for the column 'code' , we found that appending the string in HQL works lot faster that setParameter(or Criteria Query which should have been faster than HQL) .
Query createQuery = session.createQuery("from abc where code='"+substring+"'");
/*Query createQuery = session.createQuery("from abc where code=:substring");
createQuery.setParameter("substring","Test");*/
return createQuery.list();
Please let me know how this would make a difference.