JPA
Order By with Character Set Issue.
I use spring-data-jpa
and mysql 5.7
. My db character set is utf8mb4
for I need store emoji in table.
Here is my table:
+--------------------+--------------+------+-----+-------------------+-----------------------------+
| Field | Type | Null | Key | Default | Extra |
+--------------------+--------------+------+-----+-------------------+-----------------------------+
| id | varchar(50) | NO | PRI | NULL | |
| name | varchar(100) | NO | | NULL | |
| content | varchar(100) | NO | | NULL | |
| status | varchar(20) | NO | MUL | DEFAULT | |
| type | varchar(50) | NO | MUL | DEFAULT | |
+--------------------+--------------+------+-----+-------------------+-----------------------------+
I want to select item and order by name with Chinese character order. Item name can be emoji and Chinese string.
I can do this if use native sql :
select * from item where name like ? order by convert(name using gbk);
Is it possible to use convert(name using gbk)
in JPA Specification?