在ssh架构和mysql数据库使用过程中,遇到了如下错误:
org.hibernate.MappingException: No Dialect mapping for JDBC type: xxx
解决步骤:
1.更改hibernate的配置文件:由原来的:
hibernate.connection.driverClass=com.mysql.jdbc.Driver
hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
(ps:MySQL 5.5及以上版本用这个方言,MySQL 5.5以下的貌似用org.hibernate.dialect.MySQLInnoDBDialect)
hibernate.connection.url=jdbc:mysql://localhost:3306/xxxx......
hibernate.connection.userName=xxxx
hibernate.connection.password=xxxx
改为:
hibernate.connection.driverClass=com.mysql.jdbc.Driver
hibernate.dialect=com.xxx.xxxx.util.DialectForInkfish(ps:此处是新建的Java文件的路径)
hibernate.connection.url=jdbc:mysql://localhost:3306/xxxx......
hibernate.connection.userName=xxxx
hibernate.connection.password=xxxx
2.新建Java文件,内容如下:
package com.xxx.xxxx.util;
import java.sql.Types;
import org.hibernate.Hibernate;
import org.hibernate.dialect.MySQL5Dialect;
public class DialectForInkfish extends MySQL5Dialect {
public DialectForInkfish() {
super();
registerHibernateType(Types.LONGVARCHAR, 65535, "text");
registerHibernateType(Types.DECIMAL, Hibernate.BIG_DECIMAL.getName());
registerHibernateType(-1, Hibernate.STRING.getName());
}
}
最后
以上就是魔幻魔镜最近收集整理的关于Hibernate配置mysql数据库方言问题的全部内容,更多相关Hibernate配置mysql数据库方言问题内容请搜索靠谱客的其他文章。
发表评论 取消回复