JDBC 类型没有方言映射:1111 [英] No Dialect mapping for JDBC type: 1111

查看:46
本文介绍了JDBC 类型没有方言映射:1111的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个 Spring JPA 应用程序,使用 MySQL 作为数据库.我确保所有 spring-jpa 库、hibernate 和 mysql-connector-java 都已加载.

I'm working on a Spring JPA Application, using MySQL as database. I ensured that all spring-jpa libraries, hibernate and mysql-connector-java is loaded.

我正在运行一个 mysql 5 实例.这是我的 application.properties 文件的摘录:

I'm running a mysql 5 instance. Here is a excerpt of my application.properties file:

spring.jpa.show-sql=false
spring.jpa.hibernate.ddl-auto=create-drop
spring.jpa.database-platform=org.hibernate.dialect.MySQL5Dialect

spring.datasource.url=jdbc:mysql://localhost/mydatabase
spring.datasource.username=myuser
spring.datasource.password=SUPERSECRET
spring.datasource.driverClassName=com.mysql.jdbc.Driver

在执行集成测试时,spring 正常启动,但在创建休眠 SessionFactory 时失败,除了:

When executing an integration test, spring startsup properly but fails on creating the hibernate SessionFactory, with the exception:

org.hibernate.MappingException: No Dialect mapping for JDBC type: 1111

我认为我的方言应该是 Mysql5Dialect,我也尝试过明确说明 InnoDB 的方言,以及不指示版本 5 的两个方言选项.但我总是以相同的无方言映射 JDBC 类型"告终:1111'消息.我的 application.properties 文件位于 test/resources 源文件夹中.它被 JUnit 测试运行器识别(我之前因为输入错误而得到一个异常).

I think my dialects should be Mysql5Dialect, I also tried the one explicitly stating InnoDB, and the two dialect options which don't indicate the version 5. But I always end up with the same 'No Dialect mapping for JDBC type: 1111' message. My application.properties file resides in the test/resources source folder. It is recognized by the JUnit Test runner (I previously got an exception because of an typo in it).

我设置的属性有误吗?我找不到关于这些属性名称的一些官方文档,但在这个 stackoverflow 答案中找到了一个提示:https://stackoverflow.com/a/25941616/1735497

Are the properties I'm setting wrong? I couldn't find some official documentation on these property names but found a hint in this stackoverflow answer: https://stackoverflow.com/a/25941616/1735497

期待您的回答,谢谢!

顺便说一句,该应用程序已经在使用 spring boot.

BTW The application is already using spring boot.

推荐答案

这里是基于 SubOptimal 评论的答案:

Here the answer based on the comment from SubOptimal:

错误消息实际上是说一种列类型无法通过休眠映射到数据库类型.就我而言,它是我在某些实体中用作主键的 java.util.UUID 类型.只需应用注释 @Type(type="uuid-char")(对于 postgres @Type(type="pg-uuid"))

The error message actually says that one column type cannot be mapped to a database type by hibernate. In my case it was the java.util.UUID type I use as primary key in some of my entities. Just apply the annotation @Type(type="uuid-char") (for postgres @Type(type="pg-uuid"))

这篇关于JDBC 类型没有方言映射:1111的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆