On Wed, May 18, 2011 at 8:45 AM, phil rod <
philrod.phil@xxxxxxxxx <mailto:
philrod.phil@xxxxxxxxx>> wrote:
Hi All,
I have the following Mappings:
class MyPref {
long id;
@OneToOne
(cascade=CascadeType./ALL/, fetch=FetchType./EAGER/)
**PDMap attributes = *new* PDMap();
}
class PDMap {
long id;
@OneToMany
(mappedBy="dMap", cascade=CascadeType./ALL/, fetch=FetchType./EAGER/)
@MapKey(name="name")
Map<String, PD>
mapOfMaps = *new* HashMap<String, PD>();
}
table PD
class PD {
long id;
@ManyToOne
*private* PDMap dMap;
@Converter
(name="mapConverter",
converterClass=StringMapJsonSerializedObjectConverter.*class*)
@Convert("mapConverter")
Map<String, Object> map = *new* HashMap<String, Object>();
}
I am trying to do the following .
first time I insert into the entities using the key "ui" for PDMap
and the key "recentprojs" for the PD's map.
PDMap looks like this
id , creationdate, lastupdatedate
1 , date, date
table PD looks like this:
id, name, map dmap_id
1, "ui", {"recentprojs":"11"}, 1
next time when I retreive the same row using
myPref.getAttribute("ui","recentprojs"); i get the right row.
now I am trying to update that entry to something like this:
myPref.setAttribute("ui","recentprojs", "11,9");
em.merge(myPref)
so that PD table look like this:
id, name, map dmap_id
1, "ui", {"recentprojs":"11,9"}, 1
and PDMap updates the respective dates,
but since I am updating the value for the same key its not detecting
any changes and no updates happen to the tables... why is this ?
but when I change the it to something like this :
userPref.setAttribute("ui_1","recentproj", "11,9"); a new record
gets inserted in PD table but no update to the dates in PDMap table. but What I want to achieve is update the same row with the
new/updated values, how can I do this , and what is happening here..
Appreciate Any suggestiongs and ideas ?
Thank you!
Phil