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 else {
375 if ((layoutSetBranchModelImpl.getColumnBitmask() &
376 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
377 Object[] args = new Object[] {
378 Long.valueOf(layoutSetBranchModelImpl.getOriginalGroupId())
379 };
380
381 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
382 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
383 args);
384
385 args = new Object[] {
386 Long.valueOf(layoutSetBranchModelImpl.getGroupId())
387 };
388
389 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
390 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
391 args);
392 }
393
394 if ((layoutSetBranchModelImpl.getColumnBitmask() &
395 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P.getColumnBitmask()) != 0) {
396 Object[] args = new Object[] {
397 Long.valueOf(layoutSetBranchModelImpl.getOriginalGroupId()),
398 Boolean.valueOf(layoutSetBranchModelImpl.getOriginalPrivateLayout())
399 };
400
401 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P, args);
402 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P,
403 args);
404
405 args = new Object[] {
406 Long.valueOf(layoutSetBranchModelImpl.getGroupId()),
407 Boolean.valueOf(layoutSetBranchModelImpl.getPrivateLayout())
408 };
409
410 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P, args);
411 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P,
412 args);
413 }
414 }
415
416 EntityCacheUtil.putResult(LayoutSetBranchModelImpl.ENTITY_CACHE_ENABLED,
417 LayoutSetBranchImpl.class, layoutSetBranch.getPrimaryKey(),
418 layoutSetBranch);
419
420 if (isNew) {
421 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P_N,
422 new Object[] {
423 Long.valueOf(layoutSetBranch.getGroupId()),
424 Boolean.valueOf(layoutSetBranch.getPrivateLayout()),
425
426 layoutSetBranch.getName()
427 }, layoutSetBranch);
428 }
429 else {
430 if ((layoutSetBranchModelImpl.getColumnBitmask() &
431 FINDER_PATH_FETCH_BY_G_P_N.getColumnBitmask()) != 0) {
432 Object[] args = new Object[] {
433 Long.valueOf(layoutSetBranchModelImpl.getOriginalGroupId()),
434 Boolean.valueOf(layoutSetBranchModelImpl.getOriginalPrivateLayout()),
435
436 layoutSetBranchModelImpl.getOriginalName()
437 };
438
439 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P_N, args);
440 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_P_N, args);
441
442 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P_N,
443 new Object[] {
444 Long.valueOf(layoutSetBranch.getGroupId()),
445 Boolean.valueOf(layoutSetBranch.getPrivateLayout()),
446
447 layoutSetBranch.getName()
448 }, layoutSetBranch);
449 }
450 }
451
452 return layoutSetBranch;
453 }
454
455 protected LayoutSetBranch toUnwrappedModel(LayoutSetBranch layoutSetBranch) {
456 if (layoutSetBranch instanceof LayoutSetBranchImpl) {
457 return layoutSetBranch;
458 }
459
460 LayoutSetBranchImpl layoutSetBranchImpl = new LayoutSetBranchImpl();
461
462 layoutSetBranchImpl.setNew(layoutSetBranch.isNew());
463 layoutSetBranchImpl.setPrimaryKey(layoutSetBranch.getPrimaryKey());
464
465 layoutSetBranchImpl.setLayoutSetBranchId(layoutSetBranch.getLayoutSetBranchId());
466 layoutSetBranchImpl.setGroupId(layoutSetBranch.getGroupId());
467 layoutSetBranchImpl.setCompanyId(layoutSetBranch.getCompanyId());
468 layoutSetBranchImpl.setUserId(layoutSetBranch.getUserId());
469 layoutSetBranchImpl.setUserName(layoutSetBranch.getUserName());
470 layoutSetBranchImpl.setCreateDate(layoutSetBranch.getCreateDate());
471 layoutSetBranchImpl.setModifiedDate(layoutSetBranch.getModifiedDate());
472 layoutSetBranchImpl.setPrivateLayout(layoutSetBranch.isPrivateLayout());
473 layoutSetBranchImpl.setName(layoutSetBranch.getName());
474 layoutSetBranchImpl.setDescription(layoutSetBranch.getDescription());
475 layoutSetBranchImpl.setMaster(layoutSetBranch.isMaster());
476 layoutSetBranchImpl.setLogo(layoutSetBranch.isLogo());
477 layoutSetBranchImpl.setLogoId(layoutSetBranch.getLogoId());
478 layoutSetBranchImpl.setThemeId(layoutSetBranch.getThemeId());
479 layoutSetBranchImpl.setColorSchemeId(layoutSetBranch.getColorSchemeId());
480 layoutSetBranchImpl.setWapThemeId(layoutSetBranch.getWapThemeId());
481 layoutSetBranchImpl.setWapColorSchemeId(layoutSetBranch.getWapColorSchemeId());
482 layoutSetBranchImpl.setCss(layoutSetBranch.getCss());
483 layoutSetBranchImpl.setSettings(layoutSetBranch.getSettings());
484 layoutSetBranchImpl.setLayoutSetPrototypeUuid(layoutSetBranch.getLayoutSetPrototypeUuid());
485 layoutSetBranchImpl.setLayoutSetPrototypeLinkEnabled(layoutSetBranch.isLayoutSetPrototypeLinkEnabled());
486
487 return layoutSetBranchImpl;
488 }
489
490
498 @Override
499 public LayoutSetBranch findByPrimaryKey(Serializable primaryKey)
500 throws NoSuchModelException, SystemException {
501 return findByPrimaryKey(((Long)primaryKey).longValue());
502 }
503
504
512 public LayoutSetBranch findByPrimaryKey(long layoutSetBranchId)
513 throws NoSuchLayoutSetBranchException, SystemException {
514 LayoutSetBranch layoutSetBranch = fetchByPrimaryKey(layoutSetBranchId);
515
516 if (layoutSetBranch == null) {
517 if (_log.isWarnEnabled()) {
518 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + layoutSetBranchId);
519 }
520
521 throw new NoSuchLayoutSetBranchException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
522 layoutSetBranchId);
523 }
524
525 return layoutSetBranch;
526 }
527
528
535 @Override
536 public LayoutSetBranch fetchByPrimaryKey(Serializable primaryKey)
537 throws SystemException {
538 return fetchByPrimaryKey(((Long)primaryKey).longValue());
539 }
540
541
548 public LayoutSetBranch fetchByPrimaryKey(long layoutSetBranchId)
549 throws SystemException {
550 LayoutSetBranch layoutSetBranch = (LayoutSetBranch)EntityCacheUtil.getResult(LayoutSetBranchModelImpl.ENTITY_CACHE_ENABLED,
551 LayoutSetBranchImpl.class, layoutSetBranchId);
552
553 if (layoutSetBranch == _nullLayoutSetBranch) {
554 return null;
555 }
556
557 if (layoutSetBranch == null) {
558 Session session = null;
559
560 boolean hasException = false;
561
562 try {
563 session = openSession();
564
565 layoutSetBranch = (LayoutSetBranch)session.get(LayoutSetBranchImpl.class,
566 Long.valueOf(layoutSetBranchId));
567 }
568 catch (Exception e) {
569 hasException = true;
570
571 throw processException(e);
572 }
573 finally {
574 if (layoutSetBranch != null) {
575 cacheResult(layoutSetBranch);
576 }
577 else if (!hasException) {
578 EntityCacheUtil.putResult(LayoutSetBranchModelImpl.ENTITY_CACHE_ENABLED,
579 LayoutSetBranchImpl.class, layoutSetBranchId,
580 _nullLayoutSetBranch);
581 }
582
583 closeSession(session);
584 }
585 }
586
587 return layoutSetBranch;
588 }
589
590
597 public List<LayoutSetBranch> findByGroupId(long groupId)
598 throws SystemException {
599 return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
600 }
601
602
615 public List<LayoutSetBranch> findByGroupId(long groupId, int start, int end)
616 throws SystemException {
617 return findByGroupId(groupId, start, end, null);
618 }
619
620
634 public List<LayoutSetBranch> findByGroupId(long groupId, int start,
635 int end, OrderByComparator orderByComparator) throws SystemException {
636 FinderPath finderPath = null;
637 Object[] finderArgs = null;
638
639 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
640 (orderByComparator == null)) {
641 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
642 finderArgs = new Object[] { groupId };
643 }
644 else {
645 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
646 finderArgs = new Object[] { groupId, start, end, orderByComparator };
647 }
648
649 List<LayoutSetBranch> list = (List<LayoutSetBranch>)FinderCacheUtil.getResult(finderPath,
650 finderArgs, this);
651
652 if ((list != null) && !list.isEmpty()) {
653 for (LayoutSetBranch layoutSetBranch : list) {
654 if ((groupId != layoutSetBranch.getGroupId())) {
655 list = null;
656
657 break;
658 }
659 }
660 }
661
662 if (list == null) {
663 StringBundler query = null;
664
665 if (orderByComparator != null) {
666 query = new StringBundler(3 +
667 (orderByComparator.getOrderByFields().length * 3));
668 }
669 else {
670 query = new StringBundler(3);
671 }
672
673 query.append(_SQL_SELECT_LAYOUTSETBRANCH_WHERE);
674
675 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
676
677 if (orderByComparator != null) {
678 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
679 orderByComparator);
680 }
681
682 else {
683 query.append(LayoutSetBranchModelImpl.ORDER_BY_JPQL);
684 }
685
686 String sql = query.toString();
687
688 Session session = null;
689
690 try {
691 session = openSession();
692
693 Query q = session.createQuery(sql);
694
695 QueryPos qPos = QueryPos.getInstance(q);
696
697 qPos.add(groupId);
698
699 list = (List<LayoutSetBranch>)QueryUtil.list(q, getDialect(),
700 start, end);
701 }
702 catch (Exception e) {
703 throw processException(e);
704 }
705 finally {
706 if (list == null) {
707 FinderCacheUtil.removeResult(finderPath, finderArgs);
708 }
709 else {
710 cacheResult(list);
711
712 FinderCacheUtil.putResult(finderPath, finderArgs, list);
713 }
714
715 closeSession(session);
716 }
717 }
718
719 return list;
720 }
721
722
735 public LayoutSetBranch findByGroupId_First(long groupId,
736 OrderByComparator orderByComparator)
737 throws NoSuchLayoutSetBranchException, SystemException {
738 List<LayoutSetBranch> list = findByGroupId(groupId, 0, 1,
739 orderByComparator);
740
741 if (list.isEmpty()) {
742 StringBundler msg = new StringBundler(4);
743
744 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
745
746 msg.append("groupId=");
747 msg.append(groupId);
748
749 msg.append(StringPool.CLOSE_CURLY_BRACE);
750
751 throw new NoSuchLayoutSetBranchException(msg.toString());
752 }
753 else {
754 return list.get(0);
755 }
756 }
757
758
771 public LayoutSetBranch findByGroupId_Last(long groupId,
772 OrderByComparator orderByComparator)
773 throws NoSuchLayoutSetBranchException, SystemException {
774 int count = countByGroupId(groupId);
775
776 List<LayoutSetBranch> list = findByGroupId(groupId, count - 1, count,
777 orderByComparator);
778
779 if (list.isEmpty()) {
780 StringBundler msg = new StringBundler(4);
781
782 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
783
784 msg.append("groupId=");
785 msg.append(groupId);
786
787 msg.append(StringPool.CLOSE_CURLY_BRACE);
788
789 throw new NoSuchLayoutSetBranchException(msg.toString());
790 }
791 else {
792 return list.get(0);
793 }
794 }
795
796
810 public LayoutSetBranch[] findByGroupId_PrevAndNext(long layoutSetBranchId,
811 long groupId, OrderByComparator orderByComparator)
812 throws NoSuchLayoutSetBranchException, SystemException {
813 LayoutSetBranch layoutSetBranch = findByPrimaryKey(layoutSetBranchId);
814
815 Session session = null;
816
817 try {
818 session = openSession();
819
820 LayoutSetBranch[] array = new LayoutSetBranchImpl[3];
821
822 array[0] = getByGroupId_PrevAndNext(session, layoutSetBranch,
823 groupId, orderByComparator, true);
824
825 array[1] = layoutSetBranch;
826
827 array[2] = getByGroupId_PrevAndNext(session, layoutSetBranch,
828 groupId, orderByComparator, false);
829
830 return array;
831 }
832 catch (Exception e) {
833 throw processException(e);
834 }
835 finally {
836 closeSession(session);
837 }
838 }
839
840 protected LayoutSetBranch getByGroupId_PrevAndNext(Session session,
841 LayoutSetBranch layoutSetBranch, long groupId,
842 OrderByComparator orderByComparator, boolean previous) {
843 StringBundler query = null;
844
845 if (orderByComparator != null) {
846 query = new StringBundler(6 +
847 (orderByComparator.getOrderByFields().length * 6));
848 }
849 else {
850 query = new StringBundler(3);
851 }
852
853 query.append(_SQL_SELECT_LAYOUTSETBRANCH_WHERE);
854
855 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
856
857 if (orderByComparator != null) {
858 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
859
860 if (orderByConditionFields.length > 0) {
861 query.append(WHERE_AND);
862 }
863
864 for (int i = 0; i < orderByConditionFields.length; i++) {
865 query.append(_ORDER_BY_ENTITY_ALIAS);
866 query.append(orderByConditionFields[i]);
867
868 if ((i + 1) < orderByConditionFields.length) {
869 if (orderByComparator.isAscending() ^ previous) {
870 query.append(WHERE_GREATER_THAN_HAS_NEXT);
871 }
872 else {
873 query.append(WHERE_LESSER_THAN_HAS_NEXT);
874 }
875 }
876 else {
877 if (orderByComparator.isAscending() ^ previous) {
878 query.append(WHERE_GREATER_THAN);
879 }
880 else {
881 query.append(WHERE_LESSER_THAN);
882 }
883 }
884 }
885
886 query.append(ORDER_BY_CLAUSE);
887
888 String[] orderByFields = orderByComparator.getOrderByFields();
889
890 for (int i = 0; i < orderByFields.length; i++) {
891 query.append(_ORDER_BY_ENTITY_ALIAS);
892 query.append(orderByFields[i]);
893
894 if ((i + 1) < orderByFields.length) {
895 if (orderByComparator.isAscending() ^ previous) {
896 query.append(ORDER_BY_ASC_HAS_NEXT);
897 }
898 else {
899 query.append(ORDER_BY_DESC_HAS_NEXT);
900 }
901 }
902 else {
903 if (orderByComparator.isAscending() ^ previous) {
904 query.append(ORDER_BY_ASC);
905 }
906 else {
907 query.append(ORDER_BY_DESC);
908 }
909 }
910 }
911 }
912
913 else {
914 query.append(LayoutSetBranchModelImpl.ORDER_BY_JPQL);
915 }
916
917 String sql = query.toString();
918
919 Query q = session.createQuery(sql);
920
921 q.setFirstResult(0);
922 q.setMaxResults(2);
923
924 QueryPos qPos = QueryPos.getInstance(q);
925
926 qPos.add(groupId);
927
928 if (orderByComparator != null) {
929 Object[] values = orderByComparator.getOrderByConditionValues(layoutSetBranch);
930
931 for (Object value : values) {
932 qPos.add(value);
933 }
934 }
935
936 List<LayoutSetBranch> list = q.list();
937
938 if (list.size() == 2) {
939 return list.get(1);
940 }
941 else {
942 return null;
943 }
944 }
945
946
953 public List<LayoutSetBranch> filterFindByGroupId(long groupId)
954 throws SystemException {
955 return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
956 QueryUtil.ALL_POS, null);
957 }
958
959
972 public List<LayoutSetBranch> filterFindByGroupId(long groupId, int start,
973 int end) throws SystemException {
974 return filterFindByGroupId(groupId, start, end, null);
975 }
976
977
991 public List<LayoutSetBranch> filterFindByGroupId(long groupId, int start,
992 int end, OrderByComparator orderByComparator) throws SystemException {
993 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
994 return findByGroupId(groupId, start, end, orderByComparator);
995 }
996
997 StringBundler query = null;
998
999 if (orderByComparator != null) {
1000 query = new StringBundler(3 +
1001 (orderByComparator.getOrderByFields().length * 3));
1002 }
1003 else {
1004 query = new StringBundler(3);
1005 }
1006
1007 if (getDB().isSupportsInlineDistinct()) {
1008 query.append(_FILTER_SQL_SELECT_LAYOUTSETBRANCH_WHERE);
1009 }
1010 else {
1011 query.append(_FILTER_SQL_SELECT_LAYOUTSETBRANCH_NO_INLINE_DISTINCT_WHERE_1);
1012 }
1013
1014 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1015
1016 if (!getDB().isSupportsInlineDistinct()) {
1017 query.append(_FILTER_SQL_SELECT_LAYOUTSETBRANCH_NO_INLINE_DISTINCT_WHERE_2);
1018 }
1019
1020 if (orderByComparator != null) {
1021 if (getDB().isSupportsInlineDistinct()) {
1022 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1023 orderByComparator);
1024 }
1025 else {
1026 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
1027 orderByComparator);
1028 }
1029 }
1030
1031 else {
1032 if (getDB().isSupportsInlineDistinct()) {
1033 query.append(LayoutSetBranchModelImpl.ORDER_BY_JPQL);
1034 }
1035 else {
1036 query.append(LayoutSetBranchModelImpl.ORDER_BY_SQL);
1037 }
1038 }
1039
1040 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1041 LayoutSetBranch.class.getName(),
1042 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
1043
1044 Session session = null;
1045
1046 try {
1047 session = openSession();
1048
1049 SQLQuery q = session.createSQLQuery(sql);
1050
1051 if (getDB().isSupportsInlineDistinct()) {
1052 q.addEntity(_FILTER_ENTITY_ALIAS, LayoutSetBranchImpl.class);
1053 }
1054 else {
1055 q.addEntity(_FILTER_ENTITY_TABLE, LayoutSetBranchImpl.class);
1056 }
1057
1058 QueryPos qPos = QueryPos.getInstance(q);
1059
1060 qPos.add(groupId);
1061
1062 return (List<LayoutSetBranch>)QueryUtil.list(q, getDialect(),
1063 start, end);
1064 }
1065 catch (Exception e) {
1066 throw processException(e);
1067 }
1068 finally {
1069 closeSession(session);
1070 }
1071 }
1072
1073
1083 public LayoutSetBranch[] filterFindByGroupId_PrevAndNext(
1084 long layoutSetBranchId, long groupId,
1085 OrderByComparator orderByComparator)
1086 throws NoSuchLayoutSetBranchException, SystemException {
1087 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1088 return findByGroupId_PrevAndNext(layoutSetBranchId, groupId,
1089 orderByComparator);
1090 }
1091
1092 LayoutSetBranch layoutSetBranch = findByPrimaryKey(layoutSetBranchId);
1093
1094 Session session = null;
1095
1096 try {
1097 session = openSession();
1098
1099 LayoutSetBranch[] array = new LayoutSetBranchImpl[3];
1100
1101 array[0] = filterGetByGroupId_PrevAndNext(session, layoutSetBranch,
1102 groupId, orderByComparator, true);
1103
1104 array[1] = layoutSetBranch;
1105
1106 array[2] = filterGetByGroupId_PrevAndNext(session, layoutSetBranch,
1107 groupId, orderByComparator, false);
1108
1109 return array;
1110 }
1111 catch (Exception e) {
1112 throw processException(e);
1113 }
1114 finally {
1115 closeSession(session);
1116 }
1117 }
1118
1119 protected LayoutSetBranch filterGetByGroupId_PrevAndNext(Session session,
1120 LayoutSetBranch layoutSetBranch, long groupId,
1121 OrderByComparator orderByComparator, boolean previous) {
1122 StringBundler query = null;
1123
1124 if (orderByComparator != null) {
1125 query = new StringBundler(6 +
1126 (orderByComparator.getOrderByFields().length * 6));
1127 }
1128 else {
1129 query = new StringBundler(3);
1130 }
1131
1132 if (getDB().isSupportsInlineDistinct()) {
1133 query.append(_FILTER_SQL_SELECT_LAYOUTSETBRANCH_WHERE);
1134 }
1135 else {
1136 query.append(_FILTER_SQL_SELECT_LAYOUTSETBRANCH_NO_INLINE_DISTINCT_WHERE_1);
1137 }
1138
1139 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1140
1141 if (!getDB().isSupportsInlineDistinct()) {
1142 query.append(_FILTER_SQL_SELECT_LAYOUTSETBRANCH_NO_INLINE_DISTINCT_WHERE_2);
1143 }
1144
1145 if (orderByComparator != null) {
1146 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1147
1148 if (orderByConditionFields.length > 0) {
1149 query.append(WHERE_AND);
1150 }
1151
1152 for (int i = 0; i < orderByConditionFields.length; i++) {
1153 if (getDB().isSupportsInlineDistinct()) {
1154 query.append(_ORDER_BY_ENTITY_ALIAS);
1155 }
1156 else {
1157 query.append(_ORDER_BY_ENTITY_TABLE);
1158 }
1159
1160 query.append(orderByConditionFields[i]);
1161
1162 if ((i + 1) < orderByConditionFields.length) {
1163 if (orderByComparator.isAscending() ^ previous) {
1164 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1165 }
1166 else {
1167 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1168 }
1169 }
1170 else {
1171 if (orderByComparator.isAscending() ^ previous) {
1172 query.append(WHERE_GREATER_THAN);
1173 }
1174 else {
1175 query.append(WHERE_LESSER_THAN);
1176 }
1177 }
1178 }
1179
1180 query.append(ORDER_BY_CLAUSE);
1181
1182 String[] orderByFields = orderByComparator.getOrderByFields();
1183
1184 for (int i = 0; i < orderByFields.length; i++) {
1185 if (getDB().isSupportsInlineDistinct()) {
1186 query.append(_ORDER_BY_ENTITY_ALIAS);
1187 }
1188 else {
1189 query.append(_ORDER_BY_ENTITY_TABLE);
1190 }
1191
1192 query.append(orderByFields[i]);
1193
1194 if ((i + 1) < orderByFields.length) {
1195 if (orderByComparator.isAscending() ^ previous) {
1196 query.append(ORDER_BY_ASC_HAS_NEXT);
1197 }
1198 else {
1199 query.append(ORDER_BY_DESC_HAS_NEXT);
1200 }
1201 }
1202 else {
1203 if (orderByComparator.isAscending() ^ previous) {
1204 query.append(ORDER_BY_ASC);
1205 }
1206 else {
1207 query.append(ORDER_BY_DESC);
1208 }
1209 }
1210 }
1211 }
1212
1213 else {
1214 if (getDB().isSupportsInlineDistinct()) {
1215 query.append(LayoutSetBranchModelImpl.ORDER_BY_JPQL);
1216 }
1217 else {
1218 query.append(LayoutSetBranchModelImpl.ORDER_BY_SQL);
1219 }
1220 }
1221
1222 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1223 LayoutSetBranch.class.getName(),
1224 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
1225
1226 SQLQuery q = session.createSQLQuery(sql);
1227
1228 q.setFirstResult(0);
1229 q.setMaxResults(2);
1230
1231 if (getDB().isSupportsInlineDistinct()) {
1232 q.addEntity(_FILTER_ENTITY_ALIAS, LayoutSetBranchImpl.class);
1233 }
1234 else {
1235 q.addEntity(_FILTER_ENTITY_TABLE, LayoutSetBranchImpl.class);
1236 }
1237
1238 QueryPos qPos = QueryPos.getInstance(q);
1239
1240 qPos.add(groupId);
1241
1242 if (orderByComparator != null) {
1243 Object[] values = orderByComparator.getOrderByConditionValues(layoutSetBranch);
1244
1245 for (Object value : values) {
1246 qPos.add(value);
1247 }
1248 }
1249
1250 List<LayoutSetBranch> list = q.list();
1251
1252 if (list.size() == 2) {
1253 return list.get(1);
1254 }
1255 else {
1256 return null;
1257 }
1258 }
1259
1260
1268 public List<LayoutSetBranch> findByG_P(long groupId, boolean privateLayout)
1269 throws SystemException {
1270 return findByG_P(groupId, privateLayout, QueryUtil.ALL_POS,
1271 QueryUtil.ALL_POS, null);
1272 }
1273
1274
1288 public List<LayoutSetBranch> findByG_P(long groupId, boolean privateLayout,
1289 int start, int end) throws SystemException {
1290 return findByG_P(groupId, privateLayout, start, end, null);
1291 }
1292
1293
1308 public List<LayoutSetBranch> findByG_P(long groupId, boolean privateLayout,
1309 int start, int end, OrderByComparator orderByComparator)
1310 throws SystemException {
1311 FinderPath finderPath = null;
1312 Object[] finderArgs = null;
1313
1314 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1315 (orderByComparator == null)) {
1316 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P;
1317 finderArgs = new Object[] { groupId, privateLayout };
1318 }
1319 else {
1320 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P;
1321 finderArgs = new Object[] {
1322 groupId, privateLayout,
1323
1324 start, end, orderByComparator
1325 };
1326 }
1327
1328 List<LayoutSetBranch> list = (List<LayoutSetBranch>)FinderCacheUtil.getResult(finderPath,
1329 finderArgs, this);
1330
1331 if ((list != null) && !list.isEmpty()) {
1332 for (LayoutSetBranch layoutSetBranch : list) {
1333 if ((groupId != layoutSetBranch.getGroupId()) ||
1334 (privateLayout != layoutSetBranch.getPrivateLayout())) {
1335 list = null;
1336
1337 break;
1338 }
1339 }
1340 }
1341
1342 if (list == null) {
1343 StringBundler query = null;
1344
1345 if (orderByComparator != null) {
1346 query = new StringBundler(4 +
1347 (orderByComparator.getOrderByFields().length * 3));
1348 }
1349 else {
1350 query = new StringBundler(4);
1351 }
1352
1353 query.append(_SQL_SELECT_LAYOUTSETBRANCH_WHERE);
1354
1355 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
1356
1357 query.append(_FINDER_COLUMN_G_P_PRIVATELAYOUT_2);
1358
1359 if (orderByComparator != null) {
1360 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1361 orderByComparator);
1362 }
1363
1364 else {
1365 query.append(LayoutSetBranchModelImpl.ORDER_BY_JPQL);
1366 }
1367
1368 String sql = query.toString();
1369
1370 Session session = null;
1371
1372 try {
1373 session = openSession();
1374
1375 Query q = session.createQuery(sql);
1376
1377 QueryPos qPos = QueryPos.getInstance(q);
1378
1379 qPos.add(groupId);
1380
1381 qPos.add(privateLayout);
1382
1383 list = (List<LayoutSetBranch>)QueryUtil.list(q, getDialect(),
1384 start, end);
1385 }
1386 catch (Exception e) {
1387 throw processException(e);
1388 }
1389 finally {
1390 if (list == null) {
1391 FinderCacheUtil.removeResult(finderPath, finderArgs);
1392 }
1393 else {
1394 cacheResult(list);
1395
1396 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1397 }
1398
1399 closeSession(session);
1400 }
1401 }
1402
1403 return list;
1404 }
1405
1406
1420 public LayoutSetBranch findByG_P_First(long groupId, boolean privateLayout,
1421 OrderByComparator orderByComparator)
1422 throws NoSuchLayoutSetBranchException, SystemException {
1423 List<LayoutSetBranch> list = findByG_P(groupId, privateLayout, 0, 1,
1424 orderByComparator);
1425
1426 if (list.isEmpty()) {
1427 StringBundler msg = new StringBundler(6);
1428
1429 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1430
1431 msg.append("groupId=");
1432 msg.append(groupId);
1433
1434 msg.append(", privateLayout=");
1435 msg.append(privateLayout);
1436
1437 msg.append(StringPool.CLOSE_CURLY_BRACE);
1438
1439 throw new NoSuchLayoutSetBranchException(msg.toString());
1440 }
1441 else {
1442 return list.get(0);
1443 }
1444 }
1445
1446
1460 public LayoutSetBranch findByG_P_Last(long groupId, boolean privateLayout,
1461 OrderByComparator orderByComparator)
1462 throws NoSuchLayoutSetBranchException, SystemException {
1463 int count = countByG_P(groupId, privateLayout);
1464
1465 List<LayoutSetBranch> list = findByG_P(groupId, privateLayout,
1466 count - 1, count, orderByComparator);
1467
1468 if (list.isEmpty()) {
1469 StringBundler msg = new StringBundler(6);
1470
1471 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1472
1473 msg.append("groupId=");
1474 msg.append(groupId);
1475
1476 msg.append(", privateLayout=");
1477 msg.append(privateLayout);
1478
1479 msg.append(StringPool.CLOSE_CURLY_BRACE);
1480
1481 throw new NoSuchLayoutSetBranchException(msg.toString());
1482 }
1483 else {
1484 return list.get(0);
1485 }
1486 }
1487
1488
1503 public LayoutSetBranch[] findByG_P_PrevAndNext(long layoutSetBranchId,
1504 long groupId, boolean privateLayout, OrderByComparator orderByComparator)
1505 throws NoSuchLayoutSetBranchException, SystemException {
1506 LayoutSetBranch layoutSetBranch = findByPrimaryKey(layoutSetBranchId);
1507
1508 Session session = null;
1509
1510 try {
1511 session = openSession();
1512
1513 LayoutSetBranch[] array = new LayoutSetBranchImpl[3];
1514
1515 array[0] = getByG_P_PrevAndNext(session, layoutSetBranch, groupId,
1516 privateLayout, orderByComparator, true);
1517
1518 array[1] = layoutSetBranch;
1519
1520 array[2] = getByG_P_PrevAndNext(session, layoutSetBranch, groupId,
1521 privateLayout, orderByComparator, false);
1522
1523 return array;
1524 }
1525 catch (Exception e) {
1526 throw processException(e);
1527 }
1528 finally {
1529 closeSession(session);
1530 }
1531 }
1532
1533 protected LayoutSetBranch getByG_P_PrevAndNext(Session session,
1534 LayoutSetBranch layoutSetBranch, long groupId, boolean privateLayout,
1535 OrderByComparator orderByComparator, boolean previous) {
1536 StringBundler query = null;
1537
1538 if (orderByComparator != null) {
1539 query = new StringBundler(6 +
1540 (orderByComparator.getOrderByFields().length * 6));
1541 }
1542 else {
1543 query = new StringBundler(3);
1544 }
1545
1546 query.append(_SQL_SELECT_LAYOUTSETBRANCH_WHERE);
1547
1548 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
1549
1550 query.append(_FINDER_COLUMN_G_P_PRIVATELAYOUT_2);
1551
1552 if (orderByComparator != null) {
1553 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1554
1555 if (orderByConditionFields.length > 0) {
1556 query.append(WHERE_AND);
1557 }
1558
1559 for (int i = 0; i < orderByConditionFields.length; i++) {
1560 query.append(_ORDER_BY_ENTITY_ALIAS);
1561 query.append(orderByConditionFields[i]);
1562
1563 if ((i + 1) < orderByConditionFields.length) {
1564 if (orderByComparator.isAscending() ^ previous) {
1565 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1566 }
1567 else {
1568 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1569 }
1570 }
1571 else {
1572 if (orderByComparator.isAscending() ^ previous) {
1573 query.append(WHERE_GREATER_THAN);
1574 }
1575 else {
1576 query.append(WHERE_LESSER_THAN);
1577 }
1578 }
1579 }
1580
1581 query.append(ORDER_BY_CLAUSE);
1582
1583 String[] orderByFields = orderByComparator.getOrderByFields();
1584
1585 for (int i = 0; i < orderByFields.length; i++) {
1586 query.append(_ORDER_BY_ENTITY_ALIAS);
1587 query.append(orderByFields[i]);
1588
1589 if ((i + 1) < orderByFields.length) {
1590 if (orderByComparator.isAscending() ^ previous) {
1591 query.append(ORDER_BY_ASC_HAS_NEXT);
1592 }
1593 else {
1594 query.append(ORDER_BY_DESC_HAS_NEXT);
1595 }
1596 }
1597 else {
1598 if (orderByComparator.isAscending() ^ previous) {
1599 query.append(ORDER_BY_ASC);
1600 }
1601 else {
1602 query.append(ORDER_BY_DESC);
1603 }
1604 }
1605 }
1606 }
1607
1608 else {
1609 query.append(LayoutSetBranchModelImpl.ORDER_BY_JPQL);
1610 }
1611
1612 String sql = query.toString();
1613
1614 Query q = session.createQuery(sql);
1615
1616 q.setFirstResult(0);
1617 q.setMaxResults(2);
1618
1619 QueryPos qPos = QueryPos.getInstance(q);
1620
1621 qPos.add(groupId);
1622
1623 qPos.add(privateLayout);
1624
1625 if (orderByComparator != null) {
1626 Object[] values = orderByComparator.getOrderByConditionValues(layoutSetBranch);
1627
1628 for (Object value : values) {
1629 qPos.add(value);
1630 }
1631 }
1632
1633 List<LayoutSetBranch> list = q.list();
1634
1635 if (list.size() == 2) {
1636 return list.get(1);
1637 }
1638 else {
1639 return null;
1640 }
1641 }
1642
1643
1651 public List<LayoutSetBranch> filterFindByG_P(long groupId,
1652 boolean privateLayout) throws SystemException {
1653 return filterFindByG_P(groupId, privateLayout, QueryUtil.ALL_POS,
1654 QueryUtil.ALL_POS, null);
1655 }
1656
1657
1671 public List<LayoutSetBranch> filterFindByG_P(long groupId,
1672 boolean privateLayout, int start, int end) throws SystemException {
1673 return filterFindByG_P(groupId, privateLayout, start, end, null);
1674 }
1675
1676
1691 public List<LayoutSetBranch> filterFindByG_P(long groupId,
1692 boolean privateLayout, int start, int end,
1693 OrderByComparator orderByComparator) throws SystemException {
1694 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1695 return findByG_P(groupId, privateLayout, start, end,
1696 orderByComparator);
1697 }
1698
1699 StringBundler query = null;
1700
1701 if (orderByComparator != null) {
1702 query = new StringBundler(4 +
1703 (orderByComparator.getOrderByFields().length * 3));
1704 }
1705 else {
1706 query = new StringBundler(4);
1707 }
1708
1709 if (getDB().isSupportsInlineDistinct()) {
1710 query.append(_FILTER_SQL_SELECT_LAYOUTSETBRANCH_WHERE);
1711 }
1712 else {
1713 query.append(_FILTER_SQL_SELECT_LAYOUTSETBRANCH_NO_INLINE_DISTINCT_WHERE_1);
1714 }
1715
1716 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
1717
1718 query.append(_FINDER_COLUMN_G_P_PRIVATELAYOUT_2);
1719
1720 if (!getDB().isSupportsInlineDistinct()) {
1721 query.append(_FILTER_SQL_SELECT_LAYOUTSETBRANCH_NO_INLINE_DISTINCT_WHERE_2);
1722 }
1723
1724 if (orderByComparator != null) {
1725 if (getDB().isSupportsInlineDistinct()) {
1726 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1727 orderByComparator);
1728 }
1729 else {
1730 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
1731 orderByComparator);
1732 }
1733 }
1734
1735 else {
1736 if (getDB().isSupportsInlineDistinct()) {
1737 query.append(LayoutSetBranchModelImpl.ORDER_BY_JPQL);
1738 }
1739 else {
1740 query.append(LayoutSetBranchModelImpl.ORDER_BY_SQL);
1741 }
1742 }
1743
1744 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1745 LayoutSetBranch.class.getName(),
1746 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
1747
1748 Session session = null;
1749
1750 try {
1751 session = openSession();
1752
1753 SQLQuery q = session.createSQLQuery(sql);
1754
1755 if (getDB().isSupportsInlineDistinct()) {
1756 q.addEntity(_FILTER_ENTITY_ALIAS, LayoutSetBranchImpl.class);
1757 }
1758 else {
1759 q.addEntity(_FILTER_ENTITY_TABLE, LayoutSetBranchImpl.class);
1760 }
1761
1762 QueryPos qPos = QueryPos.getInstance(q);
1763
1764 qPos.add(groupId);
1765
1766 qPos.add(privateLayout);
1767
1768 return (List<LayoutSetBranch>)QueryUtil.list(q, getDialect(),
1769 start, end);
1770 }
1771 catch (Exception e) {
1772 throw processException(e);
1773 }
1774 finally {
1775 closeSession(session);
1776 }
1777 }
1778
1779
1790 public LayoutSetBranch[] filterFindByG_P_PrevAndNext(
1791 long layoutSetBranchId, long groupId, boolean privateLayout,
1792 OrderByComparator orderByComparator)
1793 throws NoSuchLayoutSetBranchException, SystemException {
1794 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1795 return findByG_P_PrevAndNext(layoutSetBranchId, groupId,
1796 privateLayout, orderByComparator);
1797 }
1798
1799 LayoutSetBranch layoutSetBranch = findByPrimaryKey(layoutSetBranchId);
1800
1801 Session session = null;
1802
1803 try {
1804 session = openSession();
1805
1806 LayoutSetBranch[] array = new LayoutSetBranchImpl[3];
1807
1808 array[0] = filterGetByG_P_PrevAndNext(session, layoutSetBranch,
1809 groupId, privateLayout, orderByComparator, true);
1810
1811 array[1] = layoutSetBranch;
1812
1813 array[2] = filterGetByG_P_PrevAndNext(session, layoutSetBranch,
1814 groupId, privateLayout, orderByComparator, false);
1815
1816 return array;
1817 }
1818 catch (Exception e) {
1819 throw processException(e);
1820 }
1821 finally {
1822 closeSession(session);
1823 }
1824 }
1825
1826 protected LayoutSetBranch filterGetByG_P_PrevAndNext(Session session,
1827 LayoutSetBranch layoutSetBranch, long groupId, boolean privateLayout,
1828 OrderByComparator orderByComparator, boolean previous) {
1829 StringBundler query = null;
1830
1831 if (orderByComparator != null) {
1832 query = new StringBundler(6 +
1833 (orderByComparator.getOrderByFields().length * 6));
1834 }
1835 else {
1836 query = new StringBundler(3);
1837 }
1838
1839 if (getDB().isSupportsInlineDistinct()) {
1840 query.append(_FILTER_SQL_SELECT_LAYOUTSETBRANCH_WHERE);
1841 }
1842 else {
1843 query.append(_FILTER_SQL_SELECT_LAYOUTSETBRANCH_NO_INLINE_DISTINCT_WHERE_1);
1844 }
1845
1846 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
1847
1848 query.append(_FINDER_COLUMN_G_P_PRIVATELAYOUT_2);
1849
1850 if (!getDB().isSupportsInlineDistinct()) {
1851 query.append(_FILTER_SQL_SELECT_LAYOUTSETBRANCH_NO_INLINE_DISTINCT_WHERE_2);
1852 }
1853
1854 if (orderByComparator != null) {
1855 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1856
1857 if (orderByConditionFields.length > 0) {
1858 query.append(WHERE_AND);
1859 }
1860
1861 for (int i = 0; i < orderByConditionFields.length; i++) {
1862 if (getDB().isSupportsInlineDistinct()) {
1863 query.append(_ORDER_BY_ENTITY_ALIAS);
1864 }
1865 else {
1866 query.append(_ORDER_BY_ENTITY_TABLE);
1867 }
1868
1869 query.append(orderByConditionFields[i]);
1870
1871 if ((i + 1) < orderByConditionFields.length) {
1872 if (orderByComparator.isAscending() ^ previous) {
1873 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1874 }
1875 else {
1876 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1877 }
1878 }
1879 else {
1880 if (orderByComparator.isAscending() ^ previous) {
1881 query.append(WHERE_GREATER_THAN);
1882 }
1883 else {
1884 query.append(WHERE_LESSER_THAN);
1885 }
1886 }
1887 }
1888
1889 query.append(ORDER_BY_CLAUSE);
1890
1891 String[] orderByFields = orderByComparator.getOrderByFields();
1892
1893 for (int i = 0; i < orderByFields.length; i++) {
1894 if (getDB().isSupportsInlineDistinct()) {
1895 query.append(_ORDER_BY_ENTITY_ALIAS);
1896 }
1897 else {
1898 query.append(_ORDER_BY_ENTITY_TABLE);
1899 }
1900
1901 query.append(orderByFields[i]);
1902
1903 if ((i + 1) < orderByFields.length) {
1904 if (orderByComparator.isAscending() ^ previous) {
1905 query.append(ORDER_BY_ASC_HAS_NEXT);
1906 }
1907 else {
1908 query.append(ORDER_BY_DESC_HAS_NEXT);
1909 }
1910 }
1911 else {
1912 if (orderByComparator.isAscending() ^ previous) {
1913 query.append(ORDER_BY_ASC);
1914 }
1915 else {
1916 query.append(ORDER_BY_DESC);
1917 }
1918 }
1919 }
1920 }
1921
1922 else {
1923 if (getDB().isSupportsInlineDistinct()) {
1924 query.append(LayoutSetBranchModelImpl.ORDER_BY_JPQL);
1925 }
1926 else {
1927 query.append(LayoutSetBranchModelImpl.ORDER_BY_SQL);
1928 }
1929 }
1930
1931 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1932 LayoutSetBranch.class.getName(),
1933 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
1934
1935 SQLQuery q = session.createSQLQuery(sql);
1936
1937 q.setFirstResult(0);
1938 q.setMaxResults(2);
1939
1940 if (getDB().isSupportsInlineDistinct()) {
1941 q.addEntity(_FILTER_ENTITY_ALIAS, LayoutSetBranchImpl.class);
1942 }
1943 else {
1944 q.addEntity(_FILTER_ENTITY_TABLE, LayoutSetBranchImpl.class);
1945 }
1946
1947 QueryPos qPos = QueryPos.getInstance(q);
1948
1949 qPos.add(groupId);
1950
1951 qPos.add(privateLayout);
1952
1953 if (orderByComparator != null) {
1954 Object[] values = orderByComparator.getOrderByConditionValues(layoutSetBranch);
1955
1956 for (Object value : values) {
1957 qPos.add(value);
1958 }
1959 }
1960
1961 List<LayoutSetBranch> list = q.list();
1962
1963 if (list.size() == 2) {
1964 return list.get(1);
1965 }
1966 else {
1967 return null;
1968 }
1969 }
1970
1971
1981 public LayoutSetBranch findByG_P_N(long groupId, boolean privateLayout,
1982 String name) throws NoSuchLayoutSetBranchException, SystemException {
1983 LayoutSetBranch layoutSetBranch = fetchByG_P_N(groupId, privateLayout,
1984 name);
1985
1986 if (layoutSetBranch == null) {
1987 StringBundler msg = new StringBundler(8);
1988
1989 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1990
1991 msg.append("groupId=");
1992 msg.append(groupId);
1993
1994 msg.append(", privateLayout=");
1995 msg.append(privateLayout);
1996
1997 msg.append(", name=");
1998 msg.append(name);
1999
2000 msg.append(StringPool.CLOSE_CURLY_BRACE);
2001
2002 if (_log.isWarnEnabled()) {
2003 _log.warn(msg.toString());
2004 }
2005
2006 throw new NoSuchLayoutSetBranchException(msg.toString());
2007 }
2008
2009 return layoutSetBranch;
2010 }
2011
2012
2021 public LayoutSetBranch fetchByG_P_N(long groupId, boolean privateLayout,
2022 String name) throws SystemException {
2023 return fetchByG_P_N(groupId, privateLayout, name, true);
2024 }
2025
2026
2036 public LayoutSetBranch fetchByG_P_N(long groupId, boolean privateLayout,
2037 String name, boolean retrieveFromCache) throws SystemException {
2038 Object[] finderArgs = new Object[] { groupId, privateLayout, name };
2039
2040 Object result = null;
2041
2042 if (retrieveFromCache) {
2043 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_P_N,
2044 finderArgs, this);
2045 }
2046
2047 if (result instanceof LayoutSetBranch) {
2048 LayoutSetBranch layoutSetBranch = (LayoutSetBranch)result;
2049
2050 if ((groupId != layoutSetBranch.getGroupId()) ||
2051 (privateLayout != layoutSetBranch.getPrivateLayout()) ||
2052 !Validator.equals(name, layoutSetBranch.getName())) {
2053 result = null;
2054 }
2055 }
2056
2057 if (result == null) {
2058 StringBundler query = new StringBundler(5);
2059
2060 query.append(_SQL_SELECT_LAYOUTSETBRANCH_WHERE);
2061
2062 query.append(_FINDER_COLUMN_G_P_N_GROUPID_2);
2063
2064 query.append(_FINDER_COLUMN_G_P_N_PRIVATELAYOUT_2);
2065
2066 if (name == null) {
2067 query.append(_FINDER_COLUMN_G_P_N_NAME_1);
2068 }
2069 else {
2070 if (name.equals(StringPool.BLANK)) {
2071 query.append(_FINDER_COLUMN_G_P_N_NAME_3);
2072 }
2073 else {
2074 query.append(_FINDER_COLUMN_G_P_N_NAME_2);
2075 }
2076 }
2077
2078 query.append(LayoutSetBranchModelImpl.ORDER_BY_JPQL);
2079
2080 String sql = query.toString();
2081
2082 Session session = null;
2083
2084 try {
2085 session = openSession();
2086
2087 Query q = session.createQuery(sql);
2088
2089 QueryPos qPos = QueryPos.getInstance(q);
2090
2091 qPos.add(groupId);
2092
2093 qPos.add(privateLayout);
2094
2095 if (name != null) {
2096 qPos.add(name);
2097 }
2098
2099 List<LayoutSetBranch> list = q.list();
2100
2101 result = list;
2102
2103 LayoutSetBranch layoutSetBranch = null;
2104
2105 if (list.isEmpty()) {
2106 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P_N,
2107 finderArgs, list);
2108 }
2109 else {
2110 layoutSetBranch = list.get(0);
2111
2112 cacheResult(layoutSetBranch);
2113
2114 if ((layoutSetBranch.getGroupId() != groupId) ||
2115 (layoutSetBranch.getPrivateLayout() != privateLayout) ||
2116 (layoutSetBranch.getName() == null) ||
2117 !layoutSetBranch.getName().equals(name)) {
2118 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P_N,
2119 finderArgs, layoutSetBranch);
2120 }
2121 }
2122
2123 return layoutSetBranch;
2124 }
2125 catch (Exception e) {
2126 throw processException(e);
2127 }
2128 finally {
2129 if (result == null) {
2130 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_P_N,
2131 finderArgs);
2132 }
2133
2134 closeSession(session);
2135 }
2136 }
2137 else {
2138 if (result instanceof List<?>) {
2139 return null;
2140 }
2141 else {
2142 return (LayoutSetBranch)result;
2143 }
2144 }
2145 }
2146
2147
2153 public List<LayoutSetBranch> findAll() throws SystemException {
2154 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2155 }
2156
2157
2169 public List<LayoutSetBranch> findAll(int start, int end)
2170 throws SystemException {
2171 return findAll(start, end, null);
2172 }
2173
2174
2187 public List<LayoutSetBranch> findAll(int start, int end,
2188 OrderByComparator orderByComparator) throws SystemException {
2189 FinderPath finderPath = null;
2190 Object[] finderArgs = new Object[] { start, end, orderByComparator };
2191
2192 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2193 (orderByComparator == null)) {
2194 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
2195 finderArgs = FINDER_ARGS_EMPTY;
2196 }
2197 else {
2198 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
2199 finderArgs = new Object[] { start, end, orderByComparator };
2200 }
2201
2202 List<LayoutSetBranch> list = (List<LayoutSetBranch>)FinderCacheUtil.getResult(finderPath,
2203 finderArgs, this);
2204
2205 if (list == null) {
2206 StringBundler query = null;
2207 String sql = null;
2208
2209 if (orderByComparator != null) {
2210 query = new StringBundler(2 +
2211 (orderByComparator.getOrderByFields().length * 3));
2212
2213 query.append(_SQL_SELECT_LAYOUTSETBRANCH);
2214
2215 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2216 orderByComparator);
2217
2218 sql = query.toString();
2219 }
2220 else {
2221 sql = _SQL_SELECT_LAYOUTSETBRANCH.concat(LayoutSetBranchModelImpl.ORDER_BY_JPQL);
2222 }
2223
2224 Session session = null;
2225
2226 try {
2227 session = openSession();
2228
2229 Query q = session.createQuery(sql);
2230
2231 if (orderByComparator == null) {
2232 list = (List<LayoutSetBranch>)QueryUtil.list(q,
2233 getDialect(), start, end, false);
2234
2235 Collections.sort(list);
2236 }
2237 else {
2238 list = (List<LayoutSetBranch>)QueryUtil.list(q,
2239 getDialect(), start, end);
2240 }
2241 }
2242 catch (Exception e) {
2243 throw processException(e);
2244 }
2245 finally {
2246 if (list == null) {
2247 FinderCacheUtil.removeResult(finderPath, finderArgs);
2248 }
2249 else {
2250 cacheResult(list);
2251
2252 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2253 }
2254
2255 closeSession(session);
2256 }
2257 }
2258
2259 return list;
2260 }
2261
2262
2268 public void removeByGroupId(long groupId) throws SystemException {
2269 for (LayoutSetBranch layoutSetBranch : findByGroupId(groupId)) {
2270 remove(layoutSetBranch);
2271 }
2272 }
2273
2274
2281 public void removeByG_P(long groupId, boolean privateLayout)
2282 throws SystemException {
2283 for (LayoutSetBranch layoutSetBranch : findByG_P(groupId, privateLayout)) {
2284 remove(layoutSetBranch);
2285 }
2286 }
2287
2288
2296 public void removeByG_P_N(long groupId, boolean privateLayout, String name)
2297 throws NoSuchLayoutSetBranchException, SystemException {
2298 LayoutSetBranch layoutSetBranch = findByG_P_N(groupId, privateLayout,
2299 name);
2300
2301 remove(layoutSetBranch);
2302 }
2303
2304
2309 public void removeAll() throws SystemException {
2310 for (LayoutSetBranch layoutSetBranch : findAll()) {
2311 remove(layoutSetBranch);
2312 }
2313 }
2314
2315
2322 public int countByGroupId(long groupId) throws SystemException {
2323 Object[] finderArgs = new Object[] { groupId };
2324
2325 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
2326 finderArgs, this);
2327
2328 if (count == null) {
2329 StringBundler query = new StringBundler(2);
2330
2331 query.append(_SQL_COUNT_LAYOUTSETBRANCH_WHERE);
2332
2333 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2334
2335 String sql = query.toString();
2336
2337 Session session = null;
2338
2339 try {
2340 session = openSession();
2341
2342 Query q = session.createQuery(sql);
2343
2344 QueryPos qPos = QueryPos.getInstance(q);
2345
2346 qPos.add(groupId);
2347
2348 count = (Long)q.uniqueResult();
2349 }
2350 catch (Exception e) {
2351 throw processException(e);
2352 }
2353 finally {
2354 if (count == null) {
2355 count = Long.valueOf(0);
2356 }
2357
2358 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
2359 finderArgs, count);
2360
2361 closeSession(session);
2362 }
2363 }
2364
2365 return count.intValue();
2366 }
2367
2368
2375 public int filterCountByGroupId(long groupId) throws SystemException {
2376 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2377 return countByGroupId(groupId);
2378 }
2379
2380 StringBundler query = new StringBundler(2);
2381
2382 query.append(_FILTER_SQL_COUNT_LAYOUTSETBRANCH_WHERE);
2383
2384 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2385
2386 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2387 LayoutSetBranch.class.getName(),
2388 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2389
2390 Session session = null;
2391
2392 try {
2393 session = openSession();
2394
2395 SQLQuery q = session.createSQLQuery(sql);
2396
2397 q.addScalar(COUNT_COLUMN_NAME,
2398 com.liferay.portal.kernel.dao.orm.Type.LONG);
2399
2400 QueryPos qPos = QueryPos.getInstance(q);
2401
2402 qPos.add(groupId);
2403
2404 Long count = (Long)q.uniqueResult();
2405
2406 return count.intValue();
2407 }
2408 catch (Exception e) {
2409 throw processException(e);
2410 }
2411 finally {
2412 closeSession(session);
2413 }
2414 }
2415
2416
2424 public int countByG_P(long groupId, boolean privateLayout)
2425 throws SystemException {
2426 Object[] finderArgs = new Object[] { groupId, privateLayout };
2427
2428 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_P,
2429 finderArgs, this);
2430
2431 if (count == null) {
2432 StringBundler query = new StringBundler(3);
2433
2434 query.append(_SQL_COUNT_LAYOUTSETBRANCH_WHERE);
2435
2436 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
2437
2438 query.append(_FINDER_COLUMN_G_P_PRIVATELAYOUT_2);
2439
2440 String sql = query.toString();
2441
2442 Session session = null;
2443
2444 try {
2445 session = openSession();
2446
2447 Query q = session.createQuery(sql);
2448
2449 QueryPos qPos = QueryPos.getInstance(q);
2450
2451 qPos.add(groupId);
2452
2453 qPos.add(privateLayout);
2454
2455 count = (Long)q.uniqueResult();
2456 }
2457 catch (Exception e) {
2458 throw processException(e);
2459 }
2460 finally {
2461 if (count == null) {
2462 count = Long.valueOf(0);
2463 }
2464
2465 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_P, finderArgs,
2466 count);
2467
2468 closeSession(session);
2469 }
2470 }
2471
2472 return count.intValue();
2473 }
2474
2475
2483 public int filterCountByG_P(long groupId, boolean privateLayout)
2484 throws SystemException {
2485 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2486 return countByG_P(groupId, privateLayout);
2487 }
2488
2489 StringBundler query = new StringBundler(3);
2490
2491 query.append(_FILTER_SQL_COUNT_LAYOUTSETBRANCH_WHERE);
2492
2493 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
2494
2495 query.append(_FINDER_COLUMN_G_P_PRIVATELAYOUT_2);
2496
2497 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2498 LayoutSetBranch.class.getName(),
2499 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2500
2501 Session session = null;
2502
2503 try {
2504 session = openSession();
2505
2506 SQLQuery q = session.createSQLQuery(sql);
2507
2508 q.addScalar(COUNT_COLUMN_NAME,
2509 com.liferay.portal.kernel.dao.orm.Type.LONG);
2510
2511 QueryPos qPos = QueryPos.getInstance(q);
2512
2513 qPos.add(groupId);
2514
2515 qPos.add(privateLayout);
2516
2517 Long count = (Long)q.uniqueResult();
2518
2519 return count.intValue();
2520 }
2521 catch (Exception e) {
2522 throw processException(e);
2523 }
2524 finally {
2525 closeSession(session);
2526 }
2527 }
2528
2529
2538 public int countByG_P_N(long groupId, boolean privateLayout, String name)
2539 throws SystemException {
2540 Object[] finderArgs = new Object[] { groupId, privateLayout, name };
2541
2542 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_P_N,
2543 finderArgs, this);
2544
2545 if (count == null) {
2546 StringBundler query = new StringBundler(4);
2547
2548 query.append(_SQL_COUNT_LAYOUTSETBRANCH_WHERE);
2549
2550 query.append(_FINDER_COLUMN_G_P_N_GROUPID_2);
2551
2552 query.append(_FINDER_COLUMN_G_P_N_PRIVATELAYOUT_2);
2553
2554 if (name == null) {
2555 query.append(_FINDER_COLUMN_G_P_N_NAME_1);
2556 }
2557 else {
2558 if (name.equals(StringPool.BLANK)) {
2559 query.append(_FINDER_COLUMN_G_P_N_NAME_3);
2560 }
2561 else {
2562 query.append(_FINDER_COLUMN_G_P_N_NAME_2);
2563 }
2564 }
2565
2566 String sql = query.toString();
2567
2568 Session session = null;
2569
2570 try {
2571 session = openSession();
2572
2573 Query q = session.createQuery(sql);
2574
2575 QueryPos qPos = QueryPos.getInstance(q);
2576
2577 qPos.add(groupId);
2578
2579 qPos.add(privateLayout);
2580
2581 if (name != null) {
2582 qPos.add(name);
2583 }
2584
2585 count = (Long)q.uniqueResult();
2586 }
2587 catch (Exception e) {
2588 throw processException(e);
2589 }
2590 finally {
2591 if (count == null) {
2592 count = Long.valueOf(0);
2593 }
2594
2595 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_P_N,
2596 finderArgs, count);
2597
2598 closeSession(session);
2599 }
2600 }
2601
2602 return count.intValue();
2603 }
2604
2605
2611 public int countAll() throws SystemException {
2612 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
2613 FINDER_ARGS_EMPTY, this);
2614
2615 if (count == null) {
2616 Session session = null;
2617
2618 try {
2619 session = openSession();
2620
2621 Query q = session.createQuery(_SQL_COUNT_LAYOUTSETBRANCH);
2622
2623 count = (Long)q.uniqueResult();
2624 }
2625 catch (Exception e) {
2626 throw processException(e);
2627 }
2628 finally {
2629 if (count == null) {
2630 count = Long.valueOf(0);
2631 }
2632
2633 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
2634 FINDER_ARGS_EMPTY, count);
2635
2636 closeSession(session);
2637 }
2638 }
2639
2640 return count.intValue();
2641 }
2642
2643
2646 public void afterPropertiesSet() {
2647 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
2648 com.liferay.portal.util.PropsUtil.get(
2649 "value.object.listener.com.liferay.portal.model.LayoutSetBranch")));
2650
2651 if (listenerClassNames.length > 0) {
2652 try {
2653 List<ModelListener<LayoutSetBranch>> listenersList = new ArrayList<ModelListener<LayoutSetBranch>>();
2654
2655 for (String listenerClassName : listenerClassNames) {
2656 listenersList.add((ModelListener<LayoutSetBranch>)InstanceFactory.newInstance(
2657 listenerClassName));
2658 }
2659
2660 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
2661 }
2662 catch (Exception e) {
2663 _log.error(e);
2664 }
2665 }
2666 }
2667
2668 public void destroy() {
2669 EntityCacheUtil.removeCache(LayoutSetBranchImpl.class.getName());
2670 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
2671 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2672 }
2673
2674 @BeanReference(type = AccountPersistence.class)
2675 protected AccountPersistence accountPersistence;
2676 @BeanReference(type = AddressPersistence.class)
2677 protected AddressPersistence addressPersistence;
2678 @BeanReference(type = BrowserTrackerPersistence.class)
2679 protected BrowserTrackerPersistence browserTrackerPersistence;
2680 @BeanReference(type = ClassNamePersistence.class)
2681 protected ClassNamePersistence classNamePersistence;
2682 @BeanReference(type = ClusterGroupPersistence.class)
2683 protected ClusterGroupPersistence clusterGroupPersistence;
2684 @BeanReference(type = CompanyPersistence.class)
2685 protected CompanyPersistence companyPersistence;
2686 @BeanReference(type = ContactPersistence.class)
2687 protected ContactPersistence contactPersistence;
2688 @BeanReference(type = CountryPersistence.class)
2689 protected CountryPersistence countryPersistence;
2690 @BeanReference(type = EmailAddressPersistence.class)
2691 protected EmailAddressPersistence emailAddressPersistence;
2692 @BeanReference(type = GroupPersistence.class)
2693 protected GroupPersistence groupPersistence;
2694 @BeanReference(type = ImagePersistence.class)
2695 protected ImagePersistence imagePersistence;
2696 @BeanReference(type = LayoutPersistence.class)
2697 protected LayoutPersistence layoutPersistence;
2698 @BeanReference(type = LayoutBranchPersistence.class)
2699 protected LayoutBranchPersistence layoutBranchPersistence;
2700 @BeanReference(type = LayoutPrototypePersistence.class)
2701 protected LayoutPrototypePersistence layoutPrototypePersistence;
2702 @BeanReference(type = LayoutRevisionPersistence.class)
2703 protected LayoutRevisionPersistence layoutRevisionPersistence;
2704 @BeanReference(type = LayoutSetPersistence.class)
2705 protected LayoutSetPersistence layoutSetPersistence;
2706 @BeanReference(type = LayoutSetBranchPersistence.class)
2707 protected LayoutSetBranchPersistence layoutSetBranchPersistence;
2708 @BeanReference(type = LayoutSetPrototypePersistence.class)
2709 protected LayoutSetPrototypePersistence layoutSetPrototypePersistence;
2710 @BeanReference(type = ListTypePersistence.class)
2711 protected ListTypePersistence listTypePersistence;
2712 @BeanReference(type = LockPersistence.class)
2713 protected LockPersistence lockPersistence;
2714 @BeanReference(type = MembershipRequestPersistence.class)
2715 protected MembershipRequestPersistence membershipRequestPersistence;
2716 @BeanReference(type = OrganizationPersistence.class)
2717 protected OrganizationPersistence organizationPersistence;
2718 @BeanReference(type = OrgGroupPermissionPersistence.class)
2719 protected OrgGroupPermissionPersistence orgGroupPermissionPersistence;
2720 @BeanReference(type = OrgGroupRolePersistence.class)
2721 protected OrgGroupRolePersistence orgGroupRolePersistence;
2722 @BeanReference(type = OrgLaborPersistence.class)
2723 protected OrgLaborPersistence orgLaborPersistence;
2724 @BeanReference(type = PasswordPolicyPersistence.class)
2725 protected PasswordPolicyPersistence passwordPolicyPersistence;
2726 @BeanReference(type = PasswordPolicyRelPersistence.class)
2727 protected PasswordPolicyRelPersistence passwordPolicyRelPersistence;
2728 @BeanReference(type = PasswordTrackerPersistence.class)
2729 protected PasswordTrackerPersistence passwordTrackerPersistence;
2730 @BeanReference(type = PermissionPersistence.class)
2731 protected PermissionPersistence permissionPersistence;
2732 @BeanReference(type = PhonePersistence.class)
2733 protected PhonePersistence phonePersistence;
2734 @BeanReference(type = PluginSettingPersistence.class)
2735 protected PluginSettingPersistence pluginSettingPersistence;
2736 @BeanReference(type = PortalPreferencesPersistence.class)
2737 protected PortalPreferencesPersistence portalPreferencesPersistence;
2738 @BeanReference(type = PortletPersistence.class)
2739 protected PortletPersistence portletPersistence;
2740 @BeanReference(type = PortletItemPersistence.class)
2741 protected PortletItemPersistence portletItemPersistence;
2742 @BeanReference(type = PortletPreferencesPersistence.class)
2743 protected PortletPreferencesPersistence portletPreferencesPersistence;
2744 @BeanReference(type = RegionPersistence.class)
2745 protected RegionPersistence regionPersistence;
2746 @BeanReference(type = ReleasePersistence.class)
2747 protected ReleasePersistence releasePersistence;
2748 @BeanReference(type = RepositoryPersistence.class)
2749 protected RepositoryPersistence repositoryPersistence;
2750 @BeanReference(type = RepositoryEntryPersistence.class)
2751 protected RepositoryEntryPersistence repositoryEntryPersistence;
2752 @BeanReference(type = ResourcePersistence.class)
2753 protected ResourcePersistence resourcePersistence;
2754 @BeanReference(type = ResourceActionPersistence.class)
2755 protected ResourceActionPersistence resourceActionPersistence;
2756 @BeanReference(type = ResourceBlockPersistence.class)
2757 protected ResourceBlockPersistence resourceBlockPersistence;
2758 @BeanReference(type = ResourceBlockPermissionPersistence.class)
2759 protected ResourceBlockPermissionPersistence resourceBlockPermissionPersistence;
2760 @BeanReference(type = ResourceCodePersistence.class)
2761 protected ResourceCodePersistence resourceCodePersistence;
2762 @BeanReference(type = ResourcePermissionPersistence.class)
2763 protected ResourcePermissionPersistence resourcePermissionPersistence;
2764 @BeanReference(type = ResourceTypePermissionPersistence.class)
2765 protected ResourceTypePermissionPersistence resourceTypePermissionPersistence;
2766 @BeanReference(type = RolePersistence.class)
2767 protected RolePersistence rolePersistence;
2768 @BeanReference(type = ServiceComponentPersistence.class)
2769 protected ServiceComponentPersistence serviceComponentPersistence;
2770 @BeanReference(type = ShardPersistence.class)
2771 protected ShardPersistence shardPersistence;
2772 @BeanReference(type = SubscriptionPersistence.class)
2773 protected SubscriptionPersistence subscriptionPersistence;
2774 @BeanReference(type = TeamPersistence.class)
2775 protected TeamPersistence teamPersistence;
2776 @BeanReference(type = TicketPersistence.class)
2777 protected TicketPersistence ticketPersistence;
2778 @BeanReference(type = UserPersistence.class)
2779 protected UserPersistence userPersistence;
2780 @BeanReference(type = UserGroupPersistence.class)
2781 protected UserGroupPersistence userGroupPersistence;
2782 @BeanReference(type = UserGroupGroupRolePersistence.class)
2783 protected UserGroupGroupRolePersistence userGroupGroupRolePersistence;
2784 @BeanReference(type = UserGroupRolePersistence.class)
2785 protected UserGroupRolePersistence userGroupRolePersistence;
2786 @BeanReference(type = UserIdMapperPersistence.class)
2787 protected UserIdMapperPersistence userIdMapperPersistence;
2788 @BeanReference(type = UserNotificationEventPersistence.class)
2789 protected UserNotificationEventPersistence userNotificationEventPersistence;
2790 @BeanReference(type = UserTrackerPersistence.class)
2791 protected UserTrackerPersistence userTrackerPersistence;
2792 @BeanReference(type = UserTrackerPathPersistence.class)
2793 protected UserTrackerPathPersistence userTrackerPathPersistence;
2794 @BeanReference(type = VirtualHostPersistence.class)
2795 protected VirtualHostPersistence virtualHostPersistence;
2796 @BeanReference(type = WebDAVPropsPersistence.class)
2797 protected WebDAVPropsPersistence webDAVPropsPersistence;
2798 @BeanReference(type = WebsitePersistence.class)
2799 protected WebsitePersistence websitePersistence;
2800 @BeanReference(type = WorkflowDefinitionLinkPersistence.class)
2801 protected WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
2802 @BeanReference(type = WorkflowInstanceLinkPersistence.class)
2803 protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
2804 private static final String _SQL_SELECT_LAYOUTSETBRANCH = "SELECT layoutSetBranch FROM LayoutSetBranch layoutSetBranch";
2805 private static final String _SQL_SELECT_LAYOUTSETBRANCH_WHERE = "SELECT layoutSetBranch FROM LayoutSetBranch layoutSetBranch WHERE ";
2806 private static final String _SQL_COUNT_LAYOUTSETBRANCH = "SELECT COUNT(layoutSetBranch) FROM LayoutSetBranch layoutSetBranch";
2807 private static final String _SQL_COUNT_LAYOUTSETBRANCH_WHERE = "SELECT COUNT(layoutSetBranch) FROM LayoutSetBranch layoutSetBranch WHERE ";
2808 private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "layoutSetBranch.groupId = ?";
2809 private static final String _FINDER_COLUMN_G_P_GROUPID_2 = "layoutSetBranch.groupId = ? AND ";
2810 private static final String _FINDER_COLUMN_G_P_PRIVATELAYOUT_2 = "layoutSetBranch.privateLayout = ?";
2811 private static final String _FINDER_COLUMN_G_P_N_GROUPID_2 = "layoutSetBranch.groupId = ? AND ";
2812 private static final String _FINDER_COLUMN_G_P_N_PRIVATELAYOUT_2 = "layoutSetBranch.privateLayout = ? AND ";
2813 private static final String _FINDER_COLUMN_G_P_N_NAME_1 = "layoutSetBranch.name IS NULL";
2814 private static final String _FINDER_COLUMN_G_P_N_NAME_2 = "layoutSetBranch.name = ?";
2815 private static final String _FINDER_COLUMN_G_P_N_NAME_3 = "(layoutSetBranch.name IS NULL OR layoutSetBranch.name = ?)";
2816 private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "layoutSetBranch.layoutSetBranchId";
2817 private static final String _FILTER_SQL_SELECT_LAYOUTSETBRANCH_WHERE = "SELECT DISTINCT {layoutSetBranch.*} FROM LayoutSetBranch layoutSetBranch WHERE ";
2818 private static final String _FILTER_SQL_SELECT_LAYOUTSETBRANCH_NO_INLINE_DISTINCT_WHERE_1 =
2819 "SELECT {LayoutSetBranch.*} FROM (SELECT DISTINCT layoutSetBranch.layoutSetBranchId FROM LayoutSetBranch layoutSetBranch WHERE ";
2820 private static final String _FILTER_SQL_SELECT_LAYOUTSETBRANCH_NO_INLINE_DISTINCT_WHERE_2 =
2821 ") TEMP_TABLE INNER JOIN LayoutSetBranch ON TEMP_TABLE.layoutSetBranchId = LayoutSetBranch.layoutSetBranchId";
2822 private static final String _FILTER_SQL_COUNT_LAYOUTSETBRANCH_WHERE = "SELECT COUNT(DISTINCT layoutSetBranch.layoutSetBranchId) AS COUNT_VALUE FROM LayoutSetBranch layoutSetBranch WHERE ";
2823 private static final String _FILTER_ENTITY_ALIAS = "layoutSetBranch";
2824 private static final String _FILTER_ENTITY_TABLE = "LayoutSetBranch";
2825 private static final String _ORDER_BY_ENTITY_ALIAS = "layoutSetBranch.";
2826 private static final String _ORDER_BY_ENTITY_TABLE = "LayoutSetBranch.";
2827 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No LayoutSetBranch exists with the primary key ";
2828 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No LayoutSetBranch exists with the key {";
2829 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
2830 private static Log _log = LogFactoryUtil.getLog(LayoutSetBranchPersistenceImpl.class);
2831 private static LayoutSetBranch _nullLayoutSetBranch = new LayoutSetBranchImpl() {
2832 @Override
2833 public Object clone() {
2834 return this;
2835 }
2836
2837 @Override
2838 public CacheModel<LayoutSetBranch> toCacheModel() {
2839 return _nullLayoutSetBranchCacheModel;
2840 }
2841 };
2842
2843 private static CacheModel<LayoutSetBranch> _nullLayoutSetBranchCacheModel = new CacheModel<LayoutSetBranch>() {
2844 public LayoutSetBranch toEntityModel() {
2845 return _nullLayoutSetBranch;
2846 }
2847 };
2848 }