[
https://issues.apache.org/jira/browse/OPENJPA-1253?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12755596#action_12755596
]
Fay Wang commented on OPENJPA-1253:
-----------------------------------
According to JPA 2.0 spec (Section 11.1.21),
The table in which the JoinColumn annotion is found depends upon the context.
(1) If the join is for a OneToOne or ManyToOne mapping using a foreign key
mapping strategy, the foreign key column is in the table of the source entity
or embeddable.
(2) If the join is for a unidirectional OneToMany mapping using a foreign key
mapping strategy, the foreign key is in the table of the target entity.
(3) If the join is for a ManyToMany mapping or for a one-to-one or
bidirectional
ManyToOne/OneToMany mapping using a join table, the foreign key is in a join
table.
(4) If the join is for an element collection, the foreign key is in a
collection table.
In comparison to the JPA 1.0 spec (Section 9.1.6):
The table in which it is found depends upon the context.
(1) If the join is for a OneToOne or Many-ToOne mapping, the foreign key column
is in the table of the source entity.
(2) If the join is for a ManyToMany, the foreign key is in a join table.
The JoinColumn annotation in v2.0 apparently becomes more flexible as it is
allowed to appear for a OneToMany mapping.
> JoinColumn annotation not allowed in conjunction with *ToMany annotation
> ------------------------------------------------------------------------
>
> Key: OPENJPA-1253
> URL: https://issues.apache.org/jira/browse/OPENJPA-1253
> Project: OpenJPA
> Issue Type: Bug
> Components: jdbc
> Affects Versions: 2.0.0-M1, 2.0.0-M2, 2.0.0-M3, 2.0.0-M4, 2.0.0
> Reporter: Rick Curtis
> Fix For: 2.0.0
>
>
> I receive the following exception if I have an Entity with a One(Many)ToMany
> relationship with another Entity.
> <openjpa-2.0.0-SNAPSHOT-r422266:805588 fatal user error>
> org.apache.openjpa.persistence.ArgumentException: You have supplied columns
> for "....Entity", but this mapping cannot have columns in this context.
> To recreate the failure, add a @JoinColumn annotation to one of the *ToMany
> relationships in org.apache.openjpa.persistence.jdbc.annotations.AnnoTest1.
> example:
> @MapKey(name = "basic")
> @OneToMany(mappedBy = "oneManyOwner")
> @JoinColumn(name = "asdf")
> protected Map<String, AnnoTest2> inverseOwnerMapKey = new HashMap();
> Then run:
> trunk\openjpa-parent\openjpa-persistence-jdbc>mvn test
> -Dtest=org.apache.openjpa.persistence.jdbc.annotations.TestOneToMany
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.