How to find what variable is too long

Getting an error on committing the historical variables to the mysql database. Is there a way to determine which variable it might be?

ENGINE-16004 Exception while closing command context: ENGINE-03083 Exception while executing Batch Database Operations with message ’

Error flushing statements. Cause: org.apache.ibatis.executor.BatchExecutorException: org.camunda.bpm.engine.impl.persistence.entity.HistoricDetailEntity.insertHistoricVariableUpdateEvent (batch index #1) failed. Cause: java.sql.BatchUpdateException: Data truncation: Data too long for column ‘TEXT_’ at row 1

Cause: org.apache.ibatis.executor.BatchExecutorException: org.camunda.bpm.engine.impl.persistence.entity.HistoricDetailEntity.insertHistoricVariableUpdateEvent (batch index #1) failed. Cause: java.sql.BatchUpdateException: Data truncation: Data too long for column ‘TEXT_’ at row 1

java.sql.BatchUpdateException: Data truncation: Data too long for column ‘TEXT_’ at row 1
com.mysql.jdbc.MysqlDataTruncation: Data truncation: Data too long for column ‘TEXT_’ at row 1
'. Flush summary:
[
INSERT HistoricVariableUpdateEventEntity[99f5371a-71f2-11ea-8c15-0242ac100035]
INSERT HistoricVariableUpdateEventEntity[99f55e2b-71f2-11ea-8c15-0242ac100035]
INSERT HistoricVariableUpdateEventEntity[9a33036e-71f2-11ea-8c15-0242ac100035]
INSERT HistoricVariableUpdateEventEntity[9a330370-71f2-11ea-8c15-0242ac100035]
INSERT HistoricVariableUpdateEventEntity[9a35c293-71f2-11ea-8c15-0242ac100035]
INSERT HistoricVariableUpdateEventEntity[9a35c295-71f2-11ea-8c15-0242ac100035]

TEXT_ column is a size of 4K bytes. For the variables of size >4K, can be stored as Object instead of String variable.

To find variable size: https://mothereff.in/byte-counter (just for reference)

Two example using Java Serialization (String object) and JSON serialization (JSON string)

    StringBuffer buffer =  new StringBuffer();
    while (buffer.length()<4100) buffer.append("abcdefghijabcdefghijabcdefghijabcdefghijabcdefghij");

    ObjectValue textString = Variables.objectValue(buffer.toString()).create();

    ObjectValue textJson = Variables
            .objectValue(buffer.toString())
            .serializationDataFormat(Variables.SerializationDataFormats.JSON)
            .create();

    //add json ObjectValue as process variable
    runtimeService.startProcessInstanceByKey("JustOneStep", "BC1", Collections.singletonMap("textString", textString));
    //add string as ObjectValue as process variable
    runtimeService.startProcessInstanceByKey("JustOneStep", "BC2", Collections.singletonMap("textJson", textJson));

Also see: