title: How work with foreign keys in Hibernate?
body: <p>I'm new to Hibernate. This is my problem. I can do this:</p>
  
  <pre><code>package = session.createQuery("from Package").list();
  session.getTransaction().commit();
  </code></pre>
  
  <p>But what I really want is this in SQL:</p>
  
  <pre><code>select * from package,product where product.nome='television' and package.idProduct = product.id
  </code></pre>
  
  <p>How do I do that?</p>
  
  <p>These are my POJOs:</p>
  
  <pre><code>public class Package implements java.io.Serializable {
  
    private PackageId id;
    private User user;
    private Product product;
    private int quant;
    private char mode;
    private String unit;
    private String description;
  
  public class PackageId implements java.io.Serializable {
  
    private int id;
    private int idProduct;
  
  public class Product  implements java.io.Serializable {
  
    private int id;
    private String name;
    private Set packages = new HashSet(0);
  </code></pre>
  
  <p>These POJOs were generated by Netbeans.</p>
  
  <p>Is this configuration right?</p>
  
  <p><a href="http://pastebin.com/gBUdKke0" rel="nofollow">http://pastebin.com/gBUdKke0</a></p>