How to silently truncate strings while storing them when they are longer than the column length definition?

前端 未结 12 1392
梦谈多话
梦谈多话 2020-12-24 06:17

I have a web app, using EclipseLink and MySQL for storing data. Some of these data are strings, ie varchars in the DB. In the code of entities, the strings have attributes

12条回答
  •  南笙
    南笙 (楼主)
    2020-12-24 06:45

    Since the Exception seems to be raised at the database level during the commit() process, a before-insert Trigger on the target table/s could truncate the new values before they are committed, bypassing the error.

提交回复
热议问题