SQL generated even for FetchType.LAZY reference [message #1737561] |
Sat, 09 July 2016 21:52  |
Eclipse User |
|
|
|
I have a reference in an entity to its parent entity, and annotated it:
@ManyToOne(fetch=FetchType.LAZY)
to prevent it from making an unnecessary database call. Still, I'm seeing SQL generated to retrieve the parent entities, even for those that are common and should have been in the level 1 cache. I shouldn't have had to, but I also enabled the shared cache, and this, as expected, had no effect.
I then tried adding the query hint "eclipselink.batch" with a value of "x.task" (referring to the parent). Now there's only a single single SQL statement generated for the parent, which makes sense.
The batch hint is an improvement, but in the first case, at least, we shouldn't be seeing any DB call made for a LAZY reference, correct? Is there something I need to set to prevent this unnecessary call?
|
|
|
|
|
|
Re: SQL generated even for FetchType.LAZY reference [message #1739403 is a reply to message #1739155] |
Sun, 31 July 2016 19:32  |
Eclipse User |
|
|
|
Thanks, Chris. I deliberately excluded that field from toString(), etc., but I'm seeing the query calls for those parent records being issued at the same time as the main query. In any case, I'll try what you said and get back to you.
Best,
Ari
[Updated on: Sun, 31 July 2016 19:35] by Moderator
|
|
|
Powered by
FUDForum. Page generated in 0.04398 seconds