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