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
I can not use POJO because it's limited to a stable table so I'd like to use java object like this
class MyObject {
int id;
Map<String, Object> fields = new Map<String, Object>();
public void setId(int id) {
this.id = id;
}
public void setField(String key, Object value) {
fields.put(key, value);
}
}
The table for storing MyObject :
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;
And of course the possibility to query