org.hibernate.util.JDBCExceptionReporter — недопустимая сортировка ‘latin1_general_ci’. с помощью MariaDB

#spring #hibernate #mariadb #collation

#spring #переход в спящий режим #mariadb #сортировка

Вопрос:

Ребята, я пытаюсь интегрировать свое приложение с MariaDB, я создал предполагаемую базу данных и таблицу в соответствии с моими требованиями, а также вставил демонстрационные данные для тестирования приложения.

При запуске приложения я должен прочитать некоторые значения конфигурации из базы данных, чтобы запустить систему.

При чтении данных из одной из таблиц я получаю

 org.hibernate.util.JDBCExceptionReporter - Invalid collation 'latin1_general_ci'. 
  

Я также должен проверить сопоставление базы данных и таблицы —

Для базы данных —

 SELECT @@character_set_database, @@collation_database;


 -------------------------- ---------------------- 
| @@character_set_database | @@collation_database |
 -------------------------- ---------------------- 
| utf8                     | utf8_general_ci      |
 -------------------------- ---------------------- 
  

Для таблицы

 SHOW FULL COLUMNS FROM USM_CONFIGURATION;

 --------------------- -------------- ----------------- ------ ----- --------- ---------------- --------------------------------- --------- 
| Field               | Type         | Collation       | Null | Key | Default | Extra          | Privileges                      | Comment |
 --------------------- -------------- ----------------- ------ ----- --------- ---------------- --------------------------------- --------- 
| ID                  | bigint(20)   | NULL            | NO   | PRI | NULL    | auto_increment | select,insert,update,references |         |
| ELEMENT_TYPE        | int(11)      | NULL            | NO   |     | NULL    |                | select,insert,update,references |         |
| INTERNAL_NAME       | varchar(64)  | utf8_general_ci | NO   |     | NULL    |                | select,insert,update,references |         |
| PARENT_ID           | bigint(20)   | NULL            | YES  | MUL | NULL    |                | select,insert,update,references |         |
| CONFIGURATION_ORDER | int(11)      | NULL            | YES  |     | NULL    |                | select,insert,update,references |         |
| HIDDEN              | smallint(6)  | NULL            | NO   |     | NULL    |                | select,insert,update,references |         |
| READ_ONLY           | smallint(6)  | NULL            | NO   |     | NULL    |                | select,insert,update,references |         |
| REMOVABLE           | smallint(6)  | NULL            | NO   |     | NULL    |                | select,insert,update,references |         |
| ALLOW_BLANK         | smallint(6)  | NULL            | NO   |     | NULL    |                | select,insert,update,references |         |
| PREFERENCE          | smallint(6)  | NULL            | NO   |     | NULL    |                | select,insert,update,references |         |
| TEMPLATE            | smallint(6)  | NULL            | NO   |     | NULL    |                | select,insert,update,references |         |
| DISPLAY_NAME_KEY    | varchar(64)  | utf8_general_ci | YES  |     | NULL    |                | select,insert,update,references |         |
| DISPLAY_NAME        | varchar(256) | utf8_general_ci | YES  |     | NULL    |                | select,insert,update,references |         |
| DISPLAY_WIDTH       | int(11)      | NULL            | YES  |     | NULL    |                | select,insert,update,references |         |
| DESCRIPTION_KEY     | varchar(256) | utf8_general_ci | YES  |     | NULL    |                | select,insert,update,references |         |
| DEFAULT_KEY         | varchar(64)  | utf8_general_ci | YES  |     | NULL    |                | select,insert,update,references |         |
| DEFAULT_VALUE       | float        | NULL            | YES  |     | NULL    |                | select,insert,update,references |         |
| USAGE_NOTE          | varchar(256) | utf8_general_ci | YES  |     | NULL    |                | select,insert,update,references |         |
| VALIDATION_CLASS    | varchar(256) | utf8_general_ci | YES  |     | NULL    |                | select,insert,update,references |         |
| OWNER               | varchar(64)  | utf8_general_ci | YES  |     | NULL    |                | select,insert,update,references |         |
| UPDATE_DATE         | datetime     | NULL            | YES  |     | NULL    |                | select,insert,update,references |         |
| NS_THREAD           | int(11)      | NULL            | NO   | MUL | NULL    |                | select,insert,update,references |         |
| NS_LEFT             | int(11)      | NULL            | NO   |     | NULL    |                | select,insert,update,references |         |
| NS_RIGHT            | int(11)      | NULL            | NO   |     | NULL    |                | select,insert,update,references |         |
| VERSION             | int(11)      | NULL            | YES  |     | 0       |                | select,insert,update,references |         |
 --------------------- -------------- ----------------- ------ ----- --------- ---------------- --------------------------------- --------- 
  

Как в базе данных, так и в таблице я не смог увидеть сопоставление latin1_general_ci.

Почему я получаю эту ошибку, есть ли что-нибудь, что я пропустил при установке DB или создании DB.

Я проверил эту ошибку в SO answers и других блогах и не смог найти никакого конкретного решения.

Ответ №1:

 spring.jpa.properties.hibernate.connection.characterEncoding=utf-8
spring.jpa.properties.hibernate.connection.CharSet=utf-8
spring.jpa.properties.hibernate.connection.useUnicode=true