Playframework モデルのプロパティのデータ型を指定する
PlayframeworkでモデルにString型のプロパティを追加すると、データ型はMySQLだと自動的にVARCHAR(255)になります。
このままだと255を超える長さの文字列を追加しようとするとPersistenceExceptionになります。
PersistenceException occured : org.hibernate.exception.DataException: could not insert: [models.Comment]
..
Caused by: org.hibernate.exception.DataException: could not insert: [models.Comment]
@Columnアノテーションを使ってデータ型をTEXTにすることで回避できました
@Entity public class Comment extends Model{ @ManyToOne public Post post @Column(columnDefinition = "TEXT") public String comment; }
Source:
http://stackoverflow.com/questions/7247968/use-of-lob-for-field-in-playframework
http://docs.oracle.com/javaee/5/api/javax/persistence/Column.html