09-04
18
No Dialect mapping for JDBC type 3错误
作者:Java伴侣 日期:2009-04-18
自定义Hibernate Dialect解决createSQLQuery时的decimal,long类型问题
org.hibernate.MappingException: No Dialect mapping for JDBC type: 3
首先建一个类,继承org.hibernate.dialect.DB2Dialect,该类的内容如下:
import java.sql.Types;
import org.hibernate.Hibernate;
import org.hibernate.dialect.DB2Dialect;
public class PmDb2Dialect extends DB2Dialect
{
public PmDb2Dialect()
{
super();
registerHibernateType(Types.DECIMAL, Hibernate.BIG_DECIMAL.getName());
}
}
第二步,就是修改hibernate的配置文件hibernate.cfg.xml:
将:
<property name="hibernate.dialect">
org.hibernate.dialect.DB2Dialect
</property>
改为:
<property name="hibernate.dialect">
com.yonder.pm.common.PmDb2Dialect
</property>
org.hibernate.MappingException: No Dialect mapping for JDBC type: 3
首先建一个类,继承org.hibernate.dialect.DB2Dialect,该类的内容如下:
import java.sql.Types;
import org.hibernate.Hibernate;
import org.hibernate.dialect.DB2Dialect;
public class PmDb2Dialect extends DB2Dialect
{
public PmDb2Dialect()
{
super();
registerHibernateType(Types.DECIMAL, Hibernate.BIG_DECIMAL.getName());
}
}
第二步,就是修改hibernate的配置文件hibernate.cfg.xml:
将:
<property name="hibernate.dialect">
org.hibernate.dialect.DB2Dialect
</property>
改为:
<property name="hibernate.dialect">
com.yonder.pm.common.PmDb2Dialect
</property>
评论: 0 | 引用: 0 | 查看次数: 1427
发表评论