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 issues discussed in the <ahref="/architecture/compare-jpa">comparison with JPA</a> also apply to Hibernate.
86
-
The comparison here apply more specifically to Hibernate.
85
+
The issues discussed in this <ahref="/architecture/compare-jpa">comparison with JPA</a> also apply to Hibernate.
87
86
</p>
88
87
89
88
<h2id="max-rows">Honoring maxRows in SQL</h2>
90
89
<p>
91
90
Ebean ORM will always honor firstRows / maxRows in generated SQL. Once you include a join fetch
92
-
to a @OneToMany Hibernate stops implementing maxRows in SQL and instead brings all the rows back
91
+
to a @OneToMany, Hibernate stops implementing maxRows in SQL and instead brings all the rows back
93
92
to the client (application server) and filters the results there.
94
93
</p>
95
94
<p>
96
95
This means the database does not get the opportunity to optimise that query using maxRows
97
-
(via limit offset clause or similar) and so the DB query execution plan can be very different
98
-
by reducing the ability of the DB to use indexes and increasing the chances of full table scans.
96
+
(via limit offset clause or similar) so the DB query execution plan can be very different
97
+
by reducing the ability to use indexes and increasing the chance of a full table scan.
99
98
</p>
100
99
<p>
101
-
This also means significantly more data is pulled back from the DB to the client.
100
+
Significantly more data is pulled back from the DB to the client in this way.
102
101
</p>
103
102
<divclass="row">
104
103
<divclass="col-md-6">
@@ -161,49 +160,47 @@ <h4 class="media-heading">Lazy loading beyond the context</h4>
161
160
</div>
162
161
163
162
<p>
164
-
Hibernate does not allow lazy loading beyond the end of it's Session scope and instead
165
-
throws <code>LazyInitialisationException</code>.
163
+
Hibernate does not allow lazy loading beyond the end of its' Session scope throwing <code>LazyInitialisationException</code>.
166
164
</p>
167
165
<h4>Ebean allows lazy loading beyond the initial scope</h4>
168
166
<ul>
169
167
<li>
170
-
The transaction isolation level of read committed is used as per the JPA spec. This means
171
-
there is no effective difference when we lazy load with using another JDBC transaction relative
168
+
The transaction isolation level of read committed is used as per the JPA spec. There is no effective difference when we lazy load with using another JDBC transaction relative
172
169
to holding open a transaction (as typically required by Hibernate via "Open session in view").
173
170
</li>
174
171
<li>
175
172
Ebean's entity beans have a reference back to their load context which enables subsequent
176
-
lazy loading to execute with the same PersistenceContext and also enables batch lazy loading.
173
+
lazy loading with the same PersistenceContext. (also enables batch lazy loading)
177
174
This means the lazy loading still produces a consistent object graph (just as if it was loaded
178
175
eagerly).
179
176
</li>
180
177
<li>
181
-
If you want to prevent lazy loading with Ebean you can do<code>query.setDisableLazyLoading(true)</code>.
178
+
To prevent lazy loading with Ebean, set<code>query.setDisableLazyLoading(true)</code>.
182
179
This is useful when you want to use a partially populated bean and give it to a reflection based tool
183
180
that converts it to JSON or DTO's etc.
184
181
</li>
185
182
</ul>
186
183
<blockquote>
187
-
With Ebean lazy loading just works without any drama
184
+
With Ebean, lazy loading "just works" without any drama
188
185
</blockquote>
189
186
190
187
<p> </p>
191
188
<h4id="open-session-in-view">Open session in view</h4>
192
189
<p>
193
190
As a byproduct of Ebean supporting lazy loading (beyond transaction scope) Ebean does not require
194
-
the <code>"Open session in view"</code> pattern which is sometimes used with Hibernate.
191
+
the <code>"Open session in view"</code> pattern sometimes seen with Hibernate.
195
192
</p>
196
193
<p>
197
-
The "Open session in view" used with Hibernate has the effect of holding a transaction open for a
198
-
longer time relative to Ebean. This pattern is considered an anti-pattern by many and instead the
199
-
focus is on making sure service layer code has loaded everything that is needed on the entities
194
+
"Open session in view" has the effect of holding a transaction open for a
195
+
longer time relative to Ebean. This is considered an anti-pattern by many, with the
196
+
focus now being on ensuring the service layer has loaded everything needed on the entities
200
197
(and this is code we don't need to write with Ebean).
201
198
</p>
202
199
203
200
<p> </p>
204
201
<h2id="history">SQL2011 @History vs Hibernate Envers</h2>
205
202
<p>
206
-
Ebean's @History is a databasecentric approach mapping to SQL2011. Hibernate Envers is an application centric approach
203
+
Ebean's @History is a database-centric approach mapping to SQL2011. Hibernate Envers is an application centric approach
207
204
which means that unlike @History bulk updates and external updates don't get included in auditing with Envers.
0 commit comments