What is the difference between javax.persistence.metamodel.Map and java.util.Map?

梦想与她 提交于 2019-12-25 08:05:46

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!