EMMA Coverage Report (generated Thu May 22 12:08:10 CDT 2014)
[all classes][org.springframework.batch.item.database.orm]

COVERAGE SUMMARY FOR SOURCE FILE [JpaNativeQueryProvider.java]

nameclass, %method, %block, %line, %
JpaNativeQueryProvider.java100% (1/1)100% (5/5)100% (29/29)100% (9/9)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class JpaNativeQueryProvider100% (1/1)100% (5/5)100% (29/29)100% (9/9)
JpaNativeQueryProvider (): void 100% (1/1)100% (3/3)100% (1/1)
afterPropertiesSet (): void 100% (1/1)100% (10/10)100% (3/3)
createQuery (): Query 100% (1/1)100% (8/8)100% (1/1)
setEntityClass (Class): void 100% (1/1)100% (4/4)100% (2/2)
setSqlQuery (String): void 100% (1/1)100% (4/4)100% (2/2)

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.orm;
18 
19import javax.persistence.Query;
20 
21import org.springframework.util.Assert;
22import org.springframework.util.StringUtils;
23 
24/**
25 * <p>
26 * This query provider creates JPA {@link Query}s from injected native SQL
27 * queries. This is useful if there is a need to utilize database-specific
28 * features such as query hints, the CONNECT keyword in Oracle, etc.
29 * </p>
30 * 
31 * @author Anatoly Polinsky
32 * 
33 * @param <E> entity returned by executing the query
34 */
35public class JpaNativeQueryProvider<E> extends AbstractJpaQueryProvider {
36 
37        private Class<E> entityClass;
38 
39        private String sqlQuery;
40 
41    @Override
42        public Query createQuery() {
43                return getEntityManager().createNativeQuery(sqlQuery, entityClass);
44        }
45 
46        public void setSqlQuery(String sqlQuery) {
47                this.sqlQuery = sqlQuery;
48        }
49 
50        public void setEntityClass(Class<E> entityClazz) {
51                this.entityClass = entityClazz;
52        }
53 
54    @Override
55        public void afterPropertiesSet() throws Exception {
56                Assert.isTrue(StringUtils.hasText(sqlQuery), "Native SQL query cannot be empty");
57                Assert.notNull(entityClass, "Entity class cannot be NULL");
58        }
59}

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