You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The `limit 50` here refers to the total number of rows returned from the database.
2130
-
The final number of ``Phone``s returned by `getResultList()` will be fewer, after Hibernate eliminates duplicate ``Phone``s from the result list.
2129
+
However, if you log the SQL executed by Hibernate, you'll notice something wrong:
2130
+
2131
+
[source, SQL, indent=0]
2132
+
----
2133
+
select
2134
+
p1_0.id,
2135
+
c1_0.phone_id,
2136
+
c1_0.calls_ORDER,
2137
+
c1_0.id,
2138
+
c1_0.duration,
2139
+
c1_0.payment_id,
2140
+
c1_0.call_timestamp,
2141
+
p1_0.phone_number,
2142
+
p1_0.person_id,
2143
+
p1_0.phone_type
2144
+
from
2145
+
Phone p1_0
2146
+
join
2147
+
phone_call c1_0
2148
+
on p1_0.id=c1_0.phone_id
2149
+
order by 1
2150
+
----
2151
+
2152
+
What happened to the `limit` clause?
2153
+
2154
+
[IMPORTANT]
2155
+
====
2156
+
When limits or pagination are combined with `fetch join`, Hibernate must retrieve all matching results from the database and _apply the limit in memory_!
2157
+
2158
+
This _almost certainly_ isn't the behavior you were hoping for, and in general will exhibit _terrible_ performance characteristics.
2159
+
====
2131
2160
2132
2161
In the next chapter we'll see a completely different way to write queries in Hibernate.
0 commit comments