Search code examples
modelliferayportletliferay-6sqlexception

Getting exception java.sql.BatchUpdateException: Data truncation: Data too long for column 'XXXX'


I have my custom portlet in liferay6 and I am getting exception while inserting long data in database as java.sql.BatchUpdateException: Data truncation: Data too long for column 'XXXX' at row 1

This is happening even when I have given following parameter in the portlet-modal-hints

<field name="advurl" type="String">
    <hint name="max-length">4000</hint>
</field>

This is the String in column which is throwing error: http://www.coderanch.com/t/435635/java/java/Regular-expression-check-specific-special

can anyone please tell me why this is still throwing an error?

Error stack

Caused by: com.liferay.portal.kernel.dao.orm.ORMException: org.hibernate.exception.DataException: Could not execute JDBC batch update
    at com.liferay.portal.dao.orm.hibernate.ExceptionTranslator.translate(ExceptionTranslator.java:30)
    at com.liferay.portal.dao.orm.hibernate.SessionImpl.flush(SessionImpl.java:122)
    at com.liferay.portal.kernel.dao.orm.ClassLoaderSession.flush(ClassLoaderSession.java:218)
    at com.liferay.portal.service.persistence.BatchSessionImpl.update(BatchSessionImpl.java:95)
    at com.liferay.portal.service.persistence.BatchSessionUtil.update(BatchSessionUtil.java:50)
    at emenu.advertise.database.service.persistence.advertisePersistenceImpl.updateImpl(advertisePersistenceImpl.java:505)
    ... 178 more
Caused by: org.hibernate.exception.DataException: Could not execute JDBC batch update
    at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:102)
    at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
    at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:275)
    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:119)
    ... 182 more
Caused by: java.sql.BatchUpdateException: Data truncation: Data too long for column 'advlink' at row 1
    at com.mysql.jdbc.PreparedStatement.executeBatchSerially(PreparedStatement.java:1257)
    at com.mysql.jdbc.PreparedStatement.executeBatch(PreparedStatement.java:943)
    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)
    ... 188 more
    

can anyone give me some suggestion?


Solution

  • Converting my comment to answer to resolve this question :-)

    You should rebuild the service after the change in the portal-model-hints.xml file.

    And then you should re-deploy the plugin portlet to have the change take effect.

    so please check if the database column has been updated after you have performed the above steps.