[英]HQL - Querying by email or string with dot('.') is always returning empty set
This is my HQL Query 这是我的HQL查询
Query query = getCurrentSession().createQuery(
"from User where username = :usersName ");
query.setParameter("usersName", usersName);
Now if the user name contains dot'.' 现在,如果用户名包含点'。 character its returning empty set other wise its returning the user details.
字符,返回空集,否则返回用户详细信息。
What I have tried? 我尝试了什么?
Hibernate having difficulty with '@' character in HQL
Hibernate在HQL中难以使用'@'字符
Executed the sql query in the server its returning the user details.
在服务器中执行sql查询,返回用户详细信息。
Concatenated the parameters directly in query string getting same error.
直接将参数串联在查询字符串中会得到相同的错误。
Tried Criteria Query Got the same problem
尝试过的条件查询遇到了同样的问题
where might be the problem? 问题可能出在哪里?
尝试使用此方法: query.setString("usersName", usersName);
You can try this: 您可以尝试以下方法:
query.setString("usersName", usersName.replaceAll("@", "/@"));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.