Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Problems Mapping Map

Also you could create an association object to model the many-to-many join
table.

See:
http://en.wikibooks.org/wiki/Java_Persistence/ManyToMany#Mapping_a_Join_Table_with_Additional_Columns


Gordon Yorke-2 wrote:
> 
> Ok, l thought you were attempting to map pre-existing  tables not 
> generate them.  What you are seeing when you use Hibernate is a 
> Hibernate  specific extension supporting Entities as Map keys when  
> there is no relation between the Map value and Map key.  This is not 
> supported in the JPA 1.0 specification. 
>  EclipseLink will support this type of relationship if there is  a 
> relationship between class1 and class2 and you use the @MapKey 
> annotation like:
> 
> @Entity
> public class Class2 {
>     @Id
>     protected int id;
>     protected String name;
>     @OneToOne
>     protected Class1 class1;
>    
> public class Class3 {
>     @Id
>     protected int id;
>     protected String name;
>     @MapKey(name="class1")
>     @ManyToMany
>     protected Map<Class1, Class2> class2;
> 
> --Gordon
> 
> 


-----
---
http://wiki.eclipse.org/User:James.sutherland.oracle.com James Sutherland 
http://www.eclipse.org/eclipselink/
 EclipseLink ,  http://www.oracle.com/technology/products/ias/toplink/
TopLink 
Wiki:  http://wiki.eclipse.org/EclipseLink EclipseLink , 
http://wiki.oracle.com/page/TopLink TopLink 
Forums:  http://forums.oracle.com/forums/forum.jspa?forumID=48 TopLink , 
http://www.nabble.com/EclipseLink-f26430.html EclipseLink 
Book:  http://en.wikibooks.org/wiki/Java_Persistence Java Persistence 
-- 
View this message in context: http://www.nabble.com/Problems-Mapping-Map-tp16485097p16537433.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.



Back to the top