我使用Ebean的play-framework 2.2.1。我在學生和學校課之間有許多關係。Ebean manyToMany沒有保存在交易
在交易中,創建schoolClass,添加到Student並保存時,相應的橋表未填滿。
@Entity
public class Student extends Model {
...
@ManyToMany(cascade = CascadeType.ALL)
public List<SchoolClass> schoolClasses = new ArrayList<SchoolClass>();
}
@Entity
public class SchoolClass extends Model {
...
@ManyToMany(mappedBy = "schoolClasses")
public List<Student> students = new ArrayList<Student>();
}
代碼:
try {
Ebean.beginTransaction();
...
Student student = new Student();
student.schoolClasses.add(schoolClass);
student.save();
Ebean.commitTransaction();
} finally {
Ebean.endTransaction();
}
任何想法?
如果交易被刪除的代碼按預期工作 – KirdApe