簡體   English   中英

JPQL查詢屬於另一個實體並滿足某些條件的實體

[英]JPQL query for entities belonging to another entity and satisfying certain conditions

我有一個Patient實體,其中包含一個Appointment對象列表。 Appointment不了解Patient 我想創建一個JPQL查詢,該查詢查找指定日期之間屬於特定患者的約會。 好像我需要在Appointment編寫此查詢,但是由於Appointment沒有類型為Patient的字段,所以我很難做到這一點。

編輯(包含更多信息):

我知道我必須使用某種聯接來做到這一點,但是我對聯接的編寫並不了解。

編輯(帶有指向實體的鏈接):

約定

患者

您只需要加入:

select a from Patient p
join p.appointments a
where p.id = :patientId
and a.date between :start and :end

如果您對某事不太了解,最好的方法是閱讀文檔

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM