Hi
Your are right. You have to store the mapkey to class1 in a class2 object at your own. It is not done automatic.
The definition of a map in java is:
Map - an object that maps keys to values. A Map cannot contain duplicate keys; each key can map to at most one value.
So in the definition of the collection frameworks, the map key is unique in a map. So the behaviour is correct.
Kind regards
-----Ursprüngliche Nachricht-----
Von: fedr [mailto:fury123_at_gmail.com]
Gesendet: Freitag, 4. April 2008 23:27
An: persistence_at_glassfish.dev.java.net
Betreff: Re: AW: Problems Mapping Map
Juerg.Treichler wrote:
>
> Hi
>
> In Class2 you need a reference to Class1.
> This reference is the @MapKey in the Class3.
>
> If you load the a class3 object the system loads all corresponding
> Class2 objects and use the key (the reference to class1) from the
> loaded class2 objects.
>
> Kind regards
>
> Jürg
>
i tried this; on Class2 i put a Class1 reference:
private Class1 mapkey; and i setup the accessor methods
on Class3 i put:
@ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
@MapKey(name = "mapkey")
public Map<Class1, Class2> getHm() {
return hm;
}
what i notice is that when i create a Class2 object i have to store on it the Class1 object that is the key of the Map, it is not automatic.
But anyway with this solution i can have only one key-value pair, there is only one reference to Class1.
I can't have more keys that refer to the same value, it's not a real Map.
I think i miss something.
Can you tell me what is wrong?
thanks for help.
--
View this message in context: http://www.nabble.com/Problems-Mapping-Map-tp16468447p16500172.html
Sent from the java.net - glassfish persistence mailing list archive at Nabble.com.