001
014
015 package com.liferay.portal.service.persistence;
016
017 import com.liferay.portal.NoSuchLayoutSetBranchException;
018 import com.liferay.portal.NoSuchModelException;
019 import com.liferay.portal.kernel.bean.BeanReference;
020 import com.liferay.portal.kernel.cache.CacheRegistryUtil;
021 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
022 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
023 import com.liferay.portal.kernel.dao.orm.FinderPath;
024 import com.liferay.portal.kernel.dao.orm.Query;
025 import com.liferay.portal.kernel.dao.orm.QueryPos;
026 import com.liferay.portal.kernel.dao.orm.QueryUtil;
027 import com.liferay.portal.kernel.dao.orm.SQLQuery;
028 import com.liferay.portal.kernel.dao.orm.Session;
029 import com.liferay.portal.kernel.exception.SystemException;
030 import com.liferay.portal.kernel.log.Log;
031 import com.liferay.portal.kernel.log.LogFactoryUtil;
032 import com.liferay.portal.kernel.util.GetterUtil;
033 import com.liferay.portal.kernel.util.InstanceFactory;
034 import com.liferay.portal.kernel.util.OrderByComparator;
035 import com.liferay.portal.kernel.util.StringBundler;
036 import com.liferay.portal.kernel.util.StringPool;
037 import com.liferay.portal.kernel.util.StringUtil;
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_BY_GROUPID = new FinderPath(LayoutSetBranchModelImpl.ENTITY_CACHE_ENABLED,
077 LayoutSetBranchModelImpl.FINDER_CACHE_ENABLED,
078 LayoutSetBranchImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
079 "findByGroupId",
080 new String[] {
081 Long.class.getName(),
082
083 "java.lang.Integer", "java.lang.Integer",
084 "com.liferay.portal.kernel.util.OrderByComparator"
085 });
086 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID =
087 new FinderPath(LayoutSetBranchModelImpl.ENTITY_CACHE_ENABLED,
088 LayoutSetBranchModelImpl.FINDER_CACHE_ENABLED,
089 LayoutSetBranchImpl.class,
090 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByGroupId",
091 new String[] { Long.class.getName() },
092 LayoutSetBranchModelImpl.GROUPID_COLUMN_BITMASK);
093 public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(LayoutSetBranchModelImpl.ENTITY_CACHE_ENABLED,
094 LayoutSetBranchModelImpl.FINDER_CACHE_ENABLED, Long.class,
095 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId",
096 new String[] { Long.class.getName() });
097 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P = new FinderPath(LayoutSetBranchModelImpl.ENTITY_CACHE_ENABLED,
098 LayoutSetBranchModelImpl.FINDER_CACHE_ENABLED,
099 LayoutSetBranchImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
100 "findByG_P",
101 new String[] {
102 Long.class.getName(), Boolean.class.getName(),
103
104 "java.lang.Integer", "java.lang.Integer",
105 "com.liferay.portal.kernel.util.OrderByComparator"
106 });
107 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P = new FinderPath(LayoutSetBranchModelImpl.ENTITY_CACHE_ENABLED,
108 LayoutSetBranchModelImpl.FINDER_CACHE_ENABLED,
109 LayoutSetBranchImpl.class,
110 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_P",
111 new String[] { Long.class.getName(), Boolean.class.getName() },
112 LayoutSetBranchModelImpl.GROUPID_COLUMN_BITMASK |
113 LayoutSetBranchModelImpl.PRIVATELAYOUT_COLUMN_BITMASK);
114 public static final FinderPath FINDER_PATH_COUNT_BY_G_P = new FinderPath(LayoutSetBranchModelImpl.ENTITY_CACHE_ENABLED,
115 LayoutSetBranchModelImpl.FINDER_CACHE_ENABLED, Long.class,
116 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_P",
117 new String[] { Long.class.getName(), Boolean.class.getName() });
118 public static final FinderPath FINDER_PATH_FETCH_BY_G_P_N = new FinderPath(LayoutSetBranchModelImpl.ENTITY_CACHE_ENABLED,
119 LayoutSetBranchModelImpl.FINDER_CACHE_ENABLED,
120 LayoutSetBranchImpl.class, FINDER_CLASS_NAME_ENTITY,
121 "fetchByG_P_N",
122 new String[] {
123 Long.class.getName(), Boolean.class.getName(),
124 String.class.getName()
125 },
126 LayoutSetBranchModelImpl.GROUPID_COLUMN_BITMASK |
127 LayoutSetBranchModelImpl.PRIVATELAYOUT_COLUMN_BITMASK |
128 LayoutSetBranchModelImpl.NAME_COLUMN_BITMASK);
129 public static final FinderPath FINDER_PATH_COUNT_BY_G_P_N = new FinderPath(LayoutSetBranchModelImpl.ENTITY_CACHE_ENABLED,
130 LayoutSetBranchModelImpl.FINDER_CACHE_ENABLED, Long.class,
131 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_P_N",
132 new String[] {
133 Long.class.getName(), Boolean.class.getName(),
134 String.class.getName()
135 });
136 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(LayoutSetBranchModelImpl.ENTITY_CACHE_ENABLED,
137 LayoutSetBranchModelImpl.FINDER_CACHE_ENABLED,
138 LayoutSetBranchImpl.class,
139 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
140 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(LayoutSetBranchModelImpl.ENTITY_CACHE_ENABLED,
141 LayoutSetBranchModelImpl.FINDER_CACHE_ENABLED,
142 LayoutSetBranchImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
143 "findAll", new String[0]);
144 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(LayoutSetBranchModelImpl.ENTITY_CACHE_ENABLED,
145 LayoutSetBranchModelImpl.FINDER_CACHE_ENABLED, Long.class,
146 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
147
148
153 public void cacheResult(LayoutSetBranch layoutSetBranch) {
154 EntityCacheUtil.putResult(LayoutSetBranchModelImpl.ENTITY_CACHE_ENABLED,
155 LayoutSetBranchImpl.class, layoutSetBranch.getPrimaryKey(),
156 layoutSetBranch);
157
158 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P_N,
159 new Object[] {
160 Long.valueOf(layoutSetBranch.getGroupId()),
161 Boolean.valueOf(layoutSetBranch.getPrivateLayout()),
162
163 layoutSetBranch.getName()
164 }, layoutSetBranch);
165
166 layoutSetBranch.resetOriginalValues();
167 }
168
169
174 public void cacheResult(List<LayoutSetBranch> layoutSetBranchs) {
175 for (LayoutSetBranch layoutSetBranch : layoutSetBranchs) {
176 if (EntityCacheUtil.getResult(
177 LayoutSetBranchModelImpl.ENTITY_CACHE_ENABLED,
178 LayoutSetBranchImpl.class,
179 layoutSetBranch.getPrimaryKey()) == null) {
180 cacheResult(layoutSetBranch);
181 }
182 else {
183 layoutSetBranch.resetOriginalValues();
184 }
185 }
186 }
187
188
195 @Override
196 public void clearCache() {
197 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
198 CacheRegistryUtil.clear(LayoutSetBranchImpl.class.getName());
199 }
200
201 EntityCacheUtil.clearCache(LayoutSetBranchImpl.class.getName());
202
203 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
204 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
205 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
206 }
207
208
215 @Override
216 public void clearCache(LayoutSetBranch layoutSetBranch) {
217 EntityCacheUtil.removeResult(LayoutSetBranchModelImpl.ENTITY_CACHE_ENABLED,
218 LayoutSetBranchImpl.class, layoutSetBranch.getPrimaryKey());
219
220 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
221 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
222
223 clearUniqueFindersCache(layoutSetBranch);
224 }
225
226 @Override
227 public void clearCache(List<LayoutSetBranch> layoutSetBranchs) {
228 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
229 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
230
231 for (LayoutSetBranch layoutSetBranch : layoutSetBranchs) {
232 EntityCacheUtil.removeResult(LayoutSetBranchModelImpl.ENTITY_CACHE_ENABLED,
233 LayoutSetBranchImpl.class, layoutSetBranch.getPrimaryKey());
234
235 clearUniqueFindersCache(layoutSetBranch);
236 }
237 }
238
239 protected void clearUniqueFindersCache(LayoutSetBranch layoutSetBranch) {
240 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_P_N,
241 new Object[] {
242 Long.valueOf(layoutSetBranch.getGroupId()),
243 Boolean.valueOf(layoutSetBranch.getPrivateLayout()),
244
245 layoutSetBranch.getName()
246 });
247 }
248
249
255 public LayoutSetBranch create(long layoutSetBranchId) {
256 LayoutSetBranch layoutSetBranch = new LayoutSetBranchImpl();
257
258 layoutSetBranch.setNew(true);
259 layoutSetBranch.setPrimaryKey(layoutSetBranchId);
260
261 return layoutSetBranch;
262 }
263
264
272 public LayoutSetBranch remove(long layoutSetBranchId)
273 throws NoSuchLayoutSetBranchException, SystemException {
274 return remove(Long.valueOf(layoutSetBranchId));
275 }
276
277
285 @Override
286 public LayoutSetBranch remove(Serializable primaryKey)
287 throws NoSuchLayoutSetBranchException, SystemException {
288 Session session = null;
289
290 try {
291 session = openSession();
292
293 LayoutSetBranch layoutSetBranch = (LayoutSetBranch)session.get(LayoutSetBranchImpl.class,
294 primaryKey);
295
296 if (layoutSetBranch == null) {
297 if (_log.isWarnEnabled()) {
298 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
299 }
300
301 throw new NoSuchLayoutSetBranchException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
302 primaryKey);
303 }
304
305 return remove(layoutSetBranch);
306 }
307 catch (NoSuchLayoutSetBranchException nsee) {
308 throw nsee;
309 }
310 catch (Exception e) {
311 throw processException(e);
312 }
313 finally {
314 closeSession(session);
315 }
316 }
317
318 @Override
319 protected LayoutSetBranch removeImpl(LayoutSetBranch layoutSetBranch)
320 throws SystemException {
321 layoutSetBranch = toUnwrappedModel(layoutSetBranch);
322
323 Session session = null;
324
325 try {
326 session = openSession();
327
328 BatchSessionUtil.delete(session, layoutSetBranch);
329 }
330 catch (Exception e) {
331 throw processException(e);
332 }
333 finally {
334 closeSession(session);
335 }
336
337 clearCache(layoutSetBranch);
338
339 return layoutSetBranch;
340 }
341
342 @Override
343 public LayoutSetBranch updateImpl(
344 com.liferay.portal.model.LayoutSetBranch layoutSetBranch, boolean merge)
345 throws SystemException {
346 layoutSetBranch = toUnwrappedModel(layoutSetBranch);
347
348 boolean isNew = layoutSetBranch.isNew();
349
350 LayoutSetBranchModelImpl layoutSetBranchModelImpl = (LayoutSetBranchModelImpl)layoutSetBranch;
351
352 Session session = null;
353
354 try {
355 session = openSession();
356
357 BatchSessionUtil.update(session, layoutSetBranch, merge);
358
359 layoutSetBranch.setNew(false);
360 }
361 catch (Exception e) {
362 throw processException(e);
363 }
364 finally {
365 closeSession(session);
366 }
367
368 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
369
370 if (isNew || !LayoutSetBranchModelImpl.COLUMN_BITMASK_ENABLED) {
371 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
372 }
373
374 else {
375 if ((layoutSetBranchModelImpl.getColumnBitmask() &
376 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
377 Object[] args = new Object[] {
378 Long.valueOf(layoutSetBranchModelImpl.getOriginalGroupId())
379 };
380
381 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
382 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
383 args);
384
385 args = new Object[] {
386 Long.valueOf(layoutSetBranchModelImpl.getGroupId())
387 };
388
389 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
390 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
391 args);
392 }
393
394 if ((layoutSetBranchModelImpl.getColumnBitmask() &
395 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P.getColumnBitmask()) != 0) {
396 Object[] args = new Object[] {
397 Long.valueOf(layoutSetBranchModelImpl.getOriginalGroupId()),
398 Boolean.valueOf(layoutSetBranchModelImpl.getOriginalPrivateLayout())
399 };
400
401 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P, args);
402 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P,
403 args);
404
405 args = new Object[] {
406 Long.valueOf(layoutSetBranchModelImpl.getGroupId()),
407 Boolean.valueOf(layoutSetBranchModelImpl.getPrivateLayout())
408 };
409
410 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P, args);
411 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P,
412 args);
413 }
414 }
415
416 EntityCacheUtil.putResult(LayoutSetBranchModelImpl.ENTITY_CACHE_ENABLED,
417 LayoutSetBranchImpl.class, layoutSetBranch.getPrimaryKey(),
418 layoutSetBranch);
419
420 if (isNew) {
421 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P_N,
422 new Object[] {
423 Long.valueOf(layoutSetBranch.getGroupId()),
424 Boolean.valueOf(layoutSetBranch.getPrivateLayout()),
425
426 layoutSetBranch.getName()
427 }, layoutSetBranch);
428 }
429 else {
430 if ((layoutSetBranchModelImpl.getColumnBitmask() &
431 FINDER_PATH_FETCH_BY_G_P_N.getColumnBitmask()) != 0) {
432 Object[] args = new Object[] {
433 Long.valueOf(layoutSetBranchModelImpl.getOriginalGroupId()),
434 Boolean.valueOf(layoutSetBranchModelImpl.getOriginalPrivateLayout()),
435
436 layoutSetBranchModelImpl.getOriginalName()
437 };
438
439 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P_N, args);
440 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_P_N, args);
441
442 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P_N,
443 new Object[] {
444 Long.valueOf(layoutSetBranch.getGroupId()),
445 Boolean.valueOf(layoutSetBranch.getPrivateLayout()),
446
447 layoutSetBranch.getName()
448 }, layoutSetBranch);
449 }
450 }
451
452 return layoutSetBranch;
453 }
454
455 protected LayoutSetBranch toUnwrappedModel(LayoutSetBranch layoutSetBranch) {
456 if (layoutSetBranch instanceof LayoutSetBranchImpl) {
457 return layoutSetBranch;
458 }
459
460 LayoutSetBranchImpl layoutSetBranchImpl = new LayoutSetBranchImpl();
461
462 layoutSetBranchImpl.setNew(layoutSetBranch.isNew());
463 layoutSetBranchImpl.setPrimaryKey(layoutSetBranch.getPrimaryKey());
464
465 layoutSetBranchImpl.setLayoutSetBranchId(layoutSetBranch.getLayoutSetBranchId());
466 layoutSetBranchImpl.setGroupId(layoutSetBranch.getGroupId());
467 layoutSetBranchImpl.setCompanyId(layoutSetBranch.getCompanyId());
468 layoutSetBranchImpl.setUserId(layoutSetBranch.getUserId());
469 layoutSetBranchImpl.setUserName(layoutSetBranch.getUserName());
470 layoutSetBranchImpl.setCreateDate(layoutSetBranch.getCreateDate());
471 layoutSetBranchImpl.setModifiedDate(layoutSetBranch.getModifiedDate());
472 layoutSetBranchImpl.setPrivateLayout(layoutSetBranch.isPrivateLayout());
473 layoutSetBranchImpl.setName(layoutSetBranch.getName());
474 layoutSetBranchImpl.setDescription(layoutSetBranch.getDescription());
475 layoutSetBranchImpl.setMaster(layoutSetBranch.isMaster());
476
477 return layoutSetBranchImpl;
478 }
479
480
488 @Override
489 public LayoutSetBranch findByPrimaryKey(Serializable primaryKey)
490 throws NoSuchModelException, SystemException {
491 return findByPrimaryKey(((Long)primaryKey).longValue());
492 }
493
494
502 public LayoutSetBranch findByPrimaryKey(long layoutSetBranchId)
503 throws NoSuchLayoutSetBranchException, SystemException {
504 LayoutSetBranch layoutSetBranch = fetchByPrimaryKey(layoutSetBranchId);
505
506 if (layoutSetBranch == null) {
507 if (_log.isWarnEnabled()) {
508 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + layoutSetBranchId);
509 }
510
511 throw new NoSuchLayoutSetBranchException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
512 layoutSetBranchId);
513 }
514
515 return layoutSetBranch;
516 }
517
518
525 @Override
526 public LayoutSetBranch fetchByPrimaryKey(Serializable primaryKey)
527 throws SystemException {
528 return fetchByPrimaryKey(((Long)primaryKey).longValue());
529 }
530
531
538 public LayoutSetBranch fetchByPrimaryKey(long layoutSetBranchId)
539 throws SystemException {
540 LayoutSetBranch layoutSetBranch = (LayoutSetBranch)EntityCacheUtil.getResult(LayoutSetBranchModelImpl.ENTITY_CACHE_ENABLED,
541 LayoutSetBranchImpl.class, layoutSetBranchId);
542
543 if (layoutSetBranch == _nullLayoutSetBranch) {
544 return null;
545 }
546
547 if (layoutSetBranch == null) {
548 Session session = null;
549
550 boolean hasException = false;
551
552 try {
553 session = openSession();
554
555 layoutSetBranch = (LayoutSetBranch)session.get(LayoutSetBranchImpl.class,
556 Long.valueOf(layoutSetBranchId));
557 }
558 catch (Exception e) {
559 hasException = true;
560
561 throw processException(e);
562 }
563 finally {
564 if (layoutSetBranch != null) {
565 cacheResult(layoutSetBranch);
566 }
567 else if (!hasException) {
568 EntityCacheUtil.putResult(LayoutSetBranchModelImpl.ENTITY_CACHE_ENABLED,
569 LayoutSetBranchImpl.class, layoutSetBranchId,
570 _nullLayoutSetBranch);
571 }
572
573 closeSession(session);
574 }
575 }
576
577 return layoutSetBranch;
578 }
579
580
587 public List<LayoutSetBranch> findByGroupId(long groupId)
588 throws SystemException {
589 return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
590 }
591
592
605 public List<LayoutSetBranch> findByGroupId(long groupId, int start, int end)
606 throws SystemException {
607 return findByGroupId(groupId, start, end, null);
608 }
609
610
624 public List<LayoutSetBranch> findByGroupId(long groupId, int start,
625 int end, OrderByComparator orderByComparator) throws SystemException {
626 FinderPath finderPath = null;
627 Object[] finderArgs = null;
628
629 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
630 (orderByComparator == null)) {
631 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
632 finderArgs = new Object[] { groupId };
633 }
634 else {
635 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
636 finderArgs = new Object[] { groupId, start, end, orderByComparator };
637 }
638
639 List<LayoutSetBranch> list = (List<LayoutSetBranch>)FinderCacheUtil.getResult(finderPath,
640 finderArgs, this);
641
642 if (list == null) {
643 StringBundler query = null;
644
645 if (orderByComparator != null) {
646 query = new StringBundler(3 +
647 (orderByComparator.getOrderByFields().length * 3));
648 }
649 else {
650 query = new StringBundler(3);
651 }
652
653 query.append(_SQL_SELECT_LAYOUTSETBRANCH_WHERE);
654
655 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
656
657 if (orderByComparator != null) {
658 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
659 orderByComparator);
660 }
661
662 else {
663 query.append(LayoutSetBranchModelImpl.ORDER_BY_JPQL);
664 }
665
666 String sql = query.toString();
667
668 Session session = null;
669
670 try {
671 session = openSession();
672
673 Query q = session.createQuery(sql);
674
675 QueryPos qPos = QueryPos.getInstance(q);
676
677 qPos.add(groupId);
678
679 list = (List<LayoutSetBranch>)QueryUtil.list(q, getDialect(),
680 start, end);
681 }
682 catch (Exception e) {
683 throw processException(e);
684 }
685 finally {
686 if (list == null) {
687 FinderCacheUtil.removeResult(finderPath, finderArgs);
688 }
689 else {
690 cacheResult(list);
691
692 FinderCacheUtil.putResult(finderPath, finderArgs, list);
693 }
694
695 closeSession(session);
696 }
697 }
698
699 return list;
700 }
701
702
715 public LayoutSetBranch findByGroupId_First(long groupId,
716 OrderByComparator orderByComparator)
717 throws NoSuchLayoutSetBranchException, SystemException {
718 List<LayoutSetBranch> list = findByGroupId(groupId, 0, 1,
719 orderByComparator);
720
721 if (list.isEmpty()) {
722 StringBundler msg = new StringBundler(4);
723
724 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
725
726 msg.append("groupId=");
727 msg.append(groupId);
728
729 msg.append(StringPool.CLOSE_CURLY_BRACE);
730
731 throw new NoSuchLayoutSetBranchException(msg.toString());
732 }
733 else {
734 return list.get(0);
735 }
736 }
737
738
751 public LayoutSetBranch findByGroupId_Last(long groupId,
752 OrderByComparator orderByComparator)
753 throws NoSuchLayoutSetBranchException, SystemException {
754 int count = countByGroupId(groupId);
755
756 List<LayoutSetBranch> list = findByGroupId(groupId, count - 1, count,
757 orderByComparator);
758
759 if (list.isEmpty()) {
760 StringBundler msg = new StringBundler(4);
761
762 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
763
764 msg.append("groupId=");
765 msg.append(groupId);
766
767 msg.append(StringPool.CLOSE_CURLY_BRACE);
768
769 throw new NoSuchLayoutSetBranchException(msg.toString());
770 }
771 else {
772 return list.get(0);
773 }
774 }
775
776
790 public LayoutSetBranch[] findByGroupId_PrevAndNext(long layoutSetBranchId,
791 long groupId, OrderByComparator orderByComparator)
792 throws NoSuchLayoutSetBranchException, SystemException {
793 LayoutSetBranch layoutSetBranch = findByPrimaryKey(layoutSetBranchId);
794
795 Session session = null;
796
797 try {
798 session = openSession();
799
800 LayoutSetBranch[] array = new LayoutSetBranchImpl[3];
801
802 array[0] = getByGroupId_PrevAndNext(session, layoutSetBranch,
803 groupId, orderByComparator, true);
804
805 array[1] = layoutSetBranch;
806
807 array[2] = getByGroupId_PrevAndNext(session, layoutSetBranch,
808 groupId, orderByComparator, false);
809
810 return array;
811 }
812 catch (Exception e) {
813 throw processException(e);
814 }
815 finally {
816 closeSession(session);
817 }
818 }
819
820 protected LayoutSetBranch getByGroupId_PrevAndNext(Session session,
821 LayoutSetBranch layoutSetBranch, long groupId,
822 OrderByComparator orderByComparator, boolean previous) {
823 StringBundler query = null;
824
825 if (orderByComparator != null) {
826 query = new StringBundler(6 +
827 (orderByComparator.getOrderByFields().length * 6));
828 }
829 else {
830 query = new StringBundler(3);
831 }
832
833 query.append(_SQL_SELECT_LAYOUTSETBRANCH_WHERE);
834
835 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
836
837 if (orderByComparator != null) {
838 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
839
840 if (orderByConditionFields.length > 0) {
841 query.append(WHERE_AND);
842 }
843
844 for (int i = 0; i < orderByConditionFields.length; i++) {
845 query.append(_ORDER_BY_ENTITY_ALIAS);
846 query.append(orderByConditionFields[i]);
847
848 if ((i + 1) < orderByConditionFields.length) {
849 if (orderByComparator.isAscending() ^ previous) {
850 query.append(WHERE_GREATER_THAN_HAS_NEXT);
851 }
852 else {
853 query.append(WHERE_LESSER_THAN_HAS_NEXT);
854 }
855 }
856 else {
857 if (orderByComparator.isAscending() ^ previous) {
858 query.append(WHERE_GREATER_THAN);
859 }
860 else {
861 query.append(WHERE_LESSER_THAN);
862 }
863 }
864 }
865
866 query.append(ORDER_BY_CLAUSE);
867
868 String[] orderByFields = orderByComparator.getOrderByFields();
869
870 for (int i = 0; i < orderByFields.length; i++) {
871 query.append(_ORDER_BY_ENTITY_ALIAS);
872 query.append(orderByFields[i]);
873
874 if ((i + 1) < orderByFields.length) {
875 if (orderByComparator.isAscending() ^ previous) {
876 query.append(ORDER_BY_ASC_HAS_NEXT);
877 }
878 else {
879 query.append(ORDER_BY_DESC_HAS_NEXT);
880 }
881 }
882 else {
883 if (orderByComparator.isAscending() ^ previous) {
884 query.append(ORDER_BY_ASC);
885 }
886 else {
887 query.append(ORDER_BY_DESC);
888 }
889 }
890 }
891 }
892
893 else {
894 query.append(LayoutSetBranchModelImpl.ORDER_BY_JPQL);
895 }
896
897 String sql = query.toString();
898
899 Query q = session.createQuery(sql);
900
901 q.setFirstResult(0);
902 q.setMaxResults(2);
903
904 QueryPos qPos = QueryPos.getInstance(q);
905
906 qPos.add(groupId);
907
908 if (orderByComparator != null) {
909 Object[] values = orderByComparator.getOrderByConditionValues(layoutSetBranch);
910
911 for (Object value : values) {
912 qPos.add(value);
913 }
914 }
915
916 List<LayoutSetBranch> list = q.list();
917
918 if (list.size() == 2) {
919 return list.get(1);
920 }
921 else {
922 return null;
923 }
924 }
925
926
933 public List<LayoutSetBranch> filterFindByGroupId(long groupId)
934 throws SystemException {
935 return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
936 QueryUtil.ALL_POS, null);
937 }
938
939
952 public List<LayoutSetBranch> filterFindByGroupId(long groupId, int start,
953 int end) throws SystemException {
954 return filterFindByGroupId(groupId, start, end, null);
955 }
956
957
971 public List<LayoutSetBranch> filterFindByGroupId(long groupId, int start,
972 int end, OrderByComparator orderByComparator) throws SystemException {
973 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
974 return findByGroupId(groupId, start, end, orderByComparator);
975 }
976
977 StringBundler query = null;
978
979 if (orderByComparator != null) {
980 query = new StringBundler(3 +
981 (orderByComparator.getOrderByFields().length * 3));
982 }
983 else {
984 query = new StringBundler(3);
985 }
986
987 if (getDB().isSupportsInlineDistinct()) {
988 query.append(_FILTER_SQL_SELECT_LAYOUTSETBRANCH_WHERE);
989 }
990 else {
991 query.append(_FILTER_SQL_SELECT_LAYOUTSETBRANCH_NO_INLINE_DISTINCT_WHERE_1);
992 }
993
994 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
995
996 if (!getDB().isSupportsInlineDistinct()) {
997 query.append(_FILTER_SQL_SELECT_LAYOUTSETBRANCH_NO_INLINE_DISTINCT_WHERE_2);
998 }
999
1000 if (orderByComparator != null) {
1001 if (getDB().isSupportsInlineDistinct()) {
1002 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1003 orderByComparator);
1004 }
1005 else {
1006 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
1007 orderByComparator);
1008 }
1009 }
1010
1011 else {
1012 if (getDB().isSupportsInlineDistinct()) {
1013 query.append(LayoutSetBranchModelImpl.ORDER_BY_JPQL);
1014 }
1015 else {
1016 query.append(LayoutSetBranchModelImpl.ORDER_BY_SQL);
1017 }
1018 }
1019
1020 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1021 LayoutSetBranch.class.getName(),
1022 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
1023
1024 Session session = null;
1025
1026 try {
1027 session = openSession();
1028
1029 SQLQuery q = session.createSQLQuery(sql);
1030
1031 if (getDB().isSupportsInlineDistinct()) {
1032 q.addEntity(_FILTER_ENTITY_ALIAS, LayoutSetBranchImpl.class);
1033 }
1034 else {
1035 q.addEntity(_FILTER_ENTITY_TABLE, LayoutSetBranchImpl.class);
1036 }
1037
1038 QueryPos qPos = QueryPos.getInstance(q);
1039
1040 qPos.add(groupId);
1041
1042 return (List<LayoutSetBranch>)QueryUtil.list(q, getDialect(),
1043 start, end);
1044 }
1045 catch (Exception e) {
1046 throw processException(e);
1047 }
1048 finally {
1049 closeSession(session);
1050 }
1051 }
1052
1053
1063 public LayoutSetBranch[] filterFindByGroupId_PrevAndNext(
1064 long layoutSetBranchId, long groupId,
1065 OrderByComparator orderByComparator)
1066 throws NoSuchLayoutSetBranchException, SystemException {
1067 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1068 return findByGroupId_PrevAndNext(layoutSetBranchId, groupId,
1069 orderByComparator);
1070 }
1071
1072 LayoutSetBranch layoutSetBranch = findByPrimaryKey(layoutSetBranchId);
1073
1074 Session session = null;
1075
1076 try {
1077 session = openSession();
1078
1079 LayoutSetBranch[] array = new LayoutSetBranchImpl[3];
1080
1081 array[0] = filterGetByGroupId_PrevAndNext(session, layoutSetBranch,
1082 groupId, orderByComparator, true);
1083
1084 array[1] = layoutSetBranch;
1085
1086 array[2] = filterGetByGroupId_PrevAndNext(session, layoutSetBranch,
1087 groupId, orderByComparator, false);
1088
1089 return array;
1090 }
1091 catch (Exception e) {
1092 throw processException(e);
1093 }
1094 finally {
1095 closeSession(session);
1096 }
1097 }
1098
1099 protected LayoutSetBranch filterGetByGroupId_PrevAndNext(Session session,
1100 LayoutSetBranch layoutSetBranch, long groupId,
1101 OrderByComparator orderByComparator, boolean previous) {
1102 StringBundler query = null;
1103
1104 if (orderByComparator != null) {
1105 query = new StringBundler(6 +
1106 (orderByComparator.getOrderByFields().length * 6));
1107 }
1108 else {
1109 query = new StringBundler(3);
1110 }
1111
1112 if (getDB().isSupportsInlineDistinct()) {
1113 query.append(_FILTER_SQL_SELECT_LAYOUTSETBRANCH_WHERE);
1114 }
1115 else {
1116 query.append(_FILTER_SQL_SELECT_LAYOUTSETBRANCH_NO_INLINE_DISTINCT_WHERE_1);
1117 }
1118
1119 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1120
1121 if (!getDB().isSupportsInlineDistinct()) {
1122 query.append(_FILTER_SQL_SELECT_LAYOUTSETBRANCH_NO_INLINE_DISTINCT_WHERE_2);
1123 }
1124
1125 if (orderByComparator != null) {
1126 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1127
1128 if (orderByConditionFields.length > 0) {
1129 query.append(WHERE_AND);
1130 }
1131
1132 for (int i = 0; i < orderByConditionFields.length; i++) {
1133 if (getDB().isSupportsInlineDistinct()) {
1134 query.append(_ORDER_BY_ENTITY_ALIAS);
1135 }
1136 else {
1137 query.append(_ORDER_BY_ENTITY_TABLE);
1138 }
1139
1140 query.append(orderByConditionFields[i]);
1141
1142 if ((i + 1) < orderByConditionFields.length) {
1143 if (orderByComparator.isAscending() ^ previous) {
1144 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1145 }
1146 else {
1147 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1148 }
1149 }
1150 else {
1151 if (orderByComparator.isAscending() ^ previous) {
1152 query.append(WHERE_GREATER_THAN);
1153 }
1154 else {
1155 query.append(WHERE_LESSER_THAN);
1156 }
1157 }
1158 }
1159
1160 query.append(ORDER_BY_CLAUSE);
1161
1162 String[] orderByFields = orderByComparator.getOrderByFields();
1163
1164 for (int i = 0; i < orderByFields.length; i++) {
1165 if (getDB().isSupportsInlineDistinct()) {
1166 query.append(_ORDER_BY_ENTITY_ALIAS);
1167 }
1168 else {
1169 query.append(_ORDER_BY_ENTITY_TABLE);
1170 }
1171
1172 query.append(orderByFields[i]);
1173
1174 if ((i + 1) < orderByFields.length) {
1175 if (orderByComparator.isAscending() ^ previous) {
1176 query.append(ORDER_BY_ASC_HAS_NEXT);
1177 }
1178 else {
1179 query.append(ORDER_BY_DESC_HAS_NEXT);
1180 }
1181 }
1182 else {
1183 if (orderByComparator.isAscending() ^ previous) {
1184 query.append(ORDER_BY_ASC);
1185 }
1186 else {
1187 query.append(ORDER_BY_DESC);
1188 }
1189 }
1190 }
1191 }
1192
1193 else {
1194 if (getDB().isSupportsInlineDistinct()) {
1195 query.append(LayoutSetBranchModelImpl.ORDER_BY_JPQL);
1196 }
1197 else {
1198 query.append(LayoutSetBranchModelImpl.ORDER_BY_SQL);
1199 }
1200 }
1201
1202 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1203 LayoutSetBranch.class.getName(),
1204 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
1205
1206 SQLQuery q = session.createSQLQuery(sql);
1207
1208 q.setFirstResult(0);
1209 q.setMaxResults(2);
1210
1211 if (getDB().isSupportsInlineDistinct()) {
1212 q.addEntity(_FILTER_ENTITY_ALIAS, LayoutSetBranchImpl.class);
1213 }
1214 else {
1215 q.addEntity(_FILTER_ENTITY_TABLE, LayoutSetBranchImpl.class);
1216 }
1217
1218 QueryPos qPos = QueryPos.getInstance(q);
1219
1220 qPos.add(groupId);
1221
1222 if (orderByComparator != null) {
1223 Object[] values = orderByComparator.getOrderByConditionValues(layoutSetBranch);
1224
1225 for (Object value : values) {
1226 qPos.add(value);
1227 }
1228 }
1229
1230 List<LayoutSetBranch> list = q.list();
1231
1232 if (list.size() == 2) {
1233 return list.get(1);
1234 }
1235 else {
1236 return null;
1237 }
1238 }
1239
1240
1248 public List<LayoutSetBranch> findByG_P(long groupId, boolean privateLayout)
1249 throws SystemException {
1250 return findByG_P(groupId, privateLayout, QueryUtil.ALL_POS,
1251 QueryUtil.ALL_POS, null);
1252 }
1253
1254
1268 public List<LayoutSetBranch> findByG_P(long groupId, boolean privateLayout,
1269 int start, int end) throws SystemException {
1270 return findByG_P(groupId, privateLayout, start, end, null);
1271 }
1272
1273
1288 public List<LayoutSetBranch> findByG_P(long groupId, boolean privateLayout,
1289 int start, int end, OrderByComparator orderByComparator)
1290 throws SystemException {
1291 FinderPath finderPath = null;
1292 Object[] finderArgs = null;
1293
1294 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1295 (orderByComparator == null)) {
1296 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P;
1297 finderArgs = new Object[] { groupId, privateLayout };
1298 }
1299 else {
1300 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P;
1301 finderArgs = new Object[] {
1302 groupId, privateLayout,
1303
1304 start, end, orderByComparator
1305 };
1306 }
1307
1308 List<LayoutSetBranch> list = (List<LayoutSetBranch>)FinderCacheUtil.getResult(finderPath,
1309 finderArgs, this);
1310
1311 if (list == null) {
1312 StringBundler query = null;
1313
1314 if (orderByComparator != null) {
1315 query = new StringBundler(4 +
1316 (orderByComparator.getOrderByFields().length * 3));
1317 }
1318 else {
1319 query = new StringBundler(4);
1320 }
1321
1322 query.append(_SQL_SELECT_LAYOUTSETBRANCH_WHERE);
1323
1324 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
1325
1326 query.append(_FINDER_COLUMN_G_P_PRIVATELAYOUT_2);
1327
1328 if (orderByComparator != null) {
1329 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1330 orderByComparator);
1331 }
1332
1333 else {
1334 query.append(LayoutSetBranchModelImpl.ORDER_BY_JPQL);
1335 }
1336
1337 String sql = query.toString();
1338
1339 Session session = null;
1340
1341 try {
1342 session = openSession();
1343
1344 Query q = session.createQuery(sql);
1345
1346 QueryPos qPos = QueryPos.getInstance(q);
1347
1348 qPos.add(groupId);
1349
1350 qPos.add(privateLayout);
1351
1352 list = (List<LayoutSetBranch>)QueryUtil.list(q, getDialect(),
1353 start, end);
1354 }
1355 catch (Exception e) {
1356 throw processException(e);
1357 }
1358 finally {
1359 if (list == null) {
1360 FinderCacheUtil.removeResult(finderPath, finderArgs);
1361 }
1362 else {
1363 cacheResult(list);
1364
1365 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1366 }
1367
1368 closeSession(session);
1369 }
1370 }
1371
1372 return list;
1373 }
1374
1375
1389 public LayoutSetBranch findByG_P_First(long groupId, boolean privateLayout,
1390 OrderByComparator orderByComparator)
1391 throws NoSuchLayoutSetBranchException, SystemException {
1392 List<LayoutSetBranch> list = findByG_P(groupId, privateLayout, 0, 1,
1393 orderByComparator);
1394
1395 if (list.isEmpty()) {
1396 StringBundler msg = new StringBundler(6);
1397
1398 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1399
1400 msg.append("groupId=");
1401 msg.append(groupId);
1402
1403 msg.append(", privateLayout=");
1404 msg.append(privateLayout);
1405
1406 msg.append(StringPool.CLOSE_CURLY_BRACE);
1407
1408 throw new NoSuchLayoutSetBranchException(msg.toString());
1409 }
1410 else {
1411 return list.get(0);
1412 }
1413 }
1414
1415
1429 public LayoutSetBranch findByG_P_Last(long groupId, boolean privateLayout,
1430 OrderByComparator orderByComparator)
1431 throws NoSuchLayoutSetBranchException, SystemException {
1432 int count = countByG_P(groupId, privateLayout);
1433
1434 List<LayoutSetBranch> list = findByG_P(groupId, privateLayout,
1435 count - 1, count, orderByComparator);
1436
1437 if (list.isEmpty()) {
1438 StringBundler msg = new StringBundler(6);
1439
1440 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1441
1442 msg.append("groupId=");
1443 msg.append(groupId);
1444
1445 msg.append(", privateLayout=");
1446 msg.append(privateLayout);
1447
1448 msg.append(StringPool.CLOSE_CURLY_BRACE);
1449
1450 throw new NoSuchLayoutSetBranchException(msg.toString());
1451 }
1452 else {
1453 return list.get(0);
1454 }
1455 }
1456
1457
1472 public LayoutSetBranch[] findByG_P_PrevAndNext(long layoutSetBranchId,
1473 long groupId, boolean privateLayout, OrderByComparator orderByComparator)
1474 throws NoSuchLayoutSetBranchException, SystemException {
1475 LayoutSetBranch layoutSetBranch = findByPrimaryKey(layoutSetBranchId);
1476
1477 Session session = null;
1478
1479 try {
1480 session = openSession();
1481
1482 LayoutSetBranch[] array = new LayoutSetBranchImpl[3];
1483
1484 array[0] = getByG_P_PrevAndNext(session, layoutSetBranch, groupId,
1485 privateLayout, orderByComparator, true);
1486
1487 array[1] = layoutSetBranch;
1488
1489 array[2] = getByG_P_PrevAndNext(session, layoutSetBranch, groupId,
1490 privateLayout, orderByComparator, false);
1491
1492 return array;
1493 }
1494 catch (Exception e) {
1495 throw processException(e);
1496 }
1497 finally {
1498 closeSession(session);
1499 }
1500 }
1501
1502 protected LayoutSetBranch getByG_P_PrevAndNext(Session session,
1503 LayoutSetBranch layoutSetBranch, long groupId, boolean privateLayout,
1504 OrderByComparator orderByComparator, boolean previous) {
1505 StringBundler query = null;
1506
1507 if (orderByComparator != null) {
1508 query = new StringBundler(6 +
1509 (orderByComparator.getOrderByFields().length * 6));
1510 }
1511 else {
1512 query = new StringBundler(3);
1513 }
1514
1515 query.append(_SQL_SELECT_LAYOUTSETBRANCH_WHERE);
1516
1517 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
1518
1519 query.append(_FINDER_COLUMN_G_P_PRIVATELAYOUT_2);
1520
1521 if (orderByComparator != null) {
1522 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1523
1524 if (orderByConditionFields.length > 0) {
1525 query.append(WHERE_AND);
1526 }
1527
1528 for (int i = 0; i < orderByConditionFields.length; i++) {
1529 query.append(_ORDER_BY_ENTITY_ALIAS);
1530 query.append(orderByConditionFields[i]);
1531
1532 if ((i + 1) < orderByConditionFields.length) {
1533 if (orderByComparator.isAscending() ^ previous) {
1534 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1535 }
1536 else {
1537 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1538 }
1539 }
1540 else {
1541 if (orderByComparator.isAscending() ^ previous) {
1542 query.append(WHERE_GREATER_THAN);
1543 }
1544 else {
1545 query.append(WHERE_LESSER_THAN);
1546 }
1547 }
1548 }
1549
1550 query.append(ORDER_BY_CLAUSE);
1551
1552 String[] orderByFields = orderByComparator.getOrderByFields();
1553
1554 for (int i = 0; i < orderByFields.length; i++) {
1555 query.append(_ORDER_BY_ENTITY_ALIAS);
1556 query.append(orderByFields[i]);
1557
1558 if ((i + 1) < orderByFields.length) {
1559 if (orderByComparator.isAscending() ^ previous) {
1560 query.append(ORDER_BY_ASC_HAS_NEXT);
1561 }
1562 else {
1563 query.append(ORDER_BY_DESC_HAS_NEXT);
1564 }
1565 }
1566 else {
1567 if (orderByComparator.isAscending() ^ previous) {
1568 query.append(ORDER_BY_ASC);
1569 }
1570 else {
1571 query.append(ORDER_BY_DESC);
1572 }
1573 }
1574 }
1575 }
1576
1577 else {
1578 query.append(LayoutSetBranchModelImpl.ORDER_BY_JPQL);
1579 }
1580
1581 String sql = query.toString();
1582
1583 Query q = session.createQuery(sql);
1584
1585 q.setFirstResult(0);
1586 q.setMaxResults(2);
1587
1588 QueryPos qPos = QueryPos.getInstance(q);
1589
1590 qPos.add(groupId);
1591
1592 qPos.add(privateLayout);
1593
1594 if (orderByComparator != null) {
1595 Object[] values = orderByComparator.getOrderByConditionValues(layoutSetBranch);
1596
1597 for (Object value : values) {
1598 qPos.add(value);
1599 }
1600 }
1601
1602 List<LayoutSetBranch> list = q.list();
1603
1604 if (list.size() == 2) {
1605 return list.get(1);
1606 }
1607 else {
1608 return null;
1609 }
1610 }
1611
1612
1620 public List<LayoutSetBranch> filterFindByG_P(long groupId,
1621 boolean privateLayout) throws SystemException {
1622 return filterFindByG_P(groupId, privateLayout, QueryUtil.ALL_POS,
1623 QueryUtil.ALL_POS, null);
1624 }
1625
1626
1640 public List<LayoutSetBranch> filterFindByG_P(long groupId,
1641 boolean privateLayout, int start, int end) throws SystemException {
1642 return filterFindByG_P(groupId, privateLayout, start, end, null);
1643 }
1644
1645
1660 public List<LayoutSetBranch> filterFindByG_P(long groupId,
1661 boolean privateLayout, int start, int end,
1662 OrderByComparator orderByComparator) throws SystemException {
1663 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1664 return findByG_P(groupId, privateLayout, start, end,
1665 orderByComparator);
1666 }
1667
1668 StringBundler query = null;
1669
1670 if (orderByComparator != null) {
1671 query = new StringBundler(4 +
1672 (orderByComparator.getOrderByFields().length * 3));
1673 }
1674 else {
1675 query = new StringBundler(4);
1676 }
1677
1678 if (getDB().isSupportsInlineDistinct()) {
1679 query.append(_FILTER_SQL_SELECT_LAYOUTSETBRANCH_WHERE);
1680 }
1681 else {
1682 query.append(_FILTER_SQL_SELECT_LAYOUTSETBRANCH_NO_INLINE_DISTINCT_WHERE_1);
1683 }
1684
1685 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
1686
1687 query.append(_FINDER_COLUMN_G_P_PRIVATELAYOUT_2);
1688
1689 if (!getDB().isSupportsInlineDistinct()) {
1690 query.append(_FILTER_SQL_SELECT_LAYOUTSETBRANCH_NO_INLINE_DISTINCT_WHERE_2);
1691 }
1692
1693 if (orderByComparator != null) {
1694 if (getDB().isSupportsInlineDistinct()) {
1695 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1696 orderByComparator);
1697 }
1698 else {
1699 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
1700 orderByComparator);
1701 }
1702 }
1703
1704 else {
1705 if (getDB().isSupportsInlineDistinct()) {
1706 query.append(LayoutSetBranchModelImpl.ORDER_BY_JPQL);
1707 }
1708 else {
1709 query.append(LayoutSetBranchModelImpl.ORDER_BY_SQL);
1710 }
1711 }
1712
1713 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1714 LayoutSetBranch.class.getName(),
1715 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
1716
1717 Session session = null;
1718
1719 try {
1720 session = openSession();
1721
1722 SQLQuery q = session.createSQLQuery(sql);
1723
1724 if (getDB().isSupportsInlineDistinct()) {
1725 q.addEntity(_FILTER_ENTITY_ALIAS, LayoutSetBranchImpl.class);
1726 }
1727 else {
1728 q.addEntity(_FILTER_ENTITY_TABLE, LayoutSetBranchImpl.class);
1729 }
1730
1731 QueryPos qPos = QueryPos.getInstance(q);
1732
1733 qPos.add(groupId);
1734
1735 qPos.add(privateLayout);
1736
1737 return (List<LayoutSetBranch>)QueryUtil.list(q, getDialect(),
1738 start, end);
1739 }
1740 catch (Exception e) {
1741 throw processException(e);
1742 }
1743 finally {
1744 closeSession(session);
1745 }
1746 }
1747
1748
1759 public LayoutSetBranch[] filterFindByG_P_PrevAndNext(
1760 long layoutSetBranchId, long groupId, boolean privateLayout,
1761 OrderByComparator orderByComparator)
1762 throws NoSuchLayoutSetBranchException, SystemException {
1763 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1764 return findByG_P_PrevAndNext(layoutSetBranchId, groupId,
1765 privateLayout, orderByComparator);
1766 }
1767
1768 LayoutSetBranch layoutSetBranch = findByPrimaryKey(layoutSetBranchId);
1769
1770 Session session = null;
1771
1772 try {
1773 session = openSession();
1774
1775 LayoutSetBranch[] array = new LayoutSetBranchImpl[3];
1776
1777 array[0] = filterGetByG_P_PrevAndNext(session, layoutSetBranch,
1778 groupId, privateLayout, orderByComparator, true);
1779
1780 array[1] = layoutSetBranch;
1781
1782 array[2] = filterGetByG_P_PrevAndNext(session, layoutSetBranch,
1783 groupId, privateLayout, orderByComparator, false);
1784
1785 return array;
1786 }
1787 catch (Exception e) {
1788 throw processException(e);
1789 }
1790 finally {
1791 closeSession(session);
1792 }
1793 }
1794
1795 protected LayoutSetBranch filterGetByG_P_PrevAndNext(Session session,
1796 LayoutSetBranch layoutSetBranch, long groupId, boolean privateLayout,
1797 OrderByComparator orderByComparator, boolean previous) {
1798 StringBundler query = null;
1799
1800 if (orderByComparator != null) {
1801 query = new StringBundler(6 +
1802 (orderByComparator.getOrderByFields().length * 6));
1803 }
1804 else {
1805 query = new StringBundler(3);
1806 }
1807
1808 if (getDB().isSupportsInlineDistinct()) {
1809 query.append(_FILTER_SQL_SELECT_LAYOUTSETBRANCH_WHERE);
1810 }
1811 else {
1812 query.append(_FILTER_SQL_SELECT_LAYOUTSETBRANCH_NO_INLINE_DISTINCT_WHERE_1);
1813 }
1814
1815 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
1816
1817 query.append(_FINDER_COLUMN_G_P_PRIVATELAYOUT_2);
1818
1819 if (!getDB().isSupportsInlineDistinct()) {
1820 query.append(_FILTER_SQL_SELECT_LAYOUTSETBRANCH_NO_INLINE_DISTINCT_WHERE_2);
1821 }
1822
1823 if (orderByComparator != null) {
1824 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1825
1826 if (orderByConditionFields.length > 0) {
1827 query.append(WHERE_AND);
1828 }
1829
1830 for (int i = 0; i < orderByConditionFields.length; i++) {
1831 if (getDB().isSupportsInlineDistinct()) {
1832 query.append(_ORDER_BY_ENTITY_ALIAS);
1833 }
1834 else {
1835 query.append(_ORDER_BY_ENTITY_TABLE);
1836 }
1837
1838 query.append(orderByConditionFields[i]);
1839
1840 if ((i + 1) < orderByConditionFields.length) {
1841 if (orderByComparator.isAscending() ^ previous) {
1842 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1843 }
1844 else {
1845 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1846 }
1847 }
1848 else {
1849 if (orderByComparator.isAscending() ^ previous) {
1850 query.append(WHERE_GREATER_THAN);
1851 }
1852 else {
1853 query.append(WHERE_LESSER_THAN);
1854 }
1855 }
1856 }
1857
1858 query.append(ORDER_BY_CLAUSE);
1859
1860 String[] orderByFields = orderByComparator.getOrderByFields();
1861
1862 for (int i = 0; i < orderByFields.length; i++) {
1863 if (getDB().isSupportsInlineDistinct()) {
1864 query.append(_ORDER_BY_ENTITY_ALIAS);
1865 }
1866 else {
1867 query.append(_ORDER_BY_ENTITY_TABLE);
1868 }
1869
1870 query.append(orderByFields[i]);
1871
1872 if ((i + 1) < orderByFields.length) {
1873 if (orderByComparator.isAscending() ^ previous) {
1874 query.append(ORDER_BY_ASC_HAS_NEXT);
1875 }
1876 else {
1877 query.append(ORDER_BY_DESC_HAS_NEXT);
1878 }
1879 }
1880 else {
1881 if (orderByComparator.isAscending() ^ previous) {
1882 query.append(ORDER_BY_ASC);
1883 }
1884 else {
1885 query.append(ORDER_BY_DESC);
1886 }
1887 }
1888 }
1889 }
1890
1891 else {
1892 if (getDB().isSupportsInlineDistinct()) {
1893 query.append(LayoutSetBranchModelImpl.ORDER_BY_JPQL);
1894 }
1895 else {
1896 query.append(LayoutSetBranchModelImpl.ORDER_BY_SQL);
1897 }
1898 }
1899
1900 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1901 LayoutSetBranch.class.getName(),
1902 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
1903
1904 SQLQuery q = session.createSQLQuery(sql);
1905
1906 q.setFirstResult(0);
1907 q.setMaxResults(2);
1908
1909 if (getDB().isSupportsInlineDistinct()) {
1910 q.addEntity(_FILTER_ENTITY_ALIAS, LayoutSetBranchImpl.class);
1911 }
1912 else {
1913 q.addEntity(_FILTER_ENTITY_TABLE, LayoutSetBranchImpl.class);
1914 }
1915
1916 QueryPos qPos = QueryPos.getInstance(q);
1917
1918 qPos.add(groupId);
1919
1920 qPos.add(privateLayout);
1921
1922 if (orderByComparator != null) {
1923 Object[] values = orderByComparator.getOrderByConditionValues(layoutSetBranch);
1924
1925 for (Object value : values) {
1926 qPos.add(value);
1927 }
1928 }
1929
1930 List<LayoutSetBranch> list = q.list();
1931
1932 if (list.size() == 2) {
1933 return list.get(1);
1934 }
1935 else {
1936 return null;
1937 }
1938 }
1939
1940
1950 public LayoutSetBranch findByG_P_N(long groupId, boolean privateLayout,
1951 String name) throws NoSuchLayoutSetBranchException, SystemException {
1952 LayoutSetBranch layoutSetBranch = fetchByG_P_N(groupId, privateLayout,
1953 name);
1954
1955 if (layoutSetBranch == null) {
1956 StringBundler msg = new StringBundler(8);
1957
1958 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1959
1960 msg.append("groupId=");
1961 msg.append(groupId);
1962
1963 msg.append(", privateLayout=");
1964 msg.append(privateLayout);
1965
1966 msg.append(", name=");
1967 msg.append(name);
1968
1969 msg.append(StringPool.CLOSE_CURLY_BRACE);
1970
1971 if (_log.isWarnEnabled()) {
1972 _log.warn(msg.toString());
1973 }
1974
1975 throw new NoSuchLayoutSetBranchException(msg.toString());
1976 }
1977
1978 return layoutSetBranch;
1979 }
1980
1981
1990 public LayoutSetBranch fetchByG_P_N(long groupId, boolean privateLayout,
1991 String name) throws SystemException {
1992 return fetchByG_P_N(groupId, privateLayout, name, true);
1993 }
1994
1995
2005 public LayoutSetBranch fetchByG_P_N(long groupId, boolean privateLayout,
2006 String name, boolean retrieveFromCache) throws SystemException {
2007 Object[] finderArgs = new Object[] { groupId, privateLayout, name };
2008
2009 Object result = null;
2010
2011 if (retrieveFromCache) {
2012 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_P_N,
2013 finderArgs, this);
2014 }
2015
2016 if (result == null) {
2017 StringBundler query = new StringBundler(5);
2018
2019 query.append(_SQL_SELECT_LAYOUTSETBRANCH_WHERE);
2020
2021 query.append(_FINDER_COLUMN_G_P_N_GROUPID_2);
2022
2023 query.append(_FINDER_COLUMN_G_P_N_PRIVATELAYOUT_2);
2024
2025 if (name == null) {
2026 query.append(_FINDER_COLUMN_G_P_N_NAME_1);
2027 }
2028 else {
2029 if (name.equals(StringPool.BLANK)) {
2030 query.append(_FINDER_COLUMN_G_P_N_NAME_3);
2031 }
2032 else {
2033 query.append(_FINDER_COLUMN_G_P_N_NAME_2);
2034 }
2035 }
2036
2037 query.append(LayoutSetBranchModelImpl.ORDER_BY_JPQL);
2038
2039 String sql = query.toString();
2040
2041 Session session = null;
2042
2043 try {
2044 session = openSession();
2045
2046 Query q = session.createQuery(sql);
2047
2048 QueryPos qPos = QueryPos.getInstance(q);
2049
2050 qPos.add(groupId);
2051
2052 qPos.add(privateLayout);
2053
2054 if (name != null) {
2055 qPos.add(name);
2056 }
2057
2058 List<LayoutSetBranch> list = q.list();
2059
2060 result = list;
2061
2062 LayoutSetBranch layoutSetBranch = null;
2063
2064 if (list.isEmpty()) {
2065 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P_N,
2066 finderArgs, list);
2067 }
2068 else {
2069 layoutSetBranch = list.get(0);
2070
2071 cacheResult(layoutSetBranch);
2072
2073 if ((layoutSetBranch.getGroupId() != groupId) ||
2074 (layoutSetBranch.getPrivateLayout() != privateLayout) ||
2075 (layoutSetBranch.getName() == null) ||
2076 !layoutSetBranch.getName().equals(name)) {
2077 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P_N,
2078 finderArgs, layoutSetBranch);
2079 }
2080 }
2081
2082 return layoutSetBranch;
2083 }
2084 catch (Exception e) {
2085 throw processException(e);
2086 }
2087 finally {
2088 if (result == null) {
2089 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_P_N,
2090 finderArgs);
2091 }
2092
2093 closeSession(session);
2094 }
2095 }
2096 else {
2097 if (result instanceof List<?>) {
2098 return null;
2099 }
2100 else {
2101 return (LayoutSetBranch)result;
2102 }
2103 }
2104 }
2105
2106
2112 public List<LayoutSetBranch> findAll() throws SystemException {
2113 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2114 }
2115
2116
2128 public List<LayoutSetBranch> findAll(int start, int end)
2129 throws SystemException {
2130 return findAll(start, end, null);
2131 }
2132
2133
2146 public List<LayoutSetBranch> findAll(int start, int end,
2147 OrderByComparator orderByComparator) throws SystemException {
2148 FinderPath finderPath = null;
2149 Object[] finderArgs = new Object[] { start, end, orderByComparator };
2150
2151 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2152 (orderByComparator == null)) {
2153 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
2154 finderArgs = FINDER_ARGS_EMPTY;
2155 }
2156 else {
2157 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
2158 finderArgs = new Object[] { start, end, orderByComparator };
2159 }
2160
2161 List<LayoutSetBranch> list = (List<LayoutSetBranch>)FinderCacheUtil.getResult(finderPath,
2162 finderArgs, this);
2163
2164 if (list == null) {
2165 StringBundler query = null;
2166 String sql = null;
2167
2168 if (orderByComparator != null) {
2169 query = new StringBundler(2 +
2170 (orderByComparator.getOrderByFields().length * 3));
2171
2172 query.append(_SQL_SELECT_LAYOUTSETBRANCH);
2173
2174 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2175 orderByComparator);
2176
2177 sql = query.toString();
2178 }
2179 else {
2180 sql = _SQL_SELECT_LAYOUTSETBRANCH.concat(LayoutSetBranchModelImpl.ORDER_BY_JPQL);
2181 }
2182
2183 Session session = null;
2184
2185 try {
2186 session = openSession();
2187
2188 Query q = session.createQuery(sql);
2189
2190 if (orderByComparator == null) {
2191 list = (List<LayoutSetBranch>)QueryUtil.list(q,
2192 getDialect(), start, end, false);
2193
2194 Collections.sort(list);
2195 }
2196 else {
2197 list = (List<LayoutSetBranch>)QueryUtil.list(q,
2198 getDialect(), start, end);
2199 }
2200 }
2201 catch (Exception e) {
2202 throw processException(e);
2203 }
2204 finally {
2205 if (list == null) {
2206 FinderCacheUtil.removeResult(finderPath, finderArgs);
2207 }
2208 else {
2209 cacheResult(list);
2210
2211 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2212 }
2213
2214 closeSession(session);
2215 }
2216 }
2217
2218 return list;
2219 }
2220
2221
2227 public void removeByGroupId(long groupId) throws SystemException {
2228 for (LayoutSetBranch layoutSetBranch : findByGroupId(groupId)) {
2229 remove(layoutSetBranch);
2230 }
2231 }
2232
2233
2240 public void removeByG_P(long groupId, boolean privateLayout)
2241 throws SystemException {
2242 for (LayoutSetBranch layoutSetBranch : findByG_P(groupId, privateLayout)) {
2243 remove(layoutSetBranch);
2244 }
2245 }
2246
2247
2255 public void removeByG_P_N(long groupId, boolean privateLayout, String name)
2256 throws NoSuchLayoutSetBranchException, SystemException {
2257 LayoutSetBranch layoutSetBranch = findByG_P_N(groupId, privateLayout,
2258 name);
2259
2260 remove(layoutSetBranch);
2261 }
2262
2263
2268 public void removeAll() throws SystemException {
2269 for (LayoutSetBranch layoutSetBranch : findAll()) {
2270 remove(layoutSetBranch);
2271 }
2272 }
2273
2274
2281 public int countByGroupId(long groupId) throws SystemException {
2282 Object[] finderArgs = new Object[] { groupId };
2283
2284 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
2285 finderArgs, this);
2286
2287 if (count == null) {
2288 StringBundler query = new StringBundler(2);
2289
2290 query.append(_SQL_COUNT_LAYOUTSETBRANCH_WHERE);
2291
2292 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2293
2294 String sql = query.toString();
2295
2296 Session session = null;
2297
2298 try {
2299 session = openSession();
2300
2301 Query q = session.createQuery(sql);
2302
2303 QueryPos qPos = QueryPos.getInstance(q);
2304
2305 qPos.add(groupId);
2306
2307 count = (Long)q.uniqueResult();
2308 }
2309 catch (Exception e) {
2310 throw processException(e);
2311 }
2312 finally {
2313 if (count == null) {
2314 count = Long.valueOf(0);
2315 }
2316
2317 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
2318 finderArgs, count);
2319
2320 closeSession(session);
2321 }
2322 }
2323
2324 return count.intValue();
2325 }
2326
2327
2334 public int filterCountByGroupId(long groupId) throws SystemException {
2335 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2336 return countByGroupId(groupId);
2337 }
2338
2339 StringBundler query = new StringBundler(2);
2340
2341 query.append(_FILTER_SQL_COUNT_LAYOUTSETBRANCH_WHERE);
2342
2343 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2344
2345 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2346 LayoutSetBranch.class.getName(),
2347 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2348
2349 Session session = null;
2350
2351 try {
2352 session = openSession();
2353
2354 SQLQuery q = session.createSQLQuery(sql);
2355
2356 q.addScalar(COUNT_COLUMN_NAME,
2357 com.liferay.portal.kernel.dao.orm.Type.LONG);
2358
2359 QueryPos qPos = QueryPos.getInstance(q);
2360
2361 qPos.add(groupId);
2362
2363 Long count = (Long)q.uniqueResult();
2364
2365 return count.intValue();
2366 }
2367 catch (Exception e) {
2368 throw processException(e);
2369 }
2370 finally {
2371 closeSession(session);
2372 }
2373 }
2374
2375
2383 public int countByG_P(long groupId, boolean privateLayout)
2384 throws SystemException {
2385 Object[] finderArgs = new Object[] { groupId, privateLayout };
2386
2387 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_P,
2388 finderArgs, this);
2389
2390 if (count == null) {
2391 StringBundler query = new StringBundler(3);
2392
2393 query.append(_SQL_COUNT_LAYOUTSETBRANCH_WHERE);
2394
2395 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
2396
2397 query.append(_FINDER_COLUMN_G_P_PRIVATELAYOUT_2);
2398
2399 String sql = query.toString();
2400
2401 Session session = null;
2402
2403 try {
2404 session = openSession();
2405
2406 Query q = session.createQuery(sql);
2407
2408 QueryPos qPos = QueryPos.getInstance(q);
2409
2410 qPos.add(groupId);
2411
2412 qPos.add(privateLayout);
2413
2414 count = (Long)q.uniqueResult();
2415 }
2416 catch (Exception e) {
2417 throw processException(e);
2418 }
2419 finally {
2420 if (count == null) {
2421 count = Long.valueOf(0);
2422 }
2423
2424 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_P, finderArgs,
2425 count);
2426
2427 closeSession(session);
2428 }
2429 }
2430
2431 return count.intValue();
2432 }
2433
2434
2442 public int filterCountByG_P(long groupId, boolean privateLayout)
2443 throws SystemException {
2444 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2445 return countByG_P(groupId, privateLayout);
2446 }
2447
2448 StringBundler query = new StringBundler(3);
2449
2450 query.append(_FILTER_SQL_COUNT_LAYOUTSETBRANCH_WHERE);
2451
2452 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
2453
2454 query.append(_FINDER_COLUMN_G_P_PRIVATELAYOUT_2);
2455
2456 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2457 LayoutSetBranch.class.getName(),
2458 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2459
2460 Session session = null;
2461
2462 try {
2463 session = openSession();
2464
2465 SQLQuery q = session.createSQLQuery(sql);
2466
2467 q.addScalar(COUNT_COLUMN_NAME,
2468 com.liferay.portal.kernel.dao.orm.Type.LONG);
2469
2470 QueryPos qPos = QueryPos.getInstance(q);
2471
2472 qPos.add(groupId);
2473
2474 qPos.add(privateLayout);
2475
2476 Long count = (Long)q.uniqueResult();
2477
2478 return count.intValue();
2479 }
2480 catch (Exception e) {
2481 throw processException(e);
2482 }
2483 finally {
2484 closeSession(session);
2485 }
2486 }
2487
2488
2497 public int countByG_P_N(long groupId, boolean privateLayout, String name)
2498 throws SystemException {
2499 Object[] finderArgs = new Object[] { groupId, privateLayout, name };
2500
2501 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_P_N,
2502 finderArgs, this);
2503
2504 if (count == null) {
2505 StringBundler query = new StringBundler(4);
2506
2507 query.append(_SQL_COUNT_LAYOUTSETBRANCH_WHERE);
2508
2509 query.append(_FINDER_COLUMN_G_P_N_GROUPID_2);
2510
2511 query.append(_FINDER_COLUMN_G_P_N_PRIVATELAYOUT_2);
2512
2513 if (name == null) {
2514 query.append(_FINDER_COLUMN_G_P_N_NAME_1);
2515 }
2516 else {
2517 if (name.equals(StringPool.BLANK)) {
2518 query.append(_FINDER_COLUMN_G_P_N_NAME_3);
2519 }
2520 else {
2521 query.append(_FINDER_COLUMN_G_P_N_NAME_2);
2522 }
2523 }
2524
2525 String sql = query.toString();
2526
2527 Session session = null;
2528
2529 try {
2530 session = openSession();
2531
2532 Query q = session.createQuery(sql);
2533
2534 QueryPos qPos = QueryPos.getInstance(q);
2535
2536 qPos.add(groupId);
2537
2538 qPos.add(privateLayout);
2539
2540 if (name != null) {
2541 qPos.add(name);
2542 }
2543
2544 count = (Long)q.uniqueResult();
2545 }
2546 catch (Exception e) {
2547 throw processException(e);
2548 }
2549 finally {
2550 if (count == null) {
2551 count = Long.valueOf(0);
2552 }
2553
2554 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_P_N,
2555 finderArgs, count);
2556
2557 closeSession(session);
2558 }
2559 }
2560
2561 return count.intValue();
2562 }
2563
2564
2570 public int countAll() throws SystemException {
2571 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
2572 FINDER_ARGS_EMPTY, this);
2573
2574 if (count == null) {
2575 Session session = null;
2576
2577 try {
2578 session = openSession();
2579
2580 Query q = session.createQuery(_SQL_COUNT_LAYOUTSETBRANCH);
2581
2582 count = (Long)q.uniqueResult();
2583 }
2584 catch (Exception e) {
2585 throw processException(e);
2586 }
2587 finally {
2588 if (count == null) {
2589 count = Long.valueOf(0);
2590 }
2591
2592 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
2593 FINDER_ARGS_EMPTY, count);
2594
2595 closeSession(session);
2596 }
2597 }
2598
2599 return count.intValue();
2600 }
2601
2602
2605 public void afterPropertiesSet() {
2606 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
2607 com.liferay.portal.util.PropsUtil.get(
2608 "value.object.listener.com.liferay.portal.model.LayoutSetBranch")));
2609
2610 if (listenerClassNames.length > 0) {
2611 try {
2612 List<ModelListener<LayoutSetBranch>> listenersList = new ArrayList<ModelListener<LayoutSetBranch>>();
2613
2614 for (String listenerClassName : listenerClassNames) {
2615 listenersList.add((ModelListener<LayoutSetBranch>)InstanceFactory.newInstance(
2616 listenerClassName));
2617 }
2618
2619 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
2620 }
2621 catch (Exception e) {
2622 _log.error(e);
2623 }
2624 }
2625 }
2626
2627 public void destroy() {
2628 EntityCacheUtil.removeCache(LayoutSetBranchImpl.class.getName());
2629 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
2630 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2631 }
2632
2633 @BeanReference(type = AccountPersistence.class)
2634 protected AccountPersistence accountPersistence;
2635 @BeanReference(type = AddressPersistence.class)
2636 protected AddressPersistence addressPersistence;
2637 @BeanReference(type = BrowserTrackerPersistence.class)
2638 protected BrowserTrackerPersistence browserTrackerPersistence;
2639 @BeanReference(type = ClassNamePersistence.class)
2640 protected ClassNamePersistence classNamePersistence;
2641 @BeanReference(type = ClusterGroupPersistence.class)
2642 protected ClusterGroupPersistence clusterGroupPersistence;
2643 @BeanReference(type = CompanyPersistence.class)
2644 protected CompanyPersistence companyPersistence;
2645 @BeanReference(type = ContactPersistence.class)
2646 protected ContactPersistence contactPersistence;
2647 @BeanReference(type = CountryPersistence.class)
2648 protected CountryPersistence countryPersistence;
2649 @BeanReference(type = EmailAddressPersistence.class)
2650 protected EmailAddressPersistence emailAddressPersistence;
2651 @BeanReference(type = GroupPersistence.class)
2652 protected GroupPersistence groupPersistence;
2653 @BeanReference(type = ImagePersistence.class)
2654 protected ImagePersistence imagePersistence;
2655 @BeanReference(type = LayoutPersistence.class)
2656 protected LayoutPersistence layoutPersistence;
2657 @BeanReference(type = LayoutBranchPersistence.class)
2658 protected LayoutBranchPersistence layoutBranchPersistence;
2659 @BeanReference(type = LayoutPrototypePersistence.class)
2660 protected LayoutPrototypePersistence layoutPrototypePersistence;
2661 @BeanReference(type = LayoutRevisionPersistence.class)
2662 protected LayoutRevisionPersistence layoutRevisionPersistence;
2663 @BeanReference(type = LayoutSetPersistence.class)
2664 protected LayoutSetPersistence layoutSetPersistence;
2665 @BeanReference(type = LayoutSetBranchPersistence.class)
2666 protected LayoutSetBranchPersistence layoutSetBranchPersistence;
2667 @BeanReference(type = LayoutSetPrototypePersistence.class)
2668 protected LayoutSetPrototypePersistence layoutSetPrototypePersistence;
2669 @BeanReference(type = ListTypePersistence.class)
2670 protected ListTypePersistence listTypePersistence;
2671 @BeanReference(type = LockPersistence.class)
2672 protected LockPersistence lockPersistence;
2673 @BeanReference(type = MembershipRequestPersistence.class)
2674 protected MembershipRequestPersistence membershipRequestPersistence;
2675 @BeanReference(type = OrganizationPersistence.class)
2676 protected OrganizationPersistence organizationPersistence;
2677 @BeanReference(type = OrgGroupPermissionPersistence.class)
2678 protected OrgGroupPermissionPersistence orgGroupPermissionPersistence;
2679 @BeanReference(type = OrgGroupRolePersistence.class)
2680 protected OrgGroupRolePersistence orgGroupRolePersistence;
2681 @BeanReference(type = OrgLaborPersistence.class)
2682 protected OrgLaborPersistence orgLaborPersistence;
2683 @BeanReference(type = PasswordPolicyPersistence.class)
2684 protected PasswordPolicyPersistence passwordPolicyPersistence;
2685 @BeanReference(type = PasswordPolicyRelPersistence.class)
2686 protected PasswordPolicyRelPersistence passwordPolicyRelPersistence;
2687 @BeanReference(type = PasswordTrackerPersistence.class)
2688 protected PasswordTrackerPersistence passwordTrackerPersistence;
2689 @BeanReference(type = PermissionPersistence.class)
2690 protected PermissionPersistence permissionPersistence;
2691 @BeanReference(type = PhonePersistence.class)
2692 protected PhonePersistence phonePersistence;
2693 @BeanReference(type = PluginSettingPersistence.class)
2694 protected PluginSettingPersistence pluginSettingPersistence;
2695 @BeanReference(type = PortalPreferencesPersistence.class)
2696 protected PortalPreferencesPersistence portalPreferencesPersistence;
2697 @BeanReference(type = PortletPersistence.class)
2698 protected PortletPersistence portletPersistence;
2699 @BeanReference(type = PortletItemPersistence.class)
2700 protected PortletItemPersistence portletItemPersistence;
2701 @BeanReference(type = PortletPreferencesPersistence.class)
2702 protected PortletPreferencesPersistence portletPreferencesPersistence;
2703 @BeanReference(type = RegionPersistence.class)
2704 protected RegionPersistence regionPersistence;
2705 @BeanReference(type = ReleasePersistence.class)
2706 protected ReleasePersistence releasePersistence;
2707 @BeanReference(type = RepositoryPersistence.class)
2708 protected RepositoryPersistence repositoryPersistence;
2709 @BeanReference(type = RepositoryEntryPersistence.class)
2710 protected RepositoryEntryPersistence repositoryEntryPersistence;
2711 @BeanReference(type = ResourcePersistence.class)
2712 protected ResourcePersistence resourcePersistence;
2713 @BeanReference(type = ResourceActionPersistence.class)
2714 protected ResourceActionPersistence resourceActionPersistence;
2715 @BeanReference(type = ResourceBlockPersistence.class)
2716 protected ResourceBlockPersistence resourceBlockPersistence;
2717 @BeanReference(type = ResourceBlockPermissionPersistence.class)
2718 protected ResourceBlockPermissionPersistence resourceBlockPermissionPersistence;
2719 @BeanReference(type = ResourceCodePersistence.class)
2720 protected ResourceCodePersistence resourceCodePersistence;
2721 @BeanReference(type = ResourcePermissionPersistence.class)
2722 protected ResourcePermissionPersistence resourcePermissionPersistence;
2723 @BeanReference(type = ResourceTypePermissionPersistence.class)
2724 protected ResourceTypePermissionPersistence resourceTypePermissionPersistence;
2725 @BeanReference(type = RolePersistence.class)
2726 protected RolePersistence rolePersistence;
2727 @BeanReference(type = ServiceComponentPersistence.class)
2728 protected ServiceComponentPersistence serviceComponentPersistence;
2729 @BeanReference(type = ShardPersistence.class)
2730 protected ShardPersistence shardPersistence;
2731 @BeanReference(type = SubscriptionPersistence.class)
2732 protected SubscriptionPersistence subscriptionPersistence;
2733 @BeanReference(type = TeamPersistence.class)
2734 protected TeamPersistence teamPersistence;
2735 @BeanReference(type = TicketPersistence.class)
2736 protected TicketPersistence ticketPersistence;
2737 @BeanReference(type = UserPersistence.class)
2738 protected UserPersistence userPersistence;
2739 @BeanReference(type = UserGroupPersistence.class)
2740 protected UserGroupPersistence userGroupPersistence;
2741 @BeanReference(type = UserGroupGroupRolePersistence.class)
2742 protected UserGroupGroupRolePersistence userGroupGroupRolePersistence;
2743 @BeanReference(type = UserGroupRolePersistence.class)
2744 protected UserGroupRolePersistence userGroupRolePersistence;
2745 @BeanReference(type = UserIdMapperPersistence.class)
2746 protected UserIdMapperPersistence userIdMapperPersistence;
2747 @BeanReference(type = UserNotificationEventPersistence.class)
2748 protected UserNotificationEventPersistence userNotificationEventPersistence;
2749 @BeanReference(type = UserTrackerPersistence.class)
2750 protected UserTrackerPersistence userTrackerPersistence;
2751 @BeanReference(type = UserTrackerPathPersistence.class)
2752 protected UserTrackerPathPersistence userTrackerPathPersistence;
2753 @BeanReference(type = VirtualHostPersistence.class)
2754 protected VirtualHostPersistence virtualHostPersistence;
2755 @BeanReference(type = WebDAVPropsPersistence.class)
2756 protected WebDAVPropsPersistence webDAVPropsPersistence;
2757 @BeanReference(type = WebsitePersistence.class)
2758 protected WebsitePersistence websitePersistence;
2759 @BeanReference(type = WorkflowDefinitionLinkPersistence.class)
2760 protected WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
2761 @BeanReference(type = WorkflowInstanceLinkPersistence.class)
2762 protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
2763 private static final String _SQL_SELECT_LAYOUTSETBRANCH = "SELECT layoutSetBranch FROM LayoutSetBranch layoutSetBranch";
2764 private static final String _SQL_SELECT_LAYOUTSETBRANCH_WHERE = "SELECT layoutSetBranch FROM LayoutSetBranch layoutSetBranch WHERE ";
2765 private static final String _SQL_COUNT_LAYOUTSETBRANCH = "SELECT COUNT(layoutSetBranch) FROM LayoutSetBranch layoutSetBranch";
2766 private static final String _SQL_COUNT_LAYOUTSETBRANCH_WHERE = "SELECT COUNT(layoutSetBranch) FROM LayoutSetBranch layoutSetBranch WHERE ";
2767 private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "layoutSetBranch.groupId = ?";
2768 private static final String _FINDER_COLUMN_G_P_GROUPID_2 = "layoutSetBranch.groupId = ? AND ";
2769 private static final String _FINDER_COLUMN_G_P_PRIVATELAYOUT_2 = "layoutSetBranch.privateLayout = ?";
2770 private static final String _FINDER_COLUMN_G_P_N_GROUPID_2 = "layoutSetBranch.groupId = ? AND ";
2771 private static final String _FINDER_COLUMN_G_P_N_PRIVATELAYOUT_2 = "layoutSetBranch.privateLayout = ? AND ";
2772 private static final String _FINDER_COLUMN_G_P_N_NAME_1 = "layoutSetBranch.name IS NULL";
2773 private static final String _FINDER_COLUMN_G_P_N_NAME_2 = "layoutSetBranch.name = ?";
2774 private static final String _FINDER_COLUMN_G_P_N_NAME_3 = "(layoutSetBranch.name IS NULL OR layoutSetBranch.name = ?)";
2775 private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "layoutSetBranch.layoutSetBranchId";
2776 private static final String _FILTER_SQL_SELECT_LAYOUTSETBRANCH_WHERE = "SELECT DISTINCT {layoutSetBranch.*} FROM LayoutSetBranch layoutSetBranch WHERE ";
2777 private static final String _FILTER_SQL_SELECT_LAYOUTSETBRANCH_NO_INLINE_DISTINCT_WHERE_1 =
2778 "SELECT {LayoutSetBranch.*} FROM (SELECT DISTINCT layoutSetBranch.layoutSetBranchId FROM LayoutSetBranch layoutSetBranch WHERE ";
2779 private static final String _FILTER_SQL_SELECT_LAYOUTSETBRANCH_NO_INLINE_DISTINCT_WHERE_2 =
2780 ") TEMP_TABLE INNER JOIN LayoutSetBranch ON TEMP_TABLE.layoutSetBranchId = LayoutSetBranch.layoutSetBranchId";
2781 private static final String _FILTER_SQL_COUNT_LAYOUTSETBRANCH_WHERE = "SELECT COUNT(DISTINCT layoutSetBranch.layoutSetBranchId) AS COUNT_VALUE FROM LayoutSetBranch layoutSetBranch WHERE ";
2782 private static final String _FILTER_ENTITY_ALIAS = "layoutSetBranch";
2783 private static final String _FILTER_ENTITY_TABLE = "LayoutSetBranch";
2784 private static final String _ORDER_BY_ENTITY_ALIAS = "layoutSetBranch.";
2785 private static final String _ORDER_BY_ENTITY_TABLE = "LayoutSetBranch.";
2786 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No LayoutSetBranch exists with the primary key ";
2787 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No LayoutSetBranch exists with the key {";
2788 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
2789 private static Log _log = LogFactoryUtil.getLog(LayoutSetBranchPersistenceImpl.class);
2790 private static LayoutSetBranch _nullLayoutSetBranch = new LayoutSetBranchImpl() {
2791 @Override
2792 public Object clone() {
2793 return this;
2794 }
2795
2796 @Override
2797 public CacheModel<LayoutSetBranch> toCacheModel() {
2798 return _nullLayoutSetBranchCacheModel;
2799 }
2800 };
2801
2802 private static CacheModel<LayoutSetBranch> _nullLayoutSetBranchCacheModel = new CacheModel<LayoutSetBranch>() {
2803 public LayoutSetBranch toEntityModel() {
2804 return _nullLayoutSetBranch;
2805 }
2806 };
2807 }