In PlayFramework, by creating a Model class (class with @Entity annotation), SQl of create statement is automatically issued, and there is a function to create a table according to the contents defined in the class. At that time, I didn't know how to write the column to save the binary data, so it took time, so I will record it.
The way to write it is as follows.
@Lob public byte[] paramBlob;
The following is a sample implementation.
TbParam.java
package models.entity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import play.db.ebean.Model;
@Entity
public class TbParam extends Model {
@Id
public Integer id;
@Lob
public byte[] paramBlob;
public TbWorkParam(){
}
}
With the above writing method, in the mysql environment, the column paramBlob is created as a longblob type.
Recommended Posts