openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Vermeulen (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (OPENJPA-2239) removing from one List<X> removes all from other List<X> in same entity
Date Fri, 21 Sep 2012 15:14:07 GMT

    [ https://issues.apache.org/jira/browse/OPENJPA-2239?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13460546#comment-13460546
] 

Vermeulen commented on OPENJPA-2239:
------------------------------------

I had another occurence of this bug which is even more subtle to find. My Appointment entity
extends the Booking entity which has a list of rooms in which the appointment takes place.
The Appointment entity has a different list of rooms to visit (as a tour). The subclass has
to specify a different join table otherwise this bug appears.
                
> 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
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message