Hibernate设置如下:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.ibm.heyang.domain">
<class name="Wisdom" table="collections_wisdom">
<id name="id" column="ID" >
<generator class="increment"/>
</id>
<property name="title" column="title" not-null="true"/>
<property name="concept" type="text">
<column name="concept" not-null="true" sql-type="LONGTEXT"/>
</property>
<property name="addUserId" column="addUserId" />
<property name="modifyTime" column="modifyTime"/>
</class>
</hibernate-mapping>
存储时,当concept字段是短文本时没有问题,为长文本就出错了:
Caused by: java.sql.BatchUpdateException: Data truncation: Data too long for column 'concept' at row 1
at com.mysql.jdbc.PreparedStatement.executeBatchSerially(PreparedStatement.java:1237)
at com.mysql.jdbc.PreparedStatement.executeBatch(PreparedStatement.java:936)
at org.apache.commons.dbcp.DelegatingStatement.executeBatch(DelegatingStatement.java:297)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:246)
... 41 more
请问我改如何调整?
------解决方案--------------------
<property name="concept" type="text">
<column name="concept" not-null="true" length = "16777216" />
</property>
这样改就好了.