|
View:
New views
3 Messages
—
Rating Filter:
Alert me
|
|
|
Problem with mapping mixed mapsHi,
i could not find a solution for the following problem by searching google, reading docs and this forum/mailing-list. I want a many-to-many mapping between two entities with an additional column. I know how to do it by adding an additional association class, but is there a possibility to accomplish this task by using a map like @Entity public class Class1 { @Id protected int id; protected String name1; public class Class2 { @Id protected int id; protected String name2; @??? protected Map<Class1, Integer> class1; By mixed maps i mean maps having entities as keys and "primitives" as values. I hope someone can help me. Regards, Winfried |
|
|
Re: Problem with mapping mixed mapsThere is no way to do this in JPA or EclipseLink currently, other than adding a class to represent the association. You could still model it as a Map, you would just need to have another variable storing the association class, and could lazy init the transient Map variable from the other (and back again the other way, but probably better to just model the association class).
JPA 2.0 may offer a Map mapping such as this. I'm not sure on the value being a primitive though, I think the spec's current intension is to allow the key to be a primitive. If your an ultra advanced user you could always create your own EclipseLink mapping subclass for your mapping. Probably subclass ManyToManyMapping, but it may not be a walk in the park. Please contribute it back if your successful though.
James Sutherland EclipseLink, TopLink Wiki: EclipseLink, TopLink Forums: TopLink, EclipseLink Book: Java Persistence |
|
|
Re: Problem with mapping mixed maps
JPA 2.0 will specify a mapping such as this and this functionality is
planned for our EclipseLink 1.1 release. http://bugs.eclipse.org/241410
If you watch the bug you should be able to see when the work is completed and get access through a nightly build. In the meantime you will be limited to the suggestions offered by James. --Gordon James Sutherland wrote: There is no way to do this in JPA or EclipseLink currently, other than adding a class to represent the association. You could still model it as a Map, you would just need to have another variable storing the association class, and could lazy init the transient Map variable from the other (and back again the other way, but probably better to just model the association class). JPA 2.0 may offer a Map mapping such as this. I'm not sure on the value being a primitive though, I think the spec's current intension is to allow the key to be a primitive. If your an ultra advanced user you could always create your own EclipseLink mapping subclass for your mapping. Probably subclass ManyToManyMapping, but it may not be a walk in the park. Please contribute it back if your successful though. converted2EL wrote: _______________________________________________ eclipselink-users mailing list eclipselink-users@... https://dev.eclipse.org/mailman/listinfo/eclipselink-users |
| Free embeddable forum powered by Nabble | Forum Help |