001
014
015 package com.liferay.portal.service.persistence.impl;
016
017 import aQute.bnd.annotation.ProviderType;
018
019 import com.liferay.portal.NoSuchLayoutSetPrototypeException;
020 import com.liferay.portal.kernel.cache.CacheRegistryUtil;
021 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
022 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
023 import com.liferay.portal.kernel.dao.orm.FinderPath;
024 import com.liferay.portal.kernel.dao.orm.Query;
025 import com.liferay.portal.kernel.dao.orm.QueryPos;
026 import com.liferay.portal.kernel.dao.orm.QueryUtil;
027 import com.liferay.portal.kernel.dao.orm.SQLQuery;
028 import com.liferay.portal.kernel.dao.orm.Session;
029 import com.liferay.portal.kernel.log.Log;
030 import com.liferay.portal.kernel.log.LogFactoryUtil;
031 import com.liferay.portal.kernel.util.OrderByComparator;
032 import com.liferay.portal.kernel.util.SetUtil;
033 import com.liferay.portal.kernel.util.StringBundler;
034 import com.liferay.portal.kernel.util.StringPool;
035 import com.liferay.portal.kernel.util.Validator;
036 import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
037 import com.liferay.portal.model.CacheModel;
038 import com.liferay.portal.model.LayoutSetPrototype;
039 import com.liferay.portal.model.MVCCModel;
040 import com.liferay.portal.model.impl.LayoutSetPrototypeImpl;
041 import com.liferay.portal.model.impl.LayoutSetPrototypeModelImpl;
042 import com.liferay.portal.security.permission.InlineSQLHelperUtil;
043 import com.liferay.portal.service.persistence.LayoutSetPrototypePersistence;
044
045 import java.io.Serializable;
046
047 import java.util.Collections;
048 import java.util.HashMap;
049 import java.util.HashSet;
050 import java.util.Iterator;
051 import java.util.List;
052 import java.util.Map;
053 import java.util.Set;
054
055
067 @ProviderType
068 public class LayoutSetPrototypePersistenceImpl extends BasePersistenceImpl<LayoutSetPrototype>
069 implements LayoutSetPrototypePersistence {
070
075 public static final String FINDER_CLASS_NAME_ENTITY = LayoutSetPrototypeImpl.class.getName();
076 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
077 ".List1";
078 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
079 ".List2";
080 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(LayoutSetPrototypeModelImpl.ENTITY_CACHE_ENABLED,
081 LayoutSetPrototypeModelImpl.FINDER_CACHE_ENABLED,
082 LayoutSetPrototypeImpl.class,
083 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
084 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(LayoutSetPrototypeModelImpl.ENTITY_CACHE_ENABLED,
085 LayoutSetPrototypeModelImpl.FINDER_CACHE_ENABLED,
086 LayoutSetPrototypeImpl.class,
087 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
088 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(LayoutSetPrototypeModelImpl.ENTITY_CACHE_ENABLED,
089 LayoutSetPrototypeModelImpl.FINDER_CACHE_ENABLED, Long.class,
090 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
091 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(LayoutSetPrototypeModelImpl.ENTITY_CACHE_ENABLED,
092 LayoutSetPrototypeModelImpl.FINDER_CACHE_ENABLED,
093 LayoutSetPrototypeImpl.class,
094 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid",
095 new String[] {
096 String.class.getName(),
097
098 Integer.class.getName(), Integer.class.getName(),
099 OrderByComparator.class.getName()
100 });
101 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(LayoutSetPrototypeModelImpl.ENTITY_CACHE_ENABLED,
102 LayoutSetPrototypeModelImpl.FINDER_CACHE_ENABLED,
103 LayoutSetPrototypeImpl.class,
104 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
105 new String[] { String.class.getName() },
106 LayoutSetPrototypeModelImpl.UUID_COLUMN_BITMASK);
107 public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(LayoutSetPrototypeModelImpl.ENTITY_CACHE_ENABLED,
108 LayoutSetPrototypeModelImpl.FINDER_CACHE_ENABLED, Long.class,
109 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
110 new String[] { String.class.getName() });
111
112
118 @Override
119 public List<LayoutSetPrototype> findByUuid(String uuid) {
120 return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
121 }
122
123
135 @Override
136 public List<LayoutSetPrototype> findByUuid(String uuid, int start, int end) {
137 return findByUuid(uuid, start, end, null);
138 }
139
140
153 @Override
154 public List<LayoutSetPrototype> findByUuid(String uuid, int start, int end,
155 OrderByComparator<LayoutSetPrototype> orderByComparator) {
156 boolean pagination = true;
157 FinderPath finderPath = null;
158 Object[] finderArgs = null;
159
160 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
161 (orderByComparator == null)) {
162 pagination = false;
163 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
164 finderArgs = new Object[] { uuid };
165 }
166 else {
167 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
168 finderArgs = new Object[] { uuid, start, end, orderByComparator };
169 }
170
171 List<LayoutSetPrototype> list = (List<LayoutSetPrototype>)FinderCacheUtil.getResult(finderPath,
172 finderArgs, this);
173
174 if ((list != null) && !list.isEmpty()) {
175 for (LayoutSetPrototype layoutSetPrototype : list) {
176 if (!Validator.equals(uuid, layoutSetPrototype.getUuid())) {
177 list = null;
178
179 break;
180 }
181 }
182 }
183
184 if (list == null) {
185 StringBundler query = null;
186
187 if (orderByComparator != null) {
188 query = new StringBundler(3 +
189 (orderByComparator.getOrderByFields().length * 3));
190 }
191 else {
192 query = new StringBundler(3);
193 }
194
195 query.append(_SQL_SELECT_LAYOUTSETPROTOTYPE_WHERE);
196
197 boolean bindUuid = false;
198
199 if (uuid == null) {
200 query.append(_FINDER_COLUMN_UUID_UUID_1);
201 }
202 else if (uuid.equals(StringPool.BLANK)) {
203 query.append(_FINDER_COLUMN_UUID_UUID_3);
204 }
205 else {
206 bindUuid = true;
207
208 query.append(_FINDER_COLUMN_UUID_UUID_2);
209 }
210
211 if (orderByComparator != null) {
212 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
213 orderByComparator);
214 }
215 else
216 if (pagination) {
217 query.append(LayoutSetPrototypeModelImpl.ORDER_BY_JPQL);
218 }
219
220 String sql = query.toString();
221
222 Session session = null;
223
224 try {
225 session = openSession();
226
227 Query q = session.createQuery(sql);
228
229 QueryPos qPos = QueryPos.getInstance(q);
230
231 if (bindUuid) {
232 qPos.add(uuid);
233 }
234
235 if (!pagination) {
236 list = (List<LayoutSetPrototype>)QueryUtil.list(q,
237 getDialect(), start, end, false);
238
239 Collections.sort(list);
240
241 list = Collections.unmodifiableList(list);
242 }
243 else {
244 list = (List<LayoutSetPrototype>)QueryUtil.list(q,
245 getDialect(), start, end);
246 }
247
248 cacheResult(list);
249
250 FinderCacheUtil.putResult(finderPath, finderArgs, list);
251 }
252 catch (Exception e) {
253 FinderCacheUtil.removeResult(finderPath, finderArgs);
254
255 throw processException(e);
256 }
257 finally {
258 closeSession(session);
259 }
260 }
261
262 return list;
263 }
264
265
273 @Override
274 public LayoutSetPrototype findByUuid_First(String uuid,
275 OrderByComparator<LayoutSetPrototype> orderByComparator)
276 throws NoSuchLayoutSetPrototypeException {
277 LayoutSetPrototype layoutSetPrototype = fetchByUuid_First(uuid,
278 orderByComparator);
279
280 if (layoutSetPrototype != null) {
281 return layoutSetPrototype;
282 }
283
284 StringBundler msg = new StringBundler(4);
285
286 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
287
288 msg.append("uuid=");
289 msg.append(uuid);
290
291 msg.append(StringPool.CLOSE_CURLY_BRACE);
292
293 throw new NoSuchLayoutSetPrototypeException(msg.toString());
294 }
295
296
303 @Override
304 public LayoutSetPrototype fetchByUuid_First(String uuid,
305 OrderByComparator<LayoutSetPrototype> orderByComparator) {
306 List<LayoutSetPrototype> list = findByUuid(uuid, 0, 1, orderByComparator);
307
308 if (!list.isEmpty()) {
309 return list.get(0);
310 }
311
312 return null;
313 }
314
315
323 @Override
324 public LayoutSetPrototype findByUuid_Last(String uuid,
325 OrderByComparator<LayoutSetPrototype> orderByComparator)
326 throws NoSuchLayoutSetPrototypeException {
327 LayoutSetPrototype layoutSetPrototype = fetchByUuid_Last(uuid,
328 orderByComparator);
329
330 if (layoutSetPrototype != null) {
331 return layoutSetPrototype;
332 }
333
334 StringBundler msg = new StringBundler(4);
335
336 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
337
338 msg.append("uuid=");
339 msg.append(uuid);
340
341 msg.append(StringPool.CLOSE_CURLY_BRACE);
342
343 throw new NoSuchLayoutSetPrototypeException(msg.toString());
344 }
345
346
353 @Override
354 public LayoutSetPrototype fetchByUuid_Last(String uuid,
355 OrderByComparator<LayoutSetPrototype> orderByComparator) {
356 int count = countByUuid(uuid);
357
358 if (count == 0) {
359 return null;
360 }
361
362 List<LayoutSetPrototype> list = findByUuid(uuid, count - 1, count,
363 orderByComparator);
364
365 if (!list.isEmpty()) {
366 return list.get(0);
367 }
368
369 return null;
370 }
371
372
381 @Override
382 public LayoutSetPrototype[] findByUuid_PrevAndNext(
383 long layoutSetPrototypeId, String uuid,
384 OrderByComparator<LayoutSetPrototype> orderByComparator)
385 throws NoSuchLayoutSetPrototypeException {
386 LayoutSetPrototype layoutSetPrototype = findByPrimaryKey(layoutSetPrototypeId);
387
388 Session session = null;
389
390 try {
391 session = openSession();
392
393 LayoutSetPrototype[] array = new LayoutSetPrototypeImpl[3];
394
395 array[0] = getByUuid_PrevAndNext(session, layoutSetPrototype, uuid,
396 orderByComparator, true);
397
398 array[1] = layoutSetPrototype;
399
400 array[2] = getByUuid_PrevAndNext(session, layoutSetPrototype, uuid,
401 orderByComparator, false);
402
403 return array;
404 }
405 catch (Exception e) {
406 throw processException(e);
407 }
408 finally {
409 closeSession(session);
410 }
411 }
412
413 protected LayoutSetPrototype getByUuid_PrevAndNext(Session session,
414 LayoutSetPrototype layoutSetPrototype, String uuid,
415 OrderByComparator<LayoutSetPrototype> orderByComparator,
416 boolean previous) {
417 StringBundler query = null;
418
419 if (orderByComparator != null) {
420 query = new StringBundler(6 +
421 (orderByComparator.getOrderByFields().length * 6));
422 }
423 else {
424 query = new StringBundler(3);
425 }
426
427 query.append(_SQL_SELECT_LAYOUTSETPROTOTYPE_WHERE);
428
429 boolean bindUuid = false;
430
431 if (uuid == null) {
432 query.append(_FINDER_COLUMN_UUID_UUID_1);
433 }
434 else if (uuid.equals(StringPool.BLANK)) {
435 query.append(_FINDER_COLUMN_UUID_UUID_3);
436 }
437 else {
438 bindUuid = true;
439
440 query.append(_FINDER_COLUMN_UUID_UUID_2);
441 }
442
443 if (orderByComparator != null) {
444 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
445
446 if (orderByConditionFields.length > 0) {
447 query.append(WHERE_AND);
448 }
449
450 for (int i = 0; i < orderByConditionFields.length; i++) {
451 query.append(_ORDER_BY_ENTITY_ALIAS);
452 query.append(orderByConditionFields[i]);
453
454 if ((i + 1) < orderByConditionFields.length) {
455 if (orderByComparator.isAscending() ^ previous) {
456 query.append(WHERE_GREATER_THAN_HAS_NEXT);
457 }
458 else {
459 query.append(WHERE_LESSER_THAN_HAS_NEXT);
460 }
461 }
462 else {
463 if (orderByComparator.isAscending() ^ previous) {
464 query.append(WHERE_GREATER_THAN);
465 }
466 else {
467 query.append(WHERE_LESSER_THAN);
468 }
469 }
470 }
471
472 query.append(ORDER_BY_CLAUSE);
473
474 String[] orderByFields = orderByComparator.getOrderByFields();
475
476 for (int i = 0; i < orderByFields.length; i++) {
477 query.append(_ORDER_BY_ENTITY_ALIAS);
478 query.append(orderByFields[i]);
479
480 if ((i + 1) < orderByFields.length) {
481 if (orderByComparator.isAscending() ^ previous) {
482 query.append(ORDER_BY_ASC_HAS_NEXT);
483 }
484 else {
485 query.append(ORDER_BY_DESC_HAS_NEXT);
486 }
487 }
488 else {
489 if (orderByComparator.isAscending() ^ previous) {
490 query.append(ORDER_BY_ASC);
491 }
492 else {
493 query.append(ORDER_BY_DESC);
494 }
495 }
496 }
497 }
498 else {
499 query.append(LayoutSetPrototypeModelImpl.ORDER_BY_JPQL);
500 }
501
502 String sql = query.toString();
503
504 Query q = session.createQuery(sql);
505
506 q.setFirstResult(0);
507 q.setMaxResults(2);
508
509 QueryPos qPos = QueryPos.getInstance(q);
510
511 if (bindUuid) {
512 qPos.add(uuid);
513 }
514
515 if (orderByComparator != null) {
516 Object[] values = orderByComparator.getOrderByConditionValues(layoutSetPrototype);
517
518 for (Object value : values) {
519 qPos.add(value);
520 }
521 }
522
523 List<LayoutSetPrototype> list = q.list();
524
525 if (list.size() == 2) {
526 return list.get(1);
527 }
528 else {
529 return null;
530 }
531 }
532
533
539 @Override
540 public List<LayoutSetPrototype> filterFindByUuid(String uuid) {
541 return filterFindByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
542 }
543
544
556 @Override
557 public List<LayoutSetPrototype> filterFindByUuid(String uuid, int start,
558 int end) {
559 return filterFindByUuid(uuid, start, end, null);
560 }
561
562
575 @Override
576 public List<LayoutSetPrototype> filterFindByUuid(String uuid, int start,
577 int end, OrderByComparator<LayoutSetPrototype> orderByComparator) {
578 if (!InlineSQLHelperUtil.isEnabled()) {
579 return findByUuid(uuid, start, end, orderByComparator);
580 }
581
582 StringBundler query = null;
583
584 if (orderByComparator != null) {
585 query = new StringBundler(3 +
586 (orderByComparator.getOrderByFields().length * 3));
587 }
588 else {
589 query = new StringBundler(3);
590 }
591
592 if (getDB().isSupportsInlineDistinct()) {
593 query.append(_FILTER_SQL_SELECT_LAYOUTSETPROTOTYPE_WHERE);
594 }
595 else {
596 query.append(_FILTER_SQL_SELECT_LAYOUTSETPROTOTYPE_NO_INLINE_DISTINCT_WHERE_1);
597 }
598
599 boolean bindUuid = false;
600
601 if (uuid == null) {
602 query.append(_FINDER_COLUMN_UUID_UUID_1_SQL);
603 }
604 else if (uuid.equals(StringPool.BLANK)) {
605 query.append(_FINDER_COLUMN_UUID_UUID_3_SQL);
606 }
607 else {
608 bindUuid = true;
609
610 query.append(_FINDER_COLUMN_UUID_UUID_2_SQL);
611 }
612
613 if (!getDB().isSupportsInlineDistinct()) {
614 query.append(_FILTER_SQL_SELECT_LAYOUTSETPROTOTYPE_NO_INLINE_DISTINCT_WHERE_2);
615 }
616
617 if (orderByComparator != null) {
618 if (getDB().isSupportsInlineDistinct()) {
619 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
620 orderByComparator, true);
621 }
622 else {
623 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
624 orderByComparator, true);
625 }
626 }
627 else {
628 if (getDB().isSupportsInlineDistinct()) {
629 query.append(LayoutSetPrototypeModelImpl.ORDER_BY_JPQL);
630 }
631 else {
632 query.append(LayoutSetPrototypeModelImpl.ORDER_BY_SQL);
633 }
634 }
635
636 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
637 LayoutSetPrototype.class.getName(),
638 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
639
640 Session session = null;
641
642 try {
643 session = openSession();
644
645 SQLQuery q = session.createSynchronizedSQLQuery(sql);
646
647 if (getDB().isSupportsInlineDistinct()) {
648 q.addEntity(_FILTER_ENTITY_ALIAS, LayoutSetPrototypeImpl.class);
649 }
650 else {
651 q.addEntity(_FILTER_ENTITY_TABLE, LayoutSetPrototypeImpl.class);
652 }
653
654 QueryPos qPos = QueryPos.getInstance(q);
655
656 if (bindUuid) {
657 qPos.add(uuid);
658 }
659
660 return (List<LayoutSetPrototype>)QueryUtil.list(q, getDialect(),
661 start, end);
662 }
663 catch (Exception e) {
664 throw processException(e);
665 }
666 finally {
667 closeSession(session);
668 }
669 }
670
671
680 @Override
681 public LayoutSetPrototype[] filterFindByUuid_PrevAndNext(
682 long layoutSetPrototypeId, String uuid,
683 OrderByComparator<LayoutSetPrototype> orderByComparator)
684 throws NoSuchLayoutSetPrototypeException {
685 if (!InlineSQLHelperUtil.isEnabled()) {
686 return findByUuid_PrevAndNext(layoutSetPrototypeId, uuid,
687 orderByComparator);
688 }
689
690 LayoutSetPrototype layoutSetPrototype = findByPrimaryKey(layoutSetPrototypeId);
691
692 Session session = null;
693
694 try {
695 session = openSession();
696
697 LayoutSetPrototype[] array = new LayoutSetPrototypeImpl[3];
698
699 array[0] = filterGetByUuid_PrevAndNext(session, layoutSetPrototype,
700 uuid, orderByComparator, true);
701
702 array[1] = layoutSetPrototype;
703
704 array[2] = filterGetByUuid_PrevAndNext(session, layoutSetPrototype,
705 uuid, orderByComparator, false);
706
707 return array;
708 }
709 catch (Exception e) {
710 throw processException(e);
711 }
712 finally {
713 closeSession(session);
714 }
715 }
716
717 protected LayoutSetPrototype filterGetByUuid_PrevAndNext(Session session,
718 LayoutSetPrototype layoutSetPrototype, String uuid,
719 OrderByComparator<LayoutSetPrototype> orderByComparator,
720 boolean previous) {
721 StringBundler query = null;
722
723 if (orderByComparator != null) {
724 query = new StringBundler(6 +
725 (orderByComparator.getOrderByFields().length * 6));
726 }
727 else {
728 query = new StringBundler(3);
729 }
730
731 if (getDB().isSupportsInlineDistinct()) {
732 query.append(_FILTER_SQL_SELECT_LAYOUTSETPROTOTYPE_WHERE);
733 }
734 else {
735 query.append(_FILTER_SQL_SELECT_LAYOUTSETPROTOTYPE_NO_INLINE_DISTINCT_WHERE_1);
736 }
737
738 boolean bindUuid = false;
739
740 if (uuid == null) {
741 query.append(_FINDER_COLUMN_UUID_UUID_1_SQL);
742 }
743 else if (uuid.equals(StringPool.BLANK)) {
744 query.append(_FINDER_COLUMN_UUID_UUID_3_SQL);
745 }
746 else {
747 bindUuid = true;
748
749 query.append(_FINDER_COLUMN_UUID_UUID_2_SQL);
750 }
751
752 if (!getDB().isSupportsInlineDistinct()) {
753 query.append(_FILTER_SQL_SELECT_LAYOUTSETPROTOTYPE_NO_INLINE_DISTINCT_WHERE_2);
754 }
755
756 if (orderByComparator != null) {
757 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
758
759 if (orderByConditionFields.length > 0) {
760 query.append(WHERE_AND);
761 }
762
763 for (int i = 0; i < orderByConditionFields.length; i++) {
764 if (getDB().isSupportsInlineDistinct()) {
765 query.append(_ORDER_BY_ENTITY_ALIAS);
766 }
767 else {
768 query.append(_ORDER_BY_ENTITY_TABLE);
769 }
770
771 query.append(orderByConditionFields[i]);
772
773 if ((i + 1) < orderByConditionFields.length) {
774 if (orderByComparator.isAscending() ^ previous) {
775 query.append(WHERE_GREATER_THAN_HAS_NEXT);
776 }
777 else {
778 query.append(WHERE_LESSER_THAN_HAS_NEXT);
779 }
780 }
781 else {
782 if (orderByComparator.isAscending() ^ previous) {
783 query.append(WHERE_GREATER_THAN);
784 }
785 else {
786 query.append(WHERE_LESSER_THAN);
787 }
788 }
789 }
790
791 query.append(ORDER_BY_CLAUSE);
792
793 String[] orderByFields = orderByComparator.getOrderByFields();
794
795 for (int i = 0; i < orderByFields.length; i++) {
796 if (getDB().isSupportsInlineDistinct()) {
797 query.append(_ORDER_BY_ENTITY_ALIAS);
798 }
799 else {
800 query.append(_ORDER_BY_ENTITY_TABLE);
801 }
802
803 query.append(orderByFields[i]);
804
805 if ((i + 1) < orderByFields.length) {
806 if (orderByComparator.isAscending() ^ previous) {
807 query.append(ORDER_BY_ASC_HAS_NEXT);
808 }
809 else {
810 query.append(ORDER_BY_DESC_HAS_NEXT);
811 }
812 }
813 else {
814 if (orderByComparator.isAscending() ^ previous) {
815 query.append(ORDER_BY_ASC);
816 }
817 else {
818 query.append(ORDER_BY_DESC);
819 }
820 }
821 }
822 }
823 else {
824 if (getDB().isSupportsInlineDistinct()) {
825 query.append(LayoutSetPrototypeModelImpl.ORDER_BY_JPQL);
826 }
827 else {
828 query.append(LayoutSetPrototypeModelImpl.ORDER_BY_SQL);
829 }
830 }
831
832 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
833 LayoutSetPrototype.class.getName(),
834 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
835
836 SQLQuery q = session.createSynchronizedSQLQuery(sql);
837
838 q.setFirstResult(0);
839 q.setMaxResults(2);
840
841 if (getDB().isSupportsInlineDistinct()) {
842 q.addEntity(_FILTER_ENTITY_ALIAS, LayoutSetPrototypeImpl.class);
843 }
844 else {
845 q.addEntity(_FILTER_ENTITY_TABLE, LayoutSetPrototypeImpl.class);
846 }
847
848 QueryPos qPos = QueryPos.getInstance(q);
849
850 if (bindUuid) {
851 qPos.add(uuid);
852 }
853
854 if (orderByComparator != null) {
855 Object[] values = orderByComparator.getOrderByConditionValues(layoutSetPrototype);
856
857 for (Object value : values) {
858 qPos.add(value);
859 }
860 }
861
862 List<LayoutSetPrototype> list = q.list();
863
864 if (list.size() == 2) {
865 return list.get(1);
866 }
867 else {
868 return null;
869 }
870 }
871
872
877 @Override
878 public void removeByUuid(String uuid) {
879 for (LayoutSetPrototype layoutSetPrototype : findByUuid(uuid,
880 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
881 remove(layoutSetPrototype);
882 }
883 }
884
885
891 @Override
892 public int countByUuid(String uuid) {
893 FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID;
894
895 Object[] finderArgs = new Object[] { uuid };
896
897 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
898 this);
899
900 if (count == null) {
901 StringBundler query = new StringBundler(2);
902
903 query.append(_SQL_COUNT_LAYOUTSETPROTOTYPE_WHERE);
904
905 boolean bindUuid = false;
906
907 if (uuid == null) {
908 query.append(_FINDER_COLUMN_UUID_UUID_1);
909 }
910 else if (uuid.equals(StringPool.BLANK)) {
911 query.append(_FINDER_COLUMN_UUID_UUID_3);
912 }
913 else {
914 bindUuid = true;
915
916 query.append(_FINDER_COLUMN_UUID_UUID_2);
917 }
918
919 String sql = query.toString();
920
921 Session session = null;
922
923 try {
924 session = openSession();
925
926 Query q = session.createQuery(sql);
927
928 QueryPos qPos = QueryPos.getInstance(q);
929
930 if (bindUuid) {
931 qPos.add(uuid);
932 }
933
934 count = (Long)q.uniqueResult();
935
936 FinderCacheUtil.putResult(finderPath, finderArgs, count);
937 }
938 catch (Exception e) {
939 FinderCacheUtil.removeResult(finderPath, finderArgs);
940
941 throw processException(e);
942 }
943 finally {
944 closeSession(session);
945 }
946 }
947
948 return count.intValue();
949 }
950
951
957 @Override
958 public int filterCountByUuid(String uuid) {
959 if (!InlineSQLHelperUtil.isEnabled()) {
960 return countByUuid(uuid);
961 }
962
963 StringBundler query = new StringBundler(2);
964
965 query.append(_FILTER_SQL_COUNT_LAYOUTSETPROTOTYPE_WHERE);
966
967 boolean bindUuid = false;
968
969 if (uuid == null) {
970 query.append(_FINDER_COLUMN_UUID_UUID_1_SQL);
971 }
972 else if (uuid.equals(StringPool.BLANK)) {
973 query.append(_FINDER_COLUMN_UUID_UUID_3_SQL);
974 }
975 else {
976 bindUuid = true;
977
978 query.append(_FINDER_COLUMN_UUID_UUID_2_SQL);
979 }
980
981 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
982 LayoutSetPrototype.class.getName(),
983 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
984
985 Session session = null;
986
987 try {
988 session = openSession();
989
990 SQLQuery q = session.createSynchronizedSQLQuery(sql);
991
992 q.addScalar(COUNT_COLUMN_NAME,
993 com.liferay.portal.kernel.dao.orm.Type.LONG);
994
995 QueryPos qPos = QueryPos.getInstance(q);
996
997 if (bindUuid) {
998 qPos.add(uuid);
999 }
1000
1001 Long count = (Long)q.uniqueResult();
1002
1003 return count.intValue();
1004 }
1005 catch (Exception e) {
1006 throw processException(e);
1007 }
1008 finally {
1009 closeSession(session);
1010 }
1011 }
1012
1013 private static final String _FINDER_COLUMN_UUID_UUID_1 = "layoutSetPrototype.uuid IS NULL";
1014 private static final String _FINDER_COLUMN_UUID_UUID_2 = "layoutSetPrototype.uuid = ?";
1015 private static final String _FINDER_COLUMN_UUID_UUID_3 = "(layoutSetPrototype.uuid IS NULL OR layoutSetPrototype.uuid = '')";
1016 private static final String _FINDER_COLUMN_UUID_UUID_1_SQL = "layoutSetPrototype.uuid_ IS NULL";
1017 private static final String _FINDER_COLUMN_UUID_UUID_2_SQL = "layoutSetPrototype.uuid_ = ?";
1018 private static final String _FINDER_COLUMN_UUID_UUID_3_SQL = "(layoutSetPrototype.uuid_ IS NULL OR layoutSetPrototype.uuid_ = '')";
1019 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C = new FinderPath(LayoutSetPrototypeModelImpl.ENTITY_CACHE_ENABLED,
1020 LayoutSetPrototypeModelImpl.FINDER_CACHE_ENABLED,
1021 LayoutSetPrototypeImpl.class,
1022 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid_C",
1023 new String[] {
1024 String.class.getName(), Long.class.getName(),
1025
1026 Integer.class.getName(), Integer.class.getName(),
1027 OrderByComparator.class.getName()
1028 });
1029 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C =
1030 new FinderPath(LayoutSetPrototypeModelImpl.ENTITY_CACHE_ENABLED,
1031 LayoutSetPrototypeModelImpl.FINDER_CACHE_ENABLED,
1032 LayoutSetPrototypeImpl.class,
1033 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid_C",
1034 new String[] { String.class.getName(), Long.class.getName() },
1035 LayoutSetPrototypeModelImpl.UUID_COLUMN_BITMASK |
1036 LayoutSetPrototypeModelImpl.COMPANYID_COLUMN_BITMASK);
1037 public static final FinderPath FINDER_PATH_COUNT_BY_UUID_C = new FinderPath(LayoutSetPrototypeModelImpl.ENTITY_CACHE_ENABLED,
1038 LayoutSetPrototypeModelImpl.FINDER_CACHE_ENABLED, Long.class,
1039 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid_C",
1040 new String[] { String.class.getName(), Long.class.getName() });
1041
1042
1049 @Override
1050 public List<LayoutSetPrototype> findByUuid_C(String uuid, long companyId) {
1051 return findByUuid_C(uuid, companyId, QueryUtil.ALL_POS,
1052 QueryUtil.ALL_POS, null);
1053 }
1054
1055
1068 @Override
1069 public List<LayoutSetPrototype> findByUuid_C(String uuid, long companyId,
1070 int start, int end) {
1071 return findByUuid_C(uuid, companyId, start, end, null);
1072 }
1073
1074
1088 @Override
1089 public List<LayoutSetPrototype> findByUuid_C(String uuid, long companyId,
1090 int start, int end,
1091 OrderByComparator<LayoutSetPrototype> orderByComparator) {
1092 boolean pagination = true;
1093 FinderPath finderPath = null;
1094 Object[] finderArgs = null;
1095
1096 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1097 (orderByComparator == null)) {
1098 pagination = false;
1099 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C;
1100 finderArgs = new Object[] { uuid, companyId };
1101 }
1102 else {
1103 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C;
1104 finderArgs = new Object[] {
1105 uuid, companyId,
1106
1107 start, end, orderByComparator
1108 };
1109 }
1110
1111 List<LayoutSetPrototype> list = (List<LayoutSetPrototype>)FinderCacheUtil.getResult(finderPath,
1112 finderArgs, this);
1113
1114 if ((list != null) && !list.isEmpty()) {
1115 for (LayoutSetPrototype layoutSetPrototype : list) {
1116 if (!Validator.equals(uuid, layoutSetPrototype.getUuid()) ||
1117 (companyId != layoutSetPrototype.getCompanyId())) {
1118 list = null;
1119
1120 break;
1121 }
1122 }
1123 }
1124
1125 if (list == null) {
1126 StringBundler query = null;
1127
1128 if (orderByComparator != null) {
1129 query = new StringBundler(4 +
1130 (orderByComparator.getOrderByFields().length * 3));
1131 }
1132 else {
1133 query = new StringBundler(4);
1134 }
1135
1136 query.append(_SQL_SELECT_LAYOUTSETPROTOTYPE_WHERE);
1137
1138 boolean bindUuid = false;
1139
1140 if (uuid == null) {
1141 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1142 }
1143 else if (uuid.equals(StringPool.BLANK)) {
1144 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1145 }
1146 else {
1147 bindUuid = true;
1148
1149 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1150 }
1151
1152 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1153
1154 if (orderByComparator != null) {
1155 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1156 orderByComparator);
1157 }
1158 else
1159 if (pagination) {
1160 query.append(LayoutSetPrototypeModelImpl.ORDER_BY_JPQL);
1161 }
1162
1163 String sql = query.toString();
1164
1165 Session session = null;
1166
1167 try {
1168 session = openSession();
1169
1170 Query q = session.createQuery(sql);
1171
1172 QueryPos qPos = QueryPos.getInstance(q);
1173
1174 if (bindUuid) {
1175 qPos.add(uuid);
1176 }
1177
1178 qPos.add(companyId);
1179
1180 if (!pagination) {
1181 list = (List<LayoutSetPrototype>)QueryUtil.list(q,
1182 getDialect(), start, end, false);
1183
1184 Collections.sort(list);
1185
1186 list = Collections.unmodifiableList(list);
1187 }
1188 else {
1189 list = (List<LayoutSetPrototype>)QueryUtil.list(q,
1190 getDialect(), start, end);
1191 }
1192
1193 cacheResult(list);
1194
1195 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1196 }
1197 catch (Exception e) {
1198 FinderCacheUtil.removeResult(finderPath, finderArgs);
1199
1200 throw processException(e);
1201 }
1202 finally {
1203 closeSession(session);
1204 }
1205 }
1206
1207 return list;
1208 }
1209
1210
1219 @Override
1220 public LayoutSetPrototype findByUuid_C_First(String uuid, long companyId,
1221 OrderByComparator<LayoutSetPrototype> orderByComparator)
1222 throws NoSuchLayoutSetPrototypeException {
1223 LayoutSetPrototype layoutSetPrototype = fetchByUuid_C_First(uuid,
1224 companyId, orderByComparator);
1225
1226 if (layoutSetPrototype != null) {
1227 return layoutSetPrototype;
1228 }
1229
1230 StringBundler msg = new StringBundler(6);
1231
1232 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1233
1234 msg.append("uuid=");
1235 msg.append(uuid);
1236
1237 msg.append(", companyId=");
1238 msg.append(companyId);
1239
1240 msg.append(StringPool.CLOSE_CURLY_BRACE);
1241
1242 throw new NoSuchLayoutSetPrototypeException(msg.toString());
1243 }
1244
1245
1253 @Override
1254 public LayoutSetPrototype fetchByUuid_C_First(String uuid, long companyId,
1255 OrderByComparator<LayoutSetPrototype> orderByComparator) {
1256 List<LayoutSetPrototype> list = findByUuid_C(uuid, companyId, 0, 1,
1257 orderByComparator);
1258
1259 if (!list.isEmpty()) {
1260 return list.get(0);
1261 }
1262
1263 return null;
1264 }
1265
1266
1275 @Override
1276 public LayoutSetPrototype findByUuid_C_Last(String uuid, long companyId,
1277 OrderByComparator<LayoutSetPrototype> orderByComparator)
1278 throws NoSuchLayoutSetPrototypeException {
1279 LayoutSetPrototype layoutSetPrototype = fetchByUuid_C_Last(uuid,
1280 companyId, orderByComparator);
1281
1282 if (layoutSetPrototype != null) {
1283 return layoutSetPrototype;
1284 }
1285
1286 StringBundler msg = new StringBundler(6);
1287
1288 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1289
1290 msg.append("uuid=");
1291 msg.append(uuid);
1292
1293 msg.append(", companyId=");
1294 msg.append(companyId);
1295
1296 msg.append(StringPool.CLOSE_CURLY_BRACE);
1297
1298 throw new NoSuchLayoutSetPrototypeException(msg.toString());
1299 }
1300
1301
1309 @Override
1310 public LayoutSetPrototype fetchByUuid_C_Last(String uuid, long companyId,
1311 OrderByComparator<LayoutSetPrototype> orderByComparator) {
1312 int count = countByUuid_C(uuid, companyId);
1313
1314 if (count == 0) {
1315 return null;
1316 }
1317
1318 List<LayoutSetPrototype> list = findByUuid_C(uuid, companyId,
1319 count - 1, count, orderByComparator);
1320
1321 if (!list.isEmpty()) {
1322 return list.get(0);
1323 }
1324
1325 return null;
1326 }
1327
1328
1338 @Override
1339 public LayoutSetPrototype[] findByUuid_C_PrevAndNext(
1340 long layoutSetPrototypeId, String uuid, long companyId,
1341 OrderByComparator<LayoutSetPrototype> orderByComparator)
1342 throws NoSuchLayoutSetPrototypeException {
1343 LayoutSetPrototype layoutSetPrototype = findByPrimaryKey(layoutSetPrototypeId);
1344
1345 Session session = null;
1346
1347 try {
1348 session = openSession();
1349
1350 LayoutSetPrototype[] array = new LayoutSetPrototypeImpl[3];
1351
1352 array[0] = getByUuid_C_PrevAndNext(session, layoutSetPrototype,
1353 uuid, companyId, orderByComparator, true);
1354
1355 array[1] = layoutSetPrototype;
1356
1357 array[2] = getByUuid_C_PrevAndNext(session, layoutSetPrototype,
1358 uuid, companyId, orderByComparator, false);
1359
1360 return array;
1361 }
1362 catch (Exception e) {
1363 throw processException(e);
1364 }
1365 finally {
1366 closeSession(session);
1367 }
1368 }
1369
1370 protected LayoutSetPrototype getByUuid_C_PrevAndNext(Session session,
1371 LayoutSetPrototype layoutSetPrototype, String uuid, long companyId,
1372 OrderByComparator<LayoutSetPrototype> orderByComparator,
1373 boolean previous) {
1374 StringBundler query = null;
1375
1376 if (orderByComparator != null) {
1377 query = new StringBundler(6 +
1378 (orderByComparator.getOrderByFields().length * 6));
1379 }
1380 else {
1381 query = new StringBundler(3);
1382 }
1383
1384 query.append(_SQL_SELECT_LAYOUTSETPROTOTYPE_WHERE);
1385
1386 boolean bindUuid = false;
1387
1388 if (uuid == null) {
1389 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1390 }
1391 else if (uuid.equals(StringPool.BLANK)) {
1392 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1393 }
1394 else {
1395 bindUuid = true;
1396
1397 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1398 }
1399
1400 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1401
1402 if (orderByComparator != null) {
1403 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1404
1405 if (orderByConditionFields.length > 0) {
1406 query.append(WHERE_AND);
1407 }
1408
1409 for (int i = 0; i < orderByConditionFields.length; i++) {
1410 query.append(_ORDER_BY_ENTITY_ALIAS);
1411 query.append(orderByConditionFields[i]);
1412
1413 if ((i + 1) < orderByConditionFields.length) {
1414 if (orderByComparator.isAscending() ^ previous) {
1415 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1416 }
1417 else {
1418 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1419 }
1420 }
1421 else {
1422 if (orderByComparator.isAscending() ^ previous) {
1423 query.append(WHERE_GREATER_THAN);
1424 }
1425 else {
1426 query.append(WHERE_LESSER_THAN);
1427 }
1428 }
1429 }
1430
1431 query.append(ORDER_BY_CLAUSE);
1432
1433 String[] orderByFields = orderByComparator.getOrderByFields();
1434
1435 for (int i = 0; i < orderByFields.length; i++) {
1436 query.append(_ORDER_BY_ENTITY_ALIAS);
1437 query.append(orderByFields[i]);
1438
1439 if ((i + 1) < orderByFields.length) {
1440 if (orderByComparator.isAscending() ^ previous) {
1441 query.append(ORDER_BY_ASC_HAS_NEXT);
1442 }
1443 else {
1444 query.append(ORDER_BY_DESC_HAS_NEXT);
1445 }
1446 }
1447 else {
1448 if (orderByComparator.isAscending() ^ previous) {
1449 query.append(ORDER_BY_ASC);
1450 }
1451 else {
1452 query.append(ORDER_BY_DESC);
1453 }
1454 }
1455 }
1456 }
1457 else {
1458 query.append(LayoutSetPrototypeModelImpl.ORDER_BY_JPQL);
1459 }
1460
1461 String sql = query.toString();
1462
1463 Query q = session.createQuery(sql);
1464
1465 q.setFirstResult(0);
1466 q.setMaxResults(2);
1467
1468 QueryPos qPos = QueryPos.getInstance(q);
1469
1470 if (bindUuid) {
1471 qPos.add(uuid);
1472 }
1473
1474 qPos.add(companyId);
1475
1476 if (orderByComparator != null) {
1477 Object[] values = orderByComparator.getOrderByConditionValues(layoutSetPrototype);
1478
1479 for (Object value : values) {
1480 qPos.add(value);
1481 }
1482 }
1483
1484 List<LayoutSetPrototype> list = q.list();
1485
1486 if (list.size() == 2) {
1487 return list.get(1);
1488 }
1489 else {
1490 return null;
1491 }
1492 }
1493
1494
1501 @Override
1502 public List<LayoutSetPrototype> filterFindByUuid_C(String uuid,
1503 long companyId) {
1504 return filterFindByUuid_C(uuid, companyId, QueryUtil.ALL_POS,
1505 QueryUtil.ALL_POS, null);
1506 }
1507
1508
1521 @Override
1522 public List<LayoutSetPrototype> filterFindByUuid_C(String uuid,
1523 long companyId, int start, int end) {
1524 return filterFindByUuid_C(uuid, companyId, start, end, null);
1525 }
1526
1527
1541 @Override
1542 public List<LayoutSetPrototype> filterFindByUuid_C(String uuid,
1543 long companyId, int start, int end,
1544 OrderByComparator<LayoutSetPrototype> orderByComparator) {
1545 if (!InlineSQLHelperUtil.isEnabled()) {
1546 return findByUuid_C(uuid, companyId, start, end, orderByComparator);
1547 }
1548
1549 StringBundler query = null;
1550
1551 if (orderByComparator != null) {
1552 query = new StringBundler(4 +
1553 (orderByComparator.getOrderByFields().length * 3));
1554 }
1555 else {
1556 query = new StringBundler(4);
1557 }
1558
1559 if (getDB().isSupportsInlineDistinct()) {
1560 query.append(_FILTER_SQL_SELECT_LAYOUTSETPROTOTYPE_WHERE);
1561 }
1562 else {
1563 query.append(_FILTER_SQL_SELECT_LAYOUTSETPROTOTYPE_NO_INLINE_DISTINCT_WHERE_1);
1564 }
1565
1566 boolean bindUuid = false;
1567
1568 if (uuid == null) {
1569 query.append(_FINDER_COLUMN_UUID_C_UUID_1_SQL);
1570 }
1571 else if (uuid.equals(StringPool.BLANK)) {
1572 query.append(_FINDER_COLUMN_UUID_C_UUID_3_SQL);
1573 }
1574 else {
1575 bindUuid = true;
1576
1577 query.append(_FINDER_COLUMN_UUID_C_UUID_2_SQL);
1578 }
1579
1580 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1581
1582 if (!getDB().isSupportsInlineDistinct()) {
1583 query.append(_FILTER_SQL_SELECT_LAYOUTSETPROTOTYPE_NO_INLINE_DISTINCT_WHERE_2);
1584 }
1585
1586 if (orderByComparator != null) {
1587 if (getDB().isSupportsInlineDistinct()) {
1588 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1589 orderByComparator, true);
1590 }
1591 else {
1592 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
1593 orderByComparator, true);
1594 }
1595 }
1596 else {
1597 if (getDB().isSupportsInlineDistinct()) {
1598 query.append(LayoutSetPrototypeModelImpl.ORDER_BY_JPQL);
1599 }
1600 else {
1601 query.append(LayoutSetPrototypeModelImpl.ORDER_BY_SQL);
1602 }
1603 }
1604
1605 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1606 LayoutSetPrototype.class.getName(),
1607 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
1608
1609 Session session = null;
1610
1611 try {
1612 session = openSession();
1613
1614 SQLQuery q = session.createSynchronizedSQLQuery(sql);
1615
1616 if (getDB().isSupportsInlineDistinct()) {
1617 q.addEntity(_FILTER_ENTITY_ALIAS, LayoutSetPrototypeImpl.class);
1618 }
1619 else {
1620 q.addEntity(_FILTER_ENTITY_TABLE, LayoutSetPrototypeImpl.class);
1621 }
1622
1623 QueryPos qPos = QueryPos.getInstance(q);
1624
1625 if (bindUuid) {
1626 qPos.add(uuid);
1627 }
1628
1629 qPos.add(companyId);
1630
1631 return (List<LayoutSetPrototype>)QueryUtil.list(q, getDialect(),
1632 start, end);
1633 }
1634 catch (Exception e) {
1635 throw processException(e);
1636 }
1637 finally {
1638 closeSession(session);
1639 }
1640 }
1641
1642
1652 @Override
1653 public LayoutSetPrototype[] filterFindByUuid_C_PrevAndNext(
1654 long layoutSetPrototypeId, String uuid, long companyId,
1655 OrderByComparator<LayoutSetPrototype> orderByComparator)
1656 throws NoSuchLayoutSetPrototypeException {
1657 if (!InlineSQLHelperUtil.isEnabled()) {
1658 return findByUuid_C_PrevAndNext(layoutSetPrototypeId, uuid,
1659 companyId, orderByComparator);
1660 }
1661
1662 LayoutSetPrototype layoutSetPrototype = findByPrimaryKey(layoutSetPrototypeId);
1663
1664 Session session = null;
1665
1666 try {
1667 session = openSession();
1668
1669 LayoutSetPrototype[] array = new LayoutSetPrototypeImpl[3];
1670
1671 array[0] = filterGetByUuid_C_PrevAndNext(session,
1672 layoutSetPrototype, uuid, companyId, orderByComparator, true);
1673
1674 array[1] = layoutSetPrototype;
1675
1676 array[2] = filterGetByUuid_C_PrevAndNext(session,
1677 layoutSetPrototype, uuid, companyId, orderByComparator,
1678 false);
1679
1680 return array;
1681 }
1682 catch (Exception e) {
1683 throw processException(e);
1684 }
1685 finally {
1686 closeSession(session);
1687 }
1688 }
1689
1690 protected LayoutSetPrototype filterGetByUuid_C_PrevAndNext(
1691 Session session, LayoutSetPrototype layoutSetPrototype, String uuid,
1692 long companyId,
1693 OrderByComparator<LayoutSetPrototype> orderByComparator,
1694 boolean previous) {
1695 StringBundler query = null;
1696
1697 if (orderByComparator != null) {
1698 query = new StringBundler(6 +
1699 (orderByComparator.getOrderByFields().length * 6));
1700 }
1701 else {
1702 query = new StringBundler(3);
1703 }
1704
1705 if (getDB().isSupportsInlineDistinct()) {
1706 query.append(_FILTER_SQL_SELECT_LAYOUTSETPROTOTYPE_WHERE);
1707 }
1708 else {
1709 query.append(_FILTER_SQL_SELECT_LAYOUTSETPROTOTYPE_NO_INLINE_DISTINCT_WHERE_1);
1710 }
1711
1712 boolean bindUuid = false;
1713
1714 if (uuid == null) {
1715 query.append(_FINDER_COLUMN_UUID_C_UUID_1_SQL);
1716 }
1717 else if (uuid.equals(StringPool.BLANK)) {
1718 query.append(_FINDER_COLUMN_UUID_C_UUID_3_SQL);
1719 }
1720 else {
1721 bindUuid = true;
1722
1723 query.append(_FINDER_COLUMN_UUID_C_UUID_2_SQL);
1724 }
1725
1726 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1727
1728 if (!getDB().isSupportsInlineDistinct()) {
1729 query.append(_FILTER_SQL_SELECT_LAYOUTSETPROTOTYPE_NO_INLINE_DISTINCT_WHERE_2);
1730 }
1731
1732 if (orderByComparator != null) {
1733 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1734
1735 if (orderByConditionFields.length > 0) {
1736 query.append(WHERE_AND);
1737 }
1738
1739 for (int i = 0; i < orderByConditionFields.length; i++) {
1740 if (getDB().isSupportsInlineDistinct()) {
1741 query.append(_ORDER_BY_ENTITY_ALIAS);
1742 }
1743 else {
1744 query.append(_ORDER_BY_ENTITY_TABLE);
1745 }
1746
1747 query.append(orderByConditionFields[i]);
1748
1749 if ((i + 1) < orderByConditionFields.length) {
1750 if (orderByComparator.isAscending() ^ previous) {
1751 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1752 }
1753 else {
1754 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1755 }
1756 }
1757 else {
1758 if (orderByComparator.isAscending() ^ previous) {
1759 query.append(WHERE_GREATER_THAN);
1760 }
1761 else {
1762 query.append(WHERE_LESSER_THAN);
1763 }
1764 }
1765 }
1766
1767 query.append(ORDER_BY_CLAUSE);
1768
1769 String[] orderByFields = orderByComparator.getOrderByFields();
1770
1771 for (int i = 0; i < orderByFields.length; i++) {
1772 if (getDB().isSupportsInlineDistinct()) {
1773 query.append(_ORDER_BY_ENTITY_ALIAS);
1774 }
1775 else {
1776 query.append(_ORDER_BY_ENTITY_TABLE);
1777 }
1778
1779 query.append(orderByFields[i]);
1780
1781 if ((i + 1) < orderByFields.length) {
1782 if (orderByComparator.isAscending() ^ previous) {
1783 query.append(ORDER_BY_ASC_HAS_NEXT);
1784 }
1785 else {
1786 query.append(ORDER_BY_DESC_HAS_NEXT);
1787 }
1788 }
1789 else {
1790 if (orderByComparator.isAscending() ^ previous) {
1791 query.append(ORDER_BY_ASC);
1792 }
1793 else {
1794 query.append(ORDER_BY_DESC);
1795 }
1796 }
1797 }
1798 }
1799 else {
1800 if (getDB().isSupportsInlineDistinct()) {
1801 query.append(LayoutSetPrototypeModelImpl.ORDER_BY_JPQL);
1802 }
1803 else {
1804 query.append(LayoutSetPrototypeModelImpl.ORDER_BY_SQL);
1805 }
1806 }
1807
1808 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1809 LayoutSetPrototype.class.getName(),
1810 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
1811
1812 SQLQuery q = session.createSynchronizedSQLQuery(sql);
1813
1814 q.setFirstResult(0);
1815 q.setMaxResults(2);
1816
1817 if (getDB().isSupportsInlineDistinct()) {
1818 q.addEntity(_FILTER_ENTITY_ALIAS, LayoutSetPrototypeImpl.class);
1819 }
1820 else {
1821 q.addEntity(_FILTER_ENTITY_TABLE, LayoutSetPrototypeImpl.class);
1822 }
1823
1824 QueryPos qPos = QueryPos.getInstance(q);
1825
1826 if (bindUuid) {
1827 qPos.add(uuid);
1828 }
1829
1830 qPos.add(companyId);
1831
1832 if (orderByComparator != null) {
1833 Object[] values = orderByComparator.getOrderByConditionValues(layoutSetPrototype);
1834
1835 for (Object value : values) {
1836 qPos.add(value);
1837 }
1838 }
1839
1840 List<LayoutSetPrototype> list = q.list();
1841
1842 if (list.size() == 2) {
1843 return list.get(1);
1844 }
1845 else {
1846 return null;
1847 }
1848 }
1849
1850
1856 @Override
1857 public void removeByUuid_C(String uuid, long companyId) {
1858 for (LayoutSetPrototype layoutSetPrototype : findByUuid_C(uuid,
1859 companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1860 remove(layoutSetPrototype);
1861 }
1862 }
1863
1864
1871 @Override
1872 public int countByUuid_C(String uuid, long companyId) {
1873 FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_C;
1874
1875 Object[] finderArgs = new Object[] { uuid, companyId };
1876
1877 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1878 this);
1879
1880 if (count == null) {
1881 StringBundler query = new StringBundler(3);
1882
1883 query.append(_SQL_COUNT_LAYOUTSETPROTOTYPE_WHERE);
1884
1885 boolean bindUuid = false;
1886
1887 if (uuid == null) {
1888 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1889 }
1890 else if (uuid.equals(StringPool.BLANK)) {
1891 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1892 }
1893 else {
1894 bindUuid = true;
1895
1896 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1897 }
1898
1899 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1900
1901 String sql = query.toString();
1902
1903 Session session = null;
1904
1905 try {
1906 session = openSession();
1907
1908 Query q = session.createQuery(sql);
1909
1910 QueryPos qPos = QueryPos.getInstance(q);
1911
1912 if (bindUuid) {
1913 qPos.add(uuid);
1914 }
1915
1916 qPos.add(companyId);
1917
1918 count = (Long)q.uniqueResult();
1919
1920 FinderCacheUtil.putResult(finderPath, finderArgs, count);
1921 }
1922 catch (Exception e) {
1923 FinderCacheUtil.removeResult(finderPath, finderArgs);
1924
1925 throw processException(e);
1926 }
1927 finally {
1928 closeSession(session);
1929 }
1930 }
1931
1932 return count.intValue();
1933 }
1934
1935
1942 @Override
1943 public int filterCountByUuid_C(String uuid, long companyId) {
1944 if (!InlineSQLHelperUtil.isEnabled()) {
1945 return countByUuid_C(uuid, companyId);
1946 }
1947
1948 StringBundler query = new StringBundler(3);
1949
1950 query.append(_FILTER_SQL_COUNT_LAYOUTSETPROTOTYPE_WHERE);
1951
1952 boolean bindUuid = false;
1953
1954 if (uuid == null) {
1955 query.append(_FINDER_COLUMN_UUID_C_UUID_1_SQL);
1956 }
1957 else if (uuid.equals(StringPool.BLANK)) {
1958 query.append(_FINDER_COLUMN_UUID_C_UUID_3_SQL);
1959 }
1960 else {
1961 bindUuid = true;
1962
1963 query.append(_FINDER_COLUMN_UUID_C_UUID_2_SQL);
1964 }
1965
1966 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1967
1968 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1969 LayoutSetPrototype.class.getName(),
1970 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
1971
1972 Session session = null;
1973
1974 try {
1975 session = openSession();
1976
1977 SQLQuery q = session.createSynchronizedSQLQuery(sql);
1978
1979 q.addScalar(COUNT_COLUMN_NAME,
1980 com.liferay.portal.kernel.dao.orm.Type.LONG);
1981
1982 QueryPos qPos = QueryPos.getInstance(q);
1983
1984 if (bindUuid) {
1985 qPos.add(uuid);
1986 }
1987
1988 qPos.add(companyId);
1989
1990 Long count = (Long)q.uniqueResult();
1991
1992 return count.intValue();
1993 }
1994 catch (Exception e) {
1995 throw processException(e);
1996 }
1997 finally {
1998 closeSession(session);
1999 }
2000 }
2001
2002 private static final String _FINDER_COLUMN_UUID_C_UUID_1 = "layoutSetPrototype.uuid IS NULL AND ";
2003 private static final String _FINDER_COLUMN_UUID_C_UUID_2 = "layoutSetPrototype.uuid = ? AND ";
2004 private static final String _FINDER_COLUMN_UUID_C_UUID_3 = "(layoutSetPrototype.uuid IS NULL OR layoutSetPrototype.uuid = '') AND ";
2005 private static final String _FINDER_COLUMN_UUID_C_UUID_1_SQL = "layoutSetPrototype.uuid_ IS NULL AND ";
2006 private static final String _FINDER_COLUMN_UUID_C_UUID_2_SQL = "layoutSetPrototype.uuid_ = ? AND ";
2007 private static final String _FINDER_COLUMN_UUID_C_UUID_3_SQL = "(layoutSetPrototype.uuid_ IS NULL OR layoutSetPrototype.uuid_ = '') AND ";
2008 private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 = "layoutSetPrototype.companyId = ?";
2009 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID =
2010 new FinderPath(LayoutSetPrototypeModelImpl.ENTITY_CACHE_ENABLED,
2011 LayoutSetPrototypeModelImpl.FINDER_CACHE_ENABLED,
2012 LayoutSetPrototypeImpl.class,
2013 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByCompanyId",
2014 new String[] {
2015 Long.class.getName(),
2016
2017 Integer.class.getName(), Integer.class.getName(),
2018 OrderByComparator.class.getName()
2019 });
2020 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID =
2021 new FinderPath(LayoutSetPrototypeModelImpl.ENTITY_CACHE_ENABLED,
2022 LayoutSetPrototypeModelImpl.FINDER_CACHE_ENABLED,
2023 LayoutSetPrototypeImpl.class,
2024 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCompanyId",
2025 new String[] { Long.class.getName() },
2026 LayoutSetPrototypeModelImpl.COMPANYID_COLUMN_BITMASK);
2027 public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(LayoutSetPrototypeModelImpl.ENTITY_CACHE_ENABLED,
2028 LayoutSetPrototypeModelImpl.FINDER_CACHE_ENABLED, Long.class,
2029 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCompanyId",
2030 new String[] { Long.class.getName() });
2031
2032
2038 @Override
2039 public List<LayoutSetPrototype> findByCompanyId(long companyId) {
2040 return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
2041 null);
2042 }
2043
2044
2056 @Override
2057 public List<LayoutSetPrototype> findByCompanyId(long companyId, int start,
2058 int end) {
2059 return findByCompanyId(companyId, start, end, null);
2060 }
2061
2062
2075 @Override
2076 public List<LayoutSetPrototype> findByCompanyId(long companyId, int start,
2077 int end, OrderByComparator<LayoutSetPrototype> orderByComparator) {
2078 boolean pagination = true;
2079 FinderPath finderPath = null;
2080 Object[] finderArgs = null;
2081
2082 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2083 (orderByComparator == null)) {
2084 pagination = false;
2085 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID;
2086 finderArgs = new Object[] { companyId };
2087 }
2088 else {
2089 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID;
2090 finderArgs = new Object[] { companyId, start, end, orderByComparator };
2091 }
2092
2093 List<LayoutSetPrototype> list = (List<LayoutSetPrototype>)FinderCacheUtil.getResult(finderPath,
2094 finderArgs, this);
2095
2096 if ((list != null) && !list.isEmpty()) {
2097 for (LayoutSetPrototype layoutSetPrototype : list) {
2098 if ((companyId != layoutSetPrototype.getCompanyId())) {
2099 list = null;
2100
2101 break;
2102 }
2103 }
2104 }
2105
2106 if (list == null) {
2107 StringBundler query = null;
2108
2109 if (orderByComparator != null) {
2110 query = new StringBundler(3 +
2111 (orderByComparator.getOrderByFields().length * 3));
2112 }
2113 else {
2114 query = new StringBundler(3);
2115 }
2116
2117 query.append(_SQL_SELECT_LAYOUTSETPROTOTYPE_WHERE);
2118
2119 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2120
2121 if (orderByComparator != null) {
2122 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2123 orderByComparator);
2124 }
2125 else
2126 if (pagination) {
2127 query.append(LayoutSetPrototypeModelImpl.ORDER_BY_JPQL);
2128 }
2129
2130 String sql = query.toString();
2131
2132 Session session = null;
2133
2134 try {
2135 session = openSession();
2136
2137 Query q = session.createQuery(sql);
2138
2139 QueryPos qPos = QueryPos.getInstance(q);
2140
2141 qPos.add(companyId);
2142
2143 if (!pagination) {
2144 list = (List<LayoutSetPrototype>)QueryUtil.list(q,
2145 getDialect(), start, end, false);
2146
2147 Collections.sort(list);
2148
2149 list = Collections.unmodifiableList(list);
2150 }
2151 else {
2152 list = (List<LayoutSetPrototype>)QueryUtil.list(q,
2153 getDialect(), start, end);
2154 }
2155
2156 cacheResult(list);
2157
2158 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2159 }
2160 catch (Exception e) {
2161 FinderCacheUtil.removeResult(finderPath, finderArgs);
2162
2163 throw processException(e);
2164 }
2165 finally {
2166 closeSession(session);
2167 }
2168 }
2169
2170 return list;
2171 }
2172
2173
2181 @Override
2182 public LayoutSetPrototype findByCompanyId_First(long companyId,
2183 OrderByComparator<LayoutSetPrototype> orderByComparator)
2184 throws NoSuchLayoutSetPrototypeException {
2185 LayoutSetPrototype layoutSetPrototype = fetchByCompanyId_First(companyId,
2186 orderByComparator);
2187
2188 if (layoutSetPrototype != null) {
2189 return layoutSetPrototype;
2190 }
2191
2192 StringBundler msg = new StringBundler(4);
2193
2194 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2195
2196 msg.append("companyId=");
2197 msg.append(companyId);
2198
2199 msg.append(StringPool.CLOSE_CURLY_BRACE);
2200
2201 throw new NoSuchLayoutSetPrototypeException(msg.toString());
2202 }
2203
2204
2211 @Override
2212 public LayoutSetPrototype fetchByCompanyId_First(long companyId,
2213 OrderByComparator<LayoutSetPrototype> orderByComparator) {
2214 List<LayoutSetPrototype> list = findByCompanyId(companyId, 0, 1,
2215 orderByComparator);
2216
2217 if (!list.isEmpty()) {
2218 return list.get(0);
2219 }
2220
2221 return null;
2222 }
2223
2224
2232 @Override
2233 public LayoutSetPrototype findByCompanyId_Last(long companyId,
2234 OrderByComparator<LayoutSetPrototype> orderByComparator)
2235 throws NoSuchLayoutSetPrototypeException {
2236 LayoutSetPrototype layoutSetPrototype = fetchByCompanyId_Last(companyId,
2237 orderByComparator);
2238
2239 if (layoutSetPrototype != null) {
2240 return layoutSetPrototype;
2241 }
2242
2243 StringBundler msg = new StringBundler(4);
2244
2245 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2246
2247 msg.append("companyId=");
2248 msg.append(companyId);
2249
2250 msg.append(StringPool.CLOSE_CURLY_BRACE);
2251
2252 throw new NoSuchLayoutSetPrototypeException(msg.toString());
2253 }
2254
2255
2262 @Override
2263 public LayoutSetPrototype fetchByCompanyId_Last(long companyId,
2264 OrderByComparator<LayoutSetPrototype> orderByComparator) {
2265 int count = countByCompanyId(companyId);
2266
2267 if (count == 0) {
2268 return null;
2269 }
2270
2271 List<LayoutSetPrototype> list = findByCompanyId(companyId, count - 1,
2272 count, orderByComparator);
2273
2274 if (!list.isEmpty()) {
2275 return list.get(0);
2276 }
2277
2278 return null;
2279 }
2280
2281
2290 @Override
2291 public LayoutSetPrototype[] findByCompanyId_PrevAndNext(
2292 long layoutSetPrototypeId, long companyId,
2293 OrderByComparator<LayoutSetPrototype> orderByComparator)
2294 throws NoSuchLayoutSetPrototypeException {
2295 LayoutSetPrototype layoutSetPrototype = findByPrimaryKey(layoutSetPrototypeId);
2296
2297 Session session = null;
2298
2299 try {
2300 session = openSession();
2301
2302 LayoutSetPrototype[] array = new LayoutSetPrototypeImpl[3];
2303
2304 array[0] = getByCompanyId_PrevAndNext(session, layoutSetPrototype,
2305 companyId, orderByComparator, true);
2306
2307 array[1] = layoutSetPrototype;
2308
2309 array[2] = getByCompanyId_PrevAndNext(session, layoutSetPrototype,
2310 companyId, orderByComparator, false);
2311
2312 return array;
2313 }
2314 catch (Exception e) {
2315 throw processException(e);
2316 }
2317 finally {
2318 closeSession(session);
2319 }
2320 }
2321
2322 protected LayoutSetPrototype getByCompanyId_PrevAndNext(Session session,
2323 LayoutSetPrototype layoutSetPrototype, long companyId,
2324 OrderByComparator<LayoutSetPrototype> orderByComparator,
2325 boolean previous) {
2326 StringBundler query = null;
2327
2328 if (orderByComparator != null) {
2329 query = new StringBundler(6 +
2330 (orderByComparator.getOrderByFields().length * 6));
2331 }
2332 else {
2333 query = new StringBundler(3);
2334 }
2335
2336 query.append(_SQL_SELECT_LAYOUTSETPROTOTYPE_WHERE);
2337
2338 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2339
2340 if (orderByComparator != null) {
2341 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2342
2343 if (orderByConditionFields.length > 0) {
2344 query.append(WHERE_AND);
2345 }
2346
2347 for (int i = 0; i < orderByConditionFields.length; i++) {
2348 query.append(_ORDER_BY_ENTITY_ALIAS);
2349 query.append(orderByConditionFields[i]);
2350
2351 if ((i + 1) < orderByConditionFields.length) {
2352 if (orderByComparator.isAscending() ^ previous) {
2353 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2354 }
2355 else {
2356 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2357 }
2358 }
2359 else {
2360 if (orderByComparator.isAscending() ^ previous) {
2361 query.append(WHERE_GREATER_THAN);
2362 }
2363 else {
2364 query.append(WHERE_LESSER_THAN);
2365 }
2366 }
2367 }
2368
2369 query.append(ORDER_BY_CLAUSE);
2370
2371 String[] orderByFields = orderByComparator.getOrderByFields();
2372
2373 for (int i = 0; i < orderByFields.length; i++) {
2374 query.append(_ORDER_BY_ENTITY_ALIAS);
2375 query.append(orderByFields[i]);
2376
2377 if ((i + 1) < orderByFields.length) {
2378 if (orderByComparator.isAscending() ^ previous) {
2379 query.append(ORDER_BY_ASC_HAS_NEXT);
2380 }
2381 else {
2382 query.append(ORDER_BY_DESC_HAS_NEXT);
2383 }
2384 }
2385 else {
2386 if (orderByComparator.isAscending() ^ previous) {
2387 query.append(ORDER_BY_ASC);
2388 }
2389 else {
2390 query.append(ORDER_BY_DESC);
2391 }
2392 }
2393 }
2394 }
2395 else {
2396 query.append(LayoutSetPrototypeModelImpl.ORDER_BY_JPQL);
2397 }
2398
2399 String sql = query.toString();
2400
2401 Query q = session.createQuery(sql);
2402
2403 q.setFirstResult(0);
2404 q.setMaxResults(2);
2405
2406 QueryPos qPos = QueryPos.getInstance(q);
2407
2408 qPos.add(companyId);
2409
2410 if (orderByComparator != null) {
2411 Object[] values = orderByComparator.getOrderByConditionValues(layoutSetPrototype);
2412
2413 for (Object value : values) {
2414 qPos.add(value);
2415 }
2416 }
2417
2418 List<LayoutSetPrototype> list = q.list();
2419
2420 if (list.size() == 2) {
2421 return list.get(1);
2422 }
2423 else {
2424 return null;
2425 }
2426 }
2427
2428
2434 @Override
2435 public List<LayoutSetPrototype> filterFindByCompanyId(long companyId) {
2436 return filterFindByCompanyId(companyId, QueryUtil.ALL_POS,
2437 QueryUtil.ALL_POS, null);
2438 }
2439
2440
2452 @Override
2453 public List<LayoutSetPrototype> filterFindByCompanyId(long companyId,
2454 int start, int end) {
2455 return filterFindByCompanyId(companyId, start, end, null);
2456 }
2457
2458
2471 @Override
2472 public List<LayoutSetPrototype> filterFindByCompanyId(long companyId,
2473 int start, int end,
2474 OrderByComparator<LayoutSetPrototype> orderByComparator) {
2475 if (!InlineSQLHelperUtil.isEnabled()) {
2476 return findByCompanyId(companyId, start, end, orderByComparator);
2477 }
2478
2479 StringBundler query = null;
2480
2481 if (orderByComparator != null) {
2482 query = new StringBundler(3 +
2483 (orderByComparator.getOrderByFields().length * 3));
2484 }
2485 else {
2486 query = new StringBundler(3);
2487 }
2488
2489 if (getDB().isSupportsInlineDistinct()) {
2490 query.append(_FILTER_SQL_SELECT_LAYOUTSETPROTOTYPE_WHERE);
2491 }
2492 else {
2493 query.append(_FILTER_SQL_SELECT_LAYOUTSETPROTOTYPE_NO_INLINE_DISTINCT_WHERE_1);
2494 }
2495
2496 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2497
2498 if (!getDB().isSupportsInlineDistinct()) {
2499 query.append(_FILTER_SQL_SELECT_LAYOUTSETPROTOTYPE_NO_INLINE_DISTINCT_WHERE_2);
2500 }
2501
2502 if (orderByComparator != null) {
2503 if (getDB().isSupportsInlineDistinct()) {
2504 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2505 orderByComparator, true);
2506 }
2507 else {
2508 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
2509 orderByComparator, true);
2510 }
2511 }
2512 else {
2513 if (getDB().isSupportsInlineDistinct()) {
2514 query.append(LayoutSetPrototypeModelImpl.ORDER_BY_JPQL);
2515 }
2516 else {
2517 query.append(LayoutSetPrototypeModelImpl.ORDER_BY_SQL);
2518 }
2519 }
2520
2521 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2522 LayoutSetPrototype.class.getName(),
2523 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
2524
2525 Session session = null;
2526
2527 try {
2528 session = openSession();
2529
2530 SQLQuery q = session.createSynchronizedSQLQuery(sql);
2531
2532 if (getDB().isSupportsInlineDistinct()) {
2533 q.addEntity(_FILTER_ENTITY_ALIAS, LayoutSetPrototypeImpl.class);
2534 }
2535 else {
2536 q.addEntity(_FILTER_ENTITY_TABLE, LayoutSetPrototypeImpl.class);
2537 }
2538
2539 QueryPos qPos = QueryPos.getInstance(q);
2540
2541 qPos.add(companyId);
2542
2543 return (List<LayoutSetPrototype>)QueryUtil.list(q, getDialect(),
2544 start, end);
2545 }
2546 catch (Exception e) {
2547 throw processException(e);
2548 }
2549 finally {
2550 closeSession(session);
2551 }
2552 }
2553
2554
2563 @Override
2564 public LayoutSetPrototype[] filterFindByCompanyId_PrevAndNext(
2565 long layoutSetPrototypeId, long companyId,
2566 OrderByComparator<LayoutSetPrototype> orderByComparator)
2567 throws NoSuchLayoutSetPrototypeException {
2568 if (!InlineSQLHelperUtil.isEnabled()) {
2569 return findByCompanyId_PrevAndNext(layoutSetPrototypeId, companyId,
2570 orderByComparator);
2571 }
2572
2573 LayoutSetPrototype layoutSetPrototype = findByPrimaryKey(layoutSetPrototypeId);
2574
2575 Session session = null;
2576
2577 try {
2578 session = openSession();
2579
2580 LayoutSetPrototype[] array = new LayoutSetPrototypeImpl[3];
2581
2582 array[0] = filterGetByCompanyId_PrevAndNext(session,
2583 layoutSetPrototype, companyId, orderByComparator, true);
2584
2585 array[1] = layoutSetPrototype;
2586
2587 array[2] = filterGetByCompanyId_PrevAndNext(session,
2588 layoutSetPrototype, companyId, orderByComparator, false);
2589
2590 return array;
2591 }
2592 catch (Exception e) {
2593 throw processException(e);
2594 }
2595 finally {
2596 closeSession(session);
2597 }
2598 }
2599
2600 protected LayoutSetPrototype filterGetByCompanyId_PrevAndNext(
2601 Session session, LayoutSetPrototype layoutSetPrototype, long companyId,
2602 OrderByComparator<LayoutSetPrototype> orderByComparator,
2603 boolean previous) {
2604 StringBundler query = null;
2605
2606 if (orderByComparator != null) {
2607 query = new StringBundler(6 +
2608 (orderByComparator.getOrderByFields().length * 6));
2609 }
2610 else {
2611 query = new StringBundler(3);
2612 }
2613
2614 if (getDB().isSupportsInlineDistinct()) {
2615 query.append(_FILTER_SQL_SELECT_LAYOUTSETPROTOTYPE_WHERE);
2616 }
2617 else {
2618 query.append(_FILTER_SQL_SELECT_LAYOUTSETPROTOTYPE_NO_INLINE_DISTINCT_WHERE_1);
2619 }
2620
2621 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2622
2623 if (!getDB().isSupportsInlineDistinct()) {
2624 query.append(_FILTER_SQL_SELECT_LAYOUTSETPROTOTYPE_NO_INLINE_DISTINCT_WHERE_2);
2625 }
2626
2627 if (orderByComparator != null) {
2628 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2629
2630 if (orderByConditionFields.length > 0) {
2631 query.append(WHERE_AND);
2632 }
2633
2634 for (int i = 0; i < orderByConditionFields.length; i++) {
2635 if (getDB().isSupportsInlineDistinct()) {
2636 query.append(_ORDER_BY_ENTITY_ALIAS);
2637 }
2638 else {
2639 query.append(_ORDER_BY_ENTITY_TABLE);
2640 }
2641
2642 query.append(orderByConditionFields[i]);
2643
2644 if ((i + 1) < orderByConditionFields.length) {
2645 if (orderByComparator.isAscending() ^ previous) {
2646 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2647 }
2648 else {
2649 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2650 }
2651 }
2652 else {
2653 if (orderByComparator.isAscending() ^ previous) {
2654 query.append(WHERE_GREATER_THAN);
2655 }
2656 else {
2657 query.append(WHERE_LESSER_THAN);
2658 }
2659 }
2660 }
2661
2662 query.append(ORDER_BY_CLAUSE);
2663
2664 String[] orderByFields = orderByComparator.getOrderByFields();
2665
2666 for (int i = 0; i < orderByFields.length; i++) {
2667 if (getDB().isSupportsInlineDistinct()) {
2668 query.append(_ORDER_BY_ENTITY_ALIAS);
2669 }
2670 else {
2671 query.append(_ORDER_BY_ENTITY_TABLE);
2672 }
2673
2674 query.append(orderByFields[i]);
2675
2676 if ((i + 1) < orderByFields.length) {
2677 if (orderByComparator.isAscending() ^ previous) {
2678 query.append(ORDER_BY_ASC_HAS_NEXT);
2679 }
2680 else {
2681 query.append(ORDER_BY_DESC_HAS_NEXT);
2682 }
2683 }
2684 else {
2685 if (orderByComparator.isAscending() ^ previous) {
2686 query.append(ORDER_BY_ASC);
2687 }
2688 else {
2689 query.append(ORDER_BY_DESC);
2690 }
2691 }
2692 }
2693 }
2694 else {
2695 if (getDB().isSupportsInlineDistinct()) {
2696 query.append(LayoutSetPrototypeModelImpl.ORDER_BY_JPQL);
2697 }
2698 else {
2699 query.append(LayoutSetPrototypeModelImpl.ORDER_BY_SQL);
2700 }
2701 }
2702
2703 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2704 LayoutSetPrototype.class.getName(),
2705 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
2706
2707 SQLQuery q = session.createSynchronizedSQLQuery(sql);
2708
2709 q.setFirstResult(0);
2710 q.setMaxResults(2);
2711
2712 if (getDB().isSupportsInlineDistinct()) {
2713 q.addEntity(_FILTER_ENTITY_ALIAS, LayoutSetPrototypeImpl.class);
2714 }
2715 else {
2716 q.addEntity(_FILTER_ENTITY_TABLE, LayoutSetPrototypeImpl.class);
2717 }
2718
2719 QueryPos qPos = QueryPos.getInstance(q);
2720
2721 qPos.add(companyId);
2722
2723 if (orderByComparator != null) {
2724 Object[] values = orderByComparator.getOrderByConditionValues(layoutSetPrototype);
2725
2726 for (Object value : values) {
2727 qPos.add(value);
2728 }
2729 }
2730
2731 List<LayoutSetPrototype> list = q.list();
2732
2733 if (list.size() == 2) {
2734 return list.get(1);
2735 }
2736 else {
2737 return null;
2738 }
2739 }
2740
2741
2746 @Override
2747 public void removeByCompanyId(long companyId) {
2748 for (LayoutSetPrototype layoutSetPrototype : findByCompanyId(
2749 companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
2750 remove(layoutSetPrototype);
2751 }
2752 }
2753
2754
2760 @Override
2761 public int countByCompanyId(long companyId) {
2762 FinderPath finderPath = FINDER_PATH_COUNT_BY_COMPANYID;
2763
2764 Object[] finderArgs = new Object[] { companyId };
2765
2766 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
2767 this);
2768
2769 if (count == null) {
2770 StringBundler query = new StringBundler(2);
2771
2772 query.append(_SQL_COUNT_LAYOUTSETPROTOTYPE_WHERE);
2773
2774 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2775
2776 String sql = query.toString();
2777
2778 Session session = null;
2779
2780 try {
2781 session = openSession();
2782
2783 Query q = session.createQuery(sql);
2784
2785 QueryPos qPos = QueryPos.getInstance(q);
2786
2787 qPos.add(companyId);
2788
2789 count = (Long)q.uniqueResult();
2790
2791 FinderCacheUtil.putResult(finderPath, finderArgs, count);
2792 }
2793 catch (Exception e) {
2794 FinderCacheUtil.removeResult(finderPath, finderArgs);
2795
2796 throw processException(e);
2797 }
2798 finally {
2799 closeSession(session);
2800 }
2801 }
2802
2803 return count.intValue();
2804 }
2805
2806
2812 @Override
2813 public int filterCountByCompanyId(long companyId) {
2814 if (!InlineSQLHelperUtil.isEnabled()) {
2815 return countByCompanyId(companyId);
2816 }
2817
2818 StringBundler query = new StringBundler(2);
2819
2820 query.append(_FILTER_SQL_COUNT_LAYOUTSETPROTOTYPE_WHERE);
2821
2822 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2823
2824 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2825 LayoutSetPrototype.class.getName(),
2826 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
2827
2828 Session session = null;
2829
2830 try {
2831 session = openSession();
2832
2833 SQLQuery q = session.createSynchronizedSQLQuery(sql);
2834
2835 q.addScalar(COUNT_COLUMN_NAME,
2836 com.liferay.portal.kernel.dao.orm.Type.LONG);
2837
2838 QueryPos qPos = QueryPos.getInstance(q);
2839
2840 qPos.add(companyId);
2841
2842 Long count = (Long)q.uniqueResult();
2843
2844 return count.intValue();
2845 }
2846 catch (Exception e) {
2847 throw processException(e);
2848 }
2849 finally {
2850 closeSession(session);
2851 }
2852 }
2853
2854 private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "layoutSetPrototype.companyId = ?";
2855 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_A = new FinderPath(LayoutSetPrototypeModelImpl.ENTITY_CACHE_ENABLED,
2856 LayoutSetPrototypeModelImpl.FINDER_CACHE_ENABLED,
2857 LayoutSetPrototypeImpl.class,
2858 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_A",
2859 new String[] {
2860 Long.class.getName(), Boolean.class.getName(),
2861
2862 Integer.class.getName(), Integer.class.getName(),
2863 OrderByComparator.class.getName()
2864 });
2865 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_A = new FinderPath(LayoutSetPrototypeModelImpl.ENTITY_CACHE_ENABLED,
2866 LayoutSetPrototypeModelImpl.FINDER_CACHE_ENABLED,
2867 LayoutSetPrototypeImpl.class,
2868 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_A",
2869 new String[] { Long.class.getName(), Boolean.class.getName() },
2870 LayoutSetPrototypeModelImpl.COMPANYID_COLUMN_BITMASK |
2871 LayoutSetPrototypeModelImpl.ACTIVE_COLUMN_BITMASK);
2872 public static final FinderPath FINDER_PATH_COUNT_BY_C_A = new FinderPath(LayoutSetPrototypeModelImpl.ENTITY_CACHE_ENABLED,
2873 LayoutSetPrototypeModelImpl.FINDER_CACHE_ENABLED, Long.class,
2874 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_A",
2875 new String[] { Long.class.getName(), Boolean.class.getName() });
2876
2877
2884 @Override
2885 public List<LayoutSetPrototype> findByC_A(long companyId, boolean active) {
2886 return findByC_A(companyId, active, QueryUtil.ALL_POS,
2887 QueryUtil.ALL_POS, null);
2888 }
2889
2890
2903 @Override
2904 public List<LayoutSetPrototype> findByC_A(long companyId, boolean active,
2905 int start, int end) {
2906 return findByC_A(companyId, active, start, end, null);
2907 }
2908
2909
2923 @Override
2924 public List<LayoutSetPrototype> findByC_A(long companyId, boolean active,
2925 int start, int end,
2926 OrderByComparator<LayoutSetPrototype> orderByComparator) {
2927 boolean pagination = true;
2928 FinderPath finderPath = null;
2929 Object[] finderArgs = null;
2930
2931 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2932 (orderByComparator == null)) {
2933 pagination = false;
2934 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_A;
2935 finderArgs = new Object[] { companyId, active };
2936 }
2937 else {
2938 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_A;
2939 finderArgs = new Object[] {
2940 companyId, active,
2941
2942 start, end, orderByComparator
2943 };
2944 }
2945
2946 List<LayoutSetPrototype> list = (List<LayoutSetPrototype>)FinderCacheUtil.getResult(finderPath,
2947 finderArgs, this);
2948
2949 if ((list != null) && !list.isEmpty()) {
2950 for (LayoutSetPrototype layoutSetPrototype : list) {
2951 if ((companyId != layoutSetPrototype.getCompanyId()) ||
2952 (active != layoutSetPrototype.getActive())) {
2953 list = null;
2954
2955 break;
2956 }
2957 }
2958 }
2959
2960 if (list == null) {
2961 StringBundler query = null;
2962
2963 if (orderByComparator != null) {
2964 query = new StringBundler(4 +
2965 (orderByComparator.getOrderByFields().length * 3));
2966 }
2967 else {
2968 query = new StringBundler(4);
2969 }
2970
2971 query.append(_SQL_SELECT_LAYOUTSETPROTOTYPE_WHERE);
2972
2973 query.append(_FINDER_COLUMN_C_A_COMPANYID_2);
2974
2975 query.append(_FINDER_COLUMN_C_A_ACTIVE_2);
2976
2977 if (orderByComparator != null) {
2978 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2979 orderByComparator);
2980 }
2981 else
2982 if (pagination) {
2983 query.append(LayoutSetPrototypeModelImpl.ORDER_BY_JPQL);
2984 }
2985
2986 String sql = query.toString();
2987
2988 Session session = null;
2989
2990 try {
2991 session = openSession();
2992
2993 Query q = session.createQuery(sql);
2994
2995 QueryPos qPos = QueryPos.getInstance(q);
2996
2997 qPos.add(companyId);
2998
2999 qPos.add(active);
3000
3001 if (!pagination) {
3002 list = (List<LayoutSetPrototype>)QueryUtil.list(q,
3003 getDialect(), start, end, false);
3004
3005 Collections.sort(list);
3006
3007 list = Collections.unmodifiableList(list);
3008 }
3009 else {
3010 list = (List<LayoutSetPrototype>)QueryUtil.list(q,
3011 getDialect(), start, end);
3012 }
3013
3014 cacheResult(list);
3015
3016 FinderCacheUtil.putResult(finderPath, finderArgs, list);
3017 }
3018 catch (Exception e) {
3019 FinderCacheUtil.removeResult(finderPath, finderArgs);
3020
3021 throw processException(e);
3022 }
3023 finally {
3024 closeSession(session);
3025 }
3026 }
3027
3028 return list;
3029 }
3030
3031
3040 @Override
3041 public LayoutSetPrototype findByC_A_First(long companyId, boolean active,
3042 OrderByComparator<LayoutSetPrototype> orderByComparator)
3043 throws NoSuchLayoutSetPrototypeException {
3044 LayoutSetPrototype layoutSetPrototype = fetchByC_A_First(companyId,
3045 active, orderByComparator);
3046
3047 if (layoutSetPrototype != null) {
3048 return layoutSetPrototype;
3049 }
3050
3051 StringBundler msg = new StringBundler(6);
3052
3053 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3054
3055 msg.append("companyId=");
3056 msg.append(companyId);
3057
3058 msg.append(", active=");
3059 msg.append(active);
3060
3061 msg.append(StringPool.CLOSE_CURLY_BRACE);
3062
3063 throw new NoSuchLayoutSetPrototypeException(msg.toString());
3064 }
3065
3066
3074 @Override
3075 public LayoutSetPrototype fetchByC_A_First(long companyId, boolean active,
3076 OrderByComparator<LayoutSetPrototype> orderByComparator) {
3077 List<LayoutSetPrototype> list = findByC_A(companyId, active, 0, 1,
3078 orderByComparator);
3079
3080 if (!list.isEmpty()) {
3081 return list.get(0);
3082 }
3083
3084 return null;
3085 }
3086
3087
3096 @Override
3097 public LayoutSetPrototype findByC_A_Last(long companyId, boolean active,
3098 OrderByComparator<LayoutSetPrototype> orderByComparator)
3099 throws NoSuchLayoutSetPrototypeException {
3100 LayoutSetPrototype layoutSetPrototype = fetchByC_A_Last(companyId,
3101 active, orderByComparator);
3102
3103 if (layoutSetPrototype != null) {
3104 return layoutSetPrototype;
3105 }
3106
3107 StringBundler msg = new StringBundler(6);
3108
3109 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3110
3111 msg.append("companyId=");
3112 msg.append(companyId);
3113
3114 msg.append(", active=");
3115 msg.append(active);
3116
3117 msg.append(StringPool.CLOSE_CURLY_BRACE);
3118
3119 throw new NoSuchLayoutSetPrototypeException(msg.toString());
3120 }
3121
3122
3130 @Override
3131 public LayoutSetPrototype fetchByC_A_Last(long companyId, boolean active,
3132 OrderByComparator<LayoutSetPrototype> orderByComparator) {
3133 int count = countByC_A(companyId, active);
3134
3135 if (count == 0) {
3136 return null;
3137 }
3138
3139 List<LayoutSetPrototype> list = findByC_A(companyId, active, count - 1,
3140 count, orderByComparator);
3141
3142 if (!list.isEmpty()) {
3143 return list.get(0);
3144 }
3145
3146 return null;
3147 }
3148
3149
3159 @Override
3160 public LayoutSetPrototype[] findByC_A_PrevAndNext(
3161 long layoutSetPrototypeId, long companyId, boolean active,
3162 OrderByComparator<LayoutSetPrototype> orderByComparator)
3163 throws NoSuchLayoutSetPrototypeException {
3164 LayoutSetPrototype layoutSetPrototype = findByPrimaryKey(layoutSetPrototypeId);
3165
3166 Session session = null;
3167
3168 try {
3169 session = openSession();
3170
3171 LayoutSetPrototype[] array = new LayoutSetPrototypeImpl[3];
3172
3173 array[0] = getByC_A_PrevAndNext(session, layoutSetPrototype,
3174 companyId, active, orderByComparator, true);
3175
3176 array[1] = layoutSetPrototype;
3177
3178 array[2] = getByC_A_PrevAndNext(session, layoutSetPrototype,
3179 companyId, active, orderByComparator, false);
3180
3181 return array;
3182 }
3183 catch (Exception e) {
3184 throw processException(e);
3185 }
3186 finally {
3187 closeSession(session);
3188 }
3189 }
3190
3191 protected LayoutSetPrototype getByC_A_PrevAndNext(Session session,
3192 LayoutSetPrototype layoutSetPrototype, long companyId, boolean active,
3193 OrderByComparator<LayoutSetPrototype> orderByComparator,
3194 boolean previous) {
3195 StringBundler query = null;
3196
3197 if (orderByComparator != null) {
3198 query = new StringBundler(6 +
3199 (orderByComparator.getOrderByFields().length * 6));
3200 }
3201 else {
3202 query = new StringBundler(3);
3203 }
3204
3205 query.append(_SQL_SELECT_LAYOUTSETPROTOTYPE_WHERE);
3206
3207 query.append(_FINDER_COLUMN_C_A_COMPANYID_2);
3208
3209 query.append(_FINDER_COLUMN_C_A_ACTIVE_2);
3210
3211 if (orderByComparator != null) {
3212 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3213
3214 if (orderByConditionFields.length > 0) {
3215 query.append(WHERE_AND);
3216 }
3217
3218 for (int i = 0; i < orderByConditionFields.length; i++) {
3219 query.append(_ORDER_BY_ENTITY_ALIAS);
3220 query.append(orderByConditionFields[i]);
3221
3222 if ((i + 1) < orderByConditionFields.length) {
3223 if (orderByComparator.isAscending() ^ previous) {
3224 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3225 }
3226 else {
3227 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3228 }
3229 }
3230 else {
3231 if (orderByComparator.isAscending() ^ previous) {
3232 query.append(WHERE_GREATER_THAN);
3233 }
3234 else {
3235 query.append(WHERE_LESSER_THAN);
3236 }
3237 }
3238 }
3239
3240 query.append(ORDER_BY_CLAUSE);
3241
3242 String[] orderByFields = orderByComparator.getOrderByFields();
3243
3244 for (int i = 0; i < orderByFields.length; i++) {
3245 query.append(_ORDER_BY_ENTITY_ALIAS);
3246 query.append(orderByFields[i]);
3247
3248 if ((i + 1) < orderByFields.length) {
3249 if (orderByComparator.isAscending() ^ previous) {
3250 query.append(ORDER_BY_ASC_HAS_NEXT);
3251 }
3252 else {
3253 query.append(ORDER_BY_DESC_HAS_NEXT);
3254 }
3255 }
3256 else {
3257 if (orderByComparator.isAscending() ^ previous) {
3258 query.append(ORDER_BY_ASC);
3259 }
3260 else {
3261 query.append(ORDER_BY_DESC);
3262 }
3263 }
3264 }
3265 }
3266 else {
3267 query.append(LayoutSetPrototypeModelImpl.ORDER_BY_JPQL);
3268 }
3269
3270 String sql = query.toString();
3271
3272 Query q = session.createQuery(sql);
3273
3274 q.setFirstResult(0);
3275 q.setMaxResults(2);
3276
3277 QueryPos qPos = QueryPos.getInstance(q);
3278
3279 qPos.add(companyId);
3280
3281 qPos.add(active);
3282
3283 if (orderByComparator != null) {
3284 Object[] values = orderByComparator.getOrderByConditionValues(layoutSetPrototype);
3285
3286 for (Object value : values) {
3287 qPos.add(value);
3288 }
3289 }
3290
3291 List<LayoutSetPrototype> list = q.list();
3292
3293 if (list.size() == 2) {
3294 return list.get(1);
3295 }
3296 else {
3297 return null;
3298 }
3299 }
3300
3301
3308 @Override
3309 public List<LayoutSetPrototype> filterFindByC_A(long companyId,
3310 boolean active) {
3311 return filterFindByC_A(companyId, active, QueryUtil.ALL_POS,
3312 QueryUtil.ALL_POS, null);
3313 }
3314
3315
3328 @Override
3329 public List<LayoutSetPrototype> filterFindByC_A(long companyId,
3330 boolean active, int start, int end) {
3331 return filterFindByC_A(companyId, active, start, end, null);
3332 }
3333
3334
3348 @Override
3349 public List<LayoutSetPrototype> filterFindByC_A(long companyId,
3350 boolean active, int start, int end,
3351 OrderByComparator<LayoutSetPrototype> orderByComparator) {
3352 if (!InlineSQLHelperUtil.isEnabled()) {
3353 return findByC_A(companyId, active, start, end, orderByComparator);
3354 }
3355
3356 StringBundler query = null;
3357
3358 if (orderByComparator != null) {
3359 query = new StringBundler(4 +
3360 (orderByComparator.getOrderByFields().length * 3));
3361 }
3362 else {
3363 query = new StringBundler(4);
3364 }
3365
3366 if (getDB().isSupportsInlineDistinct()) {
3367 query.append(_FILTER_SQL_SELECT_LAYOUTSETPROTOTYPE_WHERE);
3368 }
3369 else {
3370 query.append(_FILTER_SQL_SELECT_LAYOUTSETPROTOTYPE_NO_INLINE_DISTINCT_WHERE_1);
3371 }
3372
3373 query.append(_FINDER_COLUMN_C_A_COMPANYID_2);
3374
3375 query.append(_FINDER_COLUMN_C_A_ACTIVE_2_SQL);
3376
3377 if (!getDB().isSupportsInlineDistinct()) {
3378 query.append(_FILTER_SQL_SELECT_LAYOUTSETPROTOTYPE_NO_INLINE_DISTINCT_WHERE_2);
3379 }
3380
3381 if (orderByComparator != null) {
3382 if (getDB().isSupportsInlineDistinct()) {
3383 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3384 orderByComparator, true);
3385 }
3386 else {
3387 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
3388 orderByComparator, true);
3389 }
3390 }
3391 else {
3392 if (getDB().isSupportsInlineDistinct()) {
3393 query.append(LayoutSetPrototypeModelImpl.ORDER_BY_JPQL);
3394 }
3395 else {
3396 query.append(LayoutSetPrototypeModelImpl.ORDER_BY_SQL);
3397 }
3398 }
3399
3400 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3401 LayoutSetPrototype.class.getName(),
3402 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
3403
3404 Session session = null;
3405
3406 try {
3407 session = openSession();
3408
3409 SQLQuery q = session.createSynchronizedSQLQuery(sql);
3410
3411 if (getDB().isSupportsInlineDistinct()) {
3412 q.addEntity(_FILTER_ENTITY_ALIAS, LayoutSetPrototypeImpl.class);
3413 }
3414 else {
3415 q.addEntity(_FILTER_ENTITY_TABLE, LayoutSetPrototypeImpl.class);
3416 }
3417
3418 QueryPos qPos = QueryPos.getInstance(q);
3419
3420 qPos.add(companyId);
3421
3422 qPos.add(active);
3423
3424 return (List<LayoutSetPrototype>)QueryUtil.list(q, getDialect(),
3425 start, end);
3426 }
3427 catch (Exception e) {
3428 throw processException(e);
3429 }
3430 finally {
3431 closeSession(session);
3432 }
3433 }
3434
3435
3445 @Override
3446 public LayoutSetPrototype[] filterFindByC_A_PrevAndNext(
3447 long layoutSetPrototypeId, long companyId, boolean active,
3448 OrderByComparator<LayoutSetPrototype> orderByComparator)
3449 throws NoSuchLayoutSetPrototypeException {
3450 if (!InlineSQLHelperUtil.isEnabled()) {
3451 return findByC_A_PrevAndNext(layoutSetPrototypeId, companyId,
3452 active, orderByComparator);
3453 }
3454
3455 LayoutSetPrototype layoutSetPrototype = findByPrimaryKey(layoutSetPrototypeId);
3456
3457 Session session = null;
3458
3459 try {
3460 session = openSession();
3461
3462 LayoutSetPrototype[] array = new LayoutSetPrototypeImpl[3];
3463
3464 array[0] = filterGetByC_A_PrevAndNext(session, layoutSetPrototype,
3465 companyId, active, orderByComparator, true);
3466
3467 array[1] = layoutSetPrototype;
3468
3469 array[2] = filterGetByC_A_PrevAndNext(session, layoutSetPrototype,
3470 companyId, active, orderByComparator, false);
3471
3472 return array;
3473 }
3474 catch (Exception e) {
3475 throw processException(e);
3476 }
3477 finally {
3478 closeSession(session);
3479 }
3480 }
3481
3482 protected LayoutSetPrototype filterGetByC_A_PrevAndNext(Session session,
3483 LayoutSetPrototype layoutSetPrototype, long companyId, boolean active,
3484 OrderByComparator<LayoutSetPrototype> orderByComparator,
3485 boolean previous) {
3486 StringBundler query = null;
3487
3488 if (orderByComparator != null) {
3489 query = new StringBundler(6 +
3490 (orderByComparator.getOrderByFields().length * 6));
3491 }
3492 else {
3493 query = new StringBundler(3);
3494 }
3495
3496 if (getDB().isSupportsInlineDistinct()) {
3497 query.append(_FILTER_SQL_SELECT_LAYOUTSETPROTOTYPE_WHERE);
3498 }
3499 else {
3500 query.append(_FILTER_SQL_SELECT_LAYOUTSETPROTOTYPE_NO_INLINE_DISTINCT_WHERE_1);
3501 }
3502
3503 query.append(_FINDER_COLUMN_C_A_COMPANYID_2);
3504
3505 query.append(_FINDER_COLUMN_C_A_ACTIVE_2_SQL);
3506
3507 if (!getDB().isSupportsInlineDistinct()) {
3508 query.append(_FILTER_SQL_SELECT_LAYOUTSETPROTOTYPE_NO_INLINE_DISTINCT_WHERE_2);
3509 }
3510
3511 if (orderByComparator != null) {
3512 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3513
3514 if (orderByConditionFields.length > 0) {
3515 query.append(WHERE_AND);
3516 }
3517
3518 for (int i = 0; i < orderByConditionFields.length; i++) {
3519 if (getDB().isSupportsInlineDistinct()) {
3520 query.append(_ORDER_BY_ENTITY_ALIAS);
3521 }
3522 else {
3523 query.append(_ORDER_BY_ENTITY_TABLE);
3524 }
3525
3526 query.append(orderByConditionFields[i]);
3527
3528 if ((i + 1) < orderByConditionFields.length) {
3529 if (orderByComparator.isAscending() ^ previous) {
3530 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3531 }
3532 else {
3533 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3534 }
3535 }
3536 else {
3537 if (orderByComparator.isAscending() ^ previous) {
3538 query.append(WHERE_GREATER_THAN);
3539 }
3540 else {
3541 query.append(WHERE_LESSER_THAN);
3542 }
3543 }
3544 }
3545
3546 query.append(ORDER_BY_CLAUSE);
3547
3548 String[] orderByFields = orderByComparator.getOrderByFields();
3549
3550 for (int i = 0; i < orderByFields.length; i++) {
3551 if (getDB().isSupportsInlineDistinct()) {
3552 query.append(_ORDER_BY_ENTITY_ALIAS);
3553 }
3554 else {
3555 query.append(_ORDER_BY_ENTITY_TABLE);
3556 }
3557
3558 query.append(orderByFields[i]);
3559
3560 if ((i + 1) < orderByFields.length) {
3561 if (orderByComparator.isAscending() ^ previous) {
3562 query.append(ORDER_BY_ASC_HAS_NEXT);
3563 }
3564 else {
3565 query.append(ORDER_BY_DESC_HAS_NEXT);
3566 }
3567 }
3568 else {
3569 if (orderByComparator.isAscending() ^ previous) {
3570 query.append(ORDER_BY_ASC);
3571 }
3572 else {
3573 query.append(ORDER_BY_DESC);
3574 }
3575 }
3576 }
3577 }
3578 else {
3579 if (getDB().isSupportsInlineDistinct()) {
3580 query.append(LayoutSetPrototypeModelImpl.ORDER_BY_JPQL);
3581 }
3582 else {
3583 query.append(LayoutSetPrototypeModelImpl.ORDER_BY_SQL);
3584 }
3585 }
3586
3587 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3588 LayoutSetPrototype.class.getName(),
3589 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
3590
3591 SQLQuery q = session.createSynchronizedSQLQuery(sql);
3592
3593 q.setFirstResult(0);
3594 q.setMaxResults(2);
3595
3596 if (getDB().isSupportsInlineDistinct()) {
3597 q.addEntity(_FILTER_ENTITY_ALIAS, LayoutSetPrototypeImpl.class);
3598 }
3599 else {
3600 q.addEntity(_FILTER_ENTITY_TABLE, LayoutSetPrototypeImpl.class);
3601 }
3602
3603 QueryPos qPos = QueryPos.getInstance(q);
3604
3605 qPos.add(companyId);
3606
3607 qPos.add(active);
3608
3609 if (orderByComparator != null) {
3610 Object[] values = orderByComparator.getOrderByConditionValues(layoutSetPrototype);
3611
3612 for (Object value : values) {
3613 qPos.add(value);
3614 }
3615 }
3616
3617 List<LayoutSetPrototype> list = q.list();
3618
3619 if (list.size() == 2) {
3620 return list.get(1);
3621 }
3622 else {
3623 return null;
3624 }
3625 }
3626
3627
3633 @Override
3634 public void removeByC_A(long companyId, boolean active) {
3635 for (LayoutSetPrototype layoutSetPrototype : findByC_A(companyId,
3636 active, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
3637 remove(layoutSetPrototype);
3638 }
3639 }
3640
3641
3648 @Override
3649 public int countByC_A(long companyId, boolean active) {
3650 FinderPath finderPath = FINDER_PATH_COUNT_BY_C_A;
3651
3652 Object[] finderArgs = new Object[] { companyId, active };
3653
3654 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
3655 this);
3656
3657 if (count == null) {
3658 StringBundler query = new StringBundler(3);
3659
3660 query.append(_SQL_COUNT_LAYOUTSETPROTOTYPE_WHERE);
3661
3662 query.append(_FINDER_COLUMN_C_A_COMPANYID_2);
3663
3664 query.append(_FINDER_COLUMN_C_A_ACTIVE_2);
3665
3666 String sql = query.toString();
3667
3668 Session session = null;
3669
3670 try {
3671 session = openSession();
3672
3673 Query q = session.createQuery(sql);
3674
3675 QueryPos qPos = QueryPos.getInstance(q);
3676
3677 qPos.add(companyId);
3678
3679 qPos.add(active);
3680
3681 count = (Long)q.uniqueResult();
3682
3683 FinderCacheUtil.putResult(finderPath, finderArgs, count);
3684 }
3685 catch (Exception e) {
3686 FinderCacheUtil.removeResult(finderPath, finderArgs);
3687
3688 throw processException(e);
3689 }
3690 finally {
3691 closeSession(session);
3692 }
3693 }
3694
3695 return count.intValue();
3696 }
3697
3698
3705 @Override
3706 public int filterCountByC_A(long companyId, boolean active) {
3707 if (!InlineSQLHelperUtil.isEnabled()) {
3708 return countByC_A(companyId, active);
3709 }
3710
3711 StringBundler query = new StringBundler(3);
3712
3713 query.append(_FILTER_SQL_COUNT_LAYOUTSETPROTOTYPE_WHERE);
3714
3715 query.append(_FINDER_COLUMN_C_A_COMPANYID_2);
3716
3717 query.append(_FINDER_COLUMN_C_A_ACTIVE_2_SQL);
3718
3719 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3720 LayoutSetPrototype.class.getName(),
3721 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
3722
3723 Session session = null;
3724
3725 try {
3726 session = openSession();
3727
3728 SQLQuery q = session.createSynchronizedSQLQuery(sql);
3729
3730 q.addScalar(COUNT_COLUMN_NAME,
3731 com.liferay.portal.kernel.dao.orm.Type.LONG);
3732
3733 QueryPos qPos = QueryPos.getInstance(q);
3734
3735 qPos.add(companyId);
3736
3737 qPos.add(active);
3738
3739 Long count = (Long)q.uniqueResult();
3740
3741 return count.intValue();
3742 }
3743 catch (Exception e) {
3744 throw processException(e);
3745 }
3746 finally {
3747 closeSession(session);
3748 }
3749 }
3750
3751 private static final String _FINDER_COLUMN_C_A_COMPANYID_2 = "layoutSetPrototype.companyId = ? AND ";
3752 private static final String _FINDER_COLUMN_C_A_ACTIVE_2 = "layoutSetPrototype.active = ?";
3753 private static final String _FINDER_COLUMN_C_A_ACTIVE_2_SQL = "layoutSetPrototype.active_ = ?";
3754
3755 public LayoutSetPrototypePersistenceImpl() {
3756 setModelClass(LayoutSetPrototype.class);
3757 }
3758
3759
3764 @Override
3765 public void cacheResult(LayoutSetPrototype layoutSetPrototype) {
3766 EntityCacheUtil.putResult(LayoutSetPrototypeModelImpl.ENTITY_CACHE_ENABLED,
3767 LayoutSetPrototypeImpl.class, layoutSetPrototype.getPrimaryKey(),
3768 layoutSetPrototype);
3769
3770 layoutSetPrototype.resetOriginalValues();
3771 }
3772
3773
3778 @Override
3779 public void cacheResult(List<LayoutSetPrototype> layoutSetPrototypes) {
3780 for (LayoutSetPrototype layoutSetPrototype : layoutSetPrototypes) {
3781 if (EntityCacheUtil.getResult(
3782 LayoutSetPrototypeModelImpl.ENTITY_CACHE_ENABLED,
3783 LayoutSetPrototypeImpl.class,
3784 layoutSetPrototype.getPrimaryKey()) == null) {
3785 cacheResult(layoutSetPrototype);
3786 }
3787 else {
3788 layoutSetPrototype.resetOriginalValues();
3789 }
3790 }
3791 }
3792
3793
3800 @Override
3801 public void clearCache() {
3802 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
3803 CacheRegistryUtil.clear(LayoutSetPrototypeImpl.class.getName());
3804 }
3805
3806 EntityCacheUtil.clearCache(LayoutSetPrototypeImpl.class);
3807
3808 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
3809 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
3810 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
3811 }
3812
3813
3820 @Override
3821 public void clearCache(LayoutSetPrototype layoutSetPrototype) {
3822 EntityCacheUtil.removeResult(LayoutSetPrototypeModelImpl.ENTITY_CACHE_ENABLED,
3823 LayoutSetPrototypeImpl.class, layoutSetPrototype.getPrimaryKey());
3824
3825 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
3826 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
3827 }
3828
3829 @Override
3830 public void clearCache(List<LayoutSetPrototype> layoutSetPrototypes) {
3831 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
3832 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
3833
3834 for (LayoutSetPrototype layoutSetPrototype : layoutSetPrototypes) {
3835 EntityCacheUtil.removeResult(LayoutSetPrototypeModelImpl.ENTITY_CACHE_ENABLED,
3836 LayoutSetPrototypeImpl.class, layoutSetPrototype.getPrimaryKey());
3837 }
3838 }
3839
3840
3846 @Override
3847 public LayoutSetPrototype create(long layoutSetPrototypeId) {
3848 LayoutSetPrototype layoutSetPrototype = new LayoutSetPrototypeImpl();
3849
3850 layoutSetPrototype.setNew(true);
3851 layoutSetPrototype.setPrimaryKey(layoutSetPrototypeId);
3852
3853 String uuid = PortalUUIDUtil.generate();
3854
3855 layoutSetPrototype.setUuid(uuid);
3856
3857 return layoutSetPrototype;
3858 }
3859
3860
3867 @Override
3868 public LayoutSetPrototype remove(long layoutSetPrototypeId)
3869 throws NoSuchLayoutSetPrototypeException {
3870 return remove((Serializable)layoutSetPrototypeId);
3871 }
3872
3873
3880 @Override
3881 public LayoutSetPrototype remove(Serializable primaryKey)
3882 throws NoSuchLayoutSetPrototypeException {
3883 Session session = null;
3884
3885 try {
3886 session = openSession();
3887
3888 LayoutSetPrototype layoutSetPrototype = (LayoutSetPrototype)session.get(LayoutSetPrototypeImpl.class,
3889 primaryKey);
3890
3891 if (layoutSetPrototype == null) {
3892 if (_log.isWarnEnabled()) {
3893 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
3894 }
3895
3896 throw new NoSuchLayoutSetPrototypeException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
3897 primaryKey);
3898 }
3899
3900 return remove(layoutSetPrototype);
3901 }
3902 catch (NoSuchLayoutSetPrototypeException nsee) {
3903 throw nsee;
3904 }
3905 catch (Exception e) {
3906 throw processException(e);
3907 }
3908 finally {
3909 closeSession(session);
3910 }
3911 }
3912
3913 @Override
3914 protected LayoutSetPrototype removeImpl(
3915 LayoutSetPrototype layoutSetPrototype) {
3916 layoutSetPrototype = toUnwrappedModel(layoutSetPrototype);
3917
3918 Session session = null;
3919
3920 try {
3921 session = openSession();
3922
3923 if (!session.contains(layoutSetPrototype)) {
3924 layoutSetPrototype = (LayoutSetPrototype)session.get(LayoutSetPrototypeImpl.class,
3925 layoutSetPrototype.getPrimaryKeyObj());
3926 }
3927
3928 if (layoutSetPrototype != null) {
3929 session.delete(layoutSetPrototype);
3930 }
3931 }
3932 catch (Exception e) {
3933 throw processException(e);
3934 }
3935 finally {
3936 closeSession(session);
3937 }
3938
3939 if (layoutSetPrototype != null) {
3940 clearCache(layoutSetPrototype);
3941 }
3942
3943 return layoutSetPrototype;
3944 }
3945
3946 @Override
3947 public LayoutSetPrototype updateImpl(
3948 com.liferay.portal.model.LayoutSetPrototype layoutSetPrototype) {
3949 layoutSetPrototype = toUnwrappedModel(layoutSetPrototype);
3950
3951 boolean isNew = layoutSetPrototype.isNew();
3952
3953 LayoutSetPrototypeModelImpl layoutSetPrototypeModelImpl = (LayoutSetPrototypeModelImpl)layoutSetPrototype;
3954
3955 if (Validator.isNull(layoutSetPrototype.getUuid())) {
3956 String uuid = PortalUUIDUtil.generate();
3957
3958 layoutSetPrototype.setUuid(uuid);
3959 }
3960
3961 Session session = null;
3962
3963 try {
3964 session = openSession();
3965
3966 if (layoutSetPrototype.isNew()) {
3967 session.save(layoutSetPrototype);
3968
3969 layoutSetPrototype.setNew(false);
3970 }
3971 else {
3972 session.merge(layoutSetPrototype);
3973 }
3974 }
3975 catch (Exception e) {
3976 throw processException(e);
3977 }
3978 finally {
3979 closeSession(session);
3980 }
3981
3982 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
3983
3984 if (isNew || !LayoutSetPrototypeModelImpl.COLUMN_BITMASK_ENABLED) {
3985 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
3986 }
3987
3988 else {
3989 if ((layoutSetPrototypeModelImpl.getColumnBitmask() &
3990 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
3991 Object[] args = new Object[] {
3992 layoutSetPrototypeModelImpl.getOriginalUuid()
3993 };
3994
3995 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
3996 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
3997 args);
3998
3999 args = new Object[] { layoutSetPrototypeModelImpl.getUuid() };
4000
4001 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
4002 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
4003 args);
4004 }
4005
4006 if ((layoutSetPrototypeModelImpl.getColumnBitmask() &
4007 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C.getColumnBitmask()) != 0) {
4008 Object[] args = new Object[] {
4009 layoutSetPrototypeModelImpl.getOriginalUuid(),
4010 layoutSetPrototypeModelImpl.getOriginalCompanyId()
4011 };
4012
4013 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
4014 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
4015 args);
4016
4017 args = new Object[] {
4018 layoutSetPrototypeModelImpl.getUuid(),
4019 layoutSetPrototypeModelImpl.getCompanyId()
4020 };
4021
4022 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
4023 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
4024 args);
4025 }
4026
4027 if ((layoutSetPrototypeModelImpl.getColumnBitmask() &
4028 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
4029 Object[] args = new Object[] {
4030 layoutSetPrototypeModelImpl.getOriginalCompanyId()
4031 };
4032
4033 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
4034 args);
4035 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
4036 args);
4037
4038 args = new Object[] { layoutSetPrototypeModelImpl.getCompanyId() };
4039
4040 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
4041 args);
4042 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
4043 args);
4044 }
4045
4046 if ((layoutSetPrototypeModelImpl.getColumnBitmask() &
4047 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_A.getColumnBitmask()) != 0) {
4048 Object[] args = new Object[] {
4049 layoutSetPrototypeModelImpl.getOriginalCompanyId(),
4050 layoutSetPrototypeModelImpl.getOriginalActive()
4051 };
4052
4053 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_A, args);
4054 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_A,
4055 args);
4056
4057 args = new Object[] {
4058 layoutSetPrototypeModelImpl.getCompanyId(),
4059 layoutSetPrototypeModelImpl.getActive()
4060 };
4061
4062 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_A, args);
4063 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_A,
4064 args);
4065 }
4066 }
4067
4068 EntityCacheUtil.putResult(LayoutSetPrototypeModelImpl.ENTITY_CACHE_ENABLED,
4069 LayoutSetPrototypeImpl.class, layoutSetPrototype.getPrimaryKey(),
4070 layoutSetPrototype, false);
4071
4072 layoutSetPrototype.resetOriginalValues();
4073
4074 return layoutSetPrototype;
4075 }
4076
4077 protected LayoutSetPrototype toUnwrappedModel(
4078 LayoutSetPrototype layoutSetPrototype) {
4079 if (layoutSetPrototype instanceof LayoutSetPrototypeImpl) {
4080 return layoutSetPrototype;
4081 }
4082
4083 LayoutSetPrototypeImpl layoutSetPrototypeImpl = new LayoutSetPrototypeImpl();
4084
4085 layoutSetPrototypeImpl.setNew(layoutSetPrototype.isNew());
4086 layoutSetPrototypeImpl.setPrimaryKey(layoutSetPrototype.getPrimaryKey());
4087
4088 layoutSetPrototypeImpl.setMvccVersion(layoutSetPrototype.getMvccVersion());
4089 layoutSetPrototypeImpl.setUuid(layoutSetPrototype.getUuid());
4090 layoutSetPrototypeImpl.setLayoutSetPrototypeId(layoutSetPrototype.getLayoutSetPrototypeId());
4091 layoutSetPrototypeImpl.setCompanyId(layoutSetPrototype.getCompanyId());
4092 layoutSetPrototypeImpl.setUserId(layoutSetPrototype.getUserId());
4093 layoutSetPrototypeImpl.setUserName(layoutSetPrototype.getUserName());
4094 layoutSetPrototypeImpl.setCreateDate(layoutSetPrototype.getCreateDate());
4095 layoutSetPrototypeImpl.setModifiedDate(layoutSetPrototype.getModifiedDate());
4096 layoutSetPrototypeImpl.setName(layoutSetPrototype.getName());
4097 layoutSetPrototypeImpl.setDescription(layoutSetPrototype.getDescription());
4098 layoutSetPrototypeImpl.setSettings(layoutSetPrototype.getSettings());
4099 layoutSetPrototypeImpl.setActive(layoutSetPrototype.isActive());
4100
4101 return layoutSetPrototypeImpl;
4102 }
4103
4104
4111 @Override
4112 public LayoutSetPrototype findByPrimaryKey(Serializable primaryKey)
4113 throws NoSuchLayoutSetPrototypeException {
4114 LayoutSetPrototype layoutSetPrototype = fetchByPrimaryKey(primaryKey);
4115
4116 if (layoutSetPrototype == null) {
4117 if (_log.isWarnEnabled()) {
4118 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
4119 }
4120
4121 throw new NoSuchLayoutSetPrototypeException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
4122 primaryKey);
4123 }
4124
4125 return layoutSetPrototype;
4126 }
4127
4128
4135 @Override
4136 public LayoutSetPrototype findByPrimaryKey(long layoutSetPrototypeId)
4137 throws NoSuchLayoutSetPrototypeException {
4138 return findByPrimaryKey((Serializable)layoutSetPrototypeId);
4139 }
4140
4141
4147 @Override
4148 public LayoutSetPrototype fetchByPrimaryKey(Serializable primaryKey) {
4149 LayoutSetPrototype layoutSetPrototype = (LayoutSetPrototype)EntityCacheUtil.getResult(LayoutSetPrototypeModelImpl.ENTITY_CACHE_ENABLED,
4150 LayoutSetPrototypeImpl.class, primaryKey);
4151
4152 if (layoutSetPrototype == _nullLayoutSetPrototype) {
4153 return null;
4154 }
4155
4156 if (layoutSetPrototype == null) {
4157 Session session = null;
4158
4159 try {
4160 session = openSession();
4161
4162 layoutSetPrototype = (LayoutSetPrototype)session.get(LayoutSetPrototypeImpl.class,
4163 primaryKey);
4164
4165 if (layoutSetPrototype != null) {
4166 cacheResult(layoutSetPrototype);
4167 }
4168 else {
4169 EntityCacheUtil.putResult(LayoutSetPrototypeModelImpl.ENTITY_CACHE_ENABLED,
4170 LayoutSetPrototypeImpl.class, primaryKey,
4171 _nullLayoutSetPrototype);
4172 }
4173 }
4174 catch (Exception e) {
4175 EntityCacheUtil.removeResult(LayoutSetPrototypeModelImpl.ENTITY_CACHE_ENABLED,
4176 LayoutSetPrototypeImpl.class, primaryKey);
4177
4178 throw processException(e);
4179 }
4180 finally {
4181 closeSession(session);
4182 }
4183 }
4184
4185 return layoutSetPrototype;
4186 }
4187
4188
4194 @Override
4195 public LayoutSetPrototype fetchByPrimaryKey(long layoutSetPrototypeId) {
4196 return fetchByPrimaryKey((Serializable)layoutSetPrototypeId);
4197 }
4198
4199 @Override
4200 public Map<Serializable, LayoutSetPrototype> fetchByPrimaryKeys(
4201 Set<Serializable> primaryKeys) {
4202 if (primaryKeys.isEmpty()) {
4203 return Collections.emptyMap();
4204 }
4205
4206 Map<Serializable, LayoutSetPrototype> map = new HashMap<Serializable, LayoutSetPrototype>();
4207
4208 if (primaryKeys.size() == 1) {
4209 Iterator<Serializable> iterator = primaryKeys.iterator();
4210
4211 Serializable primaryKey = iterator.next();
4212
4213 LayoutSetPrototype layoutSetPrototype = fetchByPrimaryKey(primaryKey);
4214
4215 if (layoutSetPrototype != null) {
4216 map.put(primaryKey, layoutSetPrototype);
4217 }
4218
4219 return map;
4220 }
4221
4222 Set<Serializable> uncachedPrimaryKeys = null;
4223
4224 for (Serializable primaryKey : primaryKeys) {
4225 LayoutSetPrototype layoutSetPrototype = (LayoutSetPrototype)EntityCacheUtil.getResult(LayoutSetPrototypeModelImpl.ENTITY_CACHE_ENABLED,
4226 LayoutSetPrototypeImpl.class, primaryKey);
4227
4228 if (layoutSetPrototype == null) {
4229 if (uncachedPrimaryKeys == null) {
4230 uncachedPrimaryKeys = new HashSet<Serializable>();
4231 }
4232
4233 uncachedPrimaryKeys.add(primaryKey);
4234 }
4235 else {
4236 map.put(primaryKey, layoutSetPrototype);
4237 }
4238 }
4239
4240 if (uncachedPrimaryKeys == null) {
4241 return map;
4242 }
4243
4244 StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) +
4245 1);
4246
4247 query.append(_SQL_SELECT_LAYOUTSETPROTOTYPE_WHERE_PKS_IN);
4248
4249 for (Serializable primaryKey : uncachedPrimaryKeys) {
4250 query.append(String.valueOf(primaryKey));
4251
4252 query.append(StringPool.COMMA);
4253 }
4254
4255 query.setIndex(query.index() - 1);
4256
4257 query.append(StringPool.CLOSE_PARENTHESIS);
4258
4259 String sql = query.toString();
4260
4261 Session session = null;
4262
4263 try {
4264 session = openSession();
4265
4266 Query q = session.createQuery(sql);
4267
4268 for (LayoutSetPrototype layoutSetPrototype : (List<LayoutSetPrototype>)q.list()) {
4269 map.put(layoutSetPrototype.getPrimaryKeyObj(),
4270 layoutSetPrototype);
4271
4272 cacheResult(layoutSetPrototype);
4273
4274 uncachedPrimaryKeys.remove(layoutSetPrototype.getPrimaryKeyObj());
4275 }
4276
4277 for (Serializable primaryKey : uncachedPrimaryKeys) {
4278 EntityCacheUtil.putResult(LayoutSetPrototypeModelImpl.ENTITY_CACHE_ENABLED,
4279 LayoutSetPrototypeImpl.class, primaryKey,
4280 _nullLayoutSetPrototype);
4281 }
4282 }
4283 catch (Exception e) {
4284 throw processException(e);
4285 }
4286 finally {
4287 closeSession(session);
4288 }
4289
4290 return map;
4291 }
4292
4293
4298 @Override
4299 public List<LayoutSetPrototype> findAll() {
4300 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
4301 }
4302
4303
4314 @Override
4315 public List<LayoutSetPrototype> findAll(int start, int end) {
4316 return findAll(start, end, null);
4317 }
4318
4319
4331 @Override
4332 public List<LayoutSetPrototype> findAll(int start, int end,
4333 OrderByComparator<LayoutSetPrototype> orderByComparator) {
4334 boolean pagination = true;
4335 FinderPath finderPath = null;
4336 Object[] finderArgs = null;
4337
4338 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4339 (orderByComparator == null)) {
4340 pagination = false;
4341 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
4342 finderArgs = FINDER_ARGS_EMPTY;
4343 }
4344 else {
4345 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
4346 finderArgs = new Object[] { start, end, orderByComparator };
4347 }
4348
4349 List<LayoutSetPrototype> list = (List<LayoutSetPrototype>)FinderCacheUtil.getResult(finderPath,
4350 finderArgs, this);
4351
4352 if (list == null) {
4353 StringBundler query = null;
4354 String sql = null;
4355
4356 if (orderByComparator != null) {
4357 query = new StringBundler(2 +
4358 (orderByComparator.getOrderByFields().length * 3));
4359
4360 query.append(_SQL_SELECT_LAYOUTSETPROTOTYPE);
4361
4362 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4363 orderByComparator);
4364
4365 sql = query.toString();
4366 }
4367 else {
4368 sql = _SQL_SELECT_LAYOUTSETPROTOTYPE;
4369
4370 if (pagination) {
4371 sql = sql.concat(LayoutSetPrototypeModelImpl.ORDER_BY_JPQL);
4372 }
4373 }
4374
4375 Session session = null;
4376
4377 try {
4378 session = openSession();
4379
4380 Query q = session.createQuery(sql);
4381
4382 if (!pagination) {
4383 list = (List<LayoutSetPrototype>)QueryUtil.list(q,
4384 getDialect(), start, end, false);
4385
4386 Collections.sort(list);
4387
4388 list = Collections.unmodifiableList(list);
4389 }
4390 else {
4391 list = (List<LayoutSetPrototype>)QueryUtil.list(q,
4392 getDialect(), start, end);
4393 }
4394
4395 cacheResult(list);
4396
4397 FinderCacheUtil.putResult(finderPath, finderArgs, list);
4398 }
4399 catch (Exception e) {
4400 FinderCacheUtil.removeResult(finderPath, finderArgs);
4401
4402 throw processException(e);
4403 }
4404 finally {
4405 closeSession(session);
4406 }
4407 }
4408
4409 return list;
4410 }
4411
4412
4416 @Override
4417 public void removeAll() {
4418 for (LayoutSetPrototype layoutSetPrototype : findAll()) {
4419 remove(layoutSetPrototype);
4420 }
4421 }
4422
4423
4428 @Override
4429 public int countAll() {
4430 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
4431 FINDER_ARGS_EMPTY, this);
4432
4433 if (count == null) {
4434 Session session = null;
4435
4436 try {
4437 session = openSession();
4438
4439 Query q = session.createQuery(_SQL_COUNT_LAYOUTSETPROTOTYPE);
4440
4441 count = (Long)q.uniqueResult();
4442
4443 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
4444 FINDER_ARGS_EMPTY, count);
4445 }
4446 catch (Exception e) {
4447 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
4448 FINDER_ARGS_EMPTY);
4449
4450 throw processException(e);
4451 }
4452 finally {
4453 closeSession(session);
4454 }
4455 }
4456
4457 return count.intValue();
4458 }
4459
4460 @Override
4461 protected Set<String> getBadColumnNames() {
4462 return _badColumnNames;
4463 }
4464
4465
4468 public void afterPropertiesSet() {
4469 }
4470
4471 public void destroy() {
4472 EntityCacheUtil.removeCache(LayoutSetPrototypeImpl.class.getName());
4473 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
4474 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
4475 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
4476 }
4477
4478 private static final String _SQL_SELECT_LAYOUTSETPROTOTYPE = "SELECT layoutSetPrototype FROM LayoutSetPrototype layoutSetPrototype";
4479 private static final String _SQL_SELECT_LAYOUTSETPROTOTYPE_WHERE_PKS_IN = "SELECT layoutSetPrototype FROM LayoutSetPrototype layoutSetPrototype WHERE layoutSetPrototypeId IN (";
4480 private static final String _SQL_SELECT_LAYOUTSETPROTOTYPE_WHERE = "SELECT layoutSetPrototype FROM LayoutSetPrototype layoutSetPrototype WHERE ";
4481 private static final String _SQL_COUNT_LAYOUTSETPROTOTYPE = "SELECT COUNT(layoutSetPrototype) FROM LayoutSetPrototype layoutSetPrototype";
4482 private static final String _SQL_COUNT_LAYOUTSETPROTOTYPE_WHERE = "SELECT COUNT(layoutSetPrototype) FROM LayoutSetPrototype layoutSetPrototype WHERE ";
4483 private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "layoutSetPrototype.layoutSetPrototypeId";
4484 private static final String _FILTER_SQL_SELECT_LAYOUTSETPROTOTYPE_WHERE = "SELECT DISTINCT {layoutSetPrototype.*} FROM LayoutSetPrototype layoutSetPrototype WHERE ";
4485 private static final String _FILTER_SQL_SELECT_LAYOUTSETPROTOTYPE_NO_INLINE_DISTINCT_WHERE_1 =
4486 "SELECT {LayoutSetPrototype.*} FROM (SELECT DISTINCT layoutSetPrototype.layoutSetPrototypeId FROM LayoutSetPrototype layoutSetPrototype WHERE ";
4487 private static final String _FILTER_SQL_SELECT_LAYOUTSETPROTOTYPE_NO_INLINE_DISTINCT_WHERE_2 =
4488 ") TEMP_TABLE INNER JOIN LayoutSetPrototype ON TEMP_TABLE.layoutSetPrototypeId = LayoutSetPrototype.layoutSetPrototypeId";
4489 private static final String _FILTER_SQL_COUNT_LAYOUTSETPROTOTYPE_WHERE = "SELECT COUNT(DISTINCT layoutSetPrototype.layoutSetPrototypeId) AS COUNT_VALUE FROM LayoutSetPrototype layoutSetPrototype WHERE ";
4490 private static final String _FILTER_ENTITY_ALIAS = "layoutSetPrototype";
4491 private static final String _FILTER_ENTITY_TABLE = "LayoutSetPrototype";
4492 private static final String _ORDER_BY_ENTITY_ALIAS = "layoutSetPrototype.";
4493 private static final String _ORDER_BY_ENTITY_TABLE = "LayoutSetPrototype.";
4494 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No LayoutSetPrototype exists with the primary key ";
4495 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No LayoutSetPrototype exists with the key {";
4496 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
4497 private static final Log _log = LogFactoryUtil.getLog(LayoutSetPrototypePersistenceImpl.class);
4498 private static final Set<String> _badColumnNames = SetUtil.fromArray(new String[] {
4499 "uuid", "settings", "active"
4500 });
4501 private static final LayoutSetPrototype _nullLayoutSetPrototype = new LayoutSetPrototypeImpl() {
4502 @Override
4503 public Object clone() {
4504 return this;
4505 }
4506
4507 @Override
4508 public CacheModel<LayoutSetPrototype> toCacheModel() {
4509 return _nullLayoutSetPrototypeCacheModel;
4510 }
4511 };
4512
4513 private static final CacheModel<LayoutSetPrototype> _nullLayoutSetPrototypeCacheModel =
4514 new NullCacheModel();
4515
4516 private static class NullCacheModel implements CacheModel<LayoutSetPrototype>,
4517 MVCCModel {
4518 @Override
4519 public long getMvccVersion() {
4520 return -1;
4521 }
4522
4523 @Override
4524 public void setMvccVersion(long mvccVersion) {
4525 }
4526
4527 @Override
4528 public LayoutSetPrototype toEntityModel() {
4529 return _nullLayoutSetPrototype;
4530 }
4531 }
4532 }