我得到我的查询此错误消息..我使用的OpenJPA和SQL Server为我的数据库中指定...无效转义字符“\”在LIKE谓词
这是我的查询:
public static List<ProcesosGeneralEntity> getALLbyProductor(String productor){
Query q = entityManager.createQuery("select a from ProcesosGeneralEntity a where a.productor like :productor ");
q.setParameter("productor", '%'+productor+'%');
List<ProcesosGeneralEntity>resultado=q.getResultList();
List<ProcesosGeneralEntity>result2=new ArrayList<ProcesosGeneralEntity>(resultado);
return result2;
}
这听起来像OpenJPA的不正确地转义产品线,作为一个来源,我发现指出, Oracle数据库的转义字符是'\',因此为了避免引用'\'',并且转义反斜杠'\\'。而在SQL Server中,单引号的转义字符是另一个引号,如''''中的。所以听起来好像你有一个'productor'字符串,它包含一个'\',该OpenJPA正在转义为'\\'。解决方案可能是您需要指定您的'openjpa.jdbc.DBDictionary'配置设置为'sqlserver'。 –