openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daryl Stultz <>
Subject left join fetch weirdness
Date Thu, 08 Oct 2009 15:12:28 GMT
Suppose I have entity A with field "bCol" which is a collection of "B". I
have 2 records of A, a1 having 2 B instances in bCol and a2 having 3 B
instances in bCol. I run this query to load the list of all A's and pre
fetch bCol:

// get em 1
select a from A as a
left join fetch a.bCol
// close em 1

I get 2 instances of A as expected, a1 and a2. Then I edit a2, first by
getting a fresh, deep instance:

//get em2
select a from A as a
left join fetch a.bCol
where = 2
// close em 2
... make edit to a2
// get em3

Then I reload the original list using the first query:
select a from A as a
left join fetch a.bCol
// close em 3

This time I get 4 rows with 3 copies (same hashCode) of a2 (apparently one
for each B child in bCol). It's as if the left join fetch turns into a left
join. Adding "distinct" to the query doesn't help. Interestingly I get only
1 instance of a1 even though it's got 2 in bCol. Note that the reload
happens on em3 - the same that the merge was done. If I call em3.clear()
before reloading, it works as expected, also if I close em3 and get em4
before reloading the list.

Am I not understanding something? Is there some aspect of L1 cache I'm not
handling properly?

OpenJPA 1.2.1.

Daryl Stultz
6 Degrees Software and Consulting, Inc.

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message