hibernate报错:org.hibernate.MappingException: No Dialect mapping for JDBC type: -1

解决方法:自定义一个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>  

 

posted @ 2014-04-15 10:15  訫飛  阅读(1348)  评论(0编辑  收藏  举报