[
https://issues.apache.org/jira/browse/OPENJPA-2239?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13421493#comment-13421493
]
Kevin Sutter commented on OPENJPA-2239:
---------------------------------------
Although I can understand the problem you are describing, isn't the proper
solution to define the alternate join table as you suggested? If you want to
maintain two separate relationships between two entitiy types, you need the
ability to separate those concerns. By default, JPA will utilize the same join
table and join columns based on the entity names and definitions. So, if you
need to maintain two separate relationships, you'll need two separate join
tables.
Or, to put it another way, how would you expect OpenJPA's behavior to change
for this scenario? Issue a warning that the same table is being utilized?
Throwing an exception wouldn't be good since there may be scenarios where
defining two relationships is a valid operation. Automatically synch up the
plannedOrderLines and actualOrderLines? But, that isn't what you would expect
either.
Not sure what your expectations are with this JIRA. Thanks.
> 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