Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I define 'TEXT' type using eBean in Play! framework?

When I define a variable in Model class as a String, it is converted as 'VARCHAR(255)' in DB.

However, I want to save more than 255 because this data is very long text consisting of several paragraphs.

As far as I remember, there is a TEXT type in DB to save very long text.

How can I define TEXT type in Play! framework?

I tried Constraints.MaxLength and Constraints.Max defined in Play! framework api.

However, still 1.sql file (created by Ebean DDL automatically) defines this variable as VARCHAR(255).

Thanks, in advance!

like image 338
byron1st Avatar asked Sep 10 '12 03:09

byron1st


1 Answers

In your model, just use the column definition set as TEXT:

@Entity
public class MyEntity extends Model {

    @Id
    private Long id;

    @Column(columnDefinition = "TEXT")
    private String aLongText;
    ....

}

I already used it with Postgres, don't know if it is ok with other database server.

like image 106
ndeverge Avatar answered Nov 28 '22 08:11

ndeverge