0

在以下来自数据库的实体类中,如何编写查询以使用集合 productsCollection2 作为参数从表中选择并检索 productsCollection3。???我可以使用 productCollection2 并使用 IN 子句将列表传递给它进行选择。

@Table(name = "Products")
public class Products implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "SKU")
    private String sku;
    @Basic(optional = false)
    @Column(name = "ProductName")
    private String productName;

    private boolean allowPreOrder;
    @ManyToMany(mappedBy = "productsCollection")
    private Collection<Categories> categoriesCollection;
    @JoinTable(name = "Products_CrossSell", joinColumns = {
        @JoinColumn(name = "SKU", referencedColumnName = "SKU")}, inverseJoinColumns = {
        @JoinColumn(name = "CrossSKU", referencedColumnName = "SKU")})
    @ManyToMany
    private Collection<Products> productsCollection;
    @ManyToMany(mappedBy = "productsCollection")
    private Collection<Products> productsCollection1;
    @JoinTable(name = "Products_Related", joinColumns = {
        @JoinColumn(name = "SKU", referencedColumnName = "SKU")}, inverseJoinColumns = {
        @JoinColumn(name = "RelatedSKU", referencedColumnName = "SKU")})
    @ManyToMany
    private Collection<Products> productsCollection2;
    @ManyToMany(mappedBy = "productsCollection2")
    private Collection<Products> productsCollection3;
4

0 回答 0