是否有与SQL BINARY等效的JPQL中的运算符?
我在谷歌上搜索了很多,发现没有人提到它。
提前感谢!
对于二进制操作符,下面是在MySQL站点.中的描述
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有关.)
发布于 2014-01-22 02:39:27
我仍然找不到BINARY在JPQL中的等价运算符。
但是如果你遇到这个问题,你会发现一个问题:
在JPA中,只需使用em.createNativeQuery(),就可以使用BINARY操作符。如下所示:
em.createNativeQuery("SELECT * FROM Student WHERE name=binary'"+ stuName+"'").getResultList();只要给那些有同样问题的人一个解决办法。
发布于 2014-04-13 22:11:38
在JPA2.0中,@nosnhoj提到的解决方案是唯一有效的解决方案,直到您想要更改数据库或表的排序规则为止。我对JPA2.1不太确定。谢谢你的帮助。
https://stackoverflow.com/questions/21181192
复制相似问题