EMMA Coverage Report (generated Tue May 06 07:28:24 PDT 2008)
[all classes][org.springframework.batch.item.database]

COVERAGE SUMMARY FOR SOURCE FILE [IbatisDrivingQueryItemReader.java]

nameclass, %method, %block, %line, %
IbatisDrivingQueryItemReader.java100% (1/1)100% (4/4)100% (28/28)100% (9/9)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class IbatisDrivingQueryItemReader100% (1/1)100% (4/4)100% (28/28)100% (9/9)
IbatisDrivingQueryItemReader (): void 100% (1/1)100% (3/3)100% (1/1)
read (): Object 100% (1/1)100% (14/14)100% (4/4)
setDetailsQueryId (String): void 100% (1/1)100% (4/4)100% (2/2)
setSqlMapClient (SqlMapClient): void 100% (1/1)100% (7/7)100% (2/2)

1/*
2 * Copyright 2006-2007 the original author or authors.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package org.springframework.batch.item.database;
17 
18import org.springframework.batch.item.database.support.IbatisKeyCollector;
19import org.springframework.orm.ibatis.SqlMapClientTemplate;
20 
21import com.ibatis.sqlmap.client.SqlMapClient;
22 
23/**
24 * Extension of {@link DrivingQueryItemReader} that maps keys to
25 * objects.  An iBatis query id must be set to map and return each 'detail record'.
26 *
27 * @author Lucas Ward
28 * @see IbatisKeyCollector
29 */
30public class IbatisDrivingQueryItemReader extends DrivingQueryItemReader {
31 
32        private String detailsQueryId;
33 
34        private SqlMapClientTemplate sqlMapClientTemplate;
35 
36        /**
37         * Overridden read() that uses the returned key as arguments to the details query.
38         *
39         * @see org.springframework.batch.item.database.DrivingQueryItemReader#read()
40         */
41        public Object read() {
42                Object key = super.read();
43                if (key==null) {
44                        return null;
45                }
46                return sqlMapClientTemplate.queryForObject(detailsQueryId, key);
47        }
48 
49        /**
50         * @param detailsQueryId id of the iBATIS select statement that will used
51         * to retrieve an object for a single primary key from the list
52         * returned by driving query
53         */
54        public void setDetailsQueryId(String detailsQueryId) {
55                this.detailsQueryId = detailsQueryId;
56        }
57        
58        /**
59         * Set the {@link SqlMapClientTemplate} to use for this input source.
60         * 
61         * @param sqlMapClient
62         */
63        public void setSqlMapClient(
64                        SqlMapClient sqlMapClient) {
65                this.sqlMapClientTemplate = new SqlMapClientTemplate(sqlMapClient);
66        }
67}

[all classes][org.springframework.batch.item.database]
EMMA 2.0.5312 (C) Vladimir Roubtsov