C
Chris Ward
Hi all,
Does anyone out there have experience of using Map in JPA entities but
with a third class as the Key?
I have no problem in using the "standard" Map scenario - where the key
field is an attribute of the value object.
e.g.
@Entity
public class Department {
...
@OneToMany(fetch = EAGER)
@MapKey(name = "name")
private Map<String, Employee> employees = new HashMap<String,
Employee>();
...
}
Where the String (name) value is an attribute of the Employee class.
What I want to do is ...
@Entity
public class ClassA {
...
@OneToMany()
private Map<ClassB, ClassC> lookup = new HashMap<ClassB, ClassC>();
...
}
Where ClassB is NOT an attribute of ClassC.
Is there some funky form of the @MapKey annotation that I can use?
Many thanks for any replies on this.
Chris
Does anyone out there have experience of using Map in JPA entities but
with a third class as the Key?
I have no problem in using the "standard" Map scenario - where the key
field is an attribute of the value object.
e.g.
@Entity
public class Department {
...
@OneToMany(fetch = EAGER)
@MapKey(name = "name")
private Map<String, Employee> employees = new HashMap<String,
Employee>();
...
}
Where the String (name) value is an attribute of the Employee class.
What I want to do is ...
@Entity
public class ClassA {
...
@OneToMany()
private Map<ClassB, ClassC> lookup = new HashMap<ClassB, ClassC>();
...
}
Where ClassB is NOT an attribute of ClassC.
Is there some funky form of the @MapKey annotation that I can use?
Many thanks for any replies on this.
Chris