Re: JPA Help

Summers Pittman <[email protected]> Tue, 28 Nov 2017 08:00:26 -0500
Newsgroups gmane.org.user-groups.ajug.members
Message-ID <CAEQz2Ct=b7EQBhPK03NUQS-M3Bw-gh_wpyQ1MsKHPg1+W-LE1Q@mail.gmail.com>
--===============6829753914884994706==
Content-Type: multipart/alternative; boundary="001a1130c102836d87055f0a9bd8"

--001a1130c102836d87055f0a9bd8
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

I haven't tested, but it looks like there are two options presented here :
https://stackoverflow.com/questions/31854776/how-to-force-eager-loading-wit=
h-crudrepository-in-spring-data

First, you can use a OneToMany mapping annotation and set the
fetchType=3Deager property.  Second you can call stream and then count on
your list which should eagerly fetch everything.  I think if you are
calling findAll and getting a list directly instead of using a mapping you
will still get the eager behavior.  Of course if you aren't on Java 8 this
isn't helpful.

On Mon, Nov 27, 2017 at 5:52 PM, Mike Barnes <mike.barnes-f9aWwpgOZj5Wk0Htik3J/[email protected]>
wrote:

> I am using the CrudRepository and am looking for a way to get list data
> back using something like FindAll without making a query for each row.
>
>
>
> My hibernate log shows something like below for a findall call
>
>
>
> select column1, column2 from myTable
>
> select column1, column2 from myTable
>
> =E2=80=A6
>
>
>
> Thanks
>
> Mike Barnes
>
>
>
> _______________________________________________
> ajug-members mailing list
> [email protected]
> Manage your subscription and unsubscribe http://lists.ajug.org/mailman/
> listinfo/ajug-members
>

--001a1130c102836d87055f0a9bd8
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">I haven&#39;t tested, but it looks like there are two opti=
ons presented here :=C2=A0<a href=3D"https://stackoverflow.com/questions/31=
854776/how-to-force-eager-loading-with-crudrepository-in-spring-data">https=
://stackoverflow.com/questions/31854776/how-to-force-eager-loading-with-cru=
drepository-in-spring-data</a><div><br></div><div>First, you can use a OneT=
oMany mapping annotation and set the fetchType=3Deager property.=C2=A0 Seco=
nd you can call stream and then count on your list which should eagerly fet=
ch everything.=C2=A0 I think if you are calling findAll and getting a list =
directly instead of using a mapping you will still get the eager behavior.=
=C2=A0 Of course if you aren&#39;t on Java 8 this isn&#39;t helpful.</div><=
/div><div class=3D"gmail_extra"><br><div class=3D"gmail_quote">On Mon, Nov =
27, 2017 at 5:52 PM, Mike Barnes <span dir=3D"ltr">&lt;<a href=3D"mailto:mi=
ke.barnes-f9aWwpgOZj5Wk0Htik3J/[email protected]" target=3D"_blank">mike.barnes-f9aWwpgOZj5Wk0Htik3J/[email protected]</a>&gt;<=
/span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8=
ex;border-left:1px #ccc solid;padding-left:1ex"><div lang=3D"EN-US" link=3D=
"blue" vlink=3D"#954F72"><div class=3D"m_-2447592735371230143WordSection1">=
<p class=3D"MsoNormal">I am using the CrudRepository and am looking for a w=
ay to get list data back using something like FindAll without making a quer=
y for each row.</p><p class=3D"MsoNormal"><u></u>=C2=A0<u></u></p><p class=
=3D"MsoNormal">My hibernate log shows something like below for a findall ca=
ll</p><p class=3D"MsoNormal"><u></u>=C2=A0<u></u></p><p class=3D"MsoNormal"=
>select column1, column2 from myTable</p><p class=3D"MsoNormal">select colu=
mn1, column2 from myTable<u></u><u></u></p><p class=3D"MsoNormal">=E2=80=A6=
</p><p class=3D"MsoNormal"><u></u>=C2=A0<u></u></p><p class=3D"MsoNormal">T=
hanks</p><span class=3D"HOEnZb"><font color=3D"#888888"><p class=3D"MsoNorm=
al">Mike Barnes</p><p class=3D"MsoNormal"><u></u>=C2=A0<u></u></p></font></=
span></div></div><br>______________________________<wbr>_________________<b=
r>
ajug-members mailing list<br>
<a href=3D"mailto:[email protected]">[email protected]<=
/a><br>
Manage your subscription and unsubscribe <a href=3D"http://lists.ajug.org/m=
ailman/listinfo/ajug-members" rel=3D"noreferrer" target=3D"_blank">http://l=
ists.ajug.org/mailman/<wbr>listinfo/ajug-members</a><br></blockquote></div>=
<br></div>

--001a1130c102836d87055f0a9bd8--

--===============6829753914884994706==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: base64
Content-Disposition: inline

X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KYWp1Zy1tZW1i
ZXJzIG1haWxpbmcgbGlzdAphanVnLW1lbWJlcnNAbGlzdHMuYWp1Zy5vcmcKTWFuYWdlIHlvdXIg
c3Vic2NyaXB0aW9uIGFuZCB1bnN1YnNjcmliZSBodHRwOi8vbGlzdHMuYWp1Zy5vcmcvbWFpbG1h
bi9saXN0aW5mby9hanVnLW1lbWJlcnM=

--===============6829753914884994706==--