继承于MySQLDialect ,引入 registerHibernateType(Types.LONGVARCHAR, Hibernate.TEXT.getName());
import java.sql.Types;import org.hibernate.Hibernate;import org.hibernate.dialect.MySQLDialect;public class ThisMySQLDialect extends MySQLDialect { public ThisMySQLDialect (){ super(); registerHibernateType(Types.LONGVARCHAR, Hibernate.TEXT.getName()); } }
hibernate 配置修改
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource"></property> <property name="hibernateProperties"> <props> <prop key="connection.useUnicode">true</prop> <prop key="connection.characterEncoding">GBK</prop> <prop key="hibernate.dialect">com.yjf.dao. ThisMySQLDialect </prop><!-- org.hibernate.dialect.Oracle9Dialect --> <prop key="hibernate.show_sql">true</prop> <prop key="hibernate.format_sql">false</prop> <!-- <prop key="hibernate.hbm2ddl.auto">update</prop> --> <prop key="hibernate.jdbc.batch_size">0</prop> </props> </property> <property name="mappingLocations"> <list> <value>classpath:com/yjf/model/hbm/*.hbm.xml</value> </list> </property> </bean>