Java Reference
In-Depth Information
This example calls
ScrollableResults.scroll()
to skip over the first 100 rows
and
ScrollableResults
.
next()
to move through the orders. You need to write
more code when using
Criteria.scroll()
than you do when using
list()
, but it
is a more efficient way to execute some queries.
At this point you've had an overview of the challenges of implementing effi-
cient dynamic paged queries in a Hibernate or
JDO
application. Next, let's take an
in-depth look at using
JDO
.
11.4 A JDO design example
In a
JDO
application, queries are typically executed by the domain model's reposi-
tories. This means that the code that implements a search screen will ultimately call
a repository, which must generate a query and call
JDO
to execute it. Figure 11.5
shows the
JDO
version of the
OrderRepository
, which is responsible for retrieving
orders from the database.It defines a
findOrders()
method whose signature is sim-
ilar to the
OrderDAO
method we saw earlier. The
startingIndex
and
pageSize
<<interface>>
OrderRepository
PagedQuery
Result
PagedQueryResult findOrders(startingIndex, pageSize, OrderSearchCriteria)
...
more
JDO
OrderRepository
Impl
Order
JDOFindOrders
Callback
Spring
JdoTemplate
<<interface>>
JdoCallback
execute(JdoTemplate)
Figure 11.5
The JDO version of the design for finding orders
Search WWH ::
Custom Search