У меня проблема с отображением базы данных H2 в режиме MySQL.
CREATE TABLE `USER_BOOKING` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`booker_id` varchar(36) NOT NULL,
`booking_id` varchar(20) NOT NULL,
UNIQUE KEY `id_booker_with_booking` (`booker_id`,`booking_id`),
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
Использование MyBatis для выбора таких данных:
@Select(" select (`booker_id`, `booking_id`) "
+ " from `USER_BOOKING` "
+ "where `booker_id` = #{bookerId};")
@Results(value = {
@Result(column = "booker_id", property = "bookerId", javaType = String.class, jdbcType = JdbcType.VARCHAR),
@Result(column = "booking_id", property = "bookingId", javaType = String.class, jdbcType = JdbcType.VARCHAR),
})
List<UserActivityModel> getBookerActivity(@Param("bookerId") String bookerId);
Вызов getBookerActivity
заканчивается этим исключением:
### Error querying database. Cause: org.h2.jdbc.JdbcSQLNonTransientException: General error: "java.lang.RuntimeException: type=39" [50000-200]
### The error may exist in com/blablacar/user/activity/infrastructure/UserActivityWriteStorage.java (best guess)
### The error may involve com.blablacar.user.activity.infrastructure.UserActivityWriteStorage.getBookerActivity
### The error occurred while handling results
### SQL: select (`booker_id`, `booking_id`) from `USER_BOOKING` where `booker_id` = ?;
### Cause: org.h2.jdbc.JdbcSQLNonTransientException: General error: "java.lang.RuntimeException: type=39" [50000-200]
; uncategorized SQLException; SQL state [HY000]; error code [50000]; General error: "java.lang.RuntimeException: type=39" [50000-200]; nested exception is org.h2.jdbc.JdbcSQLNonTransientException: General error: "java.lang.RuntimeException: type=39" [50000-200]
org.springframework.jdbc.UncategorizedSQLException:
### Error querying database. Cause: org.h2.jdbc.JdbcSQLNonTransientException: General error: "java.lang.RuntimeException: type=39" [50000-200]
### The error may exist in com/blablacar/user/activity/infrastructure/UserActivityWriteStorage.java (best guess)
### The error may involve com.blablacar.user.activity.infrastructure.UserActivityWriteStorage.getBookerActivity
### The error occurred while handling results
### SQL: select (`booker_id`, `booking_id`) from `USER_BOOKING` where `booker_id` = ?;
### Cause: org.h2.jdbc.JdbcSQLNonTransientException: General error: "java.lang.RuntimeException: type=39" [50000-200]
; uncategorized SQLException; SQL state [HY000]; error code [50000]; General error: "java.lang.RuntimeException: type=39" [50000-200]; nested exception is org.h2.jdbc.JdbcSQLNonTransientException: General error: "java.lang.RuntimeException: type=39" [50000-200]
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:89)
...
Caused by: org.h2.jdbc.JdbcSQLNonTransientException: General error: "java.lang.RuntimeException: type=39" [50000-200]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:505)
...
Caused by: java.lang.RuntimeException: type=39
at org.h2.message.DbException.throwInternalError(DbException.java:293)
...
(вставка работает отлично)
Тип 39
относится к типу ROW
, в то время как я ожидаю STRING
(тип 13
).
Я не могу понять, почему я получаю это ROW
отображение: есть ли параметр, который я пропустил?