我在 Play Framework 2 中有一个简单的模型,如果在执行 INSERT 时没有提供任何值,我想指定一个要插入到指定 INT 列上的默认值。
模型:
@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;
我希望默认size
填充该列2
,但是,如果我如上所述指定默认值,我的数据库演变不会反映这一点:
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))
;
我希望看到的是:
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))
;