0
我想通過使用下面的JPQL對Faculty
實體進行排序,但我正在檢索太多具有相同ID的系。通過關聯字段(OneToMany)排序
@NamedQuery(
name = "Faculty.findFacultySortedByPreferredTime",
query = "SELECT f FROM Faculty f JOIN f.preferredTimes p ORDER BY p.day, p.startTime"
),
這裏是我的Faculty
實體,我的工作
public class Faculty implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
private String firstName;
private String middleName;
private String lastName;
@OneToMany(cascade = CascadeType.PERSIST)
@OrderBy(value = "day, startTime")
private List<PreferredTime> preferredTimes;
// some codes removed
我是不是做錯了?
完美地工作!偉大的解釋兩個大拇指! – ltlynx