001
014
015 package com.liferay.portal.service.persistence;
016
017 import com.liferay.portal.NoSuchLayoutSetPrototypeException;
018 import com.liferay.portal.NoSuchModelException;
019 import com.liferay.portal.kernel.cache.CacheRegistryUtil;
020 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
021 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
022 import com.liferay.portal.kernel.dao.orm.FinderPath;
023 import com.liferay.portal.kernel.dao.orm.Query;
024 import com.liferay.portal.kernel.dao.orm.QueryPos;
025 import com.liferay.portal.kernel.dao.orm.QueryUtil;
026 import com.liferay.portal.kernel.dao.orm.SQLQuery;
027 import com.liferay.portal.kernel.dao.orm.Session;
028 import com.liferay.portal.kernel.exception.SystemException;
029 import com.liferay.portal.kernel.log.Log;
030 import com.liferay.portal.kernel.log.LogFactoryUtil;
031 import com.liferay.portal.kernel.util.GetterUtil;
032 import com.liferay.portal.kernel.util.InstanceFactory;
033 import com.liferay.portal.kernel.util.OrderByComparator;
034 import com.liferay.portal.kernel.util.StringBundler;
035 import com.liferay.portal.kernel.util.StringPool;
036 import com.liferay.portal.kernel.util.StringUtil;
037 import com.liferay.portal.kernel.util.UnmodifiableList;
038 import com.liferay.portal.kernel.util.Validator;
039 import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
040 import com.liferay.portal.model.CacheModel;
041 import com.liferay.portal.model.LayoutSetPrototype;
042 import com.liferay.portal.model.ModelListener;
043 import com.liferay.portal.model.impl.LayoutSetPrototypeImpl;
044 import com.liferay.portal.model.impl.LayoutSetPrototypeModelImpl;
045 import com.liferay.portal.security.permission.InlineSQLHelperUtil;
046 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
047
048 import java.io.Serializable;
049
050 import java.util.ArrayList;
051 import java.util.Collections;
052 import java.util.List;
053
054
066 public class LayoutSetPrototypePersistenceImpl extends BasePersistenceImpl<LayoutSetPrototype>
067 implements LayoutSetPrototypePersistence {
068
073 public static final String FINDER_CLASS_NAME_ENTITY = LayoutSetPrototypeImpl.class.getName();
074 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
075 ".List1";
076 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
077 ".List2";
078 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(LayoutSetPrototypeModelImpl.ENTITY_CACHE_ENABLED,
079 LayoutSetPrototypeModelImpl.FINDER_CACHE_ENABLED,
080 LayoutSetPrototypeImpl.class,
081 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
082 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(LayoutSetPrototypeModelImpl.ENTITY_CACHE_ENABLED,
083 LayoutSetPrototypeModelImpl.FINDER_CACHE_ENABLED,
084 LayoutSetPrototypeImpl.class,
085 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
086 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(LayoutSetPrototypeModelImpl.ENTITY_CACHE_ENABLED,
087 LayoutSetPrototypeModelImpl.FINDER_CACHE_ENABLED, Long.class,
088 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
089 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(LayoutSetPrototypeModelImpl.ENTITY_CACHE_ENABLED,
090 LayoutSetPrototypeModelImpl.FINDER_CACHE_ENABLED,
091 LayoutSetPrototypeImpl.class,
092 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid",
093 new String[] {
094 String.class.getName(),
095
096 Integer.class.getName(), Integer.class.getName(),
097 OrderByComparator.class.getName()
098 });
099 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(LayoutSetPrototypeModelImpl.ENTITY_CACHE_ENABLED,
100 LayoutSetPrototypeModelImpl.FINDER_CACHE_ENABLED,
101 LayoutSetPrototypeImpl.class,
102 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
103 new String[] { String.class.getName() },
104 LayoutSetPrototypeModelImpl.UUID_COLUMN_BITMASK);
105 public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(LayoutSetPrototypeModelImpl.ENTITY_CACHE_ENABLED,
106 LayoutSetPrototypeModelImpl.FINDER_CACHE_ENABLED, Long.class,
107 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
108 new String[] { String.class.getName() });
109
110
117 public List<LayoutSetPrototype> findByUuid(String uuid)
118 throws SystemException {
119 return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
120 }
121
122
135 public List<LayoutSetPrototype> findByUuid(String uuid, int start, int end)
136 throws SystemException {
137 return findByUuid(uuid, start, end, null);
138 }
139
140
154 public List<LayoutSetPrototype> findByUuid(String uuid, int start, int end,
155 OrderByComparator orderByComparator) throws SystemException {
156 boolean pagination = true;
157 FinderPath finderPath = null;
158 Object[] finderArgs = null;
159
160 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
161 (orderByComparator == null)) {
162 pagination = false;
163 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_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 if (uuid == null) {
198 query.append(_FINDER_COLUMN_UUID_UUID_1);
199 }
200 else {
201 if (uuid.equals(StringPool.BLANK)) {
202 query.append(_FINDER_COLUMN_UUID_UUID_3);
203 }
204 else {
205 query.append(_FINDER_COLUMN_UUID_UUID_2);
206 }
207 }
208
209 if (orderByComparator != null) {
210 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
211 orderByComparator);
212 }
213 else
214 if (pagination) {
215 query.append(LayoutSetPrototypeModelImpl.ORDER_BY_JPQL);
216 }
217
218 String sql = query.toString();
219
220 Session session = null;
221
222 try {
223 session = openSession();
224
225 Query q = session.createQuery(sql);
226
227 QueryPos qPos = QueryPos.getInstance(q);
228
229 if (uuid != null) {
230 qPos.add(uuid);
231 }
232
233 if (!pagination) {
234 list = (List<LayoutSetPrototype>)QueryUtil.list(q,
235 getDialect(), start, end, false);
236
237 Collections.sort(list);
238
239 list = new UnmodifiableList<LayoutSetPrototype>(list);
240 }
241 else {
242 list = (List<LayoutSetPrototype>)QueryUtil.list(q,
243 getDialect(), start, end);
244 }
245
246 cacheResult(list);
247
248 FinderCacheUtil.putResult(finderPath, finderArgs, list);
249 }
250 catch (Exception e) {
251 FinderCacheUtil.removeResult(finderPath, finderArgs);
252
253 throw processException(e);
254 }
255 finally {
256 closeSession(session);
257 }
258 }
259
260 return list;
261 }
262
263
272 public LayoutSetPrototype findByUuid_First(String uuid,
273 OrderByComparator orderByComparator)
274 throws NoSuchLayoutSetPrototypeException, SystemException {
275 LayoutSetPrototype layoutSetPrototype = fetchByUuid_First(uuid,
276 orderByComparator);
277
278 if (layoutSetPrototype != null) {
279 return layoutSetPrototype;
280 }
281
282 StringBundler msg = new StringBundler(4);
283
284 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
285
286 msg.append("uuid=");
287 msg.append(uuid);
288
289 msg.append(StringPool.CLOSE_CURLY_BRACE);
290
291 throw new NoSuchLayoutSetPrototypeException(msg.toString());
292 }
293
294
302 public LayoutSetPrototype fetchByUuid_First(String uuid,
303 OrderByComparator orderByComparator) throws SystemException {
304 List<LayoutSetPrototype> list = findByUuid(uuid, 0, 1, orderByComparator);
305
306 if (!list.isEmpty()) {
307 return list.get(0);
308 }
309
310 return null;
311 }
312
313
322 public LayoutSetPrototype findByUuid_Last(String uuid,
323 OrderByComparator orderByComparator)
324 throws NoSuchLayoutSetPrototypeException, SystemException {
325 LayoutSetPrototype layoutSetPrototype = fetchByUuid_Last(uuid,
326 orderByComparator);
327
328 if (layoutSetPrototype != null) {
329 return layoutSetPrototype;
330 }
331
332 StringBundler msg = new StringBundler(4);
333
334 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
335
336 msg.append("uuid=");
337 msg.append(uuid);
338
339 msg.append(StringPool.CLOSE_CURLY_BRACE);
340
341 throw new NoSuchLayoutSetPrototypeException(msg.toString());
342 }
343
344
352 public LayoutSetPrototype fetchByUuid_Last(String uuid,
353 OrderByComparator orderByComparator) throws SystemException {
354 int count = countByUuid(uuid);
355
356 List<LayoutSetPrototype> list = findByUuid(uuid, count - 1, count,
357 orderByComparator);
358
359 if (!list.isEmpty()) {
360 return list.get(0);
361 }
362
363 return null;
364 }
365
366
376 public LayoutSetPrototype[] findByUuid_PrevAndNext(
377 long layoutSetPrototypeId, String uuid,
378 OrderByComparator orderByComparator)
379 throws NoSuchLayoutSetPrototypeException, SystemException {
380 LayoutSetPrototype layoutSetPrototype = findByPrimaryKey(layoutSetPrototypeId);
381
382 Session session = null;
383
384 try {
385 session = openSession();
386
387 LayoutSetPrototype[] array = new LayoutSetPrototypeImpl[3];
388
389 array[0] = getByUuid_PrevAndNext(session, layoutSetPrototype, uuid,
390 orderByComparator, true);
391
392 array[1] = layoutSetPrototype;
393
394 array[2] = getByUuid_PrevAndNext(session, layoutSetPrototype, uuid,
395 orderByComparator, false);
396
397 return array;
398 }
399 catch (Exception e) {
400 throw processException(e);
401 }
402 finally {
403 closeSession(session);
404 }
405 }
406
407 protected LayoutSetPrototype getByUuid_PrevAndNext(Session session,
408 LayoutSetPrototype layoutSetPrototype, String uuid,
409 OrderByComparator orderByComparator, boolean previous) {
410 StringBundler query = null;
411
412 if (orderByComparator != null) {
413 query = new StringBundler(6 +
414 (orderByComparator.getOrderByFields().length * 6));
415 }
416 else {
417 query = new StringBundler(3);
418 }
419
420 query.append(_SQL_SELECT_LAYOUTSETPROTOTYPE_WHERE);
421
422 if (uuid == null) {
423 query.append(_FINDER_COLUMN_UUID_UUID_1);
424 }
425 else {
426 if (uuid.equals(StringPool.BLANK)) {
427 query.append(_FINDER_COLUMN_UUID_UUID_3);
428 }
429 else {
430 query.append(_FINDER_COLUMN_UUID_UUID_2);
431 }
432 }
433
434 if (orderByComparator != null) {
435 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
436
437 if (orderByConditionFields.length > 0) {
438 query.append(WHERE_AND);
439 }
440
441 for (int i = 0; i < orderByConditionFields.length; i++) {
442 query.append(_ORDER_BY_ENTITY_ALIAS);
443 query.append(orderByConditionFields[i]);
444
445 if ((i + 1) < orderByConditionFields.length) {
446 if (orderByComparator.isAscending() ^ previous) {
447 query.append(WHERE_GREATER_THAN_HAS_NEXT);
448 }
449 else {
450 query.append(WHERE_LESSER_THAN_HAS_NEXT);
451 }
452 }
453 else {
454 if (orderByComparator.isAscending() ^ previous) {
455 query.append(WHERE_GREATER_THAN);
456 }
457 else {
458 query.append(WHERE_LESSER_THAN);
459 }
460 }
461 }
462
463 query.append(ORDER_BY_CLAUSE);
464
465 String[] orderByFields = orderByComparator.getOrderByFields();
466
467 for (int i = 0; i < orderByFields.length; i++) {
468 query.append(_ORDER_BY_ENTITY_ALIAS);
469 query.append(orderByFields[i]);
470
471 if ((i + 1) < orderByFields.length) {
472 if (orderByComparator.isAscending() ^ previous) {
473 query.append(ORDER_BY_ASC_HAS_NEXT);
474 }
475 else {
476 query.append(ORDER_BY_DESC_HAS_NEXT);
477 }
478 }
479 else {
480 if (orderByComparator.isAscending() ^ previous) {
481 query.append(ORDER_BY_ASC);
482 }
483 else {
484 query.append(ORDER_BY_DESC);
485 }
486 }
487 }
488 }
489 else {
490 query.append(LayoutSetPrototypeModelImpl.ORDER_BY_JPQL);
491 }
492
493 String sql = query.toString();
494
495 Query q = session.createQuery(sql);
496
497 q.setFirstResult(0);
498 q.setMaxResults(2);
499
500 QueryPos qPos = QueryPos.getInstance(q);
501
502 if (uuid != null) {
503 qPos.add(uuid);
504 }
505
506 if (orderByComparator != null) {
507 Object[] values = orderByComparator.getOrderByConditionValues(layoutSetPrototype);
508
509 for (Object value : values) {
510 qPos.add(value);
511 }
512 }
513
514 List<LayoutSetPrototype> list = q.list();
515
516 if (list.size() == 2) {
517 return list.get(1);
518 }
519 else {
520 return null;
521 }
522 }
523
524
531 public List<LayoutSetPrototype> filterFindByUuid(String uuid)
532 throws SystemException {
533 return filterFindByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
534 }
535
536
549 public List<LayoutSetPrototype> filterFindByUuid(String uuid, int start,
550 int end) throws SystemException {
551 return filterFindByUuid(uuid, start, end, null);
552 }
553
554
568 public List<LayoutSetPrototype> filterFindByUuid(String uuid, int start,
569 int end, OrderByComparator orderByComparator) throws SystemException {
570 if (!InlineSQLHelperUtil.isEnabled()) {
571 return findByUuid(uuid, start, end, orderByComparator);
572 }
573
574 StringBundler query = null;
575
576 if (orderByComparator != null) {
577 query = new StringBundler(3 +
578 (orderByComparator.getOrderByFields().length * 3));
579 }
580 else {
581 query = new StringBundler(3);
582 }
583
584 if (getDB().isSupportsInlineDistinct()) {
585 query.append(_FILTER_SQL_SELECT_LAYOUTSETPROTOTYPE_WHERE);
586 }
587 else {
588 query.append(_FILTER_SQL_SELECT_LAYOUTSETPROTOTYPE_NO_INLINE_DISTINCT_WHERE_1);
589 }
590
591 if (uuid == null) {
592 query.append(_FINDER_COLUMN_UUID_UUID_1);
593 }
594 else {
595 if (uuid.equals(StringPool.BLANK)) {
596 query.append(_FINDER_COLUMN_UUID_UUID_3);
597 }
598 else {
599 query.append(_FINDER_COLUMN_UUID_UUID_2);
600 }
601 }
602
603 if (!getDB().isSupportsInlineDistinct()) {
604 query.append(_FILTER_SQL_SELECT_LAYOUTSETPROTOTYPE_NO_INLINE_DISTINCT_WHERE_2);
605 }
606
607 if (orderByComparator != null) {
608 if (getDB().isSupportsInlineDistinct()) {
609 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
610 orderByComparator);
611 }
612 else {
613 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
614 orderByComparator);
615 }
616 }
617 else {
618 if (getDB().isSupportsInlineDistinct()) {
619 query.append(LayoutSetPrototypeModelImpl.ORDER_BY_JPQL);
620 }
621 else {
622 query.append(LayoutSetPrototypeModelImpl.ORDER_BY_SQL);
623 }
624 }
625
626 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
627 LayoutSetPrototype.class.getName(),
628 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
629
630 Session session = null;
631
632 try {
633 session = openSession();
634
635 SQLQuery q = session.createSQLQuery(sql);
636
637 if (getDB().isSupportsInlineDistinct()) {
638 q.addEntity(_FILTER_ENTITY_ALIAS, LayoutSetPrototypeImpl.class);
639 }
640 else {
641 q.addEntity(_FILTER_ENTITY_TABLE, LayoutSetPrototypeImpl.class);
642 }
643
644 QueryPos qPos = QueryPos.getInstance(q);
645
646 if (uuid != null) {
647 qPos.add(uuid);
648 }
649
650 return (List<LayoutSetPrototype>)QueryUtil.list(q, getDialect(),
651 start, end);
652 }
653 catch (Exception e) {
654 throw processException(e);
655 }
656 finally {
657 closeSession(session);
658 }
659 }
660
661
671 public LayoutSetPrototype[] filterFindByUuid_PrevAndNext(
672 long layoutSetPrototypeId, String uuid,
673 OrderByComparator orderByComparator)
674 throws NoSuchLayoutSetPrototypeException, SystemException {
675 if (!InlineSQLHelperUtil.isEnabled()) {
676 return findByUuid_PrevAndNext(layoutSetPrototypeId, uuid,
677 orderByComparator);
678 }
679
680 LayoutSetPrototype layoutSetPrototype = findByPrimaryKey(layoutSetPrototypeId);
681
682 Session session = null;
683
684 try {
685 session = openSession();
686
687 LayoutSetPrototype[] array = new LayoutSetPrototypeImpl[3];
688
689 array[0] = filterGetByUuid_PrevAndNext(session, layoutSetPrototype,
690 uuid, orderByComparator, true);
691
692 array[1] = layoutSetPrototype;
693
694 array[2] = filterGetByUuid_PrevAndNext(session, layoutSetPrototype,
695 uuid, orderByComparator, false);
696
697 return array;
698 }
699 catch (Exception e) {
700 throw processException(e);
701 }
702 finally {
703 closeSession(session);
704 }
705 }
706
707 protected LayoutSetPrototype filterGetByUuid_PrevAndNext(Session session,
708 LayoutSetPrototype layoutSetPrototype, String uuid,
709 OrderByComparator orderByComparator, boolean previous) {
710 StringBundler query = null;
711
712 if (orderByComparator != null) {
713 query = new StringBundler(6 +
714 (orderByComparator.getOrderByFields().length * 6));
715 }
716 else {
717 query = new StringBundler(3);
718 }
719
720 if (getDB().isSupportsInlineDistinct()) {
721 query.append(_FILTER_SQL_SELECT_LAYOUTSETPROTOTYPE_WHERE);
722 }
723 else {
724 query.append(_FILTER_SQL_SELECT_LAYOUTSETPROTOTYPE_NO_INLINE_DISTINCT_WHERE_1);
725 }
726
727 if (uuid == null) {
728 query.append(_FINDER_COLUMN_UUID_UUID_1);
729 }
730 else {
731 if (uuid.equals(StringPool.BLANK)) {
732 query.append(_FINDER_COLUMN_UUID_UUID_3);
733 }
734 else {
735 query.append(_FINDER_COLUMN_UUID_UUID_2);
736 }
737 }
738
739 if (!getDB().isSupportsInlineDistinct()) {
740 query.append(_FILTER_SQL_SELECT_LAYOUTSETPROTOTYPE_NO_INLINE_DISTINCT_WHERE_2);
741 }
742
743 if (orderByComparator != null) {
744 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
745
746 if (orderByConditionFields.length > 0) {
747 query.append(WHERE_AND);
748 }
749
750 for (int i = 0; i < orderByConditionFields.length; i++) {
751 if (getDB().isSupportsInlineDistinct()) {
752 query.append(_ORDER_BY_ENTITY_ALIAS);
753 }
754 else {
755 query.append(_ORDER_BY_ENTITY_TABLE);
756 }
757
758 query.append(orderByConditionFields[i]);
759
760 if ((i + 1) < orderByConditionFields.length) {
761 if (orderByComparator.isAscending() ^ previous) {
762 query.append(WHERE_GREATER_THAN_HAS_NEXT);
763 }
764 else {
765 query.append(WHERE_LESSER_THAN_HAS_NEXT);
766 }
767 }
768 else {
769 if (orderByComparator.isAscending() ^ previous) {
770 query.append(WHERE_GREATER_THAN);
771 }
772 else {
773 query.append(WHERE_LESSER_THAN);
774 }
775 }
776 }
777
778 query.append(ORDER_BY_CLAUSE);
779
780 String[] orderByFields = orderByComparator.getOrderByFields();
781
782 for (int i = 0; i < orderByFields.length; i++) {
783 if (getDB().isSupportsInlineDistinct()) {
784 query.append(_ORDER_BY_ENTITY_ALIAS);
785 }
786 else {
787 query.append(_ORDER_BY_ENTITY_TABLE);
788 }
789
790 query.append(orderByFields[i]);
791
792 if ((i + 1) < orderByFields.length) {
793 if (orderByComparator.isAscending() ^ previous) {
794 query.append(ORDER_BY_ASC_HAS_NEXT);
795 }
796 else {
797 query.append(ORDER_BY_DESC_HAS_NEXT);
798 }
799 }
800 else {
801 if (orderByComparator.isAscending() ^ previous) {
802 query.append(ORDER_BY_ASC);
803 }
804 else {
805 query.append(ORDER_BY_DESC);
806 }
807 }
808 }
809 }
810 else {
811 if (getDB().isSupportsInlineDistinct()) {
812 query.append(LayoutSetPrototypeModelImpl.ORDER_BY_JPQL);
813 }
814 else {
815 query.append(LayoutSetPrototypeModelImpl.ORDER_BY_SQL);
816 }
817 }
818
819 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
820 LayoutSetPrototype.class.getName(),
821 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
822
823 SQLQuery q = session.createSQLQuery(sql);
824
825 q.setFirstResult(0);
826 q.setMaxResults(2);
827
828 if (getDB().isSupportsInlineDistinct()) {
829 q.addEntity(_FILTER_ENTITY_ALIAS, LayoutSetPrototypeImpl.class);
830 }
831 else {
832 q.addEntity(_FILTER_ENTITY_TABLE, LayoutSetPrototypeImpl.class);
833 }
834
835 QueryPos qPos = QueryPos.getInstance(q);
836
837 if (uuid != null) {
838 qPos.add(uuid);
839 }
840
841 if (orderByComparator != null) {
842 Object[] values = orderByComparator.getOrderByConditionValues(layoutSetPrototype);
843
844 for (Object value : values) {
845 qPos.add(value);
846 }
847 }
848
849 List<LayoutSetPrototype> list = q.list();
850
851 if (list.size() == 2) {
852 return list.get(1);
853 }
854 else {
855 return null;
856 }
857 }
858
859
865 public void removeByUuid(String uuid) throws SystemException {
866 for (LayoutSetPrototype layoutSetPrototype : findByUuid(uuid,
867 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
868 remove(layoutSetPrototype);
869 }
870 }
871
872
879 public int countByUuid(String uuid) throws SystemException {
880 FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID;
881
882 Object[] finderArgs = new Object[] { uuid };
883
884 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
885 this);
886
887 if (count == null) {
888 StringBundler query = new StringBundler(2);
889
890 query.append(_SQL_COUNT_LAYOUTSETPROTOTYPE_WHERE);
891
892 if (uuid == null) {
893 query.append(_FINDER_COLUMN_UUID_UUID_1);
894 }
895 else {
896 if (uuid.equals(StringPool.BLANK)) {
897 query.append(_FINDER_COLUMN_UUID_UUID_3);
898 }
899 else {
900 query.append(_FINDER_COLUMN_UUID_UUID_2);
901 }
902 }
903
904 String sql = query.toString();
905
906 Session session = null;
907
908 try {
909 session = openSession();
910
911 Query q = session.createQuery(sql);
912
913 QueryPos qPos = QueryPos.getInstance(q);
914
915 if (uuid != null) {
916 qPos.add(uuid);
917 }
918
919 count = (Long)q.uniqueResult();
920
921 FinderCacheUtil.putResult(finderPath, finderArgs, count);
922 }
923 catch (Exception e) {
924 FinderCacheUtil.removeResult(finderPath, finderArgs);
925
926 throw processException(e);
927 }
928 finally {
929 closeSession(session);
930 }
931 }
932
933 return count.intValue();
934 }
935
936
943 public int filterCountByUuid(String uuid) throws SystemException {
944 if (!InlineSQLHelperUtil.isEnabled()) {
945 return countByUuid(uuid);
946 }
947
948 StringBundler query = new StringBundler(2);
949
950 query.append(_FILTER_SQL_COUNT_LAYOUTSETPROTOTYPE_WHERE);
951
952 if (uuid == null) {
953 query.append(_FINDER_COLUMN_UUID_UUID_1);
954 }
955 else {
956 if (uuid.equals(StringPool.BLANK)) {
957 query.append(_FINDER_COLUMN_UUID_UUID_3);
958 }
959 else {
960 query.append(_FINDER_COLUMN_UUID_UUID_2);
961 }
962 }
963
964 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
965 LayoutSetPrototype.class.getName(),
966 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
967
968 Session session = null;
969
970 try {
971 session = openSession();
972
973 SQLQuery q = session.createSQLQuery(sql);
974
975 q.addScalar(COUNT_COLUMN_NAME,
976 com.liferay.portal.kernel.dao.orm.Type.LONG);
977
978 QueryPos qPos = QueryPos.getInstance(q);
979
980 if (uuid != null) {
981 qPos.add(uuid);
982 }
983
984 Long count = (Long)q.uniqueResult();
985
986 return count.intValue();
987 }
988 catch (Exception e) {
989 throw processException(e);
990 }
991 finally {
992 closeSession(session);
993 }
994 }
995
996 private static final String _FINDER_COLUMN_UUID_UUID_1 = "layoutSetPrototype.uuid IS NULL";
997 private static final String _FINDER_COLUMN_UUID_UUID_2 = "layoutSetPrototype.uuid = ?";
998 private static final String _FINDER_COLUMN_UUID_UUID_3 = "(layoutSetPrototype.uuid IS NULL OR layoutSetPrototype.uuid = ?)";
999 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C = new FinderPath(LayoutSetPrototypeModelImpl.ENTITY_CACHE_ENABLED,
1000 LayoutSetPrototypeModelImpl.FINDER_CACHE_ENABLED,
1001 LayoutSetPrototypeImpl.class,
1002 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid_C",
1003 new String[] {
1004 String.class.getName(), Long.class.getName(),
1005
1006 Integer.class.getName(), Integer.class.getName(),
1007 OrderByComparator.class.getName()
1008 });
1009 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C =
1010 new FinderPath(LayoutSetPrototypeModelImpl.ENTITY_CACHE_ENABLED,
1011 LayoutSetPrototypeModelImpl.FINDER_CACHE_ENABLED,
1012 LayoutSetPrototypeImpl.class,
1013 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid_C",
1014 new String[] { String.class.getName(), Long.class.getName() },
1015 LayoutSetPrototypeModelImpl.UUID_COLUMN_BITMASK |
1016 LayoutSetPrototypeModelImpl.COMPANYID_COLUMN_BITMASK);
1017 public static final FinderPath FINDER_PATH_COUNT_BY_UUID_C = new FinderPath(LayoutSetPrototypeModelImpl.ENTITY_CACHE_ENABLED,
1018 LayoutSetPrototypeModelImpl.FINDER_CACHE_ENABLED, Long.class,
1019 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid_C",
1020 new String[] { String.class.getName(), Long.class.getName() });
1021
1022
1030 public List<LayoutSetPrototype> findByUuid_C(String uuid, long companyId)
1031 throws SystemException {
1032 return findByUuid_C(uuid, companyId, QueryUtil.ALL_POS,
1033 QueryUtil.ALL_POS, null);
1034 }
1035
1036
1050 public List<LayoutSetPrototype> findByUuid_C(String uuid, long companyId,
1051 int start, int end) throws SystemException {
1052 return findByUuid_C(uuid, companyId, start, end, null);
1053 }
1054
1055
1070 public List<LayoutSetPrototype> findByUuid_C(String uuid, long companyId,
1071 int start, int end, OrderByComparator orderByComparator)
1072 throws SystemException {
1073 boolean pagination = true;
1074 FinderPath finderPath = null;
1075 Object[] finderArgs = null;
1076
1077 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1078 (orderByComparator == null)) {
1079 pagination = false;
1080 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C;
1081 finderArgs = new Object[] { uuid, companyId };
1082 }
1083 else {
1084 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C;
1085 finderArgs = new Object[] {
1086 uuid, companyId,
1087
1088 start, end, orderByComparator
1089 };
1090 }
1091
1092 List<LayoutSetPrototype> list = (List<LayoutSetPrototype>)FinderCacheUtil.getResult(finderPath,
1093 finderArgs, this);
1094
1095 if ((list != null) && !list.isEmpty()) {
1096 for (LayoutSetPrototype layoutSetPrototype : list) {
1097 if (!Validator.equals(uuid, layoutSetPrototype.getUuid()) ||
1098 (companyId != layoutSetPrototype.getCompanyId())) {
1099 list = null;
1100
1101 break;
1102 }
1103 }
1104 }
1105
1106 if (list == null) {
1107 StringBundler query = null;
1108
1109 if (orderByComparator != null) {
1110 query = new StringBundler(4 +
1111 (orderByComparator.getOrderByFields().length * 3));
1112 }
1113 else {
1114 query = new StringBundler(4);
1115 }
1116
1117 query.append(_SQL_SELECT_LAYOUTSETPROTOTYPE_WHERE);
1118
1119 if (uuid == null) {
1120 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1121 }
1122 else {
1123 if (uuid.equals(StringPool.BLANK)) {
1124 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1125 }
1126 else {
1127 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1128 }
1129 }
1130
1131 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1132
1133 if (orderByComparator != null) {
1134 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1135 orderByComparator);
1136 }
1137 else
1138 if (pagination) {
1139 query.append(LayoutSetPrototypeModelImpl.ORDER_BY_JPQL);
1140 }
1141
1142 String sql = query.toString();
1143
1144 Session session = null;
1145
1146 try {
1147 session = openSession();
1148
1149 Query q = session.createQuery(sql);
1150
1151 QueryPos qPos = QueryPos.getInstance(q);
1152
1153 if (uuid != null) {
1154 qPos.add(uuid);
1155 }
1156
1157 qPos.add(companyId);
1158
1159 if (!pagination) {
1160 list = (List<LayoutSetPrototype>)QueryUtil.list(q,
1161 getDialect(), start, end, false);
1162
1163 Collections.sort(list);
1164
1165 list = new UnmodifiableList<LayoutSetPrototype>(list);
1166 }
1167 else {
1168 list = (List<LayoutSetPrototype>)QueryUtil.list(q,
1169 getDialect(), start, end);
1170 }
1171
1172 cacheResult(list);
1173
1174 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1175 }
1176 catch (Exception e) {
1177 FinderCacheUtil.removeResult(finderPath, finderArgs);
1178
1179 throw processException(e);
1180 }
1181 finally {
1182 closeSession(session);
1183 }
1184 }
1185
1186 return list;
1187 }
1188
1189
1199 public LayoutSetPrototype findByUuid_C_First(String uuid, long companyId,
1200 OrderByComparator orderByComparator)
1201 throws NoSuchLayoutSetPrototypeException, SystemException {
1202 LayoutSetPrototype layoutSetPrototype = fetchByUuid_C_First(uuid,
1203 companyId, orderByComparator);
1204
1205 if (layoutSetPrototype != null) {
1206 return layoutSetPrototype;
1207 }
1208
1209 StringBundler msg = new StringBundler(6);
1210
1211 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1212
1213 msg.append("uuid=");
1214 msg.append(uuid);
1215
1216 msg.append(", companyId=");
1217 msg.append(companyId);
1218
1219 msg.append(StringPool.CLOSE_CURLY_BRACE);
1220
1221 throw new NoSuchLayoutSetPrototypeException(msg.toString());
1222 }
1223
1224
1233 public LayoutSetPrototype fetchByUuid_C_First(String uuid, long companyId,
1234 OrderByComparator orderByComparator) throws SystemException {
1235 List<LayoutSetPrototype> list = findByUuid_C(uuid, companyId, 0, 1,
1236 orderByComparator);
1237
1238 if (!list.isEmpty()) {
1239 return list.get(0);
1240 }
1241
1242 return null;
1243 }
1244
1245
1255 public LayoutSetPrototype findByUuid_C_Last(String uuid, long companyId,
1256 OrderByComparator orderByComparator)
1257 throws NoSuchLayoutSetPrototypeException, SystemException {
1258 LayoutSetPrototype layoutSetPrototype = fetchByUuid_C_Last(uuid,
1259 companyId, orderByComparator);
1260
1261 if (layoutSetPrototype != null) {
1262 return layoutSetPrototype;
1263 }
1264
1265 StringBundler msg = new StringBundler(6);
1266
1267 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1268
1269 msg.append("uuid=");
1270 msg.append(uuid);
1271
1272 msg.append(", companyId=");
1273 msg.append(companyId);
1274
1275 msg.append(StringPool.CLOSE_CURLY_BRACE);
1276
1277 throw new NoSuchLayoutSetPrototypeException(msg.toString());
1278 }
1279
1280
1289 public LayoutSetPrototype fetchByUuid_C_Last(String uuid, long companyId,
1290 OrderByComparator orderByComparator) throws SystemException {
1291 int count = countByUuid_C(uuid, companyId);
1292
1293 List<LayoutSetPrototype> list = findByUuid_C(uuid, companyId,
1294 count - 1, count, orderByComparator);
1295
1296 if (!list.isEmpty()) {
1297 return list.get(0);
1298 }
1299
1300 return null;
1301 }
1302
1303
1314 public LayoutSetPrototype[] findByUuid_C_PrevAndNext(
1315 long layoutSetPrototypeId, String uuid, long companyId,
1316 OrderByComparator orderByComparator)
1317 throws NoSuchLayoutSetPrototypeException, SystemException {
1318 LayoutSetPrototype layoutSetPrototype = findByPrimaryKey(layoutSetPrototypeId);
1319
1320 Session session = null;
1321
1322 try {
1323 session = openSession();
1324
1325 LayoutSetPrototype[] array = new LayoutSetPrototypeImpl[3];
1326
1327 array[0] = getByUuid_C_PrevAndNext(session, layoutSetPrototype,
1328 uuid, companyId, orderByComparator, true);
1329
1330 array[1] = layoutSetPrototype;
1331
1332 array[2] = getByUuid_C_PrevAndNext(session, layoutSetPrototype,
1333 uuid, companyId, orderByComparator, false);
1334
1335 return array;
1336 }
1337 catch (Exception e) {
1338 throw processException(e);
1339 }
1340 finally {
1341 closeSession(session);
1342 }
1343 }
1344
1345 protected LayoutSetPrototype getByUuid_C_PrevAndNext(Session session,
1346 LayoutSetPrototype layoutSetPrototype, String uuid, long companyId,
1347 OrderByComparator orderByComparator, boolean previous) {
1348 StringBundler query = null;
1349
1350 if (orderByComparator != null) {
1351 query = new StringBundler(6 +
1352 (orderByComparator.getOrderByFields().length * 6));
1353 }
1354 else {
1355 query = new StringBundler(3);
1356 }
1357
1358 query.append(_SQL_SELECT_LAYOUTSETPROTOTYPE_WHERE);
1359
1360 if (uuid == null) {
1361 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1362 }
1363 else {
1364 if (uuid.equals(StringPool.BLANK)) {
1365 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1366 }
1367 else {
1368 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1369 }
1370 }
1371
1372 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1373
1374 if (orderByComparator != null) {
1375 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1376
1377 if (orderByConditionFields.length > 0) {
1378 query.append(WHERE_AND);
1379 }
1380
1381 for (int i = 0; i < orderByConditionFields.length; i++) {
1382 query.append(_ORDER_BY_ENTITY_ALIAS);
1383 query.append(orderByConditionFields[i]);
1384
1385 if ((i + 1) < orderByConditionFields.length) {
1386 if (orderByComparator.isAscending() ^ previous) {
1387 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1388 }
1389 else {
1390 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1391 }
1392 }
1393 else {
1394 if (orderByComparator.isAscending() ^ previous) {
1395 query.append(WHERE_GREATER_THAN);
1396 }
1397 else {
1398 query.append(WHERE_LESSER_THAN);
1399 }
1400 }
1401 }
1402
1403 query.append(ORDER_BY_CLAUSE);
1404
1405 String[] orderByFields = orderByComparator.getOrderByFields();
1406
1407 for (int i = 0; i < orderByFields.length; i++) {
1408 query.append(_ORDER_BY_ENTITY_ALIAS);
1409 query.append(orderByFields[i]);
1410
1411 if ((i + 1) < orderByFields.length) {
1412 if (orderByComparator.isAscending() ^ previous) {
1413 query.append(ORDER_BY_ASC_HAS_NEXT);
1414 }
1415 else {
1416 query.append(ORDER_BY_DESC_HAS_NEXT);
1417 }
1418 }
1419 else {
1420 if (orderByComparator.isAscending() ^ previous) {
1421 query.append(ORDER_BY_ASC);
1422 }
1423 else {
1424 query.append(ORDER_BY_DESC);
1425 }
1426 }
1427 }
1428 }
1429 else {
1430 query.append(LayoutSetPrototypeModelImpl.ORDER_BY_JPQL);
1431 }
1432
1433 String sql = query.toString();
1434
1435 Query q = session.createQuery(sql);
1436
1437 q.setFirstResult(0);
1438 q.setMaxResults(2);
1439
1440 QueryPos qPos = QueryPos.getInstance(q);
1441
1442 if (uuid != null) {
1443 qPos.add(uuid);
1444 }
1445
1446 qPos.add(companyId);
1447
1448 if (orderByComparator != null) {
1449 Object[] values = orderByComparator.getOrderByConditionValues(layoutSetPrototype);
1450
1451 for (Object value : values) {
1452 qPos.add(value);
1453 }
1454 }
1455
1456 List<LayoutSetPrototype> list = q.list();
1457
1458 if (list.size() == 2) {
1459 return list.get(1);
1460 }
1461 else {
1462 return null;
1463 }
1464 }
1465
1466
1474 public List<LayoutSetPrototype> filterFindByUuid_C(String uuid,
1475 long companyId) throws SystemException {
1476 return filterFindByUuid_C(uuid, companyId, QueryUtil.ALL_POS,
1477 QueryUtil.ALL_POS, null);
1478 }
1479
1480
1494 public List<LayoutSetPrototype> filterFindByUuid_C(String uuid,
1495 long companyId, int start, int end) throws SystemException {
1496 return filterFindByUuid_C(uuid, companyId, start, end, null);
1497 }
1498
1499
1514 public List<LayoutSetPrototype> filterFindByUuid_C(String uuid,
1515 long companyId, int start, int end, OrderByComparator orderByComparator)
1516 throws SystemException {
1517 if (!InlineSQLHelperUtil.isEnabled()) {
1518 return findByUuid_C(uuid, companyId, start, end, orderByComparator);
1519 }
1520
1521 StringBundler query = null;
1522
1523 if (orderByComparator != null) {
1524 query = new StringBundler(4 +
1525 (orderByComparator.getOrderByFields().length * 3));
1526 }
1527 else {
1528 query = new StringBundler(4);
1529 }
1530
1531 if (getDB().isSupportsInlineDistinct()) {
1532 query.append(_FILTER_SQL_SELECT_LAYOUTSETPROTOTYPE_WHERE);
1533 }
1534 else {
1535 query.append(_FILTER_SQL_SELECT_LAYOUTSETPROTOTYPE_NO_INLINE_DISTINCT_WHERE_1);
1536 }
1537
1538 if (uuid == null) {
1539 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1540 }
1541 else {
1542 if (uuid.equals(StringPool.BLANK)) {
1543 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1544 }
1545 else {
1546 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1547 }
1548 }
1549
1550 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1551
1552 if (!getDB().isSupportsInlineDistinct()) {
1553 query.append(_FILTER_SQL_SELECT_LAYOUTSETPROTOTYPE_NO_INLINE_DISTINCT_WHERE_2);
1554 }
1555
1556 if (orderByComparator != null) {
1557 if (getDB().isSupportsInlineDistinct()) {
1558 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1559 orderByComparator);
1560 }
1561 else {
1562 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
1563 orderByComparator);
1564 }
1565 }
1566 else {
1567 if (getDB().isSupportsInlineDistinct()) {
1568 query.append(LayoutSetPrototypeModelImpl.ORDER_BY_JPQL);
1569 }
1570 else {
1571 query.append(LayoutSetPrototypeModelImpl.ORDER_BY_SQL);
1572 }
1573 }
1574
1575 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1576 LayoutSetPrototype.class.getName(),
1577 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
1578
1579 Session session = null;
1580
1581 try {
1582 session = openSession();
1583
1584 SQLQuery q = session.createSQLQuery(sql);
1585
1586 if (getDB().isSupportsInlineDistinct()) {
1587 q.addEntity(_FILTER_ENTITY_ALIAS, LayoutSetPrototypeImpl.class);
1588 }
1589 else {
1590 q.addEntity(_FILTER_ENTITY_TABLE, LayoutSetPrototypeImpl.class);
1591 }
1592
1593 QueryPos qPos = QueryPos.getInstance(q);
1594
1595 if (uuid != null) {
1596 qPos.add(uuid);
1597 }
1598
1599 qPos.add(companyId);
1600
1601 return (List<LayoutSetPrototype>)QueryUtil.list(q, getDialect(),
1602 start, end);
1603 }
1604 catch (Exception e) {
1605 throw processException(e);
1606 }
1607 finally {
1608 closeSession(session);
1609 }
1610 }
1611
1612
1623 public LayoutSetPrototype[] filterFindByUuid_C_PrevAndNext(
1624 long layoutSetPrototypeId, String uuid, long companyId,
1625 OrderByComparator orderByComparator)
1626 throws NoSuchLayoutSetPrototypeException, SystemException {
1627 if (!InlineSQLHelperUtil.isEnabled()) {
1628 return findByUuid_C_PrevAndNext(layoutSetPrototypeId, uuid,
1629 companyId, orderByComparator);
1630 }
1631
1632 LayoutSetPrototype layoutSetPrototype = findByPrimaryKey(layoutSetPrototypeId);
1633
1634 Session session = null;
1635
1636 try {
1637 session = openSession();
1638
1639 LayoutSetPrototype[] array = new LayoutSetPrototypeImpl[3];
1640
1641 array[0] = filterGetByUuid_C_PrevAndNext(session,
1642 layoutSetPrototype, uuid, companyId, orderByComparator, true);
1643
1644 array[1] = layoutSetPrototype;
1645
1646 array[2] = filterGetByUuid_C_PrevAndNext(session,
1647 layoutSetPrototype, uuid, companyId, orderByComparator,
1648 false);
1649
1650 return array;
1651 }
1652 catch (Exception e) {
1653 throw processException(e);
1654 }
1655 finally {
1656 closeSession(session);
1657 }
1658 }
1659
1660 protected LayoutSetPrototype filterGetByUuid_C_PrevAndNext(
1661 Session session, LayoutSetPrototype layoutSetPrototype, String uuid,
1662 long companyId, OrderByComparator orderByComparator, boolean previous) {
1663 StringBundler query = null;
1664
1665 if (orderByComparator != null) {
1666 query = new StringBundler(6 +
1667 (orderByComparator.getOrderByFields().length * 6));
1668 }
1669 else {
1670 query = new StringBundler(3);
1671 }
1672
1673 if (getDB().isSupportsInlineDistinct()) {
1674 query.append(_FILTER_SQL_SELECT_LAYOUTSETPROTOTYPE_WHERE);
1675 }
1676 else {
1677 query.append(_FILTER_SQL_SELECT_LAYOUTSETPROTOTYPE_NO_INLINE_DISTINCT_WHERE_1);
1678 }
1679
1680 if (uuid == null) {
1681 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1682 }
1683 else {
1684 if (uuid.equals(StringPool.BLANK)) {
1685 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1686 }
1687 else {
1688 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1689 }
1690 }
1691
1692 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1693
1694 if (!getDB().isSupportsInlineDistinct()) {
1695 query.append(_FILTER_SQL_SELECT_LAYOUTSETPROTOTYPE_NO_INLINE_DISTINCT_WHERE_2);
1696 }
1697
1698 if (orderByComparator != null) {
1699 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1700
1701 if (orderByConditionFields.length > 0) {
1702 query.append(WHERE_AND);
1703 }
1704
1705 for (int i = 0; i < orderByConditionFields.length; i++) {
1706 if (getDB().isSupportsInlineDistinct()) {
1707 query.append(_ORDER_BY_ENTITY_ALIAS);
1708 }
1709 else {
1710 query.append(_ORDER_BY_ENTITY_TABLE);
1711 }
1712
1713 query.append(orderByConditionFields[i]);
1714
1715 if ((i + 1) < orderByConditionFields.length) {
1716 if (orderByComparator.isAscending() ^ previous) {
1717 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1718 }
1719 else {
1720 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1721 }
1722 }
1723 else {
1724 if (orderByComparator.isAscending() ^ previous) {
1725 query.append(WHERE_GREATER_THAN);
1726 }
1727 else {
1728 query.append(WHERE_LESSER_THAN);
1729 }
1730 }
1731 }
1732
1733 query.append(ORDER_BY_CLAUSE);
1734
1735 String[] orderByFields = orderByComparator.getOrderByFields();
1736
1737 for (int i = 0; i < orderByFields.length; i++) {
1738 if (getDB().isSupportsInlineDistinct()) {
1739 query.append(_ORDER_BY_ENTITY_ALIAS);
1740 }
1741 else {
1742 query.append(_ORDER_BY_ENTITY_TABLE);
1743 }
1744
1745 query.append(orderByFields[i]);
1746
1747 if ((i + 1) < orderByFields.length) {
1748 if (orderByComparator.isAscending() ^ previous) {
1749 query.append(ORDER_BY_ASC_HAS_NEXT);
1750 }
1751 else {
1752 query.append(ORDER_BY_DESC_HAS_NEXT);
1753 }
1754 }
1755 else {
1756 if (orderByComparator.isAscending() ^ previous) {
1757 query.append(ORDER_BY_ASC);
1758 }
1759 else {
1760 query.append(ORDER_BY_DESC);
1761 }
1762 }
1763 }
1764 }
1765 else {
1766 if (getDB().isSupportsInlineDistinct()) {
1767 query.append(LayoutSetPrototypeModelImpl.ORDER_BY_JPQL);
1768 }
1769 else {
1770 query.append(LayoutSetPrototypeModelImpl.ORDER_BY_SQL);
1771 }
1772 }
1773
1774 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1775 LayoutSetPrototype.class.getName(),
1776 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
1777
1778 SQLQuery q = session.createSQLQuery(sql);
1779
1780 q.setFirstResult(0);
1781 q.setMaxResults(2);
1782
1783 if (getDB().isSupportsInlineDistinct()) {
1784 q.addEntity(_FILTER_ENTITY_ALIAS, LayoutSetPrototypeImpl.class);
1785 }
1786 else {
1787 q.addEntity(_FILTER_ENTITY_TABLE, LayoutSetPrototypeImpl.class);
1788 }
1789
1790 QueryPos qPos = QueryPos.getInstance(q);
1791
1792 if (uuid != null) {
1793 qPos.add(uuid);
1794 }
1795
1796 qPos.add(companyId);
1797
1798 if (orderByComparator != null) {
1799 Object[] values = orderByComparator.getOrderByConditionValues(layoutSetPrototype);
1800
1801 for (Object value : values) {
1802 qPos.add(value);
1803 }
1804 }
1805
1806 List<LayoutSetPrototype> list = q.list();
1807
1808 if (list.size() == 2) {
1809 return list.get(1);
1810 }
1811 else {
1812 return null;
1813 }
1814 }
1815
1816
1823 public void removeByUuid_C(String uuid, long companyId)
1824 throws SystemException {
1825 for (LayoutSetPrototype layoutSetPrototype : findByUuid_C(uuid,
1826 companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1827 remove(layoutSetPrototype);
1828 }
1829 }
1830
1831
1839 public int countByUuid_C(String uuid, long companyId)
1840 throws SystemException {
1841 FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_C;
1842
1843 Object[] finderArgs = new Object[] { uuid, companyId };
1844
1845 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1846 this);
1847
1848 if (count == null) {
1849 StringBundler query = new StringBundler(3);
1850
1851 query.append(_SQL_COUNT_LAYOUTSETPROTOTYPE_WHERE);
1852
1853 if (uuid == null) {
1854 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1855 }
1856 else {
1857 if (uuid.equals(StringPool.BLANK)) {
1858 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1859 }
1860 else {
1861 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1862 }
1863 }
1864
1865 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1866
1867 String sql = query.toString();
1868
1869 Session session = null;
1870
1871 try {
1872 session = openSession();
1873
1874 Query q = session.createQuery(sql);
1875
1876 QueryPos qPos = QueryPos.getInstance(q);
1877
1878 if (uuid != null) {
1879 qPos.add(uuid);
1880 }
1881
1882 qPos.add(companyId);
1883
1884 count = (Long)q.uniqueResult();
1885
1886 FinderCacheUtil.putResult(finderPath, finderArgs, count);
1887 }
1888 catch (Exception e) {
1889 FinderCacheUtil.removeResult(finderPath, finderArgs);
1890
1891 throw processException(e);
1892 }
1893 finally {
1894 closeSession(session);
1895 }
1896 }
1897
1898 return count.intValue();
1899 }
1900
1901
1909 public int filterCountByUuid_C(String uuid, long companyId)
1910 throws SystemException {
1911 if (!InlineSQLHelperUtil.isEnabled()) {
1912 return countByUuid_C(uuid, companyId);
1913 }
1914
1915 StringBundler query = new StringBundler(3);
1916
1917 query.append(_FILTER_SQL_COUNT_LAYOUTSETPROTOTYPE_WHERE);
1918
1919 if (uuid == null) {
1920 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1921 }
1922 else {
1923 if (uuid.equals(StringPool.BLANK)) {
1924 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1925 }
1926 else {
1927 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1928 }
1929 }
1930
1931 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1932
1933 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1934 LayoutSetPrototype.class.getName(),
1935 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
1936
1937 Session session = null;
1938
1939 try {
1940 session = openSession();
1941
1942 SQLQuery q = session.createSQLQuery(sql);
1943
1944 q.addScalar(COUNT_COLUMN_NAME,
1945 com.liferay.portal.kernel.dao.orm.Type.LONG);
1946
1947 QueryPos qPos = QueryPos.getInstance(q);
1948
1949 if (uuid != null) {
1950 qPos.add(uuid);
1951 }
1952
1953 qPos.add(companyId);
1954
1955 Long count = (Long)q.uniqueResult();
1956
1957 return count.intValue();
1958 }
1959 catch (Exception e) {
1960 throw processException(e);
1961 }
1962 finally {
1963 closeSession(session);
1964 }
1965 }
1966
1967 private static final String _FINDER_COLUMN_UUID_C_UUID_1 = "layoutSetPrototype.uuid IS NULL AND ";
1968 private static final String _FINDER_COLUMN_UUID_C_UUID_2 = "layoutSetPrototype.uuid = ? AND ";
1969 private static final String _FINDER_COLUMN_UUID_C_UUID_3 = "(layoutSetPrototype.uuid IS NULL OR layoutSetPrototype.uuid = ?) AND ";
1970 private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 = "layoutSetPrototype.companyId = ?";
1971 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID =
1972 new FinderPath(LayoutSetPrototypeModelImpl.ENTITY_CACHE_ENABLED,
1973 LayoutSetPrototypeModelImpl.FINDER_CACHE_ENABLED,
1974 LayoutSetPrototypeImpl.class,
1975 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByCompanyId",
1976 new String[] {
1977 Long.class.getName(),
1978
1979 Integer.class.getName(), Integer.class.getName(),
1980 OrderByComparator.class.getName()
1981 });
1982 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID =
1983 new FinderPath(LayoutSetPrototypeModelImpl.ENTITY_CACHE_ENABLED,
1984 LayoutSetPrototypeModelImpl.FINDER_CACHE_ENABLED,
1985 LayoutSetPrototypeImpl.class,
1986 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCompanyId",
1987 new String[] { Long.class.getName() },
1988 LayoutSetPrototypeModelImpl.COMPANYID_COLUMN_BITMASK);
1989 public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(LayoutSetPrototypeModelImpl.ENTITY_CACHE_ENABLED,
1990 LayoutSetPrototypeModelImpl.FINDER_CACHE_ENABLED, Long.class,
1991 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCompanyId",
1992 new String[] { Long.class.getName() });
1993
1994
2001 public List<LayoutSetPrototype> findByCompanyId(long companyId)
2002 throws SystemException {
2003 return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
2004 null);
2005 }
2006
2007
2020 public List<LayoutSetPrototype> findByCompanyId(long companyId, int start,
2021 int end) throws SystemException {
2022 return findByCompanyId(companyId, start, end, null);
2023 }
2024
2025
2039 public List<LayoutSetPrototype> findByCompanyId(long companyId, int start,
2040 int end, OrderByComparator orderByComparator) throws SystemException {
2041 boolean pagination = true;
2042 FinderPath finderPath = null;
2043 Object[] finderArgs = null;
2044
2045 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2046 (orderByComparator == null)) {
2047 pagination = false;
2048 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID;
2049 finderArgs = new Object[] { companyId };
2050 }
2051 else {
2052 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID;
2053 finderArgs = new Object[] { companyId, start, end, orderByComparator };
2054 }
2055
2056 List<LayoutSetPrototype> list = (List<LayoutSetPrototype>)FinderCacheUtil.getResult(finderPath,
2057 finderArgs, this);
2058
2059 if ((list != null) && !list.isEmpty()) {
2060 for (LayoutSetPrototype layoutSetPrototype : list) {
2061 if ((companyId != layoutSetPrototype.getCompanyId())) {
2062 list = null;
2063
2064 break;
2065 }
2066 }
2067 }
2068
2069 if (list == null) {
2070 StringBundler query = null;
2071
2072 if (orderByComparator != null) {
2073 query = new StringBundler(3 +
2074 (orderByComparator.getOrderByFields().length * 3));
2075 }
2076 else {
2077 query = new StringBundler(3);
2078 }
2079
2080 query.append(_SQL_SELECT_LAYOUTSETPROTOTYPE_WHERE);
2081
2082 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2083
2084 if (orderByComparator != null) {
2085 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2086 orderByComparator);
2087 }
2088 else
2089 if (pagination) {
2090 query.append(LayoutSetPrototypeModelImpl.ORDER_BY_JPQL);
2091 }
2092
2093 String sql = query.toString();
2094
2095 Session session = null;
2096
2097 try {
2098 session = openSession();
2099
2100 Query q = session.createQuery(sql);
2101
2102 QueryPos qPos = QueryPos.getInstance(q);
2103
2104 qPos.add(companyId);
2105
2106 if (!pagination) {
2107 list = (List<LayoutSetPrototype>)QueryUtil.list(q,
2108 getDialect(), start, end, false);
2109
2110 Collections.sort(list);
2111
2112 list = new UnmodifiableList<LayoutSetPrototype>(list);
2113 }
2114 else {
2115 list = (List<LayoutSetPrototype>)QueryUtil.list(q,
2116 getDialect(), start, end);
2117 }
2118
2119 cacheResult(list);
2120
2121 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2122 }
2123 catch (Exception e) {
2124 FinderCacheUtil.removeResult(finderPath, finderArgs);
2125
2126 throw processException(e);
2127 }
2128 finally {
2129 closeSession(session);
2130 }
2131 }
2132
2133 return list;
2134 }
2135
2136
2145 public LayoutSetPrototype findByCompanyId_First(long companyId,
2146 OrderByComparator orderByComparator)
2147 throws NoSuchLayoutSetPrototypeException, SystemException {
2148 LayoutSetPrototype layoutSetPrototype = fetchByCompanyId_First(companyId,
2149 orderByComparator);
2150
2151 if (layoutSetPrototype != null) {
2152 return layoutSetPrototype;
2153 }
2154
2155 StringBundler msg = new StringBundler(4);
2156
2157 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2158
2159 msg.append("companyId=");
2160 msg.append(companyId);
2161
2162 msg.append(StringPool.CLOSE_CURLY_BRACE);
2163
2164 throw new NoSuchLayoutSetPrototypeException(msg.toString());
2165 }
2166
2167
2175 public LayoutSetPrototype fetchByCompanyId_First(long companyId,
2176 OrderByComparator orderByComparator) throws SystemException {
2177 List<LayoutSetPrototype> list = findByCompanyId(companyId, 0, 1,
2178 orderByComparator);
2179
2180 if (!list.isEmpty()) {
2181 return list.get(0);
2182 }
2183
2184 return null;
2185 }
2186
2187
2196 public LayoutSetPrototype findByCompanyId_Last(long companyId,
2197 OrderByComparator orderByComparator)
2198 throws NoSuchLayoutSetPrototypeException, SystemException {
2199 LayoutSetPrototype layoutSetPrototype = fetchByCompanyId_Last(companyId,
2200 orderByComparator);
2201
2202 if (layoutSetPrototype != null) {
2203 return layoutSetPrototype;
2204 }
2205
2206 StringBundler msg = new StringBundler(4);
2207
2208 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2209
2210 msg.append("companyId=");
2211 msg.append(companyId);
2212
2213 msg.append(StringPool.CLOSE_CURLY_BRACE);
2214
2215 throw new NoSuchLayoutSetPrototypeException(msg.toString());
2216 }
2217
2218
2226 public LayoutSetPrototype fetchByCompanyId_Last(long companyId,
2227 OrderByComparator orderByComparator) throws SystemException {
2228 int count = countByCompanyId(companyId);
2229
2230 List<LayoutSetPrototype> list = findByCompanyId(companyId, count - 1,
2231 count, orderByComparator);
2232
2233 if (!list.isEmpty()) {
2234 return list.get(0);
2235 }
2236
2237 return null;
2238 }
2239
2240
2250 public LayoutSetPrototype[] findByCompanyId_PrevAndNext(
2251 long layoutSetPrototypeId, long companyId,
2252 OrderByComparator orderByComparator)
2253 throws NoSuchLayoutSetPrototypeException, SystemException {
2254 LayoutSetPrototype layoutSetPrototype = findByPrimaryKey(layoutSetPrototypeId);
2255
2256 Session session = null;
2257
2258 try {
2259 session = openSession();
2260
2261 LayoutSetPrototype[] array = new LayoutSetPrototypeImpl[3];
2262
2263 array[0] = getByCompanyId_PrevAndNext(session, layoutSetPrototype,
2264 companyId, orderByComparator, true);
2265
2266 array[1] = layoutSetPrototype;
2267
2268 array[2] = getByCompanyId_PrevAndNext(session, layoutSetPrototype,
2269 companyId, orderByComparator, false);
2270
2271 return array;
2272 }
2273 catch (Exception e) {
2274 throw processException(e);
2275 }
2276 finally {
2277 closeSession(session);
2278 }
2279 }
2280
2281 protected LayoutSetPrototype getByCompanyId_PrevAndNext(Session session,
2282 LayoutSetPrototype layoutSetPrototype, long companyId,
2283 OrderByComparator orderByComparator, boolean previous) {
2284 StringBundler query = null;
2285
2286 if (orderByComparator != null) {
2287 query = new StringBundler(6 +
2288 (orderByComparator.getOrderByFields().length * 6));
2289 }
2290 else {
2291 query = new StringBundler(3);
2292 }
2293
2294 query.append(_SQL_SELECT_LAYOUTSETPROTOTYPE_WHERE);
2295
2296 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2297
2298 if (orderByComparator != null) {
2299 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2300
2301 if (orderByConditionFields.length > 0) {
2302 query.append(WHERE_AND);
2303 }
2304
2305 for (int i = 0; i < orderByConditionFields.length; i++) {
2306 query.append(_ORDER_BY_ENTITY_ALIAS);
2307 query.append(orderByConditionFields[i]);
2308
2309 if ((i + 1) < orderByConditionFields.length) {
2310 if (orderByComparator.isAscending() ^ previous) {
2311 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2312 }
2313 else {
2314 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2315 }
2316 }
2317 else {
2318 if (orderByComparator.isAscending() ^ previous) {
2319 query.append(WHERE_GREATER_THAN);
2320 }
2321 else {
2322 query.append(WHERE_LESSER_THAN);
2323 }
2324 }
2325 }
2326
2327 query.append(ORDER_BY_CLAUSE);
2328
2329 String[] orderByFields = orderByComparator.getOrderByFields();
2330
2331 for (int i = 0; i < orderByFields.length; i++) {
2332 query.append(_ORDER_BY_ENTITY_ALIAS);
2333 query.append(orderByFields[i]);
2334
2335 if ((i + 1) < orderByFields.length) {
2336 if (orderByComparator.isAscending() ^ previous) {
2337 query.append(ORDER_BY_ASC_HAS_NEXT);
2338 }
2339 else {
2340 query.append(ORDER_BY_DESC_HAS_NEXT);
2341 }
2342 }
2343 else {
2344 if (orderByComparator.isAscending() ^ previous) {
2345 query.append(ORDER_BY_ASC);
2346 }
2347 else {
2348 query.append(ORDER_BY_DESC);
2349 }
2350 }
2351 }
2352 }
2353 else {
2354 query.append(LayoutSetPrototypeModelImpl.ORDER_BY_JPQL);
2355 }
2356
2357 String sql = query.toString();
2358
2359 Query q = session.createQuery(sql);
2360
2361 q.setFirstResult(0);
2362 q.setMaxResults(2);
2363
2364 QueryPos qPos = QueryPos.getInstance(q);
2365
2366 qPos.add(companyId);
2367
2368 if (orderByComparator != null) {
2369 Object[] values = orderByComparator.getOrderByConditionValues(layoutSetPrototype);
2370
2371 for (Object value : values) {
2372 qPos.add(value);
2373 }
2374 }
2375
2376 List<LayoutSetPrototype> list = q.list();
2377
2378 if (list.size() == 2) {
2379 return list.get(1);
2380 }
2381 else {
2382 return null;
2383 }
2384 }
2385
2386
2393 public List<LayoutSetPrototype> filterFindByCompanyId(long companyId)
2394 throws SystemException {
2395 return filterFindByCompanyId(companyId, QueryUtil.ALL_POS,
2396 QueryUtil.ALL_POS, null);
2397 }
2398
2399
2412 public List<LayoutSetPrototype> filterFindByCompanyId(long companyId,
2413 int start, int end) throws SystemException {
2414 return filterFindByCompanyId(companyId, start, end, null);
2415 }
2416
2417
2431 public List<LayoutSetPrototype> filterFindByCompanyId(long companyId,
2432 int start, int end, OrderByComparator orderByComparator)
2433 throws SystemException {
2434 if (!InlineSQLHelperUtil.isEnabled()) {
2435 return findByCompanyId(companyId, start, end, orderByComparator);
2436 }
2437
2438 StringBundler query = null;
2439
2440 if (orderByComparator != null) {
2441 query = new StringBundler(3 +
2442 (orderByComparator.getOrderByFields().length * 3));
2443 }
2444 else {
2445 query = new StringBundler(3);
2446 }
2447
2448 if (getDB().isSupportsInlineDistinct()) {
2449 query.append(_FILTER_SQL_SELECT_LAYOUTSETPROTOTYPE_WHERE);
2450 }
2451 else {
2452 query.append(_FILTER_SQL_SELECT_LAYOUTSETPROTOTYPE_NO_INLINE_DISTINCT_WHERE_1);
2453 }
2454
2455 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2456
2457 if (!getDB().isSupportsInlineDistinct()) {
2458 query.append(_FILTER_SQL_SELECT_LAYOUTSETPROTOTYPE_NO_INLINE_DISTINCT_WHERE_2);
2459 }
2460
2461 if (orderByComparator != null) {
2462 if (getDB().isSupportsInlineDistinct()) {
2463 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2464 orderByComparator);
2465 }
2466 else {
2467 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
2468 orderByComparator);
2469 }
2470 }
2471 else {
2472 if (getDB().isSupportsInlineDistinct()) {
2473 query.append(LayoutSetPrototypeModelImpl.ORDER_BY_JPQL);
2474 }
2475 else {
2476 query.append(LayoutSetPrototypeModelImpl.ORDER_BY_SQL);
2477 }
2478 }
2479
2480 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2481 LayoutSetPrototype.class.getName(),
2482 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
2483
2484 Session session = null;
2485
2486 try {
2487 session = openSession();
2488
2489 SQLQuery q = session.createSQLQuery(sql);
2490
2491 if (getDB().isSupportsInlineDistinct()) {
2492 q.addEntity(_FILTER_ENTITY_ALIAS, LayoutSetPrototypeImpl.class);
2493 }
2494 else {
2495 q.addEntity(_FILTER_ENTITY_TABLE, LayoutSetPrototypeImpl.class);
2496 }
2497
2498 QueryPos qPos = QueryPos.getInstance(q);
2499
2500 qPos.add(companyId);
2501
2502 return (List<LayoutSetPrototype>)QueryUtil.list(q, getDialect(),
2503 start, end);
2504 }
2505 catch (Exception e) {
2506 throw processException(e);
2507 }
2508 finally {
2509 closeSession(session);
2510 }
2511 }
2512
2513
2523 public LayoutSetPrototype[] filterFindByCompanyId_PrevAndNext(
2524 long layoutSetPrototypeId, long companyId,
2525 OrderByComparator orderByComparator)
2526 throws NoSuchLayoutSetPrototypeException, SystemException {
2527 if (!InlineSQLHelperUtil.isEnabled()) {
2528 return findByCompanyId_PrevAndNext(layoutSetPrototypeId, companyId,
2529 orderByComparator);
2530 }
2531
2532 LayoutSetPrototype layoutSetPrototype = findByPrimaryKey(layoutSetPrototypeId);
2533
2534 Session session = null;
2535
2536 try {
2537 session = openSession();
2538
2539 LayoutSetPrototype[] array = new LayoutSetPrototypeImpl[3];
2540
2541 array[0] = filterGetByCompanyId_PrevAndNext(session,
2542 layoutSetPrototype, companyId, orderByComparator, true);
2543
2544 array[1] = layoutSetPrototype;
2545
2546 array[2] = filterGetByCompanyId_PrevAndNext(session,
2547 layoutSetPrototype, companyId, orderByComparator, false);
2548
2549 return array;
2550 }
2551 catch (Exception e) {
2552 throw processException(e);
2553 }
2554 finally {
2555 closeSession(session);
2556 }
2557 }
2558
2559 protected LayoutSetPrototype filterGetByCompanyId_PrevAndNext(
2560 Session session, LayoutSetPrototype layoutSetPrototype, long companyId,
2561 OrderByComparator orderByComparator, boolean previous) {
2562 StringBundler query = null;
2563
2564 if (orderByComparator != null) {
2565 query = new StringBundler(6 +
2566 (orderByComparator.getOrderByFields().length * 6));
2567 }
2568 else {
2569 query = new StringBundler(3);
2570 }
2571
2572 if (getDB().isSupportsInlineDistinct()) {
2573 query.append(_FILTER_SQL_SELECT_LAYOUTSETPROTOTYPE_WHERE);
2574 }
2575 else {
2576 query.append(_FILTER_SQL_SELECT_LAYOUTSETPROTOTYPE_NO_INLINE_DISTINCT_WHERE_1);
2577 }
2578
2579 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2580
2581 if (!getDB().isSupportsInlineDistinct()) {
2582 query.append(_FILTER_SQL_SELECT_LAYOUTSETPROTOTYPE_NO_INLINE_DISTINCT_WHERE_2);
2583 }
2584
2585 if (orderByComparator != null) {
2586 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2587
2588 if (orderByConditionFields.length > 0) {
2589 query.append(WHERE_AND);
2590 }
2591
2592 for (int i = 0; i < orderByConditionFields.length; i++) {
2593 if (getDB().isSupportsInlineDistinct()) {
2594 query.append(_ORDER_BY_ENTITY_ALIAS);
2595 }
2596 else {
2597 query.append(_ORDER_BY_ENTITY_TABLE);
2598 }
2599
2600 query.append(orderByConditionFields[i]);
2601
2602 if ((i + 1) < orderByConditionFields.length) {
2603 if (orderByComparator.isAscending() ^ previous) {
2604 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2605 }
2606 else {
2607 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2608 }
2609 }
2610 else {
2611 if (orderByComparator.isAscending() ^ previous) {
2612 query.append(WHERE_GREATER_THAN);
2613 }
2614 else {
2615 query.append(WHERE_LESSER_THAN);
2616 }
2617 }
2618 }
2619
2620 query.append(ORDER_BY_CLAUSE);
2621
2622 String[] orderByFields = orderByComparator.getOrderByFields();
2623
2624 for (int i = 0; i < orderByFields.length; i++) {
2625 if (getDB().isSupportsInlineDistinct()) {
2626 query.append(_ORDER_BY_ENTITY_ALIAS);
2627 }
2628 else {
2629 query.append(_ORDER_BY_ENTITY_TABLE);
2630 }
2631
2632 query.append(orderByFields[i]);
2633
2634 if ((i + 1) < orderByFields.length) {
2635 if (orderByComparator.isAscending() ^ previous) {
2636 query.append(ORDER_BY_ASC_HAS_NEXT);
2637 }
2638 else {
2639 query.append(ORDER_BY_DESC_HAS_NEXT);
2640 }
2641 }
2642 else {
2643 if (orderByComparator.isAscending() ^ previous) {
2644 query.append(ORDER_BY_ASC);
2645 }
2646 else {
2647 query.append(ORDER_BY_DESC);
2648 }
2649 }
2650 }
2651 }
2652 else {
2653 if (getDB().isSupportsInlineDistinct()) {
2654 query.append(LayoutSetPrototypeModelImpl.ORDER_BY_JPQL);
2655 }
2656 else {
2657 query.append(LayoutSetPrototypeModelImpl.ORDER_BY_SQL);
2658 }
2659 }
2660
2661 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2662 LayoutSetPrototype.class.getName(),
2663 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
2664
2665 SQLQuery q = session.createSQLQuery(sql);
2666
2667 q.setFirstResult(0);
2668 q.setMaxResults(2);
2669
2670 if (getDB().isSupportsInlineDistinct()) {
2671 q.addEntity(_FILTER_ENTITY_ALIAS, LayoutSetPrototypeImpl.class);
2672 }
2673 else {
2674 q.addEntity(_FILTER_ENTITY_TABLE, LayoutSetPrototypeImpl.class);
2675 }
2676
2677 QueryPos qPos = QueryPos.getInstance(q);
2678
2679 qPos.add(companyId);
2680
2681 if (orderByComparator != null) {
2682 Object[] values = orderByComparator.getOrderByConditionValues(layoutSetPrototype);
2683
2684 for (Object value : values) {
2685 qPos.add(value);
2686 }
2687 }
2688
2689 List<LayoutSetPrototype> list = q.list();
2690
2691 if (list.size() == 2) {
2692 return list.get(1);
2693 }
2694 else {
2695 return null;
2696 }
2697 }
2698
2699
2705 public void removeByCompanyId(long companyId) throws SystemException {
2706 for (LayoutSetPrototype layoutSetPrototype : findByCompanyId(
2707 companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
2708 remove(layoutSetPrototype);
2709 }
2710 }
2711
2712
2719 public int countByCompanyId(long companyId) throws SystemException {
2720 FinderPath finderPath = FINDER_PATH_COUNT_BY_COMPANYID;
2721
2722 Object[] finderArgs = new Object[] { companyId };
2723
2724 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
2725 this);
2726
2727 if (count == null) {
2728 StringBundler query = new StringBundler(2);
2729
2730 query.append(_SQL_COUNT_LAYOUTSETPROTOTYPE_WHERE);
2731
2732 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2733
2734 String sql = query.toString();
2735
2736 Session session = null;
2737
2738 try {
2739 session = openSession();
2740
2741 Query q = session.createQuery(sql);
2742
2743 QueryPos qPos = QueryPos.getInstance(q);
2744
2745 qPos.add(companyId);
2746
2747 count = (Long)q.uniqueResult();
2748
2749 FinderCacheUtil.putResult(finderPath, finderArgs, count);
2750 }
2751 catch (Exception e) {
2752 FinderCacheUtil.removeResult(finderPath, finderArgs);
2753
2754 throw processException(e);
2755 }
2756 finally {
2757 closeSession(session);
2758 }
2759 }
2760
2761 return count.intValue();
2762 }
2763
2764
2771 public int filterCountByCompanyId(long companyId) throws SystemException {
2772 if (!InlineSQLHelperUtil.isEnabled()) {
2773 return countByCompanyId(companyId);
2774 }
2775
2776 StringBundler query = new StringBundler(2);
2777
2778 query.append(_FILTER_SQL_COUNT_LAYOUTSETPROTOTYPE_WHERE);
2779
2780 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2781
2782 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2783 LayoutSetPrototype.class.getName(),
2784 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
2785
2786 Session session = null;
2787
2788 try {
2789 session = openSession();
2790
2791 SQLQuery q = session.createSQLQuery(sql);
2792
2793 q.addScalar(COUNT_COLUMN_NAME,
2794 com.liferay.portal.kernel.dao.orm.Type.LONG);
2795
2796 QueryPos qPos = QueryPos.getInstance(q);
2797
2798 qPos.add(companyId);
2799
2800 Long count = (Long)q.uniqueResult();
2801
2802 return count.intValue();
2803 }
2804 catch (Exception e) {
2805 throw processException(e);
2806 }
2807 finally {
2808 closeSession(session);
2809 }
2810 }
2811
2812 private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "layoutSetPrototype.companyId = ?";
2813 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_A = new FinderPath(LayoutSetPrototypeModelImpl.ENTITY_CACHE_ENABLED,
2814 LayoutSetPrototypeModelImpl.FINDER_CACHE_ENABLED,
2815 LayoutSetPrototypeImpl.class,
2816 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_A",
2817 new String[] {
2818 Long.class.getName(), Boolean.class.getName(),
2819
2820 Integer.class.getName(), Integer.class.getName(),
2821 OrderByComparator.class.getName()
2822 });
2823 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_A = new FinderPath(LayoutSetPrototypeModelImpl.ENTITY_CACHE_ENABLED,
2824 LayoutSetPrototypeModelImpl.FINDER_CACHE_ENABLED,
2825 LayoutSetPrototypeImpl.class,
2826 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_A",
2827 new String[] { Long.class.getName(), Boolean.class.getName() },
2828 LayoutSetPrototypeModelImpl.COMPANYID_COLUMN_BITMASK |
2829 LayoutSetPrototypeModelImpl.ACTIVE_COLUMN_BITMASK);
2830 public static final FinderPath FINDER_PATH_COUNT_BY_C_A = new FinderPath(LayoutSetPrototypeModelImpl.ENTITY_CACHE_ENABLED,
2831 LayoutSetPrototypeModelImpl.FINDER_CACHE_ENABLED, Long.class,
2832 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_A",
2833 new String[] { Long.class.getName(), Boolean.class.getName() });
2834
2835
2843 public List<LayoutSetPrototype> findByC_A(long companyId, boolean active)
2844 throws SystemException {
2845 return findByC_A(companyId, active, QueryUtil.ALL_POS,
2846 QueryUtil.ALL_POS, null);
2847 }
2848
2849
2863 public List<LayoutSetPrototype> findByC_A(long companyId, boolean active,
2864 int start, int end) throws SystemException {
2865 return findByC_A(companyId, active, start, end, null);
2866 }
2867
2868
2883 public List<LayoutSetPrototype> findByC_A(long companyId, boolean active,
2884 int start, int end, OrderByComparator orderByComparator)
2885 throws SystemException {
2886 boolean pagination = true;
2887 FinderPath finderPath = null;
2888 Object[] finderArgs = null;
2889
2890 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2891 (orderByComparator == null)) {
2892 pagination = false;
2893 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_A;
2894 finderArgs = new Object[] { companyId, active };
2895 }
2896 else {
2897 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_A;
2898 finderArgs = new Object[] {
2899 companyId, active,
2900
2901 start, end, orderByComparator
2902 };
2903 }
2904
2905 List<LayoutSetPrototype> list = (List<LayoutSetPrototype>)FinderCacheUtil.getResult(finderPath,
2906 finderArgs, this);
2907
2908 if ((list != null) && !list.isEmpty()) {
2909 for (LayoutSetPrototype layoutSetPrototype : list) {
2910 if ((companyId != layoutSetPrototype.getCompanyId()) ||
2911 (active != layoutSetPrototype.getActive())) {
2912 list = null;
2913
2914 break;
2915 }
2916 }
2917 }
2918
2919 if (list == null) {
2920 StringBundler query = null;
2921
2922 if (orderByComparator != null) {
2923 query = new StringBundler(4 +
2924 (orderByComparator.getOrderByFields().length * 3));
2925 }
2926 else {
2927 query = new StringBundler(4);
2928 }
2929
2930 query.append(_SQL_SELECT_LAYOUTSETPROTOTYPE_WHERE);
2931
2932 query.append(_FINDER_COLUMN_C_A_COMPANYID_2);
2933
2934 query.append(_FINDER_COLUMN_C_A_ACTIVE_2);
2935
2936 if (orderByComparator != null) {
2937 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2938 orderByComparator);
2939 }
2940 else
2941 if (pagination) {
2942 query.append(LayoutSetPrototypeModelImpl.ORDER_BY_JPQL);
2943 }
2944
2945 String sql = query.toString();
2946
2947 Session session = null;
2948
2949 try {
2950 session = openSession();
2951
2952 Query q = session.createQuery(sql);
2953
2954 QueryPos qPos = QueryPos.getInstance(q);
2955
2956 qPos.add(companyId);
2957
2958 qPos.add(active);
2959
2960 if (!pagination) {
2961 list = (List<LayoutSetPrototype>)QueryUtil.list(q,
2962 getDialect(), start, end, false);
2963
2964 Collections.sort(list);
2965
2966 list = new UnmodifiableList<LayoutSetPrototype>(list);
2967 }
2968 else {
2969 list = (List<LayoutSetPrototype>)QueryUtil.list(q,
2970 getDialect(), start, end);
2971 }
2972
2973 cacheResult(list);
2974
2975 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2976 }
2977 catch (Exception e) {
2978 FinderCacheUtil.removeResult(finderPath, finderArgs);
2979
2980 throw processException(e);
2981 }
2982 finally {
2983 closeSession(session);
2984 }
2985 }
2986
2987 return list;
2988 }
2989
2990
3000 public LayoutSetPrototype findByC_A_First(long companyId, boolean active,
3001 OrderByComparator orderByComparator)
3002 throws NoSuchLayoutSetPrototypeException, SystemException {
3003 LayoutSetPrototype layoutSetPrototype = fetchByC_A_First(companyId,
3004 active, orderByComparator);
3005
3006 if (layoutSetPrototype != null) {
3007 return layoutSetPrototype;
3008 }
3009
3010 StringBundler msg = new StringBundler(6);
3011
3012 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3013
3014 msg.append("companyId=");
3015 msg.append(companyId);
3016
3017 msg.append(", active=");
3018 msg.append(active);
3019
3020 msg.append(StringPool.CLOSE_CURLY_BRACE);
3021
3022 throw new NoSuchLayoutSetPrototypeException(msg.toString());
3023 }
3024
3025
3034 public LayoutSetPrototype fetchByC_A_First(long companyId, boolean active,
3035 OrderByComparator orderByComparator) throws SystemException {
3036 List<LayoutSetPrototype> list = findByC_A(companyId, active, 0, 1,
3037 orderByComparator);
3038
3039 if (!list.isEmpty()) {
3040 return list.get(0);
3041 }
3042
3043 return null;
3044 }
3045
3046
3056 public LayoutSetPrototype findByC_A_Last(long companyId, boolean active,
3057 OrderByComparator orderByComparator)
3058 throws NoSuchLayoutSetPrototypeException, SystemException {
3059 LayoutSetPrototype layoutSetPrototype = fetchByC_A_Last(companyId,
3060 active, orderByComparator);
3061
3062 if (layoutSetPrototype != null) {
3063 return layoutSetPrototype;
3064 }
3065
3066 StringBundler msg = new StringBundler(6);
3067
3068 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3069
3070 msg.append("companyId=");
3071 msg.append(companyId);
3072
3073 msg.append(", active=");
3074 msg.append(active);
3075
3076 msg.append(StringPool.CLOSE_CURLY_BRACE);
3077
3078 throw new NoSuchLayoutSetPrototypeException(msg.toString());
3079 }
3080
3081
3090 public LayoutSetPrototype fetchByC_A_Last(long companyId, boolean active,
3091 OrderByComparator orderByComparator) throws SystemException {
3092 int count = countByC_A(companyId, active);
3093
3094 List<LayoutSetPrototype> list = findByC_A(companyId, active, count - 1,
3095 count, orderByComparator);
3096
3097 if (!list.isEmpty()) {
3098 return list.get(0);
3099 }
3100
3101 return null;
3102 }
3103
3104
3115 public LayoutSetPrototype[] findByC_A_PrevAndNext(
3116 long layoutSetPrototypeId, long companyId, boolean active,
3117 OrderByComparator orderByComparator)
3118 throws NoSuchLayoutSetPrototypeException, SystemException {
3119 LayoutSetPrototype layoutSetPrototype = findByPrimaryKey(layoutSetPrototypeId);
3120
3121 Session session = null;
3122
3123 try {
3124 session = openSession();
3125
3126 LayoutSetPrototype[] array = new LayoutSetPrototypeImpl[3];
3127
3128 array[0] = getByC_A_PrevAndNext(session, layoutSetPrototype,
3129 companyId, active, orderByComparator, true);
3130
3131 array[1] = layoutSetPrototype;
3132
3133 array[2] = getByC_A_PrevAndNext(session, layoutSetPrototype,
3134 companyId, active, orderByComparator, false);
3135
3136 return array;
3137 }
3138 catch (Exception e) {
3139 throw processException(e);
3140 }
3141 finally {
3142 closeSession(session);
3143 }
3144 }
3145
3146 protected LayoutSetPrototype getByC_A_PrevAndNext(Session session,
3147 LayoutSetPrototype layoutSetPrototype, long companyId, boolean active,
3148 OrderByComparator orderByComparator, boolean previous) {
3149 StringBundler query = null;
3150
3151 if (orderByComparator != null) {
3152 query = new StringBundler(6 +
3153 (orderByComparator.getOrderByFields().length * 6));
3154 }
3155 else {
3156 query = new StringBundler(3);
3157 }
3158
3159 query.append(_SQL_SELECT_LAYOUTSETPROTOTYPE_WHERE);
3160
3161 query.append(_FINDER_COLUMN_C_A_COMPANYID_2);
3162
3163 query.append(_FINDER_COLUMN_C_A_ACTIVE_2);
3164
3165 if (orderByComparator != null) {
3166 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3167
3168 if (orderByConditionFields.length > 0) {
3169 query.append(WHERE_AND);
3170 }
3171
3172 for (int i = 0; i < orderByConditionFields.length; i++) {
3173 query.append(_ORDER_BY_ENTITY_ALIAS);
3174 query.append(orderByConditionFields[i]);
3175
3176 if ((i + 1) < orderByConditionFields.length) {
3177 if (orderByComparator.isAscending() ^ previous) {
3178 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3179 }
3180 else {
3181 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3182 }
3183 }
3184 else {
3185 if (orderByComparator.isAscending() ^ previous) {
3186 query.append(WHERE_GREATER_THAN);
3187 }
3188 else {
3189 query.append(WHERE_LESSER_THAN);
3190 }
3191 }
3192 }
3193
3194 query.append(ORDER_BY_CLAUSE);
3195
3196 String[] orderByFields = orderByComparator.getOrderByFields();
3197
3198 for (int i = 0; i < orderByFields.length; i++) {
3199 query.append(_ORDER_BY_ENTITY_ALIAS);
3200 query.append(orderByFields[i]);
3201
3202 if ((i + 1) < orderByFields.length) {
3203 if (orderByComparator.isAscending() ^ previous) {
3204 query.append(ORDER_BY_ASC_HAS_NEXT);
3205 }
3206 else {
3207 query.append(ORDER_BY_DESC_HAS_NEXT);
3208 }
3209 }
3210 else {
3211 if (orderByComparator.isAscending() ^ previous) {
3212 query.append(ORDER_BY_ASC);
3213 }
3214 else {
3215 query.append(ORDER_BY_DESC);
3216 }
3217 }
3218 }
3219 }
3220 else {
3221 query.append(LayoutSetPrototypeModelImpl.ORDER_BY_JPQL);
3222 }
3223
3224 String sql = query.toString();
3225
3226 Query q = session.createQuery(sql);
3227
3228 q.setFirstResult(0);
3229 q.setMaxResults(2);
3230
3231 QueryPos qPos = QueryPos.getInstance(q);
3232
3233 qPos.add(companyId);
3234
3235 qPos.add(active);
3236
3237 if (orderByComparator != null) {
3238 Object[] values = orderByComparator.getOrderByConditionValues(layoutSetPrototype);
3239
3240 for (Object value : values) {
3241 qPos.add(value);
3242 }
3243 }
3244
3245 List<LayoutSetPrototype> list = q.list();
3246
3247 if (list.size() == 2) {
3248 return list.get(1);
3249 }
3250 else {
3251 return null;
3252 }
3253 }
3254
3255
3263 public List<LayoutSetPrototype> filterFindByC_A(long companyId,
3264 boolean active) throws SystemException {
3265 return filterFindByC_A(companyId, active, QueryUtil.ALL_POS,
3266 QueryUtil.ALL_POS, null);
3267 }
3268
3269
3283 public List<LayoutSetPrototype> filterFindByC_A(long companyId,
3284 boolean active, int start, int end) throws SystemException {
3285 return filterFindByC_A(companyId, active, start, end, null);
3286 }
3287
3288
3303 public List<LayoutSetPrototype> filterFindByC_A(long companyId,
3304 boolean active, int start, int end, OrderByComparator orderByComparator)
3305 throws SystemException {
3306 if (!InlineSQLHelperUtil.isEnabled()) {
3307 return findByC_A(companyId, active, start, end, orderByComparator);
3308 }
3309
3310 StringBundler query = null;
3311
3312 if (orderByComparator != null) {
3313 query = new StringBundler(4 +
3314 (orderByComparator.getOrderByFields().length * 3));
3315 }
3316 else {
3317 query = new StringBundler(4);
3318 }
3319
3320 if (getDB().isSupportsInlineDistinct()) {
3321 query.append(_FILTER_SQL_SELECT_LAYOUTSETPROTOTYPE_WHERE);
3322 }
3323 else {
3324 query.append(_FILTER_SQL_SELECT_LAYOUTSETPROTOTYPE_NO_INLINE_DISTINCT_WHERE_1);
3325 }
3326
3327 query.append(_FINDER_COLUMN_C_A_COMPANYID_2);
3328
3329 query.append(_FINDER_COLUMN_C_A_ACTIVE_2);
3330
3331 if (!getDB().isSupportsInlineDistinct()) {
3332 query.append(_FILTER_SQL_SELECT_LAYOUTSETPROTOTYPE_NO_INLINE_DISTINCT_WHERE_2);
3333 }
3334
3335 if (orderByComparator != null) {
3336 if (getDB().isSupportsInlineDistinct()) {
3337 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3338 orderByComparator);
3339 }
3340 else {
3341 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
3342 orderByComparator);
3343 }
3344 }
3345 else {
3346 if (getDB().isSupportsInlineDistinct()) {
3347 query.append(LayoutSetPrototypeModelImpl.ORDER_BY_JPQL);
3348 }
3349 else {
3350 query.append(LayoutSetPrototypeModelImpl.ORDER_BY_SQL);
3351 }
3352 }
3353
3354 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3355 LayoutSetPrototype.class.getName(),
3356 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
3357
3358 Session session = null;
3359
3360 try {
3361 session = openSession();
3362
3363 SQLQuery q = session.createSQLQuery(sql);
3364
3365 if (getDB().isSupportsInlineDistinct()) {
3366 q.addEntity(_FILTER_ENTITY_ALIAS, LayoutSetPrototypeImpl.class);
3367 }
3368 else {
3369 q.addEntity(_FILTER_ENTITY_TABLE, LayoutSetPrototypeImpl.class);
3370 }
3371
3372 QueryPos qPos = QueryPos.getInstance(q);
3373
3374 qPos.add(companyId);
3375
3376 qPos.add(active);
3377
3378 return (List<LayoutSetPrototype>)QueryUtil.list(q, getDialect(),
3379 start, end);
3380 }
3381 catch (Exception e) {
3382 throw processException(e);
3383 }
3384 finally {
3385 closeSession(session);
3386 }
3387 }
3388
3389
3400 public LayoutSetPrototype[] filterFindByC_A_PrevAndNext(
3401 long layoutSetPrototypeId, long companyId, boolean active,
3402 OrderByComparator orderByComparator)
3403 throws NoSuchLayoutSetPrototypeException, SystemException {
3404 if (!InlineSQLHelperUtil.isEnabled()) {
3405 return findByC_A_PrevAndNext(layoutSetPrototypeId, companyId,
3406 active, orderByComparator);
3407 }
3408
3409 LayoutSetPrototype layoutSetPrototype = findByPrimaryKey(layoutSetPrototypeId);
3410
3411 Session session = null;
3412
3413 try {
3414 session = openSession();
3415
3416 LayoutSetPrototype[] array = new LayoutSetPrototypeImpl[3];
3417
3418 array[0] = filterGetByC_A_PrevAndNext(session, layoutSetPrototype,
3419 companyId, active, orderByComparator, true);
3420
3421 array[1] = layoutSetPrototype;
3422
3423 array[2] = filterGetByC_A_PrevAndNext(session, layoutSetPrototype,
3424 companyId, active, orderByComparator, false);
3425
3426 return array;
3427 }
3428 catch (Exception e) {
3429 throw processException(e);
3430 }
3431 finally {
3432 closeSession(session);
3433 }
3434 }
3435
3436 protected LayoutSetPrototype filterGetByC_A_PrevAndNext(Session session,
3437 LayoutSetPrototype layoutSetPrototype, long companyId, boolean active,
3438 OrderByComparator orderByComparator, boolean previous) {
3439 StringBundler query = null;
3440
3441 if (orderByComparator != null) {
3442 query = new StringBundler(6 +
3443 (orderByComparator.getOrderByFields().length * 6));
3444 }
3445 else {
3446 query = new StringBundler(3);
3447 }
3448
3449 if (getDB().isSupportsInlineDistinct()) {
3450 query.append(_FILTER_SQL_SELECT_LAYOUTSETPROTOTYPE_WHERE);
3451 }
3452 else {
3453 query.append(_FILTER_SQL_SELECT_LAYOUTSETPROTOTYPE_NO_INLINE_DISTINCT_WHERE_1);
3454 }
3455
3456 query.append(_FINDER_COLUMN_C_A_COMPANYID_2);
3457
3458 query.append(_FINDER_COLUMN_C_A_ACTIVE_2);
3459
3460 if (!getDB().isSupportsInlineDistinct()) {
3461 query.append(_FILTER_SQL_SELECT_LAYOUTSETPROTOTYPE_NO_INLINE_DISTINCT_WHERE_2);
3462 }
3463
3464 if (orderByComparator != null) {
3465 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3466
3467 if (orderByConditionFields.length > 0) {
3468 query.append(WHERE_AND);
3469 }
3470
3471 for (int i = 0; i < orderByConditionFields.length; i++) {
3472 if (getDB().isSupportsInlineDistinct()) {
3473 query.append(_ORDER_BY_ENTITY_ALIAS);
3474 }
3475 else {
3476 query.append(_ORDER_BY_ENTITY_TABLE);
3477 }
3478
3479 query.append(orderByConditionFields[i]);
3480
3481 if ((i + 1) < orderByConditionFields.length) {
3482 if (orderByComparator.isAscending() ^ previous) {
3483 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3484 }
3485 else {
3486 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3487 }
3488 }
3489 else {
3490 if (orderByComparator.isAscending() ^ previous) {
3491 query.append(WHERE_GREATER_THAN);
3492 }
3493 else {
3494 query.append(WHERE_LESSER_THAN);
3495 }
3496 }
3497 }
3498
3499 query.append(ORDER_BY_CLAUSE);
3500
3501 String[] orderByFields = orderByComparator.getOrderByFields();
3502
3503 for (int i = 0; i < orderByFields.length; i++) {
3504 if (getDB().isSupportsInlineDistinct()) {
3505 query.append(_ORDER_BY_ENTITY_ALIAS);
3506 }
3507 else {
3508 query.append(_ORDER_BY_ENTITY_TABLE);
3509 }
3510
3511 query.append(orderByFields[i]);
3512
3513 if ((i + 1) < orderByFields.length) {
3514 if (orderByComparator.isAscending() ^ previous) {
3515 query.append(ORDER_BY_ASC_HAS_NEXT);
3516 }
3517 else {
3518 query.append(ORDER_BY_DESC_HAS_NEXT);
3519 }
3520 }
3521 else {
3522 if (orderByComparator.isAscending() ^ previous) {
3523 query.append(ORDER_BY_ASC);
3524 }
3525 else {
3526 query.append(ORDER_BY_DESC);
3527 }
3528 }
3529 }
3530 }
3531 else {
3532 if (getDB().isSupportsInlineDistinct()) {
3533 query.append(LayoutSetPrototypeModelImpl.ORDER_BY_JPQL);
3534 }
3535 else {
3536 query.append(LayoutSetPrototypeModelImpl.ORDER_BY_SQL);
3537 }
3538 }
3539
3540 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3541 LayoutSetPrototype.class.getName(),
3542 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
3543
3544 SQLQuery q = session.createSQLQuery(sql);
3545
3546 q.setFirstResult(0);
3547 q.setMaxResults(2);
3548
3549 if (getDB().isSupportsInlineDistinct()) {
3550 q.addEntity(_FILTER_ENTITY_ALIAS, LayoutSetPrototypeImpl.class);
3551 }
3552 else {
3553 q.addEntity(_FILTER_ENTITY_TABLE, LayoutSetPrototypeImpl.class);
3554 }
3555
3556 QueryPos qPos = QueryPos.getInstance(q);
3557
3558 qPos.add(companyId);
3559
3560 qPos.add(active);
3561
3562 if (orderByComparator != null) {
3563 Object[] values = orderByComparator.getOrderByConditionValues(layoutSetPrototype);
3564
3565 for (Object value : values) {
3566 qPos.add(value);
3567 }
3568 }
3569
3570 List<LayoutSetPrototype> list = q.list();
3571
3572 if (list.size() == 2) {
3573 return list.get(1);
3574 }
3575 else {
3576 return null;
3577 }
3578 }
3579
3580
3587 public void removeByC_A(long companyId, boolean active)
3588 throws SystemException {
3589 for (LayoutSetPrototype layoutSetPrototype : findByC_A(companyId,
3590 active, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
3591 remove(layoutSetPrototype);
3592 }
3593 }
3594
3595
3603 public int countByC_A(long companyId, boolean active)
3604 throws SystemException {
3605 FinderPath finderPath = FINDER_PATH_COUNT_BY_C_A;
3606
3607 Object[] finderArgs = new Object[] { companyId, active };
3608
3609 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
3610 this);
3611
3612 if (count == null) {
3613 StringBundler query = new StringBundler(3);
3614
3615 query.append(_SQL_COUNT_LAYOUTSETPROTOTYPE_WHERE);
3616
3617 query.append(_FINDER_COLUMN_C_A_COMPANYID_2);
3618
3619 query.append(_FINDER_COLUMN_C_A_ACTIVE_2);
3620
3621 String sql = query.toString();
3622
3623 Session session = null;
3624
3625 try {
3626 session = openSession();
3627
3628 Query q = session.createQuery(sql);
3629
3630 QueryPos qPos = QueryPos.getInstance(q);
3631
3632 qPos.add(companyId);
3633
3634 qPos.add(active);
3635
3636 count = (Long)q.uniqueResult();
3637
3638 FinderCacheUtil.putResult(finderPath, finderArgs, count);
3639 }
3640 catch (Exception e) {
3641 FinderCacheUtil.removeResult(finderPath, finderArgs);
3642
3643 throw processException(e);
3644 }
3645 finally {
3646 closeSession(session);
3647 }
3648 }
3649
3650 return count.intValue();
3651 }
3652
3653
3661 public int filterCountByC_A(long companyId, boolean active)
3662 throws SystemException {
3663 if (!InlineSQLHelperUtil.isEnabled()) {
3664 return countByC_A(companyId, active);
3665 }
3666
3667 StringBundler query = new StringBundler(3);
3668
3669 query.append(_FILTER_SQL_COUNT_LAYOUTSETPROTOTYPE_WHERE);
3670
3671 query.append(_FINDER_COLUMN_C_A_COMPANYID_2);
3672
3673 query.append(_FINDER_COLUMN_C_A_ACTIVE_2);
3674
3675 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3676 LayoutSetPrototype.class.getName(),
3677 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
3678
3679 Session session = null;
3680
3681 try {
3682 session = openSession();
3683
3684 SQLQuery q = session.createSQLQuery(sql);
3685
3686 q.addScalar(COUNT_COLUMN_NAME,
3687 com.liferay.portal.kernel.dao.orm.Type.LONG);
3688
3689 QueryPos qPos = QueryPos.getInstance(q);
3690
3691 qPos.add(companyId);
3692
3693 qPos.add(active);
3694
3695 Long count = (Long)q.uniqueResult();
3696
3697 return count.intValue();
3698 }
3699 catch (Exception e) {
3700 throw processException(e);
3701 }
3702 finally {
3703 closeSession(session);
3704 }
3705 }
3706
3707 private static final String _FINDER_COLUMN_C_A_COMPANYID_2 = "layoutSetPrototype.companyId = ? AND ";
3708 private static final String _FINDER_COLUMN_C_A_ACTIVE_2 = "layoutSetPrototype.active = ?";
3709
3710
3715 public void cacheResult(LayoutSetPrototype layoutSetPrototype) {
3716 EntityCacheUtil.putResult(LayoutSetPrototypeModelImpl.ENTITY_CACHE_ENABLED,
3717 LayoutSetPrototypeImpl.class, layoutSetPrototype.getPrimaryKey(),
3718 layoutSetPrototype);
3719
3720 layoutSetPrototype.resetOriginalValues();
3721 }
3722
3723
3728 public void cacheResult(List<LayoutSetPrototype> layoutSetPrototypes) {
3729 for (LayoutSetPrototype layoutSetPrototype : layoutSetPrototypes) {
3730 if (EntityCacheUtil.getResult(
3731 LayoutSetPrototypeModelImpl.ENTITY_CACHE_ENABLED,
3732 LayoutSetPrototypeImpl.class,
3733 layoutSetPrototype.getPrimaryKey()) == null) {
3734 cacheResult(layoutSetPrototype);
3735 }
3736 else {
3737 layoutSetPrototype.resetOriginalValues();
3738 }
3739 }
3740 }
3741
3742
3749 @Override
3750 public void clearCache() {
3751 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
3752 CacheRegistryUtil.clear(LayoutSetPrototypeImpl.class.getName());
3753 }
3754
3755 EntityCacheUtil.clearCache(LayoutSetPrototypeImpl.class.getName());
3756
3757 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
3758 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
3759 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
3760 }
3761
3762
3769 @Override
3770 public void clearCache(LayoutSetPrototype layoutSetPrototype) {
3771 EntityCacheUtil.removeResult(LayoutSetPrototypeModelImpl.ENTITY_CACHE_ENABLED,
3772 LayoutSetPrototypeImpl.class, layoutSetPrototype.getPrimaryKey());
3773
3774 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
3775 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
3776 }
3777
3778 @Override
3779 public void clearCache(List<LayoutSetPrototype> layoutSetPrototypes) {
3780 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
3781 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
3782
3783 for (LayoutSetPrototype layoutSetPrototype : layoutSetPrototypes) {
3784 EntityCacheUtil.removeResult(LayoutSetPrototypeModelImpl.ENTITY_CACHE_ENABLED,
3785 LayoutSetPrototypeImpl.class, layoutSetPrototype.getPrimaryKey());
3786 }
3787 }
3788
3789
3795 public LayoutSetPrototype create(long layoutSetPrototypeId) {
3796 LayoutSetPrototype layoutSetPrototype = new LayoutSetPrototypeImpl();
3797
3798 layoutSetPrototype.setNew(true);
3799 layoutSetPrototype.setPrimaryKey(layoutSetPrototypeId);
3800
3801 String uuid = PortalUUIDUtil.generate();
3802
3803 layoutSetPrototype.setUuid(uuid);
3804
3805 return layoutSetPrototype;
3806 }
3807
3808
3816 public LayoutSetPrototype remove(long layoutSetPrototypeId)
3817 throws NoSuchLayoutSetPrototypeException, SystemException {
3818 return remove(Long.valueOf(layoutSetPrototypeId));
3819 }
3820
3821
3829 @Override
3830 public LayoutSetPrototype remove(Serializable primaryKey)
3831 throws NoSuchLayoutSetPrototypeException, SystemException {
3832 Session session = null;
3833
3834 try {
3835 session = openSession();
3836
3837 LayoutSetPrototype layoutSetPrototype = (LayoutSetPrototype)session.get(LayoutSetPrototypeImpl.class,
3838 primaryKey);
3839
3840 if (layoutSetPrototype == null) {
3841 if (_log.isWarnEnabled()) {
3842 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
3843 }
3844
3845 throw new NoSuchLayoutSetPrototypeException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
3846 primaryKey);
3847 }
3848
3849 return remove(layoutSetPrototype);
3850 }
3851 catch (NoSuchLayoutSetPrototypeException nsee) {
3852 throw nsee;
3853 }
3854 catch (Exception e) {
3855 throw processException(e);
3856 }
3857 finally {
3858 closeSession(session);
3859 }
3860 }
3861
3862 @Override
3863 protected LayoutSetPrototype removeImpl(
3864 LayoutSetPrototype layoutSetPrototype) throws SystemException {
3865 layoutSetPrototype = toUnwrappedModel(layoutSetPrototype);
3866
3867 Session session = null;
3868
3869 try {
3870 session = openSession();
3871
3872 if (!session.contains(layoutSetPrototype)) {
3873 layoutSetPrototype = (LayoutSetPrototype)session.get(LayoutSetPrototypeImpl.class,
3874 layoutSetPrototype.getPrimaryKeyObj());
3875 }
3876
3877 if (layoutSetPrototype != null) {
3878 session.delete(layoutSetPrototype);
3879 }
3880 }
3881 catch (Exception e) {
3882 throw processException(e);
3883 }
3884 finally {
3885 closeSession(session);
3886 }
3887
3888 if (layoutSetPrototype != null) {
3889 clearCache(layoutSetPrototype);
3890 }
3891
3892 return layoutSetPrototype;
3893 }
3894
3895 @Override
3896 public LayoutSetPrototype updateImpl(
3897 com.liferay.portal.model.LayoutSetPrototype layoutSetPrototype)
3898 throws SystemException {
3899 layoutSetPrototype = toUnwrappedModel(layoutSetPrototype);
3900
3901 boolean isNew = layoutSetPrototype.isNew();
3902
3903 LayoutSetPrototypeModelImpl layoutSetPrototypeModelImpl = (LayoutSetPrototypeModelImpl)layoutSetPrototype;
3904
3905 if (Validator.isNull(layoutSetPrototype.getUuid())) {
3906 String uuid = PortalUUIDUtil.generate();
3907
3908 layoutSetPrototype.setUuid(uuid);
3909 }
3910
3911 Session session = null;
3912
3913 try {
3914 session = openSession();
3915
3916 if (layoutSetPrototype.isNew()) {
3917 session.save(layoutSetPrototype);
3918
3919 layoutSetPrototype.setNew(false);
3920 }
3921 else {
3922 session.merge(layoutSetPrototype);
3923 }
3924 }
3925 catch (Exception e) {
3926 throw processException(e);
3927 }
3928 finally {
3929 closeSession(session);
3930 }
3931
3932 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
3933
3934 if (isNew || !LayoutSetPrototypeModelImpl.COLUMN_BITMASK_ENABLED) {
3935 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
3936 }
3937
3938 else {
3939 if ((layoutSetPrototypeModelImpl.getColumnBitmask() &
3940 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
3941 Object[] args = new Object[] {
3942 layoutSetPrototypeModelImpl.getOriginalUuid()
3943 };
3944
3945 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
3946 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
3947 args);
3948
3949 args = new Object[] { layoutSetPrototypeModelImpl.getUuid() };
3950
3951 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
3952 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
3953 args);
3954 }
3955
3956 if ((layoutSetPrototypeModelImpl.getColumnBitmask() &
3957 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C.getColumnBitmask()) != 0) {
3958 Object[] args = new Object[] {
3959 layoutSetPrototypeModelImpl.getOriginalUuid(),
3960 Long.valueOf(layoutSetPrototypeModelImpl.getOriginalCompanyId())
3961 };
3962
3963 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
3964 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
3965 args);
3966
3967 args = new Object[] {
3968 layoutSetPrototypeModelImpl.getUuid(),
3969 Long.valueOf(layoutSetPrototypeModelImpl.getCompanyId())
3970 };
3971
3972 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
3973 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
3974 args);
3975 }
3976
3977 if ((layoutSetPrototypeModelImpl.getColumnBitmask() &
3978 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
3979 Object[] args = new Object[] {
3980 Long.valueOf(layoutSetPrototypeModelImpl.getOriginalCompanyId())
3981 };
3982
3983 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
3984 args);
3985 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
3986 args);
3987
3988 args = new Object[] {
3989 Long.valueOf(layoutSetPrototypeModelImpl.getCompanyId())
3990 };
3991
3992 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
3993 args);
3994 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
3995 args);
3996 }
3997
3998 if ((layoutSetPrototypeModelImpl.getColumnBitmask() &
3999 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_A.getColumnBitmask()) != 0) {
4000 Object[] args = new Object[] {
4001 Long.valueOf(layoutSetPrototypeModelImpl.getOriginalCompanyId()),
4002 Boolean.valueOf(layoutSetPrototypeModelImpl.getOriginalActive())
4003 };
4004
4005 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_A, args);
4006 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_A,
4007 args);
4008
4009 args = new Object[] {
4010 Long.valueOf(layoutSetPrototypeModelImpl.getCompanyId()),
4011 Boolean.valueOf(layoutSetPrototypeModelImpl.getActive())
4012 };
4013
4014 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_A, args);
4015 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_A,
4016 args);
4017 }
4018 }
4019
4020 EntityCacheUtil.putResult(LayoutSetPrototypeModelImpl.ENTITY_CACHE_ENABLED,
4021 LayoutSetPrototypeImpl.class, layoutSetPrototype.getPrimaryKey(),
4022 layoutSetPrototype);
4023
4024 return layoutSetPrototype;
4025 }
4026
4027 protected LayoutSetPrototype toUnwrappedModel(
4028 LayoutSetPrototype layoutSetPrototype) {
4029 if (layoutSetPrototype instanceof LayoutSetPrototypeImpl) {
4030 return layoutSetPrototype;
4031 }
4032
4033 LayoutSetPrototypeImpl layoutSetPrototypeImpl = new LayoutSetPrototypeImpl();
4034
4035 layoutSetPrototypeImpl.setNew(layoutSetPrototype.isNew());
4036 layoutSetPrototypeImpl.setPrimaryKey(layoutSetPrototype.getPrimaryKey());
4037
4038 layoutSetPrototypeImpl.setUuid(layoutSetPrototype.getUuid());
4039 layoutSetPrototypeImpl.setLayoutSetPrototypeId(layoutSetPrototype.getLayoutSetPrototypeId());
4040 layoutSetPrototypeImpl.setCompanyId(layoutSetPrototype.getCompanyId());
4041 layoutSetPrototypeImpl.setCreateDate(layoutSetPrototype.getCreateDate());
4042 layoutSetPrototypeImpl.setModifiedDate(layoutSetPrototype.getModifiedDate());
4043 layoutSetPrototypeImpl.setName(layoutSetPrototype.getName());
4044 layoutSetPrototypeImpl.setDescription(layoutSetPrototype.getDescription());
4045 layoutSetPrototypeImpl.setSettings(layoutSetPrototype.getSettings());
4046 layoutSetPrototypeImpl.setActive(layoutSetPrototype.isActive());
4047
4048 return layoutSetPrototypeImpl;
4049 }
4050
4051
4059 @Override
4060 public LayoutSetPrototype findByPrimaryKey(Serializable primaryKey)
4061 throws NoSuchModelException, SystemException {
4062 return findByPrimaryKey(((Long)primaryKey).longValue());
4063 }
4064
4065
4073 public LayoutSetPrototype findByPrimaryKey(long layoutSetPrototypeId)
4074 throws NoSuchLayoutSetPrototypeException, SystemException {
4075 LayoutSetPrototype layoutSetPrototype = fetchByPrimaryKey(layoutSetPrototypeId);
4076
4077 if (layoutSetPrototype == null) {
4078 if (_log.isWarnEnabled()) {
4079 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
4080 layoutSetPrototypeId);
4081 }
4082
4083 throw new NoSuchLayoutSetPrototypeException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
4084 layoutSetPrototypeId);
4085 }
4086
4087 return layoutSetPrototype;
4088 }
4089
4090
4097 @Override
4098 public LayoutSetPrototype fetchByPrimaryKey(Serializable primaryKey)
4099 throws SystemException {
4100 return fetchByPrimaryKey(((Long)primaryKey).longValue());
4101 }
4102
4103
4110 public LayoutSetPrototype fetchByPrimaryKey(long layoutSetPrototypeId)
4111 throws SystemException {
4112 LayoutSetPrototype layoutSetPrototype = (LayoutSetPrototype)EntityCacheUtil.getResult(LayoutSetPrototypeModelImpl.ENTITY_CACHE_ENABLED,
4113 LayoutSetPrototypeImpl.class, layoutSetPrototypeId);
4114
4115 if (layoutSetPrototype == _nullLayoutSetPrototype) {
4116 return null;
4117 }
4118
4119 if (layoutSetPrototype == null) {
4120 Session session = null;
4121
4122 try {
4123 session = openSession();
4124
4125 layoutSetPrototype = (LayoutSetPrototype)session.get(LayoutSetPrototypeImpl.class,
4126 Long.valueOf(layoutSetPrototypeId));
4127
4128 if (layoutSetPrototype != null) {
4129 cacheResult(layoutSetPrototype);
4130 }
4131 else {
4132 EntityCacheUtil.putResult(LayoutSetPrototypeModelImpl.ENTITY_CACHE_ENABLED,
4133 LayoutSetPrototypeImpl.class, layoutSetPrototypeId,
4134 _nullLayoutSetPrototype);
4135 }
4136 }
4137 catch (Exception e) {
4138 EntityCacheUtil.removeResult(LayoutSetPrototypeModelImpl.ENTITY_CACHE_ENABLED,
4139 LayoutSetPrototypeImpl.class, layoutSetPrototypeId);
4140
4141 throw processException(e);
4142 }
4143 finally {
4144 closeSession(session);
4145 }
4146 }
4147
4148 return layoutSetPrototype;
4149 }
4150
4151
4157 public List<LayoutSetPrototype> findAll() throws SystemException {
4158 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
4159 }
4160
4161
4173 public List<LayoutSetPrototype> findAll(int start, int end)
4174 throws SystemException {
4175 return findAll(start, end, null);
4176 }
4177
4178
4191 public List<LayoutSetPrototype> findAll(int start, int end,
4192 OrderByComparator orderByComparator) throws SystemException {
4193 boolean pagination = true;
4194 FinderPath finderPath = null;
4195 Object[] finderArgs = null;
4196
4197 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4198 (orderByComparator == null)) {
4199 pagination = false;
4200 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
4201 finderArgs = FINDER_ARGS_EMPTY;
4202 }
4203 else {
4204 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
4205 finderArgs = new Object[] { start, end, orderByComparator };
4206 }
4207
4208 List<LayoutSetPrototype> list = (List<LayoutSetPrototype>)FinderCacheUtil.getResult(finderPath,
4209 finderArgs, this);
4210
4211 if (list == null) {
4212 StringBundler query = null;
4213 String sql = null;
4214
4215 if (orderByComparator != null) {
4216 query = new StringBundler(2 +
4217 (orderByComparator.getOrderByFields().length * 3));
4218
4219 query.append(_SQL_SELECT_LAYOUTSETPROTOTYPE);
4220
4221 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4222 orderByComparator);
4223
4224 sql = query.toString();
4225 }
4226 else {
4227 sql = _SQL_SELECT_LAYOUTSETPROTOTYPE;
4228
4229 if (pagination) {
4230 sql = sql.concat(LayoutSetPrototypeModelImpl.ORDER_BY_JPQL);
4231 }
4232 }
4233
4234 Session session = null;
4235
4236 try {
4237 session = openSession();
4238
4239 Query q = session.createQuery(sql);
4240
4241 if (!pagination) {
4242 list = (List<LayoutSetPrototype>)QueryUtil.list(q,
4243 getDialect(), start, end, false);
4244
4245 Collections.sort(list);
4246
4247 list = new UnmodifiableList<LayoutSetPrototype>(list);
4248 }
4249 else {
4250 list = (List<LayoutSetPrototype>)QueryUtil.list(q,
4251 getDialect(), start, end);
4252 }
4253
4254 cacheResult(list);
4255
4256 FinderCacheUtil.putResult(finderPath, finderArgs, list);
4257 }
4258 catch (Exception e) {
4259 FinderCacheUtil.removeResult(finderPath, finderArgs);
4260
4261 throw processException(e);
4262 }
4263 finally {
4264 closeSession(session);
4265 }
4266 }
4267
4268 return list;
4269 }
4270
4271
4276 public void removeAll() throws SystemException {
4277 for (LayoutSetPrototype layoutSetPrototype : findAll()) {
4278 remove(layoutSetPrototype);
4279 }
4280 }
4281
4282
4288 public int countAll() throws SystemException {
4289 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
4290 FINDER_ARGS_EMPTY, this);
4291
4292 if (count == null) {
4293 Session session = null;
4294
4295 try {
4296 session = openSession();
4297
4298 Query q = session.createQuery(_SQL_COUNT_LAYOUTSETPROTOTYPE);
4299
4300 count = (Long)q.uniqueResult();
4301
4302 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
4303 FINDER_ARGS_EMPTY, count);
4304 }
4305 catch (Exception e) {
4306 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
4307 FINDER_ARGS_EMPTY);
4308
4309 throw processException(e);
4310 }
4311 finally {
4312 closeSession(session);
4313 }
4314 }
4315
4316 return count.intValue();
4317 }
4318
4319
4322 public void afterPropertiesSet() {
4323 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
4324 com.liferay.portal.util.PropsUtil.get(
4325 "value.object.listener.com.liferay.portal.model.LayoutSetPrototype")));
4326
4327 if (listenerClassNames.length > 0) {
4328 try {
4329 List<ModelListener<LayoutSetPrototype>> listenersList = new ArrayList<ModelListener<LayoutSetPrototype>>();
4330
4331 for (String listenerClassName : listenerClassNames) {
4332 listenersList.add((ModelListener<LayoutSetPrototype>)InstanceFactory.newInstance(
4333 listenerClassName));
4334 }
4335
4336 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
4337 }
4338 catch (Exception e) {
4339 _log.error(e);
4340 }
4341 }
4342 }
4343
4344 public void destroy() {
4345 EntityCacheUtil.removeCache(LayoutSetPrototypeImpl.class.getName());
4346 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
4347 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
4348 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
4349 }
4350
4351 private static final String _SQL_SELECT_LAYOUTSETPROTOTYPE = "SELECT layoutSetPrototype FROM LayoutSetPrototype layoutSetPrototype";
4352 private static final String _SQL_SELECT_LAYOUTSETPROTOTYPE_WHERE = "SELECT layoutSetPrototype FROM LayoutSetPrototype layoutSetPrototype WHERE ";
4353 private static final String _SQL_COUNT_LAYOUTSETPROTOTYPE = "SELECT COUNT(layoutSetPrototype) FROM LayoutSetPrototype layoutSetPrototype";
4354 private static final String _SQL_COUNT_LAYOUTSETPROTOTYPE_WHERE = "SELECT COUNT(layoutSetPrototype) FROM LayoutSetPrototype layoutSetPrototype WHERE ";
4355 private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "layoutSetPrototype.layoutSetPrototypeId";
4356 private static final String _FILTER_SQL_SELECT_LAYOUTSETPROTOTYPE_WHERE = "SELECT DISTINCT {layoutSetPrototype.*} FROM LayoutSetPrototype layoutSetPrototype WHERE ";
4357 private static final String _FILTER_SQL_SELECT_LAYOUTSETPROTOTYPE_NO_INLINE_DISTINCT_WHERE_1 =
4358 "SELECT {LayoutSetPrototype.*} FROM (SELECT DISTINCT layoutSetPrototype.layoutSetPrototypeId FROM LayoutSetPrototype layoutSetPrototype WHERE ";
4359 private static final String _FILTER_SQL_SELECT_LAYOUTSETPROTOTYPE_NO_INLINE_DISTINCT_WHERE_2 =
4360 ") TEMP_TABLE INNER JOIN LayoutSetPrototype ON TEMP_TABLE.layoutSetPrototypeId = LayoutSetPrototype.layoutSetPrototypeId";
4361 private static final String _FILTER_SQL_COUNT_LAYOUTSETPROTOTYPE_WHERE = "SELECT COUNT(DISTINCT layoutSetPrototype.layoutSetPrototypeId) AS COUNT_VALUE FROM LayoutSetPrototype layoutSetPrototype WHERE ";
4362 private static final String _FILTER_ENTITY_ALIAS = "layoutSetPrototype";
4363 private static final String _FILTER_ENTITY_TABLE = "LayoutSetPrototype";
4364 private static final String _ORDER_BY_ENTITY_ALIAS = "layoutSetPrototype.";
4365 private static final String _ORDER_BY_ENTITY_TABLE = "LayoutSetPrototype.";
4366 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No LayoutSetPrototype exists with the primary key ";
4367 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No LayoutSetPrototype exists with the key {";
4368 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
4369 private static Log _log = LogFactoryUtil.getLog(LayoutSetPrototypePersistenceImpl.class);
4370 private static LayoutSetPrototype _nullLayoutSetPrototype = new LayoutSetPrototypeImpl() {
4371 @Override
4372 public Object clone() {
4373 return this;
4374 }
4375
4376 @Override
4377 public CacheModel<LayoutSetPrototype> toCacheModel() {
4378 return _nullLayoutSetPrototypeCacheModel;
4379 }
4380 };
4381
4382 private static CacheModel<LayoutSetPrototype> _nullLayoutSetPrototypeCacheModel =
4383 new CacheModel<LayoutSetPrototype>() {
4384 public LayoutSetPrototype toEntityModel() {
4385 return _nullLayoutSetPrototype;
4386 }
4387 };
4388 }