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