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.kernel.util.Validator;
039 import com.liferay.portal.model.CacheModel;
040 import com.liferay.portal.model.LayoutSetBranch;
041 import com.liferay.portal.model.ModelListener;
042 import com.liferay.portal.model.impl.LayoutSetBranchImpl;
043 import com.liferay.portal.model.impl.LayoutSetBranchModelImpl;
044 import com.liferay.portal.security.permission.InlineSQLHelperUtil;
045 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
046
047 import java.io.Serializable;
048
049 import java.util.ArrayList;
050 import java.util.Collections;
051 import java.util.List;
052
053
065 public class LayoutSetBranchPersistenceImpl extends BasePersistenceImpl<LayoutSetBranch>
066 implements LayoutSetBranchPersistence {
067
072 public static final String FINDER_CLASS_NAME_ENTITY = LayoutSetBranchImpl.class.getName();
073 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
074 ".List1";
075 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
076 ".List2";
077 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(LayoutSetBranchModelImpl.ENTITY_CACHE_ENABLED,
078 LayoutSetBranchModelImpl.FINDER_CACHE_ENABLED,
079 LayoutSetBranchImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
080 "findByGroupId",
081 new String[] {
082 Long.class.getName(),
083
084 "java.lang.Integer", "java.lang.Integer",
085 "com.liferay.portal.kernel.util.OrderByComparator"
086 });
087 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID =
088 new FinderPath(LayoutSetBranchModelImpl.ENTITY_CACHE_ENABLED,
089 LayoutSetBranchModelImpl.FINDER_CACHE_ENABLED,
090 LayoutSetBranchImpl.class,
091 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByGroupId",
092 new String[] { Long.class.getName() },
093 LayoutSetBranchModelImpl.GROUPID_COLUMN_BITMASK);
094 public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(LayoutSetBranchModelImpl.ENTITY_CACHE_ENABLED,
095 LayoutSetBranchModelImpl.FINDER_CACHE_ENABLED, Long.class,
096 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId",
097 new String[] { Long.class.getName() });
098 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P = new FinderPath(LayoutSetBranchModelImpl.ENTITY_CACHE_ENABLED,
099 LayoutSetBranchModelImpl.FINDER_CACHE_ENABLED,
100 LayoutSetBranchImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
101 "findByG_P",
102 new String[] {
103 Long.class.getName(), Boolean.class.getName(),
104
105 "java.lang.Integer", "java.lang.Integer",
106 "com.liferay.portal.kernel.util.OrderByComparator"
107 });
108 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P = new FinderPath(LayoutSetBranchModelImpl.ENTITY_CACHE_ENABLED,
109 LayoutSetBranchModelImpl.FINDER_CACHE_ENABLED,
110 LayoutSetBranchImpl.class,
111 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_P",
112 new String[] { Long.class.getName(), Boolean.class.getName() },
113 LayoutSetBranchModelImpl.GROUPID_COLUMN_BITMASK |
114 LayoutSetBranchModelImpl.PRIVATELAYOUT_COLUMN_BITMASK);
115 public static final FinderPath FINDER_PATH_COUNT_BY_G_P = new FinderPath(LayoutSetBranchModelImpl.ENTITY_CACHE_ENABLED,
116 LayoutSetBranchModelImpl.FINDER_CACHE_ENABLED, Long.class,
117 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_P",
118 new String[] { Long.class.getName(), Boolean.class.getName() });
119 public static final FinderPath FINDER_PATH_FETCH_BY_G_P_N = new FinderPath(LayoutSetBranchModelImpl.ENTITY_CACHE_ENABLED,
120 LayoutSetBranchModelImpl.FINDER_CACHE_ENABLED,
121 LayoutSetBranchImpl.class, FINDER_CLASS_NAME_ENTITY,
122 "fetchByG_P_N",
123 new String[] {
124 Long.class.getName(), Boolean.class.getName(),
125 String.class.getName()
126 },
127 LayoutSetBranchModelImpl.GROUPID_COLUMN_BITMASK |
128 LayoutSetBranchModelImpl.PRIVATELAYOUT_COLUMN_BITMASK |
129 LayoutSetBranchModelImpl.NAME_COLUMN_BITMASK);
130 public static final FinderPath FINDER_PATH_COUNT_BY_G_P_N = new FinderPath(LayoutSetBranchModelImpl.ENTITY_CACHE_ENABLED,
131 LayoutSetBranchModelImpl.FINDER_CACHE_ENABLED, Long.class,
132 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_P_N",
133 new String[] {
134 Long.class.getName(), Boolean.class.getName(),
135 String.class.getName()
136 });
137 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(LayoutSetBranchModelImpl.ENTITY_CACHE_ENABLED,
138 LayoutSetBranchModelImpl.FINDER_CACHE_ENABLED,
139 LayoutSetBranchImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
140 "findAll", new String[0]);
141 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(LayoutSetBranchModelImpl.ENTITY_CACHE_ENABLED,
142 LayoutSetBranchModelImpl.FINDER_CACHE_ENABLED,
143 LayoutSetBranchImpl.class,
144 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
145 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(LayoutSetBranchModelImpl.ENTITY_CACHE_ENABLED,
146 LayoutSetBranchModelImpl.FINDER_CACHE_ENABLED, Long.class,
147 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
148
149
154 public void cacheResult(LayoutSetBranch layoutSetBranch) {
155 EntityCacheUtil.putResult(LayoutSetBranchModelImpl.ENTITY_CACHE_ENABLED,
156 LayoutSetBranchImpl.class, layoutSetBranch.getPrimaryKey(),
157 layoutSetBranch);
158
159 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P_N,
160 new Object[] {
161 Long.valueOf(layoutSetBranch.getGroupId()),
162 Boolean.valueOf(layoutSetBranch.getPrivateLayout()),
163
164 layoutSetBranch.getName()
165 }, layoutSetBranch);
166
167 layoutSetBranch.resetOriginalValues();
168 }
169
170
175 public void cacheResult(List<LayoutSetBranch> layoutSetBranchs) {
176 for (LayoutSetBranch layoutSetBranch : layoutSetBranchs) {
177 if (EntityCacheUtil.getResult(
178 LayoutSetBranchModelImpl.ENTITY_CACHE_ENABLED,
179 LayoutSetBranchImpl.class,
180 layoutSetBranch.getPrimaryKey()) == null) {
181 cacheResult(layoutSetBranch);
182 }
183 else {
184 layoutSetBranch.resetOriginalValues();
185 }
186 }
187 }
188
189
196 @Override
197 public void clearCache() {
198 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
199 CacheRegistryUtil.clear(LayoutSetBranchImpl.class.getName());
200 }
201
202 EntityCacheUtil.clearCache(LayoutSetBranchImpl.class.getName());
203
204 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
205 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
206 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
207 }
208
209
216 @Override
217 public void clearCache(LayoutSetBranch layoutSetBranch) {
218 EntityCacheUtil.removeResult(LayoutSetBranchModelImpl.ENTITY_CACHE_ENABLED,
219 LayoutSetBranchImpl.class, layoutSetBranch.getPrimaryKey());
220
221 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
222 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
223
224 clearUniqueFindersCache(layoutSetBranch);
225 }
226
227 @Override
228 public void clearCache(List<LayoutSetBranch> layoutSetBranchs) {
229 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
230 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
231
232 for (LayoutSetBranch layoutSetBranch : layoutSetBranchs) {
233 EntityCacheUtil.removeResult(LayoutSetBranchModelImpl.ENTITY_CACHE_ENABLED,
234 LayoutSetBranchImpl.class, layoutSetBranch.getPrimaryKey());
235
236 clearUniqueFindersCache(layoutSetBranch);
237 }
238 }
239
240 protected void clearUniqueFindersCache(LayoutSetBranch layoutSetBranch) {
241 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_P_N,
242 new Object[] {
243 Long.valueOf(layoutSetBranch.getGroupId()),
244 Boolean.valueOf(layoutSetBranch.getPrivateLayout()),
245
246 layoutSetBranch.getName()
247 });
248 }
249
250
256 public LayoutSetBranch create(long layoutSetBranchId) {
257 LayoutSetBranch layoutSetBranch = new LayoutSetBranchImpl();
258
259 layoutSetBranch.setNew(true);
260 layoutSetBranch.setPrimaryKey(layoutSetBranchId);
261
262 return layoutSetBranch;
263 }
264
265
273 public LayoutSetBranch remove(long layoutSetBranchId)
274 throws NoSuchLayoutSetBranchException, SystemException {
275 return remove(Long.valueOf(layoutSetBranchId));
276 }
277
278
286 @Override
287 public LayoutSetBranch remove(Serializable primaryKey)
288 throws NoSuchLayoutSetBranchException, SystemException {
289 Session session = null;
290
291 try {
292 session = openSession();
293
294 LayoutSetBranch layoutSetBranch = (LayoutSetBranch)session.get(LayoutSetBranchImpl.class,
295 primaryKey);
296
297 if (layoutSetBranch == null) {
298 if (_log.isWarnEnabled()) {
299 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
300 }
301
302 throw new NoSuchLayoutSetBranchException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
303 primaryKey);
304 }
305
306 return remove(layoutSetBranch);
307 }
308 catch (NoSuchLayoutSetBranchException nsee) {
309 throw nsee;
310 }
311 catch (Exception e) {
312 throw processException(e);
313 }
314 finally {
315 closeSession(session);
316 }
317 }
318
319 @Override
320 protected LayoutSetBranch removeImpl(LayoutSetBranch layoutSetBranch)
321 throws SystemException {
322 layoutSetBranch = toUnwrappedModel(layoutSetBranch);
323
324 Session session = null;
325
326 try {
327 session = openSession();
328
329 BatchSessionUtil.delete(session, layoutSetBranch);
330 }
331 catch (Exception e) {
332 throw processException(e);
333 }
334 finally {
335 closeSession(session);
336 }
337
338 clearCache(layoutSetBranch);
339
340 return layoutSetBranch;
341 }
342
343 @Override
344 public LayoutSetBranch updateImpl(
345 com.liferay.portal.model.LayoutSetBranch layoutSetBranch, boolean merge)
346 throws SystemException {
347 layoutSetBranch = toUnwrappedModel(layoutSetBranch);
348
349 boolean isNew = layoutSetBranch.isNew();
350
351 LayoutSetBranchModelImpl layoutSetBranchModelImpl = (LayoutSetBranchModelImpl)layoutSetBranch;
352
353 Session session = null;
354
355 try {
356 session = openSession();
357
358 BatchSessionUtil.update(session, layoutSetBranch, merge);
359
360 layoutSetBranch.setNew(false);
361 }
362 catch (Exception e) {
363 throw processException(e);
364 }
365 finally {
366 closeSession(session);
367 }
368
369 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
370
371 if (isNew || !LayoutSetBranchModelImpl.COLUMN_BITMASK_ENABLED) {
372 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
373 }
374
375 else {
376 if ((layoutSetBranchModelImpl.getColumnBitmask() &
377 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
378 Object[] args = new Object[] {
379 Long.valueOf(layoutSetBranchModelImpl.getOriginalGroupId())
380 };
381
382 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
383 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
384 args);
385
386 args = new Object[] {
387 Long.valueOf(layoutSetBranchModelImpl.getGroupId())
388 };
389
390 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
391 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
392 args);
393 }
394
395 if ((layoutSetBranchModelImpl.getColumnBitmask() &
396 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P.getColumnBitmask()) != 0) {
397 Object[] args = new Object[] {
398 Long.valueOf(layoutSetBranchModelImpl.getOriginalGroupId()),
399 Boolean.valueOf(layoutSetBranchModelImpl.getOriginalPrivateLayout())
400 };
401
402 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P, args);
403 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P,
404 args);
405
406 args = new Object[] {
407 Long.valueOf(layoutSetBranchModelImpl.getGroupId()),
408 Boolean.valueOf(layoutSetBranchModelImpl.getPrivateLayout())
409 };
410
411 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P, args);
412 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P,
413 args);
414 }
415 }
416
417 EntityCacheUtil.putResult(LayoutSetBranchModelImpl.ENTITY_CACHE_ENABLED,
418 LayoutSetBranchImpl.class, layoutSetBranch.getPrimaryKey(),
419 layoutSetBranch);
420
421 if (isNew) {
422 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P_N,
423 new Object[] {
424 Long.valueOf(layoutSetBranch.getGroupId()),
425 Boolean.valueOf(layoutSetBranch.getPrivateLayout()),
426
427 layoutSetBranch.getName()
428 }, layoutSetBranch);
429 }
430 else {
431 if ((layoutSetBranchModelImpl.getColumnBitmask() &
432 FINDER_PATH_FETCH_BY_G_P_N.getColumnBitmask()) != 0) {
433 Object[] args = new Object[] {
434 Long.valueOf(layoutSetBranchModelImpl.getOriginalGroupId()),
435 Boolean.valueOf(layoutSetBranchModelImpl.getOriginalPrivateLayout()),
436
437 layoutSetBranchModelImpl.getOriginalName()
438 };
439
440 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P_N, args);
441
442 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_P_N, args);
443
444 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P_N,
445 new Object[] {
446 Long.valueOf(layoutSetBranch.getGroupId()),
447 Boolean.valueOf(layoutSetBranch.getPrivateLayout()),
448
449 layoutSetBranch.getName()
450 }, layoutSetBranch);
451 }
452 }
453
454 return layoutSetBranch;
455 }
456
457 protected LayoutSetBranch toUnwrappedModel(LayoutSetBranch layoutSetBranch) {
458 if (layoutSetBranch instanceof LayoutSetBranchImpl) {
459 return layoutSetBranch;
460 }
461
462 LayoutSetBranchImpl layoutSetBranchImpl = new LayoutSetBranchImpl();
463
464 layoutSetBranchImpl.setNew(layoutSetBranch.isNew());
465 layoutSetBranchImpl.setPrimaryKey(layoutSetBranch.getPrimaryKey());
466
467 layoutSetBranchImpl.setLayoutSetBranchId(layoutSetBranch.getLayoutSetBranchId());
468 layoutSetBranchImpl.setGroupId(layoutSetBranch.getGroupId());
469 layoutSetBranchImpl.setCompanyId(layoutSetBranch.getCompanyId());
470 layoutSetBranchImpl.setUserId(layoutSetBranch.getUserId());
471 layoutSetBranchImpl.setUserName(layoutSetBranch.getUserName());
472 layoutSetBranchImpl.setCreateDate(layoutSetBranch.getCreateDate());
473 layoutSetBranchImpl.setModifiedDate(layoutSetBranch.getModifiedDate());
474 layoutSetBranchImpl.setPrivateLayout(layoutSetBranch.isPrivateLayout());
475 layoutSetBranchImpl.setName(layoutSetBranch.getName());
476 layoutSetBranchImpl.setDescription(layoutSetBranch.getDescription());
477 layoutSetBranchImpl.setMaster(layoutSetBranch.isMaster());
478 layoutSetBranchImpl.setLogo(layoutSetBranch.isLogo());
479 layoutSetBranchImpl.setLogoId(layoutSetBranch.getLogoId());
480 layoutSetBranchImpl.setThemeId(layoutSetBranch.getThemeId());
481 layoutSetBranchImpl.setColorSchemeId(layoutSetBranch.getColorSchemeId());
482 layoutSetBranchImpl.setWapThemeId(layoutSetBranch.getWapThemeId());
483 layoutSetBranchImpl.setWapColorSchemeId(layoutSetBranch.getWapColorSchemeId());
484 layoutSetBranchImpl.setCss(layoutSetBranch.getCss());
485 layoutSetBranchImpl.setSettings(layoutSetBranch.getSettings());
486 layoutSetBranchImpl.setLayoutSetPrototypeUuid(layoutSetBranch.getLayoutSetPrototypeUuid());
487 layoutSetBranchImpl.setLayoutSetPrototypeLinkEnabled(layoutSetBranch.isLayoutSetPrototypeLinkEnabled());
488
489 return layoutSetBranchImpl;
490 }
491
492
500 @Override
501 public LayoutSetBranch findByPrimaryKey(Serializable primaryKey)
502 throws NoSuchModelException, SystemException {
503 return findByPrimaryKey(((Long)primaryKey).longValue());
504 }
505
506
514 public LayoutSetBranch findByPrimaryKey(long layoutSetBranchId)
515 throws NoSuchLayoutSetBranchException, SystemException {
516 LayoutSetBranch layoutSetBranch = fetchByPrimaryKey(layoutSetBranchId);
517
518 if (layoutSetBranch == null) {
519 if (_log.isWarnEnabled()) {
520 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + layoutSetBranchId);
521 }
522
523 throw new NoSuchLayoutSetBranchException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
524 layoutSetBranchId);
525 }
526
527 return layoutSetBranch;
528 }
529
530
537 @Override
538 public LayoutSetBranch fetchByPrimaryKey(Serializable primaryKey)
539 throws SystemException {
540 return fetchByPrimaryKey(((Long)primaryKey).longValue());
541 }
542
543
550 public LayoutSetBranch fetchByPrimaryKey(long layoutSetBranchId)
551 throws SystemException {
552 LayoutSetBranch layoutSetBranch = (LayoutSetBranch)EntityCacheUtil.getResult(LayoutSetBranchModelImpl.ENTITY_CACHE_ENABLED,
553 LayoutSetBranchImpl.class, layoutSetBranchId);
554
555 if (layoutSetBranch == _nullLayoutSetBranch) {
556 return null;
557 }
558
559 if (layoutSetBranch == null) {
560 Session session = null;
561
562 boolean hasException = false;
563
564 try {
565 session = openSession();
566
567 layoutSetBranch = (LayoutSetBranch)session.get(LayoutSetBranchImpl.class,
568 Long.valueOf(layoutSetBranchId));
569 }
570 catch (Exception e) {
571 hasException = true;
572
573 throw processException(e);
574 }
575 finally {
576 if (layoutSetBranch != null) {
577 cacheResult(layoutSetBranch);
578 }
579 else if (!hasException) {
580 EntityCacheUtil.putResult(LayoutSetBranchModelImpl.ENTITY_CACHE_ENABLED,
581 LayoutSetBranchImpl.class, layoutSetBranchId,
582 _nullLayoutSetBranch);
583 }
584
585 closeSession(session);
586 }
587 }
588
589 return layoutSetBranch;
590 }
591
592
599 public List<LayoutSetBranch> findByGroupId(long groupId)
600 throws SystemException {
601 return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
602 }
603
604
617 public List<LayoutSetBranch> findByGroupId(long groupId, int start, int end)
618 throws SystemException {
619 return findByGroupId(groupId, start, end, null);
620 }
621
622
636 public List<LayoutSetBranch> findByGroupId(long groupId, int start,
637 int end, OrderByComparator orderByComparator) throws SystemException {
638 FinderPath finderPath = null;
639 Object[] finderArgs = null;
640
641 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
642 (orderByComparator == null)) {
643 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
644 finderArgs = new Object[] { groupId };
645 }
646 else {
647 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
648 finderArgs = new Object[] { groupId, start, end, orderByComparator };
649 }
650
651 List<LayoutSetBranch> list = (List<LayoutSetBranch>)FinderCacheUtil.getResult(finderPath,
652 finderArgs, this);
653
654 if ((list != null) && !list.isEmpty()) {
655 for (LayoutSetBranch layoutSetBranch : list) {
656 if ((groupId != layoutSetBranch.getGroupId())) {
657 list = null;
658
659 break;
660 }
661 }
662 }
663
664 if (list == null) {
665 StringBundler query = null;
666
667 if (orderByComparator != null) {
668 query = new StringBundler(3 +
669 (orderByComparator.getOrderByFields().length * 3));
670 }
671 else {
672 query = new StringBundler(3);
673 }
674
675 query.append(_SQL_SELECT_LAYOUTSETBRANCH_WHERE);
676
677 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
678
679 if (orderByComparator != null) {
680 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
681 orderByComparator);
682 }
683
684 else {
685 query.append(LayoutSetBranchModelImpl.ORDER_BY_JPQL);
686 }
687
688 String sql = query.toString();
689
690 Session session = null;
691
692 try {
693 session = openSession();
694
695 Query q = session.createQuery(sql);
696
697 QueryPos qPos = QueryPos.getInstance(q);
698
699 qPos.add(groupId);
700
701 list = (List<LayoutSetBranch>)QueryUtil.list(q, getDialect(),
702 start, end);
703 }
704 catch (Exception e) {
705 throw processException(e);
706 }
707 finally {
708 if (list == null) {
709 FinderCacheUtil.removeResult(finderPath, finderArgs);
710 }
711 else {
712 cacheResult(list);
713
714 FinderCacheUtil.putResult(finderPath, finderArgs, list);
715 }
716
717 closeSession(session);
718 }
719 }
720
721 return list;
722 }
723
724
733 public LayoutSetBranch findByGroupId_First(long groupId,
734 OrderByComparator orderByComparator)
735 throws NoSuchLayoutSetBranchException, SystemException {
736 LayoutSetBranch layoutSetBranch = fetchByGroupId_First(groupId,
737 orderByComparator);
738
739 if (layoutSetBranch != null) {
740 return layoutSetBranch;
741 }
742
743 StringBundler msg = new StringBundler(4);
744
745 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
746
747 msg.append("groupId=");
748 msg.append(groupId);
749
750 msg.append(StringPool.CLOSE_CURLY_BRACE);
751
752 throw new NoSuchLayoutSetBranchException(msg.toString());
753 }
754
755
763 public LayoutSetBranch fetchByGroupId_First(long groupId,
764 OrderByComparator orderByComparator) throws SystemException {
765 List<LayoutSetBranch> list = findByGroupId(groupId, 0, 1,
766 orderByComparator);
767
768 if (!list.isEmpty()) {
769 return list.get(0);
770 }
771
772 return null;
773 }
774
775
784 public LayoutSetBranch findByGroupId_Last(long groupId,
785 OrderByComparator orderByComparator)
786 throws NoSuchLayoutSetBranchException, SystemException {
787 LayoutSetBranch layoutSetBranch = fetchByGroupId_Last(groupId,
788 orderByComparator);
789
790 if (layoutSetBranch != null) {
791 return layoutSetBranch;
792 }
793
794 StringBundler msg = new StringBundler(4);
795
796 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
797
798 msg.append("groupId=");
799 msg.append(groupId);
800
801 msg.append(StringPool.CLOSE_CURLY_BRACE);
802
803 throw new NoSuchLayoutSetBranchException(msg.toString());
804 }
805
806
814 public LayoutSetBranch fetchByGroupId_Last(long groupId,
815 OrderByComparator orderByComparator) throws SystemException {
816 int count = countByGroupId(groupId);
817
818 List<LayoutSetBranch> list = findByGroupId(groupId, count - 1, count,
819 orderByComparator);
820
821 if (!list.isEmpty()) {
822 return list.get(0);
823 }
824
825 return null;
826 }
827
828
838 public LayoutSetBranch[] findByGroupId_PrevAndNext(long layoutSetBranchId,
839 long groupId, OrderByComparator orderByComparator)
840 throws NoSuchLayoutSetBranchException, SystemException {
841 LayoutSetBranch layoutSetBranch = findByPrimaryKey(layoutSetBranchId);
842
843 Session session = null;
844
845 try {
846 session = openSession();
847
848 LayoutSetBranch[] array = new LayoutSetBranchImpl[3];
849
850 array[0] = getByGroupId_PrevAndNext(session, layoutSetBranch,
851 groupId, orderByComparator, true);
852
853 array[1] = layoutSetBranch;
854
855 array[2] = getByGroupId_PrevAndNext(session, layoutSetBranch,
856 groupId, orderByComparator, false);
857
858 return array;
859 }
860 catch (Exception e) {
861 throw processException(e);
862 }
863 finally {
864 closeSession(session);
865 }
866 }
867
868 protected LayoutSetBranch getByGroupId_PrevAndNext(Session session,
869 LayoutSetBranch layoutSetBranch, long groupId,
870 OrderByComparator orderByComparator, boolean previous) {
871 StringBundler query = null;
872
873 if (orderByComparator != null) {
874 query = new StringBundler(6 +
875 (orderByComparator.getOrderByFields().length * 6));
876 }
877 else {
878 query = new StringBundler(3);
879 }
880
881 query.append(_SQL_SELECT_LAYOUTSETBRANCH_WHERE);
882
883 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
884
885 if (orderByComparator != null) {
886 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
887
888 if (orderByConditionFields.length > 0) {
889 query.append(WHERE_AND);
890 }
891
892 for (int i = 0; i < orderByConditionFields.length; i++) {
893 query.append(_ORDER_BY_ENTITY_ALIAS);
894 query.append(orderByConditionFields[i]);
895
896 if ((i + 1) < orderByConditionFields.length) {
897 if (orderByComparator.isAscending() ^ previous) {
898 query.append(WHERE_GREATER_THAN_HAS_NEXT);
899 }
900 else {
901 query.append(WHERE_LESSER_THAN_HAS_NEXT);
902 }
903 }
904 else {
905 if (orderByComparator.isAscending() ^ previous) {
906 query.append(WHERE_GREATER_THAN);
907 }
908 else {
909 query.append(WHERE_LESSER_THAN);
910 }
911 }
912 }
913
914 query.append(ORDER_BY_CLAUSE);
915
916 String[] orderByFields = orderByComparator.getOrderByFields();
917
918 for (int i = 0; i < orderByFields.length; i++) {
919 query.append(_ORDER_BY_ENTITY_ALIAS);
920 query.append(orderByFields[i]);
921
922 if ((i + 1) < orderByFields.length) {
923 if (orderByComparator.isAscending() ^ previous) {
924 query.append(ORDER_BY_ASC_HAS_NEXT);
925 }
926 else {
927 query.append(ORDER_BY_DESC_HAS_NEXT);
928 }
929 }
930 else {
931 if (orderByComparator.isAscending() ^ previous) {
932 query.append(ORDER_BY_ASC);
933 }
934 else {
935 query.append(ORDER_BY_DESC);
936 }
937 }
938 }
939 }
940
941 else {
942 query.append(LayoutSetBranchModelImpl.ORDER_BY_JPQL);
943 }
944
945 String sql = query.toString();
946
947 Query q = session.createQuery(sql);
948
949 q.setFirstResult(0);
950 q.setMaxResults(2);
951
952 QueryPos qPos = QueryPos.getInstance(q);
953
954 qPos.add(groupId);
955
956 if (orderByComparator != null) {
957 Object[] values = orderByComparator.getOrderByConditionValues(layoutSetBranch);
958
959 for (Object value : values) {
960 qPos.add(value);
961 }
962 }
963
964 List<LayoutSetBranch> list = q.list();
965
966 if (list.size() == 2) {
967 return list.get(1);
968 }
969 else {
970 return null;
971 }
972 }
973
974
981 public List<LayoutSetBranch> filterFindByGroupId(long groupId)
982 throws SystemException {
983 return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
984 QueryUtil.ALL_POS, null);
985 }
986
987
1000 public List<LayoutSetBranch> filterFindByGroupId(long groupId, int start,
1001 int end) throws SystemException {
1002 return filterFindByGroupId(groupId, start, end, null);
1003 }
1004
1005
1019 public List<LayoutSetBranch> filterFindByGroupId(long groupId, int start,
1020 int end, OrderByComparator orderByComparator) throws SystemException {
1021 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1022 return findByGroupId(groupId, start, end, orderByComparator);
1023 }
1024
1025 StringBundler query = null;
1026
1027 if (orderByComparator != null) {
1028 query = new StringBundler(3 +
1029 (orderByComparator.getOrderByFields().length * 3));
1030 }
1031 else {
1032 query = new StringBundler(3);
1033 }
1034
1035 if (getDB().isSupportsInlineDistinct()) {
1036 query.append(_FILTER_SQL_SELECT_LAYOUTSETBRANCH_WHERE);
1037 }
1038 else {
1039 query.append(_FILTER_SQL_SELECT_LAYOUTSETBRANCH_NO_INLINE_DISTINCT_WHERE_1);
1040 }
1041
1042 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1043
1044 if (!getDB().isSupportsInlineDistinct()) {
1045 query.append(_FILTER_SQL_SELECT_LAYOUTSETBRANCH_NO_INLINE_DISTINCT_WHERE_2);
1046 }
1047
1048 if (orderByComparator != null) {
1049 if (getDB().isSupportsInlineDistinct()) {
1050 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1051 orderByComparator);
1052 }
1053 else {
1054 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
1055 orderByComparator);
1056 }
1057 }
1058
1059 else {
1060 if (getDB().isSupportsInlineDistinct()) {
1061 query.append(LayoutSetBranchModelImpl.ORDER_BY_JPQL);
1062 }
1063 else {
1064 query.append(LayoutSetBranchModelImpl.ORDER_BY_SQL);
1065 }
1066 }
1067
1068 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1069 LayoutSetBranch.class.getName(),
1070 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
1071
1072 Session session = null;
1073
1074 try {
1075 session = openSession();
1076
1077 SQLQuery q = session.createSQLQuery(sql);
1078
1079 if (getDB().isSupportsInlineDistinct()) {
1080 q.addEntity(_FILTER_ENTITY_ALIAS, LayoutSetBranchImpl.class);
1081 }
1082 else {
1083 q.addEntity(_FILTER_ENTITY_TABLE, LayoutSetBranchImpl.class);
1084 }
1085
1086 QueryPos qPos = QueryPos.getInstance(q);
1087
1088 qPos.add(groupId);
1089
1090 return (List<LayoutSetBranch>)QueryUtil.list(q, getDialect(),
1091 start, end);
1092 }
1093 catch (Exception e) {
1094 throw processException(e);
1095 }
1096 finally {
1097 closeSession(session);
1098 }
1099 }
1100
1101
1111 public LayoutSetBranch[] filterFindByGroupId_PrevAndNext(
1112 long layoutSetBranchId, long groupId,
1113 OrderByComparator orderByComparator)
1114 throws NoSuchLayoutSetBranchException, SystemException {
1115 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1116 return findByGroupId_PrevAndNext(layoutSetBranchId, groupId,
1117 orderByComparator);
1118 }
1119
1120 LayoutSetBranch layoutSetBranch = findByPrimaryKey(layoutSetBranchId);
1121
1122 Session session = null;
1123
1124 try {
1125 session = openSession();
1126
1127 LayoutSetBranch[] array = new LayoutSetBranchImpl[3];
1128
1129 array[0] = filterGetByGroupId_PrevAndNext(session, layoutSetBranch,
1130 groupId, orderByComparator, true);
1131
1132 array[1] = layoutSetBranch;
1133
1134 array[2] = filterGetByGroupId_PrevAndNext(session, layoutSetBranch,
1135 groupId, orderByComparator, false);
1136
1137 return array;
1138 }
1139 catch (Exception e) {
1140 throw processException(e);
1141 }
1142 finally {
1143 closeSession(session);
1144 }
1145 }
1146
1147 protected LayoutSetBranch filterGetByGroupId_PrevAndNext(Session session,
1148 LayoutSetBranch layoutSetBranch, long groupId,
1149 OrderByComparator orderByComparator, boolean previous) {
1150 StringBundler query = null;
1151
1152 if (orderByComparator != null) {
1153 query = new StringBundler(6 +
1154 (orderByComparator.getOrderByFields().length * 6));
1155 }
1156 else {
1157 query = new StringBundler(3);
1158 }
1159
1160 if (getDB().isSupportsInlineDistinct()) {
1161 query.append(_FILTER_SQL_SELECT_LAYOUTSETBRANCH_WHERE);
1162 }
1163 else {
1164 query.append(_FILTER_SQL_SELECT_LAYOUTSETBRANCH_NO_INLINE_DISTINCT_WHERE_1);
1165 }
1166
1167 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1168
1169 if (!getDB().isSupportsInlineDistinct()) {
1170 query.append(_FILTER_SQL_SELECT_LAYOUTSETBRANCH_NO_INLINE_DISTINCT_WHERE_2);
1171 }
1172
1173 if (orderByComparator != null) {
1174 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1175
1176 if (orderByConditionFields.length > 0) {
1177 query.append(WHERE_AND);
1178 }
1179
1180 for (int i = 0; i < orderByConditionFields.length; i++) {
1181 if (getDB().isSupportsInlineDistinct()) {
1182 query.append(_ORDER_BY_ENTITY_ALIAS);
1183 }
1184 else {
1185 query.append(_ORDER_BY_ENTITY_TABLE);
1186 }
1187
1188 query.append(orderByConditionFields[i]);
1189
1190 if ((i + 1) < orderByConditionFields.length) {
1191 if (orderByComparator.isAscending() ^ previous) {
1192 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1193 }
1194 else {
1195 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1196 }
1197 }
1198 else {
1199 if (orderByComparator.isAscending() ^ previous) {
1200 query.append(WHERE_GREATER_THAN);
1201 }
1202 else {
1203 query.append(WHERE_LESSER_THAN);
1204 }
1205 }
1206 }
1207
1208 query.append(ORDER_BY_CLAUSE);
1209
1210 String[] orderByFields = orderByComparator.getOrderByFields();
1211
1212 for (int i = 0; i < orderByFields.length; i++) {
1213 if (getDB().isSupportsInlineDistinct()) {
1214 query.append(_ORDER_BY_ENTITY_ALIAS);
1215 }
1216 else {
1217 query.append(_ORDER_BY_ENTITY_TABLE);
1218 }
1219
1220 query.append(orderByFields[i]);
1221
1222 if ((i + 1) < orderByFields.length) {
1223 if (orderByComparator.isAscending() ^ previous) {
1224 query.append(ORDER_BY_ASC_HAS_NEXT);
1225 }
1226 else {
1227 query.append(ORDER_BY_DESC_HAS_NEXT);
1228 }
1229 }
1230 else {
1231 if (orderByComparator.isAscending() ^ previous) {
1232 query.append(ORDER_BY_ASC);
1233 }
1234 else {
1235 query.append(ORDER_BY_DESC);
1236 }
1237 }
1238 }
1239 }
1240
1241 else {
1242 if (getDB().isSupportsInlineDistinct()) {
1243 query.append(LayoutSetBranchModelImpl.ORDER_BY_JPQL);
1244 }
1245 else {
1246 query.append(LayoutSetBranchModelImpl.ORDER_BY_SQL);
1247 }
1248 }
1249
1250 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1251 LayoutSetBranch.class.getName(),
1252 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
1253
1254 SQLQuery q = session.createSQLQuery(sql);
1255
1256 q.setFirstResult(0);
1257 q.setMaxResults(2);
1258
1259 if (getDB().isSupportsInlineDistinct()) {
1260 q.addEntity(_FILTER_ENTITY_ALIAS, LayoutSetBranchImpl.class);
1261 }
1262 else {
1263 q.addEntity(_FILTER_ENTITY_TABLE, LayoutSetBranchImpl.class);
1264 }
1265
1266 QueryPos qPos = QueryPos.getInstance(q);
1267
1268 qPos.add(groupId);
1269
1270 if (orderByComparator != null) {
1271 Object[] values = orderByComparator.getOrderByConditionValues(layoutSetBranch);
1272
1273 for (Object value : values) {
1274 qPos.add(value);
1275 }
1276 }
1277
1278 List<LayoutSetBranch> list = q.list();
1279
1280 if (list.size() == 2) {
1281 return list.get(1);
1282 }
1283 else {
1284 return null;
1285 }
1286 }
1287
1288
1296 public List<LayoutSetBranch> findByG_P(long groupId, boolean privateLayout)
1297 throws SystemException {
1298 return findByG_P(groupId, privateLayout, QueryUtil.ALL_POS,
1299 QueryUtil.ALL_POS, null);
1300 }
1301
1302
1316 public List<LayoutSetBranch> findByG_P(long groupId, boolean privateLayout,
1317 int start, int end) throws SystemException {
1318 return findByG_P(groupId, privateLayout, start, end, null);
1319 }
1320
1321
1336 public List<LayoutSetBranch> findByG_P(long groupId, boolean privateLayout,
1337 int start, int end, OrderByComparator orderByComparator)
1338 throws SystemException {
1339 FinderPath finderPath = null;
1340 Object[] finderArgs = null;
1341
1342 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1343 (orderByComparator == null)) {
1344 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P;
1345 finderArgs = new Object[] { groupId, privateLayout };
1346 }
1347 else {
1348 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P;
1349 finderArgs = new Object[] {
1350 groupId, privateLayout,
1351
1352 start, end, orderByComparator
1353 };
1354 }
1355
1356 List<LayoutSetBranch> list = (List<LayoutSetBranch>)FinderCacheUtil.getResult(finderPath,
1357 finderArgs, this);
1358
1359 if ((list != null) && !list.isEmpty()) {
1360 for (LayoutSetBranch layoutSetBranch : list) {
1361 if ((groupId != layoutSetBranch.getGroupId()) ||
1362 (privateLayout != layoutSetBranch.getPrivateLayout())) {
1363 list = null;
1364
1365 break;
1366 }
1367 }
1368 }
1369
1370 if (list == null) {
1371 StringBundler query = null;
1372
1373 if (orderByComparator != null) {
1374 query = new StringBundler(4 +
1375 (orderByComparator.getOrderByFields().length * 3));
1376 }
1377 else {
1378 query = new StringBundler(4);
1379 }
1380
1381 query.append(_SQL_SELECT_LAYOUTSETBRANCH_WHERE);
1382
1383 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
1384
1385 query.append(_FINDER_COLUMN_G_P_PRIVATELAYOUT_2);
1386
1387 if (orderByComparator != null) {
1388 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1389 orderByComparator);
1390 }
1391
1392 else {
1393 query.append(LayoutSetBranchModelImpl.ORDER_BY_JPQL);
1394 }
1395
1396 String sql = query.toString();
1397
1398 Session session = null;
1399
1400 try {
1401 session = openSession();
1402
1403 Query q = session.createQuery(sql);
1404
1405 QueryPos qPos = QueryPos.getInstance(q);
1406
1407 qPos.add(groupId);
1408
1409 qPos.add(privateLayout);
1410
1411 list = (List<LayoutSetBranch>)QueryUtil.list(q, getDialect(),
1412 start, end);
1413 }
1414 catch (Exception e) {
1415 throw processException(e);
1416 }
1417 finally {
1418 if (list == null) {
1419 FinderCacheUtil.removeResult(finderPath, finderArgs);
1420 }
1421 else {
1422 cacheResult(list);
1423
1424 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1425 }
1426
1427 closeSession(session);
1428 }
1429 }
1430
1431 return list;
1432 }
1433
1434
1444 public LayoutSetBranch findByG_P_First(long groupId, boolean privateLayout,
1445 OrderByComparator orderByComparator)
1446 throws NoSuchLayoutSetBranchException, SystemException {
1447 LayoutSetBranch layoutSetBranch = fetchByG_P_First(groupId,
1448 privateLayout, orderByComparator);
1449
1450 if (layoutSetBranch != null) {
1451 return layoutSetBranch;
1452 }
1453
1454 StringBundler msg = new StringBundler(6);
1455
1456 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1457
1458 msg.append("groupId=");
1459 msg.append(groupId);
1460
1461 msg.append(", privateLayout=");
1462 msg.append(privateLayout);
1463
1464 msg.append(StringPool.CLOSE_CURLY_BRACE);
1465
1466 throw new NoSuchLayoutSetBranchException(msg.toString());
1467 }
1468
1469
1478 public LayoutSetBranch fetchByG_P_First(long groupId,
1479 boolean privateLayout, OrderByComparator orderByComparator)
1480 throws SystemException {
1481 List<LayoutSetBranch> list = findByG_P(groupId, privateLayout, 0, 1,
1482 orderByComparator);
1483
1484 if (!list.isEmpty()) {
1485 return list.get(0);
1486 }
1487
1488 return null;
1489 }
1490
1491
1501 public LayoutSetBranch findByG_P_Last(long groupId, boolean privateLayout,
1502 OrderByComparator orderByComparator)
1503 throws NoSuchLayoutSetBranchException, SystemException {
1504 LayoutSetBranch layoutSetBranch = fetchByG_P_Last(groupId,
1505 privateLayout, orderByComparator);
1506
1507 if (layoutSetBranch != null) {
1508 return layoutSetBranch;
1509 }
1510
1511 StringBundler msg = new StringBundler(6);
1512
1513 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1514
1515 msg.append("groupId=");
1516 msg.append(groupId);
1517
1518 msg.append(", privateLayout=");
1519 msg.append(privateLayout);
1520
1521 msg.append(StringPool.CLOSE_CURLY_BRACE);
1522
1523 throw new NoSuchLayoutSetBranchException(msg.toString());
1524 }
1525
1526
1535 public LayoutSetBranch fetchByG_P_Last(long groupId, boolean privateLayout,
1536 OrderByComparator orderByComparator) throws SystemException {
1537 int count = countByG_P(groupId, privateLayout);
1538
1539 List<LayoutSetBranch> list = findByG_P(groupId, privateLayout,
1540 count - 1, count, orderByComparator);
1541
1542 if (!list.isEmpty()) {
1543 return list.get(0);
1544 }
1545
1546 return null;
1547 }
1548
1549
1560 public LayoutSetBranch[] findByG_P_PrevAndNext(long layoutSetBranchId,
1561 long groupId, boolean privateLayout, OrderByComparator orderByComparator)
1562 throws NoSuchLayoutSetBranchException, SystemException {
1563 LayoutSetBranch layoutSetBranch = findByPrimaryKey(layoutSetBranchId);
1564
1565 Session session = null;
1566
1567 try {
1568 session = openSession();
1569
1570 LayoutSetBranch[] array = new LayoutSetBranchImpl[3];
1571
1572 array[0] = getByG_P_PrevAndNext(session, layoutSetBranch, groupId,
1573 privateLayout, orderByComparator, true);
1574
1575 array[1] = layoutSetBranch;
1576
1577 array[2] = getByG_P_PrevAndNext(session, layoutSetBranch, groupId,
1578 privateLayout, orderByComparator, false);
1579
1580 return array;
1581 }
1582 catch (Exception e) {
1583 throw processException(e);
1584 }
1585 finally {
1586 closeSession(session);
1587 }
1588 }
1589
1590 protected LayoutSetBranch getByG_P_PrevAndNext(Session session,
1591 LayoutSetBranch layoutSetBranch, long groupId, boolean privateLayout,
1592 OrderByComparator orderByComparator, boolean previous) {
1593 StringBundler query = null;
1594
1595 if (orderByComparator != null) {
1596 query = new StringBundler(6 +
1597 (orderByComparator.getOrderByFields().length * 6));
1598 }
1599 else {
1600 query = new StringBundler(3);
1601 }
1602
1603 query.append(_SQL_SELECT_LAYOUTSETBRANCH_WHERE);
1604
1605 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
1606
1607 query.append(_FINDER_COLUMN_G_P_PRIVATELAYOUT_2);
1608
1609 if (orderByComparator != null) {
1610 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1611
1612 if (orderByConditionFields.length > 0) {
1613 query.append(WHERE_AND);
1614 }
1615
1616 for (int i = 0; i < orderByConditionFields.length; i++) {
1617 query.append(_ORDER_BY_ENTITY_ALIAS);
1618 query.append(orderByConditionFields[i]);
1619
1620 if ((i + 1) < orderByConditionFields.length) {
1621 if (orderByComparator.isAscending() ^ previous) {
1622 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1623 }
1624 else {
1625 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1626 }
1627 }
1628 else {
1629 if (orderByComparator.isAscending() ^ previous) {
1630 query.append(WHERE_GREATER_THAN);
1631 }
1632 else {
1633 query.append(WHERE_LESSER_THAN);
1634 }
1635 }
1636 }
1637
1638 query.append(ORDER_BY_CLAUSE);
1639
1640 String[] orderByFields = orderByComparator.getOrderByFields();
1641
1642 for (int i = 0; i < orderByFields.length; i++) {
1643 query.append(_ORDER_BY_ENTITY_ALIAS);
1644 query.append(orderByFields[i]);
1645
1646 if ((i + 1) < orderByFields.length) {
1647 if (orderByComparator.isAscending() ^ previous) {
1648 query.append(ORDER_BY_ASC_HAS_NEXT);
1649 }
1650 else {
1651 query.append(ORDER_BY_DESC_HAS_NEXT);
1652 }
1653 }
1654 else {
1655 if (orderByComparator.isAscending() ^ previous) {
1656 query.append(ORDER_BY_ASC);
1657 }
1658 else {
1659 query.append(ORDER_BY_DESC);
1660 }
1661 }
1662 }
1663 }
1664
1665 else {
1666 query.append(LayoutSetBranchModelImpl.ORDER_BY_JPQL);
1667 }
1668
1669 String sql = query.toString();
1670
1671 Query q = session.createQuery(sql);
1672
1673 q.setFirstResult(0);
1674 q.setMaxResults(2);
1675
1676 QueryPos qPos = QueryPos.getInstance(q);
1677
1678 qPos.add(groupId);
1679
1680 qPos.add(privateLayout);
1681
1682 if (orderByComparator != null) {
1683 Object[] values = orderByComparator.getOrderByConditionValues(layoutSetBranch);
1684
1685 for (Object value : values) {
1686 qPos.add(value);
1687 }
1688 }
1689
1690 List<LayoutSetBranch> list = q.list();
1691
1692 if (list.size() == 2) {
1693 return list.get(1);
1694 }
1695 else {
1696 return null;
1697 }
1698 }
1699
1700
1708 public List<LayoutSetBranch> filterFindByG_P(long groupId,
1709 boolean privateLayout) throws SystemException {
1710 return filterFindByG_P(groupId, privateLayout, QueryUtil.ALL_POS,
1711 QueryUtil.ALL_POS, null);
1712 }
1713
1714
1728 public List<LayoutSetBranch> filterFindByG_P(long groupId,
1729 boolean privateLayout, int start, int end) throws SystemException {
1730 return filterFindByG_P(groupId, privateLayout, start, end, null);
1731 }
1732
1733
1748 public List<LayoutSetBranch> filterFindByG_P(long groupId,
1749 boolean privateLayout, int start, int end,
1750 OrderByComparator orderByComparator) throws SystemException {
1751 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1752 return findByG_P(groupId, privateLayout, start, end,
1753 orderByComparator);
1754 }
1755
1756 StringBundler query = null;
1757
1758 if (orderByComparator != null) {
1759 query = new StringBundler(4 +
1760 (orderByComparator.getOrderByFields().length * 3));
1761 }
1762 else {
1763 query = new StringBundler(4);
1764 }
1765
1766 if (getDB().isSupportsInlineDistinct()) {
1767 query.append(_FILTER_SQL_SELECT_LAYOUTSETBRANCH_WHERE);
1768 }
1769 else {
1770 query.append(_FILTER_SQL_SELECT_LAYOUTSETBRANCH_NO_INLINE_DISTINCT_WHERE_1);
1771 }
1772
1773 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
1774
1775 query.append(_FINDER_COLUMN_G_P_PRIVATELAYOUT_2);
1776
1777 if (!getDB().isSupportsInlineDistinct()) {
1778 query.append(_FILTER_SQL_SELECT_LAYOUTSETBRANCH_NO_INLINE_DISTINCT_WHERE_2);
1779 }
1780
1781 if (orderByComparator != null) {
1782 if (getDB().isSupportsInlineDistinct()) {
1783 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1784 orderByComparator);
1785 }
1786 else {
1787 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
1788 orderByComparator);
1789 }
1790 }
1791
1792 else {
1793 if (getDB().isSupportsInlineDistinct()) {
1794 query.append(LayoutSetBranchModelImpl.ORDER_BY_JPQL);
1795 }
1796 else {
1797 query.append(LayoutSetBranchModelImpl.ORDER_BY_SQL);
1798 }
1799 }
1800
1801 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1802 LayoutSetBranch.class.getName(),
1803 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
1804
1805 Session session = null;
1806
1807 try {
1808 session = openSession();
1809
1810 SQLQuery q = session.createSQLQuery(sql);
1811
1812 if (getDB().isSupportsInlineDistinct()) {
1813 q.addEntity(_FILTER_ENTITY_ALIAS, LayoutSetBranchImpl.class);
1814 }
1815 else {
1816 q.addEntity(_FILTER_ENTITY_TABLE, LayoutSetBranchImpl.class);
1817 }
1818
1819 QueryPos qPos = QueryPos.getInstance(q);
1820
1821 qPos.add(groupId);
1822
1823 qPos.add(privateLayout);
1824
1825 return (List<LayoutSetBranch>)QueryUtil.list(q, getDialect(),
1826 start, end);
1827 }
1828 catch (Exception e) {
1829 throw processException(e);
1830 }
1831 finally {
1832 closeSession(session);
1833 }
1834 }
1835
1836
1847 public LayoutSetBranch[] filterFindByG_P_PrevAndNext(
1848 long layoutSetBranchId, long groupId, boolean privateLayout,
1849 OrderByComparator orderByComparator)
1850 throws NoSuchLayoutSetBranchException, SystemException {
1851 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1852 return findByG_P_PrevAndNext(layoutSetBranchId, groupId,
1853 privateLayout, orderByComparator);
1854 }
1855
1856 LayoutSetBranch layoutSetBranch = findByPrimaryKey(layoutSetBranchId);
1857
1858 Session session = null;
1859
1860 try {
1861 session = openSession();
1862
1863 LayoutSetBranch[] array = new LayoutSetBranchImpl[3];
1864
1865 array[0] = filterGetByG_P_PrevAndNext(session, layoutSetBranch,
1866 groupId, privateLayout, orderByComparator, true);
1867
1868 array[1] = layoutSetBranch;
1869
1870 array[2] = filterGetByG_P_PrevAndNext(session, layoutSetBranch,
1871 groupId, privateLayout, orderByComparator, false);
1872
1873 return array;
1874 }
1875 catch (Exception e) {
1876 throw processException(e);
1877 }
1878 finally {
1879 closeSession(session);
1880 }
1881 }
1882
1883 protected LayoutSetBranch filterGetByG_P_PrevAndNext(Session session,
1884 LayoutSetBranch layoutSetBranch, long groupId, boolean privateLayout,
1885 OrderByComparator orderByComparator, boolean previous) {
1886 StringBundler query = null;
1887
1888 if (orderByComparator != null) {
1889 query = new StringBundler(6 +
1890 (orderByComparator.getOrderByFields().length * 6));
1891 }
1892 else {
1893 query = new StringBundler(3);
1894 }
1895
1896 if (getDB().isSupportsInlineDistinct()) {
1897 query.append(_FILTER_SQL_SELECT_LAYOUTSETBRANCH_WHERE);
1898 }
1899 else {
1900 query.append(_FILTER_SQL_SELECT_LAYOUTSETBRANCH_NO_INLINE_DISTINCT_WHERE_1);
1901 }
1902
1903 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
1904
1905 query.append(_FINDER_COLUMN_G_P_PRIVATELAYOUT_2);
1906
1907 if (!getDB().isSupportsInlineDistinct()) {
1908 query.append(_FILTER_SQL_SELECT_LAYOUTSETBRANCH_NO_INLINE_DISTINCT_WHERE_2);
1909 }
1910
1911 if (orderByComparator != null) {
1912 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1913
1914 if (orderByConditionFields.length > 0) {
1915 query.append(WHERE_AND);
1916 }
1917
1918 for (int i = 0; i < orderByConditionFields.length; i++) {
1919 if (getDB().isSupportsInlineDistinct()) {
1920 query.append(_ORDER_BY_ENTITY_ALIAS);
1921 }
1922 else {
1923 query.append(_ORDER_BY_ENTITY_TABLE);
1924 }
1925
1926 query.append(orderByConditionFields[i]);
1927
1928 if ((i + 1) < orderByConditionFields.length) {
1929 if (orderByComparator.isAscending() ^ previous) {
1930 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1931 }
1932 else {
1933 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1934 }
1935 }
1936 else {
1937 if (orderByComparator.isAscending() ^ previous) {
1938 query.append(WHERE_GREATER_THAN);
1939 }
1940 else {
1941 query.append(WHERE_LESSER_THAN);
1942 }
1943 }
1944 }
1945
1946 query.append(ORDER_BY_CLAUSE);
1947
1948 String[] orderByFields = orderByComparator.getOrderByFields();
1949
1950 for (int i = 0; i < orderByFields.length; i++) {
1951 if (getDB().isSupportsInlineDistinct()) {
1952 query.append(_ORDER_BY_ENTITY_ALIAS);
1953 }
1954 else {
1955 query.append(_ORDER_BY_ENTITY_TABLE);
1956 }
1957
1958 query.append(orderByFields[i]);
1959
1960 if ((i + 1) < orderByFields.length) {
1961 if (orderByComparator.isAscending() ^ previous) {
1962 query.append(ORDER_BY_ASC_HAS_NEXT);
1963 }
1964 else {
1965 query.append(ORDER_BY_DESC_HAS_NEXT);
1966 }
1967 }
1968 else {
1969 if (orderByComparator.isAscending() ^ previous) {
1970 query.append(ORDER_BY_ASC);
1971 }
1972 else {
1973 query.append(ORDER_BY_DESC);
1974 }
1975 }
1976 }
1977 }
1978
1979 else {
1980 if (getDB().isSupportsInlineDistinct()) {
1981 query.append(LayoutSetBranchModelImpl.ORDER_BY_JPQL);
1982 }
1983 else {
1984 query.append(LayoutSetBranchModelImpl.ORDER_BY_SQL);
1985 }
1986 }
1987
1988 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1989 LayoutSetBranch.class.getName(),
1990 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
1991
1992 SQLQuery q = session.createSQLQuery(sql);
1993
1994 q.setFirstResult(0);
1995 q.setMaxResults(2);
1996
1997 if (getDB().isSupportsInlineDistinct()) {
1998 q.addEntity(_FILTER_ENTITY_ALIAS, LayoutSetBranchImpl.class);
1999 }
2000 else {
2001 q.addEntity(_FILTER_ENTITY_TABLE, LayoutSetBranchImpl.class);
2002 }
2003
2004 QueryPos qPos = QueryPos.getInstance(q);
2005
2006 qPos.add(groupId);
2007
2008 qPos.add(privateLayout);
2009
2010 if (orderByComparator != null) {
2011 Object[] values = orderByComparator.getOrderByConditionValues(layoutSetBranch);
2012
2013 for (Object value : values) {
2014 qPos.add(value);
2015 }
2016 }
2017
2018 List<LayoutSetBranch> list = q.list();
2019
2020 if (list.size() == 2) {
2021 return list.get(1);
2022 }
2023 else {
2024 return null;
2025 }
2026 }
2027
2028
2038 public LayoutSetBranch findByG_P_N(long groupId, boolean privateLayout,
2039 String name) throws NoSuchLayoutSetBranchException, SystemException {
2040 LayoutSetBranch layoutSetBranch = fetchByG_P_N(groupId, privateLayout,
2041 name);
2042
2043 if (layoutSetBranch == null) {
2044 StringBundler msg = new StringBundler(8);
2045
2046 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2047
2048 msg.append("groupId=");
2049 msg.append(groupId);
2050
2051 msg.append(", privateLayout=");
2052 msg.append(privateLayout);
2053
2054 msg.append(", name=");
2055 msg.append(name);
2056
2057 msg.append(StringPool.CLOSE_CURLY_BRACE);
2058
2059 if (_log.isWarnEnabled()) {
2060 _log.warn(msg.toString());
2061 }
2062
2063 throw new NoSuchLayoutSetBranchException(msg.toString());
2064 }
2065
2066 return layoutSetBranch;
2067 }
2068
2069
2078 public LayoutSetBranch fetchByG_P_N(long groupId, boolean privateLayout,
2079 String name) throws SystemException {
2080 return fetchByG_P_N(groupId, privateLayout, name, true);
2081 }
2082
2083
2093 public LayoutSetBranch fetchByG_P_N(long groupId, boolean privateLayout,
2094 String name, boolean retrieveFromCache) throws SystemException {
2095 Object[] finderArgs = new Object[] { groupId, privateLayout, name };
2096
2097 Object result = null;
2098
2099 if (retrieveFromCache) {
2100 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_P_N,
2101 finderArgs, this);
2102 }
2103
2104 if (result instanceof LayoutSetBranch) {
2105 LayoutSetBranch layoutSetBranch = (LayoutSetBranch)result;
2106
2107 if ((groupId != layoutSetBranch.getGroupId()) ||
2108 (privateLayout != layoutSetBranch.getPrivateLayout()) ||
2109 !Validator.equals(name, layoutSetBranch.getName())) {
2110 result = null;
2111 }
2112 }
2113
2114 if (result == null) {
2115 StringBundler query = new StringBundler(5);
2116
2117 query.append(_SQL_SELECT_LAYOUTSETBRANCH_WHERE);
2118
2119 query.append(_FINDER_COLUMN_G_P_N_GROUPID_2);
2120
2121 query.append(_FINDER_COLUMN_G_P_N_PRIVATELAYOUT_2);
2122
2123 if (name == null) {
2124 query.append(_FINDER_COLUMN_G_P_N_NAME_1);
2125 }
2126 else {
2127 if (name.equals(StringPool.BLANK)) {
2128 query.append(_FINDER_COLUMN_G_P_N_NAME_3);
2129 }
2130 else {
2131 query.append(_FINDER_COLUMN_G_P_N_NAME_2);
2132 }
2133 }
2134
2135 query.append(LayoutSetBranchModelImpl.ORDER_BY_JPQL);
2136
2137 String sql = query.toString();
2138
2139 Session session = null;
2140
2141 try {
2142 session = openSession();
2143
2144 Query q = session.createQuery(sql);
2145
2146 QueryPos qPos = QueryPos.getInstance(q);
2147
2148 qPos.add(groupId);
2149
2150 qPos.add(privateLayout);
2151
2152 if (name != null) {
2153 qPos.add(name);
2154 }
2155
2156 List<LayoutSetBranch> list = q.list();
2157
2158 result = list;
2159
2160 LayoutSetBranch layoutSetBranch = null;
2161
2162 if (list.isEmpty()) {
2163 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P_N,
2164 finderArgs, list);
2165 }
2166 else {
2167 layoutSetBranch = list.get(0);
2168
2169 cacheResult(layoutSetBranch);
2170
2171 if ((layoutSetBranch.getGroupId() != groupId) ||
2172 (layoutSetBranch.getPrivateLayout() != privateLayout) ||
2173 (layoutSetBranch.getName() == null) ||
2174 !layoutSetBranch.getName().equals(name)) {
2175 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P_N,
2176 finderArgs, layoutSetBranch);
2177 }
2178 }
2179
2180 return layoutSetBranch;
2181 }
2182 catch (Exception e) {
2183 throw processException(e);
2184 }
2185 finally {
2186 if (result == null) {
2187 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_P_N,
2188 finderArgs);
2189 }
2190
2191 closeSession(session);
2192 }
2193 }
2194 else {
2195 if (result instanceof List<?>) {
2196 return null;
2197 }
2198 else {
2199 return (LayoutSetBranch)result;
2200 }
2201 }
2202 }
2203
2204
2210 public List<LayoutSetBranch> findAll() throws SystemException {
2211 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2212 }
2213
2214
2226 public List<LayoutSetBranch> findAll(int start, int end)
2227 throws SystemException {
2228 return findAll(start, end, null);
2229 }
2230
2231
2244 public List<LayoutSetBranch> findAll(int start, int end,
2245 OrderByComparator orderByComparator) throws SystemException {
2246 FinderPath finderPath = null;
2247 Object[] finderArgs = new Object[] { start, end, orderByComparator };
2248
2249 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2250 (orderByComparator == null)) {
2251 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
2252 finderArgs = FINDER_ARGS_EMPTY;
2253 }
2254 else {
2255 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
2256 finderArgs = new Object[] { start, end, orderByComparator };
2257 }
2258
2259 List<LayoutSetBranch> list = (List<LayoutSetBranch>)FinderCacheUtil.getResult(finderPath,
2260 finderArgs, this);
2261
2262 if (list == null) {
2263 StringBundler query = null;
2264 String sql = null;
2265
2266 if (orderByComparator != null) {
2267 query = new StringBundler(2 +
2268 (orderByComparator.getOrderByFields().length * 3));
2269
2270 query.append(_SQL_SELECT_LAYOUTSETBRANCH);
2271
2272 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2273 orderByComparator);
2274
2275 sql = query.toString();
2276 }
2277 else {
2278 sql = _SQL_SELECT_LAYOUTSETBRANCH.concat(LayoutSetBranchModelImpl.ORDER_BY_JPQL);
2279 }
2280
2281 Session session = null;
2282
2283 try {
2284 session = openSession();
2285
2286 Query q = session.createQuery(sql);
2287
2288 if (orderByComparator == null) {
2289 list = (List<LayoutSetBranch>)QueryUtil.list(q,
2290 getDialect(), start, end, false);
2291
2292 Collections.sort(list);
2293 }
2294 else {
2295 list = (List<LayoutSetBranch>)QueryUtil.list(q,
2296 getDialect(), start, end);
2297 }
2298 }
2299 catch (Exception e) {
2300 throw processException(e);
2301 }
2302 finally {
2303 if (list == null) {
2304 FinderCacheUtil.removeResult(finderPath, finderArgs);
2305 }
2306 else {
2307 cacheResult(list);
2308
2309 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2310 }
2311
2312 closeSession(session);
2313 }
2314 }
2315
2316 return list;
2317 }
2318
2319
2325 public void removeByGroupId(long groupId) throws SystemException {
2326 for (LayoutSetBranch layoutSetBranch : findByGroupId(groupId)) {
2327 remove(layoutSetBranch);
2328 }
2329 }
2330
2331
2338 public void removeByG_P(long groupId, boolean privateLayout)
2339 throws SystemException {
2340 for (LayoutSetBranch layoutSetBranch : findByG_P(groupId, privateLayout)) {
2341 remove(layoutSetBranch);
2342 }
2343 }
2344
2345
2354 public LayoutSetBranch removeByG_P_N(long groupId, boolean privateLayout,
2355 String name) throws NoSuchLayoutSetBranchException, SystemException {
2356 LayoutSetBranch layoutSetBranch = findByG_P_N(groupId, privateLayout,
2357 name);
2358
2359 return remove(layoutSetBranch);
2360 }
2361
2362
2367 public void removeAll() throws SystemException {
2368 for (LayoutSetBranch layoutSetBranch : findAll()) {
2369 remove(layoutSetBranch);
2370 }
2371 }
2372
2373
2380 public int countByGroupId(long groupId) throws SystemException {
2381 Object[] finderArgs = new Object[] { groupId };
2382
2383 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
2384 finderArgs, this);
2385
2386 if (count == null) {
2387 StringBundler query = new StringBundler(2);
2388
2389 query.append(_SQL_COUNT_LAYOUTSETBRANCH_WHERE);
2390
2391 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2392
2393 String sql = query.toString();
2394
2395 Session session = null;
2396
2397 try {
2398 session = openSession();
2399
2400 Query q = session.createQuery(sql);
2401
2402 QueryPos qPos = QueryPos.getInstance(q);
2403
2404 qPos.add(groupId);
2405
2406 count = (Long)q.uniqueResult();
2407 }
2408 catch (Exception e) {
2409 throw processException(e);
2410 }
2411 finally {
2412 if (count == null) {
2413 count = Long.valueOf(0);
2414 }
2415
2416 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
2417 finderArgs, count);
2418
2419 closeSession(session);
2420 }
2421 }
2422
2423 return count.intValue();
2424 }
2425
2426
2433 public int filterCountByGroupId(long groupId) throws SystemException {
2434 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2435 return countByGroupId(groupId);
2436 }
2437
2438 StringBundler query = new StringBundler(2);
2439
2440 query.append(_FILTER_SQL_COUNT_LAYOUTSETBRANCH_WHERE);
2441
2442 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2443
2444 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2445 LayoutSetBranch.class.getName(),
2446 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2447
2448 Session session = null;
2449
2450 try {
2451 session = openSession();
2452
2453 SQLQuery q = session.createSQLQuery(sql);
2454
2455 q.addScalar(COUNT_COLUMN_NAME,
2456 com.liferay.portal.kernel.dao.orm.Type.LONG);
2457
2458 QueryPos qPos = QueryPos.getInstance(q);
2459
2460 qPos.add(groupId);
2461
2462 Long count = (Long)q.uniqueResult();
2463
2464 return count.intValue();
2465 }
2466 catch (Exception e) {
2467 throw processException(e);
2468 }
2469 finally {
2470 closeSession(session);
2471 }
2472 }
2473
2474
2482 public int countByG_P(long groupId, boolean privateLayout)
2483 throws SystemException {
2484 Object[] finderArgs = new Object[] { groupId, privateLayout };
2485
2486 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_P,
2487 finderArgs, this);
2488
2489 if (count == null) {
2490 StringBundler query = new StringBundler(3);
2491
2492 query.append(_SQL_COUNT_LAYOUTSETBRANCH_WHERE);
2493
2494 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
2495
2496 query.append(_FINDER_COLUMN_G_P_PRIVATELAYOUT_2);
2497
2498 String sql = query.toString();
2499
2500 Session session = null;
2501
2502 try {
2503 session = openSession();
2504
2505 Query q = session.createQuery(sql);
2506
2507 QueryPos qPos = QueryPos.getInstance(q);
2508
2509 qPos.add(groupId);
2510
2511 qPos.add(privateLayout);
2512
2513 count = (Long)q.uniqueResult();
2514 }
2515 catch (Exception e) {
2516 throw processException(e);
2517 }
2518 finally {
2519 if (count == null) {
2520 count = Long.valueOf(0);
2521 }
2522
2523 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_P, finderArgs,
2524 count);
2525
2526 closeSession(session);
2527 }
2528 }
2529
2530 return count.intValue();
2531 }
2532
2533
2541 public int filterCountByG_P(long groupId, boolean privateLayout)
2542 throws SystemException {
2543 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2544 return countByG_P(groupId, privateLayout);
2545 }
2546
2547 StringBundler query = new StringBundler(3);
2548
2549 query.append(_FILTER_SQL_COUNT_LAYOUTSETBRANCH_WHERE);
2550
2551 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
2552
2553 query.append(_FINDER_COLUMN_G_P_PRIVATELAYOUT_2);
2554
2555 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2556 LayoutSetBranch.class.getName(),
2557 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2558
2559 Session session = null;
2560
2561 try {
2562 session = openSession();
2563
2564 SQLQuery q = session.createSQLQuery(sql);
2565
2566 q.addScalar(COUNT_COLUMN_NAME,
2567 com.liferay.portal.kernel.dao.orm.Type.LONG);
2568
2569 QueryPos qPos = QueryPos.getInstance(q);
2570
2571 qPos.add(groupId);
2572
2573 qPos.add(privateLayout);
2574
2575 Long count = (Long)q.uniqueResult();
2576
2577 return count.intValue();
2578 }
2579 catch (Exception e) {
2580 throw processException(e);
2581 }
2582 finally {
2583 closeSession(session);
2584 }
2585 }
2586
2587
2596 public int countByG_P_N(long groupId, boolean privateLayout, String name)
2597 throws SystemException {
2598 Object[] finderArgs = new Object[] { groupId, privateLayout, name };
2599
2600 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_P_N,
2601 finderArgs, this);
2602
2603 if (count == null) {
2604 StringBundler query = new StringBundler(4);
2605
2606 query.append(_SQL_COUNT_LAYOUTSETBRANCH_WHERE);
2607
2608 query.append(_FINDER_COLUMN_G_P_N_GROUPID_2);
2609
2610 query.append(_FINDER_COLUMN_G_P_N_PRIVATELAYOUT_2);
2611
2612 if (name == null) {
2613 query.append(_FINDER_COLUMN_G_P_N_NAME_1);
2614 }
2615 else {
2616 if (name.equals(StringPool.BLANK)) {
2617 query.append(_FINDER_COLUMN_G_P_N_NAME_3);
2618 }
2619 else {
2620 query.append(_FINDER_COLUMN_G_P_N_NAME_2);
2621 }
2622 }
2623
2624 String sql = query.toString();
2625
2626 Session session = null;
2627
2628 try {
2629 session = openSession();
2630
2631 Query q = session.createQuery(sql);
2632
2633 QueryPos qPos = QueryPos.getInstance(q);
2634
2635 qPos.add(groupId);
2636
2637 qPos.add(privateLayout);
2638
2639 if (name != null) {
2640 qPos.add(name);
2641 }
2642
2643 count = (Long)q.uniqueResult();
2644 }
2645 catch (Exception e) {
2646 throw processException(e);
2647 }
2648 finally {
2649 if (count == null) {
2650 count = Long.valueOf(0);
2651 }
2652
2653 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_P_N,
2654 finderArgs, count);
2655
2656 closeSession(session);
2657 }
2658 }
2659
2660 return count.intValue();
2661 }
2662
2663
2669 public int countAll() throws SystemException {
2670 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
2671 FINDER_ARGS_EMPTY, this);
2672
2673 if (count == null) {
2674 Session session = null;
2675
2676 try {
2677 session = openSession();
2678
2679 Query q = session.createQuery(_SQL_COUNT_LAYOUTSETBRANCH);
2680
2681 count = (Long)q.uniqueResult();
2682 }
2683 catch (Exception e) {
2684 throw processException(e);
2685 }
2686 finally {
2687 if (count == null) {
2688 count = Long.valueOf(0);
2689 }
2690
2691 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
2692 FINDER_ARGS_EMPTY, count);
2693
2694 closeSession(session);
2695 }
2696 }
2697
2698 return count.intValue();
2699 }
2700
2701
2704 public void afterPropertiesSet() {
2705 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
2706 com.liferay.portal.util.PropsUtil.get(
2707 "value.object.listener.com.liferay.portal.model.LayoutSetBranch")));
2708
2709 if (listenerClassNames.length > 0) {
2710 try {
2711 List<ModelListener<LayoutSetBranch>> listenersList = new ArrayList<ModelListener<LayoutSetBranch>>();
2712
2713 for (String listenerClassName : listenerClassNames) {
2714 listenersList.add((ModelListener<LayoutSetBranch>)InstanceFactory.newInstance(
2715 listenerClassName));
2716 }
2717
2718 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
2719 }
2720 catch (Exception e) {
2721 _log.error(e);
2722 }
2723 }
2724 }
2725
2726 public void destroy() {
2727 EntityCacheUtil.removeCache(LayoutSetBranchImpl.class.getName());
2728 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
2729 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2730 }
2731
2732 @BeanReference(type = AccountPersistence.class)
2733 protected AccountPersistence accountPersistence;
2734 @BeanReference(type = AddressPersistence.class)
2735 protected AddressPersistence addressPersistence;
2736 @BeanReference(type = BrowserTrackerPersistence.class)
2737 protected BrowserTrackerPersistence browserTrackerPersistence;
2738 @BeanReference(type = ClassNamePersistence.class)
2739 protected ClassNamePersistence classNamePersistence;
2740 @BeanReference(type = ClusterGroupPersistence.class)
2741 protected ClusterGroupPersistence clusterGroupPersistence;
2742 @BeanReference(type = CompanyPersistence.class)
2743 protected CompanyPersistence companyPersistence;
2744 @BeanReference(type = ContactPersistence.class)
2745 protected ContactPersistence contactPersistence;
2746 @BeanReference(type = CountryPersistence.class)
2747 protected CountryPersistence countryPersistence;
2748 @BeanReference(type = EmailAddressPersistence.class)
2749 protected EmailAddressPersistence emailAddressPersistence;
2750 @BeanReference(type = GroupPersistence.class)
2751 protected GroupPersistence groupPersistence;
2752 @BeanReference(type = ImagePersistence.class)
2753 protected ImagePersistence imagePersistence;
2754 @BeanReference(type = LayoutPersistence.class)
2755 protected LayoutPersistence layoutPersistence;
2756 @BeanReference(type = LayoutBranchPersistence.class)
2757 protected LayoutBranchPersistence layoutBranchPersistence;
2758 @BeanReference(type = LayoutPrototypePersistence.class)
2759 protected LayoutPrototypePersistence layoutPrototypePersistence;
2760 @BeanReference(type = LayoutRevisionPersistence.class)
2761 protected LayoutRevisionPersistence layoutRevisionPersistence;
2762 @BeanReference(type = LayoutSetPersistence.class)
2763 protected LayoutSetPersistence layoutSetPersistence;
2764 @BeanReference(type = LayoutSetBranchPersistence.class)
2765 protected LayoutSetBranchPersistence layoutSetBranchPersistence;
2766 @BeanReference(type = LayoutSetPrototypePersistence.class)
2767 protected LayoutSetPrototypePersistence layoutSetPrototypePersistence;
2768 @BeanReference(type = ListTypePersistence.class)
2769 protected ListTypePersistence listTypePersistence;
2770 @BeanReference(type = LockPersistence.class)
2771 protected LockPersistence lockPersistence;
2772 @BeanReference(type = MembershipRequestPersistence.class)
2773 protected MembershipRequestPersistence membershipRequestPersistence;
2774 @BeanReference(type = OrganizationPersistence.class)
2775 protected OrganizationPersistence organizationPersistence;
2776 @BeanReference(type = OrgGroupPermissionPersistence.class)
2777 protected OrgGroupPermissionPersistence orgGroupPermissionPersistence;
2778 @BeanReference(type = OrgGroupRolePersistence.class)
2779 protected OrgGroupRolePersistence orgGroupRolePersistence;
2780 @BeanReference(type = OrgLaborPersistence.class)
2781 protected OrgLaborPersistence orgLaborPersistence;
2782 @BeanReference(type = PasswordPolicyPersistence.class)
2783 protected PasswordPolicyPersistence passwordPolicyPersistence;
2784 @BeanReference(type = PasswordPolicyRelPersistence.class)
2785 protected PasswordPolicyRelPersistence passwordPolicyRelPersistence;
2786 @BeanReference(type = PasswordTrackerPersistence.class)
2787 protected PasswordTrackerPersistence passwordTrackerPersistence;
2788 @BeanReference(type = PermissionPersistence.class)
2789 protected PermissionPersistence permissionPersistence;
2790 @BeanReference(type = PhonePersistence.class)
2791 protected PhonePersistence phonePersistence;
2792 @BeanReference(type = PluginSettingPersistence.class)
2793 protected PluginSettingPersistence pluginSettingPersistence;
2794 @BeanReference(type = PortalPreferencesPersistence.class)
2795 protected PortalPreferencesPersistence portalPreferencesPersistence;
2796 @BeanReference(type = PortletPersistence.class)
2797 protected PortletPersistence portletPersistence;
2798 @BeanReference(type = PortletItemPersistence.class)
2799 protected PortletItemPersistence portletItemPersistence;
2800 @BeanReference(type = PortletPreferencesPersistence.class)
2801 protected PortletPreferencesPersistence portletPreferencesPersistence;
2802 @BeanReference(type = RegionPersistence.class)
2803 protected RegionPersistence regionPersistence;
2804 @BeanReference(type = ReleasePersistence.class)
2805 protected ReleasePersistence releasePersistence;
2806 @BeanReference(type = RepositoryPersistence.class)
2807 protected RepositoryPersistence repositoryPersistence;
2808 @BeanReference(type = RepositoryEntryPersistence.class)
2809 protected RepositoryEntryPersistence repositoryEntryPersistence;
2810 @BeanReference(type = ResourcePersistence.class)
2811 protected ResourcePersistence resourcePersistence;
2812 @BeanReference(type = ResourceActionPersistence.class)
2813 protected ResourceActionPersistence resourceActionPersistence;
2814 @BeanReference(type = ResourceBlockPersistence.class)
2815 protected ResourceBlockPersistence resourceBlockPersistence;
2816 @BeanReference(type = ResourceBlockPermissionPersistence.class)
2817 protected ResourceBlockPermissionPersistence resourceBlockPermissionPersistence;
2818 @BeanReference(type = ResourceCodePersistence.class)
2819 protected ResourceCodePersistence resourceCodePersistence;
2820 @BeanReference(type = ResourcePermissionPersistence.class)
2821 protected ResourcePermissionPersistence resourcePermissionPersistence;
2822 @BeanReference(type = ResourceTypePermissionPersistence.class)
2823 protected ResourceTypePermissionPersistence resourceTypePermissionPersistence;
2824 @BeanReference(type = RolePersistence.class)
2825 protected RolePersistence rolePersistence;
2826 @BeanReference(type = ServiceComponentPersistence.class)
2827 protected ServiceComponentPersistence serviceComponentPersistence;
2828 @BeanReference(type = ShardPersistence.class)
2829 protected ShardPersistence shardPersistence;
2830 @BeanReference(type = SubscriptionPersistence.class)
2831 protected SubscriptionPersistence subscriptionPersistence;
2832 @BeanReference(type = TeamPersistence.class)
2833 protected TeamPersistence teamPersistence;
2834 @BeanReference(type = TicketPersistence.class)
2835 protected TicketPersistence ticketPersistence;
2836 @BeanReference(type = UserPersistence.class)
2837 protected UserPersistence userPersistence;
2838 @BeanReference(type = UserGroupPersistence.class)
2839 protected UserGroupPersistence userGroupPersistence;
2840 @BeanReference(type = UserGroupGroupRolePersistence.class)
2841 protected UserGroupGroupRolePersistence userGroupGroupRolePersistence;
2842 @BeanReference(type = UserGroupRolePersistence.class)
2843 protected UserGroupRolePersistence userGroupRolePersistence;
2844 @BeanReference(type = UserIdMapperPersistence.class)
2845 protected UserIdMapperPersistence userIdMapperPersistence;
2846 @BeanReference(type = UserNotificationEventPersistence.class)
2847 protected UserNotificationEventPersistence userNotificationEventPersistence;
2848 @BeanReference(type = UserTrackerPersistence.class)
2849 protected UserTrackerPersistence userTrackerPersistence;
2850 @BeanReference(type = UserTrackerPathPersistence.class)
2851 protected UserTrackerPathPersistence userTrackerPathPersistence;
2852 @BeanReference(type = VirtualHostPersistence.class)
2853 protected VirtualHostPersistence virtualHostPersistence;
2854 @BeanReference(type = WebDAVPropsPersistence.class)
2855 protected WebDAVPropsPersistence webDAVPropsPersistence;
2856 @BeanReference(type = WebsitePersistence.class)
2857 protected WebsitePersistence websitePersistence;
2858 @BeanReference(type = WorkflowDefinitionLinkPersistence.class)
2859 protected WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
2860 @BeanReference(type = WorkflowInstanceLinkPersistence.class)
2861 protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
2862 private static final String _SQL_SELECT_LAYOUTSETBRANCH = "SELECT layoutSetBranch FROM LayoutSetBranch layoutSetBranch";
2863 private static final String _SQL_SELECT_LAYOUTSETBRANCH_WHERE = "SELECT layoutSetBranch FROM LayoutSetBranch layoutSetBranch WHERE ";
2864 private static final String _SQL_COUNT_LAYOUTSETBRANCH = "SELECT COUNT(layoutSetBranch) FROM LayoutSetBranch layoutSetBranch";
2865 private static final String _SQL_COUNT_LAYOUTSETBRANCH_WHERE = "SELECT COUNT(layoutSetBranch) FROM LayoutSetBranch layoutSetBranch WHERE ";
2866 private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "layoutSetBranch.groupId = ?";
2867 private static final String _FINDER_COLUMN_G_P_GROUPID_2 = "layoutSetBranch.groupId = ? AND ";
2868 private static final String _FINDER_COLUMN_G_P_PRIVATELAYOUT_2 = "layoutSetBranch.privateLayout = ?";
2869 private static final String _FINDER_COLUMN_G_P_N_GROUPID_2 = "layoutSetBranch.groupId = ? AND ";
2870 private static final String _FINDER_COLUMN_G_P_N_PRIVATELAYOUT_2 = "layoutSetBranch.privateLayout = ? AND ";
2871 private static final String _FINDER_COLUMN_G_P_N_NAME_1 = "layoutSetBranch.name IS NULL";
2872 private static final String _FINDER_COLUMN_G_P_N_NAME_2 = "layoutSetBranch.name = ?";
2873 private static final String _FINDER_COLUMN_G_P_N_NAME_3 = "(layoutSetBranch.name IS NULL OR layoutSetBranch.name = ?)";
2874 private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "layoutSetBranch.layoutSetBranchId";
2875 private static final String _FILTER_SQL_SELECT_LAYOUTSETBRANCH_WHERE = "SELECT DISTINCT {layoutSetBranch.*} FROM LayoutSetBranch layoutSetBranch WHERE ";
2876 private static final String _FILTER_SQL_SELECT_LAYOUTSETBRANCH_NO_INLINE_DISTINCT_WHERE_1 =
2877 "SELECT {LayoutSetBranch.*} FROM (SELECT DISTINCT layoutSetBranch.layoutSetBranchId FROM LayoutSetBranch layoutSetBranch WHERE ";
2878 private static final String _FILTER_SQL_SELECT_LAYOUTSETBRANCH_NO_INLINE_DISTINCT_WHERE_2 =
2879 ") TEMP_TABLE INNER JOIN LayoutSetBranch ON TEMP_TABLE.layoutSetBranchId = LayoutSetBranch.layoutSetBranchId";
2880 private static final String _FILTER_SQL_COUNT_LAYOUTSETBRANCH_WHERE = "SELECT COUNT(DISTINCT layoutSetBranch.layoutSetBranchId) AS COUNT_VALUE FROM LayoutSetBranch layoutSetBranch WHERE ";
2881 private static final String _FILTER_ENTITY_ALIAS = "layoutSetBranch";
2882 private static final String _FILTER_ENTITY_TABLE = "LayoutSetBranch";
2883 private static final String _ORDER_BY_ENTITY_ALIAS = "layoutSetBranch.";
2884 private static final String _ORDER_BY_ENTITY_TABLE = "LayoutSetBranch.";
2885 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No LayoutSetBranch exists with the primary key ";
2886 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No LayoutSetBranch exists with the key {";
2887 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
2888 private static Log _log = LogFactoryUtil.getLog(LayoutSetBranchPersistenceImpl.class);
2889 private static LayoutSetBranch _nullLayoutSetBranch = new LayoutSetBranchImpl() {
2890 @Override
2891 public Object clone() {
2892 return this;
2893 }
2894
2895 @Override
2896 public CacheModel<LayoutSetBranch> toCacheModel() {
2897 return _nullLayoutSetBranchCacheModel;
2898 }
2899 };
2900
2901 private static CacheModel<LayoutSetBranch> _nullLayoutSetBranchCacheModel = new CacheModel<LayoutSetBranch>() {
2902 public LayoutSetBranch toEntityModel() {
2903 return _nullLayoutSetBranch;
2904 }
2905 };
2906 }