当我尝试使用Hibernate执行以下查询时,我遇到以下错误:
从数据类型varchar到varbinary的隐式转换不是 允许。使用CONVERT函数运行此查询。
String sql = "select distinct t.titleNo from Ties t ,Titles se,TieType TT ,Net NTT "
+" where t.seriesNo = se.titleNo and t.titleType=TT.titleType and TT.titleTypeNo = NTT.titleTypeNo "
+" and ((((t.titleName LIKE '%'+:titleName+'%') OR (:titleName LIKE '%'+ t.titleName+'%')) AND (ISNULL(TT.titleBaseType,'') ='') "
+" And Isnull(:titleBaseType,'') <> 'N') "
+" OR (((t.titleName LIKE :titleName) OR (:titleName LIKE t.titleName)) AND (ISNULL(TT.titleBaseType,'') ='N'))) "
+" AND (IsNull(se.titleName,'%') like CASE WHEN (:seriesNo>0) THEN (SUBSTRING(LTRIM(:seriesName),1,6)+'%') ELSE '%' END)";
Query qry = session.createSQLQuery(sql);
qry.setParameter("titleName", titleName); //String
qry.setParameter("seriesNo", seriesNo); //Integer
qry.setParameter("titleBaseType", titleBaseType); //String
qry.setParameter("seriesName", seriesName); //String
qry.list();
如何避免此错误?