Hi,
is there any way to persist the map with dymamic fields.Here is sample code
Table :
A table with more than 200 fields.
POJO :
public class DynamicEntity { private Long id;
private Map<String,String> fields = new HashMap();
public Long getId() { return id; } public void setId(Long id) { this.id = id; }
public void add(String key,String value){ fields.put(key,value); }
}
The map in the pojo holding dynamic fields.
Hbm file
<class entity-name="DynamicEntity" table="cs_data" lazy="false" > <id name="id" type="java.lang.Long" > <column name="ID" /> <generator class="increment" ></generator> </id> </class>
Transactional code ..
GenericData data = new GenericData(); data.addField("name", "CF"); data.addField("description", "CF-USA"); data.addField("server", "ServerName"); //get the session session.save(data);
is there any way to save the map here when I save the pojo ?Here fields are not configured in hbm file because all the fields are dynamic.
Regards, Ravi.
|