I am having trouble setting the type of a String, it goes like
public void setTextDesc(String textDesc) {
this.textDesc = textDesc;
}
@Column(name="DESC")
@Lob
public String getTextDesc() {
return textDesc;
}
and it didn’t work, I checked the mysql schema and it remains varchar(255), I also tried,
@Column(name="DESC", length="9000")
or
@Column(name="DESC")
@Type(type="text")
I am trying to make the type to be TEXT, any idea would be well appreciated!
You said “I checked the mysql schema and it remains varchar(255)” – did you expect Hibernate to automatically alter your database? It won’t. Even if you have
hibernate.hbm2ddl.autoset, I don’t believe Hibernate would alter the existing column definition.If you were to generate new database creation script,
@Lobshould generate “TEXT” type column if you don’t specify length explicitly (or if you do and it’s less that 65536). You can always force that by explicitly declaring type in@Columnannotation, though keep in mind that’s not portable between databases: