An entity with two 'shared' collections i.e. member of the first collection
is a superset of the second collection. And I am mapping with a cross-table.
For example,
public class Question {
@OneToMany
private List<Choice> _choices;
@OneToMany
private List<Choice> _correctChoices;
}
If a Choice c belongs to _correctChoices, it must belong to _choices. That
is what I mean by _choices and _correctChoices are 'shared' collections.
The relationships are uni-directional i.e. Choice has no knowledge of
Question.
Now the mapping generates, as intended, a cross-table with three columns
QUESTION_ID, CHOICES_ID and CORRECTCHOICES_ID.
But during insert, two collections work independently so if I have a
Question (id=351) with 3 Choices (id=1,2,3) and correct choice is Choice 2,
then it inserts 4 rows
QUESTION_ID | CHOICES_ID | CORRECTCHOICES_ID
| 351 | 1 | NULL |
| 351 | 2 | NULL |
| 351 | 3 | NULL |
| 351 | NULL | 2 | -- this one is
for the correct choice element
Is there a way to tell OpenJPA to use the same rows of _choices for elements
of _correctChoice?
--
View this message in context:
http://n2.nabble.com/Mapping-of-uni-directional-%27shared%27-collection-tp734120p734120.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.