Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

collections support in persistencemanager.

 
Pav Singh
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know if this is the right place to ask (my first time here) but here we go:
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.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35279
384
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pav,
Welcome to JavaRanch!

We have a forum just for Object Relational Mapping questions just a few forums down. I'll move this for you.
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't think, and I could be wrong, that JPA supports Maps as Collection Mappings. Now I know Hibernate can do it, but it might not be in the JPA 1.0 spec to allow it.

Mark
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic