EMMA Coverage Report (generated Thu Jan 24 13:37:04 CST 2013)
[all classes][org.springframework.batch.item.database.support]

COVERAGE SUMMARY FOR SOURCE FILE [DerbyPagingQueryProvider.java]

nameclass, %method, %block, %line, %
DerbyPagingQueryProvider.java100% (1/1)100% (5/5)100% (57/57)100% (9/9)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class DerbyPagingQueryProvider100% (1/1)100% (5/5)100% (57/57)100% (9/9)
DerbyPagingQueryProvider (): void 100% (1/1)100% (3/3)100% (1/1)
getOverClause (): String 100% (1/1)100% (2/2)100% (1/1)
getOverSubstituteClauseEnd (): String 100% (1/1)100% (12/12)100% (1/1)
getOverSubstituteClauseStart (): String 100% (1/1)100% (10/10)100% (1/1)
init (DataSource): void 100% (1/1)100% (30/30)100% (5/5)

1/*
2 * Copyright 2006-2008 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 */
16 
17package org.springframework.batch.item.database.support;
18 
19import org.springframework.jdbc.support.JdbcUtils;
20import org.springframework.batch.item.database.PagingQueryProvider;
21import org.springframework.dao.InvalidDataAccessResourceUsageException;
22 
23import javax.sql.DataSource;
24 
25/**
26 * Derby implementation of a  {@link PagingQueryProvider} using standard SQL:2003 windowing functions.
27 * These features are supported starting with Apache Derby version 10.4.1.3.
28 *
29 * As the OVER() function does not support the ORDER BY clause a sub query is instead used to order the results
30 * before the ROW_NUM restriction is applied
31 *
32 * @author Thomas Risberg
33 * @author David Thexton
34 * @since 2.0
35 */
36public class DerbyPagingQueryProvider extends SqlWindowingPagingQueryProvider {
37 
38        private String version;
39 
40        @Override
41        public void init(DataSource dataSource) throws Exception {
42                super.init(dataSource);
43                version = JdbcUtils.extractDatabaseMetaData(dataSource, "getDatabaseProductVersion").toString();
44                if ("10.4.1.3".compareTo(version) > 0) {
45                        throw new InvalidDataAccessResourceUsageException("Apache Derby version " + version + " is not supported by this class,  Only version 10.4.1.3 or later is supported");
46                }
47        }
48        
49        @Override
50        protected String getOverClause() {
51                return "";
52        }
53 
54        protected String getOverSubstituteClauseStart() {
55                return " FROM (SELECT " + getSelectClause();
56        }
57 
58        protected String getOverSubstituteClauseEnd() {
59                return " " + super.getOverClause() + ") AS TMP_ORDERED";
60        }
61 
62}

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