Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Problem Persisting a Map

It's not completely clear to me what you are trying to do but...

For changes to be detected in an object, it must be managed. I don't see an settings that would cause your merge to be cascaded. Try either explicitly merging the objects you want to see changes for, or setting the mappings on your graph to cascade their merge.

-Tom

phil rod wrote:
Any suggestions and ideas how to solve this ?
While posting I missed one the fields for this class:
class PD {
long id; String name;

@ManyToOne

*private* PDMap dMap;

@Converter

(name="mapConverter", converterClass=StringMapJsonSerializedObjectConverter.*class*)

@Convert("mapConverter")

Map<String, Object> map = *new* HashMap<String, Object>();

}


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


------------------------------------------------------------------------

_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users


Back to the top