我是靠谱客的博主 魔幻魔镜,这篇文章主要介绍Hibernate配置mysql数据库方言问题,现在分享给大家,希望可以做个参考。

在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数据库方言问题内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(71)

评论列表共有 0 条评论

立即
投稿
返回
顶部