d8d509022c4668218c8a7406db13dcb81a248493
[ccsdk/features.git] /
1 /*\r
2  * Copyright © 2017-2018 AT&T Intellectual Property.\r
3  * \r
4  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except\r
5  * in compliance with the License. You may obtain a copy of the License at\r
6  * \r
7  * http://www.apache.org/licenses/LICENSE-2.0\r
8  * \r
9  * Unless required by applicable law or agreed to in writing, software distributed under the License\r
10  * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express\r
11  * or implied. See the License for the specific language governing permissions and limitations under\r
12  * the License.\r
13  */\r
14 \r
15 package org.onap.ccsdk.config.data.adaptor.dao;\r
16 \r
17 import java.util.List;\r
18 import java.util.Map;\r
19 import org.onap.ccsdk.sli.core.sli.SvcLogicException;\r
20 import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;\r
21 \r
22 public interface NamedQueryExecutorDao {\r
23     /**\r
24      * Return NamedParameterJdbcTemplate object.\r
25      */\r
26     public NamedParameterJdbcTemplate getNamedParameterJdbcTemplate() throws SvcLogicException;\r
27     \r
28     /**\r
29      * Query given SQL to create a prepared statement from SQL and a list of arguments to bind to the\r
30      * query, expecting a result list.\r
31      * <p>\r
32      * The results will be mapped to a List (one entry for each row) of Maps (one entry for each column,\r
33      * using the column name as the key).\r
34      *\r
35      * @param sql SQL query to execute\r
36      * @param param map of parameters to bind to the query (leaving it to the PreparedStatement to guess\r
37      *        the corresponding SQL type)\r
38      * @return a List that contains a Map per row\r
39      * @throws org.onap.ccsdk.sli.core.sli.SvcLogicException if the query fails\r
40      */\r
41     public List<Map<String, Object>> query(String sql, Map<String, Object> parameters) throws SvcLogicException;\r
42     \r
43     /**\r
44      * Issue an update via a prepared statement, binding the given arguments.\r
45      *\r
46      * @param sql SQL containing named parameters\r
47      * @param param map of parameters to bind to the query (leaving it to the PreparedStatement to guess\r
48      *        the corresponding SQL type)\r
49      * @return the number of rows affected\r
50      * @throws org.onap.ccsdk.sli.core.sli.SvcLogicException if there is any problem issuing the update\r
51      */\r
52     public int update(String sql, Map<String, Object> parameters) throws SvcLogicException;\r
53     \r
54 }\r