001
014
015 package com.liferay.portal.service.persistence;
016
017 import com.liferay.portal.NoSuchLayoutSetBranchException;
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.model.CacheModel;
039 import com.liferay.portal.model.LayoutSetBranch;
040 import com.liferay.portal.model.ModelListener;
041 import com.liferay.portal.model.impl.LayoutSetBranchImpl;
042 import com.liferay.portal.model.impl.LayoutSetBranchModelImpl;
043 import com.liferay.portal.security.permission.InlineSQLHelperUtil;
044 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
045
046 import java.io.Serializable;
047
048 import java.util.ArrayList;
049 import java.util.Collections;
050 import java.util.List;
051
052
064 public class LayoutSetBranchPersistenceImpl extends BasePersistenceImpl<LayoutSetBranch>
065 implements LayoutSetBranchPersistence {
066
071 public static final String FINDER_CLASS_NAME_ENTITY = LayoutSetBranchImpl.class.getName();
072 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
073 ".List1";
074 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
075 ".List2";
076 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(LayoutSetBranchModelImpl.ENTITY_CACHE_ENABLED,
077 LayoutSetBranchModelImpl.FINDER_CACHE_ENABLED,
078 LayoutSetBranchImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
079 "findAll", new String[0]);
080 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(LayoutSetBranchModelImpl.ENTITY_CACHE_ENABLED,
081 LayoutSetBranchModelImpl.FINDER_CACHE_ENABLED,
082 LayoutSetBranchImpl.class,
083 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
084 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(LayoutSetBranchModelImpl.ENTITY_CACHE_ENABLED,
085 LayoutSetBranchModelImpl.FINDER_CACHE_ENABLED, Long.class,
086 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
087 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(LayoutSetBranchModelImpl.ENTITY_CACHE_ENABLED,
088 LayoutSetBranchModelImpl.FINDER_CACHE_ENABLED,
089 LayoutSetBranchImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
090 "findByGroupId",
091 new String[] {
092 Long.class.getName(),
093
094 Integer.class.getName(), Integer.class.getName(),
095 OrderByComparator.class.getName()
096 });
097 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID =
098 new FinderPath(LayoutSetBranchModelImpl.ENTITY_CACHE_ENABLED,
099 LayoutSetBranchModelImpl.FINDER_CACHE_ENABLED,
100 LayoutSetBranchImpl.class,
101 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByGroupId",
102 new String[] { Long.class.getName() },
103 LayoutSetBranchModelImpl.GROUPID_COLUMN_BITMASK |
104 LayoutSetBranchModelImpl.NAME_COLUMN_BITMASK);
105 public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(LayoutSetBranchModelImpl.ENTITY_CACHE_ENABLED,
106 LayoutSetBranchModelImpl.FINDER_CACHE_ENABLED, Long.class,
107 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId",
108 new String[] { Long.class.getName() });
109
110
117 public List<LayoutSetBranch> findByGroupId(long groupId)
118 throws SystemException {
119 return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
120 }
121
122
135 public List<LayoutSetBranch> findByGroupId(long groupId, int start, int end)
136 throws SystemException {
137 return findByGroupId(groupId, start, end, null);
138 }
139
140
154 public List<LayoutSetBranch> findByGroupId(long groupId, int start,
155 int end, OrderByComparator orderByComparator) throws SystemException {
156 boolean pagination = true;
157 FinderPath finderPath = null;
158 Object[] finderArgs = null;
159
160 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
161 (orderByComparator == null)) {
162 pagination = false;
163 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
164 finderArgs = new Object[] { groupId };
165 }
166 else {
167 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
168 finderArgs = new Object[] { groupId, start, end, orderByComparator };
169 }
170
171 List<LayoutSetBranch> list = (List<LayoutSetBranch>)FinderCacheUtil.getResult(finderPath,
172 finderArgs, this);
173
174 if ((list != null) && !list.isEmpty()) {
175 for (LayoutSetBranch layoutSetBranch : list) {
176 if ((groupId != layoutSetBranch.getGroupId())) {
177 list = null;
178
179 break;
180 }
181 }
182 }
183
184 if (list == null) {
185 StringBundler query = null;
186
187 if (orderByComparator != null) {
188 query = new StringBundler(3 +
189 (orderByComparator.getOrderByFields().length * 3));
190 }
191 else {
192 query = new StringBundler(3);
193 }
194
195 query.append(_SQL_SELECT_LAYOUTSETBRANCH_WHERE);
196
197 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
198
199 if (orderByComparator != null) {
200 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
201 orderByComparator);
202 }
203 else
204 if (pagination) {
205 query.append(LayoutSetBranchModelImpl.ORDER_BY_JPQL);
206 }
207
208 String sql = query.toString();
209
210 Session session = null;
211
212 try {
213 session = openSession();
214
215 Query q = session.createQuery(sql);
216
217 QueryPos qPos = QueryPos.getInstance(q);
218
219 qPos.add(groupId);
220
221 if (!pagination) {
222 list = (List<LayoutSetBranch>)QueryUtil.list(q,
223 getDialect(), start, end, false);
224
225 Collections.sort(list);
226
227 list = new UnmodifiableList<LayoutSetBranch>(list);
228 }
229 else {
230 list = (List<LayoutSetBranch>)QueryUtil.list(q,
231 getDialect(), start, end);
232 }
233
234 cacheResult(list);
235
236 FinderCacheUtil.putResult(finderPath, finderArgs, list);
237 }
238 catch (Exception e) {
239 FinderCacheUtil.removeResult(finderPath, finderArgs);
240
241 throw processException(e);
242 }
243 finally {
244 closeSession(session);
245 }
246 }
247
248 return list;
249 }
250
251
260 public LayoutSetBranch findByGroupId_First(long groupId,
261 OrderByComparator orderByComparator)
262 throws NoSuchLayoutSetBranchException, SystemException {
263 LayoutSetBranch layoutSetBranch = fetchByGroupId_First(groupId,
264 orderByComparator);
265
266 if (layoutSetBranch != null) {
267 return layoutSetBranch;
268 }
269
270 StringBundler msg = new StringBundler(4);
271
272 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
273
274 msg.append("groupId=");
275 msg.append(groupId);
276
277 msg.append(StringPool.CLOSE_CURLY_BRACE);
278
279 throw new NoSuchLayoutSetBranchException(msg.toString());
280 }
281
282
290 public LayoutSetBranch fetchByGroupId_First(long groupId,
291 OrderByComparator orderByComparator) throws SystemException {
292 List<LayoutSetBranch> list = findByGroupId(groupId, 0, 1,
293 orderByComparator);
294
295 if (!list.isEmpty()) {
296 return list.get(0);
297 }
298
299 return null;
300 }
301
302
311 public LayoutSetBranch findByGroupId_Last(long groupId,
312 OrderByComparator orderByComparator)
313 throws NoSuchLayoutSetBranchException, SystemException {
314 LayoutSetBranch layoutSetBranch = fetchByGroupId_Last(groupId,
315 orderByComparator);
316
317 if (layoutSetBranch != null) {
318 return layoutSetBranch;
319 }
320
321 StringBundler msg = new StringBundler(4);
322
323 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
324
325 msg.append("groupId=");
326 msg.append(groupId);
327
328 msg.append(StringPool.CLOSE_CURLY_BRACE);
329
330 throw new NoSuchLayoutSetBranchException(msg.toString());
331 }
332
333
341 public LayoutSetBranch fetchByGroupId_Last(long groupId,
342 OrderByComparator orderByComparator) throws SystemException {
343 int count = countByGroupId(groupId);
344
345 List<LayoutSetBranch> list = findByGroupId(groupId, count - 1, count,
346 orderByComparator);
347
348 if (!list.isEmpty()) {
349 return list.get(0);
350 }
351
352 return null;
353 }
354
355
365 public LayoutSetBranch[] findByGroupId_PrevAndNext(long layoutSetBranchId,
366 long groupId, OrderByComparator orderByComparator)
367 throws NoSuchLayoutSetBranchException, SystemException {
368 LayoutSetBranch layoutSetBranch = findByPrimaryKey(layoutSetBranchId);
369
370 Session session = null;
371
372 try {
373 session = openSession();
374
375 LayoutSetBranch[] array = new LayoutSetBranchImpl[3];
376
377 array[0] = getByGroupId_PrevAndNext(session, layoutSetBranch,
378 groupId, orderByComparator, true);
379
380 array[1] = layoutSetBranch;
381
382 array[2] = getByGroupId_PrevAndNext(session, layoutSetBranch,
383 groupId, orderByComparator, false);
384
385 return array;
386 }
387 catch (Exception e) {
388 throw processException(e);
389 }
390 finally {
391 closeSession(session);
392 }
393 }
394
395 protected LayoutSetBranch getByGroupId_PrevAndNext(Session session,
396 LayoutSetBranch layoutSetBranch, long groupId,
397 OrderByComparator orderByComparator, boolean previous) {
398 StringBundler query = null;
399
400 if (orderByComparator != null) {
401 query = new StringBundler(6 +
402 (orderByComparator.getOrderByFields().length * 6));
403 }
404 else {
405 query = new StringBundler(3);
406 }
407
408 query.append(_SQL_SELECT_LAYOUTSETBRANCH_WHERE);
409
410 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
411
412 if (orderByComparator != null) {
413 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
414
415 if (orderByConditionFields.length > 0) {
416 query.append(WHERE_AND);
417 }
418
419 for (int i = 0; i < orderByConditionFields.length; i++) {
420 query.append(_ORDER_BY_ENTITY_ALIAS);
421 query.append(orderByConditionFields[i]);
422
423 if ((i + 1) < orderByConditionFields.length) {
424 if (orderByComparator.isAscending() ^ previous) {
425 query.append(WHERE_GREATER_THAN_HAS_NEXT);
426 }
427 else {
428 query.append(WHERE_LESSER_THAN_HAS_NEXT);
429 }
430 }
431 else {
432 if (orderByComparator.isAscending() ^ previous) {
433 query.append(WHERE_GREATER_THAN);
434 }
435 else {
436 query.append(WHERE_LESSER_THAN);
437 }
438 }
439 }
440
441 query.append(ORDER_BY_CLAUSE);
442
443 String[] orderByFields = orderByComparator.getOrderByFields();
444
445 for (int i = 0; i < orderByFields.length; i++) {
446 query.append(_ORDER_BY_ENTITY_ALIAS);
447 query.append(orderByFields[i]);
448
449 if ((i + 1) < orderByFields.length) {
450 if (orderByComparator.isAscending() ^ previous) {
451 query.append(ORDER_BY_ASC_HAS_NEXT);
452 }
453 else {
454 query.append(ORDER_BY_DESC_HAS_NEXT);
455 }
456 }
457 else {
458 if (orderByComparator.isAscending() ^ previous) {
459 query.append(ORDER_BY_ASC);
460 }
461 else {
462 query.append(ORDER_BY_DESC);
463 }
464 }
465 }
466 }
467 else {
468 query.append(LayoutSetBranchModelImpl.ORDER_BY_JPQL);
469 }
470
471 String sql = query.toString();
472
473 Query q = session.createQuery(sql);
474
475 q.setFirstResult(0);
476 q.setMaxResults(2);
477
478 QueryPos qPos = QueryPos.getInstance(q);
479
480 qPos.add(groupId);
481
482 if (orderByComparator != null) {
483 Object[] values = orderByComparator.getOrderByConditionValues(layoutSetBranch);
484
485 for (Object value : values) {
486 qPos.add(value);
487 }
488 }
489
490 List<LayoutSetBranch> list = q.list();
491
492 if (list.size() == 2) {
493 return list.get(1);
494 }
495 else {
496 return null;
497 }
498 }
499
500
507 public List<LayoutSetBranch> filterFindByGroupId(long groupId)
508 throws SystemException {
509 return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
510 QueryUtil.ALL_POS, null);
511 }
512
513
526 public List<LayoutSetBranch> filterFindByGroupId(long groupId, int start,
527 int end) throws SystemException {
528 return filterFindByGroupId(groupId, start, end, null);
529 }
530
531
545 public List<LayoutSetBranch> filterFindByGroupId(long groupId, int start,
546 int end, OrderByComparator orderByComparator) throws SystemException {
547 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
548 return findByGroupId(groupId, start, end, orderByComparator);
549 }
550
551 StringBundler query = null;
552
553 if (orderByComparator != null) {
554 query = new StringBundler(3 +
555 (orderByComparator.getOrderByFields().length * 3));
556 }
557 else {
558 query = new StringBundler(3);
559 }
560
561 if (getDB().isSupportsInlineDistinct()) {
562 query.append(_FILTER_SQL_SELECT_LAYOUTSETBRANCH_WHERE);
563 }
564 else {
565 query.append(_FILTER_SQL_SELECT_LAYOUTSETBRANCH_NO_INLINE_DISTINCT_WHERE_1);
566 }
567
568 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
569
570 if (!getDB().isSupportsInlineDistinct()) {
571 query.append(_FILTER_SQL_SELECT_LAYOUTSETBRANCH_NO_INLINE_DISTINCT_WHERE_2);
572 }
573
574 if (orderByComparator != null) {
575 if (getDB().isSupportsInlineDistinct()) {
576 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
577 orderByComparator);
578 }
579 else {
580 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
581 orderByComparator);
582 }
583 }
584 else {
585 if (getDB().isSupportsInlineDistinct()) {
586 query.append(LayoutSetBranchModelImpl.ORDER_BY_JPQL);
587 }
588 else {
589 query.append(LayoutSetBranchModelImpl.ORDER_BY_SQL);
590 }
591 }
592
593 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
594 LayoutSetBranch.class.getName(),
595 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
596
597 Session session = null;
598
599 try {
600 session = openSession();
601
602 SQLQuery q = session.createSQLQuery(sql);
603
604 if (getDB().isSupportsInlineDistinct()) {
605 q.addEntity(_FILTER_ENTITY_ALIAS, LayoutSetBranchImpl.class);
606 }
607 else {
608 q.addEntity(_FILTER_ENTITY_TABLE, LayoutSetBranchImpl.class);
609 }
610
611 QueryPos qPos = QueryPos.getInstance(q);
612
613 qPos.add(groupId);
614
615 return (List<LayoutSetBranch>)QueryUtil.list(q, getDialect(),
616 start, end);
617 }
618 catch (Exception e) {
619 throw processException(e);
620 }
621 finally {
622 closeSession(session);
623 }
624 }
625
626
636 public LayoutSetBranch[] filterFindByGroupId_PrevAndNext(
637 long layoutSetBranchId, long groupId,
638 OrderByComparator orderByComparator)
639 throws NoSuchLayoutSetBranchException, SystemException {
640 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
641 return findByGroupId_PrevAndNext(layoutSetBranchId, groupId,
642 orderByComparator);
643 }
644
645 LayoutSetBranch layoutSetBranch = findByPrimaryKey(layoutSetBranchId);
646
647 Session session = null;
648
649 try {
650 session = openSession();
651
652 LayoutSetBranch[] array = new LayoutSetBranchImpl[3];
653
654 array[0] = filterGetByGroupId_PrevAndNext(session, layoutSetBranch,
655 groupId, orderByComparator, true);
656
657 array[1] = layoutSetBranch;
658
659 array[2] = filterGetByGroupId_PrevAndNext(session, layoutSetBranch,
660 groupId, orderByComparator, false);
661
662 return array;
663 }
664 catch (Exception e) {
665 throw processException(e);
666 }
667 finally {
668 closeSession(session);
669 }
670 }
671
672 protected LayoutSetBranch filterGetByGroupId_PrevAndNext(Session session,
673 LayoutSetBranch layoutSetBranch, long groupId,
674 OrderByComparator orderByComparator, boolean previous) {
675 StringBundler query = null;
676
677 if (orderByComparator != null) {
678 query = new StringBundler(6 +
679 (orderByComparator.getOrderByFields().length * 6));
680 }
681 else {
682 query = new StringBundler(3);
683 }
684
685 if (getDB().isSupportsInlineDistinct()) {
686 query.append(_FILTER_SQL_SELECT_LAYOUTSETBRANCH_WHERE);
687 }
688 else {
689 query.append(_FILTER_SQL_SELECT_LAYOUTSETBRANCH_NO_INLINE_DISTINCT_WHERE_1);
690 }
691
692 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
693
694 if (!getDB().isSupportsInlineDistinct()) {
695 query.append(_FILTER_SQL_SELECT_LAYOUTSETBRANCH_NO_INLINE_DISTINCT_WHERE_2);
696 }
697
698 if (orderByComparator != null) {
699 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
700
701 if (orderByConditionFields.length > 0) {
702 query.append(WHERE_AND);
703 }
704
705 for (int i = 0; i < orderByConditionFields.length; i++) {
706 if (getDB().isSupportsInlineDistinct()) {
707 query.append(_ORDER_BY_ENTITY_ALIAS);
708 }
709 else {
710 query.append(_ORDER_BY_ENTITY_TABLE);
711 }
712
713 query.append(orderByConditionFields[i]);
714
715 if ((i + 1) < orderByConditionFields.length) {
716 if (orderByComparator.isAscending() ^ previous) {
717 query.append(WHERE_GREATER_THAN_HAS_NEXT);
718 }
719 else {
720 query.append(WHERE_LESSER_THAN_HAS_NEXT);
721 }
722 }
723 else {
724 if (orderByComparator.isAscending() ^ previous) {
725 query.append(WHERE_GREATER_THAN);
726 }
727 else {
728 query.append(WHERE_LESSER_THAN);
729 }
730 }
731 }
732
733 query.append(ORDER_BY_CLAUSE);
734
735 String[] orderByFields = orderByComparator.getOrderByFields();
736
737 for (int i = 0; i < orderByFields.length; i++) {
738 if (getDB().isSupportsInlineDistinct()) {
739 query.append(_ORDER_BY_ENTITY_ALIAS);
740 }
741 else {
742 query.append(_ORDER_BY_ENTITY_TABLE);
743 }
744
745 query.append(orderByFields[i]);
746
747 if ((i + 1) < orderByFields.length) {
748 if (orderByComparator.isAscending() ^ previous) {
749 query.append(ORDER_BY_ASC_HAS_NEXT);
750 }
751 else {
752 query.append(ORDER_BY_DESC_HAS_NEXT);
753 }
754 }
755 else {
756 if (orderByComparator.isAscending() ^ previous) {
757 query.append(ORDER_BY_ASC);
758 }
759 else {
760 query.append(ORDER_BY_DESC);
761 }
762 }
763 }
764 }
765 else {
766 if (getDB().isSupportsInlineDistinct()) {
767 query.append(LayoutSetBranchModelImpl.ORDER_BY_JPQL);
768 }
769 else {
770 query.append(LayoutSetBranchModelImpl.ORDER_BY_SQL);
771 }
772 }
773
774 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
775 LayoutSetBranch.class.getName(),
776 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
777
778 SQLQuery q = session.createSQLQuery(sql);
779
780 q.setFirstResult(0);
781 q.setMaxResults(2);
782
783 if (getDB().isSupportsInlineDistinct()) {
784 q.addEntity(_FILTER_ENTITY_ALIAS, LayoutSetBranchImpl.class);
785 }
786 else {
787 q.addEntity(_FILTER_ENTITY_TABLE, LayoutSetBranchImpl.class);
788 }
789
790 QueryPos qPos = QueryPos.getInstance(q);
791
792 qPos.add(groupId);
793
794 if (orderByComparator != null) {
795 Object[] values = orderByComparator.getOrderByConditionValues(layoutSetBranch);
796
797 for (Object value : values) {
798 qPos.add(value);
799 }
800 }
801
802 List<LayoutSetBranch> list = q.list();
803
804 if (list.size() == 2) {
805 return list.get(1);
806 }
807 else {
808 return null;
809 }
810 }
811
812
818 public void removeByGroupId(long groupId) throws SystemException {
819 for (LayoutSetBranch layoutSetBranch : findByGroupId(groupId,
820 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
821 remove(layoutSetBranch);
822 }
823 }
824
825
832 public int countByGroupId(long groupId) throws SystemException {
833 FinderPath finderPath = FINDER_PATH_COUNT_BY_GROUPID;
834
835 Object[] finderArgs = new Object[] { groupId };
836
837 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
838 this);
839
840 if (count == null) {
841 StringBundler query = new StringBundler(2);
842
843 query.append(_SQL_COUNT_LAYOUTSETBRANCH_WHERE);
844
845 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
846
847 String sql = query.toString();
848
849 Session session = null;
850
851 try {
852 session = openSession();
853
854 Query q = session.createQuery(sql);
855
856 QueryPos qPos = QueryPos.getInstance(q);
857
858 qPos.add(groupId);
859
860 count = (Long)q.uniqueResult();
861
862 FinderCacheUtil.putResult(finderPath, finderArgs, count);
863 }
864 catch (Exception e) {
865 FinderCacheUtil.removeResult(finderPath, finderArgs);
866
867 throw processException(e);
868 }
869 finally {
870 closeSession(session);
871 }
872 }
873
874 return count.intValue();
875 }
876
877
884 public int filterCountByGroupId(long groupId) throws SystemException {
885 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
886 return countByGroupId(groupId);
887 }
888
889 StringBundler query = new StringBundler(2);
890
891 query.append(_FILTER_SQL_COUNT_LAYOUTSETBRANCH_WHERE);
892
893 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
894
895 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
896 LayoutSetBranch.class.getName(),
897 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
898
899 Session session = null;
900
901 try {
902 session = openSession();
903
904 SQLQuery q = session.createSQLQuery(sql);
905
906 q.addScalar(COUNT_COLUMN_NAME,
907 com.liferay.portal.kernel.dao.orm.Type.LONG);
908
909 QueryPos qPos = QueryPos.getInstance(q);
910
911 qPos.add(groupId);
912
913 Long count = (Long)q.uniqueResult();
914
915 return count.intValue();
916 }
917 catch (Exception e) {
918 throw processException(e);
919 }
920 finally {
921 closeSession(session);
922 }
923 }
924
925 private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "layoutSetBranch.groupId = ?";
926 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P = new FinderPath(LayoutSetBranchModelImpl.ENTITY_CACHE_ENABLED,
927 LayoutSetBranchModelImpl.FINDER_CACHE_ENABLED,
928 LayoutSetBranchImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
929 "findByG_P",
930 new String[] {
931 Long.class.getName(), Boolean.class.getName(),
932
933 Integer.class.getName(), Integer.class.getName(),
934 OrderByComparator.class.getName()
935 });
936 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P = new FinderPath(LayoutSetBranchModelImpl.ENTITY_CACHE_ENABLED,
937 LayoutSetBranchModelImpl.FINDER_CACHE_ENABLED,
938 LayoutSetBranchImpl.class,
939 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_P",
940 new String[] { Long.class.getName(), Boolean.class.getName() },
941 LayoutSetBranchModelImpl.GROUPID_COLUMN_BITMASK |
942 LayoutSetBranchModelImpl.PRIVATELAYOUT_COLUMN_BITMASK |
943 LayoutSetBranchModelImpl.NAME_COLUMN_BITMASK);
944 public static final FinderPath FINDER_PATH_COUNT_BY_G_P = new FinderPath(LayoutSetBranchModelImpl.ENTITY_CACHE_ENABLED,
945 LayoutSetBranchModelImpl.FINDER_CACHE_ENABLED, Long.class,
946 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_P",
947 new String[] { Long.class.getName(), Boolean.class.getName() });
948
949
957 public List<LayoutSetBranch> findByG_P(long groupId, boolean privateLayout)
958 throws SystemException {
959 return findByG_P(groupId, privateLayout, QueryUtil.ALL_POS,
960 QueryUtil.ALL_POS, null);
961 }
962
963
977 public List<LayoutSetBranch> findByG_P(long groupId, boolean privateLayout,
978 int start, int end) throws SystemException {
979 return findByG_P(groupId, privateLayout, start, end, null);
980 }
981
982
997 public List<LayoutSetBranch> findByG_P(long groupId, boolean privateLayout,
998 int start, int end, OrderByComparator orderByComparator)
999 throws SystemException {
1000 boolean pagination = true;
1001 FinderPath finderPath = null;
1002 Object[] finderArgs = null;
1003
1004 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1005 (orderByComparator == null)) {
1006 pagination = false;
1007 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P;
1008 finderArgs = new Object[] { groupId, privateLayout };
1009 }
1010 else {
1011 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P;
1012 finderArgs = new Object[] {
1013 groupId, privateLayout,
1014
1015 start, end, orderByComparator
1016 };
1017 }
1018
1019 List<LayoutSetBranch> list = (List<LayoutSetBranch>)FinderCacheUtil.getResult(finderPath,
1020 finderArgs, this);
1021
1022 if ((list != null) && !list.isEmpty()) {
1023 for (LayoutSetBranch layoutSetBranch : list) {
1024 if ((groupId != layoutSetBranch.getGroupId()) ||
1025 (privateLayout != layoutSetBranch.getPrivateLayout())) {
1026 list = null;
1027
1028 break;
1029 }
1030 }
1031 }
1032
1033 if (list == null) {
1034 StringBundler query = null;
1035
1036 if (orderByComparator != null) {
1037 query = new StringBundler(4 +
1038 (orderByComparator.getOrderByFields().length * 3));
1039 }
1040 else {
1041 query = new StringBundler(4);
1042 }
1043
1044 query.append(_SQL_SELECT_LAYOUTSETBRANCH_WHERE);
1045
1046 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
1047
1048 query.append(_FINDER_COLUMN_G_P_PRIVATELAYOUT_2);
1049
1050 if (orderByComparator != null) {
1051 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1052 orderByComparator);
1053 }
1054 else
1055 if (pagination) {
1056 query.append(LayoutSetBranchModelImpl.ORDER_BY_JPQL);
1057 }
1058
1059 String sql = query.toString();
1060
1061 Session session = null;
1062
1063 try {
1064 session = openSession();
1065
1066 Query q = session.createQuery(sql);
1067
1068 QueryPos qPos = QueryPos.getInstance(q);
1069
1070 qPos.add(groupId);
1071
1072 qPos.add(privateLayout);
1073
1074 if (!pagination) {
1075 list = (List<LayoutSetBranch>)QueryUtil.list(q,
1076 getDialect(), start, end, false);
1077
1078 Collections.sort(list);
1079
1080 list = new UnmodifiableList<LayoutSetBranch>(list);
1081 }
1082 else {
1083 list = (List<LayoutSetBranch>)QueryUtil.list(q,
1084 getDialect(), start, end);
1085 }
1086
1087 cacheResult(list);
1088
1089 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1090 }
1091 catch (Exception e) {
1092 FinderCacheUtil.removeResult(finderPath, finderArgs);
1093
1094 throw processException(e);
1095 }
1096 finally {
1097 closeSession(session);
1098 }
1099 }
1100
1101 return list;
1102 }
1103
1104
1114 public LayoutSetBranch findByG_P_First(long groupId, boolean privateLayout,
1115 OrderByComparator orderByComparator)
1116 throws NoSuchLayoutSetBranchException, SystemException {
1117 LayoutSetBranch layoutSetBranch = fetchByG_P_First(groupId,
1118 privateLayout, orderByComparator);
1119
1120 if (layoutSetBranch != null) {
1121 return layoutSetBranch;
1122 }
1123
1124 StringBundler msg = new StringBundler(6);
1125
1126 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1127
1128 msg.append("groupId=");
1129 msg.append(groupId);
1130
1131 msg.append(", privateLayout=");
1132 msg.append(privateLayout);
1133
1134 msg.append(StringPool.CLOSE_CURLY_BRACE);
1135
1136 throw new NoSuchLayoutSetBranchException(msg.toString());
1137 }
1138
1139
1148 public LayoutSetBranch fetchByG_P_First(long groupId,
1149 boolean privateLayout, OrderByComparator orderByComparator)
1150 throws SystemException {
1151 List<LayoutSetBranch> list = findByG_P(groupId, privateLayout, 0, 1,
1152 orderByComparator);
1153
1154 if (!list.isEmpty()) {
1155 return list.get(0);
1156 }
1157
1158 return null;
1159 }
1160
1161
1171 public LayoutSetBranch findByG_P_Last(long groupId, boolean privateLayout,
1172 OrderByComparator orderByComparator)
1173 throws NoSuchLayoutSetBranchException, SystemException {
1174 LayoutSetBranch layoutSetBranch = fetchByG_P_Last(groupId,
1175 privateLayout, orderByComparator);
1176
1177 if (layoutSetBranch != null) {
1178 return layoutSetBranch;
1179 }
1180
1181 StringBundler msg = new StringBundler(6);
1182
1183 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1184
1185 msg.append("groupId=");
1186 msg.append(groupId);
1187
1188 msg.append(", privateLayout=");
1189 msg.append(privateLayout);
1190
1191 msg.append(StringPool.CLOSE_CURLY_BRACE);
1192
1193 throw new NoSuchLayoutSetBranchException(msg.toString());
1194 }
1195
1196
1205 public LayoutSetBranch fetchByG_P_Last(long groupId, boolean privateLayout,
1206 OrderByComparator orderByComparator) throws SystemException {
1207 int count = countByG_P(groupId, privateLayout);
1208
1209 List<LayoutSetBranch> list = findByG_P(groupId, privateLayout,
1210 count - 1, count, orderByComparator);
1211
1212 if (!list.isEmpty()) {
1213 return list.get(0);
1214 }
1215
1216 return null;
1217 }
1218
1219
1230 public LayoutSetBranch[] findByG_P_PrevAndNext(long layoutSetBranchId,
1231 long groupId, boolean privateLayout, OrderByComparator orderByComparator)
1232 throws NoSuchLayoutSetBranchException, SystemException {
1233 LayoutSetBranch layoutSetBranch = findByPrimaryKey(layoutSetBranchId);
1234
1235 Session session = null;
1236
1237 try {
1238 session = openSession();
1239
1240 LayoutSetBranch[] array = new LayoutSetBranchImpl[3];
1241
1242 array[0] = getByG_P_PrevAndNext(session, layoutSetBranch, groupId,
1243 privateLayout, orderByComparator, true);
1244
1245 array[1] = layoutSetBranch;
1246
1247 array[2] = getByG_P_PrevAndNext(session, layoutSetBranch, groupId,
1248 privateLayout, orderByComparator, false);
1249
1250 return array;
1251 }
1252 catch (Exception e) {
1253 throw processException(e);
1254 }
1255 finally {
1256 closeSession(session);
1257 }
1258 }
1259
1260 protected LayoutSetBranch getByG_P_PrevAndNext(Session session,
1261 LayoutSetBranch layoutSetBranch, long groupId, boolean privateLayout,
1262 OrderByComparator orderByComparator, boolean previous) {
1263 StringBundler query = null;
1264
1265 if (orderByComparator != null) {
1266 query = new StringBundler(6 +
1267 (orderByComparator.getOrderByFields().length * 6));
1268 }
1269 else {
1270 query = new StringBundler(3);
1271 }
1272
1273 query.append(_SQL_SELECT_LAYOUTSETBRANCH_WHERE);
1274
1275 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
1276
1277 query.append(_FINDER_COLUMN_G_P_PRIVATELAYOUT_2);
1278
1279 if (orderByComparator != null) {
1280 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1281
1282 if (orderByConditionFields.length > 0) {
1283 query.append(WHERE_AND);
1284 }
1285
1286 for (int i = 0; i < orderByConditionFields.length; i++) {
1287 query.append(_ORDER_BY_ENTITY_ALIAS);
1288 query.append(orderByConditionFields[i]);
1289
1290 if ((i + 1) < orderByConditionFields.length) {
1291 if (orderByComparator.isAscending() ^ previous) {
1292 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1293 }
1294 else {
1295 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1296 }
1297 }
1298 else {
1299 if (orderByComparator.isAscending() ^ previous) {
1300 query.append(WHERE_GREATER_THAN);
1301 }
1302 else {
1303 query.append(WHERE_LESSER_THAN);
1304 }
1305 }
1306 }
1307
1308 query.append(ORDER_BY_CLAUSE);
1309
1310 String[] orderByFields = orderByComparator.getOrderByFields();
1311
1312 for (int i = 0; i < orderByFields.length; i++) {
1313 query.append(_ORDER_BY_ENTITY_ALIAS);
1314 query.append(orderByFields[i]);
1315
1316 if ((i + 1) < orderByFields.length) {
1317 if (orderByComparator.isAscending() ^ previous) {
1318 query.append(ORDER_BY_ASC_HAS_NEXT);
1319 }
1320 else {
1321 query.append(ORDER_BY_DESC_HAS_NEXT);
1322 }
1323 }
1324 else {
1325 if (orderByComparator.isAscending() ^ previous) {
1326 query.append(ORDER_BY_ASC);
1327 }
1328 else {
1329 query.append(ORDER_BY_DESC);
1330 }
1331 }
1332 }
1333 }
1334 else {
1335 query.append(LayoutSetBranchModelImpl.ORDER_BY_JPQL);
1336 }
1337
1338 String sql = query.toString();
1339
1340 Query q = session.createQuery(sql);
1341
1342 q.setFirstResult(0);
1343 q.setMaxResults(2);
1344
1345 QueryPos qPos = QueryPos.getInstance(q);
1346
1347 qPos.add(groupId);
1348
1349 qPos.add(privateLayout);
1350
1351 if (orderByComparator != null) {
1352 Object[] values = orderByComparator.getOrderByConditionValues(layoutSetBranch);
1353
1354 for (Object value : values) {
1355 qPos.add(value);
1356 }
1357 }
1358
1359 List<LayoutSetBranch> list = q.list();
1360
1361 if (list.size() == 2) {
1362 return list.get(1);
1363 }
1364 else {
1365 return null;
1366 }
1367 }
1368
1369
1377 public List<LayoutSetBranch> filterFindByG_P(long groupId,
1378 boolean privateLayout) throws SystemException {
1379 return filterFindByG_P(groupId, privateLayout, QueryUtil.ALL_POS,
1380 QueryUtil.ALL_POS, null);
1381 }
1382
1383
1397 public List<LayoutSetBranch> filterFindByG_P(long groupId,
1398 boolean privateLayout, int start, int end) throws SystemException {
1399 return filterFindByG_P(groupId, privateLayout, start, end, null);
1400 }
1401
1402
1417 public List<LayoutSetBranch> filterFindByG_P(long groupId,
1418 boolean privateLayout, int start, int end,
1419 OrderByComparator orderByComparator) throws SystemException {
1420 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1421 return findByG_P(groupId, privateLayout, start, end,
1422 orderByComparator);
1423 }
1424
1425 StringBundler query = null;
1426
1427 if (orderByComparator != null) {
1428 query = new StringBundler(4 +
1429 (orderByComparator.getOrderByFields().length * 3));
1430 }
1431 else {
1432 query = new StringBundler(4);
1433 }
1434
1435 if (getDB().isSupportsInlineDistinct()) {
1436 query.append(_FILTER_SQL_SELECT_LAYOUTSETBRANCH_WHERE);
1437 }
1438 else {
1439 query.append(_FILTER_SQL_SELECT_LAYOUTSETBRANCH_NO_INLINE_DISTINCT_WHERE_1);
1440 }
1441
1442 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
1443
1444 query.append(_FINDER_COLUMN_G_P_PRIVATELAYOUT_2);
1445
1446 if (!getDB().isSupportsInlineDistinct()) {
1447 query.append(_FILTER_SQL_SELECT_LAYOUTSETBRANCH_NO_INLINE_DISTINCT_WHERE_2);
1448 }
1449
1450 if (orderByComparator != null) {
1451 if (getDB().isSupportsInlineDistinct()) {
1452 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1453 orderByComparator);
1454 }
1455 else {
1456 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
1457 orderByComparator);
1458 }
1459 }
1460 else {
1461 if (getDB().isSupportsInlineDistinct()) {
1462 query.append(LayoutSetBranchModelImpl.ORDER_BY_JPQL);
1463 }
1464 else {
1465 query.append(LayoutSetBranchModelImpl.ORDER_BY_SQL);
1466 }
1467 }
1468
1469 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1470 LayoutSetBranch.class.getName(),
1471 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
1472
1473 Session session = null;
1474
1475 try {
1476 session = openSession();
1477
1478 SQLQuery q = session.createSQLQuery(sql);
1479
1480 if (getDB().isSupportsInlineDistinct()) {
1481 q.addEntity(_FILTER_ENTITY_ALIAS, LayoutSetBranchImpl.class);
1482 }
1483 else {
1484 q.addEntity(_FILTER_ENTITY_TABLE, LayoutSetBranchImpl.class);
1485 }
1486
1487 QueryPos qPos = QueryPos.getInstance(q);
1488
1489 qPos.add(groupId);
1490
1491 qPos.add(privateLayout);
1492
1493 return (List<LayoutSetBranch>)QueryUtil.list(q, getDialect(),
1494 start, end);
1495 }
1496 catch (Exception e) {
1497 throw processException(e);
1498 }
1499 finally {
1500 closeSession(session);
1501 }
1502 }
1503
1504
1515 public LayoutSetBranch[] filterFindByG_P_PrevAndNext(
1516 long layoutSetBranchId, long groupId, boolean privateLayout,
1517 OrderByComparator orderByComparator)
1518 throws NoSuchLayoutSetBranchException, SystemException {
1519 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1520 return findByG_P_PrevAndNext(layoutSetBranchId, groupId,
1521 privateLayout, orderByComparator);
1522 }
1523
1524 LayoutSetBranch layoutSetBranch = findByPrimaryKey(layoutSetBranchId);
1525
1526 Session session = null;
1527
1528 try {
1529 session = openSession();
1530
1531 LayoutSetBranch[] array = new LayoutSetBranchImpl[3];
1532
1533 array[0] = filterGetByG_P_PrevAndNext(session, layoutSetBranch,
1534 groupId, privateLayout, orderByComparator, true);
1535
1536 array[1] = layoutSetBranch;
1537
1538 array[2] = filterGetByG_P_PrevAndNext(session, layoutSetBranch,
1539 groupId, privateLayout, orderByComparator, false);
1540
1541 return array;
1542 }
1543 catch (Exception e) {
1544 throw processException(e);
1545 }
1546 finally {
1547 closeSession(session);
1548 }
1549 }
1550
1551 protected LayoutSetBranch filterGetByG_P_PrevAndNext(Session session,
1552 LayoutSetBranch layoutSetBranch, long groupId, boolean privateLayout,
1553 OrderByComparator orderByComparator, boolean previous) {
1554 StringBundler query = null;
1555
1556 if (orderByComparator != null) {
1557 query = new StringBundler(6 +
1558 (orderByComparator.getOrderByFields().length * 6));
1559 }
1560 else {
1561 query = new StringBundler(3);
1562 }
1563
1564 if (getDB().isSupportsInlineDistinct()) {
1565 query.append(_FILTER_SQL_SELECT_LAYOUTSETBRANCH_WHERE);
1566 }
1567 else {
1568 query.append(_FILTER_SQL_SELECT_LAYOUTSETBRANCH_NO_INLINE_DISTINCT_WHERE_1);
1569 }
1570
1571 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
1572
1573 query.append(_FINDER_COLUMN_G_P_PRIVATELAYOUT_2);
1574
1575 if (!getDB().isSupportsInlineDistinct()) {
1576 query.append(_FILTER_SQL_SELECT_LAYOUTSETBRANCH_NO_INLINE_DISTINCT_WHERE_2);
1577 }
1578
1579 if (orderByComparator != null) {
1580 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1581
1582 if (orderByConditionFields.length > 0) {
1583 query.append(WHERE_AND);
1584 }
1585
1586 for (int i = 0; i < orderByConditionFields.length; i++) {
1587 if (getDB().isSupportsInlineDistinct()) {
1588 query.append(_ORDER_BY_ENTITY_ALIAS);
1589 }
1590 else {
1591 query.append(_ORDER_BY_ENTITY_TABLE);
1592 }
1593
1594 query.append(orderByConditionFields[i]);
1595
1596 if ((i + 1) < orderByConditionFields.length) {
1597 if (orderByComparator.isAscending() ^ previous) {
1598 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1599 }
1600 else {
1601 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1602 }
1603 }
1604 else {
1605 if (orderByComparator.isAscending() ^ previous) {
1606 query.append(WHERE_GREATER_THAN);
1607 }
1608 else {
1609 query.append(WHERE_LESSER_THAN);
1610 }
1611 }
1612 }
1613
1614 query.append(ORDER_BY_CLAUSE);
1615
1616 String[] orderByFields = orderByComparator.getOrderByFields();
1617
1618 for (int i = 0; i < orderByFields.length; i++) {
1619 if (getDB().isSupportsInlineDistinct()) {
1620 query.append(_ORDER_BY_ENTITY_ALIAS);
1621 }
1622 else {
1623 query.append(_ORDER_BY_ENTITY_TABLE);
1624 }
1625
1626 query.append(orderByFields[i]);
1627
1628 if ((i + 1) < orderByFields.length) {
1629 if (orderByComparator.isAscending() ^ previous) {
1630 query.append(ORDER_BY_ASC_HAS_NEXT);
1631 }
1632 else {
1633 query.append(ORDER_BY_DESC_HAS_NEXT);
1634 }
1635 }
1636 else {
1637 if (orderByComparator.isAscending() ^ previous) {
1638 query.append(ORDER_BY_ASC);
1639 }
1640 else {
1641 query.append(ORDER_BY_DESC);
1642 }
1643 }
1644 }
1645 }
1646 else {
1647 if (getDB().isSupportsInlineDistinct()) {
1648 query.append(LayoutSetBranchModelImpl.ORDER_BY_JPQL);
1649 }
1650 else {
1651 query.append(LayoutSetBranchModelImpl.ORDER_BY_SQL);
1652 }
1653 }
1654
1655 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1656 LayoutSetBranch.class.getName(),
1657 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
1658
1659 SQLQuery q = session.createSQLQuery(sql);
1660
1661 q.setFirstResult(0);
1662 q.setMaxResults(2);
1663
1664 if (getDB().isSupportsInlineDistinct()) {
1665 q.addEntity(_FILTER_ENTITY_ALIAS, LayoutSetBranchImpl.class);
1666 }
1667 else {
1668 q.addEntity(_FILTER_ENTITY_TABLE, LayoutSetBranchImpl.class);
1669 }
1670
1671 QueryPos qPos = QueryPos.getInstance(q);
1672
1673 qPos.add(groupId);
1674
1675 qPos.add(privateLayout);
1676
1677 if (orderByComparator != null) {
1678 Object[] values = orderByComparator.getOrderByConditionValues(layoutSetBranch);
1679
1680 for (Object value : values) {
1681 qPos.add(value);
1682 }
1683 }
1684
1685 List<LayoutSetBranch> list = q.list();
1686
1687 if (list.size() == 2) {
1688 return list.get(1);
1689 }
1690 else {
1691 return null;
1692 }
1693 }
1694
1695
1702 public void removeByG_P(long groupId, boolean privateLayout)
1703 throws SystemException {
1704 for (LayoutSetBranch layoutSetBranch : findByG_P(groupId,
1705 privateLayout, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1706 remove(layoutSetBranch);
1707 }
1708 }
1709
1710
1718 public int countByG_P(long groupId, boolean privateLayout)
1719 throws SystemException {
1720 FinderPath finderPath = FINDER_PATH_COUNT_BY_G_P;
1721
1722 Object[] finderArgs = new Object[] { groupId, privateLayout };
1723
1724 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1725 this);
1726
1727 if (count == null) {
1728 StringBundler query = new StringBundler(3);
1729
1730 query.append(_SQL_COUNT_LAYOUTSETBRANCH_WHERE);
1731
1732 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
1733
1734 query.append(_FINDER_COLUMN_G_P_PRIVATELAYOUT_2);
1735
1736 String sql = query.toString();
1737
1738 Session session = null;
1739
1740 try {
1741 session = openSession();
1742
1743 Query q = session.createQuery(sql);
1744
1745 QueryPos qPos = QueryPos.getInstance(q);
1746
1747 qPos.add(groupId);
1748
1749 qPos.add(privateLayout);
1750
1751 count = (Long)q.uniqueResult();
1752
1753 FinderCacheUtil.putResult(finderPath, finderArgs, count);
1754 }
1755 catch (Exception e) {
1756 FinderCacheUtil.removeResult(finderPath, finderArgs);
1757
1758 throw processException(e);
1759 }
1760 finally {
1761 closeSession(session);
1762 }
1763 }
1764
1765 return count.intValue();
1766 }
1767
1768
1776 public int filterCountByG_P(long groupId, boolean privateLayout)
1777 throws SystemException {
1778 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1779 return countByG_P(groupId, privateLayout);
1780 }
1781
1782 StringBundler query = new StringBundler(3);
1783
1784 query.append(_FILTER_SQL_COUNT_LAYOUTSETBRANCH_WHERE);
1785
1786 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
1787
1788 query.append(_FINDER_COLUMN_G_P_PRIVATELAYOUT_2);
1789
1790 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1791 LayoutSetBranch.class.getName(),
1792 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
1793
1794 Session session = null;
1795
1796 try {
1797 session = openSession();
1798
1799 SQLQuery q = session.createSQLQuery(sql);
1800
1801 q.addScalar(COUNT_COLUMN_NAME,
1802 com.liferay.portal.kernel.dao.orm.Type.LONG);
1803
1804 QueryPos qPos = QueryPos.getInstance(q);
1805
1806 qPos.add(groupId);
1807
1808 qPos.add(privateLayout);
1809
1810 Long count = (Long)q.uniqueResult();
1811
1812 return count.intValue();
1813 }
1814 catch (Exception e) {
1815 throw processException(e);
1816 }
1817 finally {
1818 closeSession(session);
1819 }
1820 }
1821
1822 private static final String _FINDER_COLUMN_G_P_GROUPID_2 = "layoutSetBranch.groupId = ? AND ";
1823 private static final String _FINDER_COLUMN_G_P_PRIVATELAYOUT_2 = "layoutSetBranch.privateLayout = ?";
1824 public static final FinderPath FINDER_PATH_FETCH_BY_G_P_N = new FinderPath(LayoutSetBranchModelImpl.ENTITY_CACHE_ENABLED,
1825 LayoutSetBranchModelImpl.FINDER_CACHE_ENABLED,
1826 LayoutSetBranchImpl.class, FINDER_CLASS_NAME_ENTITY,
1827 "fetchByG_P_N",
1828 new String[] {
1829 Long.class.getName(), Boolean.class.getName(),
1830 String.class.getName()
1831 },
1832 LayoutSetBranchModelImpl.GROUPID_COLUMN_BITMASK |
1833 LayoutSetBranchModelImpl.PRIVATELAYOUT_COLUMN_BITMASK |
1834 LayoutSetBranchModelImpl.NAME_COLUMN_BITMASK);
1835 public static final FinderPath FINDER_PATH_COUNT_BY_G_P_N = new FinderPath(LayoutSetBranchModelImpl.ENTITY_CACHE_ENABLED,
1836 LayoutSetBranchModelImpl.FINDER_CACHE_ENABLED, Long.class,
1837 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_P_N",
1838 new String[] {
1839 Long.class.getName(), Boolean.class.getName(),
1840 String.class.getName()
1841 });
1842
1843
1853 public LayoutSetBranch findByG_P_N(long groupId, boolean privateLayout,
1854 String name) throws NoSuchLayoutSetBranchException, SystemException {
1855 LayoutSetBranch layoutSetBranch = fetchByG_P_N(groupId, privateLayout,
1856 name);
1857
1858 if (layoutSetBranch == null) {
1859 StringBundler msg = new StringBundler(8);
1860
1861 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1862
1863 msg.append("groupId=");
1864 msg.append(groupId);
1865
1866 msg.append(", privateLayout=");
1867 msg.append(privateLayout);
1868
1869 msg.append(", name=");
1870 msg.append(name);
1871
1872 msg.append(StringPool.CLOSE_CURLY_BRACE);
1873
1874 if (_log.isWarnEnabled()) {
1875 _log.warn(msg.toString());
1876 }
1877
1878 throw new NoSuchLayoutSetBranchException(msg.toString());
1879 }
1880
1881 return layoutSetBranch;
1882 }
1883
1884
1893 public LayoutSetBranch fetchByG_P_N(long groupId, boolean privateLayout,
1894 String name) throws SystemException {
1895 return fetchByG_P_N(groupId, privateLayout, name, true);
1896 }
1897
1898
1908 public LayoutSetBranch fetchByG_P_N(long groupId, boolean privateLayout,
1909 String name, boolean retrieveFromCache) throws SystemException {
1910 Object[] finderArgs = new Object[] { groupId, privateLayout, name };
1911
1912 Object result = null;
1913
1914 if (retrieveFromCache) {
1915 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_P_N,
1916 finderArgs, this);
1917 }
1918
1919 if (result instanceof LayoutSetBranch) {
1920 LayoutSetBranch layoutSetBranch = (LayoutSetBranch)result;
1921
1922 if ((groupId != layoutSetBranch.getGroupId()) ||
1923 (privateLayout != layoutSetBranch.getPrivateLayout()) ||
1924 !Validator.equals(name, layoutSetBranch.getName())) {
1925 result = null;
1926 }
1927 }
1928
1929 if (result == null) {
1930 StringBundler query = new StringBundler(5);
1931
1932 query.append(_SQL_SELECT_LAYOUTSETBRANCH_WHERE);
1933
1934 query.append(_FINDER_COLUMN_G_P_N_GROUPID_2);
1935
1936 query.append(_FINDER_COLUMN_G_P_N_PRIVATELAYOUT_2);
1937
1938 boolean bindName = false;
1939
1940 if (name == null) {
1941 query.append(_FINDER_COLUMN_G_P_N_NAME_1);
1942 }
1943 else if (name.equals(StringPool.BLANK)) {
1944 query.append(_FINDER_COLUMN_G_P_N_NAME_3);
1945 }
1946 else {
1947 bindName = true;
1948
1949 query.append(_FINDER_COLUMN_G_P_N_NAME_2);
1950 }
1951
1952 String sql = query.toString();
1953
1954 Session session = null;
1955
1956 try {
1957 session = openSession();
1958
1959 Query q = session.createQuery(sql);
1960
1961 QueryPos qPos = QueryPos.getInstance(q);
1962
1963 qPos.add(groupId);
1964
1965 qPos.add(privateLayout);
1966
1967 if (bindName) {
1968 qPos.add(name);
1969 }
1970
1971 List<LayoutSetBranch> list = q.list();
1972
1973 if (list.isEmpty()) {
1974 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P_N,
1975 finderArgs, list);
1976 }
1977 else {
1978 LayoutSetBranch layoutSetBranch = list.get(0);
1979
1980 result = layoutSetBranch;
1981
1982 cacheResult(layoutSetBranch);
1983
1984 if ((layoutSetBranch.getGroupId() != groupId) ||
1985 (layoutSetBranch.getPrivateLayout() != privateLayout) ||
1986 (layoutSetBranch.getName() == null) ||
1987 !layoutSetBranch.getName().equals(name)) {
1988 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P_N,
1989 finderArgs, layoutSetBranch);
1990 }
1991 }
1992 }
1993 catch (Exception e) {
1994 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_P_N,
1995 finderArgs);
1996
1997 throw processException(e);
1998 }
1999 finally {
2000 closeSession(session);
2001 }
2002 }
2003
2004 if (result instanceof List<?>) {
2005 return null;
2006 }
2007 else {
2008 return (LayoutSetBranch)result;
2009 }
2010 }
2011
2012
2021 public LayoutSetBranch removeByG_P_N(long groupId, boolean privateLayout,
2022 String name) throws NoSuchLayoutSetBranchException, SystemException {
2023 LayoutSetBranch layoutSetBranch = findByG_P_N(groupId, privateLayout,
2024 name);
2025
2026 return remove(layoutSetBranch);
2027 }
2028
2029
2038 public int countByG_P_N(long groupId, boolean privateLayout, String name)
2039 throws SystemException {
2040 FinderPath finderPath = FINDER_PATH_COUNT_BY_G_P_N;
2041
2042 Object[] finderArgs = new Object[] { groupId, privateLayout, name };
2043
2044 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
2045 this);
2046
2047 if (count == null) {
2048 StringBundler query = new StringBundler(4);
2049
2050 query.append(_SQL_COUNT_LAYOUTSETBRANCH_WHERE);
2051
2052 query.append(_FINDER_COLUMN_G_P_N_GROUPID_2);
2053
2054 query.append(_FINDER_COLUMN_G_P_N_PRIVATELAYOUT_2);
2055
2056 boolean bindName = false;
2057
2058 if (name == null) {
2059 query.append(_FINDER_COLUMN_G_P_N_NAME_1);
2060 }
2061 else if (name.equals(StringPool.BLANK)) {
2062 query.append(_FINDER_COLUMN_G_P_N_NAME_3);
2063 }
2064 else {
2065 bindName = true;
2066
2067 query.append(_FINDER_COLUMN_G_P_N_NAME_2);
2068 }
2069
2070 String sql = query.toString();
2071
2072 Session session = null;
2073
2074 try {
2075 session = openSession();
2076
2077 Query q = session.createQuery(sql);
2078
2079 QueryPos qPos = QueryPos.getInstance(q);
2080
2081 qPos.add(groupId);
2082
2083 qPos.add(privateLayout);
2084
2085 if (bindName) {
2086 qPos.add(name);
2087 }
2088
2089 count = (Long)q.uniqueResult();
2090
2091 FinderCacheUtil.putResult(finderPath, finderArgs, count);
2092 }
2093 catch (Exception e) {
2094 FinderCacheUtil.removeResult(finderPath, finderArgs);
2095
2096 throw processException(e);
2097 }
2098 finally {
2099 closeSession(session);
2100 }
2101 }
2102
2103 return count.intValue();
2104 }
2105
2106 private static final String _FINDER_COLUMN_G_P_N_GROUPID_2 = "layoutSetBranch.groupId = ? AND ";
2107 private static final String _FINDER_COLUMN_G_P_N_PRIVATELAYOUT_2 = "layoutSetBranch.privateLayout = ? AND ";
2108 private static final String _FINDER_COLUMN_G_P_N_NAME_1 = "layoutSetBranch.name IS NULL";
2109 private static final String _FINDER_COLUMN_G_P_N_NAME_2 = "layoutSetBranch.name = ?";
2110 private static final String _FINDER_COLUMN_G_P_N_NAME_3 = "(layoutSetBranch.name IS NULL OR layoutSetBranch.name = '')";
2111
2112
2117 public void cacheResult(LayoutSetBranch layoutSetBranch) {
2118 EntityCacheUtil.putResult(LayoutSetBranchModelImpl.ENTITY_CACHE_ENABLED,
2119 LayoutSetBranchImpl.class, layoutSetBranch.getPrimaryKey(),
2120 layoutSetBranch);
2121
2122 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P_N,
2123 new Object[] {
2124 layoutSetBranch.getGroupId(), layoutSetBranch.getPrivateLayout(),
2125 layoutSetBranch.getName()
2126 }, layoutSetBranch);
2127
2128 layoutSetBranch.resetOriginalValues();
2129 }
2130
2131
2136 public void cacheResult(List<LayoutSetBranch> layoutSetBranchs) {
2137 for (LayoutSetBranch layoutSetBranch : layoutSetBranchs) {
2138 if (EntityCacheUtil.getResult(
2139 LayoutSetBranchModelImpl.ENTITY_CACHE_ENABLED,
2140 LayoutSetBranchImpl.class,
2141 layoutSetBranch.getPrimaryKey()) == null) {
2142 cacheResult(layoutSetBranch);
2143 }
2144 else {
2145 layoutSetBranch.resetOriginalValues();
2146 }
2147 }
2148 }
2149
2150
2157 @Override
2158 public void clearCache() {
2159 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
2160 CacheRegistryUtil.clear(LayoutSetBranchImpl.class.getName());
2161 }
2162
2163 EntityCacheUtil.clearCache(LayoutSetBranchImpl.class.getName());
2164
2165 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
2166 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2167 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2168 }
2169
2170
2177 @Override
2178 public void clearCache(LayoutSetBranch layoutSetBranch) {
2179 EntityCacheUtil.removeResult(LayoutSetBranchModelImpl.ENTITY_CACHE_ENABLED,
2180 LayoutSetBranchImpl.class, layoutSetBranch.getPrimaryKey());
2181
2182 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2183 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2184
2185 clearUniqueFindersCache(layoutSetBranch);
2186 }
2187
2188 @Override
2189 public void clearCache(List<LayoutSetBranch> layoutSetBranchs) {
2190 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2191 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2192
2193 for (LayoutSetBranch layoutSetBranch : layoutSetBranchs) {
2194 EntityCacheUtil.removeResult(LayoutSetBranchModelImpl.ENTITY_CACHE_ENABLED,
2195 LayoutSetBranchImpl.class, layoutSetBranch.getPrimaryKey());
2196
2197 clearUniqueFindersCache(layoutSetBranch);
2198 }
2199 }
2200
2201 protected void cacheUniqueFindersCache(LayoutSetBranch layoutSetBranch) {
2202 if (layoutSetBranch.isNew()) {
2203 Object[] args = new Object[] {
2204 layoutSetBranch.getGroupId(),
2205 layoutSetBranch.getPrivateLayout(),
2206 layoutSetBranch.getName()
2207 };
2208
2209 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_P_N, args,
2210 Long.valueOf(1));
2211 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P_N, args,
2212 layoutSetBranch);
2213 }
2214 else {
2215 LayoutSetBranchModelImpl layoutSetBranchModelImpl = (LayoutSetBranchModelImpl)layoutSetBranch;
2216
2217 if ((layoutSetBranchModelImpl.getColumnBitmask() &
2218 FINDER_PATH_FETCH_BY_G_P_N.getColumnBitmask()) != 0) {
2219 Object[] args = new Object[] {
2220 layoutSetBranch.getGroupId(),
2221 layoutSetBranch.getPrivateLayout(),
2222 layoutSetBranch.getName()
2223 };
2224
2225 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_P_N, args,
2226 Long.valueOf(1));
2227 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P_N, args,
2228 layoutSetBranch);
2229 }
2230 }
2231 }
2232
2233 protected void clearUniqueFindersCache(LayoutSetBranch layoutSetBranch) {
2234 LayoutSetBranchModelImpl layoutSetBranchModelImpl = (LayoutSetBranchModelImpl)layoutSetBranch;
2235
2236 Object[] args = new Object[] {
2237 layoutSetBranch.getGroupId(), layoutSetBranch.getPrivateLayout(),
2238 layoutSetBranch.getName()
2239 };
2240
2241 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P_N, args);
2242 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_P_N, args);
2243
2244 if ((layoutSetBranchModelImpl.getColumnBitmask() &
2245 FINDER_PATH_FETCH_BY_G_P_N.getColumnBitmask()) != 0) {
2246 args = new Object[] {
2247 layoutSetBranchModelImpl.getOriginalGroupId(),
2248 layoutSetBranchModelImpl.getOriginalPrivateLayout(),
2249 layoutSetBranchModelImpl.getOriginalName()
2250 };
2251
2252 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P_N, args);
2253 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_P_N, args);
2254 }
2255 }
2256
2257
2263 public LayoutSetBranch create(long layoutSetBranchId) {
2264 LayoutSetBranch layoutSetBranch = new LayoutSetBranchImpl();
2265
2266 layoutSetBranch.setNew(true);
2267 layoutSetBranch.setPrimaryKey(layoutSetBranchId);
2268
2269 return layoutSetBranch;
2270 }
2271
2272
2280 public LayoutSetBranch remove(long layoutSetBranchId)
2281 throws NoSuchLayoutSetBranchException, SystemException {
2282 return remove((Serializable)layoutSetBranchId);
2283 }
2284
2285
2293 @Override
2294 public LayoutSetBranch remove(Serializable primaryKey)
2295 throws NoSuchLayoutSetBranchException, SystemException {
2296 Session session = null;
2297
2298 try {
2299 session = openSession();
2300
2301 LayoutSetBranch layoutSetBranch = (LayoutSetBranch)session.get(LayoutSetBranchImpl.class,
2302 primaryKey);
2303
2304 if (layoutSetBranch == null) {
2305 if (_log.isWarnEnabled()) {
2306 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
2307 }
2308
2309 throw new NoSuchLayoutSetBranchException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
2310 primaryKey);
2311 }
2312
2313 return remove(layoutSetBranch);
2314 }
2315 catch (NoSuchLayoutSetBranchException nsee) {
2316 throw nsee;
2317 }
2318 catch (Exception e) {
2319 throw processException(e);
2320 }
2321 finally {
2322 closeSession(session);
2323 }
2324 }
2325
2326 @Override
2327 protected LayoutSetBranch removeImpl(LayoutSetBranch layoutSetBranch)
2328 throws SystemException {
2329 layoutSetBranch = toUnwrappedModel(layoutSetBranch);
2330
2331 Session session = null;
2332
2333 try {
2334 session = openSession();
2335
2336 if (!session.contains(layoutSetBranch)) {
2337 layoutSetBranch = (LayoutSetBranch)session.get(LayoutSetBranchImpl.class,
2338 layoutSetBranch.getPrimaryKeyObj());
2339 }
2340
2341 if (layoutSetBranch != null) {
2342 session.delete(layoutSetBranch);
2343 }
2344 }
2345 catch (Exception e) {
2346 throw processException(e);
2347 }
2348 finally {
2349 closeSession(session);
2350 }
2351
2352 if (layoutSetBranch != null) {
2353 clearCache(layoutSetBranch);
2354 }
2355
2356 return layoutSetBranch;
2357 }
2358
2359 @Override
2360 public LayoutSetBranch updateImpl(
2361 com.liferay.portal.model.LayoutSetBranch layoutSetBranch)
2362 throws SystemException {
2363 layoutSetBranch = toUnwrappedModel(layoutSetBranch);
2364
2365 boolean isNew = layoutSetBranch.isNew();
2366
2367 LayoutSetBranchModelImpl layoutSetBranchModelImpl = (LayoutSetBranchModelImpl)layoutSetBranch;
2368
2369 Session session = null;
2370
2371 try {
2372 session = openSession();
2373
2374 if (layoutSetBranch.isNew()) {
2375 session.save(layoutSetBranch);
2376
2377 layoutSetBranch.setNew(false);
2378 }
2379 else {
2380 session.merge(layoutSetBranch);
2381 }
2382 }
2383 catch (Exception e) {
2384 throw processException(e);
2385 }
2386 finally {
2387 closeSession(session);
2388 }
2389
2390 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2391
2392 if (isNew || !LayoutSetBranchModelImpl.COLUMN_BITMASK_ENABLED) {
2393 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2394 }
2395
2396 else {
2397 if ((layoutSetBranchModelImpl.getColumnBitmask() &
2398 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
2399 Object[] args = new Object[] {
2400 layoutSetBranchModelImpl.getOriginalGroupId()
2401 };
2402
2403 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
2404 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
2405 args);
2406
2407 args = new Object[] { layoutSetBranchModelImpl.getGroupId() };
2408
2409 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
2410 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
2411 args);
2412 }
2413
2414 if ((layoutSetBranchModelImpl.getColumnBitmask() &
2415 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P.getColumnBitmask()) != 0) {
2416 Object[] args = new Object[] {
2417 layoutSetBranchModelImpl.getOriginalGroupId(),
2418 layoutSetBranchModelImpl.getOriginalPrivateLayout()
2419 };
2420
2421 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P, args);
2422 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P,
2423 args);
2424
2425 args = new Object[] {
2426 layoutSetBranchModelImpl.getGroupId(),
2427 layoutSetBranchModelImpl.getPrivateLayout()
2428 };
2429
2430 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P, args);
2431 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P,
2432 args);
2433 }
2434 }
2435
2436 EntityCacheUtil.putResult(LayoutSetBranchModelImpl.ENTITY_CACHE_ENABLED,
2437 LayoutSetBranchImpl.class, layoutSetBranch.getPrimaryKey(),
2438 layoutSetBranch);
2439
2440 clearUniqueFindersCache(layoutSetBranch);
2441 cacheUniqueFindersCache(layoutSetBranch);
2442
2443 return layoutSetBranch;
2444 }
2445
2446 protected LayoutSetBranch toUnwrappedModel(LayoutSetBranch layoutSetBranch) {
2447 if (layoutSetBranch instanceof LayoutSetBranchImpl) {
2448 return layoutSetBranch;
2449 }
2450
2451 LayoutSetBranchImpl layoutSetBranchImpl = new LayoutSetBranchImpl();
2452
2453 layoutSetBranchImpl.setNew(layoutSetBranch.isNew());
2454 layoutSetBranchImpl.setPrimaryKey(layoutSetBranch.getPrimaryKey());
2455
2456 layoutSetBranchImpl.setLayoutSetBranchId(layoutSetBranch.getLayoutSetBranchId());
2457 layoutSetBranchImpl.setGroupId(layoutSetBranch.getGroupId());
2458 layoutSetBranchImpl.setCompanyId(layoutSetBranch.getCompanyId());
2459 layoutSetBranchImpl.setUserId(layoutSetBranch.getUserId());
2460 layoutSetBranchImpl.setUserName(layoutSetBranch.getUserName());
2461 layoutSetBranchImpl.setCreateDate(layoutSetBranch.getCreateDate());
2462 layoutSetBranchImpl.setModifiedDate(layoutSetBranch.getModifiedDate());
2463 layoutSetBranchImpl.setPrivateLayout(layoutSetBranch.isPrivateLayout());
2464 layoutSetBranchImpl.setName(layoutSetBranch.getName());
2465 layoutSetBranchImpl.setDescription(layoutSetBranch.getDescription());
2466 layoutSetBranchImpl.setMaster(layoutSetBranch.isMaster());
2467 layoutSetBranchImpl.setLogo(layoutSetBranch.isLogo());
2468 layoutSetBranchImpl.setLogoId(layoutSetBranch.getLogoId());
2469 layoutSetBranchImpl.setThemeId(layoutSetBranch.getThemeId());
2470 layoutSetBranchImpl.setColorSchemeId(layoutSetBranch.getColorSchemeId());
2471 layoutSetBranchImpl.setWapThemeId(layoutSetBranch.getWapThemeId());
2472 layoutSetBranchImpl.setWapColorSchemeId(layoutSetBranch.getWapColorSchemeId());
2473 layoutSetBranchImpl.setCss(layoutSetBranch.getCss());
2474 layoutSetBranchImpl.setSettings(layoutSetBranch.getSettings());
2475 layoutSetBranchImpl.setLayoutSetPrototypeUuid(layoutSetBranch.getLayoutSetPrototypeUuid());
2476 layoutSetBranchImpl.setLayoutSetPrototypeLinkEnabled(layoutSetBranch.isLayoutSetPrototypeLinkEnabled());
2477
2478 return layoutSetBranchImpl;
2479 }
2480
2481
2489 @Override
2490 public LayoutSetBranch findByPrimaryKey(Serializable primaryKey)
2491 throws NoSuchLayoutSetBranchException, SystemException {
2492 LayoutSetBranch layoutSetBranch = fetchByPrimaryKey(primaryKey);
2493
2494 if (layoutSetBranch == null) {
2495 if (_log.isWarnEnabled()) {
2496 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
2497 }
2498
2499 throw new NoSuchLayoutSetBranchException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
2500 primaryKey);
2501 }
2502
2503 return layoutSetBranch;
2504 }
2505
2506
2514 public LayoutSetBranch findByPrimaryKey(long layoutSetBranchId)
2515 throws NoSuchLayoutSetBranchException, SystemException {
2516 return findByPrimaryKey((Serializable)layoutSetBranchId);
2517 }
2518
2519
2526 @Override
2527 public LayoutSetBranch fetchByPrimaryKey(Serializable primaryKey)
2528 throws SystemException {
2529 LayoutSetBranch layoutSetBranch = (LayoutSetBranch)EntityCacheUtil.getResult(LayoutSetBranchModelImpl.ENTITY_CACHE_ENABLED,
2530 LayoutSetBranchImpl.class, primaryKey);
2531
2532 if (layoutSetBranch == _nullLayoutSetBranch) {
2533 return null;
2534 }
2535
2536 if (layoutSetBranch == null) {
2537 Session session = null;
2538
2539 try {
2540 session = openSession();
2541
2542 layoutSetBranch = (LayoutSetBranch)session.get(LayoutSetBranchImpl.class,
2543 primaryKey);
2544
2545 if (layoutSetBranch != null) {
2546 cacheResult(layoutSetBranch);
2547 }
2548 else {
2549 EntityCacheUtil.putResult(LayoutSetBranchModelImpl.ENTITY_CACHE_ENABLED,
2550 LayoutSetBranchImpl.class, primaryKey,
2551 _nullLayoutSetBranch);
2552 }
2553 }
2554 catch (Exception e) {
2555 EntityCacheUtil.removeResult(LayoutSetBranchModelImpl.ENTITY_CACHE_ENABLED,
2556 LayoutSetBranchImpl.class, primaryKey);
2557
2558 throw processException(e);
2559 }
2560 finally {
2561 closeSession(session);
2562 }
2563 }
2564
2565 return layoutSetBranch;
2566 }
2567
2568
2575 public LayoutSetBranch fetchByPrimaryKey(long layoutSetBranchId)
2576 throws SystemException {
2577 return fetchByPrimaryKey((Serializable)layoutSetBranchId);
2578 }
2579
2580
2586 public List<LayoutSetBranch> findAll() throws SystemException {
2587 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2588 }
2589
2590
2602 public List<LayoutSetBranch> findAll(int start, int end)
2603 throws SystemException {
2604 return findAll(start, end, null);
2605 }
2606
2607
2620 public List<LayoutSetBranch> findAll(int start, int end,
2621 OrderByComparator orderByComparator) throws SystemException {
2622 boolean pagination = true;
2623 FinderPath finderPath = null;
2624 Object[] finderArgs = null;
2625
2626 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2627 (orderByComparator == null)) {
2628 pagination = false;
2629 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
2630 finderArgs = FINDER_ARGS_EMPTY;
2631 }
2632 else {
2633 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
2634 finderArgs = new Object[] { start, end, orderByComparator };
2635 }
2636
2637 List<LayoutSetBranch> list = (List<LayoutSetBranch>)FinderCacheUtil.getResult(finderPath,
2638 finderArgs, this);
2639
2640 if (list == null) {
2641 StringBundler query = null;
2642 String sql = null;
2643
2644 if (orderByComparator != null) {
2645 query = new StringBundler(2 +
2646 (orderByComparator.getOrderByFields().length * 3));
2647
2648 query.append(_SQL_SELECT_LAYOUTSETBRANCH);
2649
2650 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2651 orderByComparator);
2652
2653 sql = query.toString();
2654 }
2655 else {
2656 sql = _SQL_SELECT_LAYOUTSETBRANCH;
2657
2658 if (pagination) {
2659 sql = sql.concat(LayoutSetBranchModelImpl.ORDER_BY_JPQL);
2660 }
2661 }
2662
2663 Session session = null;
2664
2665 try {
2666 session = openSession();
2667
2668 Query q = session.createQuery(sql);
2669
2670 if (!pagination) {
2671 list = (List<LayoutSetBranch>)QueryUtil.list(q,
2672 getDialect(), start, end, false);
2673
2674 Collections.sort(list);
2675
2676 list = new UnmodifiableList<LayoutSetBranch>(list);
2677 }
2678 else {
2679 list = (List<LayoutSetBranch>)QueryUtil.list(q,
2680 getDialect(), start, end);
2681 }
2682
2683 cacheResult(list);
2684
2685 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2686 }
2687 catch (Exception e) {
2688 FinderCacheUtil.removeResult(finderPath, finderArgs);
2689
2690 throw processException(e);
2691 }
2692 finally {
2693 closeSession(session);
2694 }
2695 }
2696
2697 return list;
2698 }
2699
2700
2705 public void removeAll() throws SystemException {
2706 for (LayoutSetBranch layoutSetBranch : findAll()) {
2707 remove(layoutSetBranch);
2708 }
2709 }
2710
2711
2717 public int countAll() throws SystemException {
2718 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
2719 FINDER_ARGS_EMPTY, this);
2720
2721 if (count == null) {
2722 Session session = null;
2723
2724 try {
2725 session = openSession();
2726
2727 Query q = session.createQuery(_SQL_COUNT_LAYOUTSETBRANCH);
2728
2729 count = (Long)q.uniqueResult();
2730
2731 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
2732 FINDER_ARGS_EMPTY, count);
2733 }
2734 catch (Exception e) {
2735 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
2736 FINDER_ARGS_EMPTY);
2737
2738 throw processException(e);
2739 }
2740 finally {
2741 closeSession(session);
2742 }
2743 }
2744
2745 return count.intValue();
2746 }
2747
2748
2751 public void afterPropertiesSet() {
2752 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
2753 com.liferay.portal.util.PropsUtil.get(
2754 "value.object.listener.com.liferay.portal.model.LayoutSetBranch")));
2755
2756 if (listenerClassNames.length > 0) {
2757 try {
2758 List<ModelListener<LayoutSetBranch>> listenersList = new ArrayList<ModelListener<LayoutSetBranch>>();
2759
2760 for (String listenerClassName : listenerClassNames) {
2761 listenersList.add((ModelListener<LayoutSetBranch>)InstanceFactory.newInstance(
2762 listenerClassName));
2763 }
2764
2765 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
2766 }
2767 catch (Exception e) {
2768 _log.error(e);
2769 }
2770 }
2771 }
2772
2773 public void destroy() {
2774 EntityCacheUtil.removeCache(LayoutSetBranchImpl.class.getName());
2775 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
2776 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2777 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2778 }
2779
2780 private static final String _SQL_SELECT_LAYOUTSETBRANCH = "SELECT layoutSetBranch FROM LayoutSetBranch layoutSetBranch";
2781 private static final String _SQL_SELECT_LAYOUTSETBRANCH_WHERE = "SELECT layoutSetBranch FROM LayoutSetBranch layoutSetBranch WHERE ";
2782 private static final String _SQL_COUNT_LAYOUTSETBRANCH = "SELECT COUNT(layoutSetBranch) FROM LayoutSetBranch layoutSetBranch";
2783 private static final String _SQL_COUNT_LAYOUTSETBRANCH_WHERE = "SELECT COUNT(layoutSetBranch) FROM LayoutSetBranch layoutSetBranch WHERE ";
2784 private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "layoutSetBranch.layoutSetBranchId";
2785 private static final String _FILTER_SQL_SELECT_LAYOUTSETBRANCH_WHERE = "SELECT DISTINCT {layoutSetBranch.*} FROM LayoutSetBranch layoutSetBranch WHERE ";
2786 private static final String _FILTER_SQL_SELECT_LAYOUTSETBRANCH_NO_INLINE_DISTINCT_WHERE_1 =
2787 "SELECT {LayoutSetBranch.*} FROM (SELECT DISTINCT layoutSetBranch.layoutSetBranchId FROM LayoutSetBranch layoutSetBranch WHERE ";
2788 private static final String _FILTER_SQL_SELECT_LAYOUTSETBRANCH_NO_INLINE_DISTINCT_WHERE_2 =
2789 ") TEMP_TABLE INNER JOIN LayoutSetBranch ON TEMP_TABLE.layoutSetBranchId = LayoutSetBranch.layoutSetBranchId";
2790 private static final String _FILTER_SQL_COUNT_LAYOUTSETBRANCH_WHERE = "SELECT COUNT(DISTINCT layoutSetBranch.layoutSetBranchId) AS COUNT_VALUE FROM LayoutSetBranch layoutSetBranch WHERE ";
2791 private static final String _FILTER_ENTITY_ALIAS = "layoutSetBranch";
2792 private static final String _FILTER_ENTITY_TABLE = "LayoutSetBranch";
2793 private static final String _ORDER_BY_ENTITY_ALIAS = "layoutSetBranch.";
2794 private static final String _ORDER_BY_ENTITY_TABLE = "LayoutSetBranch.";
2795 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No LayoutSetBranch exists with the primary key ";
2796 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No LayoutSetBranch exists with the key {";
2797 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
2798 private static Log _log = LogFactoryUtil.getLog(LayoutSetBranchPersistenceImpl.class);
2799 private static LayoutSetBranch _nullLayoutSetBranch = new LayoutSetBranchImpl() {
2800 @Override
2801 public Object clone() {
2802 return this;
2803 }
2804
2805 @Override
2806 public CacheModel<LayoutSetBranch> toCacheModel() {
2807 return _nullLayoutSetBranchCacheModel;
2808 }
2809 };
2810
2811 private static CacheModel<LayoutSetBranch> _nullLayoutSetBranchCacheModel = new CacheModel<LayoutSetBranch>() {
2812 public LayoutSetBranch toEntityModel() {
2813 return _nullLayoutSetBranch;
2814 }
2815 };
2816 }