• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

Mapping Maps  RSS feed

 
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
I have gone to look for myself. If I should return before I get back, keep me here with this tiny ad:
how do I do my own kindle-like thing - without amazon
https://coderanch.com/t/711421/engineering/kindle-amazon
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!