[
https://issues.apache.org/jira/browse/OPENJPA-1361?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Matthew T. Adams updated OPENJPA-1361:
--------------------------------------
Attachment: case-sandbox-property-access.zip
At the suggestion of Mike Dick
(http://n2.nabble.com/Using-mappedBy-getting-not-a-valid-inverse-relation-tt3880282.html#a3903117),
tried property-based access & annotating the interface member with @OneToMany.
Got correct schema, but can't persist concrete type implementing interface,
getting error:
<openjpa-1.2.1-r752877:753278 nonfatal store error>
org.apache.openjpa.persistence.EntityExistsException: Attempt to persist
detached object "example.model.concr...@81fb". If this is a new instance, make
sure any version and/or auto-generated primary key fields are null/default when
persisting.
FailedObject: example.model.concr...@81fb
Doesn't matter anyway, since property access is neither desirable nor an option.
> Enhancer fails when using OneToMany.mappedBy on bidi one-to-many relationship
> when using interface references on many side
> --------------------------------------------------------------------------------------------------------------------------
>
> Key: OPENJPA-1361
> URL: https://issues.apache.org/jira/browse/OPENJPA-1361
> Project: OpenJPA
> Issue Type: Bug
> Affects Versions: 1.2.1
> Reporter: Matthew T. Adams
> Attachments: case-sandbox-property-access.zip, case-sandbox.zip
>
>
> Synopsis: bidirectional one-to-many relationship where the one side
> references the objects on the many side using a concrete class reference and
> the many side references the object on the one side using an interface
> reference. When specifying the mappedBy property of the @OneToMany
> annotation, the OpenJPA enhancer throws the error:
> Collection field "example.model.Concrete.pebbles" declares that it is mapped
> by "example.model.Pebble.buildingMaterial", but this is not a valid inverse
> relation.
> When I remove the mappedBy property, everything works fine, except that
> OpenJPA creates an extra join table (Concrete_Pebble) where it shouldn't,
> IMHO. I have two questions, an answer to either one of which will suffice:
> 1. Why can't I use mappedBy in this scenario?
> 2. How do I annotate things with @JoinColumn or similar that will allow me to
> not have a join table and only the reference from Pebble back to its
> BuildingMaterial?
> I'll attach test case next.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.