Note that there are some explanatory texts on larger screens.

plurals
  1. POJPA: join table syntax
    primarykey
    data
    text
    <p>Given the following entity (some columns omitted from this long definition for brevity):</p> <pre><code>@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&lt;Categories&gt; categoriesCollection; @JoinTable(name = "Products_CrossSell", joinColumns = { @JoinColumn(name = "SKU", referencedColumnName = "SKU")}, inverseJoinColumns = { @JoinColumn(name = "CrossSKU", referencedColumnName = "SKU")}) @ManyToMany private Collection&lt;Products&gt; productsCollection; @ManyToMany(mappedBy = "productsCollection") private Collection&lt;Products&gt; productsCollection1; @JoinTable(name = "Products_Related", joinColumns = { @JoinColumn(name = "SKU", referencedColumnName = "SKU")}, inverseJoinColumns = { @JoinColumn(name = "RelatedSKU", referencedColumnName = "SKU")}) @ManyToMany private Collection&lt;Products&gt; productsCollection2; @ManyToMany(mappedBy = "productsCollection2") private Collection&lt;Products&gt; productsCollection3; </code></pre> <p>How do I get the set of related products for a given product SKU? </p> <p>The products_related table looks like this:</p> <p><img src="https://i.stack.imgur.com/Vb6sV.jpg" alt="alt text"></p> <p>I know how to get the answer using SQL but I'm new to JPA so I haven't quite grokked the API and query syntax yet.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload