title: Mapping java.util.Map with JPA
body: <p>I have Java EE application with Hibernate mapped classes (I use *.hbm.xml mappings).
  Now I need to remake mappings with JPA annotations. All is fine but I can't create correct mapping with my Map property.</p>
  
  <pre><code>@Entity
  @Table(name = DataBaseConstants.EMPLOYEE_TABLE)
  public class Employee implements Serializable {
  private static final long serialVersionUID = 1L;
  @Id
  @SequenceGenerator(name = DataBaseConstants.EMPLOYEE_ID, sequenceName = DataBaseConstants.EMPLOYEE_SEQ)
  @GeneratedValue(generator = DataBaseConstants.EMPLOYEE_ID)
  @Column(name = DataBaseConstants.EMPLOYEE_ID)
  private long id = 0;
  @Column(name = DataBaseConstants.EMPLOYEE_NAME)
  private String name = null;
  @ManyToOne(cascade = CascadeType.ALL)
  @JoinColumn(name = DataBaseConstants.ADDRESS_ID_FK)
  private Address address = null; 
  
  private Map&lt;Office, Position&gt; officePositions = null;
  </code></pre>
  
  <p>Here is part of data model in data base.
  <a href="http://imgur.com/S1ZWu.jpg" rel="nofollow">DB MODEL IMAGE</a>
   (Sorry I can't post images)
  Help me please to mapping officeEmployee MAP</p>
  
  <p>In Hibernate i used this way and everything was OK. </p>
  
  <pre><code>&lt;map name="officePositions" table="EMPLOYEE_POSITION_OFFICE" lazy="false"
                  fetch="join" batch-size="100"&gt;
              &lt;key&gt;
              &lt;column name="EMPLOYEE_ID"&gt;&lt;/column&gt;
          &lt;/key&gt;
          &lt;map-key-many-to-many class="com.example.jpajdbctask.entities.Office"&gt;
              &lt;column name="OFFICE_ID"&gt;
              &lt;/column&gt;
          &lt;/map-key-many-to-many&gt;
          &lt;many-to-many column="POSITION_ID"
              class="com.example.jpajdbctask.entities.Position" /&gt;
          &lt;/map&gt; 
  </code></pre>