Skip to content

Commit 59b3dba

Browse files
committed
Add query unmodifiable
1 parent 666c401 commit 59b3dba

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

docs/query/option.html

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,12 +366,36 @@ <h2 id="persistenceContextScope" class="art">persistenceContextScope</h2>
366366
</pre></div>
367367
</div>
368368

369-
<h2 id="readOnly" class="art">readOnly</h2>
369+
<h2 id="readOnly" class="art">readOnly [Removed]</h2>
370+
<p>
371+
This option has been REMOVED and replaced by <a href="#unmodifiable">Unmodifiable</a>
372+
</p>
370373
<p>
371374
Query returns beans that are deemed to be <code>READ ONLY</code> and calling setter methods will
372375
throw an exception.
373376
</p>
374377

378+
<h2 id="unmodifiable" class="art">Unmodifiable</h2>
379+
<p>
380+
When set to true the query returns beans that are unmodifiable read only.
381+
When a <code>Query.setUseQueryCache()</code> is enabled the query will
382+
automatically use Unmodifiable mode (and return unmodifiable beans).
383+
</p>
384+
<p>
385+
This means that the returning graph can't be mutated via setters, all the collections
386+
are unmodifiable collections, lazy loading is disabled and that the query uses
387+
<code>PersistenceContextScope#QUERY</code>.
388+
</p>
389+
<p>
390+
Attempting to mutate an unmodifiable bean will throw a <code>UnmodifiableEntityException</code>.
391+
Attempting to load an unloaded property will throw a <code>LazyInitialisationException</code>.
392+
</p>
393+
<p>
394+
Use this when we want to ensure that the returned object graph can't be mutated in any way,
395+
such as if we want to hold the result in an application cache or otherwise want to ensure
396+
that no lazy loading is performed.
397+
</p>
398+
375399

376400
<nav class="next">
377401
<p class="edit-page">

0 commit comments

Comments
 (0)