【发布时间】:2015-03-19 16:45:35
【问题描述】:
我想在 MySQL 数据库中创建一个表,该表有一个 boolean 列,其值为 'active' 和 'inactive'。我该怎么做?
我的实体类:
@Entity
@Table(name = "organization")
public class OrganizationEntity {
private Long id;
private String nameEntity;
private String provinceEntity;
private String supporterEntity;
private String supporterAddressEntity;
private boolean active;
@Id
@GeneratedValue
@Column(name = "id")
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
@Column(name = "name")
public String getNameEntity() {
return nameEntity;
}
public void setNameEntity(String nameEntity) {
this.nameEntity = nameEntity;
}
@Column(name = "province")
public String getProvinceEntity() {
return provinceEntity;
}
public void setProvinceEntity(String provinceEntity) {
this.provinceEntity = provinceEntity;
}
@Column(name = "supporter_name")
public String getSupporterEntity() {
return supporterEntity;
}
public void setSupporterEntity(String supporterEntity) {
this.supporterEntity = supporterEntity;
}
@Column(name = "supporter_address")
public String getSupporterAddressEntity() {
return supporterAddressEntity;
}
public void setSupporterAddressEntity(String supporterAddressEntity) {
this.supporterAddressEntity = supporterAddressEntity;
}
@Column(name = "active")
public boolean isActive() {
return active;
}
public void setActive(boolean active) {
this.active = active;
}
}
我的组织实体类有一个布尔“活动”字段,显示组织处于活动状态或非活动状态。现在我怎样才能在数据库表中有一个列呢?
【问题讨论】:
-
你有没有错过
JPA和JAVA的标签?? -
以下 google 查询...google.ch/search?q=jpa+boolean+mysql你尝试过什么?
-
您是否尝试过添加
BIT(1)或TinyInt(1)列?