Thanks, did that and the map is indeed serialized now. But now, the
enitity is fetched, seems like the state is not always kept.

For example, I would like to store some attribute from an HttpSession
using the UserStats instance. Every time a user in a session press
some button, a instance is fetched (using the session id as an
identifier) and update a counter in the HashMap. The problem I faced
is even that the object is found by the JDO, the counter updated and
the object persisted again, next fetch does not return the instance
with the updated counter. Can you help please debugging this?

This is the data object:

@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class UserStats
{
        @PrimaryKey
        @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
        private Key                                                     key;

        @Persistent
        private String                                          id;

        @Persistent
        private Long                                            time;

        @Persistent( serialized ="true" )
        private HashMap<String, Integer>        queries;

        public UserStats( String id, Long time )
        {
                this.id = id;

                this.time = time;

                queries = new HashMap<String, Integer>();
        }

        public Key getKey()
        {
                return key;
        }

        public String getId()
        {
                return id;
        }

        public void setId( String id )
        {
                this.id = id;
        }

        public Long getTime()
        {
                return time;
        }

        public void setTime( Long time )
        {
                this.time = time;
        }

        public HashMap<String, Integer> getQueries()
        {
                return queries;
        }

        public void setQueries( HashMap<String, Integer> queries )
        {
                this.queries = queries;
        }
}

On Oct 29, 10:38 am, Patrizio Munzi <[email protected]> wrote:
> HashMap isn't supported as a persistable type.
> The only way you've got to persist it is serialize 
> it:http://gae-java-persistence.blogspot.com/2009/10/serialized-fields.html
> 1KViewDownload
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to