title: Hibernate - How to persist a HashMap
body: <p>Searching Stackoverflow, I saw that many people have my same problem, but I can't find out the solution looking at the other posts. So:</p>
  
  <p>I am trying to persist a Hibernate class, but without using an Entity Object. Instead I am using a Map.</p>
  
  <p>This is my map:</p>
  
  <pre><code>Map&lt;String, Object&gt; record;
  record = new HashMap&lt;String, Object&gt;();
  
  ...
  
  record.put("key1", "value");
  record.put("key2", "value");
  record.put("field1", "value");
  record.put("field2", "value");
  record.put("field3", "value");
  record.put("field4", "value");
  record.put("field5", "value");
  record.put("field6", value);
  record.put("field7", value);
  </code></pre>
  
  <p>and this is the hbm.xml</p>
  
  <pre><code>&lt;class entity-name="entity_name" dynamic-update="true"&gt;
  &lt;composite-id name="Key1Key2" class="classname"&gt;
      &lt;key-property name="Key1" column="Key1" type="string"/&gt;
      &lt;key-property name="Key2" column="Key2" type="string"/&gt;
  &lt;/composite-id&gt;
      &lt;property name="field1" column="field1" type="string"/&gt;
      &lt;property name="field2" column="field2" type="string"/&gt;
      &lt;property name="field3" column="field3" type="string"/&gt;
      &lt;property name="field4" column="field4" type="string"/&gt;
      &lt;property name="field5" column="field5" type="string"/&gt;
      &lt;property name="field6" column="field6" type="double"/&gt;
      &lt;property name="field7" column="field7" type="double"/&gt;
  &lt;/class&gt;
  </code></pre>
  
  <p>When I try to persist the record:</p>
  
  <pre><code>super.session.persist("entity_name", record)
  </code></pre>
  
  <p>This error is returned:</p>
  
  <p><strong>org.hibernate.id.IdentifierGenerationException: ids for this class must be manually assigned before calling save()</strong></p>
  
  <p>Can anyone help me?
  Thank in advance!</p>