0
我想在mysql數據庫中創建一個具有值爲'active'和'inactive'的布爾列的表。我怎樣才能做到這一點?如何在mysql表中創建布爾列?
我的實體類:
@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'? – ITroubs 2015-01-21 08:28:44
以下谷歌查詢... https://www.google.ch/search?q=jpa+boolean+mysql你有什麼嘗試過嗎? – reto 2015-01-21 08:29:39
您是否嘗試添加「BIT(1)」或「TinyInt(1)」列? – navigator 2015-01-21 08:31:00