1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portlet.ratings.service.persistence;
16  
17  import com.liferay.portal.kernel.dao.orm.QueryPos;
18  import com.liferay.portal.kernel.dao.orm.SQLQuery;
19  import com.liferay.portal.kernel.dao.orm.Session;
20  import com.liferay.portal.kernel.exception.SystemException;
21  import com.liferay.portal.kernel.util.StringUtil;
22  import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
23  import com.liferay.portlet.ratings.model.RatingsStats;
24  import com.liferay.portlet.ratings.model.impl.RatingsStatsImpl;
25  import com.liferay.util.dao.orm.CustomSQLUtil;
26  
27  import java.util.List;
28  
29  /**
30   * <a href="RatingsStatsFinderImpl.java.html"><b><i>View Source</i></b></a>
31   *
32   * @author Shuyang Zhou
33   */
34  public class RatingsStatsFinderImpl extends BasePersistenceImpl<RatingsStats>
35      implements RatingsStatsFinder{
36  
37      public static String FIND_BY_C_C =
38          RatingsStatsFinder.class.getName() + ".findByC_C";
39  
40      public List<RatingsStats> findByC_C(long classNameId, List<Long> classPKs)
41          throws SystemException {
42  
43          Session session = null;
44  
45          try {
46              session = openSession();
47  
48              String sql = CustomSQLUtil.get(FIND_BY_C_C);
49  
50              sql = StringUtil.replace(
51                  sql, "[$CLASS_PKS$]", StringUtil.merge(classPKs));
52  
53              SQLQuery q = session.createSQLQuery(sql);
54  
55              q.addEntity("RatingsStats", RatingsStatsImpl.class);
56  
57              QueryPos qPos = QueryPos.getInstance(q);
58  
59              qPos.add(classNameId);
60  
61              return q.list();
62          }
63          catch (Exception e) {
64              throw new SystemException(e);
65          }
66          finally {
67              closeSession(session);
68          }
69      }
70  
71  }