I have 3 classes: A, B, C
class A { private HashMap<String, B> Bs; @OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.PERSIST, mappedBy = "a") public HashMap<String, B> getBs() { return Bs; } }
class B { Long id; A a; C c; @OneToOne @JoinColumn(name="cId", nullable=false) public C getC() { return c; } }
class C { @Id String name; ...... }
I want to fetch A and at the same time eager fetch B. I also want to use c.name as the hashmap key.(c.name is in the table B as cId) But I don't want to eager fetch C, because C has many other attributes which i don't need. Is it possible? If yes, how can do it? (I didn't use mapkey because it will use class C as the key which is not what i want. maybe there is another way using mapkey that can achieve my goal)
Thanks in advance
|