读书人

hibernate读取TEXT门类

发布时间: 2012-07-05 07:59:18 作者: rapoo

hibernate读取TEXT类型
现象:用hibernate读取数据库中Text类型字段时,发现只能读取前10000字节的长度,后面的都丢失了。

解决办法:

第一步:
package com.my.hibernate.config;
import java.sql.Types;
import org.hibernate.dialect.MySQL5Dialect;
/**
*
*/
public class DialectForInkfish extends MySQL5Dialect {
public DialectForInkfish() {
super();
registerHibernateType(Types.LONGVARCHAR, 65535, "text");
}
}

第二步:
将hibernate配置文件中

<property name="dialect">org.hibernate.dialect.MySQLDialect</property>

改为
<property name="dialect">com.my.hibernate.config.DialectForInkfish</property>


读书人网 >其他数据库

热点推荐