私はjpaを使用しており、次のエンティティがあります。
@Entity
@Table(name="favorites_folders")
public class FavoritesFolder {
private static final long serialVersionUID = 1L;
@Id
private String id;
@NotNull
@Size(min = 1, max = 50)
public String name;
@ElementCollection(fetch = FetchType.LAZY)
@CollectionTable(
name="favorites_products",
joinColumns=@JoinColumn(name="folder_id")
)
@Column(name="product_id")
@NotNull
private Set<String> productsIds = new HashSet<String>();
}
私がやりたいのは、メンバーセットFavoritesFolder
に文字列「favorite-id」を含むエンティティのセットを取得することです。productsIds
誰かが基準APIでそれをどのように行うことができるか知っていますか?
更新:次のSQLでうまくいくと思いますが、どちらか
でそれを行う方法がわかりません: JPQL
Criteria API
select * from favorites_folders join favorites_products on favorites_folders.id = favorites_products.folder_id where favorites_products.product_id = 'favorite-id'