private String message = "";
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
I am using EJB3 and MySQL 5.1 using Java.
I want to insert paragraphs of texts into MySQL Database using Entity Bean.
But, When I add, MySQL can accept only 255 characters. It shows me the following error:
Caused by: com.mysql.jdbc.MysqlDataTruncation: Data truncation: Data too long for column ‘message’ at row 1
Currently, field type of message is varchar(255) by default. Is there anyway to change the field type to “Text” in Entity Bean or increase the limit 255 to 1000?
You can annotate the property with
javax.persistence.Lob:You would have to update your schema too (ALTER TABLE…). Hibernate does this automatically for you if you set
hibernate.hbm2ddl.auto=update.