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.service.persistence;
16  
17  import com.liferay.portal.SystemException;
18  import com.liferay.portal.kernel.dao.orm.QueryPos;
19  import com.liferay.portal.kernel.dao.orm.SQLQuery;
20  import com.liferay.portal.kernel.dao.orm.Session;
21  import com.liferay.portal.model.UserGroupRole;
22  import com.liferay.portal.model.impl.UserGroupRoleImpl;
23  import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
24  import com.liferay.util.dao.orm.CustomSQLUtil;
25  
26  import java.util.List;
27  
28  /**
29   * <a href="UserGroupRoleFinderImpl.java.html"><b><i>View Source</i></b></a>
30   *
31   * @author Brian Wing Shun Chan
32   */
33  public class UserGroupRoleFinderImpl
34      extends BasePersistenceImpl<UserGroupRole> implements UserGroupRoleFinder {
35  
36      public static String FIND_BY_USER_USER_GROUP_GROUP_ROLE =
37          UserGroupRoleFinder.class.getName() + ".findByUserUserGroupGroupRole";
38  
39      public List<UserGroupRole> findByUserUserGroupGroupRole(
40              long userId, long groupId)
41          throws SystemException {
42  
43          Session session = null;
44  
45          try {
46              session = openSession();
47  
48              String sql = CustomSQLUtil.get(FIND_BY_USER_USER_GROUP_GROUP_ROLE);
49  
50              SQLQuery q = session.createSQLQuery(sql);
51  
52              q.addEntity("UserGroupRole", UserGroupRoleImpl.class);
53  
54              QueryPos qPos = QueryPos.getInstance(q);
55  
56              qPos.add(userId);
57              qPos.add(groupId);
58  
59              return q.list();
60          }
61          catch (Exception e) {
62              throw new SystemException(e);
63          }
64          finally {
65              closeSession(session);
66          }
67      }
68  
69  }