so I am trying to build a google app engine using servlets, filters etc. I have a java file that looks something like:
public class Idea implements Comparator<Idea> {
@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
private Key key;
@Persistent
private User author;
@Persistent
private String content;
@Persistent
private Date date;
@Persistent
private Map<User, Boolean> positiveVotes ;
@Persistent
private Map<User, Boolean> negativeVotes;
public Idea(User author, String content, Date date) {
this.author = author;
this.content = content;
this.date = date;
this.positiveVotes = new HashMap<User, Boolean>();
this.negativeVotes = new HashMap<User, Boolean>();
}
but when I try to run my program, I get an exception stack beginning with:
Feb 13, 2010 5:01:23 PM com.google.apphosting.utils.jetty.JettyLogger warn
WARNING: /sign
java.lang.IllegalArgumentException: positiveVotes: java.util.HashMap is not a supported property type.
at com.google.appengine.api.datastore.DataTypeUtils.checkSupportedSingleValue(DataTypeUtils.java:145)
at com.google.appengine.api.datastore.DataTypeUtils.checkSupportedValue(DataTypeUtils.java:127)
at com.google.appengine.api.datastore.Entity.setProperty(Entity.java:280)
So, my question is why does it complain that java.util.HashMap is not a supported property type, and also what could I do to work around it. Thanks! hope someone replies soon.
You can ask GAE to store the HashMap as a Blob value by adding the JDO annotation to flag this field as being stored serialised:
@Persistent(serialized="true")
https://code.google.com/intl/pl/appengine/docs/java/datastore/dataclasses.html#Serializable_Objects
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With