试验过了,好用!!!
自定义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>