hibernate映射mysql text类型字段,报Data too long错误
hibernate映射mysql text类型字段
映射文件为:
<property name="content" type="text">
<column name="content" />
</property>
model中属性声明为:
private String content;
mysql数据库中字段为:
`content` text
此时,如果要保存的内存过长,回报
Caused by: java.sql.BatchUpdateException: Data truncation: Data too long for column 'content' at row 1
修改方法:在映射文件内<column >上加上length属性
<property name="content" type="text">
<column name="content" length = "16777216"/>
</property>