I had the same problem and came up with this snippet of code to work
around the issue. Use it when you are updating your object:
/**
* Iterates through the object and makes any persistent annotated
objects that are serialized = "true"
* dirty using <code>javax.jdo.JDOHelper.makeDirty</code>.
* @param <T>
* @param tInstance
*/
public static <T> void makeSerializedDirty(T tInstance){
for (Field field : tInstance.getClass().getDeclaredFields()) {
Persistent persistent =
field.getAnnotation(Persistent.class);
if(persistent != null &&
Boolean.valueOf(persistent.serialized())){
javax.jdo.JDOHelper.makeDirty(tInstance,
field.getName());
}
}
}
-Nick
On Oct 11, 7:34 pm, doc <[email protected]> wrote:
> This sample work but could not update content of HashMap
>
> Thank you Jason to provide useful sample. Based on this sample I have
> implemented my application which use hashMap. But when I add additem
> method like following added Item is not stored in a datastore.
>
> public void addUsers(String userID, CustomUser user)
> {
> users.put(userID, user.)
>
> }
>
> I guess the reason of this problem come from that JDO recognize this
> HashMap users as a serializable Blob. So when we access HashMap users,
> JOD deserialize Blob and create HashMap instance and provide us as a
> HashMap users instance. But JDO can not recognize what happen to the
> users after deserialization. So JDO do not try to save users when I
> close StateCore instance.
>
> So I changed code as following. This code could store added
> CoustomUser instance when I close StateCore instance.
>
> @NotPersistent
> private HashMap<String, CustomUser>usersTemp;
>
> public void addUsers(String userID, CustomUser addUser)
> {
> users.put(userID, addUser.)
>
> usersTemp=users;
> users=null;
> users=UsersTemp
>
> }
>
> Not sure this is the best counter measure for this problem but if
> someone has same problem , please try.
--
You received this message because you are subscribed to the Google Groups
"Google App Engine for Java" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-appengine-java?hl=en.