I have a simple model in Play Framework 2, and I would like to specify the default value that needs to be inserted into the INT column if none of them are specified when executing INSERT.
Model:
@Entity @Table(name = "DashboardOptions", schema = "dbo") public class DashboardOptions extends Model implements Serializable { private static final long serialVersionUID = 1L; @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Basic(optional = false) @Column(name = "id") public Long id; @Basic(optional = false) @Column(name = "userId") public Long userId; @Column(name = "chartType") public String chartType; public String name; public Integer size = 2;
I would like the size column to be populated with 2 by default, however, if I specify a default value as above, my database evolution does not reflect this:
create table dbo.DashboardOptions ( id numeric(19) identity(1,1) not null, userId numeric(19) not null, chartType varchar(255), name varchar(255), size integer, constraint pk_DashboardOptions primary key (id)) ;
I would expect to see the following:
create table dbo.DashboardOptions ( id numeric(19) identity(1,1) not null, userId numeric(19) not null, chartType varchar(255), name varchar(255), size integer default 2, constraint pk_DashboardOptions primary key (id)) ;
sean.boyer
source share