我在网上搜索了很多,但我发现什么都没有帮助我,所以我决定尝试一下。
我正在使用Jhipster代码生成器开发应用程序。我知道可以使用命令“ yo jhipster-entity EntityName ”修改实体,使用我可以选择String,Integer,Long,Float,Double,BigDecimal和LocalDate。问题是我需要像Set或List of String这样的东西。
有没有办法通过命令行执行此操作?
这是我的实体“服务台”:
import com.fasterxml.jackson.annotation.JsonIgnore;
import javax.persistence.*;
import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;
import java.util.Objects;
/**
* A Desk.
*/
@Entity
@Table(name = "desk")
public class Desk implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(name = "users_on_it")
private String usersOnIt;
@Column(name = "name")
private String name;
@OneToMany(mappedBy = "desk")
@JsonIgnore
private Set<CustomUser> users = new HashSet<>();
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getUsersOnIt() {
return usersOnIt;
}
public Desk usersOnIt(String usersOnIt) {
this.usersOnIt = usersOnIt;
return this;
}
public void setUsersOnIt(String usersOnIt) {
this.usersOnIt = usersOnIt;
}
public String getName() {
return name;
}
public Desk name(String name) {
this.name = name;
return this;
}
public void setName(String name) {
this.name = name;
}
public Set<CustomUser> getUsers() {
return users;
}
public Desk users(Set<CustomUser> customUsers) {
this.users = customUsers;
return this;
}
public Desk addUsers(CustomUser customUser) {
this.users.add(customUser);
customUser.setDesk(this);
return this;
}
public Desk removeUsers(CustomUser customUser) {
this.users.remove(customUser);
customUser.setDesk(null);
return this;
}
public void setUsers(Set<CustomUser> customUsers) {
this.users = customUsers;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
Desk desk = (Desk) o;
if (desk.getId() == null || getId() == null) {
return false;
}
return Objects.equals(getId(), desk.getId());
}
@Override
public int hashCode() {
return Objects.hashCode(getId());
}
@Override
public String toString() {
return "Desk{" +
"id=" + getId() +
", usersOnIt='" + getUsersOnIt() + "'" +
", name='" + getName() + "'" +
"}";
}
}
Jhipster按关系生成了一个Set字段(Set of CustomUser),但我需要的字段与其他实体无关。
感谢宝贵的时间,Manuel。