001
014
015 package com.liferay.portal.service.persistence;
016
017 import com.liferay.portal.NoSuchLayoutRevisionException;
018 import com.liferay.portal.kernel.cache.CacheRegistryUtil;
019 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
020 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
021 import com.liferay.portal.kernel.dao.orm.FinderPath;
022 import com.liferay.portal.kernel.dao.orm.Query;
023 import com.liferay.portal.kernel.dao.orm.QueryPos;
024 import com.liferay.portal.kernel.dao.orm.QueryUtil;
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.StringBundler;
033 import com.liferay.portal.kernel.util.StringPool;
034 import com.liferay.portal.kernel.util.StringUtil;
035 import com.liferay.portal.kernel.util.UnmodifiableList;
036 import com.liferay.portal.model.CacheModel;
037 import com.liferay.portal.model.LayoutRevision;
038 import com.liferay.portal.model.ModelListener;
039 import com.liferay.portal.model.impl.LayoutRevisionImpl;
040 import com.liferay.portal.model.impl.LayoutRevisionModelImpl;
041 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
042
043 import java.io.Serializable;
044
045 import java.util.ArrayList;
046 import java.util.Collections;
047 import java.util.List;
048
049
061 public class LayoutRevisionPersistenceImpl extends BasePersistenceImpl<LayoutRevision>
062 implements LayoutRevisionPersistence {
063
068 public static final String FINDER_CLASS_NAME_ENTITY = LayoutRevisionImpl.class.getName();
069 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
070 ".List1";
071 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
072 ".List2";
073 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(LayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
074 LayoutRevisionModelImpl.FINDER_CACHE_ENABLED,
075 LayoutRevisionImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
076 "findAll", new String[0]);
077 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(LayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
078 LayoutRevisionModelImpl.FINDER_CACHE_ENABLED,
079 LayoutRevisionImpl.class,
080 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
081 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(LayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
082 LayoutRevisionModelImpl.FINDER_CACHE_ENABLED, Long.class,
083 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
084 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_LAYOUTSETBRANCHID =
085 new FinderPath(LayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
086 LayoutRevisionModelImpl.FINDER_CACHE_ENABLED,
087 LayoutRevisionImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
088 "findByLayoutSetBranchId",
089 new String[] {
090 Long.class.getName(),
091
092 Integer.class.getName(), Integer.class.getName(),
093 OrderByComparator.class.getName()
094 });
095 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LAYOUTSETBRANCHID =
096 new FinderPath(LayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
097 LayoutRevisionModelImpl.FINDER_CACHE_ENABLED,
098 LayoutRevisionImpl.class,
099 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
100 "findByLayoutSetBranchId", new String[] { Long.class.getName() },
101 LayoutRevisionModelImpl.LAYOUTSETBRANCHID_COLUMN_BITMASK |
102 LayoutRevisionModelImpl.MODIFIEDDATE_COLUMN_BITMASK);
103 public static final FinderPath FINDER_PATH_COUNT_BY_LAYOUTSETBRANCHID = new FinderPath(LayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
104 LayoutRevisionModelImpl.FINDER_CACHE_ENABLED, Long.class,
105 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
106 "countByLayoutSetBranchId", new String[] { Long.class.getName() });
107
108
115 public List<LayoutRevision> findByLayoutSetBranchId(long layoutSetBranchId)
116 throws SystemException {
117 return findByLayoutSetBranchId(layoutSetBranchId, QueryUtil.ALL_POS,
118 QueryUtil.ALL_POS, null);
119 }
120
121
134 public List<LayoutRevision> findByLayoutSetBranchId(
135 long layoutSetBranchId, int start, int end) throws SystemException {
136 return findByLayoutSetBranchId(layoutSetBranchId, start, end, null);
137 }
138
139
153 public List<LayoutRevision> findByLayoutSetBranchId(
154 long layoutSetBranchId, int start, int end,
155 OrderByComparator orderByComparator) throws SystemException {
156 boolean pagination = true;
157 FinderPath finderPath = null;
158 Object[] finderArgs = null;
159
160 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
161 (orderByComparator == null)) {
162 pagination = false;
163 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LAYOUTSETBRANCHID;
164 finderArgs = new Object[] { layoutSetBranchId };
165 }
166 else {
167 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_LAYOUTSETBRANCHID;
168 finderArgs = new Object[] {
169 layoutSetBranchId,
170
171 start, end, orderByComparator
172 };
173 }
174
175 List<LayoutRevision> list = (List<LayoutRevision>)FinderCacheUtil.getResult(finderPath,
176 finderArgs, this);
177
178 if ((list != null) && !list.isEmpty()) {
179 for (LayoutRevision layoutRevision : list) {
180 if ((layoutSetBranchId != layoutRevision.getLayoutSetBranchId())) {
181 list = null;
182
183 break;
184 }
185 }
186 }
187
188 if (list == null) {
189 StringBundler query = null;
190
191 if (orderByComparator != null) {
192 query = new StringBundler(3 +
193 (orderByComparator.getOrderByFields().length * 3));
194 }
195 else {
196 query = new StringBundler(3);
197 }
198
199 query.append(_SQL_SELECT_LAYOUTREVISION_WHERE);
200
201 query.append(_FINDER_COLUMN_LAYOUTSETBRANCHID_LAYOUTSETBRANCHID_2);
202
203 if (orderByComparator != null) {
204 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
205 orderByComparator);
206 }
207 else
208 if (pagination) {
209 query.append(LayoutRevisionModelImpl.ORDER_BY_JPQL);
210 }
211
212 String sql = query.toString();
213
214 Session session = null;
215
216 try {
217 session = openSession();
218
219 Query q = session.createQuery(sql);
220
221 QueryPos qPos = QueryPos.getInstance(q);
222
223 qPos.add(layoutSetBranchId);
224
225 if (!pagination) {
226 list = (List<LayoutRevision>)QueryUtil.list(q,
227 getDialect(), start, end, false);
228
229 Collections.sort(list);
230
231 list = new UnmodifiableList<LayoutRevision>(list);
232 }
233 else {
234 list = (List<LayoutRevision>)QueryUtil.list(q,
235 getDialect(), start, end);
236 }
237
238 cacheResult(list);
239
240 FinderCacheUtil.putResult(finderPath, finderArgs, list);
241 }
242 catch (Exception e) {
243 FinderCacheUtil.removeResult(finderPath, finderArgs);
244
245 throw processException(e);
246 }
247 finally {
248 closeSession(session);
249 }
250 }
251
252 return list;
253 }
254
255
264 public LayoutRevision findByLayoutSetBranchId_First(
265 long layoutSetBranchId, OrderByComparator orderByComparator)
266 throws NoSuchLayoutRevisionException, SystemException {
267 LayoutRevision layoutRevision = fetchByLayoutSetBranchId_First(layoutSetBranchId,
268 orderByComparator);
269
270 if (layoutRevision != null) {
271 return layoutRevision;
272 }
273
274 StringBundler msg = new StringBundler(4);
275
276 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
277
278 msg.append("layoutSetBranchId=");
279 msg.append(layoutSetBranchId);
280
281 msg.append(StringPool.CLOSE_CURLY_BRACE);
282
283 throw new NoSuchLayoutRevisionException(msg.toString());
284 }
285
286
294 public LayoutRevision fetchByLayoutSetBranchId_First(
295 long layoutSetBranchId, OrderByComparator orderByComparator)
296 throws SystemException {
297 List<LayoutRevision> list = findByLayoutSetBranchId(layoutSetBranchId,
298 0, 1, orderByComparator);
299
300 if (!list.isEmpty()) {
301 return list.get(0);
302 }
303
304 return null;
305 }
306
307
316 public LayoutRevision findByLayoutSetBranchId_Last(long layoutSetBranchId,
317 OrderByComparator orderByComparator)
318 throws NoSuchLayoutRevisionException, SystemException {
319 LayoutRevision layoutRevision = fetchByLayoutSetBranchId_Last(layoutSetBranchId,
320 orderByComparator);
321
322 if (layoutRevision != null) {
323 return layoutRevision;
324 }
325
326 StringBundler msg = new StringBundler(4);
327
328 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
329
330 msg.append("layoutSetBranchId=");
331 msg.append(layoutSetBranchId);
332
333 msg.append(StringPool.CLOSE_CURLY_BRACE);
334
335 throw new NoSuchLayoutRevisionException(msg.toString());
336 }
337
338
346 public LayoutRevision fetchByLayoutSetBranchId_Last(
347 long layoutSetBranchId, OrderByComparator orderByComparator)
348 throws SystemException {
349 int count = countByLayoutSetBranchId(layoutSetBranchId);
350
351 List<LayoutRevision> list = findByLayoutSetBranchId(layoutSetBranchId,
352 count - 1, count, orderByComparator);
353
354 if (!list.isEmpty()) {
355 return list.get(0);
356 }
357
358 return null;
359 }
360
361
371 public LayoutRevision[] findByLayoutSetBranchId_PrevAndNext(
372 long layoutRevisionId, long layoutSetBranchId,
373 OrderByComparator orderByComparator)
374 throws NoSuchLayoutRevisionException, SystemException {
375 LayoutRevision layoutRevision = findByPrimaryKey(layoutRevisionId);
376
377 Session session = null;
378
379 try {
380 session = openSession();
381
382 LayoutRevision[] array = new LayoutRevisionImpl[3];
383
384 array[0] = getByLayoutSetBranchId_PrevAndNext(session,
385 layoutRevision, layoutSetBranchId, orderByComparator, true);
386
387 array[1] = layoutRevision;
388
389 array[2] = getByLayoutSetBranchId_PrevAndNext(session,
390 layoutRevision, layoutSetBranchId, orderByComparator, false);
391
392 return array;
393 }
394 catch (Exception e) {
395 throw processException(e);
396 }
397 finally {
398 closeSession(session);
399 }
400 }
401
402 protected LayoutRevision getByLayoutSetBranchId_PrevAndNext(
403 Session session, LayoutRevision layoutRevision, long layoutSetBranchId,
404 OrderByComparator orderByComparator, boolean previous) {
405 StringBundler query = null;
406
407 if (orderByComparator != null) {
408 query = new StringBundler(6 +
409 (orderByComparator.getOrderByFields().length * 6));
410 }
411 else {
412 query = new StringBundler(3);
413 }
414
415 query.append(_SQL_SELECT_LAYOUTREVISION_WHERE);
416
417 query.append(_FINDER_COLUMN_LAYOUTSETBRANCHID_LAYOUTSETBRANCHID_2);
418
419 if (orderByComparator != null) {
420 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
421
422 if (orderByConditionFields.length > 0) {
423 query.append(WHERE_AND);
424 }
425
426 for (int i = 0; i < orderByConditionFields.length; i++) {
427 query.append(_ORDER_BY_ENTITY_ALIAS);
428 query.append(orderByConditionFields[i]);
429
430 if ((i + 1) < orderByConditionFields.length) {
431 if (orderByComparator.isAscending() ^ previous) {
432 query.append(WHERE_GREATER_THAN_HAS_NEXT);
433 }
434 else {
435 query.append(WHERE_LESSER_THAN_HAS_NEXT);
436 }
437 }
438 else {
439 if (orderByComparator.isAscending() ^ previous) {
440 query.append(WHERE_GREATER_THAN);
441 }
442 else {
443 query.append(WHERE_LESSER_THAN);
444 }
445 }
446 }
447
448 query.append(ORDER_BY_CLAUSE);
449
450 String[] orderByFields = orderByComparator.getOrderByFields();
451
452 for (int i = 0; i < orderByFields.length; i++) {
453 query.append(_ORDER_BY_ENTITY_ALIAS);
454 query.append(orderByFields[i]);
455
456 if ((i + 1) < orderByFields.length) {
457 if (orderByComparator.isAscending() ^ previous) {
458 query.append(ORDER_BY_ASC_HAS_NEXT);
459 }
460 else {
461 query.append(ORDER_BY_DESC_HAS_NEXT);
462 }
463 }
464 else {
465 if (orderByComparator.isAscending() ^ previous) {
466 query.append(ORDER_BY_ASC);
467 }
468 else {
469 query.append(ORDER_BY_DESC);
470 }
471 }
472 }
473 }
474 else {
475 query.append(LayoutRevisionModelImpl.ORDER_BY_JPQL);
476 }
477
478 String sql = query.toString();
479
480 Query q = session.createQuery(sql);
481
482 q.setFirstResult(0);
483 q.setMaxResults(2);
484
485 QueryPos qPos = QueryPos.getInstance(q);
486
487 qPos.add(layoutSetBranchId);
488
489 if (orderByComparator != null) {
490 Object[] values = orderByComparator.getOrderByConditionValues(layoutRevision);
491
492 for (Object value : values) {
493 qPos.add(value);
494 }
495 }
496
497 List<LayoutRevision> list = q.list();
498
499 if (list.size() == 2) {
500 return list.get(1);
501 }
502 else {
503 return null;
504 }
505 }
506
507
513 public void removeByLayoutSetBranchId(long layoutSetBranchId)
514 throws SystemException {
515 for (LayoutRevision layoutRevision : findByLayoutSetBranchId(
516 layoutSetBranchId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
517 remove(layoutRevision);
518 }
519 }
520
521
528 public int countByLayoutSetBranchId(long layoutSetBranchId)
529 throws SystemException {
530 FinderPath finderPath = FINDER_PATH_COUNT_BY_LAYOUTSETBRANCHID;
531
532 Object[] finderArgs = new Object[] { layoutSetBranchId };
533
534 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
535 this);
536
537 if (count == null) {
538 StringBundler query = new StringBundler(2);
539
540 query.append(_SQL_COUNT_LAYOUTREVISION_WHERE);
541
542 query.append(_FINDER_COLUMN_LAYOUTSETBRANCHID_LAYOUTSETBRANCHID_2);
543
544 String sql = query.toString();
545
546 Session session = null;
547
548 try {
549 session = openSession();
550
551 Query q = session.createQuery(sql);
552
553 QueryPos qPos = QueryPos.getInstance(q);
554
555 qPos.add(layoutSetBranchId);
556
557 count = (Long)q.uniqueResult();
558
559 FinderCacheUtil.putResult(finderPath, finderArgs, count);
560 }
561 catch (Exception e) {
562 FinderCacheUtil.removeResult(finderPath, finderArgs);
563
564 throw processException(e);
565 }
566 finally {
567 closeSession(session);
568 }
569 }
570
571 return count.intValue();
572 }
573
574 private static final String _FINDER_COLUMN_LAYOUTSETBRANCHID_LAYOUTSETBRANCHID_2 =
575 "layoutRevision.layoutSetBranchId = ?";
576 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_PLID = new FinderPath(LayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
577 LayoutRevisionModelImpl.FINDER_CACHE_ENABLED,
578 LayoutRevisionImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
579 "findByPlid",
580 new String[] {
581 Long.class.getName(),
582
583 Integer.class.getName(), Integer.class.getName(),
584 OrderByComparator.class.getName()
585 });
586 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PLID = new FinderPath(LayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
587 LayoutRevisionModelImpl.FINDER_CACHE_ENABLED,
588 LayoutRevisionImpl.class,
589 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByPlid",
590 new String[] { Long.class.getName() },
591 LayoutRevisionModelImpl.PLID_COLUMN_BITMASK |
592 LayoutRevisionModelImpl.MODIFIEDDATE_COLUMN_BITMASK);
593 public static final FinderPath FINDER_PATH_COUNT_BY_PLID = new FinderPath(LayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
594 LayoutRevisionModelImpl.FINDER_CACHE_ENABLED, Long.class,
595 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByPlid",
596 new String[] { Long.class.getName() });
597
598
605 public List<LayoutRevision> findByPlid(long plid) throws SystemException {
606 return findByPlid(plid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
607 }
608
609
622 public List<LayoutRevision> findByPlid(long plid, int start, int end)
623 throws SystemException {
624 return findByPlid(plid, start, end, null);
625 }
626
627
641 public List<LayoutRevision> findByPlid(long plid, int start, int end,
642 OrderByComparator orderByComparator) throws SystemException {
643 boolean pagination = true;
644 FinderPath finderPath = null;
645 Object[] finderArgs = null;
646
647 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
648 (orderByComparator == null)) {
649 pagination = false;
650 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PLID;
651 finderArgs = new Object[] { plid };
652 }
653 else {
654 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_PLID;
655 finderArgs = new Object[] { plid, start, end, orderByComparator };
656 }
657
658 List<LayoutRevision> list = (List<LayoutRevision>)FinderCacheUtil.getResult(finderPath,
659 finderArgs, this);
660
661 if ((list != null) && !list.isEmpty()) {
662 for (LayoutRevision layoutRevision : list) {
663 if ((plid != layoutRevision.getPlid())) {
664 list = null;
665
666 break;
667 }
668 }
669 }
670
671 if (list == null) {
672 StringBundler query = null;
673
674 if (orderByComparator != null) {
675 query = new StringBundler(3 +
676 (orderByComparator.getOrderByFields().length * 3));
677 }
678 else {
679 query = new StringBundler(3);
680 }
681
682 query.append(_SQL_SELECT_LAYOUTREVISION_WHERE);
683
684 query.append(_FINDER_COLUMN_PLID_PLID_2);
685
686 if (orderByComparator != null) {
687 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
688 orderByComparator);
689 }
690 else
691 if (pagination) {
692 query.append(LayoutRevisionModelImpl.ORDER_BY_JPQL);
693 }
694
695 String sql = query.toString();
696
697 Session session = null;
698
699 try {
700 session = openSession();
701
702 Query q = session.createQuery(sql);
703
704 QueryPos qPos = QueryPos.getInstance(q);
705
706 qPos.add(plid);
707
708 if (!pagination) {
709 list = (List<LayoutRevision>)QueryUtil.list(q,
710 getDialect(), start, end, false);
711
712 Collections.sort(list);
713
714 list = new UnmodifiableList<LayoutRevision>(list);
715 }
716 else {
717 list = (List<LayoutRevision>)QueryUtil.list(q,
718 getDialect(), start, end);
719 }
720
721 cacheResult(list);
722
723 FinderCacheUtil.putResult(finderPath, finderArgs, list);
724 }
725 catch (Exception e) {
726 FinderCacheUtil.removeResult(finderPath, finderArgs);
727
728 throw processException(e);
729 }
730 finally {
731 closeSession(session);
732 }
733 }
734
735 return list;
736 }
737
738
747 public LayoutRevision findByPlid_First(long plid,
748 OrderByComparator orderByComparator)
749 throws NoSuchLayoutRevisionException, SystemException {
750 LayoutRevision layoutRevision = fetchByPlid_First(plid,
751 orderByComparator);
752
753 if (layoutRevision != null) {
754 return layoutRevision;
755 }
756
757 StringBundler msg = new StringBundler(4);
758
759 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
760
761 msg.append("plid=");
762 msg.append(plid);
763
764 msg.append(StringPool.CLOSE_CURLY_BRACE);
765
766 throw new NoSuchLayoutRevisionException(msg.toString());
767 }
768
769
777 public LayoutRevision fetchByPlid_First(long plid,
778 OrderByComparator orderByComparator) throws SystemException {
779 List<LayoutRevision> list = findByPlid(plid, 0, 1, orderByComparator);
780
781 if (!list.isEmpty()) {
782 return list.get(0);
783 }
784
785 return null;
786 }
787
788
797 public LayoutRevision findByPlid_Last(long plid,
798 OrderByComparator orderByComparator)
799 throws NoSuchLayoutRevisionException, SystemException {
800 LayoutRevision layoutRevision = fetchByPlid_Last(plid, orderByComparator);
801
802 if (layoutRevision != null) {
803 return layoutRevision;
804 }
805
806 StringBundler msg = new StringBundler(4);
807
808 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
809
810 msg.append("plid=");
811 msg.append(plid);
812
813 msg.append(StringPool.CLOSE_CURLY_BRACE);
814
815 throw new NoSuchLayoutRevisionException(msg.toString());
816 }
817
818
826 public LayoutRevision fetchByPlid_Last(long plid,
827 OrderByComparator orderByComparator) throws SystemException {
828 int count = countByPlid(plid);
829
830 List<LayoutRevision> list = findByPlid(plid, count - 1, count,
831 orderByComparator);
832
833 if (!list.isEmpty()) {
834 return list.get(0);
835 }
836
837 return null;
838 }
839
840
850 public LayoutRevision[] findByPlid_PrevAndNext(long layoutRevisionId,
851 long plid, OrderByComparator orderByComparator)
852 throws NoSuchLayoutRevisionException, SystemException {
853 LayoutRevision layoutRevision = findByPrimaryKey(layoutRevisionId);
854
855 Session session = null;
856
857 try {
858 session = openSession();
859
860 LayoutRevision[] array = new LayoutRevisionImpl[3];
861
862 array[0] = getByPlid_PrevAndNext(session, layoutRevision, plid,
863 orderByComparator, true);
864
865 array[1] = layoutRevision;
866
867 array[2] = getByPlid_PrevAndNext(session, layoutRevision, plid,
868 orderByComparator, false);
869
870 return array;
871 }
872 catch (Exception e) {
873 throw processException(e);
874 }
875 finally {
876 closeSession(session);
877 }
878 }
879
880 protected LayoutRevision getByPlid_PrevAndNext(Session session,
881 LayoutRevision layoutRevision, long plid,
882 OrderByComparator orderByComparator, boolean previous) {
883 StringBundler query = null;
884
885 if (orderByComparator != null) {
886 query = new StringBundler(6 +
887 (orderByComparator.getOrderByFields().length * 6));
888 }
889 else {
890 query = new StringBundler(3);
891 }
892
893 query.append(_SQL_SELECT_LAYOUTREVISION_WHERE);
894
895 query.append(_FINDER_COLUMN_PLID_PLID_2);
896
897 if (orderByComparator != null) {
898 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
899
900 if (orderByConditionFields.length > 0) {
901 query.append(WHERE_AND);
902 }
903
904 for (int i = 0; i < orderByConditionFields.length; i++) {
905 query.append(_ORDER_BY_ENTITY_ALIAS);
906 query.append(orderByConditionFields[i]);
907
908 if ((i + 1) < orderByConditionFields.length) {
909 if (orderByComparator.isAscending() ^ previous) {
910 query.append(WHERE_GREATER_THAN_HAS_NEXT);
911 }
912 else {
913 query.append(WHERE_LESSER_THAN_HAS_NEXT);
914 }
915 }
916 else {
917 if (orderByComparator.isAscending() ^ previous) {
918 query.append(WHERE_GREATER_THAN);
919 }
920 else {
921 query.append(WHERE_LESSER_THAN);
922 }
923 }
924 }
925
926 query.append(ORDER_BY_CLAUSE);
927
928 String[] orderByFields = orderByComparator.getOrderByFields();
929
930 for (int i = 0; i < orderByFields.length; i++) {
931 query.append(_ORDER_BY_ENTITY_ALIAS);
932 query.append(orderByFields[i]);
933
934 if ((i + 1) < orderByFields.length) {
935 if (orderByComparator.isAscending() ^ previous) {
936 query.append(ORDER_BY_ASC_HAS_NEXT);
937 }
938 else {
939 query.append(ORDER_BY_DESC_HAS_NEXT);
940 }
941 }
942 else {
943 if (orderByComparator.isAscending() ^ previous) {
944 query.append(ORDER_BY_ASC);
945 }
946 else {
947 query.append(ORDER_BY_DESC);
948 }
949 }
950 }
951 }
952 else {
953 query.append(LayoutRevisionModelImpl.ORDER_BY_JPQL);
954 }
955
956 String sql = query.toString();
957
958 Query q = session.createQuery(sql);
959
960 q.setFirstResult(0);
961 q.setMaxResults(2);
962
963 QueryPos qPos = QueryPos.getInstance(q);
964
965 qPos.add(plid);
966
967 if (orderByComparator != null) {
968 Object[] values = orderByComparator.getOrderByConditionValues(layoutRevision);
969
970 for (Object value : values) {
971 qPos.add(value);
972 }
973 }
974
975 List<LayoutRevision> list = q.list();
976
977 if (list.size() == 2) {
978 return list.get(1);
979 }
980 else {
981 return null;
982 }
983 }
984
985
991 public void removeByPlid(long plid) throws SystemException {
992 for (LayoutRevision layoutRevision : findByPlid(plid,
993 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
994 remove(layoutRevision);
995 }
996 }
997
998
1005 public int countByPlid(long plid) throws SystemException {
1006 FinderPath finderPath = FINDER_PATH_COUNT_BY_PLID;
1007
1008 Object[] finderArgs = new Object[] { plid };
1009
1010 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1011 this);
1012
1013 if (count == null) {
1014 StringBundler query = new StringBundler(2);
1015
1016 query.append(_SQL_COUNT_LAYOUTREVISION_WHERE);
1017
1018 query.append(_FINDER_COLUMN_PLID_PLID_2);
1019
1020 String sql = query.toString();
1021
1022 Session session = null;
1023
1024 try {
1025 session = openSession();
1026
1027 Query q = session.createQuery(sql);
1028
1029 QueryPos qPos = QueryPos.getInstance(q);
1030
1031 qPos.add(plid);
1032
1033 count = (Long)q.uniqueResult();
1034
1035 FinderCacheUtil.putResult(finderPath, finderArgs, count);
1036 }
1037 catch (Exception e) {
1038 FinderCacheUtil.removeResult(finderPath, finderArgs);
1039
1040 throw processException(e);
1041 }
1042 finally {
1043 closeSession(session);
1044 }
1045 }
1046
1047 return count.intValue();
1048 }
1049
1050 private static final String _FINDER_COLUMN_PLID_PLID_2 = "layoutRevision.plid = ?";
1051 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_L_H = new FinderPath(LayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
1052 LayoutRevisionModelImpl.FINDER_CACHE_ENABLED,
1053 LayoutRevisionImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
1054 "findByL_H",
1055 new String[] {
1056 Long.class.getName(), Boolean.class.getName(),
1057
1058 Integer.class.getName(), Integer.class.getName(),
1059 OrderByComparator.class.getName()
1060 });
1061 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_H = new FinderPath(LayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
1062 LayoutRevisionModelImpl.FINDER_CACHE_ENABLED,
1063 LayoutRevisionImpl.class,
1064 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByL_H",
1065 new String[] { Long.class.getName(), Boolean.class.getName() },
1066 LayoutRevisionModelImpl.LAYOUTSETBRANCHID_COLUMN_BITMASK |
1067 LayoutRevisionModelImpl.HEAD_COLUMN_BITMASK |
1068 LayoutRevisionModelImpl.MODIFIEDDATE_COLUMN_BITMASK);
1069 public static final FinderPath FINDER_PATH_COUNT_BY_L_H = new FinderPath(LayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
1070 LayoutRevisionModelImpl.FINDER_CACHE_ENABLED, Long.class,
1071 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByL_H",
1072 new String[] { Long.class.getName(), Boolean.class.getName() });
1073
1074
1082 public List<LayoutRevision> findByL_H(long layoutSetBranchId, boolean head)
1083 throws SystemException {
1084 return findByL_H(layoutSetBranchId, head, QueryUtil.ALL_POS,
1085 QueryUtil.ALL_POS, null);
1086 }
1087
1088
1102 public List<LayoutRevision> findByL_H(long layoutSetBranchId, boolean head,
1103 int start, int end) throws SystemException {
1104 return findByL_H(layoutSetBranchId, head, start, end, null);
1105 }
1106
1107
1122 public List<LayoutRevision> findByL_H(long layoutSetBranchId, boolean head,
1123 int start, int end, OrderByComparator orderByComparator)
1124 throws SystemException {
1125 boolean pagination = true;
1126 FinderPath finderPath = null;
1127 Object[] finderArgs = null;
1128
1129 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1130 (orderByComparator == null)) {
1131 pagination = false;
1132 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_H;
1133 finderArgs = new Object[] { layoutSetBranchId, head };
1134 }
1135 else {
1136 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_L_H;
1137 finderArgs = new Object[] {
1138 layoutSetBranchId, head,
1139
1140 start, end, orderByComparator
1141 };
1142 }
1143
1144 List<LayoutRevision> list = (List<LayoutRevision>)FinderCacheUtil.getResult(finderPath,
1145 finderArgs, this);
1146
1147 if ((list != null) && !list.isEmpty()) {
1148 for (LayoutRevision layoutRevision : list) {
1149 if ((layoutSetBranchId != layoutRevision.getLayoutSetBranchId()) ||
1150 (head != layoutRevision.getHead())) {
1151 list = null;
1152
1153 break;
1154 }
1155 }
1156 }
1157
1158 if (list == null) {
1159 StringBundler query = null;
1160
1161 if (orderByComparator != null) {
1162 query = new StringBundler(4 +
1163 (orderByComparator.getOrderByFields().length * 3));
1164 }
1165 else {
1166 query = new StringBundler(4);
1167 }
1168
1169 query.append(_SQL_SELECT_LAYOUTREVISION_WHERE);
1170
1171 query.append(_FINDER_COLUMN_L_H_LAYOUTSETBRANCHID_2);
1172
1173 query.append(_FINDER_COLUMN_L_H_HEAD_2);
1174
1175 if (orderByComparator != null) {
1176 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1177 orderByComparator);
1178 }
1179 else
1180 if (pagination) {
1181 query.append(LayoutRevisionModelImpl.ORDER_BY_JPQL);
1182 }
1183
1184 String sql = query.toString();
1185
1186 Session session = null;
1187
1188 try {
1189 session = openSession();
1190
1191 Query q = session.createQuery(sql);
1192
1193 QueryPos qPos = QueryPos.getInstance(q);
1194
1195 qPos.add(layoutSetBranchId);
1196
1197 qPos.add(head);
1198
1199 if (!pagination) {
1200 list = (List<LayoutRevision>)QueryUtil.list(q,
1201 getDialect(), start, end, false);
1202
1203 Collections.sort(list);
1204
1205 list = new UnmodifiableList<LayoutRevision>(list);
1206 }
1207 else {
1208 list = (List<LayoutRevision>)QueryUtil.list(q,
1209 getDialect(), start, end);
1210 }
1211
1212 cacheResult(list);
1213
1214 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1215 }
1216 catch (Exception e) {
1217 FinderCacheUtil.removeResult(finderPath, finderArgs);
1218
1219 throw processException(e);
1220 }
1221 finally {
1222 closeSession(session);
1223 }
1224 }
1225
1226 return list;
1227 }
1228
1229
1239 public LayoutRevision findByL_H_First(long layoutSetBranchId, boolean head,
1240 OrderByComparator orderByComparator)
1241 throws NoSuchLayoutRevisionException, SystemException {
1242 LayoutRevision layoutRevision = fetchByL_H_First(layoutSetBranchId,
1243 head, orderByComparator);
1244
1245 if (layoutRevision != null) {
1246 return layoutRevision;
1247 }
1248
1249 StringBundler msg = new StringBundler(6);
1250
1251 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1252
1253 msg.append("layoutSetBranchId=");
1254 msg.append(layoutSetBranchId);
1255
1256 msg.append(", head=");
1257 msg.append(head);
1258
1259 msg.append(StringPool.CLOSE_CURLY_BRACE);
1260
1261 throw new NoSuchLayoutRevisionException(msg.toString());
1262 }
1263
1264
1273 public LayoutRevision fetchByL_H_First(long layoutSetBranchId,
1274 boolean head, OrderByComparator orderByComparator)
1275 throws SystemException {
1276 List<LayoutRevision> list = findByL_H(layoutSetBranchId, head, 0, 1,
1277 orderByComparator);
1278
1279 if (!list.isEmpty()) {
1280 return list.get(0);
1281 }
1282
1283 return null;
1284 }
1285
1286
1296 public LayoutRevision findByL_H_Last(long layoutSetBranchId, boolean head,
1297 OrderByComparator orderByComparator)
1298 throws NoSuchLayoutRevisionException, SystemException {
1299 LayoutRevision layoutRevision = fetchByL_H_Last(layoutSetBranchId,
1300 head, orderByComparator);
1301
1302 if (layoutRevision != null) {
1303 return layoutRevision;
1304 }
1305
1306 StringBundler msg = new StringBundler(6);
1307
1308 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1309
1310 msg.append("layoutSetBranchId=");
1311 msg.append(layoutSetBranchId);
1312
1313 msg.append(", head=");
1314 msg.append(head);
1315
1316 msg.append(StringPool.CLOSE_CURLY_BRACE);
1317
1318 throw new NoSuchLayoutRevisionException(msg.toString());
1319 }
1320
1321
1330 public LayoutRevision fetchByL_H_Last(long layoutSetBranchId, boolean head,
1331 OrderByComparator orderByComparator) throws SystemException {
1332 int count = countByL_H(layoutSetBranchId, head);
1333
1334 List<LayoutRevision> list = findByL_H(layoutSetBranchId, head,
1335 count - 1, count, orderByComparator);
1336
1337 if (!list.isEmpty()) {
1338 return list.get(0);
1339 }
1340
1341 return null;
1342 }
1343
1344
1355 public LayoutRevision[] findByL_H_PrevAndNext(long layoutRevisionId,
1356 long layoutSetBranchId, boolean head,
1357 OrderByComparator orderByComparator)
1358 throws NoSuchLayoutRevisionException, SystemException {
1359 LayoutRevision layoutRevision = findByPrimaryKey(layoutRevisionId);
1360
1361 Session session = null;
1362
1363 try {
1364 session = openSession();
1365
1366 LayoutRevision[] array = new LayoutRevisionImpl[3];
1367
1368 array[0] = getByL_H_PrevAndNext(session, layoutRevision,
1369 layoutSetBranchId, head, orderByComparator, true);
1370
1371 array[1] = layoutRevision;
1372
1373 array[2] = getByL_H_PrevAndNext(session, layoutRevision,
1374 layoutSetBranchId, head, orderByComparator, false);
1375
1376 return array;
1377 }
1378 catch (Exception e) {
1379 throw processException(e);
1380 }
1381 finally {
1382 closeSession(session);
1383 }
1384 }
1385
1386 protected LayoutRevision getByL_H_PrevAndNext(Session session,
1387 LayoutRevision layoutRevision, long layoutSetBranchId, boolean head,
1388 OrderByComparator orderByComparator, boolean previous) {
1389 StringBundler query = null;
1390
1391 if (orderByComparator != null) {
1392 query = new StringBundler(6 +
1393 (orderByComparator.getOrderByFields().length * 6));
1394 }
1395 else {
1396 query = new StringBundler(3);
1397 }
1398
1399 query.append(_SQL_SELECT_LAYOUTREVISION_WHERE);
1400
1401 query.append(_FINDER_COLUMN_L_H_LAYOUTSETBRANCHID_2);
1402
1403 query.append(_FINDER_COLUMN_L_H_HEAD_2);
1404
1405 if (orderByComparator != null) {
1406 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1407
1408 if (orderByConditionFields.length > 0) {
1409 query.append(WHERE_AND);
1410 }
1411
1412 for (int i = 0; i < orderByConditionFields.length; i++) {
1413 query.append(_ORDER_BY_ENTITY_ALIAS);
1414 query.append(orderByConditionFields[i]);
1415
1416 if ((i + 1) < orderByConditionFields.length) {
1417 if (orderByComparator.isAscending() ^ previous) {
1418 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1419 }
1420 else {
1421 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1422 }
1423 }
1424 else {
1425 if (orderByComparator.isAscending() ^ previous) {
1426 query.append(WHERE_GREATER_THAN);
1427 }
1428 else {
1429 query.append(WHERE_LESSER_THAN);
1430 }
1431 }
1432 }
1433
1434 query.append(ORDER_BY_CLAUSE);
1435
1436 String[] orderByFields = orderByComparator.getOrderByFields();
1437
1438 for (int i = 0; i < orderByFields.length; i++) {
1439 query.append(_ORDER_BY_ENTITY_ALIAS);
1440 query.append(orderByFields[i]);
1441
1442 if ((i + 1) < orderByFields.length) {
1443 if (orderByComparator.isAscending() ^ previous) {
1444 query.append(ORDER_BY_ASC_HAS_NEXT);
1445 }
1446 else {
1447 query.append(ORDER_BY_DESC_HAS_NEXT);
1448 }
1449 }
1450 else {
1451 if (orderByComparator.isAscending() ^ previous) {
1452 query.append(ORDER_BY_ASC);
1453 }
1454 else {
1455 query.append(ORDER_BY_DESC);
1456 }
1457 }
1458 }
1459 }
1460 else {
1461 query.append(LayoutRevisionModelImpl.ORDER_BY_JPQL);
1462 }
1463
1464 String sql = query.toString();
1465
1466 Query q = session.createQuery(sql);
1467
1468 q.setFirstResult(0);
1469 q.setMaxResults(2);
1470
1471 QueryPos qPos = QueryPos.getInstance(q);
1472
1473 qPos.add(layoutSetBranchId);
1474
1475 qPos.add(head);
1476
1477 if (orderByComparator != null) {
1478 Object[] values = orderByComparator.getOrderByConditionValues(layoutRevision);
1479
1480 for (Object value : values) {
1481 qPos.add(value);
1482 }
1483 }
1484
1485 List<LayoutRevision> list = q.list();
1486
1487 if (list.size() == 2) {
1488 return list.get(1);
1489 }
1490 else {
1491 return null;
1492 }
1493 }
1494
1495
1502 public void removeByL_H(long layoutSetBranchId, boolean head)
1503 throws SystemException {
1504 for (LayoutRevision layoutRevision : findByL_H(layoutSetBranchId, head,
1505 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1506 remove(layoutRevision);
1507 }
1508 }
1509
1510
1518 public int countByL_H(long layoutSetBranchId, boolean head)
1519 throws SystemException {
1520 FinderPath finderPath = FINDER_PATH_COUNT_BY_L_H;
1521
1522 Object[] finderArgs = new Object[] { layoutSetBranchId, head };
1523
1524 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1525 this);
1526
1527 if (count == null) {
1528 StringBundler query = new StringBundler(3);
1529
1530 query.append(_SQL_COUNT_LAYOUTREVISION_WHERE);
1531
1532 query.append(_FINDER_COLUMN_L_H_LAYOUTSETBRANCHID_2);
1533
1534 query.append(_FINDER_COLUMN_L_H_HEAD_2);
1535
1536 String sql = query.toString();
1537
1538 Session session = null;
1539
1540 try {
1541 session = openSession();
1542
1543 Query q = session.createQuery(sql);
1544
1545 QueryPos qPos = QueryPos.getInstance(q);
1546
1547 qPos.add(layoutSetBranchId);
1548
1549 qPos.add(head);
1550
1551 count = (Long)q.uniqueResult();
1552
1553 FinderCacheUtil.putResult(finderPath, finderArgs, count);
1554 }
1555 catch (Exception e) {
1556 FinderCacheUtil.removeResult(finderPath, finderArgs);
1557
1558 throw processException(e);
1559 }
1560 finally {
1561 closeSession(session);
1562 }
1563 }
1564
1565 return count.intValue();
1566 }
1567
1568 private static final String _FINDER_COLUMN_L_H_LAYOUTSETBRANCHID_2 = "layoutRevision.layoutSetBranchId = ? AND ";
1569 private static final String _FINDER_COLUMN_L_H_HEAD_2 = "layoutRevision.head = ?";
1570 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_L_P = new FinderPath(LayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
1571 LayoutRevisionModelImpl.FINDER_CACHE_ENABLED,
1572 LayoutRevisionImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
1573 "findByL_P",
1574 new String[] {
1575 Long.class.getName(), Long.class.getName(),
1576
1577 Integer.class.getName(), Integer.class.getName(),
1578 OrderByComparator.class.getName()
1579 });
1580 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_P = new FinderPath(LayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
1581 LayoutRevisionModelImpl.FINDER_CACHE_ENABLED,
1582 LayoutRevisionImpl.class,
1583 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByL_P",
1584 new String[] { Long.class.getName(), Long.class.getName() },
1585 LayoutRevisionModelImpl.LAYOUTSETBRANCHID_COLUMN_BITMASK |
1586 LayoutRevisionModelImpl.PLID_COLUMN_BITMASK |
1587 LayoutRevisionModelImpl.MODIFIEDDATE_COLUMN_BITMASK);
1588 public static final FinderPath FINDER_PATH_COUNT_BY_L_P = new FinderPath(LayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
1589 LayoutRevisionModelImpl.FINDER_CACHE_ENABLED, Long.class,
1590 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByL_P",
1591 new String[] { Long.class.getName(), Long.class.getName() });
1592
1593
1601 public List<LayoutRevision> findByL_P(long layoutSetBranchId, long plid)
1602 throws SystemException {
1603 return findByL_P(layoutSetBranchId, plid, QueryUtil.ALL_POS,
1604 QueryUtil.ALL_POS, null);
1605 }
1606
1607
1621 public List<LayoutRevision> findByL_P(long layoutSetBranchId, long plid,
1622 int start, int end) throws SystemException {
1623 return findByL_P(layoutSetBranchId, plid, start, end, null);
1624 }
1625
1626
1641 public List<LayoutRevision> findByL_P(long layoutSetBranchId, long plid,
1642 int start, int end, OrderByComparator orderByComparator)
1643 throws SystemException {
1644 boolean pagination = true;
1645 FinderPath finderPath = null;
1646 Object[] finderArgs = null;
1647
1648 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1649 (orderByComparator == null)) {
1650 pagination = false;
1651 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_P;
1652 finderArgs = new Object[] { layoutSetBranchId, plid };
1653 }
1654 else {
1655 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_L_P;
1656 finderArgs = new Object[] {
1657 layoutSetBranchId, plid,
1658
1659 start, end, orderByComparator
1660 };
1661 }
1662
1663 List<LayoutRevision> list = (List<LayoutRevision>)FinderCacheUtil.getResult(finderPath,
1664 finderArgs, this);
1665
1666 if ((list != null) && !list.isEmpty()) {
1667 for (LayoutRevision layoutRevision : list) {
1668 if ((layoutSetBranchId != layoutRevision.getLayoutSetBranchId()) ||
1669 (plid != layoutRevision.getPlid())) {
1670 list = null;
1671
1672 break;
1673 }
1674 }
1675 }
1676
1677 if (list == null) {
1678 StringBundler query = null;
1679
1680 if (orderByComparator != null) {
1681 query = new StringBundler(4 +
1682 (orderByComparator.getOrderByFields().length * 3));
1683 }
1684 else {
1685 query = new StringBundler(4);
1686 }
1687
1688 query.append(_SQL_SELECT_LAYOUTREVISION_WHERE);
1689
1690 query.append(_FINDER_COLUMN_L_P_LAYOUTSETBRANCHID_2);
1691
1692 query.append(_FINDER_COLUMN_L_P_PLID_2);
1693
1694 if (orderByComparator != null) {
1695 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1696 orderByComparator);
1697 }
1698 else
1699 if (pagination) {
1700 query.append(LayoutRevisionModelImpl.ORDER_BY_JPQL);
1701 }
1702
1703 String sql = query.toString();
1704
1705 Session session = null;
1706
1707 try {
1708 session = openSession();
1709
1710 Query q = session.createQuery(sql);
1711
1712 QueryPos qPos = QueryPos.getInstance(q);
1713
1714 qPos.add(layoutSetBranchId);
1715
1716 qPos.add(plid);
1717
1718 if (!pagination) {
1719 list = (List<LayoutRevision>)QueryUtil.list(q,
1720 getDialect(), start, end, false);
1721
1722 Collections.sort(list);
1723
1724 list = new UnmodifiableList<LayoutRevision>(list);
1725 }
1726 else {
1727 list = (List<LayoutRevision>)QueryUtil.list(q,
1728 getDialect(), start, end);
1729 }
1730
1731 cacheResult(list);
1732
1733 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1734 }
1735 catch (Exception e) {
1736 FinderCacheUtil.removeResult(finderPath, finderArgs);
1737
1738 throw processException(e);
1739 }
1740 finally {
1741 closeSession(session);
1742 }
1743 }
1744
1745 return list;
1746 }
1747
1748
1758 public LayoutRevision findByL_P_First(long layoutSetBranchId, long plid,
1759 OrderByComparator orderByComparator)
1760 throws NoSuchLayoutRevisionException, SystemException {
1761 LayoutRevision layoutRevision = fetchByL_P_First(layoutSetBranchId,
1762 plid, orderByComparator);
1763
1764 if (layoutRevision != null) {
1765 return layoutRevision;
1766 }
1767
1768 StringBundler msg = new StringBundler(6);
1769
1770 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1771
1772 msg.append("layoutSetBranchId=");
1773 msg.append(layoutSetBranchId);
1774
1775 msg.append(", plid=");
1776 msg.append(plid);
1777
1778 msg.append(StringPool.CLOSE_CURLY_BRACE);
1779
1780 throw new NoSuchLayoutRevisionException(msg.toString());
1781 }
1782
1783
1792 public LayoutRevision fetchByL_P_First(long layoutSetBranchId, long plid,
1793 OrderByComparator orderByComparator) throws SystemException {
1794 List<LayoutRevision> list = findByL_P(layoutSetBranchId, plid, 0, 1,
1795 orderByComparator);
1796
1797 if (!list.isEmpty()) {
1798 return list.get(0);
1799 }
1800
1801 return null;
1802 }
1803
1804
1814 public LayoutRevision findByL_P_Last(long layoutSetBranchId, long plid,
1815 OrderByComparator orderByComparator)
1816 throws NoSuchLayoutRevisionException, SystemException {
1817 LayoutRevision layoutRevision = fetchByL_P_Last(layoutSetBranchId,
1818 plid, orderByComparator);
1819
1820 if (layoutRevision != null) {
1821 return layoutRevision;
1822 }
1823
1824 StringBundler msg = new StringBundler(6);
1825
1826 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1827
1828 msg.append("layoutSetBranchId=");
1829 msg.append(layoutSetBranchId);
1830
1831 msg.append(", plid=");
1832 msg.append(plid);
1833
1834 msg.append(StringPool.CLOSE_CURLY_BRACE);
1835
1836 throw new NoSuchLayoutRevisionException(msg.toString());
1837 }
1838
1839
1848 public LayoutRevision fetchByL_P_Last(long layoutSetBranchId, long plid,
1849 OrderByComparator orderByComparator) throws SystemException {
1850 int count = countByL_P(layoutSetBranchId, plid);
1851
1852 List<LayoutRevision> list = findByL_P(layoutSetBranchId, plid,
1853 count - 1, count, orderByComparator);
1854
1855 if (!list.isEmpty()) {
1856 return list.get(0);
1857 }
1858
1859 return null;
1860 }
1861
1862
1873 public LayoutRevision[] findByL_P_PrevAndNext(long layoutRevisionId,
1874 long layoutSetBranchId, long plid, OrderByComparator orderByComparator)
1875 throws NoSuchLayoutRevisionException, SystemException {
1876 LayoutRevision layoutRevision = findByPrimaryKey(layoutRevisionId);
1877
1878 Session session = null;
1879
1880 try {
1881 session = openSession();
1882
1883 LayoutRevision[] array = new LayoutRevisionImpl[3];
1884
1885 array[0] = getByL_P_PrevAndNext(session, layoutRevision,
1886 layoutSetBranchId, plid, orderByComparator, true);
1887
1888 array[1] = layoutRevision;
1889
1890 array[2] = getByL_P_PrevAndNext(session, layoutRevision,
1891 layoutSetBranchId, plid, orderByComparator, false);
1892
1893 return array;
1894 }
1895 catch (Exception e) {
1896 throw processException(e);
1897 }
1898 finally {
1899 closeSession(session);
1900 }
1901 }
1902
1903 protected LayoutRevision getByL_P_PrevAndNext(Session session,
1904 LayoutRevision layoutRevision, long layoutSetBranchId, long plid,
1905 OrderByComparator orderByComparator, boolean previous) {
1906 StringBundler query = null;
1907
1908 if (orderByComparator != null) {
1909 query = new StringBundler(6 +
1910 (orderByComparator.getOrderByFields().length * 6));
1911 }
1912 else {
1913 query = new StringBundler(3);
1914 }
1915
1916 query.append(_SQL_SELECT_LAYOUTREVISION_WHERE);
1917
1918 query.append(_FINDER_COLUMN_L_P_LAYOUTSETBRANCHID_2);
1919
1920 query.append(_FINDER_COLUMN_L_P_PLID_2);
1921
1922 if (orderByComparator != null) {
1923 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1924
1925 if (orderByConditionFields.length > 0) {
1926 query.append(WHERE_AND);
1927 }
1928
1929 for (int i = 0; i < orderByConditionFields.length; i++) {
1930 query.append(_ORDER_BY_ENTITY_ALIAS);
1931 query.append(orderByConditionFields[i]);
1932
1933 if ((i + 1) < orderByConditionFields.length) {
1934 if (orderByComparator.isAscending() ^ previous) {
1935 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1936 }
1937 else {
1938 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1939 }
1940 }
1941 else {
1942 if (orderByComparator.isAscending() ^ previous) {
1943 query.append(WHERE_GREATER_THAN);
1944 }
1945 else {
1946 query.append(WHERE_LESSER_THAN);
1947 }
1948 }
1949 }
1950
1951 query.append(ORDER_BY_CLAUSE);
1952
1953 String[] orderByFields = orderByComparator.getOrderByFields();
1954
1955 for (int i = 0; i < orderByFields.length; i++) {
1956 query.append(_ORDER_BY_ENTITY_ALIAS);
1957 query.append(orderByFields[i]);
1958
1959 if ((i + 1) < orderByFields.length) {
1960 if (orderByComparator.isAscending() ^ previous) {
1961 query.append(ORDER_BY_ASC_HAS_NEXT);
1962 }
1963 else {
1964 query.append(ORDER_BY_DESC_HAS_NEXT);
1965 }
1966 }
1967 else {
1968 if (orderByComparator.isAscending() ^ previous) {
1969 query.append(ORDER_BY_ASC);
1970 }
1971 else {
1972 query.append(ORDER_BY_DESC);
1973 }
1974 }
1975 }
1976 }
1977 else {
1978 query.append(LayoutRevisionModelImpl.ORDER_BY_JPQL);
1979 }
1980
1981 String sql = query.toString();
1982
1983 Query q = session.createQuery(sql);
1984
1985 q.setFirstResult(0);
1986 q.setMaxResults(2);
1987
1988 QueryPos qPos = QueryPos.getInstance(q);
1989
1990 qPos.add(layoutSetBranchId);
1991
1992 qPos.add(plid);
1993
1994 if (orderByComparator != null) {
1995 Object[] values = orderByComparator.getOrderByConditionValues(layoutRevision);
1996
1997 for (Object value : values) {
1998 qPos.add(value);
1999 }
2000 }
2001
2002 List<LayoutRevision> list = q.list();
2003
2004 if (list.size() == 2) {
2005 return list.get(1);
2006 }
2007 else {
2008 return null;
2009 }
2010 }
2011
2012
2019 public void removeByL_P(long layoutSetBranchId, long plid)
2020 throws SystemException {
2021 for (LayoutRevision layoutRevision : findByL_P(layoutSetBranchId, plid,
2022 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
2023 remove(layoutRevision);
2024 }
2025 }
2026
2027
2035 public int countByL_P(long layoutSetBranchId, long plid)
2036 throws SystemException {
2037 FinderPath finderPath = FINDER_PATH_COUNT_BY_L_P;
2038
2039 Object[] finderArgs = new Object[] { layoutSetBranchId, plid };
2040
2041 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
2042 this);
2043
2044 if (count == null) {
2045 StringBundler query = new StringBundler(3);
2046
2047 query.append(_SQL_COUNT_LAYOUTREVISION_WHERE);
2048
2049 query.append(_FINDER_COLUMN_L_P_LAYOUTSETBRANCHID_2);
2050
2051 query.append(_FINDER_COLUMN_L_P_PLID_2);
2052
2053 String sql = query.toString();
2054
2055 Session session = null;
2056
2057 try {
2058 session = openSession();
2059
2060 Query q = session.createQuery(sql);
2061
2062 QueryPos qPos = QueryPos.getInstance(q);
2063
2064 qPos.add(layoutSetBranchId);
2065
2066 qPos.add(plid);
2067
2068 count = (Long)q.uniqueResult();
2069
2070 FinderCacheUtil.putResult(finderPath, finderArgs, count);
2071 }
2072 catch (Exception e) {
2073 FinderCacheUtil.removeResult(finderPath, finderArgs);
2074
2075 throw processException(e);
2076 }
2077 finally {
2078 closeSession(session);
2079 }
2080 }
2081
2082 return count.intValue();
2083 }
2084
2085 private static final String _FINDER_COLUMN_L_P_LAYOUTSETBRANCHID_2 = "layoutRevision.layoutSetBranchId = ? AND ";
2086 private static final String _FINDER_COLUMN_L_P_PLID_2 = "layoutRevision.plid = ?";
2087 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_L_S = new FinderPath(LayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
2088 LayoutRevisionModelImpl.FINDER_CACHE_ENABLED,
2089 LayoutRevisionImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
2090 "findByL_S",
2091 new String[] {
2092 Long.class.getName(), Integer.class.getName(),
2093
2094 Integer.class.getName(), Integer.class.getName(),
2095 OrderByComparator.class.getName()
2096 });
2097 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_S = new FinderPath(LayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
2098 LayoutRevisionModelImpl.FINDER_CACHE_ENABLED,
2099 LayoutRevisionImpl.class,
2100 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByL_S",
2101 new String[] { Long.class.getName(), Integer.class.getName() },
2102 LayoutRevisionModelImpl.LAYOUTSETBRANCHID_COLUMN_BITMASK |
2103 LayoutRevisionModelImpl.STATUS_COLUMN_BITMASK |
2104 LayoutRevisionModelImpl.MODIFIEDDATE_COLUMN_BITMASK);
2105 public static final FinderPath FINDER_PATH_COUNT_BY_L_S = new FinderPath(LayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
2106 LayoutRevisionModelImpl.FINDER_CACHE_ENABLED, Long.class,
2107 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByL_S",
2108 new String[] { Long.class.getName(), Integer.class.getName() });
2109
2110
2118 public List<LayoutRevision> findByL_S(long layoutSetBranchId, int status)
2119 throws SystemException {
2120 return findByL_S(layoutSetBranchId, status, QueryUtil.ALL_POS,
2121 QueryUtil.ALL_POS, null);
2122 }
2123
2124
2138 public List<LayoutRevision> findByL_S(long layoutSetBranchId, int status,
2139 int start, int end) throws SystemException {
2140 return findByL_S(layoutSetBranchId, status, start, end, null);
2141 }
2142
2143
2158 public List<LayoutRevision> findByL_S(long layoutSetBranchId, int status,
2159 int start, int end, OrderByComparator orderByComparator)
2160 throws SystemException {
2161 boolean pagination = true;
2162 FinderPath finderPath = null;
2163 Object[] finderArgs = null;
2164
2165 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2166 (orderByComparator == null)) {
2167 pagination = false;
2168 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_S;
2169 finderArgs = new Object[] { layoutSetBranchId, status };
2170 }
2171 else {
2172 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_L_S;
2173 finderArgs = new Object[] {
2174 layoutSetBranchId, status,
2175
2176 start, end, orderByComparator
2177 };
2178 }
2179
2180 List<LayoutRevision> list = (List<LayoutRevision>)FinderCacheUtil.getResult(finderPath,
2181 finderArgs, this);
2182
2183 if ((list != null) && !list.isEmpty()) {
2184 for (LayoutRevision layoutRevision : list) {
2185 if ((layoutSetBranchId != layoutRevision.getLayoutSetBranchId()) ||
2186 (status != layoutRevision.getStatus())) {
2187 list = null;
2188
2189 break;
2190 }
2191 }
2192 }
2193
2194 if (list == null) {
2195 StringBundler query = null;
2196
2197 if (orderByComparator != null) {
2198 query = new StringBundler(4 +
2199 (orderByComparator.getOrderByFields().length * 3));
2200 }
2201 else {
2202 query = new StringBundler(4);
2203 }
2204
2205 query.append(_SQL_SELECT_LAYOUTREVISION_WHERE);
2206
2207 query.append(_FINDER_COLUMN_L_S_LAYOUTSETBRANCHID_2);
2208
2209 query.append(_FINDER_COLUMN_L_S_STATUS_2);
2210
2211 if (orderByComparator != null) {
2212 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2213 orderByComparator);
2214 }
2215 else
2216 if (pagination) {
2217 query.append(LayoutRevisionModelImpl.ORDER_BY_JPQL);
2218 }
2219
2220 String sql = query.toString();
2221
2222 Session session = null;
2223
2224 try {
2225 session = openSession();
2226
2227 Query q = session.createQuery(sql);
2228
2229 QueryPos qPos = QueryPos.getInstance(q);
2230
2231 qPos.add(layoutSetBranchId);
2232
2233 qPos.add(status);
2234
2235 if (!pagination) {
2236 list = (List<LayoutRevision>)QueryUtil.list(q,
2237 getDialect(), start, end, false);
2238
2239 Collections.sort(list);
2240
2241 list = new UnmodifiableList<LayoutRevision>(list);
2242 }
2243 else {
2244 list = (List<LayoutRevision>)QueryUtil.list(q,
2245 getDialect(), start, end);
2246 }
2247
2248 cacheResult(list);
2249
2250 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2251 }
2252 catch (Exception e) {
2253 FinderCacheUtil.removeResult(finderPath, finderArgs);
2254
2255 throw processException(e);
2256 }
2257 finally {
2258 closeSession(session);
2259 }
2260 }
2261
2262 return list;
2263 }
2264
2265
2275 public LayoutRevision findByL_S_First(long layoutSetBranchId, int status,
2276 OrderByComparator orderByComparator)
2277 throws NoSuchLayoutRevisionException, SystemException {
2278 LayoutRevision layoutRevision = fetchByL_S_First(layoutSetBranchId,
2279 status, orderByComparator);
2280
2281 if (layoutRevision != null) {
2282 return layoutRevision;
2283 }
2284
2285 StringBundler msg = new StringBundler(6);
2286
2287 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2288
2289 msg.append("layoutSetBranchId=");
2290 msg.append(layoutSetBranchId);
2291
2292 msg.append(", status=");
2293 msg.append(status);
2294
2295 msg.append(StringPool.CLOSE_CURLY_BRACE);
2296
2297 throw new NoSuchLayoutRevisionException(msg.toString());
2298 }
2299
2300
2309 public LayoutRevision fetchByL_S_First(long layoutSetBranchId, int status,
2310 OrderByComparator orderByComparator) throws SystemException {
2311 List<LayoutRevision> list = findByL_S(layoutSetBranchId, status, 0, 1,
2312 orderByComparator);
2313
2314 if (!list.isEmpty()) {
2315 return list.get(0);
2316 }
2317
2318 return null;
2319 }
2320
2321
2331 public LayoutRevision findByL_S_Last(long layoutSetBranchId, int status,
2332 OrderByComparator orderByComparator)
2333 throws NoSuchLayoutRevisionException, SystemException {
2334 LayoutRevision layoutRevision = fetchByL_S_Last(layoutSetBranchId,
2335 status, orderByComparator);
2336
2337 if (layoutRevision != null) {
2338 return layoutRevision;
2339 }
2340
2341 StringBundler msg = new StringBundler(6);
2342
2343 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2344
2345 msg.append("layoutSetBranchId=");
2346 msg.append(layoutSetBranchId);
2347
2348 msg.append(", status=");
2349 msg.append(status);
2350
2351 msg.append(StringPool.CLOSE_CURLY_BRACE);
2352
2353 throw new NoSuchLayoutRevisionException(msg.toString());
2354 }
2355
2356
2365 public LayoutRevision fetchByL_S_Last(long layoutSetBranchId, int status,
2366 OrderByComparator orderByComparator) throws SystemException {
2367 int count = countByL_S(layoutSetBranchId, status);
2368
2369 List<LayoutRevision> list = findByL_S(layoutSetBranchId, status,
2370 count - 1, count, orderByComparator);
2371
2372 if (!list.isEmpty()) {
2373 return list.get(0);
2374 }
2375
2376 return null;
2377 }
2378
2379
2390 public LayoutRevision[] findByL_S_PrevAndNext(long layoutRevisionId,
2391 long layoutSetBranchId, int status, OrderByComparator orderByComparator)
2392 throws NoSuchLayoutRevisionException, SystemException {
2393 LayoutRevision layoutRevision = findByPrimaryKey(layoutRevisionId);
2394
2395 Session session = null;
2396
2397 try {
2398 session = openSession();
2399
2400 LayoutRevision[] array = new LayoutRevisionImpl[3];
2401
2402 array[0] = getByL_S_PrevAndNext(session, layoutRevision,
2403 layoutSetBranchId, status, orderByComparator, true);
2404
2405 array[1] = layoutRevision;
2406
2407 array[2] = getByL_S_PrevAndNext(session, layoutRevision,
2408 layoutSetBranchId, status, orderByComparator, false);
2409
2410 return array;
2411 }
2412 catch (Exception e) {
2413 throw processException(e);
2414 }
2415 finally {
2416 closeSession(session);
2417 }
2418 }
2419
2420 protected LayoutRevision getByL_S_PrevAndNext(Session session,
2421 LayoutRevision layoutRevision, long layoutSetBranchId, int status,
2422 OrderByComparator orderByComparator, boolean previous) {
2423 StringBundler query = null;
2424
2425 if (orderByComparator != null) {
2426 query = new StringBundler(6 +
2427 (orderByComparator.getOrderByFields().length * 6));
2428 }
2429 else {
2430 query = new StringBundler(3);
2431 }
2432
2433 query.append(_SQL_SELECT_LAYOUTREVISION_WHERE);
2434
2435 query.append(_FINDER_COLUMN_L_S_LAYOUTSETBRANCHID_2);
2436
2437 query.append(_FINDER_COLUMN_L_S_STATUS_2);
2438
2439 if (orderByComparator != null) {
2440 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2441
2442 if (orderByConditionFields.length > 0) {
2443 query.append(WHERE_AND);
2444 }
2445
2446 for (int i = 0; i < orderByConditionFields.length; i++) {
2447 query.append(_ORDER_BY_ENTITY_ALIAS);
2448 query.append(orderByConditionFields[i]);
2449
2450 if ((i + 1) < orderByConditionFields.length) {
2451 if (orderByComparator.isAscending() ^ previous) {
2452 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2453 }
2454 else {
2455 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2456 }
2457 }
2458 else {
2459 if (orderByComparator.isAscending() ^ previous) {
2460 query.append(WHERE_GREATER_THAN);
2461 }
2462 else {
2463 query.append(WHERE_LESSER_THAN);
2464 }
2465 }
2466 }
2467
2468 query.append(ORDER_BY_CLAUSE);
2469
2470 String[] orderByFields = orderByComparator.getOrderByFields();
2471
2472 for (int i = 0; i < orderByFields.length; i++) {
2473 query.append(_ORDER_BY_ENTITY_ALIAS);
2474 query.append(orderByFields[i]);
2475
2476 if ((i + 1) < orderByFields.length) {
2477 if (orderByComparator.isAscending() ^ previous) {
2478 query.append(ORDER_BY_ASC_HAS_NEXT);
2479 }
2480 else {
2481 query.append(ORDER_BY_DESC_HAS_NEXT);
2482 }
2483 }
2484 else {
2485 if (orderByComparator.isAscending() ^ previous) {
2486 query.append(ORDER_BY_ASC);
2487 }
2488 else {
2489 query.append(ORDER_BY_DESC);
2490 }
2491 }
2492 }
2493 }
2494 else {
2495 query.append(LayoutRevisionModelImpl.ORDER_BY_JPQL);
2496 }
2497
2498 String sql = query.toString();
2499
2500 Query q = session.createQuery(sql);
2501
2502 q.setFirstResult(0);
2503 q.setMaxResults(2);
2504
2505 QueryPos qPos = QueryPos.getInstance(q);
2506
2507 qPos.add(layoutSetBranchId);
2508
2509 qPos.add(status);
2510
2511 if (orderByComparator != null) {
2512 Object[] values = orderByComparator.getOrderByConditionValues(layoutRevision);
2513
2514 for (Object value : values) {
2515 qPos.add(value);
2516 }
2517 }
2518
2519 List<LayoutRevision> list = q.list();
2520
2521 if (list.size() == 2) {
2522 return list.get(1);
2523 }
2524 else {
2525 return null;
2526 }
2527 }
2528
2529
2536 public void removeByL_S(long layoutSetBranchId, int status)
2537 throws SystemException {
2538 for (LayoutRevision layoutRevision : findByL_S(layoutSetBranchId,
2539 status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
2540 remove(layoutRevision);
2541 }
2542 }
2543
2544
2552 public int countByL_S(long layoutSetBranchId, int status)
2553 throws SystemException {
2554 FinderPath finderPath = FINDER_PATH_COUNT_BY_L_S;
2555
2556 Object[] finderArgs = new Object[] { layoutSetBranchId, status };
2557
2558 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
2559 this);
2560
2561 if (count == null) {
2562 StringBundler query = new StringBundler(3);
2563
2564 query.append(_SQL_COUNT_LAYOUTREVISION_WHERE);
2565
2566 query.append(_FINDER_COLUMN_L_S_LAYOUTSETBRANCHID_2);
2567
2568 query.append(_FINDER_COLUMN_L_S_STATUS_2);
2569
2570 String sql = query.toString();
2571
2572 Session session = null;
2573
2574 try {
2575 session = openSession();
2576
2577 Query q = session.createQuery(sql);
2578
2579 QueryPos qPos = QueryPos.getInstance(q);
2580
2581 qPos.add(layoutSetBranchId);
2582
2583 qPos.add(status);
2584
2585 count = (Long)q.uniqueResult();
2586
2587 FinderCacheUtil.putResult(finderPath, finderArgs, count);
2588 }
2589 catch (Exception e) {
2590 FinderCacheUtil.removeResult(finderPath, finderArgs);
2591
2592 throw processException(e);
2593 }
2594 finally {
2595 closeSession(session);
2596 }
2597 }
2598
2599 return count.intValue();
2600 }
2601
2602 private static final String _FINDER_COLUMN_L_S_LAYOUTSETBRANCHID_2 = "layoutRevision.layoutSetBranchId = ? AND ";
2603 private static final String _FINDER_COLUMN_L_S_STATUS_2 = "layoutRevision.status = ?";
2604 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_H_P = new FinderPath(LayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
2605 LayoutRevisionModelImpl.FINDER_CACHE_ENABLED,
2606 LayoutRevisionImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
2607 "findByH_P",
2608 new String[] {
2609 Boolean.class.getName(), Long.class.getName(),
2610
2611 Integer.class.getName(), Integer.class.getName(),
2612 OrderByComparator.class.getName()
2613 });
2614 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_H_P = new FinderPath(LayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
2615 LayoutRevisionModelImpl.FINDER_CACHE_ENABLED,
2616 LayoutRevisionImpl.class,
2617 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByH_P",
2618 new String[] { Boolean.class.getName(), Long.class.getName() },
2619 LayoutRevisionModelImpl.HEAD_COLUMN_BITMASK |
2620 LayoutRevisionModelImpl.PLID_COLUMN_BITMASK |
2621 LayoutRevisionModelImpl.MODIFIEDDATE_COLUMN_BITMASK);
2622 public static final FinderPath FINDER_PATH_COUNT_BY_H_P = new FinderPath(LayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
2623 LayoutRevisionModelImpl.FINDER_CACHE_ENABLED, Long.class,
2624 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByH_P",
2625 new String[] { Boolean.class.getName(), Long.class.getName() });
2626
2627
2635 public List<LayoutRevision> findByH_P(boolean head, long plid)
2636 throws SystemException {
2637 return findByH_P(head, plid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2638 }
2639
2640
2654 public List<LayoutRevision> findByH_P(boolean head, long plid, int start,
2655 int end) throws SystemException {
2656 return findByH_P(head, plid, start, end, null);
2657 }
2658
2659
2674 public List<LayoutRevision> findByH_P(boolean head, long plid, int start,
2675 int end, OrderByComparator orderByComparator) throws SystemException {
2676 boolean pagination = true;
2677 FinderPath finderPath = null;
2678 Object[] finderArgs = null;
2679
2680 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2681 (orderByComparator == null)) {
2682 pagination = false;
2683 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_H_P;
2684 finderArgs = new Object[] { head, plid };
2685 }
2686 else {
2687 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_H_P;
2688 finderArgs = new Object[] { head, plid, start, end, orderByComparator };
2689 }
2690
2691 List<LayoutRevision> list = (List<LayoutRevision>)FinderCacheUtil.getResult(finderPath,
2692 finderArgs, this);
2693
2694 if ((list != null) && !list.isEmpty()) {
2695 for (LayoutRevision layoutRevision : list) {
2696 if ((head != layoutRevision.getHead()) ||
2697 (plid != layoutRevision.getPlid())) {
2698 list = null;
2699
2700 break;
2701 }
2702 }
2703 }
2704
2705 if (list == null) {
2706 StringBundler query = null;
2707
2708 if (orderByComparator != null) {
2709 query = new StringBundler(4 +
2710 (orderByComparator.getOrderByFields().length * 3));
2711 }
2712 else {
2713 query = new StringBundler(4);
2714 }
2715
2716 query.append(_SQL_SELECT_LAYOUTREVISION_WHERE);
2717
2718 query.append(_FINDER_COLUMN_H_P_HEAD_2);
2719
2720 query.append(_FINDER_COLUMN_H_P_PLID_2);
2721
2722 if (orderByComparator != null) {
2723 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2724 orderByComparator);
2725 }
2726 else
2727 if (pagination) {
2728 query.append(LayoutRevisionModelImpl.ORDER_BY_JPQL);
2729 }
2730
2731 String sql = query.toString();
2732
2733 Session session = null;
2734
2735 try {
2736 session = openSession();
2737
2738 Query q = session.createQuery(sql);
2739
2740 QueryPos qPos = QueryPos.getInstance(q);
2741
2742 qPos.add(head);
2743
2744 qPos.add(plid);
2745
2746 if (!pagination) {
2747 list = (List<LayoutRevision>)QueryUtil.list(q,
2748 getDialect(), start, end, false);
2749
2750 Collections.sort(list);
2751
2752 list = new UnmodifiableList<LayoutRevision>(list);
2753 }
2754 else {
2755 list = (List<LayoutRevision>)QueryUtil.list(q,
2756 getDialect(), start, end);
2757 }
2758
2759 cacheResult(list);
2760
2761 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2762 }
2763 catch (Exception e) {
2764 FinderCacheUtil.removeResult(finderPath, finderArgs);
2765
2766 throw processException(e);
2767 }
2768 finally {
2769 closeSession(session);
2770 }
2771 }
2772
2773 return list;
2774 }
2775
2776
2786 public LayoutRevision findByH_P_First(boolean head, long plid,
2787 OrderByComparator orderByComparator)
2788 throws NoSuchLayoutRevisionException, SystemException {
2789 LayoutRevision layoutRevision = fetchByH_P_First(head, plid,
2790 orderByComparator);
2791
2792 if (layoutRevision != null) {
2793 return layoutRevision;
2794 }
2795
2796 StringBundler msg = new StringBundler(6);
2797
2798 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2799
2800 msg.append("head=");
2801 msg.append(head);
2802
2803 msg.append(", plid=");
2804 msg.append(plid);
2805
2806 msg.append(StringPool.CLOSE_CURLY_BRACE);
2807
2808 throw new NoSuchLayoutRevisionException(msg.toString());
2809 }
2810
2811
2820 public LayoutRevision fetchByH_P_First(boolean head, long plid,
2821 OrderByComparator orderByComparator) throws SystemException {
2822 List<LayoutRevision> list = findByH_P(head, plid, 0, 1,
2823 orderByComparator);
2824
2825 if (!list.isEmpty()) {
2826 return list.get(0);
2827 }
2828
2829 return null;
2830 }
2831
2832
2842 public LayoutRevision findByH_P_Last(boolean head, long plid,
2843 OrderByComparator orderByComparator)
2844 throws NoSuchLayoutRevisionException, SystemException {
2845 LayoutRevision layoutRevision = fetchByH_P_Last(head, plid,
2846 orderByComparator);
2847
2848 if (layoutRevision != null) {
2849 return layoutRevision;
2850 }
2851
2852 StringBundler msg = new StringBundler(6);
2853
2854 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2855
2856 msg.append("head=");
2857 msg.append(head);
2858
2859 msg.append(", plid=");
2860 msg.append(plid);
2861
2862 msg.append(StringPool.CLOSE_CURLY_BRACE);
2863
2864 throw new NoSuchLayoutRevisionException(msg.toString());
2865 }
2866
2867
2876 public LayoutRevision fetchByH_P_Last(boolean head, long plid,
2877 OrderByComparator orderByComparator) throws SystemException {
2878 int count = countByH_P(head, plid);
2879
2880 List<LayoutRevision> list = findByH_P(head, plid, count - 1, count,
2881 orderByComparator);
2882
2883 if (!list.isEmpty()) {
2884 return list.get(0);
2885 }
2886
2887 return null;
2888 }
2889
2890
2901 public LayoutRevision[] findByH_P_PrevAndNext(long layoutRevisionId,
2902 boolean head, long plid, OrderByComparator orderByComparator)
2903 throws NoSuchLayoutRevisionException, SystemException {
2904 LayoutRevision layoutRevision = findByPrimaryKey(layoutRevisionId);
2905
2906 Session session = null;
2907
2908 try {
2909 session = openSession();
2910
2911 LayoutRevision[] array = new LayoutRevisionImpl[3];
2912
2913 array[0] = getByH_P_PrevAndNext(session, layoutRevision, head,
2914 plid, orderByComparator, true);
2915
2916 array[1] = layoutRevision;
2917
2918 array[2] = getByH_P_PrevAndNext(session, layoutRevision, head,
2919 plid, orderByComparator, false);
2920
2921 return array;
2922 }
2923 catch (Exception e) {
2924 throw processException(e);
2925 }
2926 finally {
2927 closeSession(session);
2928 }
2929 }
2930
2931 protected LayoutRevision getByH_P_PrevAndNext(Session session,
2932 LayoutRevision layoutRevision, boolean head, long plid,
2933 OrderByComparator orderByComparator, boolean previous) {
2934 StringBundler query = null;
2935
2936 if (orderByComparator != null) {
2937 query = new StringBundler(6 +
2938 (orderByComparator.getOrderByFields().length * 6));
2939 }
2940 else {
2941 query = new StringBundler(3);
2942 }
2943
2944 query.append(_SQL_SELECT_LAYOUTREVISION_WHERE);
2945
2946 query.append(_FINDER_COLUMN_H_P_HEAD_2);
2947
2948 query.append(_FINDER_COLUMN_H_P_PLID_2);
2949
2950 if (orderByComparator != null) {
2951 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2952
2953 if (orderByConditionFields.length > 0) {
2954 query.append(WHERE_AND);
2955 }
2956
2957 for (int i = 0; i < orderByConditionFields.length; i++) {
2958 query.append(_ORDER_BY_ENTITY_ALIAS);
2959 query.append(orderByConditionFields[i]);
2960
2961 if ((i + 1) < orderByConditionFields.length) {
2962 if (orderByComparator.isAscending() ^ previous) {
2963 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2964 }
2965 else {
2966 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2967 }
2968 }
2969 else {
2970 if (orderByComparator.isAscending() ^ previous) {
2971 query.append(WHERE_GREATER_THAN);
2972 }
2973 else {
2974 query.append(WHERE_LESSER_THAN);
2975 }
2976 }
2977 }
2978
2979 query.append(ORDER_BY_CLAUSE);
2980
2981 String[] orderByFields = orderByComparator.getOrderByFields();
2982
2983 for (int i = 0; i < orderByFields.length; i++) {
2984 query.append(_ORDER_BY_ENTITY_ALIAS);
2985 query.append(orderByFields[i]);
2986
2987 if ((i + 1) < orderByFields.length) {
2988 if (orderByComparator.isAscending() ^ previous) {
2989 query.append(ORDER_BY_ASC_HAS_NEXT);
2990 }
2991 else {
2992 query.append(ORDER_BY_DESC_HAS_NEXT);
2993 }
2994 }
2995 else {
2996 if (orderByComparator.isAscending() ^ previous) {
2997 query.append(ORDER_BY_ASC);
2998 }
2999 else {
3000 query.append(ORDER_BY_DESC);
3001 }
3002 }
3003 }
3004 }
3005 else {
3006 query.append(LayoutRevisionModelImpl.ORDER_BY_JPQL);
3007 }
3008
3009 String sql = query.toString();
3010
3011 Query q = session.createQuery(sql);
3012
3013 q.setFirstResult(0);
3014 q.setMaxResults(2);
3015
3016 QueryPos qPos = QueryPos.getInstance(q);
3017
3018 qPos.add(head);
3019
3020 qPos.add(plid);
3021
3022 if (orderByComparator != null) {
3023 Object[] values = orderByComparator.getOrderByConditionValues(layoutRevision);
3024
3025 for (Object value : values) {
3026 qPos.add(value);
3027 }
3028 }
3029
3030 List<LayoutRevision> list = q.list();
3031
3032 if (list.size() == 2) {
3033 return list.get(1);
3034 }
3035 else {
3036 return null;
3037 }
3038 }
3039
3040
3047 public void removeByH_P(boolean head, long plid) throws SystemException {
3048 for (LayoutRevision layoutRevision : findByH_P(head, plid,
3049 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
3050 remove(layoutRevision);
3051 }
3052 }
3053
3054
3062 public int countByH_P(boolean head, long plid) throws SystemException {
3063 FinderPath finderPath = FINDER_PATH_COUNT_BY_H_P;
3064
3065 Object[] finderArgs = new Object[] { head, plid };
3066
3067 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
3068 this);
3069
3070 if (count == null) {
3071 StringBundler query = new StringBundler(3);
3072
3073 query.append(_SQL_COUNT_LAYOUTREVISION_WHERE);
3074
3075 query.append(_FINDER_COLUMN_H_P_HEAD_2);
3076
3077 query.append(_FINDER_COLUMN_H_P_PLID_2);
3078
3079 String sql = query.toString();
3080
3081 Session session = null;
3082
3083 try {
3084 session = openSession();
3085
3086 Query q = session.createQuery(sql);
3087
3088 QueryPos qPos = QueryPos.getInstance(q);
3089
3090 qPos.add(head);
3091
3092 qPos.add(plid);
3093
3094 count = (Long)q.uniqueResult();
3095
3096 FinderCacheUtil.putResult(finderPath, finderArgs, count);
3097 }
3098 catch (Exception e) {
3099 FinderCacheUtil.removeResult(finderPath, finderArgs);
3100
3101 throw processException(e);
3102 }
3103 finally {
3104 closeSession(session);
3105 }
3106 }
3107
3108 return count.intValue();
3109 }
3110
3111 private static final String _FINDER_COLUMN_H_P_HEAD_2 = "layoutRevision.head = ? AND ";
3112 private static final String _FINDER_COLUMN_H_P_PLID_2 = "layoutRevision.plid = ?";
3113 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_P_NOTS = new FinderPath(LayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
3114 LayoutRevisionModelImpl.FINDER_CACHE_ENABLED,
3115 LayoutRevisionImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
3116 "findByP_NotS",
3117 new String[] {
3118 Long.class.getName(), Integer.class.getName(),
3119
3120 Integer.class.getName(), Integer.class.getName(),
3121 OrderByComparator.class.getName()
3122 });
3123 public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_P_NOTS = new FinderPath(LayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
3124 LayoutRevisionModelImpl.FINDER_CACHE_ENABLED, Long.class,
3125 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByP_NotS",
3126 new String[] { Long.class.getName(), Integer.class.getName() });
3127
3128
3136 public List<LayoutRevision> findByP_NotS(long plid, int status)
3137 throws SystemException {
3138 return findByP_NotS(plid, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
3139 null);
3140 }
3141
3142
3156 public List<LayoutRevision> findByP_NotS(long plid, int status, int start,
3157 int end) throws SystemException {
3158 return findByP_NotS(plid, status, start, end, null);
3159 }
3160
3161
3176 public List<LayoutRevision> findByP_NotS(long plid, int status, int start,
3177 int end, OrderByComparator orderByComparator) throws SystemException {
3178 boolean pagination = true;
3179 FinderPath finderPath = null;
3180 Object[] finderArgs = null;
3181
3182 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_P_NOTS;
3183 finderArgs = new Object[] { plid, status, start, end, orderByComparator };
3184
3185 List<LayoutRevision> list = (List<LayoutRevision>)FinderCacheUtil.getResult(finderPath,
3186 finderArgs, this);
3187
3188 if ((list != null) && !list.isEmpty()) {
3189 for (LayoutRevision layoutRevision : list) {
3190 if ((plid != layoutRevision.getPlid()) ||
3191 (status != layoutRevision.getStatus())) {
3192 list = null;
3193
3194 break;
3195 }
3196 }
3197 }
3198
3199 if (list == null) {
3200 StringBundler query = null;
3201
3202 if (orderByComparator != null) {
3203 query = new StringBundler(4 +
3204 (orderByComparator.getOrderByFields().length * 3));
3205 }
3206 else {
3207 query = new StringBundler(4);
3208 }
3209
3210 query.append(_SQL_SELECT_LAYOUTREVISION_WHERE);
3211
3212 query.append(_FINDER_COLUMN_P_NOTS_PLID_2);
3213
3214 query.append(_FINDER_COLUMN_P_NOTS_STATUS_2);
3215
3216 if (orderByComparator != null) {
3217 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3218 orderByComparator);
3219 }
3220 else
3221 if (pagination) {
3222 query.append(LayoutRevisionModelImpl.ORDER_BY_JPQL);
3223 }
3224
3225 String sql = query.toString();
3226
3227 Session session = null;
3228
3229 try {
3230 session = openSession();
3231
3232 Query q = session.createQuery(sql);
3233
3234 QueryPos qPos = QueryPos.getInstance(q);
3235
3236 qPos.add(plid);
3237
3238 qPos.add(status);
3239
3240 if (!pagination) {
3241 list = (List<LayoutRevision>)QueryUtil.list(q,
3242 getDialect(), start, end, false);
3243
3244 Collections.sort(list);
3245
3246 list = new UnmodifiableList<LayoutRevision>(list);
3247 }
3248 else {
3249 list = (List<LayoutRevision>)QueryUtil.list(q,
3250 getDialect(), start, end);
3251 }
3252
3253 cacheResult(list);
3254
3255 FinderCacheUtil.putResult(finderPath, finderArgs, list);
3256 }
3257 catch (Exception e) {
3258 FinderCacheUtil.removeResult(finderPath, finderArgs);
3259
3260 throw processException(e);
3261 }
3262 finally {
3263 closeSession(session);
3264 }
3265 }
3266
3267 return list;
3268 }
3269
3270
3280 public LayoutRevision findByP_NotS_First(long plid, int status,
3281 OrderByComparator orderByComparator)
3282 throws NoSuchLayoutRevisionException, SystemException {
3283 LayoutRevision layoutRevision = fetchByP_NotS_First(plid, status,
3284 orderByComparator);
3285
3286 if (layoutRevision != null) {
3287 return layoutRevision;
3288 }
3289
3290 StringBundler msg = new StringBundler(6);
3291
3292 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3293
3294 msg.append("plid=");
3295 msg.append(plid);
3296
3297 msg.append(", status=");
3298 msg.append(status);
3299
3300 msg.append(StringPool.CLOSE_CURLY_BRACE);
3301
3302 throw new NoSuchLayoutRevisionException(msg.toString());
3303 }
3304
3305
3314 public LayoutRevision fetchByP_NotS_First(long plid, int status,
3315 OrderByComparator orderByComparator) throws SystemException {
3316 List<LayoutRevision> list = findByP_NotS(plid, status, 0, 1,
3317 orderByComparator);
3318
3319 if (!list.isEmpty()) {
3320 return list.get(0);
3321 }
3322
3323 return null;
3324 }
3325
3326
3336 public LayoutRevision findByP_NotS_Last(long plid, int status,
3337 OrderByComparator orderByComparator)
3338 throws NoSuchLayoutRevisionException, SystemException {
3339 LayoutRevision layoutRevision = fetchByP_NotS_Last(plid, status,
3340 orderByComparator);
3341
3342 if (layoutRevision != null) {
3343 return layoutRevision;
3344 }
3345
3346 StringBundler msg = new StringBundler(6);
3347
3348 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3349
3350 msg.append("plid=");
3351 msg.append(plid);
3352
3353 msg.append(", status=");
3354 msg.append(status);
3355
3356 msg.append(StringPool.CLOSE_CURLY_BRACE);
3357
3358 throw new NoSuchLayoutRevisionException(msg.toString());
3359 }
3360
3361
3370 public LayoutRevision fetchByP_NotS_Last(long plid, int status,
3371 OrderByComparator orderByComparator) throws SystemException {
3372 int count = countByP_NotS(plid, status);
3373
3374 List<LayoutRevision> list = findByP_NotS(plid, status, count - 1,
3375 count, orderByComparator);
3376
3377 if (!list.isEmpty()) {
3378 return list.get(0);
3379 }
3380
3381 return null;
3382 }
3383
3384
3395 public LayoutRevision[] findByP_NotS_PrevAndNext(long layoutRevisionId,
3396 long plid, int status, OrderByComparator orderByComparator)
3397 throws NoSuchLayoutRevisionException, SystemException {
3398 LayoutRevision layoutRevision = findByPrimaryKey(layoutRevisionId);
3399
3400 Session session = null;
3401
3402 try {
3403 session = openSession();
3404
3405 LayoutRevision[] array = new LayoutRevisionImpl[3];
3406
3407 array[0] = getByP_NotS_PrevAndNext(session, layoutRevision, plid,
3408 status, orderByComparator, true);
3409
3410 array[1] = layoutRevision;
3411
3412 array[2] = getByP_NotS_PrevAndNext(session, layoutRevision, plid,
3413 status, orderByComparator, false);
3414
3415 return array;
3416 }
3417 catch (Exception e) {
3418 throw processException(e);
3419 }
3420 finally {
3421 closeSession(session);
3422 }
3423 }
3424
3425 protected LayoutRevision getByP_NotS_PrevAndNext(Session session,
3426 LayoutRevision layoutRevision, long plid, int status,
3427 OrderByComparator orderByComparator, boolean previous) {
3428 StringBundler query = null;
3429
3430 if (orderByComparator != null) {
3431 query = new StringBundler(6 +
3432 (orderByComparator.getOrderByFields().length * 6));
3433 }
3434 else {
3435 query = new StringBundler(3);
3436 }
3437
3438 query.append(_SQL_SELECT_LAYOUTREVISION_WHERE);
3439
3440 query.append(_FINDER_COLUMN_P_NOTS_PLID_2);
3441
3442 query.append(_FINDER_COLUMN_P_NOTS_STATUS_2);
3443
3444 if (orderByComparator != null) {
3445 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3446
3447 if (orderByConditionFields.length > 0) {
3448 query.append(WHERE_AND);
3449 }
3450
3451 for (int i = 0; i < orderByConditionFields.length; i++) {
3452 query.append(_ORDER_BY_ENTITY_ALIAS);
3453 query.append(orderByConditionFields[i]);
3454
3455 if ((i + 1) < orderByConditionFields.length) {
3456 if (orderByComparator.isAscending() ^ previous) {
3457 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3458 }
3459 else {
3460 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3461 }
3462 }
3463 else {
3464 if (orderByComparator.isAscending() ^ previous) {
3465 query.append(WHERE_GREATER_THAN);
3466 }
3467 else {
3468 query.append(WHERE_LESSER_THAN);
3469 }
3470 }
3471 }
3472
3473 query.append(ORDER_BY_CLAUSE);
3474
3475 String[] orderByFields = orderByComparator.getOrderByFields();
3476
3477 for (int i = 0; i < orderByFields.length; i++) {
3478 query.append(_ORDER_BY_ENTITY_ALIAS);
3479 query.append(orderByFields[i]);
3480
3481 if ((i + 1) < orderByFields.length) {
3482 if (orderByComparator.isAscending() ^ previous) {
3483 query.append(ORDER_BY_ASC_HAS_NEXT);
3484 }
3485 else {
3486 query.append(ORDER_BY_DESC_HAS_NEXT);
3487 }
3488 }
3489 else {
3490 if (orderByComparator.isAscending() ^ previous) {
3491 query.append(ORDER_BY_ASC);
3492 }
3493 else {
3494 query.append(ORDER_BY_DESC);
3495 }
3496 }
3497 }
3498 }
3499 else {
3500 query.append(LayoutRevisionModelImpl.ORDER_BY_JPQL);
3501 }
3502
3503 String sql = query.toString();
3504
3505 Query q = session.createQuery(sql);
3506
3507 q.setFirstResult(0);
3508 q.setMaxResults(2);
3509
3510 QueryPos qPos = QueryPos.getInstance(q);
3511
3512 qPos.add(plid);
3513
3514 qPos.add(status);
3515
3516 if (orderByComparator != null) {
3517 Object[] values = orderByComparator.getOrderByConditionValues(layoutRevision);
3518
3519 for (Object value : values) {
3520 qPos.add(value);
3521 }
3522 }
3523
3524 List<LayoutRevision> list = q.list();
3525
3526 if (list.size() == 2) {
3527 return list.get(1);
3528 }
3529 else {
3530 return null;
3531 }
3532 }
3533
3534
3541 public void removeByP_NotS(long plid, int status) throws SystemException {
3542 for (LayoutRevision layoutRevision : findByP_NotS(plid, status,
3543 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
3544 remove(layoutRevision);
3545 }
3546 }
3547
3548
3556 public int countByP_NotS(long plid, int status) throws SystemException {
3557 FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_P_NOTS;
3558
3559 Object[] finderArgs = new Object[] { plid, status };
3560
3561 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
3562 this);
3563
3564 if (count == null) {
3565 StringBundler query = new StringBundler(3);
3566
3567 query.append(_SQL_COUNT_LAYOUTREVISION_WHERE);
3568
3569 query.append(_FINDER_COLUMN_P_NOTS_PLID_2);
3570
3571 query.append(_FINDER_COLUMN_P_NOTS_STATUS_2);
3572
3573 String sql = query.toString();
3574
3575 Session session = null;
3576
3577 try {
3578 session = openSession();
3579
3580 Query q = session.createQuery(sql);
3581
3582 QueryPos qPos = QueryPos.getInstance(q);
3583
3584 qPos.add(plid);
3585
3586 qPos.add(status);
3587
3588 count = (Long)q.uniqueResult();
3589
3590 FinderCacheUtil.putResult(finderPath, finderArgs, count);
3591 }
3592 catch (Exception e) {
3593 FinderCacheUtil.removeResult(finderPath, finderArgs);
3594
3595 throw processException(e);
3596 }
3597 finally {
3598 closeSession(session);
3599 }
3600 }
3601
3602 return count.intValue();
3603 }
3604
3605 private static final String _FINDER_COLUMN_P_NOTS_PLID_2 = "layoutRevision.plid = ? AND ";
3606 private static final String _FINDER_COLUMN_P_NOTS_STATUS_2 = "layoutRevision.status != ?";
3607 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_L_L_P = new FinderPath(LayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
3608 LayoutRevisionModelImpl.FINDER_CACHE_ENABLED,
3609 LayoutRevisionImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
3610 "findByL_L_P",
3611 new String[] {
3612 Long.class.getName(), Long.class.getName(), Long.class.getName(),
3613
3614 Integer.class.getName(), Integer.class.getName(),
3615 OrderByComparator.class.getName()
3616 });
3617 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_L_P = new FinderPath(LayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
3618 LayoutRevisionModelImpl.FINDER_CACHE_ENABLED,
3619 LayoutRevisionImpl.class,
3620 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByL_L_P",
3621 new String[] {
3622 Long.class.getName(), Long.class.getName(), Long.class.getName()
3623 },
3624 LayoutRevisionModelImpl.LAYOUTSETBRANCHID_COLUMN_BITMASK |
3625 LayoutRevisionModelImpl.LAYOUTBRANCHID_COLUMN_BITMASK |
3626 LayoutRevisionModelImpl.PLID_COLUMN_BITMASK |
3627 LayoutRevisionModelImpl.MODIFIEDDATE_COLUMN_BITMASK);
3628 public static final FinderPath FINDER_PATH_COUNT_BY_L_L_P = new FinderPath(LayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
3629 LayoutRevisionModelImpl.FINDER_CACHE_ENABLED, Long.class,
3630 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByL_L_P",
3631 new String[] {
3632 Long.class.getName(), Long.class.getName(), Long.class.getName()
3633 });
3634
3635
3644 public List<LayoutRevision> findByL_L_P(long layoutSetBranchId,
3645 long layoutBranchId, long plid) throws SystemException {
3646 return findByL_L_P(layoutSetBranchId, layoutBranchId, plid,
3647 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
3648 }
3649
3650
3665 public List<LayoutRevision> findByL_L_P(long layoutSetBranchId,
3666 long layoutBranchId, long plid, int start, int end)
3667 throws SystemException {
3668 return findByL_L_P(layoutSetBranchId, layoutBranchId, plid, start, end,
3669 null);
3670 }
3671
3672
3688 public List<LayoutRevision> findByL_L_P(long layoutSetBranchId,
3689 long layoutBranchId, long plid, int start, int end,
3690 OrderByComparator orderByComparator) throws SystemException {
3691 boolean pagination = true;
3692 FinderPath finderPath = null;
3693 Object[] finderArgs = null;
3694
3695 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3696 (orderByComparator == null)) {
3697 pagination = false;
3698 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_L_P;
3699 finderArgs = new Object[] { layoutSetBranchId, layoutBranchId, plid };
3700 }
3701 else {
3702 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_L_L_P;
3703 finderArgs = new Object[] {
3704 layoutSetBranchId, layoutBranchId, plid,
3705
3706 start, end, orderByComparator
3707 };
3708 }
3709
3710 List<LayoutRevision> list = (List<LayoutRevision>)FinderCacheUtil.getResult(finderPath,
3711 finderArgs, this);
3712
3713 if ((list != null) && !list.isEmpty()) {
3714 for (LayoutRevision layoutRevision : list) {
3715 if ((layoutSetBranchId != layoutRevision.getLayoutSetBranchId()) ||
3716 (layoutBranchId != layoutRevision.getLayoutBranchId()) ||
3717 (plid != layoutRevision.getPlid())) {
3718 list = null;
3719
3720 break;
3721 }
3722 }
3723 }
3724
3725 if (list == null) {
3726 StringBundler query = null;
3727
3728 if (orderByComparator != null) {
3729 query = new StringBundler(5 +
3730 (orderByComparator.getOrderByFields().length * 3));
3731 }
3732 else {
3733 query = new StringBundler(5);
3734 }
3735
3736 query.append(_SQL_SELECT_LAYOUTREVISION_WHERE);
3737
3738 query.append(_FINDER_COLUMN_L_L_P_LAYOUTSETBRANCHID_2);
3739
3740 query.append(_FINDER_COLUMN_L_L_P_LAYOUTBRANCHID_2);
3741
3742 query.append(_FINDER_COLUMN_L_L_P_PLID_2);
3743
3744 if (orderByComparator != null) {
3745 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3746 orderByComparator);
3747 }
3748 else
3749 if (pagination) {
3750 query.append(LayoutRevisionModelImpl.ORDER_BY_JPQL);
3751 }
3752
3753 String sql = query.toString();
3754
3755 Session session = null;
3756
3757 try {
3758 session = openSession();
3759
3760 Query q = session.createQuery(sql);
3761
3762 QueryPos qPos = QueryPos.getInstance(q);
3763
3764 qPos.add(layoutSetBranchId);
3765
3766 qPos.add(layoutBranchId);
3767
3768 qPos.add(plid);
3769
3770 if (!pagination) {
3771 list = (List<LayoutRevision>)QueryUtil.list(q,
3772 getDialect(), start, end, false);
3773
3774 Collections.sort(list);
3775
3776 list = new UnmodifiableList<LayoutRevision>(list);
3777 }
3778 else {
3779 list = (List<LayoutRevision>)QueryUtil.list(q,
3780 getDialect(), start, end);
3781 }
3782
3783 cacheResult(list);
3784
3785 FinderCacheUtil.putResult(finderPath, finderArgs, list);
3786 }
3787 catch (Exception e) {
3788 FinderCacheUtil.removeResult(finderPath, finderArgs);
3789
3790 throw processException(e);
3791 }
3792 finally {
3793 closeSession(session);
3794 }
3795 }
3796
3797 return list;
3798 }
3799
3800
3811 public LayoutRevision findByL_L_P_First(long layoutSetBranchId,
3812 long layoutBranchId, long plid, OrderByComparator orderByComparator)
3813 throws NoSuchLayoutRevisionException, SystemException {
3814 LayoutRevision layoutRevision = fetchByL_L_P_First(layoutSetBranchId,
3815 layoutBranchId, plid, orderByComparator);
3816
3817 if (layoutRevision != null) {
3818 return layoutRevision;
3819 }
3820
3821 StringBundler msg = new StringBundler(8);
3822
3823 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3824
3825 msg.append("layoutSetBranchId=");
3826 msg.append(layoutSetBranchId);
3827
3828 msg.append(", layoutBranchId=");
3829 msg.append(layoutBranchId);
3830
3831 msg.append(", plid=");
3832 msg.append(plid);
3833
3834 msg.append(StringPool.CLOSE_CURLY_BRACE);
3835
3836 throw new NoSuchLayoutRevisionException(msg.toString());
3837 }
3838
3839
3849 public LayoutRevision fetchByL_L_P_First(long layoutSetBranchId,
3850 long layoutBranchId, long plid, OrderByComparator orderByComparator)
3851 throws SystemException {
3852 List<LayoutRevision> list = findByL_L_P(layoutSetBranchId,
3853 layoutBranchId, plid, 0, 1, orderByComparator);
3854
3855 if (!list.isEmpty()) {
3856 return list.get(0);
3857 }
3858
3859 return null;
3860 }
3861
3862
3873 public LayoutRevision findByL_L_P_Last(long layoutSetBranchId,
3874 long layoutBranchId, long plid, OrderByComparator orderByComparator)
3875 throws NoSuchLayoutRevisionException, SystemException {
3876 LayoutRevision layoutRevision = fetchByL_L_P_Last(layoutSetBranchId,
3877 layoutBranchId, plid, orderByComparator);
3878
3879 if (layoutRevision != null) {
3880 return layoutRevision;
3881 }
3882
3883 StringBundler msg = new StringBundler(8);
3884
3885 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3886
3887 msg.append("layoutSetBranchId=");
3888 msg.append(layoutSetBranchId);
3889
3890 msg.append(", layoutBranchId=");
3891 msg.append(layoutBranchId);
3892
3893 msg.append(", plid=");
3894 msg.append(plid);
3895
3896 msg.append(StringPool.CLOSE_CURLY_BRACE);
3897
3898 throw new NoSuchLayoutRevisionException(msg.toString());
3899 }
3900
3901
3911 public LayoutRevision fetchByL_L_P_Last(long layoutSetBranchId,
3912 long layoutBranchId, long plid, OrderByComparator orderByComparator)
3913 throws SystemException {
3914 int count = countByL_L_P(layoutSetBranchId, layoutBranchId, plid);
3915
3916 List<LayoutRevision> list = findByL_L_P(layoutSetBranchId,
3917 layoutBranchId, plid, count - 1, count, orderByComparator);
3918
3919 if (!list.isEmpty()) {
3920 return list.get(0);
3921 }
3922
3923 return null;
3924 }
3925
3926
3938 public LayoutRevision[] findByL_L_P_PrevAndNext(long layoutRevisionId,
3939 long layoutSetBranchId, long layoutBranchId, long plid,
3940 OrderByComparator orderByComparator)
3941 throws NoSuchLayoutRevisionException, SystemException {
3942 LayoutRevision layoutRevision = findByPrimaryKey(layoutRevisionId);
3943
3944 Session session = null;
3945
3946 try {
3947 session = openSession();
3948
3949 LayoutRevision[] array = new LayoutRevisionImpl[3];
3950
3951 array[0] = getByL_L_P_PrevAndNext(session, layoutRevision,
3952 layoutSetBranchId, layoutBranchId, plid, orderByComparator,
3953 true);
3954
3955 array[1] = layoutRevision;
3956
3957 array[2] = getByL_L_P_PrevAndNext(session, layoutRevision,
3958 layoutSetBranchId, layoutBranchId, plid, orderByComparator,
3959 false);
3960
3961 return array;
3962 }
3963 catch (Exception e) {
3964 throw processException(e);
3965 }
3966 finally {
3967 closeSession(session);
3968 }
3969 }
3970
3971 protected LayoutRevision getByL_L_P_PrevAndNext(Session session,
3972 LayoutRevision layoutRevision, long layoutSetBranchId,
3973 long layoutBranchId, long plid, OrderByComparator orderByComparator,
3974 boolean previous) {
3975 StringBundler query = null;
3976
3977 if (orderByComparator != null) {
3978 query = new StringBundler(6 +
3979 (orderByComparator.getOrderByFields().length * 6));
3980 }
3981 else {
3982 query = new StringBundler(3);
3983 }
3984
3985 query.append(_SQL_SELECT_LAYOUTREVISION_WHERE);
3986
3987 query.append(_FINDER_COLUMN_L_L_P_LAYOUTSETBRANCHID_2);
3988
3989 query.append(_FINDER_COLUMN_L_L_P_LAYOUTBRANCHID_2);
3990
3991 query.append(_FINDER_COLUMN_L_L_P_PLID_2);
3992
3993 if (orderByComparator != null) {
3994 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3995
3996 if (orderByConditionFields.length > 0) {
3997 query.append(WHERE_AND);
3998 }
3999
4000 for (int i = 0; i < orderByConditionFields.length; i++) {
4001 query.append(_ORDER_BY_ENTITY_ALIAS);
4002 query.append(orderByConditionFields[i]);
4003
4004 if ((i + 1) < orderByConditionFields.length) {
4005 if (orderByComparator.isAscending() ^ previous) {
4006 query.append(WHERE_GREATER_THAN_HAS_NEXT);
4007 }
4008 else {
4009 query.append(WHERE_LESSER_THAN_HAS_NEXT);
4010 }
4011 }
4012 else {
4013 if (orderByComparator.isAscending() ^ previous) {
4014 query.append(WHERE_GREATER_THAN);
4015 }
4016 else {
4017 query.append(WHERE_LESSER_THAN);
4018 }
4019 }
4020 }
4021
4022 query.append(ORDER_BY_CLAUSE);
4023
4024 String[] orderByFields = orderByComparator.getOrderByFields();
4025
4026 for (int i = 0; i < orderByFields.length; i++) {
4027 query.append(_ORDER_BY_ENTITY_ALIAS);
4028 query.append(orderByFields[i]);
4029
4030 if ((i + 1) < orderByFields.length) {
4031 if (orderByComparator.isAscending() ^ previous) {
4032 query.append(ORDER_BY_ASC_HAS_NEXT);
4033 }
4034 else {
4035 query.append(ORDER_BY_DESC_HAS_NEXT);
4036 }
4037 }
4038 else {
4039 if (orderByComparator.isAscending() ^ previous) {
4040 query.append(ORDER_BY_ASC);
4041 }
4042 else {
4043 query.append(ORDER_BY_DESC);
4044 }
4045 }
4046 }
4047 }
4048 else {
4049 query.append(LayoutRevisionModelImpl.ORDER_BY_JPQL);
4050 }
4051
4052 String sql = query.toString();
4053
4054 Query q = session.createQuery(sql);
4055
4056 q.setFirstResult(0);
4057 q.setMaxResults(2);
4058
4059 QueryPos qPos = QueryPos.getInstance(q);
4060
4061 qPos.add(layoutSetBranchId);
4062
4063 qPos.add(layoutBranchId);
4064
4065 qPos.add(plid);
4066
4067 if (orderByComparator != null) {
4068 Object[] values = orderByComparator.getOrderByConditionValues(layoutRevision);
4069
4070 for (Object value : values) {
4071 qPos.add(value);
4072 }
4073 }
4074
4075 List<LayoutRevision> list = q.list();
4076
4077 if (list.size() == 2) {
4078 return list.get(1);
4079 }
4080 else {
4081 return null;
4082 }
4083 }
4084
4085
4093 public void removeByL_L_P(long layoutSetBranchId, long layoutBranchId,
4094 long plid) throws SystemException {
4095 for (LayoutRevision layoutRevision : findByL_L_P(layoutSetBranchId,
4096 layoutBranchId, plid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
4097 remove(layoutRevision);
4098 }
4099 }
4100
4101
4110 public int countByL_L_P(long layoutSetBranchId, long layoutBranchId,
4111 long plid) throws SystemException {
4112 FinderPath finderPath = FINDER_PATH_COUNT_BY_L_L_P;
4113
4114 Object[] finderArgs = new Object[] {
4115 layoutSetBranchId, layoutBranchId, plid
4116 };
4117
4118 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
4119 this);
4120
4121 if (count == null) {
4122 StringBundler query = new StringBundler(4);
4123
4124 query.append(_SQL_COUNT_LAYOUTREVISION_WHERE);
4125
4126 query.append(_FINDER_COLUMN_L_L_P_LAYOUTSETBRANCHID_2);
4127
4128 query.append(_FINDER_COLUMN_L_L_P_LAYOUTBRANCHID_2);
4129
4130 query.append(_FINDER_COLUMN_L_L_P_PLID_2);
4131
4132 String sql = query.toString();
4133
4134 Session session = null;
4135
4136 try {
4137 session = openSession();
4138
4139 Query q = session.createQuery(sql);
4140
4141 QueryPos qPos = QueryPos.getInstance(q);
4142
4143 qPos.add(layoutSetBranchId);
4144
4145 qPos.add(layoutBranchId);
4146
4147 qPos.add(plid);
4148
4149 count = (Long)q.uniqueResult();
4150
4151 FinderCacheUtil.putResult(finderPath, finderArgs, count);
4152 }
4153 catch (Exception e) {
4154 FinderCacheUtil.removeResult(finderPath, finderArgs);
4155
4156 throw processException(e);
4157 }
4158 finally {
4159 closeSession(session);
4160 }
4161 }
4162
4163 return count.intValue();
4164 }
4165
4166 private static final String _FINDER_COLUMN_L_L_P_LAYOUTSETBRANCHID_2 = "layoutRevision.layoutSetBranchId = ? AND ";
4167 private static final String _FINDER_COLUMN_L_L_P_LAYOUTBRANCHID_2 = "layoutRevision.layoutBranchId = ? AND ";
4168 private static final String _FINDER_COLUMN_L_L_P_PLID_2 = "layoutRevision.plid = ? AND layoutRevision.status != 5";
4169 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_L_P_P = new FinderPath(LayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
4170 LayoutRevisionModelImpl.FINDER_CACHE_ENABLED,
4171 LayoutRevisionImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
4172 "findByL_P_P",
4173 new String[] {
4174 Long.class.getName(), Long.class.getName(), Long.class.getName(),
4175
4176 Integer.class.getName(), Integer.class.getName(),
4177 OrderByComparator.class.getName()
4178 });
4179 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_P_P = new FinderPath(LayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
4180 LayoutRevisionModelImpl.FINDER_CACHE_ENABLED,
4181 LayoutRevisionImpl.class,
4182 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByL_P_P",
4183 new String[] {
4184 Long.class.getName(), Long.class.getName(), Long.class.getName()
4185 },
4186 LayoutRevisionModelImpl.LAYOUTSETBRANCHID_COLUMN_BITMASK |
4187 LayoutRevisionModelImpl.PARENTLAYOUTREVISIONID_COLUMN_BITMASK |
4188 LayoutRevisionModelImpl.PLID_COLUMN_BITMASK |
4189 LayoutRevisionModelImpl.MODIFIEDDATE_COLUMN_BITMASK);
4190 public static final FinderPath FINDER_PATH_COUNT_BY_L_P_P = new FinderPath(LayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
4191 LayoutRevisionModelImpl.FINDER_CACHE_ENABLED, Long.class,
4192 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByL_P_P",
4193 new String[] {
4194 Long.class.getName(), Long.class.getName(), Long.class.getName()
4195 });
4196
4197
4206 public List<LayoutRevision> findByL_P_P(long layoutSetBranchId,
4207 long parentLayoutRevisionId, long plid) throws SystemException {
4208 return findByL_P_P(layoutSetBranchId, parentLayoutRevisionId, plid,
4209 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
4210 }
4211
4212
4227 public List<LayoutRevision> findByL_P_P(long layoutSetBranchId,
4228 long parentLayoutRevisionId, long plid, int start, int end)
4229 throws SystemException {
4230 return findByL_P_P(layoutSetBranchId, parentLayoutRevisionId, plid,
4231 start, end, null);
4232 }
4233
4234
4250 public List<LayoutRevision> findByL_P_P(long layoutSetBranchId,
4251 long parentLayoutRevisionId, long plid, int start, int end,
4252 OrderByComparator orderByComparator) throws SystemException {
4253 boolean pagination = true;
4254 FinderPath finderPath = null;
4255 Object[] finderArgs = null;
4256
4257 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4258 (orderByComparator == null)) {
4259 pagination = false;
4260 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_P_P;
4261 finderArgs = new Object[] {
4262 layoutSetBranchId, parentLayoutRevisionId, plid
4263 };
4264 }
4265 else {
4266 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_L_P_P;
4267 finderArgs = new Object[] {
4268 layoutSetBranchId, parentLayoutRevisionId, plid,
4269
4270 start, end, orderByComparator
4271 };
4272 }
4273
4274 List<LayoutRevision> list = (List<LayoutRevision>)FinderCacheUtil.getResult(finderPath,
4275 finderArgs, this);
4276
4277 if ((list != null) && !list.isEmpty()) {
4278 for (LayoutRevision layoutRevision : list) {
4279 if ((layoutSetBranchId != layoutRevision.getLayoutSetBranchId()) ||
4280 (parentLayoutRevisionId != layoutRevision.getParentLayoutRevisionId()) ||
4281 (plid != layoutRevision.getPlid())) {
4282 list = null;
4283
4284 break;
4285 }
4286 }
4287 }
4288
4289 if (list == null) {
4290 StringBundler query = null;
4291
4292 if (orderByComparator != null) {
4293 query = new StringBundler(5 +
4294 (orderByComparator.getOrderByFields().length * 3));
4295 }
4296 else {
4297 query = new StringBundler(5);
4298 }
4299
4300 query.append(_SQL_SELECT_LAYOUTREVISION_WHERE);
4301
4302 query.append(_FINDER_COLUMN_L_P_P_LAYOUTSETBRANCHID_2);
4303
4304 query.append(_FINDER_COLUMN_L_P_P_PARENTLAYOUTREVISIONID_2);
4305
4306 query.append(_FINDER_COLUMN_L_P_P_PLID_2);
4307
4308 if (orderByComparator != null) {
4309 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4310 orderByComparator);
4311 }
4312 else
4313 if (pagination) {
4314 query.append(LayoutRevisionModelImpl.ORDER_BY_JPQL);
4315 }
4316
4317 String sql = query.toString();
4318
4319 Session session = null;
4320
4321 try {
4322 session = openSession();
4323
4324 Query q = session.createQuery(sql);
4325
4326 QueryPos qPos = QueryPos.getInstance(q);
4327
4328 qPos.add(layoutSetBranchId);
4329
4330 qPos.add(parentLayoutRevisionId);
4331
4332 qPos.add(plid);
4333
4334 if (!pagination) {
4335 list = (List<LayoutRevision>)QueryUtil.list(q,
4336 getDialect(), start, end, false);
4337
4338 Collections.sort(list);
4339
4340 list = new UnmodifiableList<LayoutRevision>(list);
4341 }
4342 else {
4343 list = (List<LayoutRevision>)QueryUtil.list(q,
4344 getDialect(), start, end);
4345 }
4346
4347 cacheResult(list);
4348
4349 FinderCacheUtil.putResult(finderPath, finderArgs, list);
4350 }
4351 catch (Exception e) {
4352 FinderCacheUtil.removeResult(finderPath, finderArgs);
4353
4354 throw processException(e);
4355 }
4356 finally {
4357 closeSession(session);
4358 }
4359 }
4360
4361 return list;
4362 }
4363
4364
4375 public LayoutRevision findByL_P_P_First(long layoutSetBranchId,
4376 long parentLayoutRevisionId, long plid,
4377 OrderByComparator orderByComparator)
4378 throws NoSuchLayoutRevisionException, SystemException {
4379 LayoutRevision layoutRevision = fetchByL_P_P_First(layoutSetBranchId,
4380 parentLayoutRevisionId, plid, orderByComparator);
4381
4382 if (layoutRevision != null) {
4383 return layoutRevision;
4384 }
4385
4386 StringBundler msg = new StringBundler(8);
4387
4388 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4389
4390 msg.append("layoutSetBranchId=");
4391 msg.append(layoutSetBranchId);
4392
4393 msg.append(", parentLayoutRevisionId=");
4394 msg.append(parentLayoutRevisionId);
4395
4396 msg.append(", plid=");
4397 msg.append(plid);
4398
4399 msg.append(StringPool.CLOSE_CURLY_BRACE);
4400
4401 throw new NoSuchLayoutRevisionException(msg.toString());
4402 }
4403
4404
4414 public LayoutRevision fetchByL_P_P_First(long layoutSetBranchId,
4415 long parentLayoutRevisionId, long plid,
4416 OrderByComparator orderByComparator) throws SystemException {
4417 List<LayoutRevision> list = findByL_P_P(layoutSetBranchId,
4418 parentLayoutRevisionId, plid, 0, 1, orderByComparator);
4419
4420 if (!list.isEmpty()) {
4421 return list.get(0);
4422 }
4423
4424 return null;
4425 }
4426
4427
4438 public LayoutRevision findByL_P_P_Last(long layoutSetBranchId,
4439 long parentLayoutRevisionId, long plid,
4440 OrderByComparator orderByComparator)
4441 throws NoSuchLayoutRevisionException, SystemException {
4442 LayoutRevision layoutRevision = fetchByL_P_P_Last(layoutSetBranchId,
4443 parentLayoutRevisionId, plid, orderByComparator);
4444
4445 if (layoutRevision != null) {
4446 return layoutRevision;
4447 }
4448
4449 StringBundler msg = new StringBundler(8);
4450
4451 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4452
4453 msg.append("layoutSetBranchId=");
4454 msg.append(layoutSetBranchId);
4455
4456 msg.append(", parentLayoutRevisionId=");
4457 msg.append(parentLayoutRevisionId);
4458
4459 msg.append(", plid=");
4460 msg.append(plid);
4461
4462 msg.append(StringPool.CLOSE_CURLY_BRACE);
4463
4464 throw new NoSuchLayoutRevisionException(msg.toString());
4465 }
4466
4467
4477 public LayoutRevision fetchByL_P_P_Last(long layoutSetBranchId,
4478 long parentLayoutRevisionId, long plid,
4479 OrderByComparator orderByComparator) throws SystemException {
4480 int count = countByL_P_P(layoutSetBranchId, parentLayoutRevisionId, plid);
4481
4482 List<LayoutRevision> list = findByL_P_P(layoutSetBranchId,
4483 parentLayoutRevisionId, plid, count - 1, count,
4484 orderByComparator);
4485
4486 if (!list.isEmpty()) {
4487 return list.get(0);
4488 }
4489
4490 return null;
4491 }
4492
4493
4505 public LayoutRevision[] findByL_P_P_PrevAndNext(long layoutRevisionId,
4506 long layoutSetBranchId, long parentLayoutRevisionId, long plid,
4507 OrderByComparator orderByComparator)
4508 throws NoSuchLayoutRevisionException, SystemException {
4509 LayoutRevision layoutRevision = findByPrimaryKey(layoutRevisionId);
4510
4511 Session session = null;
4512
4513 try {
4514 session = openSession();
4515
4516 LayoutRevision[] array = new LayoutRevisionImpl[3];
4517
4518 array[0] = getByL_P_P_PrevAndNext(session, layoutRevision,
4519 layoutSetBranchId, parentLayoutRevisionId, plid,
4520 orderByComparator, true);
4521
4522 array[1] = layoutRevision;
4523
4524 array[2] = getByL_P_P_PrevAndNext(session, layoutRevision,
4525 layoutSetBranchId, parentLayoutRevisionId, plid,
4526 orderByComparator, false);
4527
4528 return array;
4529 }
4530 catch (Exception e) {
4531 throw processException(e);
4532 }
4533 finally {
4534 closeSession(session);
4535 }
4536 }
4537
4538 protected LayoutRevision getByL_P_P_PrevAndNext(Session session,
4539 LayoutRevision layoutRevision, long layoutSetBranchId,
4540 long parentLayoutRevisionId, long plid,
4541 OrderByComparator orderByComparator, boolean previous) {
4542 StringBundler query = null;
4543
4544 if (orderByComparator != null) {
4545 query = new StringBundler(6 +
4546 (orderByComparator.getOrderByFields().length * 6));
4547 }
4548 else {
4549 query = new StringBundler(3);
4550 }
4551
4552 query.append(_SQL_SELECT_LAYOUTREVISION_WHERE);
4553
4554 query.append(_FINDER_COLUMN_L_P_P_LAYOUTSETBRANCHID_2);
4555
4556 query.append(_FINDER_COLUMN_L_P_P_PARENTLAYOUTREVISIONID_2);
4557
4558 query.append(_FINDER_COLUMN_L_P_P_PLID_2);
4559
4560 if (orderByComparator != null) {
4561 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4562
4563 if (orderByConditionFields.length > 0) {
4564 query.append(WHERE_AND);
4565 }
4566
4567 for (int i = 0; i < orderByConditionFields.length; i++) {
4568 query.append(_ORDER_BY_ENTITY_ALIAS);
4569 query.append(orderByConditionFields[i]);
4570
4571 if ((i + 1) < orderByConditionFields.length) {
4572 if (orderByComparator.isAscending() ^ previous) {
4573 query.append(WHERE_GREATER_THAN_HAS_NEXT);
4574 }
4575 else {
4576 query.append(WHERE_LESSER_THAN_HAS_NEXT);
4577 }
4578 }
4579 else {
4580 if (orderByComparator.isAscending() ^ previous) {
4581 query.append(WHERE_GREATER_THAN);
4582 }
4583 else {
4584 query.append(WHERE_LESSER_THAN);
4585 }
4586 }
4587 }
4588
4589 query.append(ORDER_BY_CLAUSE);
4590
4591 String[] orderByFields = orderByComparator.getOrderByFields();
4592
4593 for (int i = 0; i < orderByFields.length; i++) {
4594 query.append(_ORDER_BY_ENTITY_ALIAS);
4595 query.append(orderByFields[i]);
4596
4597 if ((i + 1) < orderByFields.length) {
4598 if (orderByComparator.isAscending() ^ previous) {
4599 query.append(ORDER_BY_ASC_HAS_NEXT);
4600 }
4601 else {
4602 query.append(ORDER_BY_DESC_HAS_NEXT);
4603 }
4604 }
4605 else {
4606 if (orderByComparator.isAscending() ^ previous) {
4607 query.append(ORDER_BY_ASC);
4608 }
4609 else {
4610 query.append(ORDER_BY_DESC);
4611 }
4612 }
4613 }
4614 }
4615 else {
4616 query.append(LayoutRevisionModelImpl.ORDER_BY_JPQL);
4617 }
4618
4619 String sql = query.toString();
4620
4621 Query q = session.createQuery(sql);
4622
4623 q.setFirstResult(0);
4624 q.setMaxResults(2);
4625
4626 QueryPos qPos = QueryPos.getInstance(q);
4627
4628 qPos.add(layoutSetBranchId);
4629
4630 qPos.add(parentLayoutRevisionId);
4631
4632 qPos.add(plid);
4633
4634 if (orderByComparator != null) {
4635 Object[] values = orderByComparator.getOrderByConditionValues(layoutRevision);
4636
4637 for (Object value : values) {
4638 qPos.add(value);
4639 }
4640 }
4641
4642 List<LayoutRevision> list = q.list();
4643
4644 if (list.size() == 2) {
4645 return list.get(1);
4646 }
4647 else {
4648 return null;
4649 }
4650 }
4651
4652
4660 public void removeByL_P_P(long layoutSetBranchId,
4661 long parentLayoutRevisionId, long plid) throws SystemException {
4662 for (LayoutRevision layoutRevision : findByL_P_P(layoutSetBranchId,
4663 parentLayoutRevisionId, plid, QueryUtil.ALL_POS,
4664 QueryUtil.ALL_POS, null)) {
4665 remove(layoutRevision);
4666 }
4667 }
4668
4669
4678 public int countByL_P_P(long layoutSetBranchId,
4679 long parentLayoutRevisionId, long plid) throws SystemException {
4680 FinderPath finderPath = FINDER_PATH_COUNT_BY_L_P_P;
4681
4682 Object[] finderArgs = new Object[] {
4683 layoutSetBranchId, parentLayoutRevisionId, plid
4684 };
4685
4686 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
4687 this);
4688
4689 if (count == null) {
4690 StringBundler query = new StringBundler(4);
4691
4692 query.append(_SQL_COUNT_LAYOUTREVISION_WHERE);
4693
4694 query.append(_FINDER_COLUMN_L_P_P_LAYOUTSETBRANCHID_2);
4695
4696 query.append(_FINDER_COLUMN_L_P_P_PARENTLAYOUTREVISIONID_2);
4697
4698 query.append(_FINDER_COLUMN_L_P_P_PLID_2);
4699
4700 String sql = query.toString();
4701
4702 Session session = null;
4703
4704 try {
4705 session = openSession();
4706
4707 Query q = session.createQuery(sql);
4708
4709 QueryPos qPos = QueryPos.getInstance(q);
4710
4711 qPos.add(layoutSetBranchId);
4712
4713 qPos.add(parentLayoutRevisionId);
4714
4715 qPos.add(plid);
4716
4717 count = (Long)q.uniqueResult();
4718
4719 FinderCacheUtil.putResult(finderPath, finderArgs, count);
4720 }
4721 catch (Exception e) {
4722 FinderCacheUtil.removeResult(finderPath, finderArgs);
4723
4724 throw processException(e);
4725 }
4726 finally {
4727 closeSession(session);
4728 }
4729 }
4730
4731 return count.intValue();
4732 }
4733
4734 private static final String _FINDER_COLUMN_L_P_P_LAYOUTSETBRANCHID_2 = "layoutRevision.layoutSetBranchId = ? AND ";
4735 private static final String _FINDER_COLUMN_L_P_P_PARENTLAYOUTREVISIONID_2 = "layoutRevision.parentLayoutRevisionId = ? AND ";
4736 private static final String _FINDER_COLUMN_L_P_P_PLID_2 = "layoutRevision.plid = ?";
4737 public static final FinderPath FINDER_PATH_FETCH_BY_L_H_P = new FinderPath(LayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
4738 LayoutRevisionModelImpl.FINDER_CACHE_ENABLED,
4739 LayoutRevisionImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByL_H_P",
4740 new String[] {
4741 Long.class.getName(), Boolean.class.getName(),
4742 Long.class.getName()
4743 },
4744 LayoutRevisionModelImpl.LAYOUTSETBRANCHID_COLUMN_BITMASK |
4745 LayoutRevisionModelImpl.HEAD_COLUMN_BITMASK |
4746 LayoutRevisionModelImpl.PLID_COLUMN_BITMASK);
4747 public static final FinderPath FINDER_PATH_COUNT_BY_L_H_P = new FinderPath(LayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
4748 LayoutRevisionModelImpl.FINDER_CACHE_ENABLED, Long.class,
4749 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByL_H_P",
4750 new String[] {
4751 Long.class.getName(), Boolean.class.getName(),
4752 Long.class.getName()
4753 });
4754
4755
4765 public LayoutRevision findByL_H_P(long layoutSetBranchId, boolean head,
4766 long plid) throws NoSuchLayoutRevisionException, SystemException {
4767 LayoutRevision layoutRevision = fetchByL_H_P(layoutSetBranchId, head,
4768 plid);
4769
4770 if (layoutRevision == null) {
4771 StringBundler msg = new StringBundler(8);
4772
4773 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4774
4775 msg.append("layoutSetBranchId=");
4776 msg.append(layoutSetBranchId);
4777
4778 msg.append(", head=");
4779 msg.append(head);
4780
4781 msg.append(", plid=");
4782 msg.append(plid);
4783
4784 msg.append(StringPool.CLOSE_CURLY_BRACE);
4785
4786 if (_log.isWarnEnabled()) {
4787 _log.warn(msg.toString());
4788 }
4789
4790 throw new NoSuchLayoutRevisionException(msg.toString());
4791 }
4792
4793 return layoutRevision;
4794 }
4795
4796
4805 public LayoutRevision fetchByL_H_P(long layoutSetBranchId, boolean head,
4806 long plid) throws SystemException {
4807 return fetchByL_H_P(layoutSetBranchId, head, plid, true);
4808 }
4809
4810
4820 public LayoutRevision fetchByL_H_P(long layoutSetBranchId, boolean head,
4821 long plid, boolean retrieveFromCache) throws SystemException {
4822 Object[] finderArgs = new Object[] { layoutSetBranchId, head, plid };
4823
4824 Object result = null;
4825
4826 if (retrieveFromCache) {
4827 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_L_H_P,
4828 finderArgs, this);
4829 }
4830
4831 if (result instanceof LayoutRevision) {
4832 LayoutRevision layoutRevision = (LayoutRevision)result;
4833
4834 if ((layoutSetBranchId != layoutRevision.getLayoutSetBranchId()) ||
4835 (head != layoutRevision.getHead()) ||
4836 (plid != layoutRevision.getPlid())) {
4837 result = null;
4838 }
4839 }
4840
4841 if (result == null) {
4842 StringBundler query = new StringBundler(5);
4843
4844 query.append(_SQL_SELECT_LAYOUTREVISION_WHERE);
4845
4846 query.append(_FINDER_COLUMN_L_H_P_LAYOUTSETBRANCHID_2);
4847
4848 query.append(_FINDER_COLUMN_L_H_P_HEAD_2);
4849
4850 query.append(_FINDER_COLUMN_L_H_P_PLID_2);
4851
4852 String sql = query.toString();
4853
4854 Session session = null;
4855
4856 try {
4857 session = openSession();
4858
4859 Query q = session.createQuery(sql);
4860
4861 QueryPos qPos = QueryPos.getInstance(q);
4862
4863 qPos.add(layoutSetBranchId);
4864
4865 qPos.add(head);
4866
4867 qPos.add(plid);
4868
4869 List<LayoutRevision> list = q.list();
4870
4871 if (list.isEmpty()) {
4872 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_L_H_P,
4873 finderArgs, list);
4874 }
4875 else {
4876 if ((list.size() > 1) && _log.isWarnEnabled()) {
4877 _log.warn(
4878 "LayoutRevisionPersistenceImpl.fetchByL_H_P(long, boolean, long, boolean) with parameters (" +
4879 StringUtil.merge(finderArgs) +
4880 ") 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.");
4881 }
4882
4883 LayoutRevision layoutRevision = list.get(0);
4884
4885 result = layoutRevision;
4886
4887 cacheResult(layoutRevision);
4888
4889 if ((layoutRevision.getLayoutSetBranchId() != layoutSetBranchId) ||
4890 (layoutRevision.getHead() != head) ||
4891 (layoutRevision.getPlid() != plid)) {
4892 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_L_H_P,
4893 finderArgs, layoutRevision);
4894 }
4895 }
4896 }
4897 catch (Exception e) {
4898 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_L_H_P,
4899 finderArgs);
4900
4901 throw processException(e);
4902 }
4903 finally {
4904 closeSession(session);
4905 }
4906 }
4907
4908 if (result instanceof List<?>) {
4909 return null;
4910 }
4911 else {
4912 return (LayoutRevision)result;
4913 }
4914 }
4915
4916
4925 public LayoutRevision removeByL_H_P(long layoutSetBranchId, boolean head,
4926 long plid) throws NoSuchLayoutRevisionException, SystemException {
4927 LayoutRevision layoutRevision = findByL_H_P(layoutSetBranchId, head,
4928 plid);
4929
4930 return remove(layoutRevision);
4931 }
4932
4933
4942 public int countByL_H_P(long layoutSetBranchId, boolean head, long plid)
4943 throws SystemException {
4944 FinderPath finderPath = FINDER_PATH_COUNT_BY_L_H_P;
4945
4946 Object[] finderArgs = new Object[] { layoutSetBranchId, head, plid };
4947
4948 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
4949 this);
4950
4951 if (count == null) {
4952 StringBundler query = new StringBundler(4);
4953
4954 query.append(_SQL_COUNT_LAYOUTREVISION_WHERE);
4955
4956 query.append(_FINDER_COLUMN_L_H_P_LAYOUTSETBRANCHID_2);
4957
4958 query.append(_FINDER_COLUMN_L_H_P_HEAD_2);
4959
4960 query.append(_FINDER_COLUMN_L_H_P_PLID_2);
4961
4962 String sql = query.toString();
4963
4964 Session session = null;
4965
4966 try {
4967 session = openSession();
4968
4969 Query q = session.createQuery(sql);
4970
4971 QueryPos qPos = QueryPos.getInstance(q);
4972
4973 qPos.add(layoutSetBranchId);
4974
4975 qPos.add(head);
4976
4977 qPos.add(plid);
4978
4979 count = (Long)q.uniqueResult();
4980
4981 FinderCacheUtil.putResult(finderPath, finderArgs, count);
4982 }
4983 catch (Exception e) {
4984 FinderCacheUtil.removeResult(finderPath, finderArgs);
4985
4986 throw processException(e);
4987 }
4988 finally {
4989 closeSession(session);
4990 }
4991 }
4992
4993 return count.intValue();
4994 }
4995
4996 private static final String _FINDER_COLUMN_L_H_P_LAYOUTSETBRANCHID_2 = "layoutRevision.layoutSetBranchId = ? AND ";
4997 private static final String _FINDER_COLUMN_L_H_P_HEAD_2 = "layoutRevision.head = ? AND ";
4998 private static final String _FINDER_COLUMN_L_H_P_PLID_2 = "layoutRevision.plid = ?";
4999 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_L_P_S = new FinderPath(LayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
5000 LayoutRevisionModelImpl.FINDER_CACHE_ENABLED,
5001 LayoutRevisionImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
5002 "findByL_P_S",
5003 new String[] {
5004 Long.class.getName(), Long.class.getName(),
5005 Integer.class.getName(),
5006
5007 Integer.class.getName(), Integer.class.getName(),
5008 OrderByComparator.class.getName()
5009 });
5010 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_P_S = new FinderPath(LayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
5011 LayoutRevisionModelImpl.FINDER_CACHE_ENABLED,
5012 LayoutRevisionImpl.class,
5013 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByL_P_S",
5014 new String[] {
5015 Long.class.getName(), Long.class.getName(),
5016 Integer.class.getName()
5017 },
5018 LayoutRevisionModelImpl.LAYOUTSETBRANCHID_COLUMN_BITMASK |
5019 LayoutRevisionModelImpl.PLID_COLUMN_BITMASK |
5020 LayoutRevisionModelImpl.STATUS_COLUMN_BITMASK |
5021 LayoutRevisionModelImpl.MODIFIEDDATE_COLUMN_BITMASK);
5022 public static final FinderPath FINDER_PATH_COUNT_BY_L_P_S = new FinderPath(LayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
5023 LayoutRevisionModelImpl.FINDER_CACHE_ENABLED, Long.class,
5024 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByL_P_S",
5025 new String[] {
5026 Long.class.getName(), Long.class.getName(),
5027 Integer.class.getName()
5028 });
5029
5030
5039 public List<LayoutRevision> findByL_P_S(long layoutSetBranchId, long plid,
5040 int status) throws SystemException {
5041 return findByL_P_S(layoutSetBranchId, plid, status, QueryUtil.ALL_POS,
5042 QueryUtil.ALL_POS, null);
5043 }
5044
5045
5060 public List<LayoutRevision> findByL_P_S(long layoutSetBranchId, long plid,
5061 int status, int start, int end) throws SystemException {
5062 return findByL_P_S(layoutSetBranchId, plid, status, start, end, null);
5063 }
5064
5065
5081 public List<LayoutRevision> findByL_P_S(long layoutSetBranchId, long plid,
5082 int status, int start, int end, OrderByComparator orderByComparator)
5083 throws SystemException {
5084 boolean pagination = true;
5085 FinderPath finderPath = null;
5086 Object[] finderArgs = null;
5087
5088 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
5089 (orderByComparator == null)) {
5090 pagination = false;
5091 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_P_S;
5092 finderArgs = new Object[] { layoutSetBranchId, plid, status };
5093 }
5094 else {
5095 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_L_P_S;
5096 finderArgs = new Object[] {
5097 layoutSetBranchId, plid, status,
5098
5099 start, end, orderByComparator
5100 };
5101 }
5102
5103 List<LayoutRevision> list = (List<LayoutRevision>)FinderCacheUtil.getResult(finderPath,
5104 finderArgs, this);
5105
5106 if ((list != null) && !list.isEmpty()) {
5107 for (LayoutRevision layoutRevision : list) {
5108 if ((layoutSetBranchId != layoutRevision.getLayoutSetBranchId()) ||
5109 (plid != layoutRevision.getPlid()) ||
5110 (status != layoutRevision.getStatus())) {
5111 list = null;
5112
5113 break;
5114 }
5115 }
5116 }
5117
5118 if (list == null) {
5119 StringBundler query = null;
5120
5121 if (orderByComparator != null) {
5122 query = new StringBundler(5 +
5123 (orderByComparator.getOrderByFields().length * 3));
5124 }
5125 else {
5126 query = new StringBundler(5);
5127 }
5128
5129 query.append(_SQL_SELECT_LAYOUTREVISION_WHERE);
5130
5131 query.append(_FINDER_COLUMN_L_P_S_LAYOUTSETBRANCHID_2);
5132
5133 query.append(_FINDER_COLUMN_L_P_S_PLID_2);
5134
5135 query.append(_FINDER_COLUMN_L_P_S_STATUS_2);
5136
5137 if (orderByComparator != null) {
5138 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5139 orderByComparator);
5140 }
5141 else
5142 if (pagination) {
5143 query.append(LayoutRevisionModelImpl.ORDER_BY_JPQL);
5144 }
5145
5146 String sql = query.toString();
5147
5148 Session session = null;
5149
5150 try {
5151 session = openSession();
5152
5153 Query q = session.createQuery(sql);
5154
5155 QueryPos qPos = QueryPos.getInstance(q);
5156
5157 qPos.add(layoutSetBranchId);
5158
5159 qPos.add(plid);
5160
5161 qPos.add(status);
5162
5163 if (!pagination) {
5164 list = (List<LayoutRevision>)QueryUtil.list(q,
5165 getDialect(), start, end, false);
5166
5167 Collections.sort(list);
5168
5169 list = new UnmodifiableList<LayoutRevision>(list);
5170 }
5171 else {
5172 list = (List<LayoutRevision>)QueryUtil.list(q,
5173 getDialect(), start, end);
5174 }
5175
5176 cacheResult(list);
5177
5178 FinderCacheUtil.putResult(finderPath, finderArgs, list);
5179 }
5180 catch (Exception e) {
5181 FinderCacheUtil.removeResult(finderPath, finderArgs);
5182
5183 throw processException(e);
5184 }
5185 finally {
5186 closeSession(session);
5187 }
5188 }
5189
5190 return list;
5191 }
5192
5193
5204 public LayoutRevision findByL_P_S_First(long layoutSetBranchId, long plid,
5205 int status, OrderByComparator orderByComparator)
5206 throws NoSuchLayoutRevisionException, SystemException {
5207 LayoutRevision layoutRevision = fetchByL_P_S_First(layoutSetBranchId,
5208 plid, status, orderByComparator);
5209
5210 if (layoutRevision != null) {
5211 return layoutRevision;
5212 }
5213
5214 StringBundler msg = new StringBundler(8);
5215
5216 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5217
5218 msg.append("layoutSetBranchId=");
5219 msg.append(layoutSetBranchId);
5220
5221 msg.append(", plid=");
5222 msg.append(plid);
5223
5224 msg.append(", status=");
5225 msg.append(status);
5226
5227 msg.append(StringPool.CLOSE_CURLY_BRACE);
5228
5229 throw new NoSuchLayoutRevisionException(msg.toString());
5230 }
5231
5232
5242 public LayoutRevision fetchByL_P_S_First(long layoutSetBranchId, long plid,
5243 int status, OrderByComparator orderByComparator)
5244 throws SystemException {
5245 List<LayoutRevision> list = findByL_P_S(layoutSetBranchId, plid,
5246 status, 0, 1, orderByComparator);
5247
5248 if (!list.isEmpty()) {
5249 return list.get(0);
5250 }
5251
5252 return null;
5253 }
5254
5255
5266 public LayoutRevision findByL_P_S_Last(long layoutSetBranchId, long plid,
5267 int status, OrderByComparator orderByComparator)
5268 throws NoSuchLayoutRevisionException, SystemException {
5269 LayoutRevision layoutRevision = fetchByL_P_S_Last(layoutSetBranchId,
5270 plid, status, orderByComparator);
5271
5272 if (layoutRevision != null) {
5273 return layoutRevision;
5274 }
5275
5276 StringBundler msg = new StringBundler(8);
5277
5278 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5279
5280 msg.append("layoutSetBranchId=");
5281 msg.append(layoutSetBranchId);
5282
5283 msg.append(", plid=");
5284 msg.append(plid);
5285
5286 msg.append(", status=");
5287 msg.append(status);
5288
5289 msg.append(StringPool.CLOSE_CURLY_BRACE);
5290
5291 throw new NoSuchLayoutRevisionException(msg.toString());
5292 }
5293
5294
5304 public LayoutRevision fetchByL_P_S_Last(long layoutSetBranchId, long plid,
5305 int status, OrderByComparator orderByComparator)
5306 throws SystemException {
5307 int count = countByL_P_S(layoutSetBranchId, plid, status);
5308
5309 List<LayoutRevision> list = findByL_P_S(layoutSetBranchId, plid,
5310 status, count - 1, count, orderByComparator);
5311
5312 if (!list.isEmpty()) {
5313 return list.get(0);
5314 }
5315
5316 return null;
5317 }
5318
5319
5331 public LayoutRevision[] findByL_P_S_PrevAndNext(long layoutRevisionId,
5332 long layoutSetBranchId, long plid, int status,
5333 OrderByComparator orderByComparator)
5334 throws NoSuchLayoutRevisionException, SystemException {
5335 LayoutRevision layoutRevision = findByPrimaryKey(layoutRevisionId);
5336
5337 Session session = null;
5338
5339 try {
5340 session = openSession();
5341
5342 LayoutRevision[] array = new LayoutRevisionImpl[3];
5343
5344 array[0] = getByL_P_S_PrevAndNext(session, layoutRevision,
5345 layoutSetBranchId, plid, status, orderByComparator, true);
5346
5347 array[1] = layoutRevision;
5348
5349 array[2] = getByL_P_S_PrevAndNext(session, layoutRevision,
5350 layoutSetBranchId, plid, status, orderByComparator, false);
5351
5352 return array;
5353 }
5354 catch (Exception e) {
5355 throw processException(e);
5356 }
5357 finally {
5358 closeSession(session);
5359 }
5360 }
5361
5362 protected LayoutRevision getByL_P_S_PrevAndNext(Session session,
5363 LayoutRevision layoutRevision, long layoutSetBranchId, long plid,
5364 int status, OrderByComparator orderByComparator, boolean previous) {
5365 StringBundler query = null;
5366
5367 if (orderByComparator != null) {
5368 query = new StringBundler(6 +
5369 (orderByComparator.getOrderByFields().length * 6));
5370 }
5371 else {
5372 query = new StringBundler(3);
5373 }
5374
5375 query.append(_SQL_SELECT_LAYOUTREVISION_WHERE);
5376
5377 query.append(_FINDER_COLUMN_L_P_S_LAYOUTSETBRANCHID_2);
5378
5379 query.append(_FINDER_COLUMN_L_P_S_PLID_2);
5380
5381 query.append(_FINDER_COLUMN_L_P_S_STATUS_2);
5382
5383 if (orderByComparator != null) {
5384 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5385
5386 if (orderByConditionFields.length > 0) {
5387 query.append(WHERE_AND);
5388 }
5389
5390 for (int i = 0; i < orderByConditionFields.length; i++) {
5391 query.append(_ORDER_BY_ENTITY_ALIAS);
5392 query.append(orderByConditionFields[i]);
5393
5394 if ((i + 1) < orderByConditionFields.length) {
5395 if (orderByComparator.isAscending() ^ previous) {
5396 query.append(WHERE_GREATER_THAN_HAS_NEXT);
5397 }
5398 else {
5399 query.append(WHERE_LESSER_THAN_HAS_NEXT);
5400 }
5401 }
5402 else {
5403 if (orderByComparator.isAscending() ^ previous) {
5404 query.append(WHERE_GREATER_THAN);
5405 }
5406 else {
5407 query.append(WHERE_LESSER_THAN);
5408 }
5409 }
5410 }
5411
5412 query.append(ORDER_BY_CLAUSE);
5413
5414 String[] orderByFields = orderByComparator.getOrderByFields();
5415
5416 for (int i = 0; i < orderByFields.length; i++) {
5417 query.append(_ORDER_BY_ENTITY_ALIAS);
5418 query.append(orderByFields[i]);
5419
5420 if ((i + 1) < orderByFields.length) {
5421 if (orderByComparator.isAscending() ^ previous) {
5422 query.append(ORDER_BY_ASC_HAS_NEXT);
5423 }
5424 else {
5425 query.append(ORDER_BY_DESC_HAS_NEXT);
5426 }
5427 }
5428 else {
5429 if (orderByComparator.isAscending() ^ previous) {
5430 query.append(ORDER_BY_ASC);
5431 }
5432 else {
5433 query.append(ORDER_BY_DESC);
5434 }
5435 }
5436 }
5437 }
5438 else {
5439 query.append(LayoutRevisionModelImpl.ORDER_BY_JPQL);
5440 }
5441
5442 String sql = query.toString();
5443
5444 Query q = session.createQuery(sql);
5445
5446 q.setFirstResult(0);
5447 q.setMaxResults(2);
5448
5449 QueryPos qPos = QueryPos.getInstance(q);
5450
5451 qPos.add(layoutSetBranchId);
5452
5453 qPos.add(plid);
5454
5455 qPos.add(status);
5456
5457 if (orderByComparator != null) {
5458 Object[] values = orderByComparator.getOrderByConditionValues(layoutRevision);
5459
5460 for (Object value : values) {
5461 qPos.add(value);
5462 }
5463 }
5464
5465 List<LayoutRevision> list = q.list();
5466
5467 if (list.size() == 2) {
5468 return list.get(1);
5469 }
5470 else {
5471 return null;
5472 }
5473 }
5474
5475
5483 public void removeByL_P_S(long layoutSetBranchId, long plid, int status)
5484 throws SystemException {
5485 for (LayoutRevision layoutRevision : findByL_P_S(layoutSetBranchId,
5486 plid, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
5487 remove(layoutRevision);
5488 }
5489 }
5490
5491
5500 public int countByL_P_S(long layoutSetBranchId, long plid, int status)
5501 throws SystemException {
5502 FinderPath finderPath = FINDER_PATH_COUNT_BY_L_P_S;
5503
5504 Object[] finderArgs = new Object[] { layoutSetBranchId, plid, status };
5505
5506 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
5507 this);
5508
5509 if (count == null) {
5510 StringBundler query = new StringBundler(4);
5511
5512 query.append(_SQL_COUNT_LAYOUTREVISION_WHERE);
5513
5514 query.append(_FINDER_COLUMN_L_P_S_LAYOUTSETBRANCHID_2);
5515
5516 query.append(_FINDER_COLUMN_L_P_S_PLID_2);
5517
5518 query.append(_FINDER_COLUMN_L_P_S_STATUS_2);
5519
5520 String sql = query.toString();
5521
5522 Session session = null;
5523
5524 try {
5525 session = openSession();
5526
5527 Query q = session.createQuery(sql);
5528
5529 QueryPos qPos = QueryPos.getInstance(q);
5530
5531 qPos.add(layoutSetBranchId);
5532
5533 qPos.add(plid);
5534
5535 qPos.add(status);
5536
5537 count = (Long)q.uniqueResult();
5538
5539 FinderCacheUtil.putResult(finderPath, finderArgs, count);
5540 }
5541 catch (Exception e) {
5542 FinderCacheUtil.removeResult(finderPath, finderArgs);
5543
5544 throw processException(e);
5545 }
5546 finally {
5547 closeSession(session);
5548 }
5549 }
5550
5551 return count.intValue();
5552 }
5553
5554 private static final String _FINDER_COLUMN_L_P_S_LAYOUTSETBRANCHID_2 = "layoutRevision.layoutSetBranchId = ? AND ";
5555 private static final String _FINDER_COLUMN_L_P_S_PLID_2 = "layoutRevision.plid = ? AND ";
5556 private static final String _FINDER_COLUMN_L_P_S_STATUS_2 = "layoutRevision.status = ?";
5557
5558
5563 public void cacheResult(LayoutRevision layoutRevision) {
5564 EntityCacheUtil.putResult(LayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
5565 LayoutRevisionImpl.class, layoutRevision.getPrimaryKey(),
5566 layoutRevision);
5567
5568 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_L_H_P,
5569 new Object[] {
5570 layoutRevision.getLayoutSetBranchId(), layoutRevision.getHead(),
5571 layoutRevision.getPlid()
5572 }, layoutRevision);
5573
5574 layoutRevision.resetOriginalValues();
5575 }
5576
5577
5582 public void cacheResult(List<LayoutRevision> layoutRevisions) {
5583 for (LayoutRevision layoutRevision : layoutRevisions) {
5584 if (EntityCacheUtil.getResult(
5585 LayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
5586 LayoutRevisionImpl.class, layoutRevision.getPrimaryKey()) == null) {
5587 cacheResult(layoutRevision);
5588 }
5589 else {
5590 layoutRevision.resetOriginalValues();
5591 }
5592 }
5593 }
5594
5595
5602 @Override
5603 public void clearCache() {
5604 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
5605 CacheRegistryUtil.clear(LayoutRevisionImpl.class.getName());
5606 }
5607
5608 EntityCacheUtil.clearCache(LayoutRevisionImpl.class.getName());
5609
5610 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
5611 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
5612 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
5613 }
5614
5615
5622 @Override
5623 public void clearCache(LayoutRevision layoutRevision) {
5624 EntityCacheUtil.removeResult(LayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
5625 LayoutRevisionImpl.class, layoutRevision.getPrimaryKey());
5626
5627 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
5628 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
5629
5630 clearUniqueFindersCache(layoutRevision);
5631 }
5632
5633 @Override
5634 public void clearCache(List<LayoutRevision> layoutRevisions) {
5635 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
5636 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
5637
5638 for (LayoutRevision layoutRevision : layoutRevisions) {
5639 EntityCacheUtil.removeResult(LayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
5640 LayoutRevisionImpl.class, layoutRevision.getPrimaryKey());
5641
5642 clearUniqueFindersCache(layoutRevision);
5643 }
5644 }
5645
5646 protected void cacheUniqueFindersCache(LayoutRevision layoutRevision) {
5647 if (layoutRevision.isNew()) {
5648 Object[] args = new Object[] {
5649 layoutRevision.getLayoutSetBranchId(),
5650 layoutRevision.getHead(), layoutRevision.getPlid()
5651 };
5652
5653 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_L_H_P, args,
5654 Long.valueOf(1));
5655 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_L_H_P, args,
5656 layoutRevision);
5657 }
5658 else {
5659 LayoutRevisionModelImpl layoutRevisionModelImpl = (LayoutRevisionModelImpl)layoutRevision;
5660
5661 if ((layoutRevisionModelImpl.getColumnBitmask() &
5662 FINDER_PATH_FETCH_BY_L_H_P.getColumnBitmask()) != 0) {
5663 Object[] args = new Object[] {
5664 layoutRevision.getLayoutSetBranchId(),
5665 layoutRevision.getHead(), layoutRevision.getPlid()
5666 };
5667
5668 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_L_H_P, args,
5669 Long.valueOf(1));
5670 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_L_H_P, args,
5671 layoutRevision);
5672 }
5673 }
5674 }
5675
5676 protected void clearUniqueFindersCache(LayoutRevision layoutRevision) {
5677 LayoutRevisionModelImpl layoutRevisionModelImpl = (LayoutRevisionModelImpl)layoutRevision;
5678
5679 Object[] args = new Object[] {
5680 layoutRevision.getLayoutSetBranchId(), layoutRevision.getHead(),
5681 layoutRevision.getPlid()
5682 };
5683
5684 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_L_H_P, args);
5685 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_L_H_P, args);
5686
5687 if ((layoutRevisionModelImpl.getColumnBitmask() &
5688 FINDER_PATH_FETCH_BY_L_H_P.getColumnBitmask()) != 0) {
5689 args = new Object[] {
5690 layoutRevisionModelImpl.getOriginalLayoutSetBranchId(),
5691 layoutRevisionModelImpl.getOriginalHead(),
5692 layoutRevisionModelImpl.getOriginalPlid()
5693 };
5694
5695 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_L_H_P, args);
5696 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_L_H_P, args);
5697 }
5698 }
5699
5700
5706 public LayoutRevision create(long layoutRevisionId) {
5707 LayoutRevision layoutRevision = new LayoutRevisionImpl();
5708
5709 layoutRevision.setNew(true);
5710 layoutRevision.setPrimaryKey(layoutRevisionId);
5711
5712 return layoutRevision;
5713 }
5714
5715
5723 public LayoutRevision remove(long layoutRevisionId)
5724 throws NoSuchLayoutRevisionException, SystemException {
5725 return remove((Serializable)layoutRevisionId);
5726 }
5727
5728
5736 @Override
5737 public LayoutRevision remove(Serializable primaryKey)
5738 throws NoSuchLayoutRevisionException, SystemException {
5739 Session session = null;
5740
5741 try {
5742 session = openSession();
5743
5744 LayoutRevision layoutRevision = (LayoutRevision)session.get(LayoutRevisionImpl.class,
5745 primaryKey);
5746
5747 if (layoutRevision == null) {
5748 if (_log.isWarnEnabled()) {
5749 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
5750 }
5751
5752 throw new NoSuchLayoutRevisionException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
5753 primaryKey);
5754 }
5755
5756 return remove(layoutRevision);
5757 }
5758 catch (NoSuchLayoutRevisionException nsee) {
5759 throw nsee;
5760 }
5761 catch (Exception e) {
5762 throw processException(e);
5763 }
5764 finally {
5765 closeSession(session);
5766 }
5767 }
5768
5769 @Override
5770 protected LayoutRevision removeImpl(LayoutRevision layoutRevision)
5771 throws SystemException {
5772 layoutRevision = toUnwrappedModel(layoutRevision);
5773
5774 Session session = null;
5775
5776 try {
5777 session = openSession();
5778
5779 if (!session.contains(layoutRevision)) {
5780 layoutRevision = (LayoutRevision)session.get(LayoutRevisionImpl.class,
5781 layoutRevision.getPrimaryKeyObj());
5782 }
5783
5784 if (layoutRevision != null) {
5785 session.delete(layoutRevision);
5786 }
5787 }
5788 catch (Exception e) {
5789 throw processException(e);
5790 }
5791 finally {
5792 closeSession(session);
5793 }
5794
5795 if (layoutRevision != null) {
5796 clearCache(layoutRevision);
5797 }
5798
5799 return layoutRevision;
5800 }
5801
5802 @Override
5803 public LayoutRevision updateImpl(
5804 com.liferay.portal.model.LayoutRevision layoutRevision)
5805 throws SystemException {
5806 layoutRevision = toUnwrappedModel(layoutRevision);
5807
5808 boolean isNew = layoutRevision.isNew();
5809
5810 LayoutRevisionModelImpl layoutRevisionModelImpl = (LayoutRevisionModelImpl)layoutRevision;
5811
5812 Session session = null;
5813
5814 try {
5815 session = openSession();
5816
5817 if (layoutRevision.isNew()) {
5818 session.save(layoutRevision);
5819
5820 layoutRevision.setNew(false);
5821 }
5822 else {
5823 session.merge(layoutRevision);
5824 }
5825 }
5826 catch (Exception e) {
5827 throw processException(e);
5828 }
5829 finally {
5830 closeSession(session);
5831 }
5832
5833 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
5834
5835 if (isNew || !LayoutRevisionModelImpl.COLUMN_BITMASK_ENABLED) {
5836 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
5837 }
5838
5839 else {
5840 if ((layoutRevisionModelImpl.getColumnBitmask() &
5841 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LAYOUTSETBRANCHID.getColumnBitmask()) != 0) {
5842 Object[] args = new Object[] {
5843 layoutRevisionModelImpl.getOriginalLayoutSetBranchId()
5844 };
5845
5846 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_LAYOUTSETBRANCHID,
5847 args);
5848 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LAYOUTSETBRANCHID,
5849 args);
5850
5851 args = new Object[] {
5852 layoutRevisionModelImpl.getLayoutSetBranchId()
5853 };
5854
5855 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_LAYOUTSETBRANCHID,
5856 args);
5857 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LAYOUTSETBRANCHID,
5858 args);
5859 }
5860
5861 if ((layoutRevisionModelImpl.getColumnBitmask() &
5862 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PLID.getColumnBitmask()) != 0) {
5863 Object[] args = new Object[] {
5864 layoutRevisionModelImpl.getOriginalPlid()
5865 };
5866
5867 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_PLID, args);
5868 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PLID,
5869 args);
5870
5871 args = new Object[] { layoutRevisionModelImpl.getPlid() };
5872
5873 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_PLID, args);
5874 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PLID,
5875 args);
5876 }
5877
5878 if ((layoutRevisionModelImpl.getColumnBitmask() &
5879 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_H.getColumnBitmask()) != 0) {
5880 Object[] args = new Object[] {
5881 layoutRevisionModelImpl.getOriginalLayoutSetBranchId(),
5882 layoutRevisionModelImpl.getOriginalHead()
5883 };
5884
5885 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_L_H, args);
5886 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_H,
5887 args);
5888
5889 args = new Object[] {
5890 layoutRevisionModelImpl.getLayoutSetBranchId(),
5891 layoutRevisionModelImpl.getHead()
5892 };
5893
5894 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_L_H, args);
5895 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_H,
5896 args);
5897 }
5898
5899 if ((layoutRevisionModelImpl.getColumnBitmask() &
5900 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_P.getColumnBitmask()) != 0) {
5901 Object[] args = new Object[] {
5902 layoutRevisionModelImpl.getOriginalLayoutSetBranchId(),
5903 layoutRevisionModelImpl.getOriginalPlid()
5904 };
5905
5906 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_L_P, args);
5907 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_P,
5908 args);
5909
5910 args = new Object[] {
5911 layoutRevisionModelImpl.getLayoutSetBranchId(),
5912 layoutRevisionModelImpl.getPlid()
5913 };
5914
5915 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_L_P, args);
5916 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_P,
5917 args);
5918 }
5919
5920 if ((layoutRevisionModelImpl.getColumnBitmask() &
5921 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_S.getColumnBitmask()) != 0) {
5922 Object[] args = new Object[] {
5923 layoutRevisionModelImpl.getOriginalLayoutSetBranchId(),
5924 layoutRevisionModelImpl.getOriginalStatus()
5925 };
5926
5927 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_L_S, args);
5928 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_S,
5929 args);
5930
5931 args = new Object[] {
5932 layoutRevisionModelImpl.getLayoutSetBranchId(),
5933 layoutRevisionModelImpl.getStatus()
5934 };
5935
5936 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_L_S, args);
5937 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_S,
5938 args);
5939 }
5940
5941 if ((layoutRevisionModelImpl.getColumnBitmask() &
5942 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_H_P.getColumnBitmask()) != 0) {
5943 Object[] args = new Object[] {
5944 layoutRevisionModelImpl.getOriginalHead(),
5945 layoutRevisionModelImpl.getOriginalPlid()
5946 };
5947
5948 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_H_P, args);
5949 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_H_P,
5950 args);
5951
5952 args = new Object[] {
5953 layoutRevisionModelImpl.getHead(),
5954 layoutRevisionModelImpl.getPlid()
5955 };
5956
5957 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_H_P, args);
5958 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_H_P,
5959 args);
5960 }
5961
5962 if ((layoutRevisionModelImpl.getColumnBitmask() &
5963 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_L_P.getColumnBitmask()) != 0) {
5964 Object[] args = new Object[] {
5965 layoutRevisionModelImpl.getOriginalLayoutSetBranchId(),
5966 layoutRevisionModelImpl.getOriginalLayoutBranchId(),
5967 layoutRevisionModelImpl.getOriginalPlid()
5968 };
5969
5970 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_L_L_P, args);
5971 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_L_P,
5972 args);
5973
5974 args = new Object[] {
5975 layoutRevisionModelImpl.getLayoutSetBranchId(),
5976 layoutRevisionModelImpl.getLayoutBranchId(),
5977 layoutRevisionModelImpl.getPlid()
5978 };
5979
5980 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_L_L_P, args);
5981 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_L_P,
5982 args);
5983 }
5984
5985 if ((layoutRevisionModelImpl.getColumnBitmask() &
5986 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_P_P.getColumnBitmask()) != 0) {
5987 Object[] args = new Object[] {
5988 layoutRevisionModelImpl.getOriginalLayoutSetBranchId(),
5989 layoutRevisionModelImpl.getOriginalParentLayoutRevisionId(),
5990 layoutRevisionModelImpl.getOriginalPlid()
5991 };
5992
5993 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_L_P_P, args);
5994 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_P_P,
5995 args);
5996
5997 args = new Object[] {
5998 layoutRevisionModelImpl.getLayoutSetBranchId(),
5999 layoutRevisionModelImpl.getParentLayoutRevisionId(),
6000 layoutRevisionModelImpl.getPlid()
6001 };
6002
6003 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_L_P_P, args);
6004 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_P_P,
6005 args);
6006 }
6007
6008 if ((layoutRevisionModelImpl.getColumnBitmask() &
6009 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_P_S.getColumnBitmask()) != 0) {
6010 Object[] args = new Object[] {
6011 layoutRevisionModelImpl.getOriginalLayoutSetBranchId(),
6012 layoutRevisionModelImpl.getOriginalPlid(),
6013 layoutRevisionModelImpl.getOriginalStatus()
6014 };
6015
6016 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_L_P_S, args);
6017 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_P_S,
6018 args);
6019
6020 args = new Object[] {
6021 layoutRevisionModelImpl.getLayoutSetBranchId(),
6022 layoutRevisionModelImpl.getPlid(),
6023 layoutRevisionModelImpl.getStatus()
6024 };
6025
6026 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_L_P_S, args);
6027 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_L_P_S,
6028 args);
6029 }
6030 }
6031
6032 EntityCacheUtil.putResult(LayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
6033 LayoutRevisionImpl.class, layoutRevision.getPrimaryKey(),
6034 layoutRevision);
6035
6036 clearUniqueFindersCache(layoutRevision);
6037 cacheUniqueFindersCache(layoutRevision);
6038
6039 return layoutRevision;
6040 }
6041
6042 protected LayoutRevision toUnwrappedModel(LayoutRevision layoutRevision) {
6043 if (layoutRevision instanceof LayoutRevisionImpl) {
6044 return layoutRevision;
6045 }
6046
6047 LayoutRevisionImpl layoutRevisionImpl = new LayoutRevisionImpl();
6048
6049 layoutRevisionImpl.setNew(layoutRevision.isNew());
6050 layoutRevisionImpl.setPrimaryKey(layoutRevision.getPrimaryKey());
6051
6052 layoutRevisionImpl.setLayoutRevisionId(layoutRevision.getLayoutRevisionId());
6053 layoutRevisionImpl.setGroupId(layoutRevision.getGroupId());
6054 layoutRevisionImpl.setCompanyId(layoutRevision.getCompanyId());
6055 layoutRevisionImpl.setUserId(layoutRevision.getUserId());
6056 layoutRevisionImpl.setUserName(layoutRevision.getUserName());
6057 layoutRevisionImpl.setCreateDate(layoutRevision.getCreateDate());
6058 layoutRevisionImpl.setModifiedDate(layoutRevision.getModifiedDate());
6059 layoutRevisionImpl.setLayoutSetBranchId(layoutRevision.getLayoutSetBranchId());
6060 layoutRevisionImpl.setLayoutBranchId(layoutRevision.getLayoutBranchId());
6061 layoutRevisionImpl.setParentLayoutRevisionId(layoutRevision.getParentLayoutRevisionId());
6062 layoutRevisionImpl.setHead(layoutRevision.isHead());
6063 layoutRevisionImpl.setMajor(layoutRevision.isMajor());
6064 layoutRevisionImpl.setPlid(layoutRevision.getPlid());
6065 layoutRevisionImpl.setPrivateLayout(layoutRevision.isPrivateLayout());
6066 layoutRevisionImpl.setName(layoutRevision.getName());
6067 layoutRevisionImpl.setTitle(layoutRevision.getTitle());
6068 layoutRevisionImpl.setDescription(layoutRevision.getDescription());
6069 layoutRevisionImpl.setKeywords(layoutRevision.getKeywords());
6070 layoutRevisionImpl.setRobots(layoutRevision.getRobots());
6071 layoutRevisionImpl.setTypeSettings(layoutRevision.getTypeSettings());
6072 layoutRevisionImpl.setIconImage(layoutRevision.isIconImage());
6073 layoutRevisionImpl.setIconImageId(layoutRevision.getIconImageId());
6074 layoutRevisionImpl.setThemeId(layoutRevision.getThemeId());
6075 layoutRevisionImpl.setColorSchemeId(layoutRevision.getColorSchemeId());
6076 layoutRevisionImpl.setWapThemeId(layoutRevision.getWapThemeId());
6077 layoutRevisionImpl.setWapColorSchemeId(layoutRevision.getWapColorSchemeId());
6078 layoutRevisionImpl.setCss(layoutRevision.getCss());
6079 layoutRevisionImpl.setStatus(layoutRevision.getStatus());
6080 layoutRevisionImpl.setStatusByUserId(layoutRevision.getStatusByUserId());
6081 layoutRevisionImpl.setStatusByUserName(layoutRevision.getStatusByUserName());
6082 layoutRevisionImpl.setStatusDate(layoutRevision.getStatusDate());
6083
6084 return layoutRevisionImpl;
6085 }
6086
6087
6095 @Override
6096 public LayoutRevision findByPrimaryKey(Serializable primaryKey)
6097 throws NoSuchLayoutRevisionException, SystemException {
6098 LayoutRevision layoutRevision = fetchByPrimaryKey(primaryKey);
6099
6100 if (layoutRevision == null) {
6101 if (_log.isWarnEnabled()) {
6102 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
6103 }
6104
6105 throw new NoSuchLayoutRevisionException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
6106 primaryKey);
6107 }
6108
6109 return layoutRevision;
6110 }
6111
6112
6120 public LayoutRevision findByPrimaryKey(long layoutRevisionId)
6121 throws NoSuchLayoutRevisionException, SystemException {
6122 return findByPrimaryKey((Serializable)layoutRevisionId);
6123 }
6124
6125
6132 @Override
6133 public LayoutRevision fetchByPrimaryKey(Serializable primaryKey)
6134 throws SystemException {
6135 LayoutRevision layoutRevision = (LayoutRevision)EntityCacheUtil.getResult(LayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
6136 LayoutRevisionImpl.class, primaryKey);
6137
6138 if (layoutRevision == _nullLayoutRevision) {
6139 return null;
6140 }
6141
6142 if (layoutRevision == null) {
6143 Session session = null;
6144
6145 try {
6146 session = openSession();
6147
6148 layoutRevision = (LayoutRevision)session.get(LayoutRevisionImpl.class,
6149 primaryKey);
6150
6151 if (layoutRevision != null) {
6152 cacheResult(layoutRevision);
6153 }
6154 else {
6155 EntityCacheUtil.putResult(LayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
6156 LayoutRevisionImpl.class, primaryKey,
6157 _nullLayoutRevision);
6158 }
6159 }
6160 catch (Exception e) {
6161 EntityCacheUtil.removeResult(LayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
6162 LayoutRevisionImpl.class, primaryKey);
6163
6164 throw processException(e);
6165 }
6166 finally {
6167 closeSession(session);
6168 }
6169 }
6170
6171 return layoutRevision;
6172 }
6173
6174
6181 public LayoutRevision fetchByPrimaryKey(long layoutRevisionId)
6182 throws SystemException {
6183 return fetchByPrimaryKey((Serializable)layoutRevisionId);
6184 }
6185
6186
6192 public List<LayoutRevision> findAll() throws SystemException {
6193 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
6194 }
6195
6196
6208 public List<LayoutRevision> findAll(int start, int end)
6209 throws SystemException {
6210 return findAll(start, end, null);
6211 }
6212
6213
6226 public List<LayoutRevision> findAll(int start, int end,
6227 OrderByComparator orderByComparator) throws SystemException {
6228 boolean pagination = true;
6229 FinderPath finderPath = null;
6230 Object[] finderArgs = null;
6231
6232 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
6233 (orderByComparator == null)) {
6234 pagination = false;
6235 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
6236 finderArgs = FINDER_ARGS_EMPTY;
6237 }
6238 else {
6239 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
6240 finderArgs = new Object[] { start, end, orderByComparator };
6241 }
6242
6243 List<LayoutRevision> list = (List<LayoutRevision>)FinderCacheUtil.getResult(finderPath,
6244 finderArgs, this);
6245
6246 if (list == null) {
6247 StringBundler query = null;
6248 String sql = null;
6249
6250 if (orderByComparator != null) {
6251 query = new StringBundler(2 +
6252 (orderByComparator.getOrderByFields().length * 3));
6253
6254 query.append(_SQL_SELECT_LAYOUTREVISION);
6255
6256 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6257 orderByComparator);
6258
6259 sql = query.toString();
6260 }
6261 else {
6262 sql = _SQL_SELECT_LAYOUTREVISION;
6263
6264 if (pagination) {
6265 sql = sql.concat(LayoutRevisionModelImpl.ORDER_BY_JPQL);
6266 }
6267 }
6268
6269 Session session = null;
6270
6271 try {
6272 session = openSession();
6273
6274 Query q = session.createQuery(sql);
6275
6276 if (!pagination) {
6277 list = (List<LayoutRevision>)QueryUtil.list(q,
6278 getDialect(), start, end, false);
6279
6280 Collections.sort(list);
6281
6282 list = new UnmodifiableList<LayoutRevision>(list);
6283 }
6284 else {
6285 list = (List<LayoutRevision>)QueryUtil.list(q,
6286 getDialect(), start, end);
6287 }
6288
6289 cacheResult(list);
6290
6291 FinderCacheUtil.putResult(finderPath, finderArgs, list);
6292 }
6293 catch (Exception e) {
6294 FinderCacheUtil.removeResult(finderPath, finderArgs);
6295
6296 throw processException(e);
6297 }
6298 finally {
6299 closeSession(session);
6300 }
6301 }
6302
6303 return list;
6304 }
6305
6306
6311 public void removeAll() throws SystemException {
6312 for (LayoutRevision layoutRevision : findAll()) {
6313 remove(layoutRevision);
6314 }
6315 }
6316
6317
6323 public int countAll() throws SystemException {
6324 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
6325 FINDER_ARGS_EMPTY, this);
6326
6327 if (count == null) {
6328 Session session = null;
6329
6330 try {
6331 session = openSession();
6332
6333 Query q = session.createQuery(_SQL_COUNT_LAYOUTREVISION);
6334
6335 count = (Long)q.uniqueResult();
6336
6337 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
6338 FINDER_ARGS_EMPTY, count);
6339 }
6340 catch (Exception e) {
6341 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
6342 FINDER_ARGS_EMPTY);
6343
6344 throw processException(e);
6345 }
6346 finally {
6347 closeSession(session);
6348 }
6349 }
6350
6351 return count.intValue();
6352 }
6353
6354
6357 public void afterPropertiesSet() {
6358 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
6359 com.liferay.portal.util.PropsUtil.get(
6360 "value.object.listener.com.liferay.portal.model.LayoutRevision")));
6361
6362 if (listenerClassNames.length > 0) {
6363 try {
6364 List<ModelListener<LayoutRevision>> listenersList = new ArrayList<ModelListener<LayoutRevision>>();
6365
6366 for (String listenerClassName : listenerClassNames) {
6367 listenersList.add((ModelListener<LayoutRevision>)InstanceFactory.newInstance(
6368 getClassLoader(), listenerClassName));
6369 }
6370
6371 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
6372 }
6373 catch (Exception e) {
6374 _log.error(e);
6375 }
6376 }
6377 }
6378
6379 public void destroy() {
6380 EntityCacheUtil.removeCache(LayoutRevisionImpl.class.getName());
6381 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
6382 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
6383 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
6384 }
6385
6386 private static final String _SQL_SELECT_LAYOUTREVISION = "SELECT layoutRevision FROM LayoutRevision layoutRevision";
6387 private static final String _SQL_SELECT_LAYOUTREVISION_WHERE = "SELECT layoutRevision FROM LayoutRevision layoutRevision WHERE ";
6388 private static final String _SQL_COUNT_LAYOUTREVISION = "SELECT COUNT(layoutRevision) FROM LayoutRevision layoutRevision";
6389 private static final String _SQL_COUNT_LAYOUTREVISION_WHERE = "SELECT COUNT(layoutRevision) FROM LayoutRevision layoutRevision WHERE ";
6390 private static final String _ORDER_BY_ENTITY_ALIAS = "layoutRevision.";
6391 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No LayoutRevision exists with the primary key ";
6392 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No LayoutRevision exists with the key {";
6393 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
6394 private static Log _log = LogFactoryUtil.getLog(LayoutRevisionPersistenceImpl.class);
6395 private static LayoutRevision _nullLayoutRevision = new LayoutRevisionImpl() {
6396 @Override
6397 public Object clone() {
6398 return this;
6399 }
6400
6401 @Override
6402 public CacheModel<LayoutRevision> toCacheModel() {
6403 return _nullLayoutRevisionCacheModel;
6404 }
6405 };
6406
6407 private static CacheModel<LayoutRevision> _nullLayoutRevisionCacheModel = new CacheModel<LayoutRevision>() {
6408 public LayoutRevision toEntityModel() {
6409 return _nullLayoutRevision;
6410 }
6411 };
6412 }