List of usage examples for com.liferay.portal.kernel.util StringPool CLOSE_PARENTHESIS
String CLOSE_PARENTHESIS
To view the source code for com.liferay.portal.kernel.util StringPool CLOSE_PARENTHESIS.
Click Source Link
From source file:com.liferay.micro.maintainance.candidate.service.persistence.impl.CandidateEntryPersistenceImpl.java
License:Open Source License
@Override public Map<Serializable, CandidateEntry> fetchByPrimaryKeys(Set<Serializable> primaryKeys) { if (primaryKeys.isEmpty()) { return Collections.emptyMap(); }/*from w w w. j a v a 2s . c o m*/ Map<Serializable, CandidateEntry> map = new HashMap<Serializable, CandidateEntry>(); if (primaryKeys.size() == 1) { Iterator<Serializable> iterator = primaryKeys.iterator(); Serializable primaryKey = iterator.next(); CandidateEntry candidateEntry = fetchByPrimaryKey(primaryKey); if (candidateEntry != null) { map.put(primaryKey, candidateEntry); } return map; } Set<Serializable> uncachedPrimaryKeys = null; for (Serializable primaryKey : primaryKeys) { Serializable serializable = entityCache.getResult(CandidateEntryModelImpl.ENTITY_CACHE_ENABLED, CandidateEntryImpl.class, primaryKey); if (serializable != nullModel) { if (serializable == null) { if (uncachedPrimaryKeys == null) { uncachedPrimaryKeys = new HashSet<Serializable>(); } uncachedPrimaryKeys.add(primaryKey); } else { map.put(primaryKey, (CandidateEntry) serializable); } } } if (uncachedPrimaryKeys == null) { return map; } StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) + 1); query.append(_SQL_SELECT_CANDIDATEENTRY_WHERE_PKS_IN); for (Serializable primaryKey : uncachedPrimaryKeys) { query.append(String.valueOf(primaryKey)); query.append(StringPool.COMMA); } query.setIndex(query.index() - 1); query.append(StringPool.CLOSE_PARENTHESIS); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); for (CandidateEntry candidateEntry : (List<CandidateEntry>) q.list()) { map.put(candidateEntry.getPrimaryKeyObj(), candidateEntry); cacheResult(candidateEntry); uncachedPrimaryKeys.remove(candidateEntry.getPrimaryKeyObj()); } for (Serializable primaryKey : uncachedPrimaryKeys) { entityCache.putResult(CandidateEntryModelImpl.ENTITY_CACHE_ENABLED, CandidateEntryImpl.class, primaryKey, nullModel); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } return map; }
From source file:com.liferay.micro.maintainance.decision.service.persistence.impl.DecisionEntryPersistenceImpl.java
License:Open Source License
@Override public Map<Serializable, DecisionEntry> fetchByPrimaryKeys(Set<Serializable> primaryKeys) { if (primaryKeys.isEmpty()) { return Collections.emptyMap(); }/*from w w w . j a va2 s . c o m*/ Map<Serializable, DecisionEntry> map = new HashMap<Serializable, DecisionEntry>(); if (primaryKeys.size() == 1) { Iterator<Serializable> iterator = primaryKeys.iterator(); Serializable primaryKey = iterator.next(); DecisionEntry decisionEntry = fetchByPrimaryKey(primaryKey); if (decisionEntry != null) { map.put(primaryKey, decisionEntry); } return map; } Set<Serializable> uncachedPrimaryKeys = null; for (Serializable primaryKey : primaryKeys) { Serializable serializable = entityCache.getResult(DecisionEntryModelImpl.ENTITY_CACHE_ENABLED, DecisionEntryImpl.class, primaryKey); if (serializable != nullModel) { if (serializable == null) { if (uncachedPrimaryKeys == null) { uncachedPrimaryKeys = new HashSet<Serializable>(); } uncachedPrimaryKeys.add(primaryKey); } else { map.put(primaryKey, (DecisionEntry) serializable); } } } if (uncachedPrimaryKeys == null) { return map; } StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) + 1); query.append(_SQL_SELECT_DECISIONENTRY_WHERE_PKS_IN); for (Serializable primaryKey : uncachedPrimaryKeys) { query.append(String.valueOf(primaryKey)); query.append(StringPool.COMMA); } query.setIndex(query.index() - 1); query.append(StringPool.CLOSE_PARENTHESIS); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); for (DecisionEntry decisionEntry : (List<DecisionEntry>) q.list()) { map.put(decisionEntry.getPrimaryKeyObj(), decisionEntry); cacheResult(decisionEntry); uncachedPrimaryKeys.remove(decisionEntry.getPrimaryKeyObj()); } for (Serializable primaryKey : uncachedPrimaryKeys) { entityCache.putResult(DecisionEntryModelImpl.ENTITY_CACHE_ENABLED, DecisionEntryImpl.class, primaryKey, nullModel); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } return map; }
From source file:com.liferay.micro.maintainance.task.service.persistence.impl.CandidateMaintenancePersistenceImpl.java
License:Open Source License
@Override public Map<Serializable, CandidateMaintenance> fetchByPrimaryKeys(Set<Serializable> primaryKeys) { if (primaryKeys.isEmpty()) { return Collections.emptyMap(); }/*from w w w . j a v a 2s. c o m*/ Map<Serializable, CandidateMaintenance> map = new HashMap<Serializable, CandidateMaintenance>(); if (primaryKeys.size() == 1) { Iterator<Serializable> iterator = primaryKeys.iterator(); Serializable primaryKey = iterator.next(); CandidateMaintenance candidateMaintenance = fetchByPrimaryKey(primaryKey); if (candidateMaintenance != null) { map.put(primaryKey, candidateMaintenance); } return map; } Set<Serializable> uncachedPrimaryKeys = null; for (Serializable primaryKey : primaryKeys) { Serializable serializable = entityCache.getResult(CandidateMaintenanceModelImpl.ENTITY_CACHE_ENABLED, CandidateMaintenanceImpl.class, primaryKey); if (serializable != nullModel) { if (serializable == null) { if (uncachedPrimaryKeys == null) { uncachedPrimaryKeys = new HashSet<Serializable>(); } uncachedPrimaryKeys.add(primaryKey); } else { map.put(primaryKey, (CandidateMaintenance) serializable); } } } if (uncachedPrimaryKeys == null) { return map; } StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) + 1); query.append(_SQL_SELECT_CANDIDATEMAINTENANCE_WHERE_PKS_IN); for (Serializable primaryKey : uncachedPrimaryKeys) { query.append(String.valueOf(primaryKey)); query.append(StringPool.COMMA); } query.setIndex(query.index() - 1); query.append(StringPool.CLOSE_PARENTHESIS); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); for (CandidateMaintenance candidateMaintenance : (List<CandidateMaintenance>) q.list()) { map.put(candidateMaintenance.getPrimaryKeyObj(), candidateMaintenance); cacheResult(candidateMaintenance); uncachedPrimaryKeys.remove(candidateMaintenance.getPrimaryKeyObj()); } for (Serializable primaryKey : uncachedPrimaryKeys) { entityCache.putResult(CandidateMaintenanceModelImpl.ENTITY_CACHE_ENABLED, CandidateMaintenanceImpl.class, primaryKey, nullModel); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } return map; }
From source file:com.liferay.micro.maintainance.task.service.persistence.impl.TaskEntryPersistenceImpl.java
License:Open Source License
@Override public Map<Serializable, TaskEntry> fetchByPrimaryKeys(Set<Serializable> primaryKeys) { if (primaryKeys.isEmpty()) { return Collections.emptyMap(); }//from ww w.j ava 2 s . c om Map<Serializable, TaskEntry> map = new HashMap<Serializable, TaskEntry>(); if (primaryKeys.size() == 1) { Iterator<Serializable> iterator = primaryKeys.iterator(); Serializable primaryKey = iterator.next(); TaskEntry taskEntry = fetchByPrimaryKey(primaryKey); if (taskEntry != null) { map.put(primaryKey, taskEntry); } return map; } Set<Serializable> uncachedPrimaryKeys = null; for (Serializable primaryKey : primaryKeys) { Serializable serializable = entityCache.getResult(TaskEntryModelImpl.ENTITY_CACHE_ENABLED, TaskEntryImpl.class, primaryKey); if (serializable != nullModel) { if (serializable == null) { if (uncachedPrimaryKeys == null) { uncachedPrimaryKeys = new HashSet<Serializable>(); } uncachedPrimaryKeys.add(primaryKey); } else { map.put(primaryKey, (TaskEntry) serializable); } } } if (uncachedPrimaryKeys == null) { return map; } StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) + 1); query.append(_SQL_SELECT_TASKENTRY_WHERE_PKS_IN); for (Serializable primaryKey : uncachedPrimaryKeys) { query.append(String.valueOf(primaryKey)); query.append(StringPool.COMMA); } query.setIndex(query.index() - 1); query.append(StringPool.CLOSE_PARENTHESIS); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); for (TaskEntry taskEntry : (List<TaskEntry>) q.list()) { map.put(taskEntry.getPrimaryKeyObj(), taskEntry); cacheResult(taskEntry); uncachedPrimaryKeys.remove(taskEntry.getPrimaryKeyObj()); } for (Serializable primaryKey : uncachedPrimaryKeys) { entityCache.putResult(TaskEntryModelImpl.ENTITY_CACHE_ENABLED, TaskEntryImpl.class, primaryKey, nullModel); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } return map; }
From source file:com.liferay.microblogs.service.persistence.impl.MicroblogsEntryPersistenceImpl.java
License:Open Source License
/** * Returns an ordered range of all the microblogs entries that the user has permission to view where creatorClassNameId = ? and creatorClassPK = any ?. * * <p>// w ww. j ava2 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.liferay.microblogs.model.impl.MicroblogsEntryModelImpl}. 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 creatorClassNameId the creator class name ID * @param creatorClassPKs the creator class p ks * @param start the lower bound of the range of microblogs entries * @param end the upper bound of the range of microblogs entries (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching microblogs entries that the user has permission to view */ @Override public List<MicroblogsEntry> filterFindByCCNI_CCPK(long creatorClassNameId, long[] creatorClassPKs, int start, int end, OrderByComparator<MicroblogsEntry> orderByComparator) { if (!InlineSQLHelperUtil.isEnabled()) { return findByCCNI_CCPK(creatorClassNameId, creatorClassPKs, start, end, orderByComparator); } if (creatorClassPKs == null) { creatorClassPKs = new long[0]; } else { creatorClassPKs = ArrayUtil.unique(creatorClassPKs); } StringBundler query = new StringBundler(); if (getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_MICROBLOGSENTRY_WHERE); } else { query.append(_FILTER_SQL_SELECT_MICROBLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1); } query.append(_FINDER_COLUMN_CCNI_CCPK_CREATORCLASSNAMEID_2); if (creatorClassPKs.length > 0) { query.append(StringPool.OPEN_PARENTHESIS); query.append(_FINDER_COLUMN_CCNI_CCPK_CREATORCLASSPK_7); query.append(StringUtil.merge(creatorClassPKs)); query.append(StringPool.CLOSE_PARENTHESIS); query.append(StringPool.CLOSE_PARENTHESIS); } query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)), query.index() - 1); if (!getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_MICROBLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2); } if (orderByComparator != null) { if (getDB().isSupportsInlineDistinct()) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator, true); } else { appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE, orderByComparator, true); } } else { if (getDB().isSupportsInlineDistinct()) { query.append(MicroblogsEntryModelImpl.ORDER_BY_JPQL); } else { query.append(MicroblogsEntryModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), MicroblogsEntry.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN); Session session = null; try { session = openSession(); SQLQuery q = session.createSynchronizedSQLQuery(sql); if (getDB().isSupportsInlineDistinct()) { q.addEntity(_FILTER_ENTITY_ALIAS, MicroblogsEntryImpl.class); } else { q.addEntity(_FILTER_ENTITY_TABLE, MicroblogsEntryImpl.class); } QueryPos qPos = QueryPos.getInstance(q); qPos.add(creatorClassNameId); return (List<MicroblogsEntry>) QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } }
From source file:com.liferay.microblogs.service.persistence.impl.MicroblogsEntryPersistenceImpl.java
License:Open Source License
/** * Returns an ordered range of all the microblogs entries where creatorClassNameId = ? and creatorClassPK = any ?. * * <p>// ww w . j a 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.liferay.microblogs.model.impl.MicroblogsEntryModelImpl}. 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 creatorClassNameId the creator class name ID * @param creatorClassPKs the creator class p ks * @param start the lower bound of the range of microblogs entries * @param end the upper bound of the range of microblogs entries (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching microblogs entries */ @Override public List<MicroblogsEntry> findByCCNI_CCPK(long creatorClassNameId, long[] creatorClassPKs, int start, int end, OrderByComparator<MicroblogsEntry> orderByComparator) { if (creatorClassPKs == null) { creatorClassPKs = new long[0]; } else { creatorClassPKs = ArrayUtil.unique(creatorClassPKs); } if (creatorClassPKs.length == 1) { return findByCCNI_CCPK(creatorClassNameId, creatorClassPKs[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[] { creatorClassNameId, StringUtil.merge(creatorClassPKs) }; } else { finderArgs = new Object[] { creatorClassNameId, StringUtil.merge(creatorClassPKs), start, end, orderByComparator }; } List<MicroblogsEntry> list = (List<MicroblogsEntry>) FinderCacheUtil .getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_CCNI_CCPK, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (MicroblogsEntry microblogsEntry : list) { if ((creatorClassNameId != microblogsEntry.getCreatorClassNameId()) || !ArrayUtil.contains(creatorClassPKs, microblogsEntry.getCreatorClassPK())) { list = null; break; } } } if (list == null) { StringBundler query = new StringBundler(); query.append(_SQL_SELECT_MICROBLOGSENTRY_WHERE); query.append(_FINDER_COLUMN_CCNI_CCPK_CREATORCLASSNAMEID_2); if (creatorClassPKs.length > 0) { query.append(StringPool.OPEN_PARENTHESIS); query.append(_FINDER_COLUMN_CCNI_CCPK_CREATORCLASSPK_7); query.append(StringUtil.merge(creatorClassPKs)); 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(MicroblogsEntryModelImpl.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(creatorClassNameId); if (!pagination) { list = (List<MicroblogsEntry>) QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<MicroblogsEntry>) QueryUtil.list(q, getDialect(), start, end); } cacheResult(list); FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_CCNI_CCPK, finderArgs, list); } catch (Exception e) { FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_CCNI_CCPK, finderArgs); throw processException(e); } finally { closeSession(session); } } return list; }
From source file:com.liferay.microblogs.service.persistence.impl.MicroblogsEntryPersistenceImpl.java
License:Open Source License
/** * Returns the number of microblogs entries where creatorClassNameId = ? and creatorClassPK = any ?. * * @param creatorClassNameId the creator class name ID * @param creatorClassPKs the creator class p ks * @return the number of matching microblogs entries *///from w w w. jav a2s . c o m @Override public int countByCCNI_CCPK(long creatorClassNameId, long[] creatorClassPKs) { if (creatorClassPKs == null) { creatorClassPKs = new long[0]; } else { creatorClassPKs = ArrayUtil.unique(creatorClassPKs); } Object[] finderArgs = new Object[] { creatorClassNameId, StringUtil.merge(creatorClassPKs) }; Long count = (Long) FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_CCNI_CCPK, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(); query.append(_SQL_COUNT_MICROBLOGSENTRY_WHERE); query.append(_FINDER_COLUMN_CCNI_CCPK_CREATORCLASSNAMEID_2); if (creatorClassPKs.length > 0) { query.append(StringPool.OPEN_PARENTHESIS); query.append(_FINDER_COLUMN_CCNI_CCPK_CREATORCLASSPK_7); query.append(StringUtil.merge(creatorClassPKs)); 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(creatorClassNameId); count = (Long) q.uniqueResult(); FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_CCNI_CCPK, finderArgs, count); } catch (Exception e) { FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_CCNI_CCPK, finderArgs); throw processException(e); } finally { closeSession(session); } } return count.intValue(); }
From source file:com.liferay.microblogs.service.persistence.impl.MicroblogsEntryPersistenceImpl.java
License:Open Source License
/** * Returns the number of microblogs entries that the user has permission to view where creatorClassNameId = ? and creatorClassPK = any ?. * * @param creatorClassNameId the creator class name ID * @param creatorClassPKs the creator class p ks * @return the number of matching microblogs entries that the user has permission to view *//*from w w w.j a v a2 s . c o m*/ @Override public int filterCountByCCNI_CCPK(long creatorClassNameId, long[] creatorClassPKs) { if (!InlineSQLHelperUtil.isEnabled()) { return countByCCNI_CCPK(creatorClassNameId, creatorClassPKs); } if (creatorClassPKs == null) { creatorClassPKs = new long[0]; } else { creatorClassPKs = ArrayUtil.unique(creatorClassPKs); } StringBundler query = new StringBundler(); query.append(_FILTER_SQL_COUNT_MICROBLOGSENTRY_WHERE); query.append(_FINDER_COLUMN_CCNI_CCPK_CREATORCLASSNAMEID_2); if (creatorClassPKs.length > 0) { query.append(StringPool.OPEN_PARENTHESIS); query.append(_FINDER_COLUMN_CCNI_CCPK_CREATORCLASSPK_7); query.append(StringUtil.merge(creatorClassPKs)); query.append(StringPool.CLOSE_PARENTHESIS); query.append(StringPool.CLOSE_PARENTHESIS); } query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)), query.index() - 1); String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), MicroblogsEntry.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN); Session session = null; try { session = openSession(); SQLQuery q = session.createSynchronizedSQLQuery(sql); q.addScalar(COUNT_COLUMN_NAME, com.liferay.portal.kernel.dao.orm.Type.LONG); QueryPos qPos = QueryPos.getInstance(q); qPos.add(creatorClassNameId); Long count = (Long) q.uniqueResult(); return count.intValue(); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } }
From source file:com.liferay.microblogs.service.persistence.impl.MicroblogsEntryPersistenceImpl.java
License:Open Source License
/** * Returns an ordered range of all the microblogs entries that the user has permission to view where creatorClassNameId = ? and creatorClassPK = any ? and type = ?. * * <p>// www. j a 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.liferay.microblogs.model.impl.MicroblogsEntryModelImpl}. 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 creatorClassNameId the creator class name ID * @param creatorClassPKs the creator class p ks * @param type the type * @param start the lower bound of the range of microblogs entries * @param end the upper bound of the range of microblogs entries (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching microblogs entries that the user has permission to view */ @Override public List<MicroblogsEntry> filterFindByCCNI_CCPK_T(long creatorClassNameId, long[] creatorClassPKs, int type, int start, int end, OrderByComparator<MicroblogsEntry> orderByComparator) { if (!InlineSQLHelperUtil.isEnabled()) { return findByCCNI_CCPK_T(creatorClassNameId, creatorClassPKs, type, start, end, orderByComparator); } if (creatorClassPKs == null) { creatorClassPKs = new long[0]; } else { creatorClassPKs = ArrayUtil.unique(creatorClassPKs); } StringBundler query = new StringBundler(); if (getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_MICROBLOGSENTRY_WHERE); } else { query.append(_FILTER_SQL_SELECT_MICROBLOGSENTRY_NO_INLINE_DISTINCT_WHERE_1); } query.append(_FINDER_COLUMN_CCNI_CCPK_T_CREATORCLASSNAMEID_2); if (creatorClassPKs.length > 0) { query.append(StringPool.OPEN_PARENTHESIS); query.append(_FINDER_COLUMN_CCNI_CCPK_T_CREATORCLASSPK_7); query.append(StringUtil.merge(creatorClassPKs)); query.append(StringPool.CLOSE_PARENTHESIS); query.append(StringPool.CLOSE_PARENTHESIS); query.append(WHERE_AND); } query.append(_FINDER_COLUMN_CCNI_CCPK_T_TYPE_2_SQL); query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)), query.index() - 1); if (!getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_MICROBLOGSENTRY_NO_INLINE_DISTINCT_WHERE_2); } if (orderByComparator != null) { if (getDB().isSupportsInlineDistinct()) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator, true); } else { appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE, orderByComparator, true); } } else { if (getDB().isSupportsInlineDistinct()) { query.append(MicroblogsEntryModelImpl.ORDER_BY_JPQL); } else { query.append(MicroblogsEntryModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), MicroblogsEntry.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN); Session session = null; try { session = openSession(); SQLQuery q = session.createSynchronizedSQLQuery(sql); if (getDB().isSupportsInlineDistinct()) { q.addEntity(_FILTER_ENTITY_ALIAS, MicroblogsEntryImpl.class); } else { q.addEntity(_FILTER_ENTITY_TABLE, MicroblogsEntryImpl.class); } QueryPos qPos = QueryPos.getInstance(q); qPos.add(creatorClassNameId); qPos.add(type); return (List<MicroblogsEntry>) QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } }
From source file:com.liferay.microblogs.service.persistence.impl.MicroblogsEntryPersistenceImpl.java
License:Open Source License
/** * Returns an ordered range of all the microblogs entries where creatorClassNameId = ? and creatorClassPK = any ? and type = ?. * * <p>/* ww w . jav 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 com.liferay.microblogs.model.impl.MicroblogsEntryModelImpl}. 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 creatorClassNameId the creator class name ID * @param creatorClassPKs the creator class p ks * @param type the type * @param start the lower bound of the range of microblogs entries * @param end the upper bound of the range of microblogs entries (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching microblogs entries */ @Override public List<MicroblogsEntry> findByCCNI_CCPK_T(long creatorClassNameId, long[] creatorClassPKs, int type, int start, int end, OrderByComparator<MicroblogsEntry> orderByComparator) { if (creatorClassPKs == null) { creatorClassPKs = new long[0]; } else { creatorClassPKs = ArrayUtil.unique(creatorClassPKs); } if (creatorClassPKs.length == 1) { return findByCCNI_CCPK_T(creatorClassNameId, creatorClassPKs[0], type, 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[] { creatorClassNameId, StringUtil.merge(creatorClassPKs), type }; } else { finderArgs = new Object[] { creatorClassNameId, StringUtil.merge(creatorClassPKs), type, start, end, orderByComparator }; } List<MicroblogsEntry> list = (List<MicroblogsEntry>) FinderCacheUtil .getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_CCNI_CCPK_T, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (MicroblogsEntry microblogsEntry : list) { if ((creatorClassNameId != microblogsEntry.getCreatorClassNameId()) || !ArrayUtil.contains(creatorClassPKs, microblogsEntry.getCreatorClassPK()) || (type != microblogsEntry.getType())) { list = null; break; } } } if (list == null) { StringBundler query = new StringBundler(); query.append(_SQL_SELECT_MICROBLOGSENTRY_WHERE); query.append(_FINDER_COLUMN_CCNI_CCPK_T_CREATORCLASSNAMEID_2); if (creatorClassPKs.length > 0) { query.append(StringPool.OPEN_PARENTHESIS); query.append(_FINDER_COLUMN_CCNI_CCPK_T_CREATORCLASSPK_7); query.append(StringUtil.merge(creatorClassPKs)); query.append(StringPool.CLOSE_PARENTHESIS); query.append(StringPool.CLOSE_PARENTHESIS); query.append(WHERE_AND); } query.append(_FINDER_COLUMN_CCNI_CCPK_T_TYPE_2); 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(MicroblogsEntryModelImpl.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(creatorClassNameId); qPos.add(type); if (!pagination) { list = (List<MicroblogsEntry>) QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<MicroblogsEntry>) QueryUtil.list(q, getDialect(), start, end); } cacheResult(list); FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_CCNI_CCPK_T, finderArgs, list); } catch (Exception e) { FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_CCNI_CCPK_T, finderArgs); throw processException(e); } finally { closeSession(session); } } return list; }