Java Reference
In-Depth Information
The interface contains typical methods for transferring
Account
objects to the database
and back. There's a method to create new accounts, update an account, and delete an ac-
count; a method to find an account by
id
; and one to return all the accounts.
The implementation of the interface, using a Groovy class called
JdbcAccountDAO
,
works with the
JdbcTemplate
from Spring. Rather than show the whole class (which is
available in the topic source code), let me present just the structure and then emphasize the
Groovy aspect afterward. An outline of the class is shown in the following listing.
Listing 7.3. Implementing the
AccountDAO
using
JdbcTemplate
, in Groovy
The various
query
methods take an argument of type
RowMapper<T>
, whose definition
is