• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Mapping Maps

 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have the following (stripped down) entity:


I'm trying to figure out how to annotate the values Map. I've tried CollectionOfElements but that only seems to work if both key and value are non-entity objects like String, Integer, etc. I'm going that elsewhere and it works fine. I also tried a @OneToMany with an @MapKey however, the key in my case is not the target entity property.

Note also that StoredReportScheduleMetricValue is an Entity as well and has its own set of properties that need to be persisted.

The reason I am using a Map instead of a list is because I can't guarantee order so indexed properties won't work correctly when the data is loaded back up.

Any help is appreciated.
 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Gregg Bolinger wrote:
The reason I am using a Map instead of a list is because I can't guarantee order so indexed properties won't work correctly when the data is loaded back up.


Why Map then? You need to replace list with a no order specified.. you should use java.util.Set, Right?

If you must use Map for some other reason, think about how you going to persist your relation.. Not very clear as to what you want to persist in the related table.. May be an example would help understand your question..

HTH,
Vijay
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic