[
https://issues.apache.org/jira/browse/OPENJPA-2239?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13422390#comment-13422390
]
Kevin Sutter commented on OPENJPA-2239:
---------------------------------------
Thanks for the background and insights. Issuing a warning might be a good way
to go. Based on the comments from you and your colleague, I can understand why
"something" needs to be done. There are too many assumptions being made and
when some action breaks one of those assumptions, the outcome is not
discernable. OpenJPA needs to do something with this type of scenario. Thanks
for the comments and the testcase for reproducing it.
> removing from one List<X> removes all from other List<X> in same entity
> -----------------------------------------------------------------------
>
> Key: OPENJPA-2239
> URL: https://issues.apache.org/jira/browse/OPENJPA-2239
> Project: OpenJPA
> Issue Type: Bug
> Components: kernel
> Affects Versions: 2.1.1
> Reporter: Vermeulen
> Attachments: Order.java, OrderLine.java, OrderLineRemovalBugTest.java
>
>
> I have an Order entity that has two separate lists of OrderLine entities:
> ...
> @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
> private List<OrderLine> plannedOrderLines = new ArrayList<OrderLine>();
> @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
> private List<OrderLine> actualOrderLines = new ArrayList<OrderLine>();
> ...
> I remove a single element from actualOrderLines, then merge the entity and
> close the entity manager. When I find the entity again with a different
> entity manager, the plannedOrderLines list is empty.
> OpenJPA generates one join table that contains entries for both lists. I used
> this configuration for a long time and it seems to work fine except for this
> bug. I verified in the database that the entries for planned order lines are
> all removed from the join table.
> Workaround: use @JoinTable or @JoinColumn annotation so that both lists do
> not map to the same join table.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira