title: JPA One To Many/Many To Many Example
body: <p>I'm using:</p>
  
  <ul>
  <li>Hibernate</li>
  <li>MySQL</li>
  <li>jBoss</li>
  </ul>
  
  <p>I have to create an application that allows user to make friendship.</p>
  
  <p>I'm still in design phase, and I would like to have these tables:</p>
  
  <pre><code>- User {_id, name, address} 
   - Friendship {idUserA, idUserB, date}
  </code></pre>
  
  <p>For my purpose I should have a mutual relationship from Users. For example 1 is friend of 2 and indirectly 2 is friend of 1.
  So in my table I think to have:</p>
  
  <p>Friendship = {1, 2, ...}</p>
  
  <p>I'm asking how I can simulate this behaviour. I've read his topic: <a href="https://stackoverflow.com/questions/1831186/many-to-many-on-the-same-table-with-additional-columns">Many-to-many on the same table with additional columns</a> and I've followed this instruction generating database tables from entity (property of hibernate). But in this example when I load my Friend A, I've a list with Friend B and when I load B I haven't user A into List.</p>
  
  <p>How I can implement this damn mutual relationship?</p>