title: Hibernate and keyvalue pair implementation
body: <p>I would like to create a few classes which are in essense wrapper of a map of key value pair. What is the best appoarch to retrieve or store these classes into a database using hiberate? What are the right hibernate annotations to get the job done?</p>
  
  <p>On the database, I would expect this formation of data</p>
  
  <pre><code>class1, field1, value1
  class2, field2, value2
  class1, field2, somevalue1
  ...
  </code></pre>
  
  <p>On the java side, I may have</p>
  
  <pre><code>@Table("some_db_table")
  class KeyValuePairs {
  
    private HashMap&lt;String, String&gt; map;
  ...
  }
  
  class Class1 extends KeyValuePairs {
    private Stirng id = "class1";
  ...
  }
  
  class Class2 extends KeyValuePairs {
    private Stirng id = "class2";
  ...
  }
  </code></pre>