openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Henno Vermeulen <he...@huizemolenaar.nl>
Subject RE: How to add children to disconnected entity?
Date Wed, 26 Sep 2012 09:19:51 GMT
Hi,

I verified this situation by making an extra unit test in our system. We always work with
detached entities as well. The test works fine for me.

One explanation for this behavior is that the @OneToMany field does not use "fetch = FetchType.EAGER"
because relations are lazily fetched by default. (Or alternatively you have not included the
field in OpenJPA's FetchPlan before calling entityManager.merge which has the same effect
as FetchType.EAGER even if the @OneToMany field is not eager).

When I adjust my test to lazily fetch the field, then saving a new Assessment somehow DOES
cascade merge new AssessmentResults. However when I merge an existing Assessment that has
one existing AssessmentResult and one new AssessmentResult, OpenJPA will not cascade merge
it.

-----Oorspronkelijk bericht-----
Van: Jim Talbut [mailto:jtalbut@spudsoft.co.uk] 
Verzonden: woensdag 26 september 2012 0:02
Aan: 'users@openjpa.apache.org'
Onderwerp: How to add children to disconnected entity?

Hi,

I have a pair of entities: Assessment & AssessmentResults, with a 
One-to-Many relationship (an assessment can have many results).
The Assessment is modified whilst disconnected (outside of a transaction).

Is there any way to have AssessmentResults added whilst the Assessment 
is disconnected be persisted automatically when the Assessment gets merged?
Setting CascadeType.Merge doesn't seem to do it (I think that merges 
existing children, not adds new children).

Thanks

Jim


Mime
View raw message