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 if (layoutSetBranch.isCachedModel()) {
330 layoutSetBranch = (LayoutSetBranch)session.get(LayoutSetBranchImpl.class,
331 layoutSetBranch.getPrimaryKeyObj());
332 }
333
334 session.delete(layoutSetBranch);
335 }
336 catch (Exception e) {
337 throw processException(e);
338 }
339 finally {
340 closeSession(session);
341 }
342
343 clearCache(layoutSetBranch);
344
345 return layoutSetBranch;
346 }
347
348 @Override
349 public LayoutSetBranch updateImpl(
350 com.liferay.portal.model.LayoutSetBranch layoutSetBranch)
351 throws SystemException {
352 layoutSetBranch = toUnwrappedModel(layoutSetBranch);
353
354 boolean isNew = layoutSetBranch.isNew();
355
356 LayoutSetBranchModelImpl layoutSetBranchModelImpl = (LayoutSetBranchModelImpl)layoutSetBranch;
357
358 Session session = null;
359
360 try {
361 session = openSession();
362
363 if (layoutSetBranch.isNew()) {
364 session.save(layoutSetBranch);
365
366 layoutSetBranch.setNew(false);
367 }
368 else {
369 session.merge(layoutSetBranch);
370 }
371 }
372 catch (Exception e) {
373 throw processException(e);
374 }
375 finally {
376 closeSession(session);
377 }
378
379 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
380
381 if (isNew || !LayoutSetBranchModelImpl.COLUMN_BITMASK_ENABLED) {
382 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
383 }
384
385 else {
386 if ((layoutSetBranchModelImpl.getColumnBitmask() &
387 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
388 Object[] args = new Object[] {
389 Long.valueOf(layoutSetBranchModelImpl.getOriginalGroupId())
390 };
391
392 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
393 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
394 args);
395
396 args = new Object[] {
397 Long.valueOf(layoutSetBranchModelImpl.getGroupId())
398 };
399
400 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
401 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
402 args);
403 }
404
405 if ((layoutSetBranchModelImpl.getColumnBitmask() &
406 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P.getColumnBitmask()) != 0) {
407 Object[] args = new Object[] {
408 Long.valueOf(layoutSetBranchModelImpl.getOriginalGroupId()),
409 Boolean.valueOf(layoutSetBranchModelImpl.getOriginalPrivateLayout())
410 };
411
412 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P, args);
413 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P,
414 args);
415
416 args = new Object[] {
417 Long.valueOf(layoutSetBranchModelImpl.getGroupId()),
418 Boolean.valueOf(layoutSetBranchModelImpl.getPrivateLayout())
419 };
420
421 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P, args);
422 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P,
423 args);
424 }
425 }
426
427 EntityCacheUtil.putResult(LayoutSetBranchModelImpl.ENTITY_CACHE_ENABLED,
428 LayoutSetBranchImpl.class, layoutSetBranch.getPrimaryKey(),
429 layoutSetBranch);
430
431 if (isNew) {
432 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P_N,
433 new Object[] {
434 Long.valueOf(layoutSetBranch.getGroupId()),
435 Boolean.valueOf(layoutSetBranch.getPrivateLayout()),
436
437 layoutSetBranch.getName()
438 }, layoutSetBranch);
439 }
440 else {
441 if ((layoutSetBranchModelImpl.getColumnBitmask() &
442 FINDER_PATH_FETCH_BY_G_P_N.getColumnBitmask()) != 0) {
443 Object[] args = new Object[] {
444 Long.valueOf(layoutSetBranchModelImpl.getOriginalGroupId()),
445 Boolean.valueOf(layoutSetBranchModelImpl.getOriginalPrivateLayout()),
446
447 layoutSetBranchModelImpl.getOriginalName()
448 };
449
450 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P_N, args);
451
452 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_P_N, args);
453
454 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P_N,
455 new Object[] {
456 Long.valueOf(layoutSetBranch.getGroupId()),
457 Boolean.valueOf(layoutSetBranch.getPrivateLayout()),
458
459 layoutSetBranch.getName()
460 }, layoutSetBranch);
461 }
462 }
463
464 return layoutSetBranch;
465 }
466
467 protected LayoutSetBranch toUnwrappedModel(LayoutSetBranch layoutSetBranch) {
468 if (layoutSetBranch instanceof LayoutSetBranchImpl) {
469 return layoutSetBranch;
470 }
471
472 LayoutSetBranchImpl layoutSetBranchImpl = new LayoutSetBranchImpl();
473
474 layoutSetBranchImpl.setNew(layoutSetBranch.isNew());
475 layoutSetBranchImpl.setPrimaryKey(layoutSetBranch.getPrimaryKey());
476
477 layoutSetBranchImpl.setLayoutSetBranchId(layoutSetBranch.getLayoutSetBranchId());
478 layoutSetBranchImpl.setGroupId(layoutSetBranch.getGroupId());
479 layoutSetBranchImpl.setCompanyId(layoutSetBranch.getCompanyId());
480 layoutSetBranchImpl.setUserId(layoutSetBranch.getUserId());
481 layoutSetBranchImpl.setUserName(layoutSetBranch.getUserName());
482 layoutSetBranchImpl.setCreateDate(layoutSetBranch.getCreateDate());
483 layoutSetBranchImpl.setModifiedDate(layoutSetBranch.getModifiedDate());
484 layoutSetBranchImpl.setPrivateLayout(layoutSetBranch.isPrivateLayout());
485 layoutSetBranchImpl.setName(layoutSetBranch.getName());
486 layoutSetBranchImpl.setDescription(layoutSetBranch.getDescription());
487 layoutSetBranchImpl.setMaster(layoutSetBranch.isMaster());
488 layoutSetBranchImpl.setLogo(layoutSetBranch.isLogo());
489 layoutSetBranchImpl.setLogoId(layoutSetBranch.getLogoId());
490 layoutSetBranchImpl.setThemeId(layoutSetBranch.getThemeId());
491 layoutSetBranchImpl.setColorSchemeId(layoutSetBranch.getColorSchemeId());
492 layoutSetBranchImpl.setWapThemeId(layoutSetBranch.getWapThemeId());
493 layoutSetBranchImpl.setWapColorSchemeId(layoutSetBranch.getWapColorSchemeId());
494 layoutSetBranchImpl.setCss(layoutSetBranch.getCss());
495 layoutSetBranchImpl.setSettings(layoutSetBranch.getSettings());
496 layoutSetBranchImpl.setLayoutSetPrototypeUuid(layoutSetBranch.getLayoutSetPrototypeUuid());
497 layoutSetBranchImpl.setLayoutSetPrototypeLinkEnabled(layoutSetBranch.isLayoutSetPrototypeLinkEnabled());
498
499 return layoutSetBranchImpl;
500 }
501
502
510 @Override
511 public LayoutSetBranch findByPrimaryKey(Serializable primaryKey)
512 throws NoSuchModelException, SystemException {
513 return findByPrimaryKey(((Long)primaryKey).longValue());
514 }
515
516
524 public LayoutSetBranch findByPrimaryKey(long layoutSetBranchId)
525 throws NoSuchLayoutSetBranchException, SystemException {
526 LayoutSetBranch layoutSetBranch = fetchByPrimaryKey(layoutSetBranchId);
527
528 if (layoutSetBranch == null) {
529 if (_log.isWarnEnabled()) {
530 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + layoutSetBranchId);
531 }
532
533 throw new NoSuchLayoutSetBranchException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
534 layoutSetBranchId);
535 }
536
537 return layoutSetBranch;
538 }
539
540
547 @Override
548 public LayoutSetBranch fetchByPrimaryKey(Serializable primaryKey)
549 throws SystemException {
550 return fetchByPrimaryKey(((Long)primaryKey).longValue());
551 }
552
553
560 public LayoutSetBranch fetchByPrimaryKey(long layoutSetBranchId)
561 throws SystemException {
562 LayoutSetBranch layoutSetBranch = (LayoutSetBranch)EntityCacheUtil.getResult(LayoutSetBranchModelImpl.ENTITY_CACHE_ENABLED,
563 LayoutSetBranchImpl.class, layoutSetBranchId);
564
565 if (layoutSetBranch == _nullLayoutSetBranch) {
566 return null;
567 }
568
569 if (layoutSetBranch == null) {
570 Session session = null;
571
572 boolean hasException = false;
573
574 try {
575 session = openSession();
576
577 layoutSetBranch = (LayoutSetBranch)session.get(LayoutSetBranchImpl.class,
578 Long.valueOf(layoutSetBranchId));
579 }
580 catch (Exception e) {
581 hasException = true;
582
583 throw processException(e);
584 }
585 finally {
586 if (layoutSetBranch != null) {
587 cacheResult(layoutSetBranch);
588 }
589 else if (!hasException) {
590 EntityCacheUtil.putResult(LayoutSetBranchModelImpl.ENTITY_CACHE_ENABLED,
591 LayoutSetBranchImpl.class, layoutSetBranchId,
592 _nullLayoutSetBranch);
593 }
594
595 closeSession(session);
596 }
597 }
598
599 return layoutSetBranch;
600 }
601
602
609 public List<LayoutSetBranch> findByGroupId(long groupId)
610 throws SystemException {
611 return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
612 }
613
614
627 public List<LayoutSetBranch> findByGroupId(long groupId, int start, int end)
628 throws SystemException {
629 return findByGroupId(groupId, start, end, null);
630 }
631
632
646 public List<LayoutSetBranch> findByGroupId(long groupId, int start,
647 int end, OrderByComparator orderByComparator) throws SystemException {
648 FinderPath finderPath = null;
649 Object[] finderArgs = null;
650
651 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
652 (orderByComparator == null)) {
653 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
654 finderArgs = new Object[] { groupId };
655 }
656 else {
657 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
658 finderArgs = new Object[] { groupId, start, end, orderByComparator };
659 }
660
661 List<LayoutSetBranch> list = (List<LayoutSetBranch>)FinderCacheUtil.getResult(finderPath,
662 finderArgs, this);
663
664 if ((list != null) && !list.isEmpty()) {
665 for (LayoutSetBranch layoutSetBranch : list) {
666 if ((groupId != layoutSetBranch.getGroupId())) {
667 list = null;
668
669 break;
670 }
671 }
672 }
673
674 if (list == null) {
675 StringBundler query = null;
676
677 if (orderByComparator != null) {
678 query = new StringBundler(3 +
679 (orderByComparator.getOrderByFields().length * 3));
680 }
681 else {
682 query = new StringBundler(3);
683 }
684
685 query.append(_SQL_SELECT_LAYOUTSETBRANCH_WHERE);
686
687 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
688
689 if (orderByComparator != null) {
690 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
691 orderByComparator);
692 }
693
694 else {
695 query.append(LayoutSetBranchModelImpl.ORDER_BY_JPQL);
696 }
697
698 String sql = query.toString();
699
700 Session session = null;
701
702 try {
703 session = openSession();
704
705 Query q = session.createQuery(sql);
706
707 QueryPos qPos = QueryPos.getInstance(q);
708
709 qPos.add(groupId);
710
711 list = (List<LayoutSetBranch>)QueryUtil.list(q, getDialect(),
712 start, end);
713 }
714 catch (Exception e) {
715 throw processException(e);
716 }
717 finally {
718 if (list == null) {
719 FinderCacheUtil.removeResult(finderPath, finderArgs);
720 }
721 else {
722 cacheResult(list);
723
724 FinderCacheUtil.putResult(finderPath, finderArgs, list);
725 }
726
727 closeSession(session);
728 }
729 }
730
731 return list;
732 }
733
734
743 public LayoutSetBranch findByGroupId_First(long groupId,
744 OrderByComparator orderByComparator)
745 throws NoSuchLayoutSetBranchException, SystemException {
746 LayoutSetBranch layoutSetBranch = fetchByGroupId_First(groupId,
747 orderByComparator);
748
749 if (layoutSetBranch != null) {
750 return layoutSetBranch;
751 }
752
753 StringBundler msg = new StringBundler(4);
754
755 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
756
757 msg.append("groupId=");
758 msg.append(groupId);
759
760 msg.append(StringPool.CLOSE_CURLY_BRACE);
761
762 throw new NoSuchLayoutSetBranchException(msg.toString());
763 }
764
765
773 public LayoutSetBranch fetchByGroupId_First(long groupId,
774 OrderByComparator orderByComparator) throws SystemException {
775 List<LayoutSetBranch> list = findByGroupId(groupId, 0, 1,
776 orderByComparator);
777
778 if (!list.isEmpty()) {
779 return list.get(0);
780 }
781
782 return null;
783 }
784
785
794 public LayoutSetBranch findByGroupId_Last(long groupId,
795 OrderByComparator orderByComparator)
796 throws NoSuchLayoutSetBranchException, SystemException {
797 LayoutSetBranch layoutSetBranch = fetchByGroupId_Last(groupId,
798 orderByComparator);
799
800 if (layoutSetBranch != null) {
801 return layoutSetBranch;
802 }
803
804 StringBundler msg = new StringBundler(4);
805
806 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
807
808 msg.append("groupId=");
809 msg.append(groupId);
810
811 msg.append(StringPool.CLOSE_CURLY_BRACE);
812
813 throw new NoSuchLayoutSetBranchException(msg.toString());
814 }
815
816
824 public LayoutSetBranch fetchByGroupId_Last(long groupId,
825 OrderByComparator orderByComparator) throws SystemException {
826 int count = countByGroupId(groupId);
827
828 List<LayoutSetBranch> list = findByGroupId(groupId, count - 1, count,
829 orderByComparator);
830
831 if (!list.isEmpty()) {
832 return list.get(0);
833 }
834
835 return null;
836 }
837
838
848 public LayoutSetBranch[] findByGroupId_PrevAndNext(long layoutSetBranchId,
849 long groupId, OrderByComparator orderByComparator)
850 throws NoSuchLayoutSetBranchException, SystemException {
851 LayoutSetBranch layoutSetBranch = findByPrimaryKey(layoutSetBranchId);
852
853 Session session = null;
854
855 try {
856 session = openSession();
857
858 LayoutSetBranch[] array = new LayoutSetBranchImpl[3];
859
860 array[0] = getByGroupId_PrevAndNext(session, layoutSetBranch,
861 groupId, orderByComparator, true);
862
863 array[1] = layoutSetBranch;
864
865 array[2] = getByGroupId_PrevAndNext(session, layoutSetBranch,
866 groupId, orderByComparator, false);
867
868 return array;
869 }
870 catch (Exception e) {
871 throw processException(e);
872 }
873 finally {
874 closeSession(session);
875 }
876 }
877
878 protected LayoutSetBranch getByGroupId_PrevAndNext(Session session,
879 LayoutSetBranch layoutSetBranch, long groupId,
880 OrderByComparator orderByComparator, boolean previous) {
881 StringBundler query = null;
882
883 if (orderByComparator != null) {
884 query = new StringBundler(6 +
885 (orderByComparator.getOrderByFields().length * 6));
886 }
887 else {
888 query = new StringBundler(3);
889 }
890
891 query.append(_SQL_SELECT_LAYOUTSETBRANCH_WHERE);
892
893 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
894
895 if (orderByComparator != null) {
896 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
897
898 if (orderByConditionFields.length > 0) {
899 query.append(WHERE_AND);
900 }
901
902 for (int i = 0; i < orderByConditionFields.length; i++) {
903 query.append(_ORDER_BY_ENTITY_ALIAS);
904 query.append(orderByConditionFields[i]);
905
906 if ((i + 1) < orderByConditionFields.length) {
907 if (orderByComparator.isAscending() ^ previous) {
908 query.append(WHERE_GREATER_THAN_HAS_NEXT);
909 }
910 else {
911 query.append(WHERE_LESSER_THAN_HAS_NEXT);
912 }
913 }
914 else {
915 if (orderByComparator.isAscending() ^ previous) {
916 query.append(WHERE_GREATER_THAN);
917 }
918 else {
919 query.append(WHERE_LESSER_THAN);
920 }
921 }
922 }
923
924 query.append(ORDER_BY_CLAUSE);
925
926 String[] orderByFields = orderByComparator.getOrderByFields();
927
928 for (int i = 0; i < orderByFields.length; i++) {
929 query.append(_ORDER_BY_ENTITY_ALIAS);
930 query.append(orderByFields[i]);
931
932 if ((i + 1) < orderByFields.length) {
933 if (orderByComparator.isAscending() ^ previous) {
934 query.append(ORDER_BY_ASC_HAS_NEXT);
935 }
936 else {
937 query.append(ORDER_BY_DESC_HAS_NEXT);
938 }
939 }
940 else {
941 if (orderByComparator.isAscending() ^ previous) {
942 query.append(ORDER_BY_ASC);
943 }
944 else {
945 query.append(ORDER_BY_DESC);
946 }
947 }
948 }
949 }
950
951 else {
952 query.append(LayoutSetBranchModelImpl.ORDER_BY_JPQL);
953 }
954
955 String sql = query.toString();
956
957 Query q = session.createQuery(sql);
958
959 q.setFirstResult(0);
960 q.setMaxResults(2);
961
962 QueryPos qPos = QueryPos.getInstance(q);
963
964 qPos.add(groupId);
965
966 if (orderByComparator != null) {
967 Object[] values = orderByComparator.getOrderByConditionValues(layoutSetBranch);
968
969 for (Object value : values) {
970 qPos.add(value);
971 }
972 }
973
974 List<LayoutSetBranch> list = q.list();
975
976 if (list.size() == 2) {
977 return list.get(1);
978 }
979 else {
980 return null;
981 }
982 }
983
984
991 public List<LayoutSetBranch> filterFindByGroupId(long groupId)
992 throws SystemException {
993 return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
994 QueryUtil.ALL_POS, null);
995 }
996
997
1010 public List<LayoutSetBranch> filterFindByGroupId(long groupId, int start,
1011 int end) throws SystemException {
1012 return filterFindByGroupId(groupId, start, end, null);
1013 }
1014
1015
1029 public List<LayoutSetBranch> filterFindByGroupId(long groupId, int start,
1030 int end, OrderByComparator orderByComparator) throws SystemException {
1031 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1032 return findByGroupId(groupId, start, end, orderByComparator);
1033 }
1034
1035 StringBundler query = null;
1036
1037 if (orderByComparator != null) {
1038 query = new StringBundler(3 +
1039 (orderByComparator.getOrderByFields().length * 3));
1040 }
1041 else {
1042 query = new StringBundler(3);
1043 }
1044
1045 if (getDB().isSupportsInlineDistinct()) {
1046 query.append(_FILTER_SQL_SELECT_LAYOUTSETBRANCH_WHERE);
1047 }
1048 else {
1049 query.append(_FILTER_SQL_SELECT_LAYOUTSETBRANCH_NO_INLINE_DISTINCT_WHERE_1);
1050 }
1051
1052 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1053
1054 if (!getDB().isSupportsInlineDistinct()) {
1055 query.append(_FILTER_SQL_SELECT_LAYOUTSETBRANCH_NO_INLINE_DISTINCT_WHERE_2);
1056 }
1057
1058 if (orderByComparator != null) {
1059 if (getDB().isSupportsInlineDistinct()) {
1060 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1061 orderByComparator);
1062 }
1063 else {
1064 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
1065 orderByComparator);
1066 }
1067 }
1068
1069 else {
1070 if (getDB().isSupportsInlineDistinct()) {
1071 query.append(LayoutSetBranchModelImpl.ORDER_BY_JPQL);
1072 }
1073 else {
1074 query.append(LayoutSetBranchModelImpl.ORDER_BY_SQL);
1075 }
1076 }
1077
1078 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1079 LayoutSetBranch.class.getName(),
1080 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
1081
1082 Session session = null;
1083
1084 try {
1085 session = openSession();
1086
1087 SQLQuery q = session.createSQLQuery(sql);
1088
1089 if (getDB().isSupportsInlineDistinct()) {
1090 q.addEntity(_FILTER_ENTITY_ALIAS, LayoutSetBranchImpl.class);
1091 }
1092 else {
1093 q.addEntity(_FILTER_ENTITY_TABLE, LayoutSetBranchImpl.class);
1094 }
1095
1096 QueryPos qPos = QueryPos.getInstance(q);
1097
1098 qPos.add(groupId);
1099
1100 return (List<LayoutSetBranch>)QueryUtil.list(q, getDialect(),
1101 start, end);
1102 }
1103 catch (Exception e) {
1104 throw processException(e);
1105 }
1106 finally {
1107 closeSession(session);
1108 }
1109 }
1110
1111
1121 public LayoutSetBranch[] filterFindByGroupId_PrevAndNext(
1122 long layoutSetBranchId, long groupId,
1123 OrderByComparator orderByComparator)
1124 throws NoSuchLayoutSetBranchException, SystemException {
1125 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1126 return findByGroupId_PrevAndNext(layoutSetBranchId, groupId,
1127 orderByComparator);
1128 }
1129
1130 LayoutSetBranch layoutSetBranch = findByPrimaryKey(layoutSetBranchId);
1131
1132 Session session = null;
1133
1134 try {
1135 session = openSession();
1136
1137 LayoutSetBranch[] array = new LayoutSetBranchImpl[3];
1138
1139 array[0] = filterGetByGroupId_PrevAndNext(session, layoutSetBranch,
1140 groupId, orderByComparator, true);
1141
1142 array[1] = layoutSetBranch;
1143
1144 array[2] = filterGetByGroupId_PrevAndNext(session, layoutSetBranch,
1145 groupId, orderByComparator, false);
1146
1147 return array;
1148 }
1149 catch (Exception e) {
1150 throw processException(e);
1151 }
1152 finally {
1153 closeSession(session);
1154 }
1155 }
1156
1157 protected LayoutSetBranch filterGetByGroupId_PrevAndNext(Session session,
1158 LayoutSetBranch layoutSetBranch, long groupId,
1159 OrderByComparator orderByComparator, boolean previous) {
1160 StringBundler query = null;
1161
1162 if (orderByComparator != null) {
1163 query = new StringBundler(6 +
1164 (orderByComparator.getOrderByFields().length * 6));
1165 }
1166 else {
1167 query = new StringBundler(3);
1168 }
1169
1170 if (getDB().isSupportsInlineDistinct()) {
1171 query.append(_FILTER_SQL_SELECT_LAYOUTSETBRANCH_WHERE);
1172 }
1173 else {
1174 query.append(_FILTER_SQL_SELECT_LAYOUTSETBRANCH_NO_INLINE_DISTINCT_WHERE_1);
1175 }
1176
1177 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1178
1179 if (!getDB().isSupportsInlineDistinct()) {
1180 query.append(_FILTER_SQL_SELECT_LAYOUTSETBRANCH_NO_INLINE_DISTINCT_WHERE_2);
1181 }
1182
1183 if (orderByComparator != null) {
1184 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1185
1186 if (orderByConditionFields.length > 0) {
1187 query.append(WHERE_AND);
1188 }
1189
1190 for (int i = 0; i < orderByConditionFields.length; i++) {
1191 if (getDB().isSupportsInlineDistinct()) {
1192 query.append(_ORDER_BY_ENTITY_ALIAS);
1193 }
1194 else {
1195 query.append(_ORDER_BY_ENTITY_TABLE);
1196 }
1197
1198 query.append(orderByConditionFields[i]);
1199
1200 if ((i + 1) < orderByConditionFields.length) {
1201 if (orderByComparator.isAscending() ^ previous) {
1202 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1203 }
1204 else {
1205 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1206 }
1207 }
1208 else {
1209 if (orderByComparator.isAscending() ^ previous) {
1210 query.append(WHERE_GREATER_THAN);
1211 }
1212 else {
1213 query.append(WHERE_LESSER_THAN);
1214 }
1215 }
1216 }
1217
1218 query.append(ORDER_BY_CLAUSE);
1219
1220 String[] orderByFields = orderByComparator.getOrderByFields();
1221
1222 for (int i = 0; i < orderByFields.length; i++) {
1223 if (getDB().isSupportsInlineDistinct()) {
1224 query.append(_ORDER_BY_ENTITY_ALIAS);
1225 }
1226 else {
1227 query.append(_ORDER_BY_ENTITY_TABLE);
1228 }
1229
1230 query.append(orderByFields[i]);
1231
1232 if ((i + 1) < orderByFields.length) {
1233 if (orderByComparator.isAscending() ^ previous) {
1234 query.append(ORDER_BY_ASC_HAS_NEXT);
1235 }
1236 else {
1237 query.append(ORDER_BY_DESC_HAS_NEXT);
1238 }
1239 }
1240 else {
1241 if (orderByComparator.isAscending() ^ previous) {
1242 query.append(ORDER_BY_ASC);
1243 }
1244 else {
1245 query.append(ORDER_BY_DESC);
1246 }
1247 }
1248 }
1249 }
1250
1251 else {
1252 if (getDB().isSupportsInlineDistinct()) {
1253 query.append(LayoutSetBranchModelImpl.ORDER_BY_JPQL);
1254 }
1255 else {
1256 query.append(LayoutSetBranchModelImpl.ORDER_BY_SQL);
1257 }
1258 }
1259
1260 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1261 LayoutSetBranch.class.getName(),
1262 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
1263
1264 SQLQuery q = session.createSQLQuery(sql);
1265
1266 q.setFirstResult(0);
1267 q.setMaxResults(2);
1268
1269 if (getDB().isSupportsInlineDistinct()) {
1270 q.addEntity(_FILTER_ENTITY_ALIAS, LayoutSetBranchImpl.class);
1271 }
1272 else {
1273 q.addEntity(_FILTER_ENTITY_TABLE, LayoutSetBranchImpl.class);
1274 }
1275
1276 QueryPos qPos = QueryPos.getInstance(q);
1277
1278 qPos.add(groupId);
1279
1280 if (orderByComparator != null) {
1281 Object[] values = orderByComparator.getOrderByConditionValues(layoutSetBranch);
1282
1283 for (Object value : values) {
1284 qPos.add(value);
1285 }
1286 }
1287
1288 List<LayoutSetBranch> list = q.list();
1289
1290 if (list.size() == 2) {
1291 return list.get(1);
1292 }
1293 else {
1294 return null;
1295 }
1296 }
1297
1298
1306 public List<LayoutSetBranch> findByG_P(long groupId, boolean privateLayout)
1307 throws SystemException {
1308 return findByG_P(groupId, privateLayout, QueryUtil.ALL_POS,
1309 QueryUtil.ALL_POS, null);
1310 }
1311
1312
1326 public List<LayoutSetBranch> findByG_P(long groupId, boolean privateLayout,
1327 int start, int end) throws SystemException {
1328 return findByG_P(groupId, privateLayout, start, end, null);
1329 }
1330
1331
1346 public List<LayoutSetBranch> findByG_P(long groupId, boolean privateLayout,
1347 int start, int end, OrderByComparator orderByComparator)
1348 throws SystemException {
1349 FinderPath finderPath = null;
1350 Object[] finderArgs = null;
1351
1352 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1353 (orderByComparator == null)) {
1354 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P;
1355 finderArgs = new Object[] { groupId, privateLayout };
1356 }
1357 else {
1358 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P;
1359 finderArgs = new Object[] {
1360 groupId, privateLayout,
1361
1362 start, end, orderByComparator
1363 };
1364 }
1365
1366 List<LayoutSetBranch> list = (List<LayoutSetBranch>)FinderCacheUtil.getResult(finderPath,
1367 finderArgs, this);
1368
1369 if ((list != null) && !list.isEmpty()) {
1370 for (LayoutSetBranch layoutSetBranch : list) {
1371 if ((groupId != layoutSetBranch.getGroupId()) ||
1372 (privateLayout != layoutSetBranch.getPrivateLayout())) {
1373 list = null;
1374
1375 break;
1376 }
1377 }
1378 }
1379
1380 if (list == null) {
1381 StringBundler query = null;
1382
1383 if (orderByComparator != null) {
1384 query = new StringBundler(4 +
1385 (orderByComparator.getOrderByFields().length * 3));
1386 }
1387 else {
1388 query = new StringBundler(4);
1389 }
1390
1391 query.append(_SQL_SELECT_LAYOUTSETBRANCH_WHERE);
1392
1393 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
1394
1395 query.append(_FINDER_COLUMN_G_P_PRIVATELAYOUT_2);
1396
1397 if (orderByComparator != null) {
1398 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1399 orderByComparator);
1400 }
1401
1402 else {
1403 query.append(LayoutSetBranchModelImpl.ORDER_BY_JPQL);
1404 }
1405
1406 String sql = query.toString();
1407
1408 Session session = null;
1409
1410 try {
1411 session = openSession();
1412
1413 Query q = session.createQuery(sql);
1414
1415 QueryPos qPos = QueryPos.getInstance(q);
1416
1417 qPos.add(groupId);
1418
1419 qPos.add(privateLayout);
1420
1421 list = (List<LayoutSetBranch>)QueryUtil.list(q, getDialect(),
1422 start, end);
1423 }
1424 catch (Exception e) {
1425 throw processException(e);
1426 }
1427 finally {
1428 if (list == null) {
1429 FinderCacheUtil.removeResult(finderPath, finderArgs);
1430 }
1431 else {
1432 cacheResult(list);
1433
1434 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1435 }
1436
1437 closeSession(session);
1438 }
1439 }
1440
1441 return list;
1442 }
1443
1444
1454 public LayoutSetBranch findByG_P_First(long groupId, boolean privateLayout,
1455 OrderByComparator orderByComparator)
1456 throws NoSuchLayoutSetBranchException, SystemException {
1457 LayoutSetBranch layoutSetBranch = fetchByG_P_First(groupId,
1458 privateLayout, orderByComparator);
1459
1460 if (layoutSetBranch != null) {
1461 return layoutSetBranch;
1462 }
1463
1464 StringBundler msg = new StringBundler(6);
1465
1466 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1467
1468 msg.append("groupId=");
1469 msg.append(groupId);
1470
1471 msg.append(", privateLayout=");
1472 msg.append(privateLayout);
1473
1474 msg.append(StringPool.CLOSE_CURLY_BRACE);
1475
1476 throw new NoSuchLayoutSetBranchException(msg.toString());
1477 }
1478
1479
1488 public LayoutSetBranch fetchByG_P_First(long groupId,
1489 boolean privateLayout, OrderByComparator orderByComparator)
1490 throws SystemException {
1491 List<LayoutSetBranch> list = findByG_P(groupId, privateLayout, 0, 1,
1492 orderByComparator);
1493
1494 if (!list.isEmpty()) {
1495 return list.get(0);
1496 }
1497
1498 return null;
1499 }
1500
1501
1511 public LayoutSetBranch findByG_P_Last(long groupId, boolean privateLayout,
1512 OrderByComparator orderByComparator)
1513 throws NoSuchLayoutSetBranchException, SystemException {
1514 LayoutSetBranch layoutSetBranch = fetchByG_P_Last(groupId,
1515 privateLayout, orderByComparator);
1516
1517 if (layoutSetBranch != null) {
1518 return layoutSetBranch;
1519 }
1520
1521 StringBundler msg = new StringBundler(6);
1522
1523 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1524
1525 msg.append("groupId=");
1526 msg.append(groupId);
1527
1528 msg.append(", privateLayout=");
1529 msg.append(privateLayout);
1530
1531 msg.append(StringPool.CLOSE_CURLY_BRACE);
1532
1533 throw new NoSuchLayoutSetBranchException(msg.toString());
1534 }
1535
1536
1545 public LayoutSetBranch fetchByG_P_Last(long groupId, boolean privateLayout,
1546 OrderByComparator orderByComparator) throws SystemException {
1547 int count = countByG_P(groupId, privateLayout);
1548
1549 List<LayoutSetBranch> list = findByG_P(groupId, privateLayout,
1550 count - 1, count, orderByComparator);
1551
1552 if (!list.isEmpty()) {
1553 return list.get(0);
1554 }
1555
1556 return null;
1557 }
1558
1559
1570 public LayoutSetBranch[] findByG_P_PrevAndNext(long layoutSetBranchId,
1571 long groupId, boolean privateLayout, OrderByComparator orderByComparator)
1572 throws NoSuchLayoutSetBranchException, SystemException {
1573 LayoutSetBranch layoutSetBranch = findByPrimaryKey(layoutSetBranchId);
1574
1575 Session session = null;
1576
1577 try {
1578 session = openSession();
1579
1580 LayoutSetBranch[] array = new LayoutSetBranchImpl[3];
1581
1582 array[0] = getByG_P_PrevAndNext(session, layoutSetBranch, groupId,
1583 privateLayout, orderByComparator, true);
1584
1585 array[1] = layoutSetBranch;
1586
1587 array[2] = getByG_P_PrevAndNext(session, layoutSetBranch, groupId,
1588 privateLayout, orderByComparator, false);
1589
1590 return array;
1591 }
1592 catch (Exception e) {
1593 throw processException(e);
1594 }
1595 finally {
1596 closeSession(session);
1597 }
1598 }
1599
1600 protected LayoutSetBranch getByG_P_PrevAndNext(Session session,
1601 LayoutSetBranch layoutSetBranch, long groupId, boolean privateLayout,
1602 OrderByComparator orderByComparator, boolean previous) {
1603 StringBundler query = null;
1604
1605 if (orderByComparator != null) {
1606 query = new StringBundler(6 +
1607 (orderByComparator.getOrderByFields().length * 6));
1608 }
1609 else {
1610 query = new StringBundler(3);
1611 }
1612
1613 query.append(_SQL_SELECT_LAYOUTSETBRANCH_WHERE);
1614
1615 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
1616
1617 query.append(_FINDER_COLUMN_G_P_PRIVATELAYOUT_2);
1618
1619 if (orderByComparator != null) {
1620 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1621
1622 if (orderByConditionFields.length > 0) {
1623 query.append(WHERE_AND);
1624 }
1625
1626 for (int i = 0; i < orderByConditionFields.length; i++) {
1627 query.append(_ORDER_BY_ENTITY_ALIAS);
1628 query.append(orderByConditionFields[i]);
1629
1630 if ((i + 1) < orderByConditionFields.length) {
1631 if (orderByComparator.isAscending() ^ previous) {
1632 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1633 }
1634 else {
1635 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1636 }
1637 }
1638 else {
1639 if (orderByComparator.isAscending() ^ previous) {
1640 query.append(WHERE_GREATER_THAN);
1641 }
1642 else {
1643 query.append(WHERE_LESSER_THAN);
1644 }
1645 }
1646 }
1647
1648 query.append(ORDER_BY_CLAUSE);
1649
1650 String[] orderByFields = orderByComparator.getOrderByFields();
1651
1652 for (int i = 0; i < orderByFields.length; i++) {
1653 query.append(_ORDER_BY_ENTITY_ALIAS);
1654 query.append(orderByFields[i]);
1655
1656 if ((i + 1) < orderByFields.length) {
1657 if (orderByComparator.isAscending() ^ previous) {
1658 query.append(ORDER_BY_ASC_HAS_NEXT);
1659 }
1660 else {
1661 query.append(ORDER_BY_DESC_HAS_NEXT);
1662 }
1663 }
1664 else {
1665 if (orderByComparator.isAscending() ^ previous) {
1666 query.append(ORDER_BY_ASC);
1667 }
1668 else {
1669 query.append(ORDER_BY_DESC);
1670 }
1671 }
1672 }
1673 }
1674
1675 else {
1676 query.append(LayoutSetBranchModelImpl.ORDER_BY_JPQL);
1677 }
1678
1679 String sql = query.toString();
1680
1681 Query q = session.createQuery(sql);
1682
1683 q.setFirstResult(0);
1684 q.setMaxResults(2);
1685
1686 QueryPos qPos = QueryPos.getInstance(q);
1687
1688 qPos.add(groupId);
1689
1690 qPos.add(privateLayout);
1691
1692 if (orderByComparator != null) {
1693 Object[] values = orderByComparator.getOrderByConditionValues(layoutSetBranch);
1694
1695 for (Object value : values) {
1696 qPos.add(value);
1697 }
1698 }
1699
1700 List<LayoutSetBranch> list = q.list();
1701
1702 if (list.size() == 2) {
1703 return list.get(1);
1704 }
1705 else {
1706 return null;
1707 }
1708 }
1709
1710
1718 public List<LayoutSetBranch> filterFindByG_P(long groupId,
1719 boolean privateLayout) throws SystemException {
1720 return filterFindByG_P(groupId, privateLayout, QueryUtil.ALL_POS,
1721 QueryUtil.ALL_POS, null);
1722 }
1723
1724
1738 public List<LayoutSetBranch> filterFindByG_P(long groupId,
1739 boolean privateLayout, int start, int end) throws SystemException {
1740 return filterFindByG_P(groupId, privateLayout, start, end, null);
1741 }
1742
1743
1758 public List<LayoutSetBranch> filterFindByG_P(long groupId,
1759 boolean privateLayout, int start, int end,
1760 OrderByComparator orderByComparator) throws SystemException {
1761 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1762 return findByG_P(groupId, privateLayout, start, end,
1763 orderByComparator);
1764 }
1765
1766 StringBundler query = null;
1767
1768 if (orderByComparator != null) {
1769 query = new StringBundler(4 +
1770 (orderByComparator.getOrderByFields().length * 3));
1771 }
1772 else {
1773 query = new StringBundler(4);
1774 }
1775
1776 if (getDB().isSupportsInlineDistinct()) {
1777 query.append(_FILTER_SQL_SELECT_LAYOUTSETBRANCH_WHERE);
1778 }
1779 else {
1780 query.append(_FILTER_SQL_SELECT_LAYOUTSETBRANCH_NO_INLINE_DISTINCT_WHERE_1);
1781 }
1782
1783 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
1784
1785 query.append(_FINDER_COLUMN_G_P_PRIVATELAYOUT_2);
1786
1787 if (!getDB().isSupportsInlineDistinct()) {
1788 query.append(_FILTER_SQL_SELECT_LAYOUTSETBRANCH_NO_INLINE_DISTINCT_WHERE_2);
1789 }
1790
1791 if (orderByComparator != null) {
1792 if (getDB().isSupportsInlineDistinct()) {
1793 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1794 orderByComparator);
1795 }
1796 else {
1797 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
1798 orderByComparator);
1799 }
1800 }
1801
1802 else {
1803 if (getDB().isSupportsInlineDistinct()) {
1804 query.append(LayoutSetBranchModelImpl.ORDER_BY_JPQL);
1805 }
1806 else {
1807 query.append(LayoutSetBranchModelImpl.ORDER_BY_SQL);
1808 }
1809 }
1810
1811 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1812 LayoutSetBranch.class.getName(),
1813 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
1814
1815 Session session = null;
1816
1817 try {
1818 session = openSession();
1819
1820 SQLQuery q = session.createSQLQuery(sql);
1821
1822 if (getDB().isSupportsInlineDistinct()) {
1823 q.addEntity(_FILTER_ENTITY_ALIAS, LayoutSetBranchImpl.class);
1824 }
1825 else {
1826 q.addEntity(_FILTER_ENTITY_TABLE, LayoutSetBranchImpl.class);
1827 }
1828
1829 QueryPos qPos = QueryPos.getInstance(q);
1830
1831 qPos.add(groupId);
1832
1833 qPos.add(privateLayout);
1834
1835 return (List<LayoutSetBranch>)QueryUtil.list(q, getDialect(),
1836 start, end);
1837 }
1838 catch (Exception e) {
1839 throw processException(e);
1840 }
1841 finally {
1842 closeSession(session);
1843 }
1844 }
1845
1846
1857 public LayoutSetBranch[] filterFindByG_P_PrevAndNext(
1858 long layoutSetBranchId, long groupId, boolean privateLayout,
1859 OrderByComparator orderByComparator)
1860 throws NoSuchLayoutSetBranchException, SystemException {
1861 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1862 return findByG_P_PrevAndNext(layoutSetBranchId, groupId,
1863 privateLayout, orderByComparator);
1864 }
1865
1866 LayoutSetBranch layoutSetBranch = findByPrimaryKey(layoutSetBranchId);
1867
1868 Session session = null;
1869
1870 try {
1871 session = openSession();
1872
1873 LayoutSetBranch[] array = new LayoutSetBranchImpl[3];
1874
1875 array[0] = filterGetByG_P_PrevAndNext(session, layoutSetBranch,
1876 groupId, privateLayout, orderByComparator, true);
1877
1878 array[1] = layoutSetBranch;
1879
1880 array[2] = filterGetByG_P_PrevAndNext(session, layoutSetBranch,
1881 groupId, privateLayout, orderByComparator, false);
1882
1883 return array;
1884 }
1885 catch (Exception e) {
1886 throw processException(e);
1887 }
1888 finally {
1889 closeSession(session);
1890 }
1891 }
1892
1893 protected LayoutSetBranch filterGetByG_P_PrevAndNext(Session session,
1894 LayoutSetBranch layoutSetBranch, long groupId, boolean privateLayout,
1895 OrderByComparator orderByComparator, boolean previous) {
1896 StringBundler query = null;
1897
1898 if (orderByComparator != null) {
1899 query = new StringBundler(6 +
1900 (orderByComparator.getOrderByFields().length * 6));
1901 }
1902 else {
1903 query = new StringBundler(3);
1904 }
1905
1906 if (getDB().isSupportsInlineDistinct()) {
1907 query.append(_FILTER_SQL_SELECT_LAYOUTSETBRANCH_WHERE);
1908 }
1909 else {
1910 query.append(_FILTER_SQL_SELECT_LAYOUTSETBRANCH_NO_INLINE_DISTINCT_WHERE_1);
1911 }
1912
1913 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
1914
1915 query.append(_FINDER_COLUMN_G_P_PRIVATELAYOUT_2);
1916
1917 if (!getDB().isSupportsInlineDistinct()) {
1918 query.append(_FILTER_SQL_SELECT_LAYOUTSETBRANCH_NO_INLINE_DISTINCT_WHERE_2);
1919 }
1920
1921 if (orderByComparator != null) {
1922 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1923
1924 if (orderByConditionFields.length > 0) {
1925 query.append(WHERE_AND);
1926 }
1927
1928 for (int i = 0; i < orderByConditionFields.length; i++) {
1929 if (getDB().isSupportsInlineDistinct()) {
1930 query.append(_ORDER_BY_ENTITY_ALIAS);
1931 }
1932 else {
1933 query.append(_ORDER_BY_ENTITY_TABLE);
1934 }
1935
1936 query.append(orderByConditionFields[i]);
1937
1938 if ((i + 1) < orderByConditionFields.length) {
1939 if (orderByComparator.isAscending() ^ previous) {
1940 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1941 }
1942 else {
1943 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1944 }
1945 }
1946 else {
1947 if (orderByComparator.isAscending() ^ previous) {
1948 query.append(WHERE_GREATER_THAN);
1949 }
1950 else {
1951 query.append(WHERE_LESSER_THAN);
1952 }
1953 }
1954 }
1955
1956 query.append(ORDER_BY_CLAUSE);
1957
1958 String[] orderByFields = orderByComparator.getOrderByFields();
1959
1960 for (int i = 0; i < orderByFields.length; i++) {
1961 if (getDB().isSupportsInlineDistinct()) {
1962 query.append(_ORDER_BY_ENTITY_ALIAS);
1963 }
1964 else {
1965 query.append(_ORDER_BY_ENTITY_TABLE);
1966 }
1967
1968 query.append(orderByFields[i]);
1969
1970 if ((i + 1) < orderByFields.length) {
1971 if (orderByComparator.isAscending() ^ previous) {
1972 query.append(ORDER_BY_ASC_HAS_NEXT);
1973 }
1974 else {
1975 query.append(ORDER_BY_DESC_HAS_NEXT);
1976 }
1977 }
1978 else {
1979 if (orderByComparator.isAscending() ^ previous) {
1980 query.append(ORDER_BY_ASC);
1981 }
1982 else {
1983 query.append(ORDER_BY_DESC);
1984 }
1985 }
1986 }
1987 }
1988
1989 else {
1990 if (getDB().isSupportsInlineDistinct()) {
1991 query.append(LayoutSetBranchModelImpl.ORDER_BY_JPQL);
1992 }
1993 else {
1994 query.append(LayoutSetBranchModelImpl.ORDER_BY_SQL);
1995 }
1996 }
1997
1998 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1999 LayoutSetBranch.class.getName(),
2000 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2001
2002 SQLQuery q = session.createSQLQuery(sql);
2003
2004 q.setFirstResult(0);
2005 q.setMaxResults(2);
2006
2007 if (getDB().isSupportsInlineDistinct()) {
2008 q.addEntity(_FILTER_ENTITY_ALIAS, LayoutSetBranchImpl.class);
2009 }
2010 else {
2011 q.addEntity(_FILTER_ENTITY_TABLE, LayoutSetBranchImpl.class);
2012 }
2013
2014 QueryPos qPos = QueryPos.getInstance(q);
2015
2016 qPos.add(groupId);
2017
2018 qPos.add(privateLayout);
2019
2020 if (orderByComparator != null) {
2021 Object[] values = orderByComparator.getOrderByConditionValues(layoutSetBranch);
2022
2023 for (Object value : values) {
2024 qPos.add(value);
2025 }
2026 }
2027
2028 List<LayoutSetBranch> list = q.list();
2029
2030 if (list.size() == 2) {
2031 return list.get(1);
2032 }
2033 else {
2034 return null;
2035 }
2036 }
2037
2038
2048 public LayoutSetBranch findByG_P_N(long groupId, boolean privateLayout,
2049 String name) throws NoSuchLayoutSetBranchException, SystemException {
2050 LayoutSetBranch layoutSetBranch = fetchByG_P_N(groupId, privateLayout,
2051 name);
2052
2053 if (layoutSetBranch == null) {
2054 StringBundler msg = new StringBundler(8);
2055
2056 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2057
2058 msg.append("groupId=");
2059 msg.append(groupId);
2060
2061 msg.append(", privateLayout=");
2062 msg.append(privateLayout);
2063
2064 msg.append(", name=");
2065 msg.append(name);
2066
2067 msg.append(StringPool.CLOSE_CURLY_BRACE);
2068
2069 if (_log.isWarnEnabled()) {
2070 _log.warn(msg.toString());
2071 }
2072
2073 throw new NoSuchLayoutSetBranchException(msg.toString());
2074 }
2075
2076 return layoutSetBranch;
2077 }
2078
2079
2088 public LayoutSetBranch fetchByG_P_N(long groupId, boolean privateLayout,
2089 String name) throws SystemException {
2090 return fetchByG_P_N(groupId, privateLayout, name, true);
2091 }
2092
2093
2103 public LayoutSetBranch fetchByG_P_N(long groupId, boolean privateLayout,
2104 String name, boolean retrieveFromCache) throws SystemException {
2105 Object[] finderArgs = new Object[] { groupId, privateLayout, name };
2106
2107 Object result = null;
2108
2109 if (retrieveFromCache) {
2110 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_P_N,
2111 finderArgs, this);
2112 }
2113
2114 if (result instanceof LayoutSetBranch) {
2115 LayoutSetBranch layoutSetBranch = (LayoutSetBranch)result;
2116
2117 if ((groupId != layoutSetBranch.getGroupId()) ||
2118 (privateLayout != layoutSetBranch.getPrivateLayout()) ||
2119 !Validator.equals(name, layoutSetBranch.getName())) {
2120 result = null;
2121 }
2122 }
2123
2124 if (result == null) {
2125 StringBundler query = new StringBundler(5);
2126
2127 query.append(_SQL_SELECT_LAYOUTSETBRANCH_WHERE);
2128
2129 query.append(_FINDER_COLUMN_G_P_N_GROUPID_2);
2130
2131 query.append(_FINDER_COLUMN_G_P_N_PRIVATELAYOUT_2);
2132
2133 if (name == null) {
2134 query.append(_FINDER_COLUMN_G_P_N_NAME_1);
2135 }
2136 else {
2137 if (name.equals(StringPool.BLANK)) {
2138 query.append(_FINDER_COLUMN_G_P_N_NAME_3);
2139 }
2140 else {
2141 query.append(_FINDER_COLUMN_G_P_N_NAME_2);
2142 }
2143 }
2144
2145 query.append(LayoutSetBranchModelImpl.ORDER_BY_JPQL);
2146
2147 String sql = query.toString();
2148
2149 Session session = null;
2150
2151 try {
2152 session = openSession();
2153
2154 Query q = session.createQuery(sql);
2155
2156 QueryPos qPos = QueryPos.getInstance(q);
2157
2158 qPos.add(groupId);
2159
2160 qPos.add(privateLayout);
2161
2162 if (name != null) {
2163 qPos.add(name);
2164 }
2165
2166 List<LayoutSetBranch> list = q.list();
2167
2168 result = list;
2169
2170 LayoutSetBranch layoutSetBranch = null;
2171
2172 if (list.isEmpty()) {
2173 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P_N,
2174 finderArgs, list);
2175 }
2176 else {
2177 layoutSetBranch = list.get(0);
2178
2179 cacheResult(layoutSetBranch);
2180
2181 if ((layoutSetBranch.getGroupId() != groupId) ||
2182 (layoutSetBranch.getPrivateLayout() != privateLayout) ||
2183 (layoutSetBranch.getName() == null) ||
2184 !layoutSetBranch.getName().equals(name)) {
2185 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P_N,
2186 finderArgs, layoutSetBranch);
2187 }
2188 }
2189
2190 return layoutSetBranch;
2191 }
2192 catch (Exception e) {
2193 throw processException(e);
2194 }
2195 finally {
2196 if (result == null) {
2197 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_P_N,
2198 finderArgs);
2199 }
2200
2201 closeSession(session);
2202 }
2203 }
2204 else {
2205 if (result instanceof List<?>) {
2206 return null;
2207 }
2208 else {
2209 return (LayoutSetBranch)result;
2210 }
2211 }
2212 }
2213
2214
2220 public List<LayoutSetBranch> findAll() throws SystemException {
2221 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2222 }
2223
2224
2236 public List<LayoutSetBranch> findAll(int start, int end)
2237 throws SystemException {
2238 return findAll(start, end, null);
2239 }
2240
2241
2254 public List<LayoutSetBranch> findAll(int start, int end,
2255 OrderByComparator orderByComparator) throws SystemException {
2256 FinderPath finderPath = null;
2257 Object[] finderArgs = new Object[] { start, end, orderByComparator };
2258
2259 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2260 (orderByComparator == null)) {
2261 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
2262 finderArgs = FINDER_ARGS_EMPTY;
2263 }
2264 else {
2265 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
2266 finderArgs = new Object[] { start, end, orderByComparator };
2267 }
2268
2269 List<LayoutSetBranch> list = (List<LayoutSetBranch>)FinderCacheUtil.getResult(finderPath,
2270 finderArgs, this);
2271
2272 if (list == null) {
2273 StringBundler query = null;
2274 String sql = null;
2275
2276 if (orderByComparator != null) {
2277 query = new StringBundler(2 +
2278 (orderByComparator.getOrderByFields().length * 3));
2279
2280 query.append(_SQL_SELECT_LAYOUTSETBRANCH);
2281
2282 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2283 orderByComparator);
2284
2285 sql = query.toString();
2286 }
2287 else {
2288 sql = _SQL_SELECT_LAYOUTSETBRANCH.concat(LayoutSetBranchModelImpl.ORDER_BY_JPQL);
2289 }
2290
2291 Session session = null;
2292
2293 try {
2294 session = openSession();
2295
2296 Query q = session.createQuery(sql);
2297
2298 if (orderByComparator == null) {
2299 list = (List<LayoutSetBranch>)QueryUtil.list(q,
2300 getDialect(), start, end, false);
2301
2302 Collections.sort(list);
2303 }
2304 else {
2305 list = (List<LayoutSetBranch>)QueryUtil.list(q,
2306 getDialect(), start, end);
2307 }
2308 }
2309 catch (Exception e) {
2310 throw processException(e);
2311 }
2312 finally {
2313 if (list == null) {
2314 FinderCacheUtil.removeResult(finderPath, finderArgs);
2315 }
2316 else {
2317 cacheResult(list);
2318
2319 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2320 }
2321
2322 closeSession(session);
2323 }
2324 }
2325
2326 return list;
2327 }
2328
2329
2335 public void removeByGroupId(long groupId) throws SystemException {
2336 for (LayoutSetBranch layoutSetBranch : findByGroupId(groupId)) {
2337 remove(layoutSetBranch);
2338 }
2339 }
2340
2341
2348 public void removeByG_P(long groupId, boolean privateLayout)
2349 throws SystemException {
2350 for (LayoutSetBranch layoutSetBranch : findByG_P(groupId, privateLayout)) {
2351 remove(layoutSetBranch);
2352 }
2353 }
2354
2355
2364 public LayoutSetBranch removeByG_P_N(long groupId, boolean privateLayout,
2365 String name) throws NoSuchLayoutSetBranchException, SystemException {
2366 LayoutSetBranch layoutSetBranch = findByG_P_N(groupId, privateLayout,
2367 name);
2368
2369 return remove(layoutSetBranch);
2370 }
2371
2372
2377 public void removeAll() throws SystemException {
2378 for (LayoutSetBranch layoutSetBranch : findAll()) {
2379 remove(layoutSetBranch);
2380 }
2381 }
2382
2383
2390 public int countByGroupId(long groupId) throws SystemException {
2391 Object[] finderArgs = new Object[] { groupId };
2392
2393 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
2394 finderArgs, this);
2395
2396 if (count == null) {
2397 StringBundler query = new StringBundler(2);
2398
2399 query.append(_SQL_COUNT_LAYOUTSETBRANCH_WHERE);
2400
2401 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2402
2403 String sql = query.toString();
2404
2405 Session session = null;
2406
2407 try {
2408 session = openSession();
2409
2410 Query q = session.createQuery(sql);
2411
2412 QueryPos qPos = QueryPos.getInstance(q);
2413
2414 qPos.add(groupId);
2415
2416 count = (Long)q.uniqueResult();
2417 }
2418 catch (Exception e) {
2419 throw processException(e);
2420 }
2421 finally {
2422 if (count == null) {
2423 count = Long.valueOf(0);
2424 }
2425
2426 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
2427 finderArgs, count);
2428
2429 closeSession(session);
2430 }
2431 }
2432
2433 return count.intValue();
2434 }
2435
2436
2443 public int filterCountByGroupId(long groupId) throws SystemException {
2444 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2445 return countByGroupId(groupId);
2446 }
2447
2448 StringBundler query = new StringBundler(2);
2449
2450 query.append(_FILTER_SQL_COUNT_LAYOUTSETBRANCH_WHERE);
2451
2452 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2453
2454 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2455 LayoutSetBranch.class.getName(),
2456 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2457
2458 Session session = null;
2459
2460 try {
2461 session = openSession();
2462
2463 SQLQuery q = session.createSQLQuery(sql);
2464
2465 q.addScalar(COUNT_COLUMN_NAME,
2466 com.liferay.portal.kernel.dao.orm.Type.LONG);
2467
2468 QueryPos qPos = QueryPos.getInstance(q);
2469
2470 qPos.add(groupId);
2471
2472 Long count = (Long)q.uniqueResult();
2473
2474 return count.intValue();
2475 }
2476 catch (Exception e) {
2477 throw processException(e);
2478 }
2479 finally {
2480 closeSession(session);
2481 }
2482 }
2483
2484
2492 public int countByG_P(long groupId, boolean privateLayout)
2493 throws SystemException {
2494 Object[] finderArgs = new Object[] { groupId, privateLayout };
2495
2496 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_P,
2497 finderArgs, this);
2498
2499 if (count == null) {
2500 StringBundler query = new StringBundler(3);
2501
2502 query.append(_SQL_COUNT_LAYOUTSETBRANCH_WHERE);
2503
2504 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
2505
2506 query.append(_FINDER_COLUMN_G_P_PRIVATELAYOUT_2);
2507
2508 String sql = query.toString();
2509
2510 Session session = null;
2511
2512 try {
2513 session = openSession();
2514
2515 Query q = session.createQuery(sql);
2516
2517 QueryPos qPos = QueryPos.getInstance(q);
2518
2519 qPos.add(groupId);
2520
2521 qPos.add(privateLayout);
2522
2523 count = (Long)q.uniqueResult();
2524 }
2525 catch (Exception e) {
2526 throw processException(e);
2527 }
2528 finally {
2529 if (count == null) {
2530 count = Long.valueOf(0);
2531 }
2532
2533 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_P, finderArgs,
2534 count);
2535
2536 closeSession(session);
2537 }
2538 }
2539
2540 return count.intValue();
2541 }
2542
2543
2551 public int filterCountByG_P(long groupId, boolean privateLayout)
2552 throws SystemException {
2553 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2554 return countByG_P(groupId, privateLayout);
2555 }
2556
2557 StringBundler query = new StringBundler(3);
2558
2559 query.append(_FILTER_SQL_COUNT_LAYOUTSETBRANCH_WHERE);
2560
2561 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
2562
2563 query.append(_FINDER_COLUMN_G_P_PRIVATELAYOUT_2);
2564
2565 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2566 LayoutSetBranch.class.getName(),
2567 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2568
2569 Session session = null;
2570
2571 try {
2572 session = openSession();
2573
2574 SQLQuery q = session.createSQLQuery(sql);
2575
2576 q.addScalar(COUNT_COLUMN_NAME,
2577 com.liferay.portal.kernel.dao.orm.Type.LONG);
2578
2579 QueryPos qPos = QueryPos.getInstance(q);
2580
2581 qPos.add(groupId);
2582
2583 qPos.add(privateLayout);
2584
2585 Long count = (Long)q.uniqueResult();
2586
2587 return count.intValue();
2588 }
2589 catch (Exception e) {
2590 throw processException(e);
2591 }
2592 finally {
2593 closeSession(session);
2594 }
2595 }
2596
2597
2606 public int countByG_P_N(long groupId, boolean privateLayout, String name)
2607 throws SystemException {
2608 Object[] finderArgs = new Object[] { groupId, privateLayout, name };
2609
2610 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_P_N,
2611 finderArgs, this);
2612
2613 if (count == null) {
2614 StringBundler query = new StringBundler(4);
2615
2616 query.append(_SQL_COUNT_LAYOUTSETBRANCH_WHERE);
2617
2618 query.append(_FINDER_COLUMN_G_P_N_GROUPID_2);
2619
2620 query.append(_FINDER_COLUMN_G_P_N_PRIVATELAYOUT_2);
2621
2622 if (name == null) {
2623 query.append(_FINDER_COLUMN_G_P_N_NAME_1);
2624 }
2625 else {
2626 if (name.equals(StringPool.BLANK)) {
2627 query.append(_FINDER_COLUMN_G_P_N_NAME_3);
2628 }
2629 else {
2630 query.append(_FINDER_COLUMN_G_P_N_NAME_2);
2631 }
2632 }
2633
2634 String sql = query.toString();
2635
2636 Session session = null;
2637
2638 try {
2639 session = openSession();
2640
2641 Query q = session.createQuery(sql);
2642
2643 QueryPos qPos = QueryPos.getInstance(q);
2644
2645 qPos.add(groupId);
2646
2647 qPos.add(privateLayout);
2648
2649 if (name != null) {
2650 qPos.add(name);
2651 }
2652
2653 count = (Long)q.uniqueResult();
2654 }
2655 catch (Exception e) {
2656 throw processException(e);
2657 }
2658 finally {
2659 if (count == null) {
2660 count = Long.valueOf(0);
2661 }
2662
2663 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_P_N,
2664 finderArgs, count);
2665
2666 closeSession(session);
2667 }
2668 }
2669
2670 return count.intValue();
2671 }
2672
2673
2679 public int countAll() throws SystemException {
2680 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
2681 FINDER_ARGS_EMPTY, this);
2682
2683 if (count == null) {
2684 Session session = null;
2685
2686 try {
2687 session = openSession();
2688
2689 Query q = session.createQuery(_SQL_COUNT_LAYOUTSETBRANCH);
2690
2691 count = (Long)q.uniqueResult();
2692 }
2693 catch (Exception e) {
2694 throw processException(e);
2695 }
2696 finally {
2697 if (count == null) {
2698 count = Long.valueOf(0);
2699 }
2700
2701 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
2702 FINDER_ARGS_EMPTY, count);
2703
2704 closeSession(session);
2705 }
2706 }
2707
2708 return count.intValue();
2709 }
2710
2711
2714 public void afterPropertiesSet() {
2715 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
2716 com.liferay.portal.util.PropsUtil.get(
2717 "value.object.listener.com.liferay.portal.model.LayoutSetBranch")));
2718
2719 if (listenerClassNames.length > 0) {
2720 try {
2721 List<ModelListener<LayoutSetBranch>> listenersList = new ArrayList<ModelListener<LayoutSetBranch>>();
2722
2723 for (String listenerClassName : listenerClassNames) {
2724 listenersList.add((ModelListener<LayoutSetBranch>)InstanceFactory.newInstance(
2725 listenerClassName));
2726 }
2727
2728 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
2729 }
2730 catch (Exception e) {
2731 _log.error(e);
2732 }
2733 }
2734 }
2735
2736 public void destroy() {
2737 EntityCacheUtil.removeCache(LayoutSetBranchImpl.class.getName());
2738 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
2739 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2740 }
2741
2742 @BeanReference(type = AccountPersistence.class)
2743 protected AccountPersistence accountPersistence;
2744 @BeanReference(type = AddressPersistence.class)
2745 protected AddressPersistence addressPersistence;
2746 @BeanReference(type = BrowserTrackerPersistence.class)
2747 protected BrowserTrackerPersistence browserTrackerPersistence;
2748 @BeanReference(type = ClassNamePersistence.class)
2749 protected ClassNamePersistence classNamePersistence;
2750 @BeanReference(type = ClusterGroupPersistence.class)
2751 protected ClusterGroupPersistence clusterGroupPersistence;
2752 @BeanReference(type = CompanyPersistence.class)
2753 protected CompanyPersistence companyPersistence;
2754 @BeanReference(type = ContactPersistence.class)
2755 protected ContactPersistence contactPersistence;
2756 @BeanReference(type = CountryPersistence.class)
2757 protected CountryPersistence countryPersistence;
2758 @BeanReference(type = EmailAddressPersistence.class)
2759 protected EmailAddressPersistence emailAddressPersistence;
2760 @BeanReference(type = GroupPersistence.class)
2761 protected GroupPersistence groupPersistence;
2762 @BeanReference(type = ImagePersistence.class)
2763 protected ImagePersistence imagePersistence;
2764 @BeanReference(type = LayoutPersistence.class)
2765 protected LayoutPersistence layoutPersistence;
2766 @BeanReference(type = LayoutBranchPersistence.class)
2767 protected LayoutBranchPersistence layoutBranchPersistence;
2768 @BeanReference(type = LayoutPrototypePersistence.class)
2769 protected LayoutPrototypePersistence layoutPrototypePersistence;
2770 @BeanReference(type = LayoutRevisionPersistence.class)
2771 protected LayoutRevisionPersistence layoutRevisionPersistence;
2772 @BeanReference(type = LayoutSetPersistence.class)
2773 protected LayoutSetPersistence layoutSetPersistence;
2774 @BeanReference(type = LayoutSetBranchPersistence.class)
2775 protected LayoutSetBranchPersistence layoutSetBranchPersistence;
2776 @BeanReference(type = LayoutSetPrototypePersistence.class)
2777 protected LayoutSetPrototypePersistence layoutSetPrototypePersistence;
2778 @BeanReference(type = ListTypePersistence.class)
2779 protected ListTypePersistence listTypePersistence;
2780 @BeanReference(type = LockPersistence.class)
2781 protected LockPersistence lockPersistence;
2782 @BeanReference(type = MembershipRequestPersistence.class)
2783 protected MembershipRequestPersistence membershipRequestPersistence;
2784 @BeanReference(type = OrganizationPersistence.class)
2785 protected OrganizationPersistence organizationPersistence;
2786 @BeanReference(type = OrgGroupRolePersistence.class)
2787 protected OrgGroupRolePersistence orgGroupRolePersistence;
2788 @BeanReference(type = OrgLaborPersistence.class)
2789 protected OrgLaborPersistence orgLaborPersistence;
2790 @BeanReference(type = PasswordPolicyPersistence.class)
2791 protected PasswordPolicyPersistence passwordPolicyPersistence;
2792 @BeanReference(type = PasswordPolicyRelPersistence.class)
2793 protected PasswordPolicyRelPersistence passwordPolicyRelPersistence;
2794 @BeanReference(type = PasswordTrackerPersistence.class)
2795 protected PasswordTrackerPersistence passwordTrackerPersistence;
2796 @BeanReference(type = PhonePersistence.class)
2797 protected PhonePersistence phonePersistence;
2798 @BeanReference(type = PluginSettingPersistence.class)
2799 protected PluginSettingPersistence pluginSettingPersistence;
2800 @BeanReference(type = PortalPreferencesPersistence.class)
2801 protected PortalPreferencesPersistence portalPreferencesPersistence;
2802 @BeanReference(type = PortletPersistence.class)
2803 protected PortletPersistence portletPersistence;
2804 @BeanReference(type = PortletItemPersistence.class)
2805 protected PortletItemPersistence portletItemPersistence;
2806 @BeanReference(type = PortletPreferencesPersistence.class)
2807 protected PortletPreferencesPersistence portletPreferencesPersistence;
2808 @BeanReference(type = RegionPersistence.class)
2809 protected RegionPersistence regionPersistence;
2810 @BeanReference(type = ReleasePersistence.class)
2811 protected ReleasePersistence releasePersistence;
2812 @BeanReference(type = RepositoryPersistence.class)
2813 protected RepositoryPersistence repositoryPersistence;
2814 @BeanReference(type = RepositoryEntryPersistence.class)
2815 protected RepositoryEntryPersistence repositoryEntryPersistence;
2816 @BeanReference(type = ResourceActionPersistence.class)
2817 protected ResourceActionPersistence resourceActionPersistence;
2818 @BeanReference(type = ResourceBlockPersistence.class)
2819 protected ResourceBlockPersistence resourceBlockPersistence;
2820 @BeanReference(type = ResourceBlockPermissionPersistence.class)
2821 protected ResourceBlockPermissionPersistence resourceBlockPermissionPersistence;
2822 @BeanReference(type = ResourcePermissionPersistence.class)
2823 protected ResourcePermissionPersistence resourcePermissionPersistence;
2824 @BeanReference(type = ResourceTypePermissionPersistence.class)
2825 protected ResourceTypePermissionPersistence resourceTypePermissionPersistence;
2826 @BeanReference(type = RolePersistence.class)
2827 protected RolePersistence rolePersistence;
2828 @BeanReference(type = ServiceComponentPersistence.class)
2829 protected ServiceComponentPersistence serviceComponentPersistence;
2830 @BeanReference(type = ShardPersistence.class)
2831 protected ShardPersistence shardPersistence;
2832 @BeanReference(type = SubscriptionPersistence.class)
2833 protected SubscriptionPersistence subscriptionPersistence;
2834 @BeanReference(type = TeamPersistence.class)
2835 protected TeamPersistence teamPersistence;
2836 @BeanReference(type = TicketPersistence.class)
2837 protected TicketPersistence ticketPersistence;
2838 @BeanReference(type = UserPersistence.class)
2839 protected UserPersistence userPersistence;
2840 @BeanReference(type = UserGroupPersistence.class)
2841 protected UserGroupPersistence userGroupPersistence;
2842 @BeanReference(type = UserGroupGroupRolePersistence.class)
2843 protected UserGroupGroupRolePersistence userGroupGroupRolePersistence;
2844 @BeanReference(type = UserGroupRolePersistence.class)
2845 protected UserGroupRolePersistence userGroupRolePersistence;
2846 @BeanReference(type = UserIdMapperPersistence.class)
2847 protected UserIdMapperPersistence userIdMapperPersistence;
2848 @BeanReference(type = UserNotificationEventPersistence.class)
2849 protected UserNotificationEventPersistence userNotificationEventPersistence;
2850 @BeanReference(type = UserTrackerPersistence.class)
2851 protected UserTrackerPersistence userTrackerPersistence;
2852 @BeanReference(type = UserTrackerPathPersistence.class)
2853 protected UserTrackerPathPersistence userTrackerPathPersistence;
2854 @BeanReference(type = VirtualHostPersistence.class)
2855 protected VirtualHostPersistence virtualHostPersistence;
2856 @BeanReference(type = WebDAVPropsPersistence.class)
2857 protected WebDAVPropsPersistence webDAVPropsPersistence;
2858 @BeanReference(type = WebsitePersistence.class)
2859 protected WebsitePersistence websitePersistence;
2860 @BeanReference(type = WorkflowDefinitionLinkPersistence.class)
2861 protected WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
2862 @BeanReference(type = WorkflowInstanceLinkPersistence.class)
2863 protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
2864 private static final String _SQL_SELECT_LAYOUTSETBRANCH = "SELECT layoutSetBranch FROM LayoutSetBranch layoutSetBranch";
2865 private static final String _SQL_SELECT_LAYOUTSETBRANCH_WHERE = "SELECT layoutSetBranch FROM LayoutSetBranch layoutSetBranch WHERE ";
2866 private static final String _SQL_COUNT_LAYOUTSETBRANCH = "SELECT COUNT(layoutSetBranch) FROM LayoutSetBranch layoutSetBranch";
2867 private static final String _SQL_COUNT_LAYOUTSETBRANCH_WHERE = "SELECT COUNT(layoutSetBranch) FROM LayoutSetBranch layoutSetBranch WHERE ";
2868 private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "layoutSetBranch.groupId = ?";
2869 private static final String _FINDER_COLUMN_G_P_GROUPID_2 = "layoutSetBranch.groupId = ? AND ";
2870 private static final String _FINDER_COLUMN_G_P_PRIVATELAYOUT_2 = "layoutSetBranch.privateLayout = ?";
2871 private static final String _FINDER_COLUMN_G_P_N_GROUPID_2 = "layoutSetBranch.groupId = ? AND ";
2872 private static final String _FINDER_COLUMN_G_P_N_PRIVATELAYOUT_2 = "layoutSetBranch.privateLayout = ? AND ";
2873 private static final String _FINDER_COLUMN_G_P_N_NAME_1 = "layoutSetBranch.name IS NULL";
2874 private static final String _FINDER_COLUMN_G_P_N_NAME_2 = "layoutSetBranch.name = ?";
2875 private static final String _FINDER_COLUMN_G_P_N_NAME_3 = "(layoutSetBranch.name IS NULL OR layoutSetBranch.name = ?)";
2876 private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "layoutSetBranch.layoutSetBranchId";
2877 private static final String _FILTER_SQL_SELECT_LAYOUTSETBRANCH_WHERE = "SELECT DISTINCT {layoutSetBranch.*} FROM LayoutSetBranch layoutSetBranch WHERE ";
2878 private static final String _FILTER_SQL_SELECT_LAYOUTSETBRANCH_NO_INLINE_DISTINCT_WHERE_1 =
2879 "SELECT {LayoutSetBranch.*} FROM (SELECT DISTINCT layoutSetBranch.layoutSetBranchId FROM LayoutSetBranch layoutSetBranch WHERE ";
2880 private static final String _FILTER_SQL_SELECT_LAYOUTSETBRANCH_NO_INLINE_DISTINCT_WHERE_2 =
2881 ") TEMP_TABLE INNER JOIN LayoutSetBranch ON TEMP_TABLE.layoutSetBranchId = LayoutSetBranch.layoutSetBranchId";
2882 private static final String _FILTER_SQL_COUNT_LAYOUTSETBRANCH_WHERE = "SELECT COUNT(DISTINCT layoutSetBranch.layoutSetBranchId) AS COUNT_VALUE FROM LayoutSetBranch layoutSetBranch WHERE ";
2883 private static final String _FILTER_ENTITY_ALIAS = "layoutSetBranch";
2884 private static final String _FILTER_ENTITY_TABLE = "LayoutSetBranch";
2885 private static final String _ORDER_BY_ENTITY_ALIAS = "layoutSetBranch.";
2886 private static final String _ORDER_BY_ENTITY_TABLE = "LayoutSetBranch.";
2887 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No LayoutSetBranch exists with the primary key ";
2888 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No LayoutSetBranch exists with the key {";
2889 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
2890 private static Log _log = LogFactoryUtil.getLog(LayoutSetBranchPersistenceImpl.class);
2891 private static LayoutSetBranch _nullLayoutSetBranch = new LayoutSetBranchImpl() {
2892 @Override
2893 public Object clone() {
2894 return this;
2895 }
2896
2897 @Override
2898 public CacheModel<LayoutSetBranch> toCacheModel() {
2899 return _nullLayoutSetBranchCacheModel;
2900 }
2901 };
2902
2903 private static CacheModel<LayoutSetBranch> _nullLayoutSetBranchCacheModel = new CacheModel<LayoutSetBranch>() {
2904 public LayoutSetBranch toEntityModel() {
2905 return _nullLayoutSetBranch;
2906 }
2907 };
2908 }