I am working on a Java
project on my spare time,
I started using JPA 2.1
and learning to use annotations
.
I have a class named Schedule
that I want to contain this field:
private HashMap<LocalDate, ArrayList<Lesson>> theLessons
Lesson is another entity in my Database, LocalDate is the Java class.
Is that possible?
I tried to do it combining @OneToMany with @MapKey like in How do you map a "Map" in hibernate using annotations?
but with no effect.
I am thinking that maybe I will need to create other Entities
to facilitate this, like maybe a ListOfLessons
, that will contain the ArrayList<Lesson>
in order to shorten the HashMap
to :
private HashMap<LocalDate, ListOfLessons>
Any help welcome