-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Persist dynamic map
PostPosted: Mon Jul 09, 2012 2:22 am 
Newbie

Joined: Wed Jul 04, 2012 10:13 pm
Posts: 2
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.