I java ee项目有两个实体类别:Employee和Shft,它们之间有许多重复工作。 它希望:
@Entity
public class Employee implements Serializable {
@ManyToMany(mappedBy="employees")
private List shifts;
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
private String surname;
private String firstname;
......
@Entity
public class Shift implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@Temporal(javax.persistence.TemporalType.TIMESTAMP)
private Date timeStart;
@Temporal(javax.persistence.TemporalType.TIMESTAMP)
private Date timeEnd;
private int workers;
private int overseers;
@ManyToMany
private List employees;
我有一个共同基金网页,希望把雇员(一个或一个)增到在我背后的传票上选择的班子:
public void addToShift(Employee e){
selectedShift.addEmployee(e);
e.addShift(selectedShift);
}
After the method is called, i see nothing in the join table. I tried a few things, like looking up the entities again using entitymanager.find, but nothing really helped, i can t see anything in the join table and i can t see why. There were no problem managing employees and shift, it s "just" the connection...... Do you have any ideas?