[
https://issues.apache.org/jira/browse/OPENJPA-2593?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14569090#comment-14569090
]
Rick Curtis commented on OPENJPA-2593:
--------------------------------------
I didn't take the time to debug through the code, but I suspect this is working
as expected.
My bet as to what is going on here is that OpenJPA keeps track of the fact that
this field is already 'loaded' in the previous persistence context. Even
through you closed the first context, we're still able to track state via
DetachedState[1] and when you call model.getPlants() we think that field is
already loaded(even though it's empty/null). You could call em.refresh(model)
to ensure that we get the most recent data?
[1]
http://ci.apache.org/projects/openjpa/trunk/docbook/manual.html#ref_guide_detach_state
> Many-to-many collection is not lazily loaded if entity has been merged into
> context right after persist
> -------------------------------------------------------------------------------------------------------
>
> Key: OPENJPA-2593
> URL: https://issues.apache.org/jira/browse/OPENJPA-2593
> Project: OpenJPA
> Issue Type: Bug
> Components: jpa
> Affects Versions: 2.3.0
> Reporter: Alexander Budarov
> Priority: Minor
> Attachments: testcase-mtm.zip
>
>
> Steps are the following:
> 1) Persist an entity which has a many-to-many collection link;
> 2) Create related entity;
> 3) Merge first entity to another persistence context.
> 4) Try to lazily load collection - it does not get loaded.
> If you reload the entity in a separate transaction through
> entityManger.find() before merging - lazy loading works.
> Test project with two test cases attached (please run test methods
> separately).
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)