Reputation: 1308
I'm using hibernate over mysql to save data where some fields can exceed the length limit:
Caused by: com.mysql.jdbc.MysqlDataTruncation: Data truncation: Data too long for column 'telephone' at row 1
I can not change the field length, the field is varchar(45). Is there a simple way to persist the record anyway into the database? I don't care if the field saved is truncated or nothing at all.
Upvotes: 0
Views: 242
Reputation: 30813
i would just truncate in the setter of the string field, then the object behaves the same wether it is created or saved and loaded from database.
Upvotes: 1