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:com.mobilekipyonetim.service.service.persistence.OrderPersistenceImpl.java
License:Open Source License
/** * Returns the number of orders where organizationId = any ?. * * @param organizationIds the organization IDs * @return the number of matching orders * @throws SystemException if a system exception occurred */// ww w. j ava2 s.com @Override public int countByorganizationList(long[] organizationIds) throws SystemException { Object[] finderArgs = new Object[] { StringUtil.merge(organizationIds) }; Long count = (Long) FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_ORGANIZATIONLIST, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(); query.append(_SQL_COUNT_ORDER__WHERE); boolean conjunctionable = false; if ((organizationIds == null) || (organizationIds.length > 0)) { if (conjunctionable) { query.append(WHERE_AND); } query.append(StringPool.OPEN_PARENTHESIS); for (int i = 0; i < organizationIds.length; i++) { query.append(_FINDER_COLUMN_ORGANIZATIONLIST_ORGANIZATIONID_5); if ((i + 1) < organizationIds.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); if (organizationIds != null) { qPos.add(organizationIds); } count = (Long) q.uniqueResult(); FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_ORGANIZATIONLIST, finderArgs, count); } catch (Exception e) { FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_ORGANIZATIONLIST, finderArgs); throw processException(e); } finally { closeSession(session); } } return count.intValue(); }
From source file:com.mobilekipyonetim.service.service.persistence.PoiPersistenceImpl.java
License:Open Source License
/** * Returns an ordered range of all the pois where organizationId = any ?. * * <p>//from w ww.ja v a 2 s . 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 com.mobilekipyonetim.service.model.impl.PoiModelImpl}. 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 organizationIds the organization IDs * @param start the lower bound of the range of pois * @param end the upper bound of the range of pois (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching pois * @throws SystemException if a system exception occurred */ @Override public List<Poi> findByorganizationIdList(long[] organizationIds, int start, int end, OrderByComparator orderByComparator) throws SystemException { if ((organizationIds != null) && (organizationIds.length == 1)) { return findByorganizationIdList(organizationIds[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[] { StringUtil.merge(organizationIds) }; } else { finderArgs = new Object[] { StringUtil.merge(organizationIds), start, end, orderByComparator }; } List<Poi> list = (List<Poi>) FinderCacheUtil .getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_ORGANIZATIONIDLIST, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (Poi poi : list) { if (!ArrayUtil.contains(organizationIds, poi.getOrganizationId())) { list = null; break; } } } if (list == null) { StringBundler query = new StringBundler(); query.append(_SQL_SELECT_POI_WHERE); boolean conjunctionable = false; if ((organizationIds == null) || (organizationIds.length > 0)) { if (conjunctionable) { query.append(WHERE_AND); } query.append(StringPool.OPEN_PARENTHESIS); for (int i = 0; i < organizationIds.length; i++) { query.append(_FINDER_COLUMN_ORGANIZATIONIDLIST_ORGANIZATIONID_5); if ((i + 1) < organizationIds.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(PoiModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); if (organizationIds != null) { qPos.add(organizationIds); } if (!pagination) { list = (List<Poi>) QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = new UnmodifiableList<Poi>(list); } else { list = (List<Poi>) QueryUtil.list(q, getDialect(), start, end); } cacheResult(list); FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_ORGANIZATIONIDLIST, finderArgs, list); } catch (Exception e) { FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_ORGANIZATIONIDLIST, finderArgs); throw processException(e); } finally { closeSession(session); } } return list; }
From source file:com.mobilekipyonetim.service.service.persistence.PoiPersistenceImpl.java
License:Open Source License
/** * Returns the number of pois where organizationId = any ?. * * @param organizationIds the organization IDs * @return the number of matching pois//from w w w . j a va 2s . c o m * @throws SystemException if a system exception occurred */ @Override public int countByorganizationIdList(long[] organizationIds) throws SystemException { Object[] finderArgs = new Object[] { StringUtil.merge(organizationIds) }; Long count = (Long) FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_ORGANIZATIONIDLIST, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(); query.append(_SQL_COUNT_POI_WHERE); boolean conjunctionable = false; if ((organizationIds == null) || (organizationIds.length > 0)) { if (conjunctionable) { query.append(WHERE_AND); } query.append(StringPool.OPEN_PARENTHESIS); for (int i = 0; i < organizationIds.length; i++) { query.append(_FINDER_COLUMN_ORGANIZATIONIDLIST_ORGANIZATIONID_5); if ((i + 1) < organizationIds.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); if (organizationIds != null) { qPos.add(organizationIds); } count = (Long) q.uniqueResult(); FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_ORGANIZATIONIDLIST, finderArgs, count); } catch (Exception e) { FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_ORGANIZATIONIDLIST, finderArgs); throw processException(e); } finally { closeSession(session); } } return count.intValue(); }
From source file:com.mobilekipyonetim.service.service.persistence.VehiclePersistenceImpl.java
License:Open Source License
/** * Returns an ordered range of all the vehicles where organizationId = any ?. * * <p>/*from 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 com.mobilekipyonetim.service.model.impl.VehicleModelImpl}. 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 organizationIds the organization IDs * @param start the lower bound of the range of vehicles * @param end the upper bound of the range of vehicles (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching vehicles * @throws SystemException if a system exception occurred */ @Override public List<Vehicle> findByorganizationList(long[] organizationIds, int start, int end, OrderByComparator orderByComparator) throws SystemException { if ((organizationIds != null) && (organizationIds.length == 1)) { return findByorganizationList(organizationIds[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[] { StringUtil.merge(organizationIds) }; } else { finderArgs = new Object[] { StringUtil.merge(organizationIds), start, end, orderByComparator }; } List<Vehicle> list = (List<Vehicle>) FinderCacheUtil .getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_ORGANIZATIONLIST, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (Vehicle vehicle : list) { if (!ArrayUtil.contains(organizationIds, vehicle.getOrganizationId())) { list = null; break; } } } if (list == null) { StringBundler query = new StringBundler(); query.append(_SQL_SELECT_VEHICLE_WHERE); boolean conjunctionable = false; if ((organizationIds == null) || (organizationIds.length > 0)) { if (conjunctionable) { query.append(WHERE_AND); } query.append(StringPool.OPEN_PARENTHESIS); for (int i = 0; i < organizationIds.length; i++) { query.append(_FINDER_COLUMN_ORGANIZATIONLIST_ORGANIZATIONID_5); if ((i + 1) < organizationIds.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(VehicleModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); if (organizationIds != null) { qPos.add(organizationIds); } if (!pagination) { list = (List<Vehicle>) QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = new UnmodifiableList<Vehicle>(list); } else { list = (List<Vehicle>) QueryUtil.list(q, getDialect(), start, end); } cacheResult(list); FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_ORGANIZATIONLIST, finderArgs, list); } catch (Exception e) { FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_ORGANIZATIONLIST, finderArgs); throw processException(e); } finally { closeSession(session); } } return list; }
From source file:com.mobilekipyonetim.service.service.persistence.VehiclePersistenceImpl.java
License:Open Source License
/** * Returns the number of vehicles where organizationId = any ?. * * @param organizationIds the organization IDs * @return the number of matching vehicles * @throws SystemException if a system exception occurred *//* w w w. j a v a 2 s .c om*/ @Override public int countByorganizationList(long[] organizationIds) throws SystemException { Object[] finderArgs = new Object[] { StringUtil.merge(organizationIds) }; Long count = (Long) FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_ORGANIZATIONLIST, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(); query.append(_SQL_COUNT_VEHICLE_WHERE); boolean conjunctionable = false; if ((organizationIds == null) || (organizationIds.length > 0)) { if (conjunctionable) { query.append(WHERE_AND); } query.append(StringPool.OPEN_PARENTHESIS); for (int i = 0; i < organizationIds.length; i++) { query.append(_FINDER_COLUMN_ORGANIZATIONLIST_ORGANIZATIONID_5); if ((i + 1) < organizationIds.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); if (organizationIds != null) { qPos.add(organizationIds); } count = (Long) q.uniqueResult(); FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_ORGANIZATIONLIST, finderArgs, count); } catch (Exception e) { FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_ORGANIZATIONLIST, finderArgs); throw processException(e); } finally { closeSession(session); } } return count.intValue(); }
From source file:com.mobilekipyonetim.service.service.persistence.VehiclePersistenceImpl.java
License:Open Source License
/** * Returns an ordered range of all the vehicles where plate LIKE ? and organizationId = any ?. * * <p>/*w w w. ja v a 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 com.mobilekipyonetim.service.model.impl.VehicleModelImpl}. 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 plate the plate * @param organizationIds the organization IDs * @param start the lower bound of the range of vehicles * @param end the upper bound of the range of vehicles (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching vehicles * @throws SystemException if a system exception occurred */ @Override public List<Vehicle> findByplateAndOrganizationList(String plate, long[] organizationIds, int start, int end, OrderByComparator orderByComparator) throws SystemException { if ((organizationIds != null) && (organizationIds.length == 1)) { return findByplateAndOrganizationList(plate, organizationIds[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[] { plate, StringUtil.merge(organizationIds) }; } else { finderArgs = new Object[] { plate, StringUtil.merge(organizationIds), start, end, orderByComparator }; } List<Vehicle> list = (List<Vehicle>) FinderCacheUtil .getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_PLATEANDORGANIZATIONLIST, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (Vehicle vehicle : list) { if (!Validator.equals(plate, vehicle.getPlate()) || !ArrayUtil.contains(organizationIds, vehicle.getOrganizationId())) { list = null; break; } } } if (list == null) { StringBundler query = new StringBundler(); query.append(_SQL_SELECT_VEHICLE_WHERE); boolean conjunctionable = false; if (conjunctionable) { query.append(WHERE_AND); } boolean bindPlate = false; if (plate == null) { query.append(_FINDER_COLUMN_PLATEANDORGANIZATIONLIST_PLATE_4); } else if (plate.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_PLATEANDORGANIZATIONLIST_PLATE_6); } else { bindPlate = true; query.append(_FINDER_COLUMN_PLATEANDORGANIZATIONLIST_PLATE_5); } conjunctionable = true; if ((organizationIds == null) || (organizationIds.length > 0)) { if (conjunctionable) { query.append(WHERE_AND); } query.append(StringPool.OPEN_PARENTHESIS); for (int i = 0; i < organizationIds.length; i++) { query.append(_FINDER_COLUMN_PLATEANDORGANIZATIONLIST_ORGANIZATIONID_5); if ((i + 1) < organizationIds.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(VehicleModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); if (bindPlate) { qPos.add(plate); } if (organizationIds != null) { qPos.add(organizationIds); } if (!pagination) { list = (List<Vehicle>) QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = new UnmodifiableList<Vehicle>(list); } else { list = (List<Vehicle>) QueryUtil.list(q, getDialect(), start, end); } cacheResult(list); FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_PLATEANDORGANIZATIONLIST, finderArgs, list); } catch (Exception e) { FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_PLATEANDORGANIZATIONLIST, finderArgs); throw processException(e); } finally { closeSession(session); } } return list; }
From source file:com.mobilekipyonetim.service.service.persistence.VehiclePersistenceImpl.java
License:Open Source License
/** * Returns the number of vehicles where plate LIKE ? and organizationId = any ?. * * @param plate the plate/* ww w . j a va 2 s .c o m*/ * @param organizationIds the organization IDs * @return the number of matching vehicles * @throws SystemException if a system exception occurred */ @Override public int countByplateAndOrganizationList(String plate, long[] organizationIds) throws SystemException { Object[] finderArgs = new Object[] { plate, StringUtil.merge(organizationIds) }; Long count = (Long) FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_PLATEANDORGANIZATIONLIST, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(); query.append(_SQL_COUNT_VEHICLE_WHERE); boolean conjunctionable = false; if (conjunctionable) { query.append(WHERE_AND); } boolean bindPlate = false; if (plate == null) { query.append(_FINDER_COLUMN_PLATEANDORGANIZATIONLIST_PLATE_4); } else if (plate.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_PLATEANDORGANIZATIONLIST_PLATE_6); } else { bindPlate = true; query.append(_FINDER_COLUMN_PLATEANDORGANIZATIONLIST_PLATE_5); } conjunctionable = true; if ((organizationIds == null) || (organizationIds.length > 0)) { if (conjunctionable) { query.append(WHERE_AND); } query.append(StringPool.OPEN_PARENTHESIS); for (int i = 0; i < organizationIds.length; i++) { query.append(_FINDER_COLUMN_PLATEANDORGANIZATIONLIST_ORGANIZATIONID_5); if ((i + 1) < organizationIds.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); if (bindPlate) { qPos.add(plate); } if (organizationIds != null) { qPos.add(organizationIds); } count = (Long) q.uniqueResult(); FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_PLATEANDORGANIZATIONLIST, finderArgs, count); } catch (Exception e) { FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_PLATEANDORGANIZATIONLIST, finderArgs); throw processException(e); } finally { closeSession(session); } } return count.intValue(); }
From source file:com.nyu.service.persistence.LessonPersistenceImpl.java
License:Open Source License
/** * Returns an ordered range of all the lessons where lessonPrivacy = any ?. * * <p>//from www . jav a 2 s .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 com.nyu.model.impl.LessonModelImpl}. 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 lessonPrivacies the lesson privacies * @param start the lower bound of the range of lessons * @param end the upper bound of the range of lessons (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching lessons * @throws SystemException if a system exception occurred */ @Override public List<Lesson> findBylessons_privacy(String[] lessonPrivacies, int start, int end, OrderByComparator orderByComparator) throws SystemException { if ((lessonPrivacies != null) && (lessonPrivacies.length == 1)) { return findBylessons_privacy(lessonPrivacies[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[] { StringUtil.merge(lessonPrivacies) }; } else { finderArgs = new Object[] { StringUtil.merge(lessonPrivacies), start, end, orderByComparator }; } List<Lesson> list = (List<Lesson>) FinderCacheUtil .getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_LESSONS_PRIVACY, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (Lesson lesson : list) { if (!ArrayUtil.contains(lessonPrivacies, lesson.getLessonPrivacy())) { list = null; break; } } } if (list == null) { StringBundler query = new StringBundler(); query.append(_SQL_SELECT_LESSON_WHERE); boolean conjunctionable = false; if ((lessonPrivacies == null) || (lessonPrivacies.length > 0)) { if (conjunctionable) { query.append(WHERE_AND); } query.append(StringPool.OPEN_PARENTHESIS); for (int i = 0; i < lessonPrivacies.length; i++) { String lessonPrivacy = lessonPrivacies[i]; if (lessonPrivacy == null) { query.append(_FINDER_COLUMN_LESSONS_PRIVACY_LESSONPRIVACY_4); } else if (lessonPrivacy.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_LESSONS_PRIVACY_LESSONPRIVACY_6); } else { query.append(_FINDER_COLUMN_LESSONS_PRIVACY_LESSONPRIVACY_5); } if ((i + 1) < lessonPrivacies.length) { query.append(WHERE_OR); } } query.append(StringPool.CLOSE_PARENTHESIS); conjunctionable = true; } if (conjunctionable) { query.append(WHERE_AND); } query.append("lesson.status='published'"); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(LessonModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); if (lessonPrivacies != null) { qPos.add(lessonPrivacies); } if (!pagination) { list = (List<Lesson>) QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = new UnmodifiableList<Lesson>(list); } else { list = (List<Lesson>) QueryUtil.list(q, getDialect(), start, end); } cacheResult(list); FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_LESSONS_PRIVACY, finderArgs, list); } catch (Exception e) { FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_LESSONS_PRIVACY, finderArgs); throw processException(e); } finally { closeSession(session); } } return list; }
From source file:com.nyu.service.persistence.LessonPersistenceImpl.java
License:Open Source License
/** * Returns the number of lessons where lessonPrivacy = any ?. * * @param lessonPrivacies the lesson privacies * @return the number of matching lessons * @throws SystemException if a system exception occurred *//* ww w . j a va 2 s. com*/ @Override public int countBylessons_privacy(String[] lessonPrivacies) throws SystemException { Object[] finderArgs = new Object[] { StringUtil.merge(lessonPrivacies) }; Long count = (Long) FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_LESSONS_PRIVACY, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(); query.append(_SQL_COUNT_LESSON_WHERE); boolean conjunctionable = false; if ((lessonPrivacies == null) || (lessonPrivacies.length > 0)) { if (conjunctionable) { query.append(WHERE_AND); } query.append(StringPool.OPEN_PARENTHESIS); for (int i = 0; i < lessonPrivacies.length; i++) { String lessonPrivacy = lessonPrivacies[i]; if (lessonPrivacy == null) { query.append(_FINDER_COLUMN_LESSONS_PRIVACY_LESSONPRIVACY_4); } else if (lessonPrivacy.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_LESSONS_PRIVACY_LESSONPRIVACY_6); } else { query.append(_FINDER_COLUMN_LESSONS_PRIVACY_LESSONPRIVACY_5); } if ((i + 1) < lessonPrivacies.length) { query.append(WHERE_OR); } } query.append(StringPool.CLOSE_PARENTHESIS); conjunctionable = true; } if (conjunctionable) { query.append(WHERE_AND); } query.append("lesson.status='published'"); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); if (lessonPrivacies != null) { qPos.add(lessonPrivacies); } count = (Long) q.uniqueResult(); FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_LESSONS_PRIVACY, finderArgs, count); } catch (Exception e) { FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_LESSONS_PRIVACY, finderArgs); throw processException(e); } finally { closeSession(session); } } return count.intValue(); }
From source file:com.rec.hitss.layer.service.persistence.UsuarioPersistenceImpl.java
License:Open Source License
/** * Returns an ordered range of all the usuarios where userId = any ?. * * <p>/*from w ww. ja v a2s.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 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 com.rec.hitss.layer.model.impl.UsuarioModelImpl}. 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 userIds the user IDs * @param start the lower bound of the range of usuarios * @param end the upper bound of the range of usuarios (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching usuarios * @throws SystemException if a system exception occurred */ @Override public List<Usuario> findByResponsableAsingadoSolReclutamientoIn(long[] userIds, int start, int end, OrderByComparator orderByComparator) throws SystemException { if ((userIds != null) && (userIds.length == 1)) { return findByResponsableAsingadoSolReclutamientoIn(userIds[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[] { StringUtil.merge(userIds) }; } else { finderArgs = new Object[] { StringUtil.merge(userIds), start, end, orderByComparator }; } List<Usuario> list = (List<Usuario>) FinderCacheUtil.getResult( FINDER_PATH_WITH_PAGINATION_FIND_BY_RESPONSABLEASINGADOSOLRECLUTAMIENTOIN, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (Usuario usuario : list) { if (!ArrayUtil.contains(userIds, usuario.getUserId())) { list = null; break; } } } if (list == null) { StringBundler query = new StringBundler(); query.append(_SQL_SELECT_USUARIO_WHERE); boolean conjunctionable = false; if ((userIds == null) || (userIds.length > 0)) { if (conjunctionable) { query.append(WHERE_AND); } query.append(StringPool.OPEN_PARENTHESIS); for (int i = 0; i < userIds.length; i++) { query.append(_FINDER_COLUMN_RESPONSABLEASINGADOSOLRECLUTAMIENTOIN_USERID_5); if ((i + 1) < userIds.length) { query.append(WHERE_OR); } } query.append(StringPool.CLOSE_PARENTHESIS); conjunctionable = true; } if (conjunctionable) { query.append(WHERE_AND); } query.append("usuario.activo=true"); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(UsuarioModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); if (userIds != null) { qPos.add(userIds); } if (!pagination) { list = (List<Usuario>) QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = new UnmodifiableList<Usuario>(list); } else { list = (List<Usuario>) QueryUtil.list(q, getDialect(), start, end); } cacheResult(list); FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_RESPONSABLEASINGADOSOLRECLUTAMIENTOIN, finderArgs, list); } catch (Exception e) { FinderCacheUtil.removeResult( FINDER_PATH_WITH_PAGINATION_FIND_BY_RESPONSABLEASINGADOSOLRECLUTAMIENTOIN, finderArgs); throw processException(e); } finally { closeSession(session); } } return list; }