解决方法:自定义一个Hibernate Dialect.

package com.yourcompany.util ;  
  
import java.sql.Types;  
  
import org.hibernate.Hibernate;  
import org.hibernate.dialect.MySQL5Dialect;  
  
public class CustomDialect extends MySQL5Dialect {  
    public CustomDialect() {  
        super();  
        registerHibernateType(Types.DECIMAL, Hibernate.BIG_DECIMAL.getName());  
        registerHibernateType(-1, Hibernate.STRING.getName());  
    }  
}  

然后将hibernate配置文件(或是Spring配置文件)中配置数据库方言的那一项,改成上面自定义的方言

<property name="hibernate.dialect">  
      com.yourcompany.CustomDialect  
</property>  

 

相关文章:

  • 2021-11-04
  • 2021-08-25
  • 2021-07-28
  • 2022-12-23
  • 2021-05-16
  • 2022-12-23
  • 2022-12-23
  • 2021-09-01
猜你喜欢
  • 2021-09-06
  • 2021-10-18
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-10
相关资源
相似解决方案