有人可以建议如何在java MYSQL(Hibernate)中使用utf8来搜索“à,ç”等特殊字符。
我试过这样的话:
StringBuilder lSql = new StringBuilder("select count(s.id) from SampleTable s where s.deleted = false");
if (lSearchterm != null) {
lSql.append(" and ((UPPER(s.name) like :lSearchterm))");
}
Query lQuery = em.createQuery(lSql.toString());
if (lSearchterm != null) {
lQuery.setParameter("lSearchterm", '%' + lSearchterm.toUpperCase() + "COLLATE utf8_bin" + '%');
}
提前感谢您的帮助。