[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [eclipselink-users] Persisting a Map
|
So you are storing a Map in a VARCHAR column through serializing it through
your custom serializer, correct?
What does your setAttribute method do? Does it modify the Map in-place, or
create another Map?
It could be a mutability issue, you need to set mutable in your converter.
public boolean isMutable() {
return true;
}
phil rod 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
>
-----
http://wiki.eclipse.org/User:James.sutherland.oracle.com James Sutherland
http://www.eclipse.org/eclipselink/
EclipseLink , http://www.oracle.com/technology/products/ias/toplink/
TopLink
Wiki: http://wiki.eclipse.org/EclipseLink EclipseLink ,
http://wiki.oracle.com/page/TopLink TopLink
Forums: http://forums.oracle.com/forums/forum.jspa?forumID=48 TopLink ,
http://www.nabble.com/EclipseLink-f26430.html EclipseLink
Book: http://en.wikibooks.org/wiki/Java_Persistence Java Persistence
Blog: http://java-persistence-performance.blogspot.com/ Java Persistence
Performance
--
View this message in context: http://old.nabble.com/Persisting-a-Map-tp31648129p31708315.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.