我正在使用Liferay框架和mysql数据库,我不断收到此错误:
ERROR [http-bio-80-exec-5][render_portlet_jsp:157] com.mysql.jdbc.MysqlDataTruncation: Data truncation: Data too long for column 'odlukaKomentar' at row 1
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4118)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4052)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2503)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2664)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2794)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2155)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2458)
at com.mysql.jdbc.PreparedStatement.executeBatchSerially(PreparedStatement.java:2006)
at com.mysql.jdbc.PreparedStatement.executeBatch(PreparedStatement.java:1467)
at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeBatch(NewProxyPreparedStatement.java:1723)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:70)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:268)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:268)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:184)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:51)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1216)
at com.liferay.portal.dao.orm.hibernate.SessionImpl.flush(SessionImpl.java:144)
at com.liferay.portal.kernel.dao.orm.ClassLoaderSession.flush(ClassLoaderSession.java:237)
at com.liferay.portal.service.persistence.BatchSessionImpl.update(BatchSessionImpl.java:86)
数据库中的此字段“odlukaKomentar”是LONGTEXT类型。有解决方案吗 感谢
答案 0 :(得分:0)
根据the docs(链接5.0),
LONGTEXT [CHARACTER SET charset_name] [COLLATE collation_name]
TEXT列,最大长度为4,294,967,295或4GB(2 ^ 32 - 1) 字符。如果值包含,则有效最大长度较小 多字节字符。 LONGTEXT列的有效最大长度 还取决于配置的最大数据包大小 客户端/服务器协议和可用内存。每个LONGTEXT值都是 使用指示字节数的4字节长度前缀存储 在价值中。
您可能想检查数据库驱动程序的配置,实际长度(我怀疑您接近4G字节)。如果这是一个服务构建器组件(因为您提到了Liferay),您可能需要google" liferay服务构建器模型提示"并为服务构建者提供更好的预期列大小的提示。