问题
I am trying to write a JDO annotated class in GAE and I want to persist a map. The map is supposed to be an entity field that is a collection of entities hashed by Date. (I am not even sure if this is the right approach).
Eclipse's auto-complete provides me with javax.persistence.metamodel.Map and java.util.Map. What is the difference between these two? What is an example of the former?
回答1:
One is a class from a standard Java library that is supported in GAE, and the other is part of the JPA API (that you're not using).
回答2:
Only these collections [1] were allowed in google-app-engine:
java.util.ArrayList<...>
java.util.HashSet<...>
java.util.LinkedHashSet<...>
java.util.LinkedList<...>
java.util.List<...>
java.util.Set<...>
java.util.SortedSet<...>
java.util.Stack<...>
java.util.TreeSet<...>
java.util.Vector<...>
- See first comment below this post!
So I would recommend you to use these classes with the given packages.
[1] https://developers.google.com/appengine/docs/java/datastore/jdo/dataclasses?hl=de#Collections
回答3:
As far as I see from the javadoc of java.util.Map and javax.persistence.metamodel.Map which does not seem to exist in the latest API, the metamodel Map seems to be a wrapper over the util Map so that we can use it to get metadata about the util Map.
来源:https://stackoverflow.com/questions/14214480/what-is-the-difference-between-javax-persistence-metamodel-map-and-java-util-map