title: Bulk insertion of CollectionTable elements in Hibernate / JPA
body: <p>We are using Hibernate 4.2 as the backing library for JPA 2.0 entities. We have an entity like the following:</p>
  
  <pre><code>@Entity
  public class MyEntity {
      ....
      @ElementCollection
      @MapKeyColumn(name = "key")
      @Column(name = "value")
      @CollectionTable("MyEntityMap")
      private Map&lt;String, Integer&gt; theMap;
      ...
  }
  </code></pre>
  
  <p>The map potentially has thousands of entries. I have set <code>hibernate.jdbc.batch_size=50</code>, but Hibernate still generates an insert statement for each entry in the map, when I say <code>entityManager.persist(myEntity)</code>. Is there a way to make Hibernate insert the values in a bulk insert like <code>INSERT INTO MyEntityMap () VALUES (), (), (), (), ()</code>?</p>