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

前端 未结 12 1383
梦谈多话
梦谈多话 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:25

    You can set your database to work in a non strict mode as explained here: Automatically trimming length of string submitted to MySQL

    Note that it might cancel other validations too so be careful in what you wish for

提交回复
热议问题