title: hibernate many to many mappings for join table with extra columns , surrogate key, additional primary key
body: <p>I'm having hard time to resolve entity mappings (using annotations) for the following scenarios ( from legacy db)</p>
  
  <p><strong>Scenario 1:</strong></p>
  
  <pre><code>Table A
    A_ID (PK)
  
  Table B    
    B_ID (PK)
  
  TABLE A_B    
    AB_ID (PK)    
    A_ID (FK)    
    B_ID (FK)    
    Created_DATE
  </code></pre>
  
  <p><strong>Scenario 2:</strong></p>
  
  <pre><code>Table A    
    A_ID (PK)
  
  Table B    
    B_ID (PK)
  
  TABLE A_B    
    AB_ID (PK)    
    A_ID (PK)(FK)    
    Test_Date (PK)    
    B_ID (FK)    
    Created_DATE
  </code></pre>
  
  <p><strong>Scenario 3:</strong></p>
  
  <pre><code>Table A
    A_ID (PK)             
    A2_ID (PK)
  
  Table B    
    B_ID (PK)
  
  TABLE A_B    
    A_ID (PK)(FK)    
    A2_ID (PK)(FK)    
    B_ID (PK)(FK)   
    Created_DATE
  </code></pre>
  
  <p>Could some one kind enough to show these entities in hibernate using annotations and with explanation please?</p>