title: JPA: query to get results based on value of foreign key defined in the entity class?
body: <p>Netbean 6.9 generated the following JPA entity class from this SQL Server 2008 table:
  <img src="https://i.stack.imgur.com/Fnxer.jpg" alt="alt text"></p>
  
  <p>I want to get all the ProductDescriptors that have a specific SKU value.  Something like this:</p>
  
  <pre><code>SELECT * FROM ProductDescriptors WHERE SKU='something'
  </code></pre>
  
  <p>Given the entity class, what's the Java code to get the results?</p>
  
  <h2>Thanks.</h2>
  
  <pre><code>@Entity
  @Table(name = "ProductDescriptors")
  @NamedQueries({
      @NamedQuery(name = "ProductDescriptors.findAll",     query = "SELECT p FROM ProductDescriptors p"),
      @NamedQuery(name = "ProductDescriptors.findByDescriptorID", query = "SELECT p FROM ProductDescriptors p WHERE p.descriptorID = :descriptorID"),
      @NamedQuery(name = "ProductDescriptors.findByLanguageCode", query = "SELECT p FROM ProductDescriptors p WHERE p.languageCode = :languageCode"),
      @NamedQuery(name = "ProductDescriptors.findByTitle", query = "SELECT p FROM ProductDescriptors p WHERE p.title = :title"),
      @NamedQuery(name = "ProductDescriptors.findByIsDefault", query = "SELECT p FROM ProductDescriptors p WHERE p.isDefault = :isDefault"),
      @NamedQuery(name = "ProductDescriptors.findByBody", query = "SELECT p FROM ProductDescriptors p WHERE p.body = :body")})
  public class ProductDescriptors implements Serializable {
      private static final long serialVersionUID = 1L;
      @Id
      @Basic(optional = false)
      @Column(name = "DescriptorID")
      private Integer descriptorID;
      @Basic(optional = false)
      @Column(name = "LanguageCode")
      private String languageCode;
      @Basic(optional = false)
      @Column(name = "Title")
      private String title;
      @Basic(optional = false)
      @Column(name = "IsDefault")
      private boolean isDefault;
      @Basic(optional = false)
      @Column(name = "Body")
      private String body;
      @JoinColumn(name = "SKU", referencedColumnName = "SKU")
      @ManyToOne(optional = false)
      private Products products;
  </code></pre>
  
  <p>...</p>