我有两个模型,它们都使用hibernate并使用mySQL,它们有一个ManyToOne关系,我使用AngularJS来显示视图。我想知道是否有办法从TraineeStatus模型中检索对象列表并将其存储在Trainee模型中?
TraineeStatus.java
@Entity
public class Trainees {
@Id
@GeneratedValue
private int traineesID;
@ManyToOne
private Technologies technologies;
@ManyToOne
private TraineeStatus traineestatus;
private int customersID;
private String name;
private String surname;
private String phoneDetails;
private String email;
public Trainees(){
}
public Trainees(String name, String surname, String phoneDetails, String email, int id, Technologies technologies, TraineeStatus traineestatus, int customersID) {
super();
this.name = name;
this.surname = surname;
this.email = email;
this.phoneDetails = phoneDetails;
this.technologies = technologies;
this.traineestatus = traineestatus;
this.customersID = customersID;
}
//getters and setters
TraineeStatus.java
@Entity
@Table(name="traineeStatus")
public class TraineeStatus {
@Id
@GeneratedValue
private int traineeStatusId;
private String value;
public TraineeStatus(){
}
我的目标是从TraineeStatus中检索一个对象数组,其中包含id和value,并在我的Trainees模型中使用它。有可能吗?谢谢。
答案 0 :(得分:0)
试试吧
@Entity
@Table(name="traineeStatus")
public class TraineeStatus {
@OneToMany(mappedBy = "traineestatus")
private List<Trainees> orderItems;
...
// GETTERS and SETTERS
}