JPQL中是否有等同于SQL BINARY
的运算符?
我在谷歌上搜索了很多,发现没有人提到它。
提前致谢!
对于 BINARY 运算符,这里是 MySQL site 中的描述.
The BINARY operator casts the string following it to a binary string.
This is an easy way to force a column comparison to be done byte by byte
rather than character by character. This causes the comparison to be case
sensitive even if the column is not defined as BINARY or BLOB. BINARY also
causes trailing spaces to be significant.
mysql> SELECT 'a' = 'A';
-> 1
mysql> SELECT BINARY 'a' = 'A';
-> 0
mysql> SELECT 'a' = 'a ';
-> 1
mysql> SELECT BINARY 'a' = 'a ';
-> 0
BTY,我正在使用MySql 5.6。(虽然我不认为这个问题与MySql有关...)
最佳答案
我仍然无法在 JPQL 中找到 BINARY
的等效运算符。
但是如果你遇到这个问题,有一个解决方法:
在 JPA 中,只需使用 em.createNativeQuery()
就可以使用 SQL,因此您可以使用 BINARY
运算符。
像这样:
em.createNativeQuery("SELECT * FROM Student WHERE name=binary'"+ stuName+"'").getResultList();
只为遇到同样问题的人提供解决方案。
关于mysql - JPQL中的BINARY运算符等价的是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21181192/