1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   *
12   *
13   */
14  
15  package com.liferay.portal.dao.jdbc.spring;
16  
17  import com.liferay.portal.kernel.dao.jdbc.MappingSqlQuery;
18  import com.liferay.portal.kernel.dao.jdbc.RowMapper;
19  
20  import java.sql.ResultSet;
21  import java.sql.SQLException;
22  
23  import javax.sql.DataSource;
24  
25  import org.springframework.jdbc.core.SqlParameter;
26  
27  /**
28   * <a href="MappingSqlQueryImpl.java.html"><b><i>View Source</i></b></a>
29   *
30   * @author Brian Wing Shun Chan
31   */
32  public class MappingSqlQueryImpl
33      extends org.springframework.jdbc.object.MappingSqlQuery
34      implements MappingSqlQuery {
35  
36      public MappingSqlQueryImpl(
37          DataSource dataSource, String sql, int[] types, RowMapper rowMapper) {
38  
39          super(dataSource, sql);
40  
41          for (int type : types) {
42              declareParameter(new SqlParameter(type));
43          }
44  
45          _rowMapper = rowMapper;
46  
47          compile();
48      }
49  
50      protected Object mapRow(ResultSet rs, int rowNumber) throws SQLException {
51          return _rowMapper.mapRow(rs, rowNumber);
52      }
53  
54      private RowMapper _rowMapper;
55  
56  }