0
我需要根據放置在相關記錄上的約束以一對多關係提取記錄。舉例來說,我有:獲取具有一對多關係的所有實體,其中一個相關實體符合標準
@Entity
@Table (name = "LISTING")
public class Listing
{
@Id
@GeneratedValue (strategy = GenerationType.SEQUENCE, generator = "LISTING_SEQ")
@SequenceGenerator (name = "LISTING_SEQ", initialValue = 1, allocationSize = 1, sequenceName = "LISTING_SEQ")
@Column (unique = true, nullable = false, updatable = false)
long id;
@OneToMany (mappedBy = "listing", fetch = FetchType.EAGER)
Set<ListingLineItem> listingLineItems;
...
}
而且....
@Entity
@Table (name = "LISTING_LINE_ITEM")
public class ListingLineItem
{
@EmbeddedId
ListingLineItemPK id;
boolean ignored;
@ManyToOne (fetch = FetchType.EAGER)
@JoinColumn (name = "listing_id", nullable = false)
Listing listing;
...
}
我需要或者寫一個JPQL/HQL查詢或利用CriteriaBuilder
給我Listing
S的有一個相關的ListingLineItem哪裏忽略=真。
我希望場'ignored'映射!?被忽略的 –
確實被映射。謝謝,這是按預期工作,現在看來它顯得很荒謬:) – lmerry213