001
014
015 package com.liferay.portlet.journal.service.persistence;
016
017 import com.liferay.portal.kernel.cache.CacheRegistryUtil;
018 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
019 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
020 import com.liferay.portal.kernel.dao.orm.FinderPath;
021 import com.liferay.portal.kernel.dao.orm.Query;
022 import com.liferay.portal.kernel.dao.orm.QueryPos;
023 import com.liferay.portal.kernel.dao.orm.QueryUtil;
024 import com.liferay.portal.kernel.dao.orm.SQLQuery;
025 import com.liferay.portal.kernel.dao.orm.Session;
026 import com.liferay.portal.kernel.exception.SystemException;
027 import com.liferay.portal.kernel.log.Log;
028 import com.liferay.portal.kernel.log.LogFactoryUtil;
029 import com.liferay.portal.kernel.util.GetterUtil;
030 import com.liferay.portal.kernel.util.InstanceFactory;
031 import com.liferay.portal.kernel.util.OrderByComparator;
032 import com.liferay.portal.kernel.util.SetUtil;
033 import com.liferay.portal.kernel.util.StringBundler;
034 import com.liferay.portal.kernel.util.StringPool;
035 import com.liferay.portal.kernel.util.StringUtil;
036 import com.liferay.portal.kernel.util.UnmodifiableList;
037 import com.liferay.portal.kernel.util.Validator;
038 import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
039 import com.liferay.portal.model.CacheModel;
040 import com.liferay.portal.model.ModelListener;
041 import com.liferay.portal.security.permission.InlineSQLHelperUtil;
042 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
043
044 import com.liferay.portlet.journal.NoSuchFolderException;
045 import com.liferay.portlet.journal.model.JournalFolder;
046 import com.liferay.portlet.journal.model.impl.JournalFolderImpl;
047 import com.liferay.portlet.journal.model.impl.JournalFolderModelImpl;
048
049 import java.io.Serializable;
050
051 import java.util.ArrayList;
052 import java.util.Collections;
053 import java.util.List;
054 import java.util.Set;
055
056
068 public class JournalFolderPersistenceImpl extends BasePersistenceImpl<JournalFolder>
069 implements JournalFolderPersistence {
070
075 public static final String FINDER_CLASS_NAME_ENTITY = JournalFolderImpl.class.getName();
076 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
077 ".List1";
078 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
079 ".List2";
080 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(JournalFolderModelImpl.ENTITY_CACHE_ENABLED,
081 JournalFolderModelImpl.FINDER_CACHE_ENABLED,
082 JournalFolderImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
083 "findAll", new String[0]);
084 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(JournalFolderModelImpl.ENTITY_CACHE_ENABLED,
085 JournalFolderModelImpl.FINDER_CACHE_ENABLED,
086 JournalFolderImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
087 "findAll", new String[0]);
088 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(JournalFolderModelImpl.ENTITY_CACHE_ENABLED,
089 JournalFolderModelImpl.FINDER_CACHE_ENABLED, Long.class,
090 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
091 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(JournalFolderModelImpl.ENTITY_CACHE_ENABLED,
092 JournalFolderModelImpl.FINDER_CACHE_ENABLED,
093 JournalFolderImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
094 "findByUuid",
095 new String[] {
096 String.class.getName(),
097
098 Integer.class.getName(), Integer.class.getName(),
099 OrderByComparator.class.getName()
100 });
101 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(JournalFolderModelImpl.ENTITY_CACHE_ENABLED,
102 JournalFolderModelImpl.FINDER_CACHE_ENABLED,
103 JournalFolderImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
104 "findByUuid", new String[] { String.class.getName() },
105 JournalFolderModelImpl.UUID_COLUMN_BITMASK |
106 JournalFolderModelImpl.PARENTFOLDERID_COLUMN_BITMASK |
107 JournalFolderModelImpl.NAME_COLUMN_BITMASK);
108 public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(JournalFolderModelImpl.ENTITY_CACHE_ENABLED,
109 JournalFolderModelImpl.FINDER_CACHE_ENABLED, Long.class,
110 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
111 new String[] { String.class.getName() });
112
113
120 public List<JournalFolder> findByUuid(String uuid)
121 throws SystemException {
122 return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
123 }
124
125
138 public List<JournalFolder> findByUuid(String uuid, int start, int end)
139 throws SystemException {
140 return findByUuid(uuid, start, end, null);
141 }
142
143
157 public List<JournalFolder> findByUuid(String uuid, int start, int end,
158 OrderByComparator orderByComparator) throws SystemException {
159 boolean pagination = true;
160 FinderPath finderPath = null;
161 Object[] finderArgs = null;
162
163 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
164 (orderByComparator == null)) {
165 pagination = false;
166 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
167 finderArgs = new Object[] { uuid };
168 }
169 else {
170 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
171 finderArgs = new Object[] { uuid, start, end, orderByComparator };
172 }
173
174 List<JournalFolder> list = (List<JournalFolder>)FinderCacheUtil.getResult(finderPath,
175 finderArgs, this);
176
177 if ((list != null) && !list.isEmpty()) {
178 for (JournalFolder journalFolder : list) {
179 if (!Validator.equals(uuid, journalFolder.getUuid())) {
180 list = null;
181
182 break;
183 }
184 }
185 }
186
187 if (list == null) {
188 StringBundler query = null;
189
190 if (orderByComparator != null) {
191 query = new StringBundler(3 +
192 (orderByComparator.getOrderByFields().length * 3));
193 }
194 else {
195 query = new StringBundler(3);
196 }
197
198 query.append(_SQL_SELECT_JOURNALFOLDER_WHERE);
199
200 boolean bindUuid = false;
201
202 if (uuid == null) {
203 query.append(_FINDER_COLUMN_UUID_UUID_1);
204 }
205 else if (uuid.equals(StringPool.BLANK)) {
206 query.append(_FINDER_COLUMN_UUID_UUID_3);
207 }
208 else {
209 bindUuid = true;
210
211 query.append(_FINDER_COLUMN_UUID_UUID_2);
212 }
213
214 if (orderByComparator != null) {
215 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
216 orderByComparator);
217 }
218 else
219 if (pagination) {
220 query.append(JournalFolderModelImpl.ORDER_BY_JPQL);
221 }
222
223 String sql = query.toString();
224
225 Session session = null;
226
227 try {
228 session = openSession();
229
230 Query q = session.createQuery(sql);
231
232 QueryPos qPos = QueryPos.getInstance(q);
233
234 if (bindUuid) {
235 qPos.add(uuid);
236 }
237
238 if (!pagination) {
239 list = (List<JournalFolder>)QueryUtil.list(q, getDialect(),
240 start, end, false);
241
242 Collections.sort(list);
243
244 list = new UnmodifiableList<JournalFolder>(list);
245 }
246 else {
247 list = (List<JournalFolder>)QueryUtil.list(q, getDialect(),
248 start, end);
249 }
250
251 cacheResult(list);
252
253 FinderCacheUtil.putResult(finderPath, finderArgs, list);
254 }
255 catch (Exception e) {
256 FinderCacheUtil.removeResult(finderPath, finderArgs);
257
258 throw processException(e);
259 }
260 finally {
261 closeSession(session);
262 }
263 }
264
265 return list;
266 }
267
268
277 public JournalFolder findByUuid_First(String uuid,
278 OrderByComparator orderByComparator)
279 throws NoSuchFolderException, SystemException {
280 JournalFolder journalFolder = fetchByUuid_First(uuid, orderByComparator);
281
282 if (journalFolder != null) {
283 return journalFolder;
284 }
285
286 StringBundler msg = new StringBundler(4);
287
288 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
289
290 msg.append("uuid=");
291 msg.append(uuid);
292
293 msg.append(StringPool.CLOSE_CURLY_BRACE);
294
295 throw new NoSuchFolderException(msg.toString());
296 }
297
298
306 public JournalFolder fetchByUuid_First(String uuid,
307 OrderByComparator orderByComparator) throws SystemException {
308 List<JournalFolder> list = findByUuid(uuid, 0, 1, orderByComparator);
309
310 if (!list.isEmpty()) {
311 return list.get(0);
312 }
313
314 return null;
315 }
316
317
326 public JournalFolder findByUuid_Last(String uuid,
327 OrderByComparator orderByComparator)
328 throws NoSuchFolderException, SystemException {
329 JournalFolder journalFolder = fetchByUuid_Last(uuid, orderByComparator);
330
331 if (journalFolder != null) {
332 return journalFolder;
333 }
334
335 StringBundler msg = new StringBundler(4);
336
337 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
338
339 msg.append("uuid=");
340 msg.append(uuid);
341
342 msg.append(StringPool.CLOSE_CURLY_BRACE);
343
344 throw new NoSuchFolderException(msg.toString());
345 }
346
347
355 public JournalFolder fetchByUuid_Last(String uuid,
356 OrderByComparator orderByComparator) throws SystemException {
357 int count = countByUuid(uuid);
358
359 List<JournalFolder> list = findByUuid(uuid, count - 1, count,
360 orderByComparator);
361
362 if (!list.isEmpty()) {
363 return list.get(0);
364 }
365
366 return null;
367 }
368
369
379 public JournalFolder[] findByUuid_PrevAndNext(long folderId, String uuid,
380 OrderByComparator orderByComparator)
381 throws NoSuchFolderException, SystemException {
382 JournalFolder journalFolder = findByPrimaryKey(folderId);
383
384 Session session = null;
385
386 try {
387 session = openSession();
388
389 JournalFolder[] array = new JournalFolderImpl[3];
390
391 array[0] = getByUuid_PrevAndNext(session, journalFolder, uuid,
392 orderByComparator, true);
393
394 array[1] = journalFolder;
395
396 array[2] = getByUuid_PrevAndNext(session, journalFolder, uuid,
397 orderByComparator, false);
398
399 return array;
400 }
401 catch (Exception e) {
402 throw processException(e);
403 }
404 finally {
405 closeSession(session);
406 }
407 }
408
409 protected JournalFolder getByUuid_PrevAndNext(Session session,
410 JournalFolder journalFolder, String uuid,
411 OrderByComparator orderByComparator, boolean previous) {
412 StringBundler query = null;
413
414 if (orderByComparator != null) {
415 query = new StringBundler(6 +
416 (orderByComparator.getOrderByFields().length * 6));
417 }
418 else {
419 query = new StringBundler(3);
420 }
421
422 query.append(_SQL_SELECT_JOURNALFOLDER_WHERE);
423
424 boolean bindUuid = false;
425
426 if (uuid == null) {
427 query.append(_FINDER_COLUMN_UUID_UUID_1);
428 }
429 else if (uuid.equals(StringPool.BLANK)) {
430 query.append(_FINDER_COLUMN_UUID_UUID_3);
431 }
432 else {
433 bindUuid = true;
434
435 query.append(_FINDER_COLUMN_UUID_UUID_2);
436 }
437
438 if (orderByComparator != null) {
439 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
440
441 if (orderByConditionFields.length > 0) {
442 query.append(WHERE_AND);
443 }
444
445 for (int i = 0; i < orderByConditionFields.length; i++) {
446 query.append(_ORDER_BY_ENTITY_ALIAS);
447 query.append(orderByConditionFields[i]);
448
449 if ((i + 1) < orderByConditionFields.length) {
450 if (orderByComparator.isAscending() ^ previous) {
451 query.append(WHERE_GREATER_THAN_HAS_NEXT);
452 }
453 else {
454 query.append(WHERE_LESSER_THAN_HAS_NEXT);
455 }
456 }
457 else {
458 if (orderByComparator.isAscending() ^ previous) {
459 query.append(WHERE_GREATER_THAN);
460 }
461 else {
462 query.append(WHERE_LESSER_THAN);
463 }
464 }
465 }
466
467 query.append(ORDER_BY_CLAUSE);
468
469 String[] orderByFields = orderByComparator.getOrderByFields();
470
471 for (int i = 0; i < orderByFields.length; i++) {
472 query.append(_ORDER_BY_ENTITY_ALIAS);
473 query.append(orderByFields[i]);
474
475 if ((i + 1) < orderByFields.length) {
476 if (orderByComparator.isAscending() ^ previous) {
477 query.append(ORDER_BY_ASC_HAS_NEXT);
478 }
479 else {
480 query.append(ORDER_BY_DESC_HAS_NEXT);
481 }
482 }
483 else {
484 if (orderByComparator.isAscending() ^ previous) {
485 query.append(ORDER_BY_ASC);
486 }
487 else {
488 query.append(ORDER_BY_DESC);
489 }
490 }
491 }
492 }
493 else {
494 query.append(JournalFolderModelImpl.ORDER_BY_JPQL);
495 }
496
497 String sql = query.toString();
498
499 Query q = session.createQuery(sql);
500
501 q.setFirstResult(0);
502 q.setMaxResults(2);
503
504 QueryPos qPos = QueryPos.getInstance(q);
505
506 if (bindUuid) {
507 qPos.add(uuid);
508 }
509
510 if (orderByComparator != null) {
511 Object[] values = orderByComparator.getOrderByConditionValues(journalFolder);
512
513 for (Object value : values) {
514 qPos.add(value);
515 }
516 }
517
518 List<JournalFolder> list = q.list();
519
520 if (list.size() == 2) {
521 return list.get(1);
522 }
523 else {
524 return null;
525 }
526 }
527
528
534 public void removeByUuid(String uuid) throws SystemException {
535 for (JournalFolder journalFolder : findByUuid(uuid, QueryUtil.ALL_POS,
536 QueryUtil.ALL_POS, null)) {
537 remove(journalFolder);
538 }
539 }
540
541
548 public int countByUuid(String uuid) throws SystemException {
549 FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID;
550
551 Object[] finderArgs = new Object[] { uuid };
552
553 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
554 this);
555
556 if (count == null) {
557 StringBundler query = new StringBundler(2);
558
559 query.append(_SQL_COUNT_JOURNALFOLDER_WHERE);
560
561 boolean bindUuid = false;
562
563 if (uuid == null) {
564 query.append(_FINDER_COLUMN_UUID_UUID_1);
565 }
566 else if (uuid.equals(StringPool.BLANK)) {
567 query.append(_FINDER_COLUMN_UUID_UUID_3);
568 }
569 else {
570 bindUuid = true;
571
572 query.append(_FINDER_COLUMN_UUID_UUID_2);
573 }
574
575 String sql = query.toString();
576
577 Session session = null;
578
579 try {
580 session = openSession();
581
582 Query q = session.createQuery(sql);
583
584 QueryPos qPos = QueryPos.getInstance(q);
585
586 if (bindUuid) {
587 qPos.add(uuid);
588 }
589
590 count = (Long)q.uniqueResult();
591
592 FinderCacheUtil.putResult(finderPath, finderArgs, count);
593 }
594 catch (Exception e) {
595 FinderCacheUtil.removeResult(finderPath, finderArgs);
596
597 throw processException(e);
598 }
599 finally {
600 closeSession(session);
601 }
602 }
603
604 return count.intValue();
605 }
606
607 private static final String _FINDER_COLUMN_UUID_UUID_1 = "journalFolder.uuid IS NULL";
608 private static final String _FINDER_COLUMN_UUID_UUID_2 = "journalFolder.uuid = ?";
609 private static final String _FINDER_COLUMN_UUID_UUID_3 = "(journalFolder.uuid IS NULL OR journalFolder.uuid = '')";
610 public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(JournalFolderModelImpl.ENTITY_CACHE_ENABLED,
611 JournalFolderModelImpl.FINDER_CACHE_ENABLED,
612 JournalFolderImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByUUID_G",
613 new String[] { String.class.getName(), Long.class.getName() },
614 JournalFolderModelImpl.UUID_COLUMN_BITMASK |
615 JournalFolderModelImpl.GROUPID_COLUMN_BITMASK);
616 public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(JournalFolderModelImpl.ENTITY_CACHE_ENABLED,
617 JournalFolderModelImpl.FINDER_CACHE_ENABLED, Long.class,
618 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G",
619 new String[] { String.class.getName(), Long.class.getName() });
620
621
630 public JournalFolder findByUUID_G(String uuid, long groupId)
631 throws NoSuchFolderException, SystemException {
632 JournalFolder journalFolder = fetchByUUID_G(uuid, groupId);
633
634 if (journalFolder == null) {
635 StringBundler msg = new StringBundler(6);
636
637 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
638
639 msg.append("uuid=");
640 msg.append(uuid);
641
642 msg.append(", groupId=");
643 msg.append(groupId);
644
645 msg.append(StringPool.CLOSE_CURLY_BRACE);
646
647 if (_log.isWarnEnabled()) {
648 _log.warn(msg.toString());
649 }
650
651 throw new NoSuchFolderException(msg.toString());
652 }
653
654 return journalFolder;
655 }
656
657
665 public JournalFolder fetchByUUID_G(String uuid, long groupId)
666 throws SystemException {
667 return fetchByUUID_G(uuid, groupId, true);
668 }
669
670
679 public JournalFolder fetchByUUID_G(String uuid, long groupId,
680 boolean retrieveFromCache) throws SystemException {
681 Object[] finderArgs = new Object[] { uuid, groupId };
682
683 Object result = null;
684
685 if (retrieveFromCache) {
686 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
687 finderArgs, this);
688 }
689
690 if (result instanceof JournalFolder) {
691 JournalFolder journalFolder = (JournalFolder)result;
692
693 if (!Validator.equals(uuid, journalFolder.getUuid()) ||
694 (groupId != journalFolder.getGroupId())) {
695 result = null;
696 }
697 }
698
699 if (result == null) {
700 StringBundler query = new StringBundler(4);
701
702 query.append(_SQL_SELECT_JOURNALFOLDER_WHERE);
703
704 boolean bindUuid = false;
705
706 if (uuid == null) {
707 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
708 }
709 else if (uuid.equals(StringPool.BLANK)) {
710 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
711 }
712 else {
713 bindUuid = true;
714
715 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
716 }
717
718 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
719
720 String sql = query.toString();
721
722 Session session = null;
723
724 try {
725 session = openSession();
726
727 Query q = session.createQuery(sql);
728
729 QueryPos qPos = QueryPos.getInstance(q);
730
731 if (bindUuid) {
732 qPos.add(uuid);
733 }
734
735 qPos.add(groupId);
736
737 List<JournalFolder> list = q.list();
738
739 if (list.isEmpty()) {
740 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
741 finderArgs, list);
742 }
743 else {
744 JournalFolder journalFolder = list.get(0);
745
746 result = journalFolder;
747
748 cacheResult(journalFolder);
749
750 if ((journalFolder.getUuid() == null) ||
751 !journalFolder.getUuid().equals(uuid) ||
752 (journalFolder.getGroupId() != groupId)) {
753 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
754 finderArgs, journalFolder);
755 }
756 }
757 }
758 catch (Exception e) {
759 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
760 finderArgs);
761
762 throw processException(e);
763 }
764 finally {
765 closeSession(session);
766 }
767 }
768
769 if (result instanceof List<?>) {
770 return null;
771 }
772 else {
773 return (JournalFolder)result;
774 }
775 }
776
777
785 public JournalFolder removeByUUID_G(String uuid, long groupId)
786 throws NoSuchFolderException, SystemException {
787 JournalFolder journalFolder = findByUUID_G(uuid, groupId);
788
789 return remove(journalFolder);
790 }
791
792
800 public int countByUUID_G(String uuid, long groupId)
801 throws SystemException {
802 FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_G;
803
804 Object[] finderArgs = new Object[] { uuid, groupId };
805
806 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
807 this);
808
809 if (count == null) {
810 StringBundler query = new StringBundler(3);
811
812 query.append(_SQL_COUNT_JOURNALFOLDER_WHERE);
813
814 boolean bindUuid = false;
815
816 if (uuid == null) {
817 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
818 }
819 else if (uuid.equals(StringPool.BLANK)) {
820 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
821 }
822 else {
823 bindUuid = true;
824
825 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
826 }
827
828 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
829
830 String sql = query.toString();
831
832 Session session = null;
833
834 try {
835 session = openSession();
836
837 Query q = session.createQuery(sql);
838
839 QueryPos qPos = QueryPos.getInstance(q);
840
841 if (bindUuid) {
842 qPos.add(uuid);
843 }
844
845 qPos.add(groupId);
846
847 count = (Long)q.uniqueResult();
848
849 FinderCacheUtil.putResult(finderPath, finderArgs, count);
850 }
851 catch (Exception e) {
852 FinderCacheUtil.removeResult(finderPath, finderArgs);
853
854 throw processException(e);
855 }
856 finally {
857 closeSession(session);
858 }
859 }
860
861 return count.intValue();
862 }
863
864 private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "journalFolder.uuid IS NULL AND ";
865 private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "journalFolder.uuid = ? AND ";
866 private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(journalFolder.uuid IS NULL OR journalFolder.uuid = '') AND ";
867 private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "journalFolder.groupId = ?";
868 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C = new FinderPath(JournalFolderModelImpl.ENTITY_CACHE_ENABLED,
869 JournalFolderModelImpl.FINDER_CACHE_ENABLED,
870 JournalFolderImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
871 "findByUuid_C",
872 new String[] {
873 String.class.getName(), Long.class.getName(),
874
875 Integer.class.getName(), Integer.class.getName(),
876 OrderByComparator.class.getName()
877 });
878 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C =
879 new FinderPath(JournalFolderModelImpl.ENTITY_CACHE_ENABLED,
880 JournalFolderModelImpl.FINDER_CACHE_ENABLED,
881 JournalFolderImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
882 "findByUuid_C",
883 new String[] { String.class.getName(), Long.class.getName() },
884 JournalFolderModelImpl.UUID_COLUMN_BITMASK |
885 JournalFolderModelImpl.COMPANYID_COLUMN_BITMASK |
886 JournalFolderModelImpl.PARENTFOLDERID_COLUMN_BITMASK |
887 JournalFolderModelImpl.NAME_COLUMN_BITMASK);
888 public static final FinderPath FINDER_PATH_COUNT_BY_UUID_C = new FinderPath(JournalFolderModelImpl.ENTITY_CACHE_ENABLED,
889 JournalFolderModelImpl.FINDER_CACHE_ENABLED, Long.class,
890 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid_C",
891 new String[] { String.class.getName(), Long.class.getName() });
892
893
901 public List<JournalFolder> findByUuid_C(String uuid, long companyId)
902 throws SystemException {
903 return findByUuid_C(uuid, companyId, QueryUtil.ALL_POS,
904 QueryUtil.ALL_POS, null);
905 }
906
907
921 public List<JournalFolder> findByUuid_C(String uuid, long companyId,
922 int start, int end) throws SystemException {
923 return findByUuid_C(uuid, companyId, start, end, null);
924 }
925
926
941 public List<JournalFolder> findByUuid_C(String uuid, long companyId,
942 int start, int end, OrderByComparator orderByComparator)
943 throws SystemException {
944 boolean pagination = true;
945 FinderPath finderPath = null;
946 Object[] finderArgs = null;
947
948 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
949 (orderByComparator == null)) {
950 pagination = false;
951 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C;
952 finderArgs = new Object[] { uuid, companyId };
953 }
954 else {
955 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C;
956 finderArgs = new Object[] {
957 uuid, companyId,
958
959 start, end, orderByComparator
960 };
961 }
962
963 List<JournalFolder> list = (List<JournalFolder>)FinderCacheUtil.getResult(finderPath,
964 finderArgs, this);
965
966 if ((list != null) && !list.isEmpty()) {
967 for (JournalFolder journalFolder : list) {
968 if (!Validator.equals(uuid, journalFolder.getUuid()) ||
969 (companyId != journalFolder.getCompanyId())) {
970 list = null;
971
972 break;
973 }
974 }
975 }
976
977 if (list == null) {
978 StringBundler query = null;
979
980 if (orderByComparator != null) {
981 query = new StringBundler(4 +
982 (orderByComparator.getOrderByFields().length * 3));
983 }
984 else {
985 query = new StringBundler(4);
986 }
987
988 query.append(_SQL_SELECT_JOURNALFOLDER_WHERE);
989
990 boolean bindUuid = false;
991
992 if (uuid == null) {
993 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
994 }
995 else if (uuid.equals(StringPool.BLANK)) {
996 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
997 }
998 else {
999 bindUuid = true;
1000
1001 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1002 }
1003
1004 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1005
1006 if (orderByComparator != null) {
1007 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1008 orderByComparator);
1009 }
1010 else
1011 if (pagination) {
1012 query.append(JournalFolderModelImpl.ORDER_BY_JPQL);
1013 }
1014
1015 String sql = query.toString();
1016
1017 Session session = null;
1018
1019 try {
1020 session = openSession();
1021
1022 Query q = session.createQuery(sql);
1023
1024 QueryPos qPos = QueryPos.getInstance(q);
1025
1026 if (bindUuid) {
1027 qPos.add(uuid);
1028 }
1029
1030 qPos.add(companyId);
1031
1032 if (!pagination) {
1033 list = (List<JournalFolder>)QueryUtil.list(q, getDialect(),
1034 start, end, false);
1035
1036 Collections.sort(list);
1037
1038 list = new UnmodifiableList<JournalFolder>(list);
1039 }
1040 else {
1041 list = (List<JournalFolder>)QueryUtil.list(q, getDialect(),
1042 start, end);
1043 }
1044
1045 cacheResult(list);
1046
1047 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1048 }
1049 catch (Exception e) {
1050 FinderCacheUtil.removeResult(finderPath, finderArgs);
1051
1052 throw processException(e);
1053 }
1054 finally {
1055 closeSession(session);
1056 }
1057 }
1058
1059 return list;
1060 }
1061
1062
1072 public JournalFolder findByUuid_C_First(String uuid, long companyId,
1073 OrderByComparator orderByComparator)
1074 throws NoSuchFolderException, SystemException {
1075 JournalFolder journalFolder = fetchByUuid_C_First(uuid, companyId,
1076 orderByComparator);
1077
1078 if (journalFolder != null) {
1079 return journalFolder;
1080 }
1081
1082 StringBundler msg = new StringBundler(6);
1083
1084 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1085
1086 msg.append("uuid=");
1087 msg.append(uuid);
1088
1089 msg.append(", companyId=");
1090 msg.append(companyId);
1091
1092 msg.append(StringPool.CLOSE_CURLY_BRACE);
1093
1094 throw new NoSuchFolderException(msg.toString());
1095 }
1096
1097
1106 public JournalFolder fetchByUuid_C_First(String uuid, long companyId,
1107 OrderByComparator orderByComparator) throws SystemException {
1108 List<JournalFolder> list = findByUuid_C(uuid, companyId, 0, 1,
1109 orderByComparator);
1110
1111 if (!list.isEmpty()) {
1112 return list.get(0);
1113 }
1114
1115 return null;
1116 }
1117
1118
1128 public JournalFolder findByUuid_C_Last(String uuid, long companyId,
1129 OrderByComparator orderByComparator)
1130 throws NoSuchFolderException, SystemException {
1131 JournalFolder journalFolder = fetchByUuid_C_Last(uuid, companyId,
1132 orderByComparator);
1133
1134 if (journalFolder != null) {
1135 return journalFolder;
1136 }
1137
1138 StringBundler msg = new StringBundler(6);
1139
1140 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1141
1142 msg.append("uuid=");
1143 msg.append(uuid);
1144
1145 msg.append(", companyId=");
1146 msg.append(companyId);
1147
1148 msg.append(StringPool.CLOSE_CURLY_BRACE);
1149
1150 throw new NoSuchFolderException(msg.toString());
1151 }
1152
1153
1162 public JournalFolder fetchByUuid_C_Last(String uuid, long companyId,
1163 OrderByComparator orderByComparator) throws SystemException {
1164 int count = countByUuid_C(uuid, companyId);
1165
1166 List<JournalFolder> list = findByUuid_C(uuid, companyId, count - 1,
1167 count, orderByComparator);
1168
1169 if (!list.isEmpty()) {
1170 return list.get(0);
1171 }
1172
1173 return null;
1174 }
1175
1176
1187 public JournalFolder[] findByUuid_C_PrevAndNext(long folderId, String uuid,
1188 long companyId, OrderByComparator orderByComparator)
1189 throws NoSuchFolderException, SystemException {
1190 JournalFolder journalFolder = findByPrimaryKey(folderId);
1191
1192 Session session = null;
1193
1194 try {
1195 session = openSession();
1196
1197 JournalFolder[] array = new JournalFolderImpl[3];
1198
1199 array[0] = getByUuid_C_PrevAndNext(session, journalFolder, uuid,
1200 companyId, orderByComparator, true);
1201
1202 array[1] = journalFolder;
1203
1204 array[2] = getByUuid_C_PrevAndNext(session, journalFolder, uuid,
1205 companyId, orderByComparator, false);
1206
1207 return array;
1208 }
1209 catch (Exception e) {
1210 throw processException(e);
1211 }
1212 finally {
1213 closeSession(session);
1214 }
1215 }
1216
1217 protected JournalFolder getByUuid_C_PrevAndNext(Session session,
1218 JournalFolder journalFolder, String uuid, long companyId,
1219 OrderByComparator orderByComparator, boolean previous) {
1220 StringBundler query = null;
1221
1222 if (orderByComparator != null) {
1223 query = new StringBundler(6 +
1224 (orderByComparator.getOrderByFields().length * 6));
1225 }
1226 else {
1227 query = new StringBundler(3);
1228 }
1229
1230 query.append(_SQL_SELECT_JOURNALFOLDER_WHERE);
1231
1232 boolean bindUuid = false;
1233
1234 if (uuid == null) {
1235 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1236 }
1237 else if (uuid.equals(StringPool.BLANK)) {
1238 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1239 }
1240 else {
1241 bindUuid = true;
1242
1243 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1244 }
1245
1246 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1247
1248 if (orderByComparator != null) {
1249 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1250
1251 if (orderByConditionFields.length > 0) {
1252 query.append(WHERE_AND);
1253 }
1254
1255 for (int i = 0; i < orderByConditionFields.length; i++) {
1256 query.append(_ORDER_BY_ENTITY_ALIAS);
1257 query.append(orderByConditionFields[i]);
1258
1259 if ((i + 1) < orderByConditionFields.length) {
1260 if (orderByComparator.isAscending() ^ previous) {
1261 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1262 }
1263 else {
1264 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1265 }
1266 }
1267 else {
1268 if (orderByComparator.isAscending() ^ previous) {
1269 query.append(WHERE_GREATER_THAN);
1270 }
1271 else {
1272 query.append(WHERE_LESSER_THAN);
1273 }
1274 }
1275 }
1276
1277 query.append(ORDER_BY_CLAUSE);
1278
1279 String[] orderByFields = orderByComparator.getOrderByFields();
1280
1281 for (int i = 0; i < orderByFields.length; i++) {
1282 query.append(_ORDER_BY_ENTITY_ALIAS);
1283 query.append(orderByFields[i]);
1284
1285 if ((i + 1) < orderByFields.length) {
1286 if (orderByComparator.isAscending() ^ previous) {
1287 query.append(ORDER_BY_ASC_HAS_NEXT);
1288 }
1289 else {
1290 query.append(ORDER_BY_DESC_HAS_NEXT);
1291 }
1292 }
1293 else {
1294 if (orderByComparator.isAscending() ^ previous) {
1295 query.append(ORDER_BY_ASC);
1296 }
1297 else {
1298 query.append(ORDER_BY_DESC);
1299 }
1300 }
1301 }
1302 }
1303 else {
1304 query.append(JournalFolderModelImpl.ORDER_BY_JPQL);
1305 }
1306
1307 String sql = query.toString();
1308
1309 Query q = session.createQuery(sql);
1310
1311 q.setFirstResult(0);
1312 q.setMaxResults(2);
1313
1314 QueryPos qPos = QueryPos.getInstance(q);
1315
1316 if (bindUuid) {
1317 qPos.add(uuid);
1318 }
1319
1320 qPos.add(companyId);
1321
1322 if (orderByComparator != null) {
1323 Object[] values = orderByComparator.getOrderByConditionValues(journalFolder);
1324
1325 for (Object value : values) {
1326 qPos.add(value);
1327 }
1328 }
1329
1330 List<JournalFolder> list = q.list();
1331
1332 if (list.size() == 2) {
1333 return list.get(1);
1334 }
1335 else {
1336 return null;
1337 }
1338 }
1339
1340
1347 public void removeByUuid_C(String uuid, long companyId)
1348 throws SystemException {
1349 for (JournalFolder journalFolder : findByUuid_C(uuid, companyId,
1350 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1351 remove(journalFolder);
1352 }
1353 }
1354
1355
1363 public int countByUuid_C(String uuid, long companyId)
1364 throws SystemException {
1365 FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_C;
1366
1367 Object[] finderArgs = new Object[] { uuid, companyId };
1368
1369 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1370 this);
1371
1372 if (count == null) {
1373 StringBundler query = new StringBundler(3);
1374
1375 query.append(_SQL_COUNT_JOURNALFOLDER_WHERE);
1376
1377 boolean bindUuid = false;
1378
1379 if (uuid == null) {
1380 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1381 }
1382 else if (uuid.equals(StringPool.BLANK)) {
1383 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1384 }
1385 else {
1386 bindUuid = true;
1387
1388 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1389 }
1390
1391 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1392
1393 String sql = query.toString();
1394
1395 Session session = null;
1396
1397 try {
1398 session = openSession();
1399
1400 Query q = session.createQuery(sql);
1401
1402 QueryPos qPos = QueryPos.getInstance(q);
1403
1404 if (bindUuid) {
1405 qPos.add(uuid);
1406 }
1407
1408 qPos.add(companyId);
1409
1410 count = (Long)q.uniqueResult();
1411
1412 FinderCacheUtil.putResult(finderPath, finderArgs, count);
1413 }
1414 catch (Exception e) {
1415 FinderCacheUtil.removeResult(finderPath, finderArgs);
1416
1417 throw processException(e);
1418 }
1419 finally {
1420 closeSession(session);
1421 }
1422 }
1423
1424 return count.intValue();
1425 }
1426
1427 private static final String _FINDER_COLUMN_UUID_C_UUID_1 = "journalFolder.uuid IS NULL AND ";
1428 private static final String _FINDER_COLUMN_UUID_C_UUID_2 = "journalFolder.uuid = ? AND ";
1429 private static final String _FINDER_COLUMN_UUID_C_UUID_3 = "(journalFolder.uuid IS NULL OR journalFolder.uuid = '') AND ";
1430 private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 = "journalFolder.companyId = ?";
1431 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(JournalFolderModelImpl.ENTITY_CACHE_ENABLED,
1432 JournalFolderModelImpl.FINDER_CACHE_ENABLED,
1433 JournalFolderImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
1434 "findByGroupId",
1435 new String[] {
1436 Long.class.getName(),
1437
1438 Integer.class.getName(), Integer.class.getName(),
1439 OrderByComparator.class.getName()
1440 });
1441 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID =
1442 new FinderPath(JournalFolderModelImpl.ENTITY_CACHE_ENABLED,
1443 JournalFolderModelImpl.FINDER_CACHE_ENABLED,
1444 JournalFolderImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
1445 "findByGroupId", new String[] { Long.class.getName() },
1446 JournalFolderModelImpl.GROUPID_COLUMN_BITMASK |
1447 JournalFolderModelImpl.PARENTFOLDERID_COLUMN_BITMASK |
1448 JournalFolderModelImpl.NAME_COLUMN_BITMASK);
1449 public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(JournalFolderModelImpl.ENTITY_CACHE_ENABLED,
1450 JournalFolderModelImpl.FINDER_CACHE_ENABLED, Long.class,
1451 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId",
1452 new String[] { Long.class.getName() });
1453
1454
1461 public List<JournalFolder> findByGroupId(long groupId)
1462 throws SystemException {
1463 return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1464 }
1465
1466
1479 public List<JournalFolder> findByGroupId(long groupId, int start, int end)
1480 throws SystemException {
1481 return findByGroupId(groupId, start, end, null);
1482 }
1483
1484
1498 public List<JournalFolder> findByGroupId(long groupId, int start, int end,
1499 OrderByComparator orderByComparator) throws SystemException {
1500 boolean pagination = true;
1501 FinderPath finderPath = null;
1502 Object[] finderArgs = null;
1503
1504 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1505 (orderByComparator == null)) {
1506 pagination = false;
1507 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
1508 finderArgs = new Object[] { groupId };
1509 }
1510 else {
1511 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
1512 finderArgs = new Object[] { groupId, start, end, orderByComparator };
1513 }
1514
1515 List<JournalFolder> list = (List<JournalFolder>)FinderCacheUtil.getResult(finderPath,
1516 finderArgs, this);
1517
1518 if ((list != null) && !list.isEmpty()) {
1519 for (JournalFolder journalFolder : list) {
1520 if ((groupId != journalFolder.getGroupId())) {
1521 list = null;
1522
1523 break;
1524 }
1525 }
1526 }
1527
1528 if (list == null) {
1529 StringBundler query = null;
1530
1531 if (orderByComparator != null) {
1532 query = new StringBundler(3 +
1533 (orderByComparator.getOrderByFields().length * 3));
1534 }
1535 else {
1536 query = new StringBundler(3);
1537 }
1538
1539 query.append(_SQL_SELECT_JOURNALFOLDER_WHERE);
1540
1541 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1542
1543 if (orderByComparator != null) {
1544 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1545 orderByComparator);
1546 }
1547 else
1548 if (pagination) {
1549 query.append(JournalFolderModelImpl.ORDER_BY_JPQL);
1550 }
1551
1552 String sql = query.toString();
1553
1554 Session session = null;
1555
1556 try {
1557 session = openSession();
1558
1559 Query q = session.createQuery(sql);
1560
1561 QueryPos qPos = QueryPos.getInstance(q);
1562
1563 qPos.add(groupId);
1564
1565 if (!pagination) {
1566 list = (List<JournalFolder>)QueryUtil.list(q, getDialect(),
1567 start, end, false);
1568
1569 Collections.sort(list);
1570
1571 list = new UnmodifiableList<JournalFolder>(list);
1572 }
1573 else {
1574 list = (List<JournalFolder>)QueryUtil.list(q, getDialect(),
1575 start, end);
1576 }
1577
1578 cacheResult(list);
1579
1580 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1581 }
1582 catch (Exception e) {
1583 FinderCacheUtil.removeResult(finderPath, finderArgs);
1584
1585 throw processException(e);
1586 }
1587 finally {
1588 closeSession(session);
1589 }
1590 }
1591
1592 return list;
1593 }
1594
1595
1604 public JournalFolder findByGroupId_First(long groupId,
1605 OrderByComparator orderByComparator)
1606 throws NoSuchFolderException, SystemException {
1607 JournalFolder journalFolder = fetchByGroupId_First(groupId,
1608 orderByComparator);
1609
1610 if (journalFolder != null) {
1611 return journalFolder;
1612 }
1613
1614 StringBundler msg = new StringBundler(4);
1615
1616 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1617
1618 msg.append("groupId=");
1619 msg.append(groupId);
1620
1621 msg.append(StringPool.CLOSE_CURLY_BRACE);
1622
1623 throw new NoSuchFolderException(msg.toString());
1624 }
1625
1626
1634 public JournalFolder fetchByGroupId_First(long groupId,
1635 OrderByComparator orderByComparator) throws SystemException {
1636 List<JournalFolder> list = findByGroupId(groupId, 0, 1,
1637 orderByComparator);
1638
1639 if (!list.isEmpty()) {
1640 return list.get(0);
1641 }
1642
1643 return null;
1644 }
1645
1646
1655 public JournalFolder findByGroupId_Last(long groupId,
1656 OrderByComparator orderByComparator)
1657 throws NoSuchFolderException, SystemException {
1658 JournalFolder journalFolder = fetchByGroupId_Last(groupId,
1659 orderByComparator);
1660
1661 if (journalFolder != null) {
1662 return journalFolder;
1663 }
1664
1665 StringBundler msg = new StringBundler(4);
1666
1667 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1668
1669 msg.append("groupId=");
1670 msg.append(groupId);
1671
1672 msg.append(StringPool.CLOSE_CURLY_BRACE);
1673
1674 throw new NoSuchFolderException(msg.toString());
1675 }
1676
1677
1685 public JournalFolder fetchByGroupId_Last(long groupId,
1686 OrderByComparator orderByComparator) throws SystemException {
1687 int count = countByGroupId(groupId);
1688
1689 List<JournalFolder> list = findByGroupId(groupId, count - 1, count,
1690 orderByComparator);
1691
1692 if (!list.isEmpty()) {
1693 return list.get(0);
1694 }
1695
1696 return null;
1697 }
1698
1699
1709 public JournalFolder[] findByGroupId_PrevAndNext(long folderId,
1710 long groupId, OrderByComparator orderByComparator)
1711 throws NoSuchFolderException, SystemException {
1712 JournalFolder journalFolder = findByPrimaryKey(folderId);
1713
1714 Session session = null;
1715
1716 try {
1717 session = openSession();
1718
1719 JournalFolder[] array = new JournalFolderImpl[3];
1720
1721 array[0] = getByGroupId_PrevAndNext(session, journalFolder,
1722 groupId, orderByComparator, true);
1723
1724 array[1] = journalFolder;
1725
1726 array[2] = getByGroupId_PrevAndNext(session, journalFolder,
1727 groupId, orderByComparator, false);
1728
1729 return array;
1730 }
1731 catch (Exception e) {
1732 throw processException(e);
1733 }
1734 finally {
1735 closeSession(session);
1736 }
1737 }
1738
1739 protected JournalFolder getByGroupId_PrevAndNext(Session session,
1740 JournalFolder journalFolder, long groupId,
1741 OrderByComparator orderByComparator, boolean previous) {
1742 StringBundler query = null;
1743
1744 if (orderByComparator != null) {
1745 query = new StringBundler(6 +
1746 (orderByComparator.getOrderByFields().length * 6));
1747 }
1748 else {
1749 query = new StringBundler(3);
1750 }
1751
1752 query.append(_SQL_SELECT_JOURNALFOLDER_WHERE);
1753
1754 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1755
1756 if (orderByComparator != null) {
1757 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1758
1759 if (orderByConditionFields.length > 0) {
1760 query.append(WHERE_AND);
1761 }
1762
1763 for (int i = 0; i < orderByConditionFields.length; i++) {
1764 query.append(_ORDER_BY_ENTITY_ALIAS);
1765 query.append(orderByConditionFields[i]);
1766
1767 if ((i + 1) < orderByConditionFields.length) {
1768 if (orderByComparator.isAscending() ^ previous) {
1769 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1770 }
1771 else {
1772 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1773 }
1774 }
1775 else {
1776 if (orderByComparator.isAscending() ^ previous) {
1777 query.append(WHERE_GREATER_THAN);
1778 }
1779 else {
1780 query.append(WHERE_LESSER_THAN);
1781 }
1782 }
1783 }
1784
1785 query.append(ORDER_BY_CLAUSE);
1786
1787 String[] orderByFields = orderByComparator.getOrderByFields();
1788
1789 for (int i = 0; i < orderByFields.length; i++) {
1790 query.append(_ORDER_BY_ENTITY_ALIAS);
1791 query.append(orderByFields[i]);
1792
1793 if ((i + 1) < orderByFields.length) {
1794 if (orderByComparator.isAscending() ^ previous) {
1795 query.append(ORDER_BY_ASC_HAS_NEXT);
1796 }
1797 else {
1798 query.append(ORDER_BY_DESC_HAS_NEXT);
1799 }
1800 }
1801 else {
1802 if (orderByComparator.isAscending() ^ previous) {
1803 query.append(ORDER_BY_ASC);
1804 }
1805 else {
1806 query.append(ORDER_BY_DESC);
1807 }
1808 }
1809 }
1810 }
1811 else {
1812 query.append(JournalFolderModelImpl.ORDER_BY_JPQL);
1813 }
1814
1815 String sql = query.toString();
1816
1817 Query q = session.createQuery(sql);
1818
1819 q.setFirstResult(0);
1820 q.setMaxResults(2);
1821
1822 QueryPos qPos = QueryPos.getInstance(q);
1823
1824 qPos.add(groupId);
1825
1826 if (orderByComparator != null) {
1827 Object[] values = orderByComparator.getOrderByConditionValues(journalFolder);
1828
1829 for (Object value : values) {
1830 qPos.add(value);
1831 }
1832 }
1833
1834 List<JournalFolder> list = q.list();
1835
1836 if (list.size() == 2) {
1837 return list.get(1);
1838 }
1839 else {
1840 return null;
1841 }
1842 }
1843
1844
1851 public List<JournalFolder> filterFindByGroupId(long groupId)
1852 throws SystemException {
1853 return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
1854 QueryUtil.ALL_POS, null);
1855 }
1856
1857
1870 public List<JournalFolder> filterFindByGroupId(long groupId, int start,
1871 int end) throws SystemException {
1872 return filterFindByGroupId(groupId, start, end, null);
1873 }
1874
1875
1889 public List<JournalFolder> filterFindByGroupId(long groupId, int start,
1890 int end, OrderByComparator orderByComparator) throws SystemException {
1891 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1892 return findByGroupId(groupId, start, end, orderByComparator);
1893 }
1894
1895 StringBundler query = null;
1896
1897 if (orderByComparator != null) {
1898 query = new StringBundler(3 +
1899 (orderByComparator.getOrderByFields().length * 3));
1900 }
1901 else {
1902 query = new StringBundler(3);
1903 }
1904
1905 if (getDB().isSupportsInlineDistinct()) {
1906 query.append(_FILTER_SQL_SELECT_JOURNALFOLDER_WHERE);
1907 }
1908 else {
1909 query.append(_FILTER_SQL_SELECT_JOURNALFOLDER_NO_INLINE_DISTINCT_WHERE_1);
1910 }
1911
1912 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1913
1914 if (!getDB().isSupportsInlineDistinct()) {
1915 query.append(_FILTER_SQL_SELECT_JOURNALFOLDER_NO_INLINE_DISTINCT_WHERE_2);
1916 }
1917
1918 if (orderByComparator != null) {
1919 if (getDB().isSupportsInlineDistinct()) {
1920 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1921 orderByComparator, true);
1922 }
1923 else {
1924 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
1925 orderByComparator, true);
1926 }
1927 }
1928 else {
1929 if (getDB().isSupportsInlineDistinct()) {
1930 query.append(JournalFolderModelImpl.ORDER_BY_JPQL);
1931 }
1932 else {
1933 query.append(JournalFolderModelImpl.ORDER_BY_SQL);
1934 }
1935 }
1936
1937 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1938 JournalFolder.class.getName(),
1939 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
1940
1941 Session session = null;
1942
1943 try {
1944 session = openSession();
1945
1946 SQLQuery q = session.createSQLQuery(sql);
1947
1948 if (getDB().isSupportsInlineDistinct()) {
1949 q.addEntity(_FILTER_ENTITY_ALIAS, JournalFolderImpl.class);
1950 }
1951 else {
1952 q.addEntity(_FILTER_ENTITY_TABLE, JournalFolderImpl.class);
1953 }
1954
1955 QueryPos qPos = QueryPos.getInstance(q);
1956
1957 qPos.add(groupId);
1958
1959 return (List<JournalFolder>)QueryUtil.list(q, getDialect(), start,
1960 end);
1961 }
1962 catch (Exception e) {
1963 throw processException(e);
1964 }
1965 finally {
1966 closeSession(session);
1967 }
1968 }
1969
1970
1980 public JournalFolder[] filterFindByGroupId_PrevAndNext(long folderId,
1981 long groupId, OrderByComparator orderByComparator)
1982 throws NoSuchFolderException, SystemException {
1983 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1984 return findByGroupId_PrevAndNext(folderId, groupId,
1985 orderByComparator);
1986 }
1987
1988 JournalFolder journalFolder = findByPrimaryKey(folderId);
1989
1990 Session session = null;
1991
1992 try {
1993 session = openSession();
1994
1995 JournalFolder[] array = new JournalFolderImpl[3];
1996
1997 array[0] = filterGetByGroupId_PrevAndNext(session, journalFolder,
1998 groupId, orderByComparator, true);
1999
2000 array[1] = journalFolder;
2001
2002 array[2] = filterGetByGroupId_PrevAndNext(session, journalFolder,
2003 groupId, orderByComparator, false);
2004
2005 return array;
2006 }
2007 catch (Exception e) {
2008 throw processException(e);
2009 }
2010 finally {
2011 closeSession(session);
2012 }
2013 }
2014
2015 protected JournalFolder filterGetByGroupId_PrevAndNext(Session session,
2016 JournalFolder journalFolder, long groupId,
2017 OrderByComparator orderByComparator, boolean previous) {
2018 StringBundler query = null;
2019
2020 if (orderByComparator != null) {
2021 query = new StringBundler(6 +
2022 (orderByComparator.getOrderByFields().length * 6));
2023 }
2024 else {
2025 query = new StringBundler(3);
2026 }
2027
2028 if (getDB().isSupportsInlineDistinct()) {
2029 query.append(_FILTER_SQL_SELECT_JOURNALFOLDER_WHERE);
2030 }
2031 else {
2032 query.append(_FILTER_SQL_SELECT_JOURNALFOLDER_NO_INLINE_DISTINCT_WHERE_1);
2033 }
2034
2035 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2036
2037 if (!getDB().isSupportsInlineDistinct()) {
2038 query.append(_FILTER_SQL_SELECT_JOURNALFOLDER_NO_INLINE_DISTINCT_WHERE_2);
2039 }
2040
2041 if (orderByComparator != null) {
2042 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2043
2044 if (orderByConditionFields.length > 0) {
2045 query.append(WHERE_AND);
2046 }
2047
2048 for (int i = 0; i < orderByConditionFields.length; i++) {
2049 if (getDB().isSupportsInlineDistinct()) {
2050 query.append(_ORDER_BY_ENTITY_ALIAS);
2051 }
2052 else {
2053 query.append(_ORDER_BY_ENTITY_TABLE);
2054 }
2055
2056 query.append(orderByConditionFields[i]);
2057
2058 if ((i + 1) < orderByConditionFields.length) {
2059 if (orderByComparator.isAscending() ^ previous) {
2060 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2061 }
2062 else {
2063 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2064 }
2065 }
2066 else {
2067 if (orderByComparator.isAscending() ^ previous) {
2068 query.append(WHERE_GREATER_THAN);
2069 }
2070 else {
2071 query.append(WHERE_LESSER_THAN);
2072 }
2073 }
2074 }
2075
2076 query.append(ORDER_BY_CLAUSE);
2077
2078 String[] orderByFields = orderByComparator.getOrderByFields();
2079
2080 for (int i = 0; i < orderByFields.length; i++) {
2081 if (getDB().isSupportsInlineDistinct()) {
2082 query.append(_ORDER_BY_ENTITY_ALIAS);
2083 }
2084 else {
2085 query.append(_ORDER_BY_ENTITY_TABLE);
2086 }
2087
2088 query.append(orderByFields[i]);
2089
2090 if ((i + 1) < orderByFields.length) {
2091 if (orderByComparator.isAscending() ^ previous) {
2092 query.append(ORDER_BY_ASC_HAS_NEXT);
2093 }
2094 else {
2095 query.append(ORDER_BY_DESC_HAS_NEXT);
2096 }
2097 }
2098 else {
2099 if (orderByComparator.isAscending() ^ previous) {
2100 query.append(ORDER_BY_ASC);
2101 }
2102 else {
2103 query.append(ORDER_BY_DESC);
2104 }
2105 }
2106 }
2107 }
2108 else {
2109 if (getDB().isSupportsInlineDistinct()) {
2110 query.append(JournalFolderModelImpl.ORDER_BY_JPQL);
2111 }
2112 else {
2113 query.append(JournalFolderModelImpl.ORDER_BY_SQL);
2114 }
2115 }
2116
2117 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2118 JournalFolder.class.getName(),
2119 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2120
2121 SQLQuery q = session.createSQLQuery(sql);
2122
2123 q.setFirstResult(0);
2124 q.setMaxResults(2);
2125
2126 if (getDB().isSupportsInlineDistinct()) {
2127 q.addEntity(_FILTER_ENTITY_ALIAS, JournalFolderImpl.class);
2128 }
2129 else {
2130 q.addEntity(_FILTER_ENTITY_TABLE, JournalFolderImpl.class);
2131 }
2132
2133 QueryPos qPos = QueryPos.getInstance(q);
2134
2135 qPos.add(groupId);
2136
2137 if (orderByComparator != null) {
2138 Object[] values = orderByComparator.getOrderByConditionValues(journalFolder);
2139
2140 for (Object value : values) {
2141 qPos.add(value);
2142 }
2143 }
2144
2145 List<JournalFolder> list = q.list();
2146
2147 if (list.size() == 2) {
2148 return list.get(1);
2149 }
2150 else {
2151 return null;
2152 }
2153 }
2154
2155
2161 public void removeByGroupId(long groupId) throws SystemException {
2162 for (JournalFolder journalFolder : findByGroupId(groupId,
2163 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
2164 remove(journalFolder);
2165 }
2166 }
2167
2168
2175 public int countByGroupId(long groupId) throws SystemException {
2176 FinderPath finderPath = FINDER_PATH_COUNT_BY_GROUPID;
2177
2178 Object[] finderArgs = new Object[] { groupId };
2179
2180 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
2181 this);
2182
2183 if (count == null) {
2184 StringBundler query = new StringBundler(2);
2185
2186 query.append(_SQL_COUNT_JOURNALFOLDER_WHERE);
2187
2188 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2189
2190 String sql = query.toString();
2191
2192 Session session = null;
2193
2194 try {
2195 session = openSession();
2196
2197 Query q = session.createQuery(sql);
2198
2199 QueryPos qPos = QueryPos.getInstance(q);
2200
2201 qPos.add(groupId);
2202
2203 count = (Long)q.uniqueResult();
2204
2205 FinderCacheUtil.putResult(finderPath, finderArgs, count);
2206 }
2207 catch (Exception e) {
2208 FinderCacheUtil.removeResult(finderPath, finderArgs);
2209
2210 throw processException(e);
2211 }
2212 finally {
2213 closeSession(session);
2214 }
2215 }
2216
2217 return count.intValue();
2218 }
2219
2220
2227 public int filterCountByGroupId(long groupId) throws SystemException {
2228 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2229 return countByGroupId(groupId);
2230 }
2231
2232 StringBundler query = new StringBundler(2);
2233
2234 query.append(_FILTER_SQL_COUNT_JOURNALFOLDER_WHERE);
2235
2236 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2237
2238 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2239 JournalFolder.class.getName(),
2240 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2241
2242 Session session = null;
2243
2244 try {
2245 session = openSession();
2246
2247 SQLQuery q = session.createSQLQuery(sql);
2248
2249 q.addScalar(COUNT_COLUMN_NAME,
2250 com.liferay.portal.kernel.dao.orm.Type.LONG);
2251
2252 QueryPos qPos = QueryPos.getInstance(q);
2253
2254 qPos.add(groupId);
2255
2256 Long count = (Long)q.uniqueResult();
2257
2258 return count.intValue();
2259 }
2260 catch (Exception e) {
2261 throw processException(e);
2262 }
2263 finally {
2264 closeSession(session);
2265 }
2266 }
2267
2268 private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "journalFolder.groupId = ?";
2269 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID =
2270 new FinderPath(JournalFolderModelImpl.ENTITY_CACHE_ENABLED,
2271 JournalFolderModelImpl.FINDER_CACHE_ENABLED,
2272 JournalFolderImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
2273 "findByCompanyId",
2274 new String[] {
2275 Long.class.getName(),
2276
2277 Integer.class.getName(), Integer.class.getName(),
2278 OrderByComparator.class.getName()
2279 });
2280 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID =
2281 new FinderPath(JournalFolderModelImpl.ENTITY_CACHE_ENABLED,
2282 JournalFolderModelImpl.FINDER_CACHE_ENABLED,
2283 JournalFolderImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
2284 "findByCompanyId", new String[] { Long.class.getName() },
2285 JournalFolderModelImpl.COMPANYID_COLUMN_BITMASK |
2286 JournalFolderModelImpl.PARENTFOLDERID_COLUMN_BITMASK |
2287 JournalFolderModelImpl.NAME_COLUMN_BITMASK);
2288 public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(JournalFolderModelImpl.ENTITY_CACHE_ENABLED,
2289 JournalFolderModelImpl.FINDER_CACHE_ENABLED, Long.class,
2290 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCompanyId",
2291 new String[] { Long.class.getName() });
2292
2293
2300 public List<JournalFolder> findByCompanyId(long companyId)
2301 throws SystemException {
2302 return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
2303 null);
2304 }
2305
2306
2319 public List<JournalFolder> findByCompanyId(long companyId, int start,
2320 int end) throws SystemException {
2321 return findByCompanyId(companyId, start, end, null);
2322 }
2323
2324
2338 public List<JournalFolder> findByCompanyId(long companyId, int start,
2339 int end, OrderByComparator orderByComparator) throws SystemException {
2340 boolean pagination = true;
2341 FinderPath finderPath = null;
2342 Object[] finderArgs = null;
2343
2344 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2345 (orderByComparator == null)) {
2346 pagination = false;
2347 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID;
2348 finderArgs = new Object[] { companyId };
2349 }
2350 else {
2351 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID;
2352 finderArgs = new Object[] { companyId, start, end, orderByComparator };
2353 }
2354
2355 List<JournalFolder> list = (List<JournalFolder>)FinderCacheUtil.getResult(finderPath,
2356 finderArgs, this);
2357
2358 if ((list != null) && !list.isEmpty()) {
2359 for (JournalFolder journalFolder : list) {
2360 if ((companyId != journalFolder.getCompanyId())) {
2361 list = null;
2362
2363 break;
2364 }
2365 }
2366 }
2367
2368 if (list == null) {
2369 StringBundler query = null;
2370
2371 if (orderByComparator != null) {
2372 query = new StringBundler(3 +
2373 (orderByComparator.getOrderByFields().length * 3));
2374 }
2375 else {
2376 query = new StringBundler(3);
2377 }
2378
2379 query.append(_SQL_SELECT_JOURNALFOLDER_WHERE);
2380
2381 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2382
2383 if (orderByComparator != null) {
2384 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2385 orderByComparator);
2386 }
2387 else
2388 if (pagination) {
2389 query.append(JournalFolderModelImpl.ORDER_BY_JPQL);
2390 }
2391
2392 String sql = query.toString();
2393
2394 Session session = null;
2395
2396 try {
2397 session = openSession();
2398
2399 Query q = session.createQuery(sql);
2400
2401 QueryPos qPos = QueryPos.getInstance(q);
2402
2403 qPos.add(companyId);
2404
2405 if (!pagination) {
2406 list = (List<JournalFolder>)QueryUtil.list(q, getDialect(),
2407 start, end, false);
2408
2409 Collections.sort(list);
2410
2411 list = new UnmodifiableList<JournalFolder>(list);
2412 }
2413 else {
2414 list = (List<JournalFolder>)QueryUtil.list(q, getDialect(),
2415 start, end);
2416 }
2417
2418 cacheResult(list);
2419
2420 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2421 }
2422 catch (Exception e) {
2423 FinderCacheUtil.removeResult(finderPath, finderArgs);
2424
2425 throw processException(e);
2426 }
2427 finally {
2428 closeSession(session);
2429 }
2430 }
2431
2432 return list;
2433 }
2434
2435
2444 public JournalFolder findByCompanyId_First(long companyId,
2445 OrderByComparator orderByComparator)
2446 throws NoSuchFolderException, SystemException {
2447 JournalFolder journalFolder = fetchByCompanyId_First(companyId,
2448 orderByComparator);
2449
2450 if (journalFolder != null) {
2451 return journalFolder;
2452 }
2453
2454 StringBundler msg = new StringBundler(4);
2455
2456 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2457
2458 msg.append("companyId=");
2459 msg.append(companyId);
2460
2461 msg.append(StringPool.CLOSE_CURLY_BRACE);
2462
2463 throw new NoSuchFolderException(msg.toString());
2464 }
2465
2466
2474 public JournalFolder fetchByCompanyId_First(long companyId,
2475 OrderByComparator orderByComparator) throws SystemException {
2476 List<JournalFolder> list = findByCompanyId(companyId, 0, 1,
2477 orderByComparator);
2478
2479 if (!list.isEmpty()) {
2480 return list.get(0);
2481 }
2482
2483 return null;
2484 }
2485
2486
2495 public JournalFolder findByCompanyId_Last(long companyId,
2496 OrderByComparator orderByComparator)
2497 throws NoSuchFolderException, SystemException {
2498 JournalFolder journalFolder = fetchByCompanyId_Last(companyId,
2499 orderByComparator);
2500
2501 if (journalFolder != null) {
2502 return journalFolder;
2503 }
2504
2505 StringBundler msg = new StringBundler(4);
2506
2507 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2508
2509 msg.append("companyId=");
2510 msg.append(companyId);
2511
2512 msg.append(StringPool.CLOSE_CURLY_BRACE);
2513
2514 throw new NoSuchFolderException(msg.toString());
2515 }
2516
2517
2525 public JournalFolder fetchByCompanyId_Last(long companyId,
2526 OrderByComparator orderByComparator) throws SystemException {
2527 int count = countByCompanyId(companyId);
2528
2529 List<JournalFolder> list = findByCompanyId(companyId, count - 1, count,
2530 orderByComparator);
2531
2532 if (!list.isEmpty()) {
2533 return list.get(0);
2534 }
2535
2536 return null;
2537 }
2538
2539
2549 public JournalFolder[] findByCompanyId_PrevAndNext(long folderId,
2550 long companyId, OrderByComparator orderByComparator)
2551 throws NoSuchFolderException, SystemException {
2552 JournalFolder journalFolder = findByPrimaryKey(folderId);
2553
2554 Session session = null;
2555
2556 try {
2557 session = openSession();
2558
2559 JournalFolder[] array = new JournalFolderImpl[3];
2560
2561 array[0] = getByCompanyId_PrevAndNext(session, journalFolder,
2562 companyId, orderByComparator, true);
2563
2564 array[1] = journalFolder;
2565
2566 array[2] = getByCompanyId_PrevAndNext(session, journalFolder,
2567 companyId, orderByComparator, false);
2568
2569 return array;
2570 }
2571 catch (Exception e) {
2572 throw processException(e);
2573 }
2574 finally {
2575 closeSession(session);
2576 }
2577 }
2578
2579 protected JournalFolder getByCompanyId_PrevAndNext(Session session,
2580 JournalFolder journalFolder, long companyId,
2581 OrderByComparator orderByComparator, boolean previous) {
2582 StringBundler query = null;
2583
2584 if (orderByComparator != null) {
2585 query = new StringBundler(6 +
2586 (orderByComparator.getOrderByFields().length * 6));
2587 }
2588 else {
2589 query = new StringBundler(3);
2590 }
2591
2592 query.append(_SQL_SELECT_JOURNALFOLDER_WHERE);
2593
2594 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2595
2596 if (orderByComparator != null) {
2597 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2598
2599 if (orderByConditionFields.length > 0) {
2600 query.append(WHERE_AND);
2601 }
2602
2603 for (int i = 0; i < orderByConditionFields.length; i++) {
2604 query.append(_ORDER_BY_ENTITY_ALIAS);
2605 query.append(orderByConditionFields[i]);
2606
2607 if ((i + 1) < orderByConditionFields.length) {
2608 if (orderByComparator.isAscending() ^ previous) {
2609 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2610 }
2611 else {
2612 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2613 }
2614 }
2615 else {
2616 if (orderByComparator.isAscending() ^ previous) {
2617 query.append(WHERE_GREATER_THAN);
2618 }
2619 else {
2620 query.append(WHERE_LESSER_THAN);
2621 }
2622 }
2623 }
2624
2625 query.append(ORDER_BY_CLAUSE);
2626
2627 String[] orderByFields = orderByComparator.getOrderByFields();
2628
2629 for (int i = 0; i < orderByFields.length; i++) {
2630 query.append(_ORDER_BY_ENTITY_ALIAS);
2631 query.append(orderByFields[i]);
2632
2633 if ((i + 1) < orderByFields.length) {
2634 if (orderByComparator.isAscending() ^ previous) {
2635 query.append(ORDER_BY_ASC_HAS_NEXT);
2636 }
2637 else {
2638 query.append(ORDER_BY_DESC_HAS_NEXT);
2639 }
2640 }
2641 else {
2642 if (orderByComparator.isAscending() ^ previous) {
2643 query.append(ORDER_BY_ASC);
2644 }
2645 else {
2646 query.append(ORDER_BY_DESC);
2647 }
2648 }
2649 }
2650 }
2651 else {
2652 query.append(JournalFolderModelImpl.ORDER_BY_JPQL);
2653 }
2654
2655 String sql = query.toString();
2656
2657 Query q = session.createQuery(sql);
2658
2659 q.setFirstResult(0);
2660 q.setMaxResults(2);
2661
2662 QueryPos qPos = QueryPos.getInstance(q);
2663
2664 qPos.add(companyId);
2665
2666 if (orderByComparator != null) {
2667 Object[] values = orderByComparator.getOrderByConditionValues(journalFolder);
2668
2669 for (Object value : values) {
2670 qPos.add(value);
2671 }
2672 }
2673
2674 List<JournalFolder> list = q.list();
2675
2676 if (list.size() == 2) {
2677 return list.get(1);
2678 }
2679 else {
2680 return null;
2681 }
2682 }
2683
2684
2690 public void removeByCompanyId(long companyId) throws SystemException {
2691 for (JournalFolder journalFolder : findByCompanyId(companyId,
2692 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
2693 remove(journalFolder);
2694 }
2695 }
2696
2697
2704 public int countByCompanyId(long companyId) throws SystemException {
2705 FinderPath finderPath = FINDER_PATH_COUNT_BY_COMPANYID;
2706
2707 Object[] finderArgs = new Object[] { companyId };
2708
2709 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
2710 this);
2711
2712 if (count == null) {
2713 StringBundler query = new StringBundler(2);
2714
2715 query.append(_SQL_COUNT_JOURNALFOLDER_WHERE);
2716
2717 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2718
2719 String sql = query.toString();
2720
2721 Session session = null;
2722
2723 try {
2724 session = openSession();
2725
2726 Query q = session.createQuery(sql);
2727
2728 QueryPos qPos = QueryPos.getInstance(q);
2729
2730 qPos.add(companyId);
2731
2732 count = (Long)q.uniqueResult();
2733
2734 FinderCacheUtil.putResult(finderPath, finderArgs, count);
2735 }
2736 catch (Exception e) {
2737 FinderCacheUtil.removeResult(finderPath, finderArgs);
2738
2739 throw processException(e);
2740 }
2741 finally {
2742 closeSession(session);
2743 }
2744 }
2745
2746 return count.intValue();
2747 }
2748
2749 private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "journalFolder.companyId = ?";
2750 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P = new FinderPath(JournalFolderModelImpl.ENTITY_CACHE_ENABLED,
2751 JournalFolderModelImpl.FINDER_CACHE_ENABLED,
2752 JournalFolderImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
2753 "findByG_P",
2754 new String[] {
2755 Long.class.getName(), Long.class.getName(),
2756
2757 Integer.class.getName(), Integer.class.getName(),
2758 OrderByComparator.class.getName()
2759 });
2760 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P = new FinderPath(JournalFolderModelImpl.ENTITY_CACHE_ENABLED,
2761 JournalFolderModelImpl.FINDER_CACHE_ENABLED,
2762 JournalFolderImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
2763 "findByG_P",
2764 new String[] { Long.class.getName(), Long.class.getName() },
2765 JournalFolderModelImpl.GROUPID_COLUMN_BITMASK |
2766 JournalFolderModelImpl.PARENTFOLDERID_COLUMN_BITMASK |
2767 JournalFolderModelImpl.NAME_COLUMN_BITMASK);
2768 public static final FinderPath FINDER_PATH_COUNT_BY_G_P = new FinderPath(JournalFolderModelImpl.ENTITY_CACHE_ENABLED,
2769 JournalFolderModelImpl.FINDER_CACHE_ENABLED, Long.class,
2770 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_P",
2771 new String[] { Long.class.getName(), Long.class.getName() });
2772
2773
2781 public List<JournalFolder> findByG_P(long groupId, long parentFolderId)
2782 throws SystemException {
2783 return findByG_P(groupId, parentFolderId, QueryUtil.ALL_POS,
2784 QueryUtil.ALL_POS, null);
2785 }
2786
2787
2801 public List<JournalFolder> findByG_P(long groupId, long parentFolderId,
2802 int start, int end) throws SystemException {
2803 return findByG_P(groupId, parentFolderId, start, end, null);
2804 }
2805
2806
2821 public List<JournalFolder> findByG_P(long groupId, long parentFolderId,
2822 int start, int end, OrderByComparator orderByComparator)
2823 throws SystemException {
2824 boolean pagination = true;
2825 FinderPath finderPath = null;
2826 Object[] finderArgs = null;
2827
2828 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2829 (orderByComparator == null)) {
2830 pagination = false;
2831 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P;
2832 finderArgs = new Object[] { groupId, parentFolderId };
2833 }
2834 else {
2835 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P;
2836 finderArgs = new Object[] {
2837 groupId, parentFolderId,
2838
2839 start, end, orderByComparator
2840 };
2841 }
2842
2843 List<JournalFolder> list = (List<JournalFolder>)FinderCacheUtil.getResult(finderPath,
2844 finderArgs, this);
2845
2846 if ((list != null) && !list.isEmpty()) {
2847 for (JournalFolder journalFolder : list) {
2848 if ((groupId != journalFolder.getGroupId()) ||
2849 (parentFolderId != journalFolder.getParentFolderId())) {
2850 list = null;
2851
2852 break;
2853 }
2854 }
2855 }
2856
2857 if (list == null) {
2858 StringBundler query = null;
2859
2860 if (orderByComparator != null) {
2861 query = new StringBundler(4 +
2862 (orderByComparator.getOrderByFields().length * 3));
2863 }
2864 else {
2865 query = new StringBundler(4);
2866 }
2867
2868 query.append(_SQL_SELECT_JOURNALFOLDER_WHERE);
2869
2870 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
2871
2872 query.append(_FINDER_COLUMN_G_P_PARENTFOLDERID_2);
2873
2874 if (orderByComparator != null) {
2875 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2876 orderByComparator);
2877 }
2878 else
2879 if (pagination) {
2880 query.append(JournalFolderModelImpl.ORDER_BY_JPQL);
2881 }
2882
2883 String sql = query.toString();
2884
2885 Session session = null;
2886
2887 try {
2888 session = openSession();
2889
2890 Query q = session.createQuery(sql);
2891
2892 QueryPos qPos = QueryPos.getInstance(q);
2893
2894 qPos.add(groupId);
2895
2896 qPos.add(parentFolderId);
2897
2898 if (!pagination) {
2899 list = (List<JournalFolder>)QueryUtil.list(q, getDialect(),
2900 start, end, false);
2901
2902 Collections.sort(list);
2903
2904 list = new UnmodifiableList<JournalFolder>(list);
2905 }
2906 else {
2907 list = (List<JournalFolder>)QueryUtil.list(q, getDialect(),
2908 start, end);
2909 }
2910
2911 cacheResult(list);
2912
2913 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2914 }
2915 catch (Exception e) {
2916 FinderCacheUtil.removeResult(finderPath, finderArgs);
2917
2918 throw processException(e);
2919 }
2920 finally {
2921 closeSession(session);
2922 }
2923 }
2924
2925 return list;
2926 }
2927
2928
2938 public JournalFolder findByG_P_First(long groupId, long parentFolderId,
2939 OrderByComparator orderByComparator)
2940 throws NoSuchFolderException, SystemException {
2941 JournalFolder journalFolder = fetchByG_P_First(groupId, parentFolderId,
2942 orderByComparator);
2943
2944 if (journalFolder != null) {
2945 return journalFolder;
2946 }
2947
2948 StringBundler msg = new StringBundler(6);
2949
2950 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2951
2952 msg.append("groupId=");
2953 msg.append(groupId);
2954
2955 msg.append(", parentFolderId=");
2956 msg.append(parentFolderId);
2957
2958 msg.append(StringPool.CLOSE_CURLY_BRACE);
2959
2960 throw new NoSuchFolderException(msg.toString());
2961 }
2962
2963
2972 public JournalFolder fetchByG_P_First(long groupId, long parentFolderId,
2973 OrderByComparator orderByComparator) throws SystemException {
2974 List<JournalFolder> list = findByG_P(groupId, parentFolderId, 0, 1,
2975 orderByComparator);
2976
2977 if (!list.isEmpty()) {
2978 return list.get(0);
2979 }
2980
2981 return null;
2982 }
2983
2984
2994 public JournalFolder findByG_P_Last(long groupId, long parentFolderId,
2995 OrderByComparator orderByComparator)
2996 throws NoSuchFolderException, SystemException {
2997 JournalFolder journalFolder = fetchByG_P_Last(groupId, parentFolderId,
2998 orderByComparator);
2999
3000 if (journalFolder != null) {
3001 return journalFolder;
3002 }
3003
3004 StringBundler msg = new StringBundler(6);
3005
3006 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3007
3008 msg.append("groupId=");
3009 msg.append(groupId);
3010
3011 msg.append(", parentFolderId=");
3012 msg.append(parentFolderId);
3013
3014 msg.append(StringPool.CLOSE_CURLY_BRACE);
3015
3016 throw new NoSuchFolderException(msg.toString());
3017 }
3018
3019
3028 public JournalFolder fetchByG_P_Last(long groupId, long parentFolderId,
3029 OrderByComparator orderByComparator) throws SystemException {
3030 int count = countByG_P(groupId, parentFolderId);
3031
3032 List<JournalFolder> list = findByG_P(groupId, parentFolderId,
3033 count - 1, count, orderByComparator);
3034
3035 if (!list.isEmpty()) {
3036 return list.get(0);
3037 }
3038
3039 return null;
3040 }
3041
3042
3053 public JournalFolder[] findByG_P_PrevAndNext(long folderId, long groupId,
3054 long parentFolderId, OrderByComparator orderByComparator)
3055 throws NoSuchFolderException, SystemException {
3056 JournalFolder journalFolder = findByPrimaryKey(folderId);
3057
3058 Session session = null;
3059
3060 try {
3061 session = openSession();
3062
3063 JournalFolder[] array = new JournalFolderImpl[3];
3064
3065 array[0] = getByG_P_PrevAndNext(session, journalFolder, groupId,
3066 parentFolderId, orderByComparator, true);
3067
3068 array[1] = journalFolder;
3069
3070 array[2] = getByG_P_PrevAndNext(session, journalFolder, groupId,
3071 parentFolderId, orderByComparator, false);
3072
3073 return array;
3074 }
3075 catch (Exception e) {
3076 throw processException(e);
3077 }
3078 finally {
3079 closeSession(session);
3080 }
3081 }
3082
3083 protected JournalFolder getByG_P_PrevAndNext(Session session,
3084 JournalFolder journalFolder, long groupId, long parentFolderId,
3085 OrderByComparator orderByComparator, boolean previous) {
3086 StringBundler query = null;
3087
3088 if (orderByComparator != null) {
3089 query = new StringBundler(6 +
3090 (orderByComparator.getOrderByFields().length * 6));
3091 }
3092 else {
3093 query = new StringBundler(3);
3094 }
3095
3096 query.append(_SQL_SELECT_JOURNALFOLDER_WHERE);
3097
3098 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
3099
3100 query.append(_FINDER_COLUMN_G_P_PARENTFOLDERID_2);
3101
3102 if (orderByComparator != null) {
3103 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3104
3105 if (orderByConditionFields.length > 0) {
3106 query.append(WHERE_AND);
3107 }
3108
3109 for (int i = 0; i < orderByConditionFields.length; i++) {
3110 query.append(_ORDER_BY_ENTITY_ALIAS);
3111 query.append(orderByConditionFields[i]);
3112
3113 if ((i + 1) < orderByConditionFields.length) {
3114 if (orderByComparator.isAscending() ^ previous) {
3115 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3116 }
3117 else {
3118 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3119 }
3120 }
3121 else {
3122 if (orderByComparator.isAscending() ^ previous) {
3123 query.append(WHERE_GREATER_THAN);
3124 }
3125 else {
3126 query.append(WHERE_LESSER_THAN);
3127 }
3128 }
3129 }
3130
3131 query.append(ORDER_BY_CLAUSE);
3132
3133 String[] orderByFields = orderByComparator.getOrderByFields();
3134
3135 for (int i = 0; i < orderByFields.length; i++) {
3136 query.append(_ORDER_BY_ENTITY_ALIAS);
3137 query.append(orderByFields[i]);
3138
3139 if ((i + 1) < orderByFields.length) {
3140 if (orderByComparator.isAscending() ^ previous) {
3141 query.append(ORDER_BY_ASC_HAS_NEXT);
3142 }
3143 else {
3144 query.append(ORDER_BY_DESC_HAS_NEXT);
3145 }
3146 }
3147 else {
3148 if (orderByComparator.isAscending() ^ previous) {
3149 query.append(ORDER_BY_ASC);
3150 }
3151 else {
3152 query.append(ORDER_BY_DESC);
3153 }
3154 }
3155 }
3156 }
3157 else {
3158 query.append(JournalFolderModelImpl.ORDER_BY_JPQL);
3159 }
3160
3161 String sql = query.toString();
3162
3163 Query q = session.createQuery(sql);
3164
3165 q.setFirstResult(0);
3166 q.setMaxResults(2);
3167
3168 QueryPos qPos = QueryPos.getInstance(q);
3169
3170 qPos.add(groupId);
3171
3172 qPos.add(parentFolderId);
3173
3174 if (orderByComparator != null) {
3175 Object[] values = orderByComparator.getOrderByConditionValues(journalFolder);
3176
3177 for (Object value : values) {
3178 qPos.add(value);
3179 }
3180 }
3181
3182 List<JournalFolder> list = q.list();
3183
3184 if (list.size() == 2) {
3185 return list.get(1);
3186 }
3187 else {
3188 return null;
3189 }
3190 }
3191
3192
3200 public List<JournalFolder> filterFindByG_P(long groupId, long parentFolderId)
3201 throws SystemException {
3202 return filterFindByG_P(groupId, parentFolderId, QueryUtil.ALL_POS,
3203 QueryUtil.ALL_POS, null);
3204 }
3205
3206
3220 public List<JournalFolder> filterFindByG_P(long groupId,
3221 long parentFolderId, int start, int end) throws SystemException {
3222 return filterFindByG_P(groupId, parentFolderId, start, end, null);
3223 }
3224
3225
3240 public List<JournalFolder> filterFindByG_P(long groupId,
3241 long parentFolderId, int start, int end,
3242 OrderByComparator orderByComparator) throws SystemException {
3243 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3244 return findByG_P(groupId, parentFolderId, start, end,
3245 orderByComparator);
3246 }
3247
3248 StringBundler query = null;
3249
3250 if (orderByComparator != null) {
3251 query = new StringBundler(4 +
3252 (orderByComparator.getOrderByFields().length * 3));
3253 }
3254 else {
3255 query = new StringBundler(4);
3256 }
3257
3258 if (getDB().isSupportsInlineDistinct()) {
3259 query.append(_FILTER_SQL_SELECT_JOURNALFOLDER_WHERE);
3260 }
3261 else {
3262 query.append(_FILTER_SQL_SELECT_JOURNALFOLDER_NO_INLINE_DISTINCT_WHERE_1);
3263 }
3264
3265 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
3266
3267 query.append(_FINDER_COLUMN_G_P_PARENTFOLDERID_2);
3268
3269 if (!getDB().isSupportsInlineDistinct()) {
3270 query.append(_FILTER_SQL_SELECT_JOURNALFOLDER_NO_INLINE_DISTINCT_WHERE_2);
3271 }
3272
3273 if (orderByComparator != null) {
3274 if (getDB().isSupportsInlineDistinct()) {
3275 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3276 orderByComparator, true);
3277 }
3278 else {
3279 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
3280 orderByComparator, true);
3281 }
3282 }
3283 else {
3284 if (getDB().isSupportsInlineDistinct()) {
3285 query.append(JournalFolderModelImpl.ORDER_BY_JPQL);
3286 }
3287 else {
3288 query.append(JournalFolderModelImpl.ORDER_BY_SQL);
3289 }
3290 }
3291
3292 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3293 JournalFolder.class.getName(),
3294 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3295
3296 Session session = null;
3297
3298 try {
3299 session = openSession();
3300
3301 SQLQuery q = session.createSQLQuery(sql);
3302
3303 if (getDB().isSupportsInlineDistinct()) {
3304 q.addEntity(_FILTER_ENTITY_ALIAS, JournalFolderImpl.class);
3305 }
3306 else {
3307 q.addEntity(_FILTER_ENTITY_TABLE, JournalFolderImpl.class);
3308 }
3309
3310 QueryPos qPos = QueryPos.getInstance(q);
3311
3312 qPos.add(groupId);
3313
3314 qPos.add(parentFolderId);
3315
3316 return (List<JournalFolder>)QueryUtil.list(q, getDialect(), start,
3317 end);
3318 }
3319 catch (Exception e) {
3320 throw processException(e);
3321 }
3322 finally {
3323 closeSession(session);
3324 }
3325 }
3326
3327
3338 public JournalFolder[] filterFindByG_P_PrevAndNext(long folderId,
3339 long groupId, long parentFolderId, OrderByComparator orderByComparator)
3340 throws NoSuchFolderException, SystemException {
3341 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3342 return findByG_P_PrevAndNext(folderId, groupId, parentFolderId,
3343 orderByComparator);
3344 }
3345
3346 JournalFolder journalFolder = findByPrimaryKey(folderId);
3347
3348 Session session = null;
3349
3350 try {
3351 session = openSession();
3352
3353 JournalFolder[] array = new JournalFolderImpl[3];
3354
3355 array[0] = filterGetByG_P_PrevAndNext(session, journalFolder,
3356 groupId, parentFolderId, orderByComparator, true);
3357
3358 array[1] = journalFolder;
3359
3360 array[2] = filterGetByG_P_PrevAndNext(session, journalFolder,
3361 groupId, parentFolderId, orderByComparator, false);
3362
3363 return array;
3364 }
3365 catch (Exception e) {
3366 throw processException(e);
3367 }
3368 finally {
3369 closeSession(session);
3370 }
3371 }
3372
3373 protected JournalFolder filterGetByG_P_PrevAndNext(Session session,
3374 JournalFolder journalFolder, long groupId, long parentFolderId,
3375 OrderByComparator orderByComparator, boolean previous) {
3376 StringBundler query = null;
3377
3378 if (orderByComparator != null) {
3379 query = new StringBundler(6 +
3380 (orderByComparator.getOrderByFields().length * 6));
3381 }
3382 else {
3383 query = new StringBundler(3);
3384 }
3385
3386 if (getDB().isSupportsInlineDistinct()) {
3387 query.append(_FILTER_SQL_SELECT_JOURNALFOLDER_WHERE);
3388 }
3389 else {
3390 query.append(_FILTER_SQL_SELECT_JOURNALFOLDER_NO_INLINE_DISTINCT_WHERE_1);
3391 }
3392
3393 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
3394
3395 query.append(_FINDER_COLUMN_G_P_PARENTFOLDERID_2);
3396
3397 if (!getDB().isSupportsInlineDistinct()) {
3398 query.append(_FILTER_SQL_SELECT_JOURNALFOLDER_NO_INLINE_DISTINCT_WHERE_2);
3399 }
3400
3401 if (orderByComparator != null) {
3402 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3403
3404 if (orderByConditionFields.length > 0) {
3405 query.append(WHERE_AND);
3406 }
3407
3408 for (int i = 0; i < orderByConditionFields.length; i++) {
3409 if (getDB().isSupportsInlineDistinct()) {
3410 query.append(_ORDER_BY_ENTITY_ALIAS);
3411 }
3412 else {
3413 query.append(_ORDER_BY_ENTITY_TABLE);
3414 }
3415
3416 query.append(orderByConditionFields[i]);
3417
3418 if ((i + 1) < orderByConditionFields.length) {
3419 if (orderByComparator.isAscending() ^ previous) {
3420 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3421 }
3422 else {
3423 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3424 }
3425 }
3426 else {
3427 if (orderByComparator.isAscending() ^ previous) {
3428 query.append(WHERE_GREATER_THAN);
3429 }
3430 else {
3431 query.append(WHERE_LESSER_THAN);
3432 }
3433 }
3434 }
3435
3436 query.append(ORDER_BY_CLAUSE);
3437
3438 String[] orderByFields = orderByComparator.getOrderByFields();
3439
3440 for (int i = 0; i < orderByFields.length; i++) {
3441 if (getDB().isSupportsInlineDistinct()) {
3442 query.append(_ORDER_BY_ENTITY_ALIAS);
3443 }
3444 else {
3445 query.append(_ORDER_BY_ENTITY_TABLE);
3446 }
3447
3448 query.append(orderByFields[i]);
3449
3450 if ((i + 1) < orderByFields.length) {
3451 if (orderByComparator.isAscending() ^ previous) {
3452 query.append(ORDER_BY_ASC_HAS_NEXT);
3453 }
3454 else {
3455 query.append(ORDER_BY_DESC_HAS_NEXT);
3456 }
3457 }
3458 else {
3459 if (orderByComparator.isAscending() ^ previous) {
3460 query.append(ORDER_BY_ASC);
3461 }
3462 else {
3463 query.append(ORDER_BY_DESC);
3464 }
3465 }
3466 }
3467 }
3468 else {
3469 if (getDB().isSupportsInlineDistinct()) {
3470 query.append(JournalFolderModelImpl.ORDER_BY_JPQL);
3471 }
3472 else {
3473 query.append(JournalFolderModelImpl.ORDER_BY_SQL);
3474 }
3475 }
3476
3477 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3478 JournalFolder.class.getName(),
3479 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3480
3481 SQLQuery q = session.createSQLQuery(sql);
3482
3483 q.setFirstResult(0);
3484 q.setMaxResults(2);
3485
3486 if (getDB().isSupportsInlineDistinct()) {
3487 q.addEntity(_FILTER_ENTITY_ALIAS, JournalFolderImpl.class);
3488 }
3489 else {
3490 q.addEntity(_FILTER_ENTITY_TABLE, JournalFolderImpl.class);
3491 }
3492
3493 QueryPos qPos = QueryPos.getInstance(q);
3494
3495 qPos.add(groupId);
3496
3497 qPos.add(parentFolderId);
3498
3499 if (orderByComparator != null) {
3500 Object[] values = orderByComparator.getOrderByConditionValues(journalFolder);
3501
3502 for (Object value : values) {
3503 qPos.add(value);
3504 }
3505 }
3506
3507 List<JournalFolder> list = q.list();
3508
3509 if (list.size() == 2) {
3510 return list.get(1);
3511 }
3512 else {
3513 return null;
3514 }
3515 }
3516
3517
3524 public void removeByG_P(long groupId, long parentFolderId)
3525 throws SystemException {
3526 for (JournalFolder journalFolder : findByG_P(groupId, parentFolderId,
3527 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
3528 remove(journalFolder);
3529 }
3530 }
3531
3532
3540 public int countByG_P(long groupId, long parentFolderId)
3541 throws SystemException {
3542 FinderPath finderPath = FINDER_PATH_COUNT_BY_G_P;
3543
3544 Object[] finderArgs = new Object[] { groupId, parentFolderId };
3545
3546 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
3547 this);
3548
3549 if (count == null) {
3550 StringBundler query = new StringBundler(3);
3551
3552 query.append(_SQL_COUNT_JOURNALFOLDER_WHERE);
3553
3554 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
3555
3556 query.append(_FINDER_COLUMN_G_P_PARENTFOLDERID_2);
3557
3558 String sql = query.toString();
3559
3560 Session session = null;
3561
3562 try {
3563 session = openSession();
3564
3565 Query q = session.createQuery(sql);
3566
3567 QueryPos qPos = QueryPos.getInstance(q);
3568
3569 qPos.add(groupId);
3570
3571 qPos.add(parentFolderId);
3572
3573 count = (Long)q.uniqueResult();
3574
3575 FinderCacheUtil.putResult(finderPath, finderArgs, count);
3576 }
3577 catch (Exception e) {
3578 FinderCacheUtil.removeResult(finderPath, finderArgs);
3579
3580 throw processException(e);
3581 }
3582 finally {
3583 closeSession(session);
3584 }
3585 }
3586
3587 return count.intValue();
3588 }
3589
3590
3598 public int filterCountByG_P(long groupId, long parentFolderId)
3599 throws SystemException {
3600 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3601 return countByG_P(groupId, parentFolderId);
3602 }
3603
3604 StringBundler query = new StringBundler(3);
3605
3606 query.append(_FILTER_SQL_COUNT_JOURNALFOLDER_WHERE);
3607
3608 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
3609
3610 query.append(_FINDER_COLUMN_G_P_PARENTFOLDERID_2);
3611
3612 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3613 JournalFolder.class.getName(),
3614 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3615
3616 Session session = null;
3617
3618 try {
3619 session = openSession();
3620
3621 SQLQuery q = session.createSQLQuery(sql);
3622
3623 q.addScalar(COUNT_COLUMN_NAME,
3624 com.liferay.portal.kernel.dao.orm.Type.LONG);
3625
3626 QueryPos qPos = QueryPos.getInstance(q);
3627
3628 qPos.add(groupId);
3629
3630 qPos.add(parentFolderId);
3631
3632 Long count = (Long)q.uniqueResult();
3633
3634 return count.intValue();
3635 }
3636 catch (Exception e) {
3637 throw processException(e);
3638 }
3639 finally {
3640 closeSession(session);
3641 }
3642 }
3643
3644 private static final String _FINDER_COLUMN_G_P_GROUPID_2 = "journalFolder.groupId = ? AND ";
3645 private static final String _FINDER_COLUMN_G_P_PARENTFOLDERID_2 = "journalFolder.parentFolderId = ?";
3646 public static final FinderPath FINDER_PATH_FETCH_BY_G_N = new FinderPath(JournalFolderModelImpl.ENTITY_CACHE_ENABLED,
3647 JournalFolderModelImpl.FINDER_CACHE_ENABLED,
3648 JournalFolderImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByG_N",
3649 new String[] { Long.class.getName(), String.class.getName() },
3650 JournalFolderModelImpl.GROUPID_COLUMN_BITMASK |
3651 JournalFolderModelImpl.NAME_COLUMN_BITMASK);
3652 public static final FinderPath FINDER_PATH_COUNT_BY_G_N = new FinderPath(JournalFolderModelImpl.ENTITY_CACHE_ENABLED,
3653 JournalFolderModelImpl.FINDER_CACHE_ENABLED, Long.class,
3654 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_N",
3655 new String[] { Long.class.getName(), String.class.getName() });
3656
3657
3666 public JournalFolder findByG_N(long groupId, String name)
3667 throws NoSuchFolderException, SystemException {
3668 JournalFolder journalFolder = fetchByG_N(groupId, name);
3669
3670 if (journalFolder == null) {
3671 StringBundler msg = new StringBundler(6);
3672
3673 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3674
3675 msg.append("groupId=");
3676 msg.append(groupId);
3677
3678 msg.append(", name=");
3679 msg.append(name);
3680
3681 msg.append(StringPool.CLOSE_CURLY_BRACE);
3682
3683 if (_log.isWarnEnabled()) {
3684 _log.warn(msg.toString());
3685 }
3686
3687 throw new NoSuchFolderException(msg.toString());
3688 }
3689
3690 return journalFolder;
3691 }
3692
3693
3701 public JournalFolder fetchByG_N(long groupId, String name)
3702 throws SystemException {
3703 return fetchByG_N(groupId, name, true);
3704 }
3705
3706
3715 public JournalFolder fetchByG_N(long groupId, String name,
3716 boolean retrieveFromCache) throws SystemException {
3717 Object[] finderArgs = new Object[] { groupId, name };
3718
3719 Object result = null;
3720
3721 if (retrieveFromCache) {
3722 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_N,
3723 finderArgs, this);
3724 }
3725
3726 if (result instanceof JournalFolder) {
3727 JournalFolder journalFolder = (JournalFolder)result;
3728
3729 if ((groupId != journalFolder.getGroupId()) ||
3730 !Validator.equals(name, journalFolder.getName())) {
3731 result = null;
3732 }
3733 }
3734
3735 if (result == null) {
3736 StringBundler query = new StringBundler(4);
3737
3738 query.append(_SQL_SELECT_JOURNALFOLDER_WHERE);
3739
3740 query.append(_FINDER_COLUMN_G_N_GROUPID_2);
3741
3742 boolean bindName = false;
3743
3744 if (name == null) {
3745 query.append(_FINDER_COLUMN_G_N_NAME_1);
3746 }
3747 else if (name.equals(StringPool.BLANK)) {
3748 query.append(_FINDER_COLUMN_G_N_NAME_3);
3749 }
3750 else {
3751 bindName = true;
3752
3753 query.append(_FINDER_COLUMN_G_N_NAME_2);
3754 }
3755
3756 String sql = query.toString();
3757
3758 Session session = null;
3759
3760 try {
3761 session = openSession();
3762
3763 Query q = session.createQuery(sql);
3764
3765 QueryPos qPos = QueryPos.getInstance(q);
3766
3767 qPos.add(groupId);
3768
3769 if (bindName) {
3770 qPos.add(name);
3771 }
3772
3773 List<JournalFolder> list = q.list();
3774
3775 if (list.isEmpty()) {
3776 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
3777 finderArgs, list);
3778 }
3779 else {
3780 if ((list.size() > 1) && _log.isWarnEnabled()) {
3781 _log.warn(
3782 "JournalFolderPersistenceImpl.fetchByG_N(long, String, boolean) with parameters (" +
3783 StringUtil.merge(finderArgs) +
3784 ") yields a result set with more than 1 result. This violates the logical unique restriction. There is no order guarantee on which result is returned by this finder.");
3785 }
3786
3787 JournalFolder journalFolder = list.get(0);
3788
3789 result = journalFolder;
3790
3791 cacheResult(journalFolder);
3792
3793 if ((journalFolder.getGroupId() != groupId) ||
3794 (journalFolder.getName() == null) ||
3795 !journalFolder.getName().equals(name)) {
3796 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
3797 finderArgs, journalFolder);
3798 }
3799 }
3800 }
3801 catch (Exception e) {
3802 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_N,
3803 finderArgs);
3804
3805 throw processException(e);
3806 }
3807 finally {
3808 closeSession(session);
3809 }
3810 }
3811
3812 if (result instanceof List<?>) {
3813 return null;
3814 }
3815 else {
3816 return (JournalFolder)result;
3817 }
3818 }
3819
3820
3828 public JournalFolder removeByG_N(long groupId, String name)
3829 throws NoSuchFolderException, SystemException {
3830 JournalFolder journalFolder = findByG_N(groupId, name);
3831
3832 return remove(journalFolder);
3833 }
3834
3835
3843 public int countByG_N(long groupId, String name) throws SystemException {
3844 FinderPath finderPath = FINDER_PATH_COUNT_BY_G_N;
3845
3846 Object[] finderArgs = new Object[] { groupId, name };
3847
3848 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
3849 this);
3850
3851 if (count == null) {
3852 StringBundler query = new StringBundler(3);
3853
3854 query.append(_SQL_COUNT_JOURNALFOLDER_WHERE);
3855
3856 query.append(_FINDER_COLUMN_G_N_GROUPID_2);
3857
3858 boolean bindName = false;
3859
3860 if (name == null) {
3861 query.append(_FINDER_COLUMN_G_N_NAME_1);
3862 }
3863 else if (name.equals(StringPool.BLANK)) {
3864 query.append(_FINDER_COLUMN_G_N_NAME_3);
3865 }
3866 else {
3867 bindName = true;
3868
3869 query.append(_FINDER_COLUMN_G_N_NAME_2);
3870 }
3871
3872 String sql = query.toString();
3873
3874 Session session = null;
3875
3876 try {
3877 session = openSession();
3878
3879 Query q = session.createQuery(sql);
3880
3881 QueryPos qPos = QueryPos.getInstance(q);
3882
3883 qPos.add(groupId);
3884
3885 if (bindName) {
3886 qPos.add(name);
3887 }
3888
3889 count = (Long)q.uniqueResult();
3890
3891 FinderCacheUtil.putResult(finderPath, finderArgs, count);
3892 }
3893 catch (Exception e) {
3894 FinderCacheUtil.removeResult(finderPath, finderArgs);
3895
3896 throw processException(e);
3897 }
3898 finally {
3899 closeSession(session);
3900 }
3901 }
3902
3903 return count.intValue();
3904 }
3905
3906 private static final String _FINDER_COLUMN_G_N_GROUPID_2 = "journalFolder.groupId = ? AND ";
3907 private static final String _FINDER_COLUMN_G_N_NAME_1 = "journalFolder.name IS NULL";
3908 private static final String _FINDER_COLUMN_G_N_NAME_2 = "journalFolder.name = ?";
3909 private static final String _FINDER_COLUMN_G_N_NAME_3 = "(journalFolder.name IS NULL OR journalFolder.name = '')";
3910 public static final FinderPath FINDER_PATH_FETCH_BY_G_P_N = new FinderPath(JournalFolderModelImpl.ENTITY_CACHE_ENABLED,
3911 JournalFolderModelImpl.FINDER_CACHE_ENABLED,
3912 JournalFolderImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByG_P_N",
3913 new String[] {
3914 Long.class.getName(), Long.class.getName(),
3915 String.class.getName()
3916 },
3917 JournalFolderModelImpl.GROUPID_COLUMN_BITMASK |
3918 JournalFolderModelImpl.PARENTFOLDERID_COLUMN_BITMASK |
3919 JournalFolderModelImpl.NAME_COLUMN_BITMASK);
3920 public static final FinderPath FINDER_PATH_COUNT_BY_G_P_N = new FinderPath(JournalFolderModelImpl.ENTITY_CACHE_ENABLED,
3921 JournalFolderModelImpl.FINDER_CACHE_ENABLED, Long.class,
3922 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_P_N",
3923 new String[] {
3924 Long.class.getName(), Long.class.getName(),
3925 String.class.getName()
3926 });
3927
3928
3938 public JournalFolder findByG_P_N(long groupId, long parentFolderId,
3939 String name) throws NoSuchFolderException, SystemException {
3940 JournalFolder journalFolder = fetchByG_P_N(groupId, parentFolderId, name);
3941
3942 if (journalFolder == null) {
3943 StringBundler msg = new StringBundler(8);
3944
3945 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3946
3947 msg.append("groupId=");
3948 msg.append(groupId);
3949
3950 msg.append(", parentFolderId=");
3951 msg.append(parentFolderId);
3952
3953 msg.append(", name=");
3954 msg.append(name);
3955
3956 msg.append(StringPool.CLOSE_CURLY_BRACE);
3957
3958 if (_log.isWarnEnabled()) {
3959 _log.warn(msg.toString());
3960 }
3961
3962 throw new NoSuchFolderException(msg.toString());
3963 }
3964
3965 return journalFolder;
3966 }
3967
3968
3977 public JournalFolder fetchByG_P_N(long groupId, long parentFolderId,
3978 String name) throws SystemException {
3979 return fetchByG_P_N(groupId, parentFolderId, name, true);
3980 }
3981
3982
3992 public JournalFolder fetchByG_P_N(long groupId, long parentFolderId,
3993 String name, boolean retrieveFromCache) throws SystemException {
3994 Object[] finderArgs = new Object[] { groupId, parentFolderId, name };
3995
3996 Object result = null;
3997
3998 if (retrieveFromCache) {
3999 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_P_N,
4000 finderArgs, this);
4001 }
4002
4003 if (result instanceof JournalFolder) {
4004 JournalFolder journalFolder = (JournalFolder)result;
4005
4006 if ((groupId != journalFolder.getGroupId()) ||
4007 (parentFolderId != journalFolder.getParentFolderId()) ||
4008 !Validator.equals(name, journalFolder.getName())) {
4009 result = null;
4010 }
4011 }
4012
4013 if (result == null) {
4014 StringBundler query = new StringBundler(5);
4015
4016 query.append(_SQL_SELECT_JOURNALFOLDER_WHERE);
4017
4018 query.append(_FINDER_COLUMN_G_P_N_GROUPID_2);
4019
4020 query.append(_FINDER_COLUMN_G_P_N_PARENTFOLDERID_2);
4021
4022 boolean bindName = false;
4023
4024 if (name == null) {
4025 query.append(_FINDER_COLUMN_G_P_N_NAME_1);
4026 }
4027 else if (name.equals(StringPool.BLANK)) {
4028 query.append(_FINDER_COLUMN_G_P_N_NAME_3);
4029 }
4030 else {
4031 bindName = true;
4032
4033 query.append(_FINDER_COLUMN_G_P_N_NAME_2);
4034 }
4035
4036 String sql = query.toString();
4037
4038 Session session = null;
4039
4040 try {
4041 session = openSession();
4042
4043 Query q = session.createQuery(sql);
4044
4045 QueryPos qPos = QueryPos.getInstance(q);
4046
4047 qPos.add(groupId);
4048
4049 qPos.add(parentFolderId);
4050
4051 if (bindName) {
4052 qPos.add(name);
4053 }
4054
4055 List<JournalFolder> list = q.list();
4056
4057 if (list.isEmpty()) {
4058 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P_N,
4059 finderArgs, list);
4060 }
4061 else {
4062 JournalFolder journalFolder = list.get(0);
4063
4064 result = journalFolder;
4065
4066 cacheResult(journalFolder);
4067
4068 if ((journalFolder.getGroupId() != groupId) ||
4069 (journalFolder.getParentFolderId() != parentFolderId) ||
4070 (journalFolder.getName() == null) ||
4071 !journalFolder.getName().equals(name)) {
4072 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P_N,
4073 finderArgs, journalFolder);
4074 }
4075 }
4076 }
4077 catch (Exception e) {
4078 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_P_N,
4079 finderArgs);
4080
4081 throw processException(e);
4082 }
4083 finally {
4084 closeSession(session);
4085 }
4086 }
4087
4088 if (result instanceof List<?>) {
4089 return null;
4090 }
4091 else {
4092 return (JournalFolder)result;
4093 }
4094 }
4095
4096
4105 public JournalFolder removeByG_P_N(long groupId, long parentFolderId,
4106 String name) throws NoSuchFolderException, SystemException {
4107 JournalFolder journalFolder = findByG_P_N(groupId, parentFolderId, name);
4108
4109 return remove(journalFolder);
4110 }
4111
4112
4121 public int countByG_P_N(long groupId, long parentFolderId, String name)
4122 throws SystemException {
4123 FinderPath finderPath = FINDER_PATH_COUNT_BY_G_P_N;
4124
4125 Object[] finderArgs = new Object[] { groupId, parentFolderId, name };
4126
4127 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
4128 this);
4129
4130 if (count == null) {
4131 StringBundler query = new StringBundler(4);
4132
4133 query.append(_SQL_COUNT_JOURNALFOLDER_WHERE);
4134
4135 query.append(_FINDER_COLUMN_G_P_N_GROUPID_2);
4136
4137 query.append(_FINDER_COLUMN_G_P_N_PARENTFOLDERID_2);
4138
4139 boolean bindName = false;
4140
4141 if (name == null) {
4142 query.append(_FINDER_COLUMN_G_P_N_NAME_1);
4143 }
4144 else if (name.equals(StringPool.BLANK)) {
4145 query.append(_FINDER_COLUMN_G_P_N_NAME_3);
4146 }
4147 else {
4148 bindName = true;
4149
4150 query.append(_FINDER_COLUMN_G_P_N_NAME_2);
4151 }
4152
4153 String sql = query.toString();
4154
4155 Session session = null;
4156
4157 try {
4158 session = openSession();
4159
4160 Query q = session.createQuery(sql);
4161
4162 QueryPos qPos = QueryPos.getInstance(q);
4163
4164 qPos.add(groupId);
4165
4166 qPos.add(parentFolderId);
4167
4168 if (bindName) {
4169 qPos.add(name);
4170 }
4171
4172 count = (Long)q.uniqueResult();
4173
4174 FinderCacheUtil.putResult(finderPath, finderArgs, count);
4175 }
4176 catch (Exception e) {
4177 FinderCacheUtil.removeResult(finderPath, finderArgs);
4178
4179 throw processException(e);
4180 }
4181 finally {
4182 closeSession(session);
4183 }
4184 }
4185
4186 return count.intValue();
4187 }
4188
4189 private static final String _FINDER_COLUMN_G_P_N_GROUPID_2 = "journalFolder.groupId = ? AND ";
4190 private static final String _FINDER_COLUMN_G_P_N_PARENTFOLDERID_2 = "journalFolder.parentFolderId = ? AND ";
4191 private static final String _FINDER_COLUMN_G_P_N_NAME_1 = "journalFolder.name IS NULL";
4192 private static final String _FINDER_COLUMN_G_P_N_NAME_2 = "journalFolder.name = ?";
4193 private static final String _FINDER_COLUMN_G_P_N_NAME_3 = "(journalFolder.name IS NULL OR journalFolder.name = '')";
4194 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P_S = new FinderPath(JournalFolderModelImpl.ENTITY_CACHE_ENABLED,
4195 JournalFolderModelImpl.FINDER_CACHE_ENABLED,
4196 JournalFolderImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
4197 "findByG_P_S",
4198 new String[] {
4199 Long.class.getName(), Long.class.getName(),
4200 Integer.class.getName(),
4201
4202 Integer.class.getName(), Integer.class.getName(),
4203 OrderByComparator.class.getName()
4204 });
4205 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_S = new FinderPath(JournalFolderModelImpl.ENTITY_CACHE_ENABLED,
4206 JournalFolderModelImpl.FINDER_CACHE_ENABLED,
4207 JournalFolderImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
4208 "findByG_P_S",
4209 new String[] {
4210 Long.class.getName(), Long.class.getName(),
4211 Integer.class.getName()
4212 },
4213 JournalFolderModelImpl.GROUPID_COLUMN_BITMASK |
4214 JournalFolderModelImpl.PARENTFOLDERID_COLUMN_BITMASK |
4215 JournalFolderModelImpl.STATUS_COLUMN_BITMASK |
4216 JournalFolderModelImpl.NAME_COLUMN_BITMASK);
4217 public static final FinderPath FINDER_PATH_COUNT_BY_G_P_S = new FinderPath(JournalFolderModelImpl.ENTITY_CACHE_ENABLED,
4218 JournalFolderModelImpl.FINDER_CACHE_ENABLED, Long.class,
4219 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_P_S",
4220 new String[] {
4221 Long.class.getName(), Long.class.getName(),
4222 Integer.class.getName()
4223 });
4224
4225
4234 public List<JournalFolder> findByG_P_S(long groupId, long parentFolderId,
4235 int status) throws SystemException {
4236 return findByG_P_S(groupId, parentFolderId, status, QueryUtil.ALL_POS,
4237 QueryUtil.ALL_POS, null);
4238 }
4239
4240
4255 public List<JournalFolder> findByG_P_S(long groupId, long parentFolderId,
4256 int status, int start, int end) throws SystemException {
4257 return findByG_P_S(groupId, parentFolderId, status, start, end, null);
4258 }
4259
4260
4276 public List<JournalFolder> findByG_P_S(long groupId, long parentFolderId,
4277 int status, int start, int end, OrderByComparator orderByComparator)
4278 throws SystemException {
4279 boolean pagination = true;
4280 FinderPath finderPath = null;
4281 Object[] finderArgs = null;
4282
4283 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4284 (orderByComparator == null)) {
4285 pagination = false;
4286 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_S;
4287 finderArgs = new Object[] { groupId, parentFolderId, status };
4288 }
4289 else {
4290 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P_S;
4291 finderArgs = new Object[] {
4292 groupId, parentFolderId, status,
4293
4294 start, end, orderByComparator
4295 };
4296 }
4297
4298 List<JournalFolder> list = (List<JournalFolder>)FinderCacheUtil.getResult(finderPath,
4299 finderArgs, this);
4300
4301 if ((list != null) && !list.isEmpty()) {
4302 for (JournalFolder journalFolder : list) {
4303 if ((groupId != journalFolder.getGroupId()) ||
4304 (parentFolderId != journalFolder.getParentFolderId()) ||
4305 (status != journalFolder.getStatus())) {
4306 list = null;
4307
4308 break;
4309 }
4310 }
4311 }
4312
4313 if (list == null) {
4314 StringBundler query = null;
4315
4316 if (orderByComparator != null) {
4317 query = new StringBundler(5 +
4318 (orderByComparator.getOrderByFields().length * 3));
4319 }
4320 else {
4321 query = new StringBundler(5);
4322 }
4323
4324 query.append(_SQL_SELECT_JOURNALFOLDER_WHERE);
4325
4326 query.append(_FINDER_COLUMN_G_P_S_GROUPID_2);
4327
4328 query.append(_FINDER_COLUMN_G_P_S_PARENTFOLDERID_2);
4329
4330 query.append(_FINDER_COLUMN_G_P_S_STATUS_2);
4331
4332 if (orderByComparator != null) {
4333 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4334 orderByComparator);
4335 }
4336 else
4337 if (pagination) {
4338 query.append(JournalFolderModelImpl.ORDER_BY_JPQL);
4339 }
4340
4341 String sql = query.toString();
4342
4343 Session session = null;
4344
4345 try {
4346 session = openSession();
4347
4348 Query q = session.createQuery(sql);
4349
4350 QueryPos qPos = QueryPos.getInstance(q);
4351
4352 qPos.add(groupId);
4353
4354 qPos.add(parentFolderId);
4355
4356 qPos.add(status);
4357
4358 if (!pagination) {
4359 list = (List<JournalFolder>)QueryUtil.list(q, getDialect(),
4360 start, end, false);
4361
4362 Collections.sort(list);
4363
4364 list = new UnmodifiableList<JournalFolder>(list);
4365 }
4366 else {
4367 list = (List<JournalFolder>)QueryUtil.list(q, getDialect(),
4368 start, end);
4369 }
4370
4371 cacheResult(list);
4372
4373 FinderCacheUtil.putResult(finderPath, finderArgs, list);
4374 }
4375 catch (Exception e) {
4376 FinderCacheUtil.removeResult(finderPath, finderArgs);
4377
4378 throw processException(e);
4379 }
4380 finally {
4381 closeSession(session);
4382 }
4383 }
4384
4385 return list;
4386 }
4387
4388
4399 public JournalFolder findByG_P_S_First(long groupId, long parentFolderId,
4400 int status, OrderByComparator orderByComparator)
4401 throws NoSuchFolderException, SystemException {
4402 JournalFolder journalFolder = fetchByG_P_S_First(groupId,
4403 parentFolderId, status, orderByComparator);
4404
4405 if (journalFolder != null) {
4406 return journalFolder;
4407 }
4408
4409 StringBundler msg = new StringBundler(8);
4410
4411 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4412
4413 msg.append("groupId=");
4414 msg.append(groupId);
4415
4416 msg.append(", parentFolderId=");
4417 msg.append(parentFolderId);
4418
4419 msg.append(", status=");
4420 msg.append(status);
4421
4422 msg.append(StringPool.CLOSE_CURLY_BRACE);
4423
4424 throw new NoSuchFolderException(msg.toString());
4425 }
4426
4427
4437 public JournalFolder fetchByG_P_S_First(long groupId, long parentFolderId,
4438 int status, OrderByComparator orderByComparator)
4439 throws SystemException {
4440 List<JournalFolder> list = findByG_P_S(groupId, parentFolderId, status,
4441 0, 1, orderByComparator);
4442
4443 if (!list.isEmpty()) {
4444 return list.get(0);
4445 }
4446
4447 return null;
4448 }
4449
4450
4461 public JournalFolder findByG_P_S_Last(long groupId, long parentFolderId,
4462 int status, OrderByComparator orderByComparator)
4463 throws NoSuchFolderException, SystemException {
4464 JournalFolder journalFolder = fetchByG_P_S_Last(groupId,
4465 parentFolderId, status, orderByComparator);
4466
4467 if (journalFolder != null) {
4468 return journalFolder;
4469 }
4470
4471 StringBundler msg = new StringBundler(8);
4472
4473 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4474
4475 msg.append("groupId=");
4476 msg.append(groupId);
4477
4478 msg.append(", parentFolderId=");
4479 msg.append(parentFolderId);
4480
4481 msg.append(", status=");
4482 msg.append(status);
4483
4484 msg.append(StringPool.CLOSE_CURLY_BRACE);
4485
4486 throw new NoSuchFolderException(msg.toString());
4487 }
4488
4489
4499 public JournalFolder fetchByG_P_S_Last(long groupId, long parentFolderId,
4500 int status, OrderByComparator orderByComparator)
4501 throws SystemException {
4502 int count = countByG_P_S(groupId, parentFolderId, status);
4503
4504 List<JournalFolder> list = findByG_P_S(groupId, parentFolderId, status,
4505 count - 1, count, orderByComparator);
4506
4507 if (!list.isEmpty()) {
4508 return list.get(0);
4509 }
4510
4511 return null;
4512 }
4513
4514
4526 public JournalFolder[] findByG_P_S_PrevAndNext(long folderId, long groupId,
4527 long parentFolderId, int status, OrderByComparator orderByComparator)
4528 throws NoSuchFolderException, SystemException {
4529 JournalFolder journalFolder = findByPrimaryKey(folderId);
4530
4531 Session session = null;
4532
4533 try {
4534 session = openSession();
4535
4536 JournalFolder[] array = new JournalFolderImpl[3];
4537
4538 array[0] = getByG_P_S_PrevAndNext(session, journalFolder, groupId,
4539 parentFolderId, status, orderByComparator, true);
4540
4541 array[1] = journalFolder;
4542
4543 array[2] = getByG_P_S_PrevAndNext(session, journalFolder, groupId,
4544 parentFolderId, status, orderByComparator, false);
4545
4546 return array;
4547 }
4548 catch (Exception e) {
4549 throw processException(e);
4550 }
4551 finally {
4552 closeSession(session);
4553 }
4554 }
4555
4556 protected JournalFolder getByG_P_S_PrevAndNext(Session session,
4557 JournalFolder journalFolder, long groupId, long parentFolderId,
4558 int status, OrderByComparator orderByComparator, boolean previous) {
4559 StringBundler query = null;
4560
4561 if (orderByComparator != null) {
4562 query = new StringBundler(6 +
4563 (orderByComparator.getOrderByFields().length * 6));
4564 }
4565 else {
4566 query = new StringBundler(3);
4567 }
4568
4569 query.append(_SQL_SELECT_JOURNALFOLDER_WHERE);
4570
4571 query.append(_FINDER_COLUMN_G_P_S_GROUPID_2);
4572
4573 query.append(_FINDER_COLUMN_G_P_S_PARENTFOLDERID_2);
4574
4575 query.append(_FINDER_COLUMN_G_P_S_STATUS_2);
4576
4577 if (orderByComparator != null) {
4578 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4579
4580 if (orderByConditionFields.length > 0) {
4581 query.append(WHERE_AND);
4582 }
4583
4584 for (int i = 0; i < orderByConditionFields.length; i++) {
4585 query.append(_ORDER_BY_ENTITY_ALIAS);
4586 query.append(orderByConditionFields[i]);
4587
4588 if ((i + 1) < orderByConditionFields.length) {
4589 if (orderByComparator.isAscending() ^ previous) {
4590 query.append(WHERE_GREATER_THAN_HAS_NEXT);
4591 }
4592 else {
4593 query.append(WHERE_LESSER_THAN_HAS_NEXT);
4594 }
4595 }
4596 else {
4597 if (orderByComparator.isAscending() ^ previous) {
4598 query.append(WHERE_GREATER_THAN);
4599 }
4600 else {
4601 query.append(WHERE_LESSER_THAN);
4602 }
4603 }
4604 }
4605
4606 query.append(ORDER_BY_CLAUSE);
4607
4608 String[] orderByFields = orderByComparator.getOrderByFields();
4609
4610 for (int i = 0; i < orderByFields.length; i++) {
4611 query.append(_ORDER_BY_ENTITY_ALIAS);
4612 query.append(orderByFields[i]);
4613
4614 if ((i + 1) < orderByFields.length) {
4615 if (orderByComparator.isAscending() ^ previous) {
4616 query.append(ORDER_BY_ASC_HAS_NEXT);
4617 }
4618 else {
4619 query.append(ORDER_BY_DESC_HAS_NEXT);
4620 }
4621 }
4622 else {
4623 if (orderByComparator.isAscending() ^ previous) {
4624 query.append(ORDER_BY_ASC);
4625 }
4626 else {
4627 query.append(ORDER_BY_DESC);
4628 }
4629 }
4630 }
4631 }
4632 else {
4633 query.append(JournalFolderModelImpl.ORDER_BY_JPQL);
4634 }
4635
4636 String sql = query.toString();
4637
4638 Query q = session.createQuery(sql);
4639
4640 q.setFirstResult(0);
4641 q.setMaxResults(2);
4642
4643 QueryPos qPos = QueryPos.getInstance(q);
4644
4645 qPos.add(groupId);
4646
4647 qPos.add(parentFolderId);
4648
4649 qPos.add(status);
4650
4651 if (orderByComparator != null) {
4652 Object[] values = orderByComparator.getOrderByConditionValues(journalFolder);
4653
4654 for (Object value : values) {
4655 qPos.add(value);
4656 }
4657 }
4658
4659 List<JournalFolder> list = q.list();
4660
4661 if (list.size() == 2) {
4662 return list.get(1);
4663 }
4664 else {
4665 return null;
4666 }
4667 }
4668
4669
4678 public List<JournalFolder> filterFindByG_P_S(long groupId,
4679 long parentFolderId, int status) throws SystemException {
4680 return filterFindByG_P_S(groupId, parentFolderId, status,
4681 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
4682 }
4683
4684
4699 public List<JournalFolder> filterFindByG_P_S(long groupId,
4700 long parentFolderId, int status, int start, int end)
4701 throws SystemException {
4702 return filterFindByG_P_S(groupId, parentFolderId, status, start, end,
4703 null);
4704 }
4705
4706
4722 public List<JournalFolder> filterFindByG_P_S(long groupId,
4723 long parentFolderId, int status, int start, int end,
4724 OrderByComparator orderByComparator) throws SystemException {
4725 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4726 return findByG_P_S(groupId, parentFolderId, status, start, end,
4727 orderByComparator);
4728 }
4729
4730 StringBundler query = null;
4731
4732 if (orderByComparator != null) {
4733 query = new StringBundler(5 +
4734 (orderByComparator.getOrderByFields().length * 3));
4735 }
4736 else {
4737 query = new StringBundler(5);
4738 }
4739
4740 if (getDB().isSupportsInlineDistinct()) {
4741 query.append(_FILTER_SQL_SELECT_JOURNALFOLDER_WHERE);
4742 }
4743 else {
4744 query.append(_FILTER_SQL_SELECT_JOURNALFOLDER_NO_INLINE_DISTINCT_WHERE_1);
4745 }
4746
4747 query.append(_FINDER_COLUMN_G_P_S_GROUPID_2);
4748
4749 query.append(_FINDER_COLUMN_G_P_S_PARENTFOLDERID_2);
4750
4751 query.append(_FINDER_COLUMN_G_P_S_STATUS_2);
4752
4753 if (!getDB().isSupportsInlineDistinct()) {
4754 query.append(_FILTER_SQL_SELECT_JOURNALFOLDER_NO_INLINE_DISTINCT_WHERE_2);
4755 }
4756
4757 if (orderByComparator != null) {
4758 if (getDB().isSupportsInlineDistinct()) {
4759 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4760 orderByComparator, true);
4761 }
4762 else {
4763 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
4764 orderByComparator, true);
4765 }
4766 }
4767 else {
4768 if (getDB().isSupportsInlineDistinct()) {
4769 query.append(JournalFolderModelImpl.ORDER_BY_JPQL);
4770 }
4771 else {
4772 query.append(JournalFolderModelImpl.ORDER_BY_SQL);
4773 }
4774 }
4775
4776 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4777 JournalFolder.class.getName(),
4778 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4779
4780 Session session = null;
4781
4782 try {
4783 session = openSession();
4784
4785 SQLQuery q = session.createSQLQuery(sql);
4786
4787 if (getDB().isSupportsInlineDistinct()) {
4788 q.addEntity(_FILTER_ENTITY_ALIAS, JournalFolderImpl.class);
4789 }
4790 else {
4791 q.addEntity(_FILTER_ENTITY_TABLE, JournalFolderImpl.class);
4792 }
4793
4794 QueryPos qPos = QueryPos.getInstance(q);
4795
4796 qPos.add(groupId);
4797
4798 qPos.add(parentFolderId);
4799
4800 qPos.add(status);
4801
4802 return (List<JournalFolder>)QueryUtil.list(q, getDialect(), start,
4803 end);
4804 }
4805 catch (Exception e) {
4806 throw processException(e);
4807 }
4808 finally {
4809 closeSession(session);
4810 }
4811 }
4812
4813
4825 public JournalFolder[] filterFindByG_P_S_PrevAndNext(long folderId,
4826 long groupId, long parentFolderId, int status,
4827 OrderByComparator orderByComparator)
4828 throws NoSuchFolderException, SystemException {
4829 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4830 return findByG_P_S_PrevAndNext(folderId, groupId, parentFolderId,
4831 status, orderByComparator);
4832 }
4833
4834 JournalFolder journalFolder = findByPrimaryKey(folderId);
4835
4836 Session session = null;
4837
4838 try {
4839 session = openSession();
4840
4841 JournalFolder[] array = new JournalFolderImpl[3];
4842
4843 array[0] = filterGetByG_P_S_PrevAndNext(session, journalFolder,
4844 groupId, parentFolderId, status, orderByComparator, true);
4845
4846 array[1] = journalFolder;
4847
4848 array[2] = filterGetByG_P_S_PrevAndNext(session, journalFolder,
4849 groupId, parentFolderId, status, orderByComparator, false);
4850
4851 return array;
4852 }
4853 catch (Exception e) {
4854 throw processException(e);
4855 }
4856 finally {
4857 closeSession(session);
4858 }
4859 }
4860
4861 protected JournalFolder filterGetByG_P_S_PrevAndNext(Session session,
4862 JournalFolder journalFolder, long groupId, long parentFolderId,
4863 int status, OrderByComparator orderByComparator, boolean previous) {
4864 StringBundler query = null;
4865
4866 if (orderByComparator != null) {
4867 query = new StringBundler(6 +
4868 (orderByComparator.getOrderByFields().length * 6));
4869 }
4870 else {
4871 query = new StringBundler(3);
4872 }
4873
4874 if (getDB().isSupportsInlineDistinct()) {
4875 query.append(_FILTER_SQL_SELECT_JOURNALFOLDER_WHERE);
4876 }
4877 else {
4878 query.append(_FILTER_SQL_SELECT_JOURNALFOLDER_NO_INLINE_DISTINCT_WHERE_1);
4879 }
4880
4881 query.append(_FINDER_COLUMN_G_P_S_GROUPID_2);
4882
4883 query.append(_FINDER_COLUMN_G_P_S_PARENTFOLDERID_2);
4884
4885 query.append(_FINDER_COLUMN_G_P_S_STATUS_2);
4886
4887 if (!getDB().isSupportsInlineDistinct()) {
4888 query.append(_FILTER_SQL_SELECT_JOURNALFOLDER_NO_INLINE_DISTINCT_WHERE_2);
4889 }
4890
4891 if (orderByComparator != null) {
4892 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4893
4894 if (orderByConditionFields.length > 0) {
4895 query.append(WHERE_AND);
4896 }
4897
4898 for (int i = 0; i < orderByConditionFields.length; i++) {
4899 if (getDB().isSupportsInlineDistinct()) {
4900 query.append(_ORDER_BY_ENTITY_ALIAS);
4901 }
4902 else {
4903 query.append(_ORDER_BY_ENTITY_TABLE);
4904 }
4905
4906 query.append(orderByConditionFields[i]);
4907
4908 if ((i + 1) < orderByConditionFields.length) {
4909 if (orderByComparator.isAscending() ^ previous) {
4910 query.append(WHERE_GREATER_THAN_HAS_NEXT);
4911 }
4912 else {
4913 query.append(WHERE_LESSER_THAN_HAS_NEXT);
4914 }
4915 }
4916 else {
4917 if (orderByComparator.isAscending() ^ previous) {
4918 query.append(WHERE_GREATER_THAN);
4919 }
4920 else {
4921 query.append(WHERE_LESSER_THAN);
4922 }
4923 }
4924 }
4925
4926 query.append(ORDER_BY_CLAUSE);
4927
4928 String[] orderByFields = orderByComparator.getOrderByFields();
4929
4930 for (int i = 0; i < orderByFields.length; i++) {
4931 if (getDB().isSupportsInlineDistinct()) {
4932 query.append(_ORDER_BY_ENTITY_ALIAS);
4933 }
4934 else {
4935 query.append(_ORDER_BY_ENTITY_TABLE);
4936 }
4937
4938 query.append(orderByFields[i]);
4939
4940 if ((i + 1) < orderByFields.length) {
4941 if (orderByComparator.isAscending() ^ previous) {
4942 query.append(ORDER_BY_ASC_HAS_NEXT);
4943 }
4944 else {
4945 query.append(ORDER_BY_DESC_HAS_NEXT);
4946 }
4947 }
4948 else {
4949 if (orderByComparator.isAscending() ^ previous) {
4950 query.append(ORDER_BY_ASC);
4951 }
4952 else {
4953 query.append(ORDER_BY_DESC);
4954 }
4955 }
4956 }
4957 }
4958 else {
4959 if (getDB().isSupportsInlineDistinct()) {
4960 query.append(JournalFolderModelImpl.ORDER_BY_JPQL);
4961 }
4962 else {
4963 query.append(JournalFolderModelImpl.ORDER_BY_SQL);
4964 }
4965 }
4966
4967 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4968 JournalFolder.class.getName(),
4969 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4970
4971 SQLQuery q = session.createSQLQuery(sql);
4972
4973 q.setFirstResult(0);
4974 q.setMaxResults(2);
4975
4976 if (getDB().isSupportsInlineDistinct()) {
4977 q.addEntity(_FILTER_ENTITY_ALIAS, JournalFolderImpl.class);
4978 }
4979 else {
4980 q.addEntity(_FILTER_ENTITY_TABLE, JournalFolderImpl.class);
4981 }
4982
4983 QueryPos qPos = QueryPos.getInstance(q);
4984
4985 qPos.add(groupId);
4986
4987 qPos.add(parentFolderId);
4988
4989 qPos.add(status);
4990
4991 if (orderByComparator != null) {
4992 Object[] values = orderByComparator.getOrderByConditionValues(journalFolder);
4993
4994 for (Object value : values) {
4995 qPos.add(value);
4996 }
4997 }
4998
4999 List<JournalFolder> list = q.list();
5000
5001 if (list.size() == 2) {
5002 return list.get(1);
5003 }
5004 else {
5005 return null;
5006 }
5007 }
5008
5009
5017 public void removeByG_P_S(long groupId, long parentFolderId, int status)
5018 throws SystemException {
5019 for (JournalFolder journalFolder : findByG_P_S(groupId, parentFolderId,
5020 status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
5021 remove(journalFolder);
5022 }
5023 }
5024
5025
5034 public int countByG_P_S(long groupId, long parentFolderId, int status)
5035 throws SystemException {
5036 FinderPath finderPath = FINDER_PATH_COUNT_BY_G_P_S;
5037
5038 Object[] finderArgs = new Object[] { groupId, parentFolderId, status };
5039
5040 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
5041 this);
5042
5043 if (count == null) {
5044 StringBundler query = new StringBundler(4);
5045
5046 query.append(_SQL_COUNT_JOURNALFOLDER_WHERE);
5047
5048 query.append(_FINDER_COLUMN_G_P_S_GROUPID_2);
5049
5050 query.append(_FINDER_COLUMN_G_P_S_PARENTFOLDERID_2);
5051
5052 query.append(_FINDER_COLUMN_G_P_S_STATUS_2);
5053
5054 String sql = query.toString();
5055
5056 Session session = null;
5057
5058 try {
5059 session = openSession();
5060
5061 Query q = session.createQuery(sql);
5062
5063 QueryPos qPos = QueryPos.getInstance(q);
5064
5065 qPos.add(groupId);
5066
5067 qPos.add(parentFolderId);
5068
5069 qPos.add(status);
5070
5071 count = (Long)q.uniqueResult();
5072
5073 FinderCacheUtil.putResult(finderPath, finderArgs, count);
5074 }
5075 catch (Exception e) {
5076 FinderCacheUtil.removeResult(finderPath, finderArgs);
5077
5078 throw processException(e);
5079 }
5080 finally {
5081 closeSession(session);
5082 }
5083 }
5084
5085 return count.intValue();
5086 }
5087
5088
5097 public int filterCountByG_P_S(long groupId, long parentFolderId, int status)
5098 throws SystemException {
5099 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5100 return countByG_P_S(groupId, parentFolderId, status);
5101 }
5102
5103 StringBundler query = new StringBundler(4);
5104
5105 query.append(_FILTER_SQL_COUNT_JOURNALFOLDER_WHERE);
5106
5107 query.append(_FINDER_COLUMN_G_P_S_GROUPID_2);
5108
5109 query.append(_FINDER_COLUMN_G_P_S_PARENTFOLDERID_2);
5110
5111 query.append(_FINDER_COLUMN_G_P_S_STATUS_2);
5112
5113 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5114 JournalFolder.class.getName(),
5115 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
5116
5117 Session session = null;
5118
5119 try {
5120 session = openSession();
5121
5122 SQLQuery q = session.createSQLQuery(sql);
5123
5124 q.addScalar(COUNT_COLUMN_NAME,
5125 com.liferay.portal.kernel.dao.orm.Type.LONG);
5126
5127 QueryPos qPos = QueryPos.getInstance(q);
5128
5129 qPos.add(groupId);
5130
5131 qPos.add(parentFolderId);
5132
5133 qPos.add(status);
5134
5135 Long count = (Long)q.uniqueResult();
5136
5137 return count.intValue();
5138 }
5139 catch (Exception e) {
5140 throw processException(e);
5141 }
5142 finally {
5143 closeSession(session);
5144 }
5145 }
5146
5147 private static final String _FINDER_COLUMN_G_P_S_GROUPID_2 = "journalFolder.groupId = ? AND ";
5148 private static final String _FINDER_COLUMN_G_P_S_PARENTFOLDERID_2 = "journalFolder.parentFolderId = ? AND ";
5149 private static final String _FINDER_COLUMN_G_P_S_STATUS_2 = "journalFolder.status = ?";
5150
5151
5156 public void cacheResult(JournalFolder journalFolder) {
5157 EntityCacheUtil.putResult(JournalFolderModelImpl.ENTITY_CACHE_ENABLED,
5158 JournalFolderImpl.class, journalFolder.getPrimaryKey(),
5159 journalFolder);
5160
5161 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
5162 new Object[] { journalFolder.getUuid(), journalFolder.getGroupId() },
5163 journalFolder);
5164
5165 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
5166 new Object[] { journalFolder.getGroupId(), journalFolder.getName() },
5167 journalFolder);
5168
5169 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P_N,
5170 new Object[] {
5171 journalFolder.getGroupId(), journalFolder.getParentFolderId(),
5172 journalFolder.getName()
5173 }, journalFolder);
5174
5175 journalFolder.resetOriginalValues();
5176 }
5177
5178
5183 public void cacheResult(List<JournalFolder> journalFolders) {
5184 for (JournalFolder journalFolder : journalFolders) {
5185 if (EntityCacheUtil.getResult(
5186 JournalFolderModelImpl.ENTITY_CACHE_ENABLED,
5187 JournalFolderImpl.class, journalFolder.getPrimaryKey()) == null) {
5188 cacheResult(journalFolder);
5189 }
5190 else {
5191 journalFolder.resetOriginalValues();
5192 }
5193 }
5194 }
5195
5196
5203 @Override
5204 public void clearCache() {
5205 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
5206 CacheRegistryUtil.clear(JournalFolderImpl.class.getName());
5207 }
5208
5209 EntityCacheUtil.clearCache(JournalFolderImpl.class.getName());
5210
5211 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
5212 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
5213 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
5214 }
5215
5216
5223 @Override
5224 public void clearCache(JournalFolder journalFolder) {
5225 EntityCacheUtil.removeResult(JournalFolderModelImpl.ENTITY_CACHE_ENABLED,
5226 JournalFolderImpl.class, journalFolder.getPrimaryKey());
5227
5228 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
5229 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
5230
5231 clearUniqueFindersCache(journalFolder);
5232 }
5233
5234 @Override
5235 public void clearCache(List<JournalFolder> journalFolders) {
5236 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
5237 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
5238
5239 for (JournalFolder journalFolder : journalFolders) {
5240 EntityCacheUtil.removeResult(JournalFolderModelImpl.ENTITY_CACHE_ENABLED,
5241 JournalFolderImpl.class, journalFolder.getPrimaryKey());
5242
5243 clearUniqueFindersCache(journalFolder);
5244 }
5245 }
5246
5247 protected void cacheUniqueFindersCache(JournalFolder journalFolder) {
5248 if (journalFolder.isNew()) {
5249 Object[] args = new Object[] {
5250 journalFolder.getUuid(), journalFolder.getGroupId()
5251 };
5252
5253 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
5254 Long.valueOf(1));
5255 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
5256 journalFolder);
5257
5258 args = new Object[] {
5259 journalFolder.getGroupId(), journalFolder.getName()
5260 };
5261
5262 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_N, args,
5263 Long.valueOf(1));
5264 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N, args,
5265 journalFolder);
5266
5267 args = new Object[] {
5268 journalFolder.getGroupId(),
5269 journalFolder.getParentFolderId(), journalFolder.getName()
5270 };
5271
5272 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_P_N, args,
5273 Long.valueOf(1));
5274 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P_N, args,
5275 journalFolder);
5276 }
5277 else {
5278 JournalFolderModelImpl journalFolderModelImpl = (JournalFolderModelImpl)journalFolder;
5279
5280 if ((journalFolderModelImpl.getColumnBitmask() &
5281 FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
5282 Object[] args = new Object[] {
5283 journalFolder.getUuid(), journalFolder.getGroupId()
5284 };
5285
5286 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
5287 Long.valueOf(1));
5288 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
5289 journalFolder);
5290 }
5291
5292 if ((journalFolderModelImpl.getColumnBitmask() &
5293 FINDER_PATH_FETCH_BY_G_N.getColumnBitmask()) != 0) {
5294 Object[] args = new Object[] {
5295 journalFolder.getGroupId(), journalFolder.getName()
5296 };
5297
5298 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_N, args,
5299 Long.valueOf(1));
5300 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N, args,
5301 journalFolder);
5302 }
5303
5304 if ((journalFolderModelImpl.getColumnBitmask() &
5305 FINDER_PATH_FETCH_BY_G_P_N.getColumnBitmask()) != 0) {
5306 Object[] args = new Object[] {
5307 journalFolder.getGroupId(),
5308 journalFolder.getParentFolderId(),
5309 journalFolder.getName()
5310 };
5311
5312 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_P_N, args,
5313 Long.valueOf(1));
5314 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P_N, args,
5315 journalFolder);
5316 }
5317 }
5318 }
5319
5320 protected void clearUniqueFindersCache(JournalFolder journalFolder) {
5321 JournalFolderModelImpl journalFolderModelImpl = (JournalFolderModelImpl)journalFolder;
5322
5323 Object[] args = new Object[] {
5324 journalFolder.getUuid(), journalFolder.getGroupId()
5325 };
5326
5327 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
5328 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
5329
5330 if ((journalFolderModelImpl.getColumnBitmask() &
5331 FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
5332 args = new Object[] {
5333 journalFolderModelImpl.getOriginalUuid(),
5334 journalFolderModelImpl.getOriginalGroupId()
5335 };
5336
5337 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
5338 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
5339 }
5340
5341 args = new Object[] { journalFolder.getGroupId(), journalFolder.getName() };
5342
5343 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_N, args);
5344 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_N, args);
5345
5346 if ((journalFolderModelImpl.getColumnBitmask() &
5347 FINDER_PATH_FETCH_BY_G_N.getColumnBitmask()) != 0) {
5348 args = new Object[] {
5349 journalFolderModelImpl.getOriginalGroupId(),
5350 journalFolderModelImpl.getOriginalName()
5351 };
5352
5353 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_N, args);
5354 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_N, args);
5355 }
5356
5357 args = new Object[] {
5358 journalFolder.getGroupId(), journalFolder.getParentFolderId(),
5359 journalFolder.getName()
5360 };
5361
5362 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P_N, args);
5363 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_P_N, args);
5364
5365 if ((journalFolderModelImpl.getColumnBitmask() &
5366 FINDER_PATH_FETCH_BY_G_P_N.getColumnBitmask()) != 0) {
5367 args = new Object[] {
5368 journalFolderModelImpl.getOriginalGroupId(),
5369 journalFolderModelImpl.getOriginalParentFolderId(),
5370 journalFolderModelImpl.getOriginalName()
5371 };
5372
5373 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P_N, args);
5374 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_P_N, args);
5375 }
5376 }
5377
5378
5384 public JournalFolder create(long folderId) {
5385 JournalFolder journalFolder = new JournalFolderImpl();
5386
5387 journalFolder.setNew(true);
5388 journalFolder.setPrimaryKey(folderId);
5389
5390 String uuid = PortalUUIDUtil.generate();
5391
5392 journalFolder.setUuid(uuid);
5393
5394 return journalFolder;
5395 }
5396
5397
5405 public JournalFolder remove(long folderId)
5406 throws NoSuchFolderException, SystemException {
5407 return remove((Serializable)folderId);
5408 }
5409
5410
5418 @Override
5419 public JournalFolder remove(Serializable primaryKey)
5420 throws NoSuchFolderException, SystemException {
5421 Session session = null;
5422
5423 try {
5424 session = openSession();
5425
5426 JournalFolder journalFolder = (JournalFolder)session.get(JournalFolderImpl.class,
5427 primaryKey);
5428
5429 if (journalFolder == null) {
5430 if (_log.isWarnEnabled()) {
5431 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
5432 }
5433
5434 throw new NoSuchFolderException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
5435 primaryKey);
5436 }
5437
5438 return remove(journalFolder);
5439 }
5440 catch (NoSuchFolderException nsee) {
5441 throw nsee;
5442 }
5443 catch (Exception e) {
5444 throw processException(e);
5445 }
5446 finally {
5447 closeSession(session);
5448 }
5449 }
5450
5451 @Override
5452 protected JournalFolder removeImpl(JournalFolder journalFolder)
5453 throws SystemException {
5454 journalFolder = toUnwrappedModel(journalFolder);
5455
5456 Session session = null;
5457
5458 try {
5459 session = openSession();
5460
5461 if (!session.contains(journalFolder)) {
5462 journalFolder = (JournalFolder)session.get(JournalFolderImpl.class,
5463 journalFolder.getPrimaryKeyObj());
5464 }
5465
5466 if (journalFolder != null) {
5467 session.delete(journalFolder);
5468 }
5469 }
5470 catch (Exception e) {
5471 throw processException(e);
5472 }
5473 finally {
5474 closeSession(session);
5475 }
5476
5477 if (journalFolder != null) {
5478 clearCache(journalFolder);
5479 }
5480
5481 return journalFolder;
5482 }
5483
5484 @Override
5485 public JournalFolder updateImpl(
5486 com.liferay.portlet.journal.model.JournalFolder journalFolder)
5487 throws SystemException {
5488 journalFolder = toUnwrappedModel(journalFolder);
5489
5490 boolean isNew = journalFolder.isNew();
5491
5492 JournalFolderModelImpl journalFolderModelImpl = (JournalFolderModelImpl)journalFolder;
5493
5494 if (Validator.isNull(journalFolder.getUuid())) {
5495 String uuid = PortalUUIDUtil.generate();
5496
5497 journalFolder.setUuid(uuid);
5498 }
5499
5500 Session session = null;
5501
5502 try {
5503 session = openSession();
5504
5505 if (journalFolder.isNew()) {
5506 session.save(journalFolder);
5507
5508 journalFolder.setNew(false);
5509 }
5510 else {
5511 session.merge(journalFolder);
5512 }
5513 }
5514 catch (Exception e) {
5515 throw processException(e);
5516 }
5517 finally {
5518 closeSession(session);
5519 }
5520
5521 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
5522
5523 if (isNew || !JournalFolderModelImpl.COLUMN_BITMASK_ENABLED) {
5524 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
5525 }
5526
5527 else {
5528 if ((journalFolderModelImpl.getColumnBitmask() &
5529 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
5530 Object[] args = new Object[] {
5531 journalFolderModelImpl.getOriginalUuid()
5532 };
5533
5534 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
5535 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
5536 args);
5537
5538 args = new Object[] { journalFolderModelImpl.getUuid() };
5539
5540 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
5541 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
5542 args);
5543 }
5544
5545 if ((journalFolderModelImpl.getColumnBitmask() &
5546 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C.getColumnBitmask()) != 0) {
5547 Object[] args = new Object[] {
5548 journalFolderModelImpl.getOriginalUuid(),
5549 journalFolderModelImpl.getOriginalCompanyId()
5550 };
5551
5552 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
5553 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
5554 args);
5555
5556 args = new Object[] {
5557 journalFolderModelImpl.getUuid(),
5558 journalFolderModelImpl.getCompanyId()
5559 };
5560
5561 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
5562 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
5563 args);
5564 }
5565
5566 if ((journalFolderModelImpl.getColumnBitmask() &
5567 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
5568 Object[] args = new Object[] {
5569 journalFolderModelImpl.getOriginalGroupId()
5570 };
5571
5572 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
5573 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
5574 args);
5575
5576 args = new Object[] { journalFolderModelImpl.getGroupId() };
5577
5578 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
5579 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
5580 args);
5581 }
5582
5583 if ((journalFolderModelImpl.getColumnBitmask() &
5584 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
5585 Object[] args = new Object[] {
5586 journalFolderModelImpl.getOriginalCompanyId()
5587 };
5588
5589 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
5590 args);
5591 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
5592 args);
5593
5594 args = new Object[] { journalFolderModelImpl.getCompanyId() };
5595
5596 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
5597 args);
5598 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
5599 args);
5600 }
5601
5602 if ((journalFolderModelImpl.getColumnBitmask() &
5603 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P.getColumnBitmask()) != 0) {
5604 Object[] args = new Object[] {
5605 journalFolderModelImpl.getOriginalGroupId(),
5606 journalFolderModelImpl.getOriginalParentFolderId()
5607 };
5608
5609 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P, args);
5610 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P,
5611 args);
5612
5613 args = new Object[] {
5614 journalFolderModelImpl.getGroupId(),
5615 journalFolderModelImpl.getParentFolderId()
5616 };
5617
5618 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P, args);
5619 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P,
5620 args);
5621 }
5622
5623 if ((journalFolderModelImpl.getColumnBitmask() &
5624 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_S.getColumnBitmask()) != 0) {
5625 Object[] args = new Object[] {
5626 journalFolderModelImpl.getOriginalGroupId(),
5627 journalFolderModelImpl.getOriginalParentFolderId(),
5628 journalFolderModelImpl.getOriginalStatus()
5629 };
5630
5631 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P_S, args);
5632 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_S,
5633 args);
5634
5635 args = new Object[] {
5636 journalFolderModelImpl.getGroupId(),
5637 journalFolderModelImpl.getParentFolderId(),
5638 journalFolderModelImpl.getStatus()
5639 };
5640
5641 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P_S, args);
5642 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_S,
5643 args);
5644 }
5645 }
5646
5647 EntityCacheUtil.putResult(JournalFolderModelImpl.ENTITY_CACHE_ENABLED,
5648 JournalFolderImpl.class, journalFolder.getPrimaryKey(),
5649 journalFolder);
5650
5651 clearUniqueFindersCache(journalFolder);
5652 cacheUniqueFindersCache(journalFolder);
5653
5654 return journalFolder;
5655 }
5656
5657 protected JournalFolder toUnwrappedModel(JournalFolder journalFolder) {
5658 if (journalFolder instanceof JournalFolderImpl) {
5659 return journalFolder;
5660 }
5661
5662 JournalFolderImpl journalFolderImpl = new JournalFolderImpl();
5663
5664 journalFolderImpl.setNew(journalFolder.isNew());
5665 journalFolderImpl.setPrimaryKey(journalFolder.getPrimaryKey());
5666
5667 journalFolderImpl.setUuid(journalFolder.getUuid());
5668 journalFolderImpl.setFolderId(journalFolder.getFolderId());
5669 journalFolderImpl.setGroupId(journalFolder.getGroupId());
5670 journalFolderImpl.setCompanyId(journalFolder.getCompanyId());
5671 journalFolderImpl.setUserId(journalFolder.getUserId());
5672 journalFolderImpl.setUserName(journalFolder.getUserName());
5673 journalFolderImpl.setCreateDate(journalFolder.getCreateDate());
5674 journalFolderImpl.setModifiedDate(journalFolder.getModifiedDate());
5675 journalFolderImpl.setParentFolderId(journalFolder.getParentFolderId());
5676 journalFolderImpl.setName(journalFolder.getName());
5677 journalFolderImpl.setDescription(journalFolder.getDescription());
5678 journalFolderImpl.setStatus(journalFolder.getStatus());
5679 journalFolderImpl.setStatusByUserId(journalFolder.getStatusByUserId());
5680 journalFolderImpl.setStatusByUserName(journalFolder.getStatusByUserName());
5681 journalFolderImpl.setStatusDate(journalFolder.getStatusDate());
5682
5683 return journalFolderImpl;
5684 }
5685
5686
5694 @Override
5695 public JournalFolder findByPrimaryKey(Serializable primaryKey)
5696 throws NoSuchFolderException, SystemException {
5697 JournalFolder journalFolder = fetchByPrimaryKey(primaryKey);
5698
5699 if (journalFolder == null) {
5700 if (_log.isWarnEnabled()) {
5701 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
5702 }
5703
5704 throw new NoSuchFolderException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
5705 primaryKey);
5706 }
5707
5708 return journalFolder;
5709 }
5710
5711
5719 public JournalFolder findByPrimaryKey(long folderId)
5720 throws NoSuchFolderException, SystemException {
5721 return findByPrimaryKey((Serializable)folderId);
5722 }
5723
5724
5731 @Override
5732 public JournalFolder fetchByPrimaryKey(Serializable primaryKey)
5733 throws SystemException {
5734 JournalFolder journalFolder = (JournalFolder)EntityCacheUtil.getResult(JournalFolderModelImpl.ENTITY_CACHE_ENABLED,
5735 JournalFolderImpl.class, primaryKey);
5736
5737 if (journalFolder == _nullJournalFolder) {
5738 return null;
5739 }
5740
5741 if (journalFolder == null) {
5742 Session session = null;
5743
5744 try {
5745 session = openSession();
5746
5747 journalFolder = (JournalFolder)session.get(JournalFolderImpl.class,
5748 primaryKey);
5749
5750 if (journalFolder != null) {
5751 cacheResult(journalFolder);
5752 }
5753 else {
5754 EntityCacheUtil.putResult(JournalFolderModelImpl.ENTITY_CACHE_ENABLED,
5755 JournalFolderImpl.class, primaryKey, _nullJournalFolder);
5756 }
5757 }
5758 catch (Exception e) {
5759 EntityCacheUtil.removeResult(JournalFolderModelImpl.ENTITY_CACHE_ENABLED,
5760 JournalFolderImpl.class, primaryKey);
5761
5762 throw processException(e);
5763 }
5764 finally {
5765 closeSession(session);
5766 }
5767 }
5768
5769 return journalFolder;
5770 }
5771
5772
5779 public JournalFolder fetchByPrimaryKey(long folderId)
5780 throws SystemException {
5781 return fetchByPrimaryKey((Serializable)folderId);
5782 }
5783
5784
5790 public List<JournalFolder> findAll() throws SystemException {
5791 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
5792 }
5793
5794
5806 public List<JournalFolder> findAll(int start, int end)
5807 throws SystemException {
5808 return findAll(start, end, null);
5809 }
5810
5811
5824 public List<JournalFolder> findAll(int start, int end,
5825 OrderByComparator orderByComparator) throws SystemException {
5826 boolean pagination = true;
5827 FinderPath finderPath = null;
5828 Object[] finderArgs = null;
5829
5830 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
5831 (orderByComparator == null)) {
5832 pagination = false;
5833 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
5834 finderArgs = FINDER_ARGS_EMPTY;
5835 }
5836 else {
5837 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
5838 finderArgs = new Object[] { start, end, orderByComparator };
5839 }
5840
5841 List<JournalFolder> list = (List<JournalFolder>)FinderCacheUtil.getResult(finderPath,
5842 finderArgs, this);
5843
5844 if (list == null) {
5845 StringBundler query = null;
5846 String sql = null;
5847
5848 if (orderByComparator != null) {
5849 query = new StringBundler(2 +
5850 (orderByComparator.getOrderByFields().length * 3));
5851
5852 query.append(_SQL_SELECT_JOURNALFOLDER);
5853
5854 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5855 orderByComparator);
5856
5857 sql = query.toString();
5858 }
5859 else {
5860 sql = _SQL_SELECT_JOURNALFOLDER;
5861
5862 if (pagination) {
5863 sql = sql.concat(JournalFolderModelImpl.ORDER_BY_JPQL);
5864 }
5865 }
5866
5867 Session session = null;
5868
5869 try {
5870 session = openSession();
5871
5872 Query q = session.createQuery(sql);
5873
5874 if (!pagination) {
5875 list = (List<JournalFolder>)QueryUtil.list(q, getDialect(),
5876 start, end, false);
5877
5878 Collections.sort(list);
5879
5880 list = new UnmodifiableList<JournalFolder>(list);
5881 }
5882 else {
5883 list = (List<JournalFolder>)QueryUtil.list(q, getDialect(),
5884 start, end);
5885 }
5886
5887 cacheResult(list);
5888
5889 FinderCacheUtil.putResult(finderPath, finderArgs, list);
5890 }
5891 catch (Exception e) {
5892 FinderCacheUtil.removeResult(finderPath, finderArgs);
5893
5894 throw processException(e);
5895 }
5896 finally {
5897 closeSession(session);
5898 }
5899 }
5900
5901 return list;
5902 }
5903
5904
5909 public void removeAll() throws SystemException {
5910 for (JournalFolder journalFolder : findAll()) {
5911 remove(journalFolder);
5912 }
5913 }
5914
5915
5921 public int countAll() throws SystemException {
5922 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
5923 FINDER_ARGS_EMPTY, this);
5924
5925 if (count == null) {
5926 Session session = null;
5927
5928 try {
5929 session = openSession();
5930
5931 Query q = session.createQuery(_SQL_COUNT_JOURNALFOLDER);
5932
5933 count = (Long)q.uniqueResult();
5934
5935 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
5936 FINDER_ARGS_EMPTY, count);
5937 }
5938 catch (Exception e) {
5939 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
5940 FINDER_ARGS_EMPTY);
5941
5942 throw processException(e);
5943 }
5944 finally {
5945 closeSession(session);
5946 }
5947 }
5948
5949 return count.intValue();
5950 }
5951
5952 @Override
5953 protected Set<String> getBadColumnNames() {
5954 return _badColumnNames;
5955 }
5956
5957
5960 public void afterPropertiesSet() {
5961 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
5962 com.liferay.portal.util.PropsUtil.get(
5963 "value.object.listener.com.liferay.portlet.journal.model.JournalFolder")));
5964
5965 if (listenerClassNames.length > 0) {
5966 try {
5967 List<ModelListener<JournalFolder>> listenersList = new ArrayList<ModelListener<JournalFolder>>();
5968
5969 for (String listenerClassName : listenerClassNames) {
5970 listenersList.add((ModelListener<JournalFolder>)InstanceFactory.newInstance(
5971 getClassLoader(), listenerClassName));
5972 }
5973
5974 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
5975 }
5976 catch (Exception e) {
5977 _log.error(e);
5978 }
5979 }
5980 }
5981
5982 public void destroy() {
5983 EntityCacheUtil.removeCache(JournalFolderImpl.class.getName());
5984 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
5985 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
5986 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
5987 }
5988
5989 private static final String _SQL_SELECT_JOURNALFOLDER = "SELECT journalFolder FROM JournalFolder journalFolder";
5990 private static final String _SQL_SELECT_JOURNALFOLDER_WHERE = "SELECT journalFolder FROM JournalFolder journalFolder WHERE ";
5991 private static final String _SQL_COUNT_JOURNALFOLDER = "SELECT COUNT(journalFolder) FROM JournalFolder journalFolder";
5992 private static final String _SQL_COUNT_JOURNALFOLDER_WHERE = "SELECT COUNT(journalFolder) FROM JournalFolder journalFolder WHERE ";
5993 private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "journalFolder.folderId";
5994 private static final String _FILTER_SQL_SELECT_JOURNALFOLDER_WHERE = "SELECT DISTINCT {journalFolder.*} FROM JournalFolder journalFolder WHERE ";
5995 private static final String _FILTER_SQL_SELECT_JOURNALFOLDER_NO_INLINE_DISTINCT_WHERE_1 =
5996 "SELECT {JournalFolder.*} FROM (SELECT DISTINCT journalFolder.folderId FROM JournalFolder journalFolder WHERE ";
5997 private static final String _FILTER_SQL_SELECT_JOURNALFOLDER_NO_INLINE_DISTINCT_WHERE_2 =
5998 ") TEMP_TABLE INNER JOIN JournalFolder ON TEMP_TABLE.folderId = JournalFolder.folderId";
5999 private static final String _FILTER_SQL_COUNT_JOURNALFOLDER_WHERE = "SELECT COUNT(DISTINCT journalFolder.folderId) AS COUNT_VALUE FROM JournalFolder journalFolder WHERE ";
6000 private static final String _FILTER_ENTITY_ALIAS = "journalFolder";
6001 private static final String _FILTER_ENTITY_TABLE = "JournalFolder";
6002 private static final String _ORDER_BY_ENTITY_ALIAS = "journalFolder.";
6003 private static final String _ORDER_BY_ENTITY_TABLE = "JournalFolder.";
6004 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No JournalFolder exists with the primary key ";
6005 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No JournalFolder exists with the key {";
6006 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
6007 private static Log _log = LogFactoryUtil.getLog(JournalFolderPersistenceImpl.class);
6008 private static Set<String> _badColumnNames = SetUtil.fromArray(new String[] {
6009 "uuid"
6010 });
6011 private static JournalFolder _nullJournalFolder = new JournalFolderImpl() {
6012 @Override
6013 public Object clone() {
6014 return this;
6015 }
6016
6017 @Override
6018 public CacheModel<JournalFolder> toCacheModel() {
6019 return _nullJournalFolderCacheModel;
6020 }
6021 };
6022
6023 private static CacheModel<JournalFolder> _nullJournalFolderCacheModel = new CacheModel<JournalFolder>() {
6024 public JournalFolder toEntityModel() {
6025 return _nullJournalFolder;
6026 }
6027 };
6028 }