How to Hibernate Annotations with circular references
<p>I have two tables with circular reference</p>

<pre><code>-----------------|                   |------------------
  product        |                   | product_detail
-----------------|                   |------------------
 product_id &lt;pk&gt; |                   | detail_id &lt;pk&gt;
  ...            | &lt;-----------------| container_id &lt;fk&gt;
                 | &lt;-----------------| product_id &lt;fk&gt;
                 |                   | ...
</code></pre>

<p>I want to know how to do the property annotations</p>

<blockquote>
  <p>How to do <strong>@OneToMany</strong> annotation</p>
</blockquote>

<pre><code>Class Product
@OneToMany ???
public List&lt;Detail&gt; getDetails();
</code></pre>

<blockquote>
  <p>How to do <strong>@ManyToOne</strong> annotations</p>
</blockquote>

<pre><code>Class Detail

@ManyToOne ???
public Product getContainer();

@ManyToOne ???
public Product getProduct();
</code></pre>

<p>I want to use the following code :</p>

<pre><code>    Product p1 = new Product(name2);
    Product p2 = new Product(name1);

    Detail d = new Detail();

    d.setProduct(p2);

    p1.getDetails().add(d);

    ...

    Session.save(p1);
</code></pre>

<p>Then hibernate <code>insert into product</code> and <code>insert into detail</code> too.</p>

<p>I don't find the way to create the annotations to make it works. Can you help me, please?</p>