List of usage examples for com.liferay.portal.kernel.util StringPool OPEN_PARENTHESIS
String OPEN_PARENTHESIS
To view the source code for com.liferay.portal.kernel.util StringPool OPEN_PARENTHESIS.
Click Source Link
From source file:org.lsug.quota.service.persistence.impl.QuotaPersistenceImpl.java
License:Open Source License
/** * Returns the number of quotas where classNameId = any ?. * * @param classNameIds the class name IDs * @return the number of matching quotas *///from ww w .jav a 2s.co m @Override public int countByCN(long[] classNameIds) { if (classNameIds == null) { classNameIds = new long[0]; } else if (classNameIds.length > 1) { classNameIds = ArrayUtil.unique(classNameIds); Arrays.sort(classNameIds); } Object[] finderArgs = new Object[] { StringUtil.merge(classNameIds) }; Long count = (Long) finderCache.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_CN, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(); query.append(_SQL_COUNT_QUOTA_WHERE); if (classNameIds.length > 0) { query.append(StringPool.OPEN_PARENTHESIS); query.append(_FINDER_COLUMN_CN_CLASSNAMEID_7); query.append(StringUtil.merge(classNameIds)); query.append(StringPool.CLOSE_PARENTHESIS); query.append(StringPool.CLOSE_PARENTHESIS); } query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)), query.index() - 1); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); count = (Long) q.uniqueResult(); finderCache.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_CN, finderArgs, count); } catch (Exception e) { finderCache.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_CN, finderArgs); throw processException(e); } finally { closeSession(session); } } return count.intValue(); }
From source file:org.lsug.quota.service.persistence.impl.QuotaPersistenceImpl.java
License:Open Source License
/** * Returns an ordered range of all the quotas where companyId = ? and classNameId = ?, optionally using the finder cache. * * <p>/*from w w w .java 2 s.c o m*/ * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link QuotaModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param companyId the company ID * @param classNameId the class name ID * @param start the lower bound of the range of quotas * @param end the upper bound of the range of quotas (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @param retrieveFromCache whether to retrieve from the finder cache * @return the ordered range of matching quotas */ @Override public List<Quota> findByC_CN(long companyId, long[] classNameIds, int start, int end, OrderByComparator<Quota> orderByComparator, boolean retrieveFromCache) { if (classNameIds == null) { classNameIds = new long[0]; } else if (classNameIds.length > 1) { classNameIds = ArrayUtil.unique(classNameIds); Arrays.sort(classNameIds); } if (classNameIds.length == 1) { return findByC_CN(companyId, classNameIds[0], start, end, orderByComparator); } boolean pagination = true; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { pagination = false; finderArgs = new Object[] { companyId, StringUtil.merge(classNameIds) }; } else { finderArgs = new Object[] { companyId, StringUtil.merge(classNameIds), start, end, orderByComparator }; } List<Quota> list = null; if (retrieveFromCache) { list = (List<Quota>) finderCache.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_C_CN, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (Quota quota : list) { if ((companyId != quota.getCompanyId()) || !ArrayUtil.contains(classNameIds, quota.getClassNameId())) { list = null; break; } } } } if (list == null) { StringBundler query = new StringBundler(); query.append(_SQL_SELECT_QUOTA_WHERE); query.append(_FINDER_COLUMN_C_CN_COMPANYID_2); if (classNameIds.length > 0) { query.append(StringPool.OPEN_PARENTHESIS); query.append(_FINDER_COLUMN_C_CN_CLASSNAMEID_7); query.append(StringUtil.merge(classNameIds)); query.append(StringPool.CLOSE_PARENTHESIS); query.append(StringPool.CLOSE_PARENTHESIS); } query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)), query.index() - 1); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(QuotaModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(companyId); if (!pagination) { list = (List<Quota>) QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<Quota>) QueryUtil.list(q, getDialect(), start, end); } cacheResult(list); finderCache.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_C_CN, finderArgs, list); } catch (Exception e) { finderCache.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_C_CN, finderArgs); throw processException(e); } finally { closeSession(session); } } return list; }
From source file:org.lsug.quota.service.persistence.impl.QuotaPersistenceImpl.java
License:Open Source License
/** * Returns the number of quotas where companyId = ? and classNameId = any ?. * * @param companyId the company ID//from ww w. java 2 s. c o m * @param classNameIds the class name IDs * @return the number of matching quotas */ @Override public int countByC_CN(long companyId, long[] classNameIds) { if (classNameIds == null) { classNameIds = new long[0]; } else if (classNameIds.length > 1) { classNameIds = ArrayUtil.unique(classNameIds); Arrays.sort(classNameIds); } Object[] finderArgs = new Object[] { companyId, StringUtil.merge(classNameIds) }; Long count = (Long) finderCache.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_CN, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(); query.append(_SQL_COUNT_QUOTA_WHERE); query.append(_FINDER_COLUMN_C_CN_COMPANYID_2); if (classNameIds.length > 0) { query.append(StringPool.OPEN_PARENTHESIS); query.append(_FINDER_COLUMN_C_CN_CLASSNAMEID_7); query.append(StringUtil.merge(classNameIds)); query.append(StringPool.CLOSE_PARENTHESIS); query.append(StringPool.CLOSE_PARENTHESIS); } query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)), query.index() - 1); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(companyId); count = (Long) q.uniqueResult(); finderCache.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_CN, finderArgs, count); } catch (Exception e) { finderCache.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_CN, finderArgs); throw processException(e); } finally { closeSession(session); } } return count.intValue(); }
From source file:org.oep.ssomgt.service.persistence.AppRole2EmployeePersistenceImpl.java
License:Open Source License
/** * Returns an ordered range of all the app role2 employees where companyId = ? and employeeId = any ?. * * <p>/*from w w w.ja va 2 s . co m*/ * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link org.oep.ssomgt.model.impl.AppRole2EmployeeModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param companyId the company ID * @param employeeIds the employee IDs * @param start the lower bound of the range of app role2 employees * @param end the upper bound of the range of app role2 employees (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching app role2 employees * @throws SystemException if a system exception occurred */ @Override public List<AppRole2Employee> findByC_InE(long companyId, long[] employeeIds, int start, int end, OrderByComparator orderByComparator) throws SystemException { if ((employeeIds != null) && (employeeIds.length == 1)) { return findByC_InE(companyId, employeeIds[0], start, end, orderByComparator); } boolean pagination = true; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { pagination = false; finderArgs = new Object[] { companyId, StringUtil.merge(employeeIds) }; } else { finderArgs = new Object[] { companyId, StringUtil.merge(employeeIds), start, end, orderByComparator }; } List<AppRole2Employee> list = (List<AppRole2Employee>) FinderCacheUtil .getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_C_INE, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (AppRole2Employee appRole2Employee : list) { if ((companyId != appRole2Employee.getCompanyId()) || !ArrayUtil.contains(employeeIds, appRole2Employee.getEmployeeId())) { list = null; break; } } } if (list == null) { StringBundler query = new StringBundler(); query.append(_SQL_SELECT_APPROLE2EMPLOYEE_WHERE); boolean conjunctionable = false; if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_C_INE_COMPANYID_5); conjunctionable = true; if ((employeeIds == null) || (employeeIds.length > 0)) { if (conjunctionable) { query.append(WHERE_AND); } query.append(StringPool.OPEN_PARENTHESIS); for (int i = 0; i < employeeIds.length; i++) { query.append(_FINDER_COLUMN_C_INE_EMPLOYEEID_5); if ((i + 1) < employeeIds.length) { query.append(WHERE_OR); } } query.append(StringPool.CLOSE_PARENTHESIS); conjunctionable = true; } if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(AppRole2EmployeeModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(companyId); if (employeeIds != null) { qPos.add(employeeIds); } if (!pagination) { list = (List<AppRole2Employee>) QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = new UnmodifiableList<AppRole2Employee>(list); } else { list = (List<AppRole2Employee>) QueryUtil.list(q, getDialect(), start, end); } cacheResult(list); FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_C_INE, finderArgs, list); } catch (Exception e) { FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_C_INE, finderArgs); throw processException(e); } finally { closeSession(session); } } return list; }
From source file:org.oep.ssomgt.service.persistence.AppRole2EmployeePersistenceImpl.java
License:Open Source License
/** * Returns the number of app role2 employees where companyId = ? and employeeId = any ?. * * @param companyId the company ID//from w w w . jav a2 s . c o m * @param employeeIds the employee IDs * @return the number of matching app role2 employees * @throws SystemException if a system exception occurred */ @Override public int countByC_InE(long companyId, long[] employeeIds) throws SystemException { Object[] finderArgs = new Object[] { companyId, StringUtil.merge(employeeIds) }; Long count = (Long) FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_INE, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(); query.append(_SQL_COUNT_APPROLE2EMPLOYEE_WHERE); boolean conjunctionable = false; if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_C_INE_COMPANYID_5); conjunctionable = true; if ((employeeIds == null) || (employeeIds.length > 0)) { if (conjunctionable) { query.append(WHERE_AND); } query.append(StringPool.OPEN_PARENTHESIS); for (int i = 0; i < employeeIds.length; i++) { query.append(_FINDER_COLUMN_C_INE_EMPLOYEEID_5); if ((i + 1) < employeeIds.length) { query.append(WHERE_OR); } } query.append(StringPool.CLOSE_PARENTHESIS); conjunctionable = true; } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(companyId); if (employeeIds != null) { qPos.add(employeeIds); } count = (Long) q.uniqueResult(); FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_INE, finderArgs, count); } catch (Exception e) { FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_INE, finderArgs); throw processException(e); } finally { closeSession(session); } } return count.intValue(); }
From source file:org.oep.ssomgt.service.persistence.AppRole2EmployeePersistenceImpl.java
License:Open Source License
/** * Returns an ordered range of all the app role2 employees where companyId = ? and groupId = ? and employeeId = any ?. * * <p>//from ww w. j a va 2 s . co m * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link org.oep.ssomgt.model.impl.AppRole2EmployeeModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param companyId the company ID * @param groupId the group ID * @param employeeIds the employee IDs * @param start the lower bound of the range of app role2 employees * @param end the upper bound of the range of app role2 employees (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching app role2 employees * @throws SystemException if a system exception occurred */ @Override public List<AppRole2Employee> findByC_G_InE(long companyId, long groupId, long[] employeeIds, int start, int end, OrderByComparator orderByComparator) throws SystemException { if ((employeeIds != null) && (employeeIds.length == 1)) { return findByC_G_InE(companyId, groupId, employeeIds[0], start, end, orderByComparator); } boolean pagination = true; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { pagination = false; finderArgs = new Object[] { companyId, groupId, StringUtil.merge(employeeIds) }; } else { finderArgs = new Object[] { companyId, groupId, StringUtil.merge(employeeIds), start, end, orderByComparator }; } List<AppRole2Employee> list = (List<AppRole2Employee>) FinderCacheUtil .getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_C_G_INE, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (AppRole2Employee appRole2Employee : list) { if ((companyId != appRole2Employee.getCompanyId()) || (groupId != appRole2Employee.getGroupId()) || !ArrayUtil.contains(employeeIds, appRole2Employee.getEmployeeId())) { list = null; break; } } } if (list == null) { StringBundler query = new StringBundler(); query.append(_SQL_SELECT_APPROLE2EMPLOYEE_WHERE); boolean conjunctionable = false; if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_C_G_INE_COMPANYID_5); conjunctionable = true; if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_C_G_INE_GROUPID_5); conjunctionable = true; if ((employeeIds == null) || (employeeIds.length > 0)) { if (conjunctionable) { query.append(WHERE_AND); } query.append(StringPool.OPEN_PARENTHESIS); for (int i = 0; i < employeeIds.length; i++) { query.append(_FINDER_COLUMN_C_G_INE_EMPLOYEEID_5); if ((i + 1) < employeeIds.length) { query.append(WHERE_OR); } } query.append(StringPool.CLOSE_PARENTHESIS); conjunctionable = true; } if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(AppRole2EmployeeModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(companyId); qPos.add(groupId); if (employeeIds != null) { qPos.add(employeeIds); } if (!pagination) { list = (List<AppRole2Employee>) QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = new UnmodifiableList<AppRole2Employee>(list); } else { list = (List<AppRole2Employee>) QueryUtil.list(q, getDialect(), start, end); } cacheResult(list); FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_C_G_INE, finderArgs, list); } catch (Exception e) { FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_C_G_INE, finderArgs); throw processException(e); } finally { closeSession(session); } } return list; }
From source file:org.oep.ssomgt.service.persistence.AppRole2EmployeePersistenceImpl.java
License:Open Source License
/** * Returns the number of app role2 employees where companyId = ? and groupId = ? and employeeId = any ?. * * @param companyId the company ID/*w ww.j a va 2 s . c o m*/ * @param groupId the group ID * @param employeeIds the employee IDs * @return the number of matching app role2 employees * @throws SystemException if a system exception occurred */ @Override public int countByC_G_InE(long companyId, long groupId, long[] employeeIds) throws SystemException { Object[] finderArgs = new Object[] { companyId, groupId, StringUtil.merge(employeeIds) }; Long count = (Long) FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_G_INE, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(); query.append(_SQL_COUNT_APPROLE2EMPLOYEE_WHERE); boolean conjunctionable = false; if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_C_G_INE_COMPANYID_5); conjunctionable = true; if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_C_G_INE_GROUPID_5); conjunctionable = true; if ((employeeIds == null) || (employeeIds.length > 0)) { if (conjunctionable) { query.append(WHERE_AND); } query.append(StringPool.OPEN_PARENTHESIS); for (int i = 0; i < employeeIds.length; i++) { query.append(_FINDER_COLUMN_C_G_INE_EMPLOYEEID_5); if ((i + 1) < employeeIds.length) { query.append(WHERE_OR); } } query.append(StringPool.CLOSE_PARENTHESIS); conjunctionable = true; } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(companyId); qPos.add(groupId); if (employeeIds != null) { qPos.add(employeeIds); } count = (Long) q.uniqueResult(); FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_G_INE, finderArgs, count); } catch (Exception e) { FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_G_INE, finderArgs); throw processException(e); } finally { closeSession(session); } } return count.intValue(); }
From source file:org.oep.ssomgt.service.persistence.AppRole2EmployeePersistenceImpl.java
License:Open Source License
/** * Returns an ordered range of all the app role2 employees where companyId = ? and groupId = ? and appRoleId = any ?. * * <p>//from w w w.j a v a2s . c om * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link org.oep.ssomgt.model.impl.AppRole2EmployeeModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param companyId the company ID * @param groupId the group ID * @param appRoleIds the app role IDs * @param start the lower bound of the range of app role2 employees * @param end the upper bound of the range of app role2 employees (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching app role2 employees * @throws SystemException if a system exception occurred */ @Override public List<AppRole2Employee> findByC_G_InAR(long companyId, long groupId, long[] appRoleIds, int start, int end, OrderByComparator orderByComparator) throws SystemException { if ((appRoleIds != null) && (appRoleIds.length == 1)) { return findByC_G_InAR(companyId, groupId, appRoleIds[0], start, end, orderByComparator); } boolean pagination = true; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { pagination = false; finderArgs = new Object[] { companyId, groupId, StringUtil.merge(appRoleIds) }; } else { finderArgs = new Object[] { companyId, groupId, StringUtil.merge(appRoleIds), start, end, orderByComparator }; } List<AppRole2Employee> list = (List<AppRole2Employee>) FinderCacheUtil .getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_C_G_INAR, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (AppRole2Employee appRole2Employee : list) { if ((companyId != appRole2Employee.getCompanyId()) || (groupId != appRole2Employee.getGroupId()) || !ArrayUtil.contains(appRoleIds, appRole2Employee.getAppRoleId())) { list = null; break; } } } if (list == null) { StringBundler query = new StringBundler(); query.append(_SQL_SELECT_APPROLE2EMPLOYEE_WHERE); boolean conjunctionable = false; if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_C_G_INAR_COMPANYID_5); conjunctionable = true; if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_C_G_INAR_GROUPID_5); conjunctionable = true; if ((appRoleIds == null) || (appRoleIds.length > 0)) { if (conjunctionable) { query.append(WHERE_AND); } query.append(StringPool.OPEN_PARENTHESIS); for (int i = 0; i < appRoleIds.length; i++) { query.append(_FINDER_COLUMN_C_G_INAR_APPROLEID_5); if ((i + 1) < appRoleIds.length) { query.append(WHERE_OR); } } query.append(StringPool.CLOSE_PARENTHESIS); conjunctionable = true; } if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(AppRole2EmployeeModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(companyId); qPos.add(groupId); if (appRoleIds != null) { qPos.add(appRoleIds); } if (!pagination) { list = (List<AppRole2Employee>) QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = new UnmodifiableList<AppRole2Employee>(list); } else { list = (List<AppRole2Employee>) QueryUtil.list(q, getDialect(), start, end); } cacheResult(list); FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_C_G_INAR, finderArgs, list); } catch (Exception e) { FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_C_G_INAR, finderArgs); throw processException(e); } finally { closeSession(session); } } return list; }
From source file:org.oep.ssomgt.service.persistence.AppRole2EmployeePersistenceImpl.java
License:Open Source License
/** * Returns the number of app role2 employees where companyId = ? and groupId = ? and appRoleId = any ?. * * @param companyId the company ID// ww w . j a v a 2s. c om * @param groupId the group ID * @param appRoleIds the app role IDs * @return the number of matching app role2 employees * @throws SystemException if a system exception occurred */ @Override public int countByC_G_InAR(long companyId, long groupId, long[] appRoleIds) throws SystemException { Object[] finderArgs = new Object[] { companyId, groupId, StringUtil.merge(appRoleIds) }; Long count = (Long) FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_G_INAR, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(); query.append(_SQL_COUNT_APPROLE2EMPLOYEE_WHERE); boolean conjunctionable = false; if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_C_G_INAR_COMPANYID_5); conjunctionable = true; if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_C_G_INAR_GROUPID_5); conjunctionable = true; if ((appRoleIds == null) || (appRoleIds.length > 0)) { if (conjunctionable) { query.append(WHERE_AND); } query.append(StringPool.OPEN_PARENTHESIS); for (int i = 0; i < appRoleIds.length; i++) { query.append(_FINDER_COLUMN_C_G_INAR_APPROLEID_5); if ((i + 1) < appRoleIds.length) { query.append(WHERE_OR); } } query.append(StringPool.CLOSE_PARENTHESIS); conjunctionable = true; } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(companyId); qPos.add(groupId); if (appRoleIds != null) { qPos.add(appRoleIds); } count = (Long) q.uniqueResult(); FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_G_INAR, finderArgs, count); } catch (Exception e) { FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_C_G_INAR, finderArgs); throw processException(e); } finally { closeSession(session); } } return count.intValue(); }
From source file:org.oep.ssomgt.service.persistence.AppRole2JobPosPersistenceImpl.java
License:Open Source License
/** * Returns an ordered range of all the app role2 job poses where companyId = ? and jobPosId = any ?. * * <p>// w w w .j a va 2 s . co m * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link org.oep.ssomgt.model.impl.AppRole2JobPosModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param companyId the company ID * @param jobPosIds the job pos IDs * @param start the lower bound of the range of app role2 job poses * @param end the upper bound of the range of app role2 job poses (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching app role2 job poses * @throws SystemException if a system exception occurred */ @Override public List<AppRole2JobPos> findByC_InJobPos(long companyId, long[] jobPosIds, int start, int end, OrderByComparator orderByComparator) throws SystemException { if ((jobPosIds != null) && (jobPosIds.length == 1)) { return findByC_InJobPos(companyId, jobPosIds[0], start, end, orderByComparator); } boolean pagination = true; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { pagination = false; finderArgs = new Object[] { companyId, StringUtil.merge(jobPosIds) }; } else { finderArgs = new Object[] { companyId, StringUtil.merge(jobPosIds), start, end, orderByComparator }; } List<AppRole2JobPos> list = (List<AppRole2JobPos>) FinderCacheUtil .getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_C_INJOBPOS, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (AppRole2JobPos appRole2JobPos : list) { if ((companyId != appRole2JobPos.getCompanyId()) || !ArrayUtil.contains(jobPosIds, appRole2JobPos.getJobPosId())) { list = null; break; } } } if (list == null) { StringBundler query = new StringBundler(); query.append(_SQL_SELECT_APPROLE2JOBPOS_WHERE); boolean conjunctionable = false; if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_C_INJOBPOS_COMPANYID_5); conjunctionable = true; if ((jobPosIds == null) || (jobPosIds.length > 0)) { if (conjunctionable) { query.append(WHERE_AND); } query.append(StringPool.OPEN_PARENTHESIS); for (int i = 0; i < jobPosIds.length; i++) { query.append(_FINDER_COLUMN_C_INJOBPOS_JOBPOSID_5); if ((i + 1) < jobPosIds.length) { query.append(WHERE_OR); } } query.append(StringPool.CLOSE_PARENTHESIS); conjunctionable = true; } if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(AppRole2JobPosModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(companyId); if (jobPosIds != null) { qPos.add(jobPosIds); } if (!pagination) { list = (List<AppRole2JobPos>) QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = new UnmodifiableList<AppRole2JobPos>(list); } else { list = (List<AppRole2JobPos>) QueryUtil.list(q, getDialect(), start, end); } cacheResult(list); FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_C_INJOBPOS, finderArgs, list); } catch (Exception e) { FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_C_INJOBPOS, finderArgs); throw processException(e); } finally { closeSession(session); } } return list; }