001
014
015 package com.liferay.portal.service.persistence.impl;
016
017 import aQute.bnd.annotation.ProviderType;
018
019 import com.liferay.portal.exception.NoSuchRecentLayoutRevisionException;
020 import com.liferay.portal.kernel.bean.BeanReference;
021 import com.liferay.portal.kernel.dao.orm.EntityCache;
022 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
023 import com.liferay.portal.kernel.dao.orm.FinderCache;
024 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
025 import com.liferay.portal.kernel.dao.orm.FinderPath;
026 import com.liferay.portal.kernel.dao.orm.Query;
027 import com.liferay.portal.kernel.dao.orm.QueryPos;
028 import com.liferay.portal.kernel.dao.orm.QueryUtil;
029 import com.liferay.portal.kernel.dao.orm.Session;
030 import com.liferay.portal.kernel.log.Log;
031 import com.liferay.portal.kernel.log.LogFactoryUtil;
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.model.CacheModel;
036 import com.liferay.portal.model.MVCCModel;
037 import com.liferay.portal.model.RecentLayoutRevision;
038 import com.liferay.portal.model.impl.RecentLayoutRevisionImpl;
039 import com.liferay.portal.model.impl.RecentLayoutRevisionModelImpl;
040 import com.liferay.portal.service.persistence.CompanyProvider;
041 import com.liferay.portal.service.persistence.CompanyProviderWrapper;
042 import com.liferay.portal.service.persistence.RecentLayoutRevisionPersistence;
043
044 import java.io.Serializable;
045
046 import java.util.Collections;
047 import java.util.HashMap;
048 import java.util.HashSet;
049 import java.util.Iterator;
050 import java.util.List;
051 import java.util.Map;
052 import java.util.Set;
053
054
066 @ProviderType
067 public class RecentLayoutRevisionPersistenceImpl extends BasePersistenceImpl<RecentLayoutRevision>
068 implements RecentLayoutRevisionPersistence {
069
074 public static final String FINDER_CLASS_NAME_ENTITY = RecentLayoutRevisionImpl.class.getName();
075 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
076 ".List1";
077 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
078 ".List2";
079 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(RecentLayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
080 RecentLayoutRevisionModelImpl.FINDER_CACHE_ENABLED,
081 RecentLayoutRevisionImpl.class,
082 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
083 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(RecentLayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
084 RecentLayoutRevisionModelImpl.FINDER_CACHE_ENABLED,
085 RecentLayoutRevisionImpl.class,
086 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
087 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(RecentLayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
088 RecentLayoutRevisionModelImpl.FINDER_CACHE_ENABLED, Long.class,
089 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
090 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(RecentLayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
091 RecentLayoutRevisionModelImpl.FINDER_CACHE_ENABLED,
092 RecentLayoutRevisionImpl.class,
093 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByGroupId",
094 new String[] {
095 Long.class.getName(),
096
097 Integer.class.getName(), Integer.class.getName(),
098 OrderByComparator.class.getName()
099 });
100 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID =
101 new FinderPath(RecentLayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
102 RecentLayoutRevisionModelImpl.FINDER_CACHE_ENABLED,
103 RecentLayoutRevisionImpl.class,
104 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByGroupId",
105 new String[] { Long.class.getName() },
106 RecentLayoutRevisionModelImpl.GROUPID_COLUMN_BITMASK);
107 public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(RecentLayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
108 RecentLayoutRevisionModelImpl.FINDER_CACHE_ENABLED, Long.class,
109 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId",
110 new String[] { Long.class.getName() });
111
112
118 @Override
119 public List<RecentLayoutRevision> findByGroupId(long groupId) {
120 return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
121 }
122
123
135 @Override
136 public List<RecentLayoutRevision> findByGroupId(long groupId, int start,
137 int end) {
138 return findByGroupId(groupId, start, end, null);
139 }
140
141
154 @Override
155 public List<RecentLayoutRevision> findByGroupId(long groupId, int start,
156 int end, OrderByComparator<RecentLayoutRevision> orderByComparator) {
157 return findByGroupId(groupId, start, end, orderByComparator, true);
158 }
159
160
174 @Override
175 public List<RecentLayoutRevision> findByGroupId(long groupId, int start,
176 int end, OrderByComparator<RecentLayoutRevision> orderByComparator,
177 boolean retrieveFromCache) {
178 boolean pagination = true;
179 FinderPath finderPath = null;
180 Object[] finderArgs = null;
181
182 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
183 (orderByComparator == null)) {
184 pagination = false;
185 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
186 finderArgs = new Object[] { groupId };
187 }
188 else {
189 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
190 finderArgs = new Object[] { groupId, start, end, orderByComparator };
191 }
192
193 List<RecentLayoutRevision> list = null;
194
195 if (retrieveFromCache) {
196 list = (List<RecentLayoutRevision>)finderCache.getResult(finderPath,
197 finderArgs, this);
198
199 if ((list != null) && !list.isEmpty()) {
200 for (RecentLayoutRevision recentLayoutRevision : list) {
201 if ((groupId != recentLayoutRevision.getGroupId())) {
202 list = null;
203
204 break;
205 }
206 }
207 }
208 }
209
210 if (list == null) {
211 StringBundler query = null;
212
213 if (orderByComparator != null) {
214 query = new StringBundler(3 +
215 (orderByComparator.getOrderByFields().length * 2));
216 }
217 else {
218 query = new StringBundler(3);
219 }
220
221 query.append(_SQL_SELECT_RECENTLAYOUTREVISION_WHERE);
222
223 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
224
225 if (orderByComparator != null) {
226 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
227 orderByComparator);
228 }
229 else
230 if (pagination) {
231 query.append(RecentLayoutRevisionModelImpl.ORDER_BY_JPQL);
232 }
233
234 String sql = query.toString();
235
236 Session session = null;
237
238 try {
239 session = openSession();
240
241 Query q = session.createQuery(sql);
242
243 QueryPos qPos = QueryPos.getInstance(q);
244
245 qPos.add(groupId);
246
247 if (!pagination) {
248 list = (List<RecentLayoutRevision>)QueryUtil.list(q,
249 getDialect(), start, end, false);
250
251 Collections.sort(list);
252
253 list = Collections.unmodifiableList(list);
254 }
255 else {
256 list = (List<RecentLayoutRevision>)QueryUtil.list(q,
257 getDialect(), start, end);
258 }
259
260 cacheResult(list);
261
262 finderCache.putResult(finderPath, finderArgs, list);
263 }
264 catch (Exception e) {
265 finderCache.removeResult(finderPath, finderArgs);
266
267 throw processException(e);
268 }
269 finally {
270 closeSession(session);
271 }
272 }
273
274 return list;
275 }
276
277
285 @Override
286 public RecentLayoutRevision findByGroupId_First(long groupId,
287 OrderByComparator<RecentLayoutRevision> orderByComparator)
288 throws NoSuchRecentLayoutRevisionException {
289 RecentLayoutRevision recentLayoutRevision = fetchByGroupId_First(groupId,
290 orderByComparator);
291
292 if (recentLayoutRevision != null) {
293 return recentLayoutRevision;
294 }
295
296 StringBundler msg = new StringBundler(4);
297
298 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
299
300 msg.append("groupId=");
301 msg.append(groupId);
302
303 msg.append(StringPool.CLOSE_CURLY_BRACE);
304
305 throw new NoSuchRecentLayoutRevisionException(msg.toString());
306 }
307
308
315 @Override
316 public RecentLayoutRevision fetchByGroupId_First(long groupId,
317 OrderByComparator<RecentLayoutRevision> orderByComparator) {
318 List<RecentLayoutRevision> list = findByGroupId(groupId, 0, 1,
319 orderByComparator);
320
321 if (!list.isEmpty()) {
322 return list.get(0);
323 }
324
325 return null;
326 }
327
328
336 @Override
337 public RecentLayoutRevision findByGroupId_Last(long groupId,
338 OrderByComparator<RecentLayoutRevision> orderByComparator)
339 throws NoSuchRecentLayoutRevisionException {
340 RecentLayoutRevision recentLayoutRevision = fetchByGroupId_Last(groupId,
341 orderByComparator);
342
343 if (recentLayoutRevision != null) {
344 return recentLayoutRevision;
345 }
346
347 StringBundler msg = new StringBundler(4);
348
349 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
350
351 msg.append("groupId=");
352 msg.append(groupId);
353
354 msg.append(StringPool.CLOSE_CURLY_BRACE);
355
356 throw new NoSuchRecentLayoutRevisionException(msg.toString());
357 }
358
359
366 @Override
367 public RecentLayoutRevision fetchByGroupId_Last(long groupId,
368 OrderByComparator<RecentLayoutRevision> orderByComparator) {
369 int count = countByGroupId(groupId);
370
371 if (count == 0) {
372 return null;
373 }
374
375 List<RecentLayoutRevision> list = findByGroupId(groupId, count - 1,
376 count, orderByComparator);
377
378 if (!list.isEmpty()) {
379 return list.get(0);
380 }
381
382 return null;
383 }
384
385
394 @Override
395 public RecentLayoutRevision[] findByGroupId_PrevAndNext(
396 long recentLayoutRevisionId, long groupId,
397 OrderByComparator<RecentLayoutRevision> orderByComparator)
398 throws NoSuchRecentLayoutRevisionException {
399 RecentLayoutRevision recentLayoutRevision = findByPrimaryKey(recentLayoutRevisionId);
400
401 Session session = null;
402
403 try {
404 session = openSession();
405
406 RecentLayoutRevision[] array = new RecentLayoutRevisionImpl[3];
407
408 array[0] = getByGroupId_PrevAndNext(session, recentLayoutRevision,
409 groupId, orderByComparator, true);
410
411 array[1] = recentLayoutRevision;
412
413 array[2] = getByGroupId_PrevAndNext(session, recentLayoutRevision,
414 groupId, orderByComparator, false);
415
416 return array;
417 }
418 catch (Exception e) {
419 throw processException(e);
420 }
421 finally {
422 closeSession(session);
423 }
424 }
425
426 protected RecentLayoutRevision getByGroupId_PrevAndNext(Session session,
427 RecentLayoutRevision recentLayoutRevision, long groupId,
428 OrderByComparator<RecentLayoutRevision> orderByComparator,
429 boolean previous) {
430 StringBundler query = null;
431
432 if (orderByComparator != null) {
433 query = new StringBundler(4 +
434 (orderByComparator.getOrderByConditionFields().length * 3) +
435 (orderByComparator.getOrderByFields().length * 3));
436 }
437 else {
438 query = new StringBundler(3);
439 }
440
441 query.append(_SQL_SELECT_RECENTLAYOUTREVISION_WHERE);
442
443 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
444
445 if (orderByComparator != null) {
446 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
447
448 if (orderByConditionFields.length > 0) {
449 query.append(WHERE_AND);
450 }
451
452 for (int i = 0; i < orderByConditionFields.length; i++) {
453 query.append(_ORDER_BY_ENTITY_ALIAS);
454 query.append(orderByConditionFields[i]);
455
456 if ((i + 1) < orderByConditionFields.length) {
457 if (orderByComparator.isAscending() ^ previous) {
458 query.append(WHERE_GREATER_THAN_HAS_NEXT);
459 }
460 else {
461 query.append(WHERE_LESSER_THAN_HAS_NEXT);
462 }
463 }
464 else {
465 if (orderByComparator.isAscending() ^ previous) {
466 query.append(WHERE_GREATER_THAN);
467 }
468 else {
469 query.append(WHERE_LESSER_THAN);
470 }
471 }
472 }
473
474 query.append(ORDER_BY_CLAUSE);
475
476 String[] orderByFields = orderByComparator.getOrderByFields();
477
478 for (int i = 0; i < orderByFields.length; i++) {
479 query.append(_ORDER_BY_ENTITY_ALIAS);
480 query.append(orderByFields[i]);
481
482 if ((i + 1) < orderByFields.length) {
483 if (orderByComparator.isAscending() ^ previous) {
484 query.append(ORDER_BY_ASC_HAS_NEXT);
485 }
486 else {
487 query.append(ORDER_BY_DESC_HAS_NEXT);
488 }
489 }
490 else {
491 if (orderByComparator.isAscending() ^ previous) {
492 query.append(ORDER_BY_ASC);
493 }
494 else {
495 query.append(ORDER_BY_DESC);
496 }
497 }
498 }
499 }
500 else {
501 query.append(RecentLayoutRevisionModelImpl.ORDER_BY_JPQL);
502 }
503
504 String sql = query.toString();
505
506 Query q = session.createQuery(sql);
507
508 q.setFirstResult(0);
509 q.setMaxResults(2);
510
511 QueryPos qPos = QueryPos.getInstance(q);
512
513 qPos.add(groupId);
514
515 if (orderByComparator != null) {
516 Object[] values = orderByComparator.getOrderByConditionValues(recentLayoutRevision);
517
518 for (Object value : values) {
519 qPos.add(value);
520 }
521 }
522
523 List<RecentLayoutRevision> list = q.list();
524
525 if (list.size() == 2) {
526 return list.get(1);
527 }
528 else {
529 return null;
530 }
531 }
532
533
538 @Override
539 public void removeByGroupId(long groupId) {
540 for (RecentLayoutRevision recentLayoutRevision : findByGroupId(
541 groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
542 remove(recentLayoutRevision);
543 }
544 }
545
546
552 @Override
553 public int countByGroupId(long groupId) {
554 FinderPath finderPath = FINDER_PATH_COUNT_BY_GROUPID;
555
556 Object[] finderArgs = new Object[] { groupId };
557
558 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
559
560 if (count == null) {
561 StringBundler query = new StringBundler(2);
562
563 query.append(_SQL_COUNT_RECENTLAYOUTREVISION_WHERE);
564
565 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
566
567 String sql = query.toString();
568
569 Session session = null;
570
571 try {
572 session = openSession();
573
574 Query q = session.createQuery(sql);
575
576 QueryPos qPos = QueryPos.getInstance(q);
577
578 qPos.add(groupId);
579
580 count = (Long)q.uniqueResult();
581
582 finderCache.putResult(finderPath, finderArgs, count);
583 }
584 catch (Exception e) {
585 finderCache.removeResult(finderPath, finderArgs);
586
587 throw processException(e);
588 }
589 finally {
590 closeSession(session);
591 }
592 }
593
594 return count.intValue();
595 }
596
597 private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "recentLayoutRevision.groupId = ?";
598 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_USERID = new FinderPath(RecentLayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
599 RecentLayoutRevisionModelImpl.FINDER_CACHE_ENABLED,
600 RecentLayoutRevisionImpl.class,
601 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUserId",
602 new String[] {
603 Long.class.getName(),
604
605 Integer.class.getName(), Integer.class.getName(),
606 OrderByComparator.class.getName()
607 });
608 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID =
609 new FinderPath(RecentLayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
610 RecentLayoutRevisionModelImpl.FINDER_CACHE_ENABLED,
611 RecentLayoutRevisionImpl.class,
612 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUserId",
613 new String[] { Long.class.getName() },
614 RecentLayoutRevisionModelImpl.USERID_COLUMN_BITMASK);
615 public static final FinderPath FINDER_PATH_COUNT_BY_USERID = new FinderPath(RecentLayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
616 RecentLayoutRevisionModelImpl.FINDER_CACHE_ENABLED, Long.class,
617 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUserId",
618 new String[] { Long.class.getName() });
619
620
626 @Override
627 public List<RecentLayoutRevision> findByUserId(long userId) {
628 return findByUserId(userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
629 }
630
631
643 @Override
644 public List<RecentLayoutRevision> findByUserId(long userId, int start,
645 int end) {
646 return findByUserId(userId, start, end, null);
647 }
648
649
662 @Override
663 public List<RecentLayoutRevision> findByUserId(long userId, int start,
664 int end, OrderByComparator<RecentLayoutRevision> orderByComparator) {
665 return findByUserId(userId, start, end, orderByComparator, true);
666 }
667
668
682 @Override
683 public List<RecentLayoutRevision> findByUserId(long userId, int start,
684 int end, OrderByComparator<RecentLayoutRevision> orderByComparator,
685 boolean retrieveFromCache) {
686 boolean pagination = true;
687 FinderPath finderPath = null;
688 Object[] finderArgs = null;
689
690 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
691 (orderByComparator == null)) {
692 pagination = false;
693 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID;
694 finderArgs = new Object[] { userId };
695 }
696 else {
697 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_USERID;
698 finderArgs = new Object[] { userId, start, end, orderByComparator };
699 }
700
701 List<RecentLayoutRevision> list = null;
702
703 if (retrieveFromCache) {
704 list = (List<RecentLayoutRevision>)finderCache.getResult(finderPath,
705 finderArgs, this);
706
707 if ((list != null) && !list.isEmpty()) {
708 for (RecentLayoutRevision recentLayoutRevision : list) {
709 if ((userId != recentLayoutRevision.getUserId())) {
710 list = null;
711
712 break;
713 }
714 }
715 }
716 }
717
718 if (list == null) {
719 StringBundler query = null;
720
721 if (orderByComparator != null) {
722 query = new StringBundler(3 +
723 (orderByComparator.getOrderByFields().length * 2));
724 }
725 else {
726 query = new StringBundler(3);
727 }
728
729 query.append(_SQL_SELECT_RECENTLAYOUTREVISION_WHERE);
730
731 query.append(_FINDER_COLUMN_USERID_USERID_2);
732
733 if (orderByComparator != null) {
734 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
735 orderByComparator);
736 }
737 else
738 if (pagination) {
739 query.append(RecentLayoutRevisionModelImpl.ORDER_BY_JPQL);
740 }
741
742 String sql = query.toString();
743
744 Session session = null;
745
746 try {
747 session = openSession();
748
749 Query q = session.createQuery(sql);
750
751 QueryPos qPos = QueryPos.getInstance(q);
752
753 qPos.add(userId);
754
755 if (!pagination) {
756 list = (List<RecentLayoutRevision>)QueryUtil.list(q,
757 getDialect(), start, end, false);
758
759 Collections.sort(list);
760
761 list = Collections.unmodifiableList(list);
762 }
763 else {
764 list = (List<RecentLayoutRevision>)QueryUtil.list(q,
765 getDialect(), start, end);
766 }
767
768 cacheResult(list);
769
770 finderCache.putResult(finderPath, finderArgs, list);
771 }
772 catch (Exception e) {
773 finderCache.removeResult(finderPath, finderArgs);
774
775 throw processException(e);
776 }
777 finally {
778 closeSession(session);
779 }
780 }
781
782 return list;
783 }
784
785
793 @Override
794 public RecentLayoutRevision findByUserId_First(long userId,
795 OrderByComparator<RecentLayoutRevision> orderByComparator)
796 throws NoSuchRecentLayoutRevisionException {
797 RecentLayoutRevision recentLayoutRevision = fetchByUserId_First(userId,
798 orderByComparator);
799
800 if (recentLayoutRevision != null) {
801 return recentLayoutRevision;
802 }
803
804 StringBundler msg = new StringBundler(4);
805
806 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
807
808 msg.append("userId=");
809 msg.append(userId);
810
811 msg.append(StringPool.CLOSE_CURLY_BRACE);
812
813 throw new NoSuchRecentLayoutRevisionException(msg.toString());
814 }
815
816
823 @Override
824 public RecentLayoutRevision fetchByUserId_First(long userId,
825 OrderByComparator<RecentLayoutRevision> orderByComparator) {
826 List<RecentLayoutRevision> list = findByUserId(userId, 0, 1,
827 orderByComparator);
828
829 if (!list.isEmpty()) {
830 return list.get(0);
831 }
832
833 return null;
834 }
835
836
844 @Override
845 public RecentLayoutRevision findByUserId_Last(long userId,
846 OrderByComparator<RecentLayoutRevision> orderByComparator)
847 throws NoSuchRecentLayoutRevisionException {
848 RecentLayoutRevision recentLayoutRevision = fetchByUserId_Last(userId,
849 orderByComparator);
850
851 if (recentLayoutRevision != null) {
852 return recentLayoutRevision;
853 }
854
855 StringBundler msg = new StringBundler(4);
856
857 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
858
859 msg.append("userId=");
860 msg.append(userId);
861
862 msg.append(StringPool.CLOSE_CURLY_BRACE);
863
864 throw new NoSuchRecentLayoutRevisionException(msg.toString());
865 }
866
867
874 @Override
875 public RecentLayoutRevision fetchByUserId_Last(long userId,
876 OrderByComparator<RecentLayoutRevision> orderByComparator) {
877 int count = countByUserId(userId);
878
879 if (count == 0) {
880 return null;
881 }
882
883 List<RecentLayoutRevision> list = findByUserId(userId, count - 1,
884 count, orderByComparator);
885
886 if (!list.isEmpty()) {
887 return list.get(0);
888 }
889
890 return null;
891 }
892
893
902 @Override
903 public RecentLayoutRevision[] findByUserId_PrevAndNext(
904 long recentLayoutRevisionId, long userId,
905 OrderByComparator<RecentLayoutRevision> orderByComparator)
906 throws NoSuchRecentLayoutRevisionException {
907 RecentLayoutRevision recentLayoutRevision = findByPrimaryKey(recentLayoutRevisionId);
908
909 Session session = null;
910
911 try {
912 session = openSession();
913
914 RecentLayoutRevision[] array = new RecentLayoutRevisionImpl[3];
915
916 array[0] = getByUserId_PrevAndNext(session, recentLayoutRevision,
917 userId, orderByComparator, true);
918
919 array[1] = recentLayoutRevision;
920
921 array[2] = getByUserId_PrevAndNext(session, recentLayoutRevision,
922 userId, orderByComparator, false);
923
924 return array;
925 }
926 catch (Exception e) {
927 throw processException(e);
928 }
929 finally {
930 closeSession(session);
931 }
932 }
933
934 protected RecentLayoutRevision getByUserId_PrevAndNext(Session session,
935 RecentLayoutRevision recentLayoutRevision, long userId,
936 OrderByComparator<RecentLayoutRevision> orderByComparator,
937 boolean previous) {
938 StringBundler query = null;
939
940 if (orderByComparator != null) {
941 query = new StringBundler(4 +
942 (orderByComparator.getOrderByConditionFields().length * 3) +
943 (orderByComparator.getOrderByFields().length * 3));
944 }
945 else {
946 query = new StringBundler(3);
947 }
948
949 query.append(_SQL_SELECT_RECENTLAYOUTREVISION_WHERE);
950
951 query.append(_FINDER_COLUMN_USERID_USERID_2);
952
953 if (orderByComparator != null) {
954 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
955
956 if (orderByConditionFields.length > 0) {
957 query.append(WHERE_AND);
958 }
959
960 for (int i = 0; i < orderByConditionFields.length; i++) {
961 query.append(_ORDER_BY_ENTITY_ALIAS);
962 query.append(orderByConditionFields[i]);
963
964 if ((i + 1) < orderByConditionFields.length) {
965 if (orderByComparator.isAscending() ^ previous) {
966 query.append(WHERE_GREATER_THAN_HAS_NEXT);
967 }
968 else {
969 query.append(WHERE_LESSER_THAN_HAS_NEXT);
970 }
971 }
972 else {
973 if (orderByComparator.isAscending() ^ previous) {
974 query.append(WHERE_GREATER_THAN);
975 }
976 else {
977 query.append(WHERE_LESSER_THAN);
978 }
979 }
980 }
981
982 query.append(ORDER_BY_CLAUSE);
983
984 String[] orderByFields = orderByComparator.getOrderByFields();
985
986 for (int i = 0; i < orderByFields.length; i++) {
987 query.append(_ORDER_BY_ENTITY_ALIAS);
988 query.append(orderByFields[i]);
989
990 if ((i + 1) < orderByFields.length) {
991 if (orderByComparator.isAscending() ^ previous) {
992 query.append(ORDER_BY_ASC_HAS_NEXT);
993 }
994 else {
995 query.append(ORDER_BY_DESC_HAS_NEXT);
996 }
997 }
998 else {
999 if (orderByComparator.isAscending() ^ previous) {
1000 query.append(ORDER_BY_ASC);
1001 }
1002 else {
1003 query.append(ORDER_BY_DESC);
1004 }
1005 }
1006 }
1007 }
1008 else {
1009 query.append(RecentLayoutRevisionModelImpl.ORDER_BY_JPQL);
1010 }
1011
1012 String sql = query.toString();
1013
1014 Query q = session.createQuery(sql);
1015
1016 q.setFirstResult(0);
1017 q.setMaxResults(2);
1018
1019 QueryPos qPos = QueryPos.getInstance(q);
1020
1021 qPos.add(userId);
1022
1023 if (orderByComparator != null) {
1024 Object[] values = orderByComparator.getOrderByConditionValues(recentLayoutRevision);
1025
1026 for (Object value : values) {
1027 qPos.add(value);
1028 }
1029 }
1030
1031 List<RecentLayoutRevision> list = q.list();
1032
1033 if (list.size() == 2) {
1034 return list.get(1);
1035 }
1036 else {
1037 return null;
1038 }
1039 }
1040
1041
1046 @Override
1047 public void removeByUserId(long userId) {
1048 for (RecentLayoutRevision recentLayoutRevision : findByUserId(userId,
1049 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1050 remove(recentLayoutRevision);
1051 }
1052 }
1053
1054
1060 @Override
1061 public int countByUserId(long userId) {
1062 FinderPath finderPath = FINDER_PATH_COUNT_BY_USERID;
1063
1064 Object[] finderArgs = new Object[] { userId };
1065
1066 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
1067
1068 if (count == null) {
1069 StringBundler query = new StringBundler(2);
1070
1071 query.append(_SQL_COUNT_RECENTLAYOUTREVISION_WHERE);
1072
1073 query.append(_FINDER_COLUMN_USERID_USERID_2);
1074
1075 String sql = query.toString();
1076
1077 Session session = null;
1078
1079 try {
1080 session = openSession();
1081
1082 Query q = session.createQuery(sql);
1083
1084 QueryPos qPos = QueryPos.getInstance(q);
1085
1086 qPos.add(userId);
1087
1088 count = (Long)q.uniqueResult();
1089
1090 finderCache.putResult(finderPath, finderArgs, count);
1091 }
1092 catch (Exception e) {
1093 finderCache.removeResult(finderPath, finderArgs);
1094
1095 throw processException(e);
1096 }
1097 finally {
1098 closeSession(session);
1099 }
1100 }
1101
1102 return count.intValue();
1103 }
1104
1105 private static final String _FINDER_COLUMN_USERID_USERID_2 = "recentLayoutRevision.userId = ?";
1106 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_LAYOUTREVISIONID =
1107 new FinderPath(RecentLayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
1108 RecentLayoutRevisionModelImpl.FINDER_CACHE_ENABLED,
1109 RecentLayoutRevisionImpl.class,
1110 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByLayoutRevisionId",
1111 new String[] {
1112 Long.class.getName(),
1113
1114 Integer.class.getName(), Integer.class.getName(),
1115 OrderByComparator.class.getName()
1116 });
1117 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LAYOUTREVISIONID =
1118 new FinderPath(RecentLayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
1119 RecentLayoutRevisionModelImpl.FINDER_CACHE_ENABLED,
1120 RecentLayoutRevisionImpl.class,
1121 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
1122 "findByLayoutRevisionId", new String[] { Long.class.getName() },
1123 RecentLayoutRevisionModelImpl.LAYOUTREVISIONID_COLUMN_BITMASK);
1124 public static final FinderPath FINDER_PATH_COUNT_BY_LAYOUTREVISIONID = new FinderPath(RecentLayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
1125 RecentLayoutRevisionModelImpl.FINDER_CACHE_ENABLED, Long.class,
1126 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
1127 "countByLayoutRevisionId", new String[] { Long.class.getName() });
1128
1129
1135 @Override
1136 public List<RecentLayoutRevision> findByLayoutRevisionId(
1137 long layoutRevisionId) {
1138 return findByLayoutRevisionId(layoutRevisionId, QueryUtil.ALL_POS,
1139 QueryUtil.ALL_POS, null);
1140 }
1141
1142
1154 @Override
1155 public List<RecentLayoutRevision> findByLayoutRevisionId(
1156 long layoutRevisionId, int start, int end) {
1157 return findByLayoutRevisionId(layoutRevisionId, start, end, null);
1158 }
1159
1160
1173 @Override
1174 public List<RecentLayoutRevision> findByLayoutRevisionId(
1175 long layoutRevisionId, int start, int end,
1176 OrderByComparator<RecentLayoutRevision> orderByComparator) {
1177 return findByLayoutRevisionId(layoutRevisionId, start, end,
1178 orderByComparator, true);
1179 }
1180
1181
1195 @Override
1196 public List<RecentLayoutRevision> findByLayoutRevisionId(
1197 long layoutRevisionId, int start, int end,
1198 OrderByComparator<RecentLayoutRevision> orderByComparator,
1199 boolean retrieveFromCache) {
1200 boolean pagination = true;
1201 FinderPath finderPath = null;
1202 Object[] finderArgs = null;
1203
1204 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1205 (orderByComparator == null)) {
1206 pagination = false;
1207 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LAYOUTREVISIONID;
1208 finderArgs = new Object[] { layoutRevisionId };
1209 }
1210 else {
1211 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_LAYOUTREVISIONID;
1212 finderArgs = new Object[] {
1213 layoutRevisionId,
1214
1215 start, end, orderByComparator
1216 };
1217 }
1218
1219 List<RecentLayoutRevision> list = null;
1220
1221 if (retrieveFromCache) {
1222 list = (List<RecentLayoutRevision>)finderCache.getResult(finderPath,
1223 finderArgs, this);
1224
1225 if ((list != null) && !list.isEmpty()) {
1226 for (RecentLayoutRevision recentLayoutRevision : list) {
1227 if ((layoutRevisionId != recentLayoutRevision.getLayoutRevisionId())) {
1228 list = null;
1229
1230 break;
1231 }
1232 }
1233 }
1234 }
1235
1236 if (list == null) {
1237 StringBundler query = null;
1238
1239 if (orderByComparator != null) {
1240 query = new StringBundler(3 +
1241 (orderByComparator.getOrderByFields().length * 2));
1242 }
1243 else {
1244 query = new StringBundler(3);
1245 }
1246
1247 query.append(_SQL_SELECT_RECENTLAYOUTREVISION_WHERE);
1248
1249 query.append(_FINDER_COLUMN_LAYOUTREVISIONID_LAYOUTREVISIONID_2);
1250
1251 if (orderByComparator != null) {
1252 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1253 orderByComparator);
1254 }
1255 else
1256 if (pagination) {
1257 query.append(RecentLayoutRevisionModelImpl.ORDER_BY_JPQL);
1258 }
1259
1260 String sql = query.toString();
1261
1262 Session session = null;
1263
1264 try {
1265 session = openSession();
1266
1267 Query q = session.createQuery(sql);
1268
1269 QueryPos qPos = QueryPos.getInstance(q);
1270
1271 qPos.add(layoutRevisionId);
1272
1273 if (!pagination) {
1274 list = (List<RecentLayoutRevision>)QueryUtil.list(q,
1275 getDialect(), start, end, false);
1276
1277 Collections.sort(list);
1278
1279 list = Collections.unmodifiableList(list);
1280 }
1281 else {
1282 list = (List<RecentLayoutRevision>)QueryUtil.list(q,
1283 getDialect(), start, end);
1284 }
1285
1286 cacheResult(list);
1287
1288 finderCache.putResult(finderPath, finderArgs, list);
1289 }
1290 catch (Exception e) {
1291 finderCache.removeResult(finderPath, finderArgs);
1292
1293 throw processException(e);
1294 }
1295 finally {
1296 closeSession(session);
1297 }
1298 }
1299
1300 return list;
1301 }
1302
1303
1311 @Override
1312 public RecentLayoutRevision findByLayoutRevisionId_First(
1313 long layoutRevisionId,
1314 OrderByComparator<RecentLayoutRevision> orderByComparator)
1315 throws NoSuchRecentLayoutRevisionException {
1316 RecentLayoutRevision recentLayoutRevision = fetchByLayoutRevisionId_First(layoutRevisionId,
1317 orderByComparator);
1318
1319 if (recentLayoutRevision != null) {
1320 return recentLayoutRevision;
1321 }
1322
1323 StringBundler msg = new StringBundler(4);
1324
1325 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1326
1327 msg.append("layoutRevisionId=");
1328 msg.append(layoutRevisionId);
1329
1330 msg.append(StringPool.CLOSE_CURLY_BRACE);
1331
1332 throw new NoSuchRecentLayoutRevisionException(msg.toString());
1333 }
1334
1335
1342 @Override
1343 public RecentLayoutRevision fetchByLayoutRevisionId_First(
1344 long layoutRevisionId,
1345 OrderByComparator<RecentLayoutRevision> orderByComparator) {
1346 List<RecentLayoutRevision> list = findByLayoutRevisionId(layoutRevisionId,
1347 0, 1, orderByComparator);
1348
1349 if (!list.isEmpty()) {
1350 return list.get(0);
1351 }
1352
1353 return null;
1354 }
1355
1356
1364 @Override
1365 public RecentLayoutRevision findByLayoutRevisionId_Last(
1366 long layoutRevisionId,
1367 OrderByComparator<RecentLayoutRevision> orderByComparator)
1368 throws NoSuchRecentLayoutRevisionException {
1369 RecentLayoutRevision recentLayoutRevision = fetchByLayoutRevisionId_Last(layoutRevisionId,
1370 orderByComparator);
1371
1372 if (recentLayoutRevision != null) {
1373 return recentLayoutRevision;
1374 }
1375
1376 StringBundler msg = new StringBundler(4);
1377
1378 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1379
1380 msg.append("layoutRevisionId=");
1381 msg.append(layoutRevisionId);
1382
1383 msg.append(StringPool.CLOSE_CURLY_BRACE);
1384
1385 throw new NoSuchRecentLayoutRevisionException(msg.toString());
1386 }
1387
1388
1395 @Override
1396 public RecentLayoutRevision fetchByLayoutRevisionId_Last(
1397 long layoutRevisionId,
1398 OrderByComparator<RecentLayoutRevision> orderByComparator) {
1399 int count = countByLayoutRevisionId(layoutRevisionId);
1400
1401 if (count == 0) {
1402 return null;
1403 }
1404
1405 List<RecentLayoutRevision> list = findByLayoutRevisionId(layoutRevisionId,
1406 count - 1, count, orderByComparator);
1407
1408 if (!list.isEmpty()) {
1409 return list.get(0);
1410 }
1411
1412 return null;
1413 }
1414
1415
1424 @Override
1425 public RecentLayoutRevision[] findByLayoutRevisionId_PrevAndNext(
1426 long recentLayoutRevisionId, long layoutRevisionId,
1427 OrderByComparator<RecentLayoutRevision> orderByComparator)
1428 throws NoSuchRecentLayoutRevisionException {
1429 RecentLayoutRevision recentLayoutRevision = findByPrimaryKey(recentLayoutRevisionId);
1430
1431 Session session = null;
1432
1433 try {
1434 session = openSession();
1435
1436 RecentLayoutRevision[] array = new RecentLayoutRevisionImpl[3];
1437
1438 array[0] = getByLayoutRevisionId_PrevAndNext(session,
1439 recentLayoutRevision, layoutRevisionId, orderByComparator,
1440 true);
1441
1442 array[1] = recentLayoutRevision;
1443
1444 array[2] = getByLayoutRevisionId_PrevAndNext(session,
1445 recentLayoutRevision, layoutRevisionId, orderByComparator,
1446 false);
1447
1448 return array;
1449 }
1450 catch (Exception e) {
1451 throw processException(e);
1452 }
1453 finally {
1454 closeSession(session);
1455 }
1456 }
1457
1458 protected RecentLayoutRevision getByLayoutRevisionId_PrevAndNext(
1459 Session session, RecentLayoutRevision recentLayoutRevision,
1460 long layoutRevisionId,
1461 OrderByComparator<RecentLayoutRevision> orderByComparator,
1462 boolean previous) {
1463 StringBundler query = null;
1464
1465 if (orderByComparator != null) {
1466 query = new StringBundler(4 +
1467 (orderByComparator.getOrderByConditionFields().length * 3) +
1468 (orderByComparator.getOrderByFields().length * 3));
1469 }
1470 else {
1471 query = new StringBundler(3);
1472 }
1473
1474 query.append(_SQL_SELECT_RECENTLAYOUTREVISION_WHERE);
1475
1476 query.append(_FINDER_COLUMN_LAYOUTREVISIONID_LAYOUTREVISIONID_2);
1477
1478 if (orderByComparator != null) {
1479 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1480
1481 if (orderByConditionFields.length > 0) {
1482 query.append(WHERE_AND);
1483 }
1484
1485 for (int i = 0; i < orderByConditionFields.length; i++) {
1486 query.append(_ORDER_BY_ENTITY_ALIAS);
1487 query.append(orderByConditionFields[i]);
1488
1489 if ((i + 1) < orderByConditionFields.length) {
1490 if (orderByComparator.isAscending() ^ previous) {
1491 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1492 }
1493 else {
1494 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1495 }
1496 }
1497 else {
1498 if (orderByComparator.isAscending() ^ previous) {
1499 query.append(WHERE_GREATER_THAN);
1500 }
1501 else {
1502 query.append(WHERE_LESSER_THAN);
1503 }
1504 }
1505 }
1506
1507 query.append(ORDER_BY_CLAUSE);
1508
1509 String[] orderByFields = orderByComparator.getOrderByFields();
1510
1511 for (int i = 0; i < orderByFields.length; i++) {
1512 query.append(_ORDER_BY_ENTITY_ALIAS);
1513 query.append(orderByFields[i]);
1514
1515 if ((i + 1) < orderByFields.length) {
1516 if (orderByComparator.isAscending() ^ previous) {
1517 query.append(ORDER_BY_ASC_HAS_NEXT);
1518 }
1519 else {
1520 query.append(ORDER_BY_DESC_HAS_NEXT);
1521 }
1522 }
1523 else {
1524 if (orderByComparator.isAscending() ^ previous) {
1525 query.append(ORDER_BY_ASC);
1526 }
1527 else {
1528 query.append(ORDER_BY_DESC);
1529 }
1530 }
1531 }
1532 }
1533 else {
1534 query.append(RecentLayoutRevisionModelImpl.ORDER_BY_JPQL);
1535 }
1536
1537 String sql = query.toString();
1538
1539 Query q = session.createQuery(sql);
1540
1541 q.setFirstResult(0);
1542 q.setMaxResults(2);
1543
1544 QueryPos qPos = QueryPos.getInstance(q);
1545
1546 qPos.add(layoutRevisionId);
1547
1548 if (orderByComparator != null) {
1549 Object[] values = orderByComparator.getOrderByConditionValues(recentLayoutRevision);
1550
1551 for (Object value : values) {
1552 qPos.add(value);
1553 }
1554 }
1555
1556 List<RecentLayoutRevision> list = q.list();
1557
1558 if (list.size() == 2) {
1559 return list.get(1);
1560 }
1561 else {
1562 return null;
1563 }
1564 }
1565
1566
1571 @Override
1572 public void removeByLayoutRevisionId(long layoutRevisionId) {
1573 for (RecentLayoutRevision recentLayoutRevision : findByLayoutRevisionId(
1574 layoutRevisionId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1575 remove(recentLayoutRevision);
1576 }
1577 }
1578
1579
1585 @Override
1586 public int countByLayoutRevisionId(long layoutRevisionId) {
1587 FinderPath finderPath = FINDER_PATH_COUNT_BY_LAYOUTREVISIONID;
1588
1589 Object[] finderArgs = new Object[] { layoutRevisionId };
1590
1591 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
1592
1593 if (count == null) {
1594 StringBundler query = new StringBundler(2);
1595
1596 query.append(_SQL_COUNT_RECENTLAYOUTREVISION_WHERE);
1597
1598 query.append(_FINDER_COLUMN_LAYOUTREVISIONID_LAYOUTREVISIONID_2);
1599
1600 String sql = query.toString();
1601
1602 Session session = null;
1603
1604 try {
1605 session = openSession();
1606
1607 Query q = session.createQuery(sql);
1608
1609 QueryPos qPos = QueryPos.getInstance(q);
1610
1611 qPos.add(layoutRevisionId);
1612
1613 count = (Long)q.uniqueResult();
1614
1615 finderCache.putResult(finderPath, finderArgs, count);
1616 }
1617 catch (Exception e) {
1618 finderCache.removeResult(finderPath, finderArgs);
1619
1620 throw processException(e);
1621 }
1622 finally {
1623 closeSession(session);
1624 }
1625 }
1626
1627 return count.intValue();
1628 }
1629
1630 private static final String _FINDER_COLUMN_LAYOUTREVISIONID_LAYOUTREVISIONID_2 =
1631 "recentLayoutRevision.layoutRevisionId = ?";
1632 public static final FinderPath FINDER_PATH_FETCH_BY_U_L_P = new FinderPath(RecentLayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
1633 RecentLayoutRevisionModelImpl.FINDER_CACHE_ENABLED,
1634 RecentLayoutRevisionImpl.class, FINDER_CLASS_NAME_ENTITY,
1635 "fetchByU_L_P",
1636 new String[] {
1637 Long.class.getName(), Long.class.getName(), Long.class.getName()
1638 },
1639 RecentLayoutRevisionModelImpl.USERID_COLUMN_BITMASK |
1640 RecentLayoutRevisionModelImpl.LAYOUTSETBRANCHID_COLUMN_BITMASK |
1641 RecentLayoutRevisionModelImpl.PLID_COLUMN_BITMASK);
1642 public static final FinderPath FINDER_PATH_COUNT_BY_U_L_P = new FinderPath(RecentLayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
1643 RecentLayoutRevisionModelImpl.FINDER_CACHE_ENABLED, Long.class,
1644 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByU_L_P",
1645 new String[] {
1646 Long.class.getName(), Long.class.getName(), Long.class.getName()
1647 });
1648
1649
1658 @Override
1659 public RecentLayoutRevision findByU_L_P(long userId,
1660 long layoutSetBranchId, long plid)
1661 throws NoSuchRecentLayoutRevisionException {
1662 RecentLayoutRevision recentLayoutRevision = fetchByU_L_P(userId,
1663 layoutSetBranchId, plid);
1664
1665 if (recentLayoutRevision == null) {
1666 StringBundler msg = new StringBundler(8);
1667
1668 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1669
1670 msg.append("userId=");
1671 msg.append(userId);
1672
1673 msg.append(", layoutSetBranchId=");
1674 msg.append(layoutSetBranchId);
1675
1676 msg.append(", plid=");
1677 msg.append(plid);
1678
1679 msg.append(StringPool.CLOSE_CURLY_BRACE);
1680
1681 if (_log.isWarnEnabled()) {
1682 _log.warn(msg.toString());
1683 }
1684
1685 throw new NoSuchRecentLayoutRevisionException(msg.toString());
1686 }
1687
1688 return recentLayoutRevision;
1689 }
1690
1691
1699 @Override
1700 public RecentLayoutRevision fetchByU_L_P(long userId,
1701 long layoutSetBranchId, long plid) {
1702 return fetchByU_L_P(userId, layoutSetBranchId, plid, true);
1703 }
1704
1705
1714 @Override
1715 public RecentLayoutRevision fetchByU_L_P(long userId,
1716 long layoutSetBranchId, long plid, boolean retrieveFromCache) {
1717 Object[] finderArgs = new Object[] { userId, layoutSetBranchId, plid };
1718
1719 Object result = null;
1720
1721 if (retrieveFromCache) {
1722 result = finderCache.getResult(FINDER_PATH_FETCH_BY_U_L_P,
1723 finderArgs, this);
1724 }
1725
1726 if (result instanceof RecentLayoutRevision) {
1727 RecentLayoutRevision recentLayoutRevision = (RecentLayoutRevision)result;
1728
1729 if ((userId != recentLayoutRevision.getUserId()) ||
1730 (layoutSetBranchId != recentLayoutRevision.getLayoutSetBranchId()) ||
1731 (plid != recentLayoutRevision.getPlid())) {
1732 result = null;
1733 }
1734 }
1735
1736 if (result == null) {
1737 StringBundler query = new StringBundler(5);
1738
1739 query.append(_SQL_SELECT_RECENTLAYOUTREVISION_WHERE);
1740
1741 query.append(_FINDER_COLUMN_U_L_P_USERID_2);
1742
1743 query.append(_FINDER_COLUMN_U_L_P_LAYOUTSETBRANCHID_2);
1744
1745 query.append(_FINDER_COLUMN_U_L_P_PLID_2);
1746
1747 String sql = query.toString();
1748
1749 Session session = null;
1750
1751 try {
1752 session = openSession();
1753
1754 Query q = session.createQuery(sql);
1755
1756 QueryPos qPos = QueryPos.getInstance(q);
1757
1758 qPos.add(userId);
1759
1760 qPos.add(layoutSetBranchId);
1761
1762 qPos.add(plid);
1763
1764 List<RecentLayoutRevision> list = q.list();
1765
1766 if (list.isEmpty()) {
1767 finderCache.putResult(FINDER_PATH_FETCH_BY_U_L_P,
1768 finderArgs, list);
1769 }
1770 else {
1771 RecentLayoutRevision recentLayoutRevision = list.get(0);
1772
1773 result = recentLayoutRevision;
1774
1775 cacheResult(recentLayoutRevision);
1776
1777 if ((recentLayoutRevision.getUserId() != userId) ||
1778 (recentLayoutRevision.getLayoutSetBranchId() != layoutSetBranchId) ||
1779 (recentLayoutRevision.getPlid() != plid)) {
1780 finderCache.putResult(FINDER_PATH_FETCH_BY_U_L_P,
1781 finderArgs, recentLayoutRevision);
1782 }
1783 }
1784 }
1785 catch (Exception e) {
1786 finderCache.removeResult(FINDER_PATH_FETCH_BY_U_L_P, finderArgs);
1787
1788 throw processException(e);
1789 }
1790 finally {
1791 closeSession(session);
1792 }
1793 }
1794
1795 if (result instanceof List<?>) {
1796 return null;
1797 }
1798 else {
1799 return (RecentLayoutRevision)result;
1800 }
1801 }
1802
1803
1811 @Override
1812 public RecentLayoutRevision removeByU_L_P(long userId,
1813 long layoutSetBranchId, long plid)
1814 throws NoSuchRecentLayoutRevisionException {
1815 RecentLayoutRevision recentLayoutRevision = findByU_L_P(userId,
1816 layoutSetBranchId, plid);
1817
1818 return remove(recentLayoutRevision);
1819 }
1820
1821
1829 @Override
1830 public int countByU_L_P(long userId, long layoutSetBranchId, long plid) {
1831 FinderPath finderPath = FINDER_PATH_COUNT_BY_U_L_P;
1832
1833 Object[] finderArgs = new Object[] { userId, layoutSetBranchId, plid };
1834
1835 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
1836
1837 if (count == null) {
1838 StringBundler query = new StringBundler(4);
1839
1840 query.append(_SQL_COUNT_RECENTLAYOUTREVISION_WHERE);
1841
1842 query.append(_FINDER_COLUMN_U_L_P_USERID_2);
1843
1844 query.append(_FINDER_COLUMN_U_L_P_LAYOUTSETBRANCHID_2);
1845
1846 query.append(_FINDER_COLUMN_U_L_P_PLID_2);
1847
1848 String sql = query.toString();
1849
1850 Session session = null;
1851
1852 try {
1853 session = openSession();
1854
1855 Query q = session.createQuery(sql);
1856
1857 QueryPos qPos = QueryPos.getInstance(q);
1858
1859 qPos.add(userId);
1860
1861 qPos.add(layoutSetBranchId);
1862
1863 qPos.add(plid);
1864
1865 count = (Long)q.uniqueResult();
1866
1867 finderCache.putResult(finderPath, finderArgs, count);
1868 }
1869 catch (Exception e) {
1870 finderCache.removeResult(finderPath, finderArgs);
1871
1872 throw processException(e);
1873 }
1874 finally {
1875 closeSession(session);
1876 }
1877 }
1878
1879 return count.intValue();
1880 }
1881
1882 private static final String _FINDER_COLUMN_U_L_P_USERID_2 = "recentLayoutRevision.userId = ? AND ";
1883 private static final String _FINDER_COLUMN_U_L_P_LAYOUTSETBRANCHID_2 = "recentLayoutRevision.layoutSetBranchId = ? AND ";
1884 private static final String _FINDER_COLUMN_U_L_P_PLID_2 = "recentLayoutRevision.plid = ?";
1885
1886 public RecentLayoutRevisionPersistenceImpl() {
1887 setModelClass(RecentLayoutRevision.class);
1888 }
1889
1890
1895 @Override
1896 public void cacheResult(RecentLayoutRevision recentLayoutRevision) {
1897 entityCache.putResult(RecentLayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
1898 RecentLayoutRevisionImpl.class,
1899 recentLayoutRevision.getPrimaryKey(), recentLayoutRevision);
1900
1901 finderCache.putResult(FINDER_PATH_FETCH_BY_U_L_P,
1902 new Object[] {
1903 recentLayoutRevision.getUserId(),
1904 recentLayoutRevision.getLayoutSetBranchId(),
1905 recentLayoutRevision.getPlid()
1906 }, recentLayoutRevision);
1907
1908 recentLayoutRevision.resetOriginalValues();
1909 }
1910
1911
1916 @Override
1917 public void cacheResult(List<RecentLayoutRevision> recentLayoutRevisions) {
1918 for (RecentLayoutRevision recentLayoutRevision : recentLayoutRevisions) {
1919 if (entityCache.getResult(
1920 RecentLayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
1921 RecentLayoutRevisionImpl.class,
1922 recentLayoutRevision.getPrimaryKey()) == null) {
1923 cacheResult(recentLayoutRevision);
1924 }
1925 else {
1926 recentLayoutRevision.resetOriginalValues();
1927 }
1928 }
1929 }
1930
1931
1938 @Override
1939 public void clearCache() {
1940 entityCache.clearCache(RecentLayoutRevisionImpl.class);
1941
1942 finderCache.clearCache(FINDER_CLASS_NAME_ENTITY);
1943 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
1944 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1945 }
1946
1947
1954 @Override
1955 public void clearCache(RecentLayoutRevision recentLayoutRevision) {
1956 entityCache.removeResult(RecentLayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
1957 RecentLayoutRevisionImpl.class, recentLayoutRevision.getPrimaryKey());
1958
1959 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
1960 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1961
1962 clearUniqueFindersCache((RecentLayoutRevisionModelImpl)recentLayoutRevision);
1963 }
1964
1965 @Override
1966 public void clearCache(List<RecentLayoutRevision> recentLayoutRevisions) {
1967 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
1968 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1969
1970 for (RecentLayoutRevision recentLayoutRevision : recentLayoutRevisions) {
1971 entityCache.removeResult(RecentLayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
1972 RecentLayoutRevisionImpl.class,
1973 recentLayoutRevision.getPrimaryKey());
1974
1975 clearUniqueFindersCache((RecentLayoutRevisionModelImpl)recentLayoutRevision);
1976 }
1977 }
1978
1979 protected void cacheUniqueFindersCache(
1980 RecentLayoutRevisionModelImpl recentLayoutRevisionModelImpl,
1981 boolean isNew) {
1982 if (isNew) {
1983 Object[] args = new Object[] {
1984 recentLayoutRevisionModelImpl.getUserId(),
1985 recentLayoutRevisionModelImpl.getLayoutSetBranchId(),
1986 recentLayoutRevisionModelImpl.getPlid()
1987 };
1988
1989 finderCache.putResult(FINDER_PATH_COUNT_BY_U_L_P, args,
1990 Long.valueOf(1));
1991 finderCache.putResult(FINDER_PATH_FETCH_BY_U_L_P, args,
1992 recentLayoutRevisionModelImpl);
1993 }
1994 else {
1995 if ((recentLayoutRevisionModelImpl.getColumnBitmask() &
1996 FINDER_PATH_FETCH_BY_U_L_P.getColumnBitmask()) != 0) {
1997 Object[] args = new Object[] {
1998 recentLayoutRevisionModelImpl.getUserId(),
1999 recentLayoutRevisionModelImpl.getLayoutSetBranchId(),
2000 recentLayoutRevisionModelImpl.getPlid()
2001 };
2002
2003 finderCache.putResult(FINDER_PATH_COUNT_BY_U_L_P, args,
2004 Long.valueOf(1));
2005 finderCache.putResult(FINDER_PATH_FETCH_BY_U_L_P, args,
2006 recentLayoutRevisionModelImpl);
2007 }
2008 }
2009 }
2010
2011 protected void clearUniqueFindersCache(
2012 RecentLayoutRevisionModelImpl recentLayoutRevisionModelImpl) {
2013 Object[] args = new Object[] {
2014 recentLayoutRevisionModelImpl.getUserId(),
2015 recentLayoutRevisionModelImpl.getLayoutSetBranchId(),
2016 recentLayoutRevisionModelImpl.getPlid()
2017 };
2018
2019 finderCache.removeResult(FINDER_PATH_COUNT_BY_U_L_P, args);
2020 finderCache.removeResult(FINDER_PATH_FETCH_BY_U_L_P, args);
2021
2022 if ((recentLayoutRevisionModelImpl.getColumnBitmask() &
2023 FINDER_PATH_FETCH_BY_U_L_P.getColumnBitmask()) != 0) {
2024 args = new Object[] {
2025 recentLayoutRevisionModelImpl.getOriginalUserId(),
2026 recentLayoutRevisionModelImpl.getOriginalLayoutSetBranchId(),
2027 recentLayoutRevisionModelImpl.getOriginalPlid()
2028 };
2029
2030 finderCache.removeResult(FINDER_PATH_COUNT_BY_U_L_P, args);
2031 finderCache.removeResult(FINDER_PATH_FETCH_BY_U_L_P, args);
2032 }
2033 }
2034
2035
2041 @Override
2042 public RecentLayoutRevision create(long recentLayoutRevisionId) {
2043 RecentLayoutRevision recentLayoutRevision = new RecentLayoutRevisionImpl();
2044
2045 recentLayoutRevision.setNew(true);
2046 recentLayoutRevision.setPrimaryKey(recentLayoutRevisionId);
2047
2048 recentLayoutRevision.setCompanyId(companyProvider.getCompanyId());
2049
2050 return recentLayoutRevision;
2051 }
2052
2053
2060 @Override
2061 public RecentLayoutRevision remove(long recentLayoutRevisionId)
2062 throws NoSuchRecentLayoutRevisionException {
2063 return remove((Serializable)recentLayoutRevisionId);
2064 }
2065
2066
2073 @Override
2074 public RecentLayoutRevision remove(Serializable primaryKey)
2075 throws NoSuchRecentLayoutRevisionException {
2076 Session session = null;
2077
2078 try {
2079 session = openSession();
2080
2081 RecentLayoutRevision recentLayoutRevision = (RecentLayoutRevision)session.get(RecentLayoutRevisionImpl.class,
2082 primaryKey);
2083
2084 if (recentLayoutRevision == null) {
2085 if (_log.isWarnEnabled()) {
2086 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
2087 }
2088
2089 throw new NoSuchRecentLayoutRevisionException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
2090 primaryKey);
2091 }
2092
2093 return remove(recentLayoutRevision);
2094 }
2095 catch (NoSuchRecentLayoutRevisionException nsee) {
2096 throw nsee;
2097 }
2098 catch (Exception e) {
2099 throw processException(e);
2100 }
2101 finally {
2102 closeSession(session);
2103 }
2104 }
2105
2106 @Override
2107 protected RecentLayoutRevision removeImpl(
2108 RecentLayoutRevision recentLayoutRevision) {
2109 recentLayoutRevision = toUnwrappedModel(recentLayoutRevision);
2110
2111 Session session = null;
2112
2113 try {
2114 session = openSession();
2115
2116 if (!session.contains(recentLayoutRevision)) {
2117 recentLayoutRevision = (RecentLayoutRevision)session.get(RecentLayoutRevisionImpl.class,
2118 recentLayoutRevision.getPrimaryKeyObj());
2119 }
2120
2121 if (recentLayoutRevision != null) {
2122 session.delete(recentLayoutRevision);
2123 }
2124 }
2125 catch (Exception e) {
2126 throw processException(e);
2127 }
2128 finally {
2129 closeSession(session);
2130 }
2131
2132 if (recentLayoutRevision != null) {
2133 clearCache(recentLayoutRevision);
2134 }
2135
2136 return recentLayoutRevision;
2137 }
2138
2139 @Override
2140 public RecentLayoutRevision updateImpl(
2141 RecentLayoutRevision recentLayoutRevision) {
2142 recentLayoutRevision = toUnwrappedModel(recentLayoutRevision);
2143
2144 boolean isNew = recentLayoutRevision.isNew();
2145
2146 RecentLayoutRevisionModelImpl recentLayoutRevisionModelImpl = (RecentLayoutRevisionModelImpl)recentLayoutRevision;
2147
2148 Session session = null;
2149
2150 try {
2151 session = openSession();
2152
2153 if (recentLayoutRevision.isNew()) {
2154 session.save(recentLayoutRevision);
2155
2156 recentLayoutRevision.setNew(false);
2157 }
2158 else {
2159 recentLayoutRevision = (RecentLayoutRevision)session.merge(recentLayoutRevision);
2160 }
2161 }
2162 catch (Exception e) {
2163 throw processException(e);
2164 }
2165 finally {
2166 closeSession(session);
2167 }
2168
2169 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2170
2171 if (isNew || !RecentLayoutRevisionModelImpl.COLUMN_BITMASK_ENABLED) {
2172 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2173 }
2174
2175 else {
2176 if ((recentLayoutRevisionModelImpl.getColumnBitmask() &
2177 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
2178 Object[] args = new Object[] {
2179 recentLayoutRevisionModelImpl.getOriginalGroupId()
2180 };
2181
2182 finderCache.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
2183 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
2184 args);
2185
2186 args = new Object[] { recentLayoutRevisionModelImpl.getGroupId() };
2187
2188 finderCache.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
2189 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
2190 args);
2191 }
2192
2193 if ((recentLayoutRevisionModelImpl.getColumnBitmask() &
2194 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID.getColumnBitmask()) != 0) {
2195 Object[] args = new Object[] {
2196 recentLayoutRevisionModelImpl.getOriginalUserId()
2197 };
2198
2199 finderCache.removeResult(FINDER_PATH_COUNT_BY_USERID, args);
2200 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID,
2201 args);
2202
2203 args = new Object[] { recentLayoutRevisionModelImpl.getUserId() };
2204
2205 finderCache.removeResult(FINDER_PATH_COUNT_BY_USERID, args);
2206 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID,
2207 args);
2208 }
2209
2210 if ((recentLayoutRevisionModelImpl.getColumnBitmask() &
2211 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LAYOUTREVISIONID.getColumnBitmask()) != 0) {
2212 Object[] args = new Object[] {
2213 recentLayoutRevisionModelImpl.getOriginalLayoutRevisionId()
2214 };
2215
2216 finderCache.removeResult(FINDER_PATH_COUNT_BY_LAYOUTREVISIONID,
2217 args);
2218 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LAYOUTREVISIONID,
2219 args);
2220
2221 args = new Object[] {
2222 recentLayoutRevisionModelImpl.getLayoutRevisionId()
2223 };
2224
2225 finderCache.removeResult(FINDER_PATH_COUNT_BY_LAYOUTREVISIONID,
2226 args);
2227 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LAYOUTREVISIONID,
2228 args);
2229 }
2230 }
2231
2232 entityCache.putResult(RecentLayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
2233 RecentLayoutRevisionImpl.class,
2234 recentLayoutRevision.getPrimaryKey(), recentLayoutRevision, false);
2235
2236 clearUniqueFindersCache(recentLayoutRevisionModelImpl);
2237 cacheUniqueFindersCache(recentLayoutRevisionModelImpl, isNew);
2238
2239 recentLayoutRevision.resetOriginalValues();
2240
2241 return recentLayoutRevision;
2242 }
2243
2244 protected RecentLayoutRevision toUnwrappedModel(
2245 RecentLayoutRevision recentLayoutRevision) {
2246 if (recentLayoutRevision instanceof RecentLayoutRevisionImpl) {
2247 return recentLayoutRevision;
2248 }
2249
2250 RecentLayoutRevisionImpl recentLayoutRevisionImpl = new RecentLayoutRevisionImpl();
2251
2252 recentLayoutRevisionImpl.setNew(recentLayoutRevision.isNew());
2253 recentLayoutRevisionImpl.setPrimaryKey(recentLayoutRevision.getPrimaryKey());
2254
2255 recentLayoutRevisionImpl.setMvccVersion(recentLayoutRevision.getMvccVersion());
2256 recentLayoutRevisionImpl.setRecentLayoutRevisionId(recentLayoutRevision.getRecentLayoutRevisionId());
2257 recentLayoutRevisionImpl.setGroupId(recentLayoutRevision.getGroupId());
2258 recentLayoutRevisionImpl.setCompanyId(recentLayoutRevision.getCompanyId());
2259 recentLayoutRevisionImpl.setUserId(recentLayoutRevision.getUserId());
2260 recentLayoutRevisionImpl.setLayoutRevisionId(recentLayoutRevision.getLayoutRevisionId());
2261 recentLayoutRevisionImpl.setLayoutSetBranchId(recentLayoutRevision.getLayoutSetBranchId());
2262 recentLayoutRevisionImpl.setPlid(recentLayoutRevision.getPlid());
2263
2264 return recentLayoutRevisionImpl;
2265 }
2266
2267
2274 @Override
2275 public RecentLayoutRevision findByPrimaryKey(Serializable primaryKey)
2276 throws NoSuchRecentLayoutRevisionException {
2277 RecentLayoutRevision recentLayoutRevision = fetchByPrimaryKey(primaryKey);
2278
2279 if (recentLayoutRevision == null) {
2280 if (_log.isWarnEnabled()) {
2281 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
2282 }
2283
2284 throw new NoSuchRecentLayoutRevisionException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
2285 primaryKey);
2286 }
2287
2288 return recentLayoutRevision;
2289 }
2290
2291
2298 @Override
2299 public RecentLayoutRevision findByPrimaryKey(long recentLayoutRevisionId)
2300 throws NoSuchRecentLayoutRevisionException {
2301 return findByPrimaryKey((Serializable)recentLayoutRevisionId);
2302 }
2303
2304
2310 @Override
2311 public RecentLayoutRevision fetchByPrimaryKey(Serializable primaryKey) {
2312 RecentLayoutRevision recentLayoutRevision = (RecentLayoutRevision)entityCache.getResult(RecentLayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
2313 RecentLayoutRevisionImpl.class, primaryKey);
2314
2315 if (recentLayoutRevision == _nullRecentLayoutRevision) {
2316 return null;
2317 }
2318
2319 if (recentLayoutRevision == null) {
2320 Session session = null;
2321
2322 try {
2323 session = openSession();
2324
2325 recentLayoutRevision = (RecentLayoutRevision)session.get(RecentLayoutRevisionImpl.class,
2326 primaryKey);
2327
2328 if (recentLayoutRevision != null) {
2329 cacheResult(recentLayoutRevision);
2330 }
2331 else {
2332 entityCache.putResult(RecentLayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
2333 RecentLayoutRevisionImpl.class, primaryKey,
2334 _nullRecentLayoutRevision);
2335 }
2336 }
2337 catch (Exception e) {
2338 entityCache.removeResult(RecentLayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
2339 RecentLayoutRevisionImpl.class, primaryKey);
2340
2341 throw processException(e);
2342 }
2343 finally {
2344 closeSession(session);
2345 }
2346 }
2347
2348 return recentLayoutRevision;
2349 }
2350
2351
2357 @Override
2358 public RecentLayoutRevision fetchByPrimaryKey(long recentLayoutRevisionId) {
2359 return fetchByPrimaryKey((Serializable)recentLayoutRevisionId);
2360 }
2361
2362 @Override
2363 public Map<Serializable, RecentLayoutRevision> fetchByPrimaryKeys(
2364 Set<Serializable> primaryKeys) {
2365 if (primaryKeys.isEmpty()) {
2366 return Collections.emptyMap();
2367 }
2368
2369 Map<Serializable, RecentLayoutRevision> map = new HashMap<Serializable, RecentLayoutRevision>();
2370
2371 if (primaryKeys.size() == 1) {
2372 Iterator<Serializable> iterator = primaryKeys.iterator();
2373
2374 Serializable primaryKey = iterator.next();
2375
2376 RecentLayoutRevision recentLayoutRevision = fetchByPrimaryKey(primaryKey);
2377
2378 if (recentLayoutRevision != null) {
2379 map.put(primaryKey, recentLayoutRevision);
2380 }
2381
2382 return map;
2383 }
2384
2385 Set<Serializable> uncachedPrimaryKeys = null;
2386
2387 for (Serializable primaryKey : primaryKeys) {
2388 RecentLayoutRevision recentLayoutRevision = (RecentLayoutRevision)entityCache.getResult(RecentLayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
2389 RecentLayoutRevisionImpl.class, primaryKey);
2390
2391 if (recentLayoutRevision == null) {
2392 if (uncachedPrimaryKeys == null) {
2393 uncachedPrimaryKeys = new HashSet<Serializable>();
2394 }
2395
2396 uncachedPrimaryKeys.add(primaryKey);
2397 }
2398 else {
2399 map.put(primaryKey, recentLayoutRevision);
2400 }
2401 }
2402
2403 if (uncachedPrimaryKeys == null) {
2404 return map;
2405 }
2406
2407 StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) +
2408 1);
2409
2410 query.append(_SQL_SELECT_RECENTLAYOUTREVISION_WHERE_PKS_IN);
2411
2412 for (Serializable primaryKey : uncachedPrimaryKeys) {
2413 query.append(String.valueOf(primaryKey));
2414
2415 query.append(StringPool.COMMA);
2416 }
2417
2418 query.setIndex(query.index() - 1);
2419
2420 query.append(StringPool.CLOSE_PARENTHESIS);
2421
2422 String sql = query.toString();
2423
2424 Session session = null;
2425
2426 try {
2427 session = openSession();
2428
2429 Query q = session.createQuery(sql);
2430
2431 for (RecentLayoutRevision recentLayoutRevision : (List<RecentLayoutRevision>)q.list()) {
2432 map.put(recentLayoutRevision.getPrimaryKeyObj(),
2433 recentLayoutRevision);
2434
2435 cacheResult(recentLayoutRevision);
2436
2437 uncachedPrimaryKeys.remove(recentLayoutRevision.getPrimaryKeyObj());
2438 }
2439
2440 for (Serializable primaryKey : uncachedPrimaryKeys) {
2441 entityCache.putResult(RecentLayoutRevisionModelImpl.ENTITY_CACHE_ENABLED,
2442 RecentLayoutRevisionImpl.class, primaryKey,
2443 _nullRecentLayoutRevision);
2444 }
2445 }
2446 catch (Exception e) {
2447 throw processException(e);
2448 }
2449 finally {
2450 closeSession(session);
2451 }
2452
2453 return map;
2454 }
2455
2456
2461 @Override
2462 public List<RecentLayoutRevision> findAll() {
2463 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2464 }
2465
2466
2477 @Override
2478 public List<RecentLayoutRevision> findAll(int start, int end) {
2479 return findAll(start, end, null);
2480 }
2481
2482
2494 @Override
2495 public List<RecentLayoutRevision> findAll(int start, int end,
2496 OrderByComparator<RecentLayoutRevision> orderByComparator) {
2497 return findAll(start, end, orderByComparator, true);
2498 }
2499
2500
2513 @Override
2514 public List<RecentLayoutRevision> findAll(int start, int end,
2515 OrderByComparator<RecentLayoutRevision> orderByComparator,
2516 boolean retrieveFromCache) {
2517 boolean pagination = true;
2518 FinderPath finderPath = null;
2519 Object[] finderArgs = null;
2520
2521 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2522 (orderByComparator == null)) {
2523 pagination = false;
2524 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
2525 finderArgs = FINDER_ARGS_EMPTY;
2526 }
2527 else {
2528 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
2529 finderArgs = new Object[] { start, end, orderByComparator };
2530 }
2531
2532 List<RecentLayoutRevision> list = null;
2533
2534 if (retrieveFromCache) {
2535 list = (List<RecentLayoutRevision>)finderCache.getResult(finderPath,
2536 finderArgs, this);
2537 }
2538
2539 if (list == null) {
2540 StringBundler query = null;
2541 String sql = null;
2542
2543 if (orderByComparator != null) {
2544 query = new StringBundler(2 +
2545 (orderByComparator.getOrderByFields().length * 2));
2546
2547 query.append(_SQL_SELECT_RECENTLAYOUTREVISION);
2548
2549 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2550 orderByComparator);
2551
2552 sql = query.toString();
2553 }
2554 else {
2555 sql = _SQL_SELECT_RECENTLAYOUTREVISION;
2556
2557 if (pagination) {
2558 sql = sql.concat(RecentLayoutRevisionModelImpl.ORDER_BY_JPQL);
2559 }
2560 }
2561
2562 Session session = null;
2563
2564 try {
2565 session = openSession();
2566
2567 Query q = session.createQuery(sql);
2568
2569 if (!pagination) {
2570 list = (List<RecentLayoutRevision>)QueryUtil.list(q,
2571 getDialect(), start, end, false);
2572
2573 Collections.sort(list);
2574
2575 list = Collections.unmodifiableList(list);
2576 }
2577 else {
2578 list = (List<RecentLayoutRevision>)QueryUtil.list(q,
2579 getDialect(), start, end);
2580 }
2581
2582 cacheResult(list);
2583
2584 finderCache.putResult(finderPath, finderArgs, list);
2585 }
2586 catch (Exception e) {
2587 finderCache.removeResult(finderPath, finderArgs);
2588
2589 throw processException(e);
2590 }
2591 finally {
2592 closeSession(session);
2593 }
2594 }
2595
2596 return list;
2597 }
2598
2599
2603 @Override
2604 public void removeAll() {
2605 for (RecentLayoutRevision recentLayoutRevision : findAll()) {
2606 remove(recentLayoutRevision);
2607 }
2608 }
2609
2610
2615 @Override
2616 public int countAll() {
2617 Long count = (Long)finderCache.getResult(FINDER_PATH_COUNT_ALL,
2618 FINDER_ARGS_EMPTY, this);
2619
2620 if (count == null) {
2621 Session session = null;
2622
2623 try {
2624 session = openSession();
2625
2626 Query q = session.createQuery(_SQL_COUNT_RECENTLAYOUTREVISION);
2627
2628 count = (Long)q.uniqueResult();
2629
2630 finderCache.putResult(FINDER_PATH_COUNT_ALL, FINDER_ARGS_EMPTY,
2631 count);
2632 }
2633 catch (Exception e) {
2634 finderCache.removeResult(FINDER_PATH_COUNT_ALL,
2635 FINDER_ARGS_EMPTY);
2636
2637 throw processException(e);
2638 }
2639 finally {
2640 closeSession(session);
2641 }
2642 }
2643
2644 return count.intValue();
2645 }
2646
2647 @Override
2648 protected Map<String, Integer> getTableColumnsMap() {
2649 return RecentLayoutRevisionModelImpl.TABLE_COLUMNS_MAP;
2650 }
2651
2652
2655 public void afterPropertiesSet() {
2656 }
2657
2658 public void destroy() {
2659 entityCache.removeCache(RecentLayoutRevisionImpl.class.getName());
2660 finderCache.removeCache(FINDER_CLASS_NAME_ENTITY);
2661 finderCache.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2662 finderCache.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2663 }
2664
2665 @BeanReference(type = CompanyProviderWrapper.class)
2666 protected CompanyProvider companyProvider;
2667 protected EntityCache entityCache = EntityCacheUtil.getEntityCache();
2668 protected FinderCache finderCache = FinderCacheUtil.getFinderCache();
2669 private static final String _SQL_SELECT_RECENTLAYOUTREVISION = "SELECT recentLayoutRevision FROM RecentLayoutRevision recentLayoutRevision";
2670 private static final String _SQL_SELECT_RECENTLAYOUTREVISION_WHERE_PKS_IN = "SELECT recentLayoutRevision FROM RecentLayoutRevision recentLayoutRevision WHERE recentLayoutRevisionId IN (";
2671 private static final String _SQL_SELECT_RECENTLAYOUTREVISION_WHERE = "SELECT recentLayoutRevision FROM RecentLayoutRevision recentLayoutRevision WHERE ";
2672 private static final String _SQL_COUNT_RECENTLAYOUTREVISION = "SELECT COUNT(recentLayoutRevision) FROM RecentLayoutRevision recentLayoutRevision";
2673 private static final String _SQL_COUNT_RECENTLAYOUTREVISION_WHERE = "SELECT COUNT(recentLayoutRevision) FROM RecentLayoutRevision recentLayoutRevision WHERE ";
2674 private static final String _ORDER_BY_ENTITY_ALIAS = "recentLayoutRevision.";
2675 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No RecentLayoutRevision exists with the primary key ";
2676 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No RecentLayoutRevision exists with the key {";
2677 private static final Log _log = LogFactoryUtil.getLog(RecentLayoutRevisionPersistenceImpl.class);
2678 private static final RecentLayoutRevision _nullRecentLayoutRevision = new RecentLayoutRevisionImpl() {
2679 @Override
2680 public Object clone() {
2681 return this;
2682 }
2683
2684 @Override
2685 public CacheModel<RecentLayoutRevision> toCacheModel() {
2686 return _nullRecentLayoutRevisionCacheModel;
2687 }
2688 };
2689
2690 private static final CacheModel<RecentLayoutRevision> _nullRecentLayoutRevisionCacheModel =
2691 new NullCacheModel();
2692
2693 private static class NullCacheModel implements CacheModel<RecentLayoutRevision>,
2694 MVCCModel {
2695 @Override
2696 public long getMvccVersion() {
2697 return -1;
2698 }
2699
2700 @Override
2701 public void setMvccVersion(long mvccVersion) {
2702 }
2703
2704 @Override
2705 public RecentLayoutRevision toEntityModel() {
2706 return _nullRecentLayoutRevision;
2707 }
2708 }
2709 }