28 lines
2.5 KiB
HTML
28 lines
2.5 KiB
HTML
<?xml version="1.0" encoding="UTF-8" standalone="no"?><!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:pls="http://www.w3.org/2005/01/pronunciation-lexicon" xmlns:ssml="http://www.w3.org/2001/10/synthesis" xmlns:svg="http://www.w3.org/2000/svg"><head><title>Driving Query Based ItemReaders</title><link rel="stylesheet" type="text/css" href="docbook-epub.css"/><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"/><link rel="prev" href="ch11s03.xhtml" title="Adding a Footer Record"/><link rel="next" href="ch11s05.xhtml" title="Multi-Line Records"/></head><body><header/><section class="section" title="Driving Query Based ItemReaders" epub:type="subchapter" id="drivingQueryBasedItemReaders"><div class="titlepage"><div><div><h2 class="title" style="clear: both">Driving Query Based ItemReaders</h2></div></div></div>
|
|
|
|
|
|
<p>In the chapter on readers and writers, database input using paging
|
|
was discussed. Many database vendors, such as DB2, have extremely
|
|
pessimistic locking strategies that can cause issues if the table being
|
|
read also needs to be used by other portions of the online application.
|
|
Furthermore, opening cursors over extremely large datasets can cause
|
|
issues on certain vendors. Therefore, many projects prefer to use a
|
|
'Driving Query' approach to reading in data. This approach works by
|
|
iterating over keys, rather than the entire object that needs to be
|
|
returned, as the following example illustrates:</p>
|
|
|
|
<div style="text-align: center; " class="mediaobject"><img style="text-align: middle; " src="images/drivingQueryExample.png" width="432"/></div>
|
|
|
|
<p>As you can see, this example uses the same 'FOO' table as was used
|
|
in the cursor based example. However, rather than selecting the entire
|
|
row, only the ID's were selected in the SQL statement. So, rather than a
|
|
FOO object being returned from <code class="classname">read</code>, an Integer
|
|
will be returned. This number can then be used to query for the 'details',
|
|
which is a complete Foo object:</p>
|
|
|
|
<div style="text-align: center; " class="mediaobject"><img style="text-align: middle; " src="images/drivingQueryJob.png" width="459"/></div>
|
|
|
|
<p>An ItemProcessor should be used to transform the key obtained from
|
|
the driving query into a full 'Foo' object. An existing DAO can be used to
|
|
query for the full object based on the key.</p>
|
|
</section><footer/></body></html> |