2

I would like to add a mapping like

Map<String, List<String>> attributes;

I have used already @MapKeyColumn for other situation, but here I do have a key/value table where a key might occur several time.

How would you solve this? Is there any (JPA built-in) solution for that kind of problem domain?

Thank you for your response!

Thomas
  • 8,357
  • 15
  • 45
  • 81
  • 1
    If you don't find any solution, just make a custom class, which has the attributes "name" and "List" – Tobi Apr 24 '12 at 08:02
  • Thank you :-) I do have a custom class which represent an attribute. It's a list of these objects within my entity. A Map would just be more convenient. – Thomas Apr 24 '12 at 08:22

1 Answers1

2

There is no direct way. You need to create a class to represent the association or perform some sort of conversion in get/set methods.

See,

http://en.wikibooks.org/wiki/Java_Persistence/Relationships#Nested_Collections.2C_Maps_and_Matrices

James
  • 17,965
  • 11
  • 91
  • 146