title: JPA/Hibernate with Dynamic Object Model
body: <p>I have a table with the number of column is variable (depend of customer), 
  so I looking for a way to mapping this table with a java object using JPA/Hibernate or other</p>
  
  <p>I can not use POJO because it's limited to a stable table so I'd like to use java object like this</p>
  
  <pre><code>class MyObject {
  int id;
  Map&lt;String, Object&gt; fields = new  Map&lt;String, Object&gt;();
  
  public void setId(int id) { 
      this.id = id; 
  }
  
  public void setField(String key, Object value) { 
      fields.put(key, value);
  }
  </code></pre>
  
  <p>}</p>
  
  <p>The table for storing MyObject :</p>
  
  <pre><code>TABLE MYTABLE (
  ID INTEGER,
  FIELD1 VARCHAR, 
  FIELD2 DATE, 
  FIELD3 INTEGER
  )
  
  
  MyObject myObject = new MyObject();
  myObject.setId(id);
  myObject.setField("FIELD1" , "hello world");
  myObject.setField("FIELD2" , new Date());
  myObject.setField("FIELD3" , 21)
  
  Action to save myObject in db;
  </code></pre>
  
  <p>And of course the possibility to query</p>