Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] cardinality does not correspond

You need to change your @OneToOne to @ManyToOne.


otismo wrote:
> 
> How should I map the following relationship?  I have an owning object
> which contains a map of target objects.  I want the Target object to
> maintain a reference to the Owner.
> 
> class Owner {
>     @OneToMany(cascade = CascadeType.ALL)
>     @MapKey(name = "date")
>     private Map<Date, Target> targets= new TreeMap<Date, Target>();
> }
> 
> class Target {
>     @OneToOne(mappedBy = "targets")
>     private Owner owner;
> }
> 
> Understandably, the above results in the following error: An incompatible
> mapping has been encountered between [Target] and [Owner]. This usually
> occurs when the cardinality of a mapping does not correspond with the
> cardinality of its backpointer.
> 
> Any tips?
> 
> Thanks,
> Peter
> 
> 


-----
---
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/cardinality-does-not-correspond-tp21384261p21417205.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.



Back to the top