This class needs to inherit the dialect class corresponding to the database we are using. For example: if we use MySQL (version 5.x.x), we need to inherit "org.hibernate.dialect.MySQL5Dialect"; if we use DB2, then we should inherit " Org.hibernate.dialect.DB2Dialect "; I'm using SqlServer2008, so I'm going to inherit" Org.hibernate.dialect.SQLServerDialect "
Import Java.sql.Types;
Import Org.hibernate.Hibernate;
Import Org.hibernate.dialect.MySQL5Dialect;
/** * Rewrite Mysql5dialect class, register types * @author LZ * * */public class Mydialect extends Mysql5dialect {public mydialect () {
Super ();
Hibernate4 after configuration Registerhibernatetype (Types.decimal, BigDecimalType.INSTANCE.getName ());
Registerhibernatetype (Types.longvarchar,stringtype.instance.getname ());
Registerhibernatetype (Types.binary,stringtype.instance.getname ());
Registerhibernatetype ( -1, StringType.INSTANCE.getName ());
Hibernate3 before the configuration Registerhibernatetype (Types.decimal, Hibernate.BIG_DECIMAL.getName ());
Registerhibernatetype (Types.longvarchar,hibernate.string.getname ());
Registerhibernatetype (Types.binary,hibernate.string.getname ());
Registerhibernatetype ( -1, Hibernate.STRING.getName ());
After the Hibernate3 configuration Registerhibernatetype (Types.decimal, New Bigdecimaltype (). GetName ());
Registerhibernatetype (Types.longvarchar,new StringType (). GetName ()); Registerhibernatetype (Types.binary,new StrinGtype (). GetName ());
Registerhibernatetype ( -1, New StringType (). GetName ());
}
}
Description: If your database is MySQL, and use the decimal type, the error should be No dialect mapping for JDBC type:3. Note This 3, which shows that hibernate cannot map this data type to your Java class. It needs to be used in a custom dialect: Description:
If your database is MySQL and uses the decimal type, the error should be No dialect mapping for JDBC type:3. Note This 3, which shows that hibernate cannot map this data type to your Java class. You need to use the following in a custom dialect:
Registerhibernatetype (Types.decimal, Hibernate.BIG_DECIMAL.getName ());
If you use the text data type, hibernate does not know this data type at all, so it returns no dialect mapping for JDBC type:-1
In this case, you need to add in the dialect:
Registerhibernatetype ( -1,hibernate.string.getname ());
<property name= "Hibernate.dialect" >
com.yourcompany.MyDialect
</property>