Skip to:
So I’ve just woken up to how hard it really is to do something like join fetch an @Any mapping.
join fetch
@Any
I got some distance with this by mapping the association @Any(fetch=LAZY), and then using a query like this:
@Any(fetch=LAZY)
And then as long as I remember to force-initialize n.thing before the tx ends, it essentially works.
n.thing
There’s three things wrong with this:
it’s pretty verbose,
I have to explicitly force-initialize the proxies, and
if I switch to @Any(fetch=EAGER)(which is the default, ugh) then I start getting n+1 selects.
@Any(fetch=EAGER)
So, damn, it would sure be nice to be able to write things like:
But I would say the highest priority would be to simply fix the problem that fetch=EAGER automatically results in extra unnecessary selects.
fetch=EAGER
So I’ve just woken up to how hard it really is to do something like
join fetch
an@Any
mapping.I got some distance with this by mapping the association
@Any(fetch=LAZY)
, and then using a query like this:And then as long as I remember to force-initialize
n.thing
before the tx ends, it essentially works.There’s three things wrong with this:
it’s pretty verbose,
I have to explicitly force-initialize the proxies, and
if I switch to
@Any(fetch=EAGER)
(which is the default, ugh) then I start getting n+1 selects.So, damn, it would sure be nice to be able to write things like:
But I would say the highest priority would be to simply fix the problem that
fetch=EAGER
automatically results in extra unnecessary selects.