1

Let's say I have a domain object with the following field:

private Map<StatType, Double> maxValues = new HashMap<StatType, Double>();

StatType is an Java enum.

How do I map this using JPA?

egervari
  • 22,372
  • 32
  • 121
  • 175
  • Somewhat similar: http://stackoverflow.com/questions/853076/jpa-mapstring-string-mapping Does it solve your problem? – zeller Sep 12 '12 at 07:04
  • @zeller It complains that Double is an ummapped class. – egervari Sep 12 '12 at 07:13
  • Because a map should be a mapping between two columns/tables. Now I think I understand what you really want, but I don't know if it is possible to map single column to a java `Map`. – zeller Sep 12 '12 at 07:15

1 Answers1

3

Another post that maybe helps: Storing a Map<String,String> using JPA. This solves the intra-table column-to-column mapping. If you really want to store a Map in a single column, I guess the only possible solution is to store it as a @Lob. An other SO post that describes this, though, in Hibernate: How to persist a HashMap with hibernate

Community
  • 1
  • 1
zeller
  • 4,904
  • 2
  • 22
  • 40