[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [eclipselink-users] Toplink bidirectional OneToMany
|
What is your code for the two classes in error? You most like have a
OneToMany back instead of ManyToOne. Check that your code is correct and
compiled/deployed correctly.
The code in TopLink Essentials is fine, isOneToOneMapping() in the model is
true for ManyToOne as well as OneToOne.
Stevo Slavic wrote:
>
> Hello eclipselink users,
>
> First of all, is it ok to ask toplink questions on this mailing list?
>
> Assuming it is, here is my case.
> In a project using (legacy) technologies like jpa 1.0, glassfish 2.1.1
> (with provided toplink 2.1-b31g-fcs) I'm getting infamous
> TOPLINK-7244,
>
> "An incompatible mapping has been encountered between [class X] and
> [class Y]. This usually occurs when the cardinality of a mapping does
> not correspond with the cardinality of its backpointer."
>
> In this (see
> http://download.oracle.com/docs/cd/B10464_05/web.904/b10313/mapping.htm#1108697
> ) toplink guide paragraph there is following statement:
>
> "Use one-to-many mappings for relationships between entity beans or
> between an entity bean and a collection of privately owned regular
> Java objects. When you create one-to-many mappings, also create a
> one-to-one mapping from the target objects back to the source."
>
> In
> oracle.toplink.essentials.internal.ejb.cmp3.metadata.accessors.OneToManyAccessor.process()
> method when mappedBy is specified so that many part is owner of the
> relationship, toplink enforces that owning many side instead of having
> @ManyToOne has @OneToOne annotation
>
> {code}
> // Create a 1-M mapping and process common collection mapping
> // metadata.
> OneToManyMapping mapping = new OneToManyMapping();
> process(mapping);
>
> // Non-owning side, process the foreign keys from the owner.
> OneToOneMapping ownerMapping = null;
> if (getOwningMapping().isOneToOneMapping()){
> ownerMapping = (OneToOneMapping) getOwningMapping();
> } else {
> // If improper mapping encountered, throw an exception.
> getValidator().throwInvalidMappingEncountered(getJavaClass(),
> getReferenceClass());
> }
> {code}
>
> What's wrong with toplink, even @OneToMany jpa 1.0 javadoc lists
> following as first example:
>
>
> Example 1: One-to-Many association using generics
>
> In Customer class:
>
> @OneToMany(cascade=ALL, mappedBy="customer")
> public Set getOrders() { return orders; }
>
> In Order class:
>
> @ManyToOne
> @JoinColumn(name="CUST_ID", nullable=false)
> public Customer getCustomer() { return customer; }
>
>
>
> What am I missing here?
>
> Regards,
> Stevo.
>
>
-----
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
Blog: http://java-persistence-performance.blogspot.com/ Java Persistence
Performance
--
View this message in context: http://old.nabble.com/Toplink-bidirectional-OneToMany-tp32364754p32380430.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.