001
014
015 package com.liferay.portal.service.persistence;
016
017 import com.liferay.portal.NoSuchLayoutSetException;
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.Session;
028 import com.liferay.portal.kernel.exception.SystemException;
029 import com.liferay.portal.kernel.log.Log;
030 import com.liferay.portal.kernel.log.LogFactoryUtil;
031 import com.liferay.portal.kernel.util.GetterUtil;
032 import com.liferay.portal.kernel.util.InstanceFactory;
033 import com.liferay.portal.kernel.util.OrderByComparator;
034 import com.liferay.portal.kernel.util.StringBundler;
035 import com.liferay.portal.kernel.util.StringPool;
036 import com.liferay.portal.kernel.util.StringUtil;
037 import com.liferay.portal.kernel.util.Validator;
038 import com.liferay.portal.model.CacheModel;
039 import com.liferay.portal.model.LayoutSet;
040 import com.liferay.portal.model.ModelListener;
041 import com.liferay.portal.model.impl.LayoutSetImpl;
042 import com.liferay.portal.model.impl.LayoutSetModelImpl;
043 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
044
045 import java.io.Serializable;
046
047 import java.util.ArrayList;
048 import java.util.Collections;
049 import java.util.List;
050
051
063 public class LayoutSetPersistenceImpl extends BasePersistenceImpl<LayoutSet>
064 implements LayoutSetPersistence {
065
070 public static final String FINDER_CLASS_NAME_ENTITY = LayoutSetImpl.class.getName();
071 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
072 ".List1";
073 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
074 ".List2";
075 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(LayoutSetModelImpl.ENTITY_CACHE_ENABLED,
076 LayoutSetModelImpl.FINDER_CACHE_ENABLED, LayoutSetImpl.class,
077 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByGroupId",
078 new String[] {
079 Long.class.getName(),
080
081 "java.lang.Integer", "java.lang.Integer",
082 "com.liferay.portal.kernel.util.OrderByComparator"
083 });
084 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID =
085 new FinderPath(LayoutSetModelImpl.ENTITY_CACHE_ENABLED,
086 LayoutSetModelImpl.FINDER_CACHE_ENABLED, LayoutSetImpl.class,
087 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByGroupId",
088 new String[] { Long.class.getName() },
089 LayoutSetModelImpl.GROUPID_COLUMN_BITMASK);
090 public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(LayoutSetModelImpl.ENTITY_CACHE_ENABLED,
091 LayoutSetModelImpl.FINDER_CACHE_ENABLED, Long.class,
092 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId",
093 new String[] { Long.class.getName() });
094 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_LAYOUTSETPROTOTYPEUUID =
095 new FinderPath(LayoutSetModelImpl.ENTITY_CACHE_ENABLED,
096 LayoutSetModelImpl.FINDER_CACHE_ENABLED, LayoutSetImpl.class,
097 FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
098 "findByLayoutSetPrototypeUuid",
099 new String[] {
100 String.class.getName(),
101
102 "java.lang.Integer", "java.lang.Integer",
103 "com.liferay.portal.kernel.util.OrderByComparator"
104 });
105 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LAYOUTSETPROTOTYPEUUID =
106 new FinderPath(LayoutSetModelImpl.ENTITY_CACHE_ENABLED,
107 LayoutSetModelImpl.FINDER_CACHE_ENABLED, LayoutSetImpl.class,
108 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
109 "findByLayoutSetPrototypeUuid",
110 new String[] { String.class.getName() },
111 LayoutSetModelImpl.LAYOUTSETPROTOTYPEUUID_COLUMN_BITMASK);
112 public static final FinderPath FINDER_PATH_COUNT_BY_LAYOUTSETPROTOTYPEUUID = new FinderPath(LayoutSetModelImpl.ENTITY_CACHE_ENABLED,
113 LayoutSetModelImpl.FINDER_CACHE_ENABLED, Long.class,
114 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
115 "countByLayoutSetPrototypeUuid",
116 new String[] { String.class.getName() });
117 public static final FinderPath FINDER_PATH_FETCH_BY_G_P = new FinderPath(LayoutSetModelImpl.ENTITY_CACHE_ENABLED,
118 LayoutSetModelImpl.FINDER_CACHE_ENABLED, LayoutSetImpl.class,
119 FINDER_CLASS_NAME_ENTITY, "fetchByG_P",
120 new String[] { Long.class.getName(), Boolean.class.getName() },
121 LayoutSetModelImpl.GROUPID_COLUMN_BITMASK |
122 LayoutSetModelImpl.PRIVATELAYOUT_COLUMN_BITMASK);
123 public static final FinderPath FINDER_PATH_COUNT_BY_G_P = new FinderPath(LayoutSetModelImpl.ENTITY_CACHE_ENABLED,
124 LayoutSetModelImpl.FINDER_CACHE_ENABLED, Long.class,
125 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_P",
126 new String[] { Long.class.getName(), Boolean.class.getName() });
127 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(LayoutSetModelImpl.ENTITY_CACHE_ENABLED,
128 LayoutSetModelImpl.FINDER_CACHE_ENABLED, LayoutSetImpl.class,
129 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
130 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(LayoutSetModelImpl.ENTITY_CACHE_ENABLED,
131 LayoutSetModelImpl.FINDER_CACHE_ENABLED, LayoutSetImpl.class,
132 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
133 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(LayoutSetModelImpl.ENTITY_CACHE_ENABLED,
134 LayoutSetModelImpl.FINDER_CACHE_ENABLED, Long.class,
135 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
136
137
142 public void cacheResult(LayoutSet layoutSet) {
143 EntityCacheUtil.putResult(LayoutSetModelImpl.ENTITY_CACHE_ENABLED,
144 LayoutSetImpl.class, layoutSet.getPrimaryKey(), layoutSet);
145
146 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P,
147 new Object[] {
148 Long.valueOf(layoutSet.getGroupId()),
149 Boolean.valueOf(layoutSet.getPrivateLayout())
150 }, layoutSet);
151
152 layoutSet.resetOriginalValues();
153 }
154
155
160 public void cacheResult(List<LayoutSet> layoutSets) {
161 for (LayoutSet layoutSet : layoutSets) {
162 if (EntityCacheUtil.getResult(
163 LayoutSetModelImpl.ENTITY_CACHE_ENABLED,
164 LayoutSetImpl.class, layoutSet.getPrimaryKey()) == null) {
165 cacheResult(layoutSet);
166 }
167 else {
168 layoutSet.resetOriginalValues();
169 }
170 }
171 }
172
173
180 @Override
181 public void clearCache() {
182 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
183 CacheRegistryUtil.clear(LayoutSetImpl.class.getName());
184 }
185
186 EntityCacheUtil.clearCache(LayoutSetImpl.class.getName());
187
188 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
189 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
190 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
191 }
192
193
200 @Override
201 public void clearCache(LayoutSet layoutSet) {
202 EntityCacheUtil.removeResult(LayoutSetModelImpl.ENTITY_CACHE_ENABLED,
203 LayoutSetImpl.class, layoutSet.getPrimaryKey());
204
205 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
206 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
207
208 clearUniqueFindersCache(layoutSet);
209 }
210
211 @Override
212 public void clearCache(List<LayoutSet> layoutSets) {
213 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
214 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
215
216 for (LayoutSet layoutSet : layoutSets) {
217 EntityCacheUtil.removeResult(LayoutSetModelImpl.ENTITY_CACHE_ENABLED,
218 LayoutSetImpl.class, layoutSet.getPrimaryKey());
219
220 clearUniqueFindersCache(layoutSet);
221 }
222 }
223
224 protected void cacheUniqueFindersCache(LayoutSet layoutSet) {
225 if (layoutSet.isNew()) {
226 Object[] args = new Object[] {
227 Long.valueOf(layoutSet.getGroupId()),
228 Boolean.valueOf(layoutSet.getPrivateLayout())
229 };
230
231 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_P, args,
232 Long.valueOf(1));
233 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P, args, layoutSet);
234 }
235 else {
236 LayoutSetModelImpl layoutSetModelImpl = (LayoutSetModelImpl)layoutSet;
237
238 if ((layoutSetModelImpl.getColumnBitmask() &
239 FINDER_PATH_FETCH_BY_G_P.getColumnBitmask()) != 0) {
240 Object[] args = new Object[] {
241 Long.valueOf(layoutSet.getGroupId()),
242 Boolean.valueOf(layoutSet.getPrivateLayout())
243 };
244
245 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_P, args,
246 Long.valueOf(1));
247 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P, args,
248 layoutSet);
249 }
250 }
251 }
252
253 protected void clearUniqueFindersCache(LayoutSet layoutSet) {
254 LayoutSetModelImpl layoutSetModelImpl = (LayoutSetModelImpl)layoutSet;
255
256 Object[] args = new Object[] {
257 Long.valueOf(layoutSet.getGroupId()),
258 Boolean.valueOf(layoutSet.getPrivateLayout())
259 };
260
261 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P, args);
262 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_P, args);
263
264 if ((layoutSetModelImpl.getColumnBitmask() &
265 FINDER_PATH_FETCH_BY_G_P.getColumnBitmask()) != 0) {
266 args = new Object[] {
267 Long.valueOf(layoutSetModelImpl.getOriginalGroupId()),
268 Boolean.valueOf(layoutSetModelImpl.getOriginalPrivateLayout())
269 };
270
271 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P, args);
272 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_P, args);
273 }
274 }
275
276
282 public LayoutSet create(long layoutSetId) {
283 LayoutSet layoutSet = new LayoutSetImpl();
284
285 layoutSet.setNew(true);
286 layoutSet.setPrimaryKey(layoutSetId);
287
288 return layoutSet;
289 }
290
291
299 public LayoutSet remove(long layoutSetId)
300 throws NoSuchLayoutSetException, SystemException {
301 return remove(Long.valueOf(layoutSetId));
302 }
303
304
312 @Override
313 public LayoutSet remove(Serializable primaryKey)
314 throws NoSuchLayoutSetException, SystemException {
315 Session session = null;
316
317 try {
318 session = openSession();
319
320 LayoutSet layoutSet = (LayoutSet)session.get(LayoutSetImpl.class,
321 primaryKey);
322
323 if (layoutSet == null) {
324 if (_log.isWarnEnabled()) {
325 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
326 }
327
328 throw new NoSuchLayoutSetException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
329 primaryKey);
330 }
331
332 return remove(layoutSet);
333 }
334 catch (NoSuchLayoutSetException nsee) {
335 throw nsee;
336 }
337 catch (Exception e) {
338 throw processException(e);
339 }
340 finally {
341 closeSession(session);
342 }
343 }
344
345 @Override
346 protected LayoutSet removeImpl(LayoutSet layoutSet)
347 throws SystemException {
348 layoutSet = toUnwrappedModel(layoutSet);
349
350 Session session = null;
351
352 try {
353 session = openSession();
354
355 BatchSessionUtil.delete(session, layoutSet);
356 }
357 catch (Exception e) {
358 throw processException(e);
359 }
360 finally {
361 closeSession(session);
362 }
363
364 clearCache(layoutSet);
365
366 return layoutSet;
367 }
368
369 @Override
370 public LayoutSet updateImpl(com.liferay.portal.model.LayoutSet layoutSet,
371 boolean merge) throws SystemException {
372 layoutSet = toUnwrappedModel(layoutSet);
373
374 boolean isNew = layoutSet.isNew();
375
376 LayoutSetModelImpl layoutSetModelImpl = (LayoutSetModelImpl)layoutSet;
377
378 Session session = null;
379
380 try {
381 session = openSession();
382
383 BatchSessionUtil.update(session, layoutSet, merge);
384
385 layoutSet.setNew(false);
386 }
387 catch (Exception e) {
388 throw processException(e);
389 }
390 finally {
391 closeSession(session);
392 }
393
394 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
395
396 if (isNew || !LayoutSetModelImpl.COLUMN_BITMASK_ENABLED) {
397 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
398 }
399
400 else {
401 if ((layoutSetModelImpl.getColumnBitmask() &
402 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
403 Object[] args = new Object[] {
404 Long.valueOf(layoutSetModelImpl.getOriginalGroupId())
405 };
406
407 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
408 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
409 args);
410
411 args = new Object[] {
412 Long.valueOf(layoutSetModelImpl.getGroupId())
413 };
414
415 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
416 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
417 args);
418 }
419
420 if ((layoutSetModelImpl.getColumnBitmask() &
421 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LAYOUTSETPROTOTYPEUUID.getColumnBitmask()) != 0) {
422 Object[] args = new Object[] {
423 layoutSetModelImpl.getOriginalLayoutSetPrototypeUuid()
424 };
425
426 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_LAYOUTSETPROTOTYPEUUID,
427 args);
428 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LAYOUTSETPROTOTYPEUUID,
429 args);
430
431 args = new Object[] {
432 layoutSetModelImpl.getLayoutSetPrototypeUuid()
433 };
434
435 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_LAYOUTSETPROTOTYPEUUID,
436 args);
437 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LAYOUTSETPROTOTYPEUUID,
438 args);
439 }
440 }
441
442 EntityCacheUtil.putResult(LayoutSetModelImpl.ENTITY_CACHE_ENABLED,
443 LayoutSetImpl.class, layoutSet.getPrimaryKey(), layoutSet);
444
445 clearUniqueFindersCache(layoutSet);
446 cacheUniqueFindersCache(layoutSet);
447
448 return layoutSet;
449 }
450
451 protected LayoutSet toUnwrappedModel(LayoutSet layoutSet) {
452 if (layoutSet instanceof LayoutSetImpl) {
453 return layoutSet;
454 }
455
456 LayoutSetImpl layoutSetImpl = new LayoutSetImpl();
457
458 layoutSetImpl.setNew(layoutSet.isNew());
459 layoutSetImpl.setPrimaryKey(layoutSet.getPrimaryKey());
460
461 layoutSetImpl.setLayoutSetId(layoutSet.getLayoutSetId());
462 layoutSetImpl.setGroupId(layoutSet.getGroupId());
463 layoutSetImpl.setCompanyId(layoutSet.getCompanyId());
464 layoutSetImpl.setCreateDate(layoutSet.getCreateDate());
465 layoutSetImpl.setModifiedDate(layoutSet.getModifiedDate());
466 layoutSetImpl.setPrivateLayout(layoutSet.isPrivateLayout());
467 layoutSetImpl.setLogo(layoutSet.isLogo());
468 layoutSetImpl.setLogoId(layoutSet.getLogoId());
469 layoutSetImpl.setThemeId(layoutSet.getThemeId());
470 layoutSetImpl.setColorSchemeId(layoutSet.getColorSchemeId());
471 layoutSetImpl.setWapThemeId(layoutSet.getWapThemeId());
472 layoutSetImpl.setWapColorSchemeId(layoutSet.getWapColorSchemeId());
473 layoutSetImpl.setCss(layoutSet.getCss());
474 layoutSetImpl.setPageCount(layoutSet.getPageCount());
475 layoutSetImpl.setSettings(layoutSet.getSettings());
476 layoutSetImpl.setLayoutSetPrototypeUuid(layoutSet.getLayoutSetPrototypeUuid());
477 layoutSetImpl.setLayoutSetPrototypeLinkEnabled(layoutSet.isLayoutSetPrototypeLinkEnabled());
478
479 return layoutSetImpl;
480 }
481
482
490 @Override
491 public LayoutSet findByPrimaryKey(Serializable primaryKey)
492 throws NoSuchModelException, SystemException {
493 return findByPrimaryKey(((Long)primaryKey).longValue());
494 }
495
496
504 public LayoutSet findByPrimaryKey(long layoutSetId)
505 throws NoSuchLayoutSetException, SystemException {
506 LayoutSet layoutSet = fetchByPrimaryKey(layoutSetId);
507
508 if (layoutSet == null) {
509 if (_log.isWarnEnabled()) {
510 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + layoutSetId);
511 }
512
513 throw new NoSuchLayoutSetException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
514 layoutSetId);
515 }
516
517 return layoutSet;
518 }
519
520
527 @Override
528 public LayoutSet fetchByPrimaryKey(Serializable primaryKey)
529 throws SystemException {
530 return fetchByPrimaryKey(((Long)primaryKey).longValue());
531 }
532
533
540 public LayoutSet fetchByPrimaryKey(long layoutSetId)
541 throws SystemException {
542 LayoutSet layoutSet = (LayoutSet)EntityCacheUtil.getResult(LayoutSetModelImpl.ENTITY_CACHE_ENABLED,
543 LayoutSetImpl.class, layoutSetId);
544
545 if (layoutSet == _nullLayoutSet) {
546 return null;
547 }
548
549 if (layoutSet == null) {
550 Session session = null;
551
552 boolean hasException = false;
553
554 try {
555 session = openSession();
556
557 layoutSet = (LayoutSet)session.get(LayoutSetImpl.class,
558 Long.valueOf(layoutSetId));
559 }
560 catch (Exception e) {
561 hasException = true;
562
563 throw processException(e);
564 }
565 finally {
566 if (layoutSet != null) {
567 cacheResult(layoutSet);
568 }
569 else if (!hasException) {
570 EntityCacheUtil.putResult(LayoutSetModelImpl.ENTITY_CACHE_ENABLED,
571 LayoutSetImpl.class, layoutSetId, _nullLayoutSet);
572 }
573
574 closeSession(session);
575 }
576 }
577
578 return layoutSet;
579 }
580
581
588 public List<LayoutSet> findByGroupId(long groupId)
589 throws SystemException {
590 return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
591 }
592
593
606 public List<LayoutSet> findByGroupId(long groupId, int start, int end)
607 throws SystemException {
608 return findByGroupId(groupId, start, end, null);
609 }
610
611
625 public List<LayoutSet> findByGroupId(long groupId, int start, int end,
626 OrderByComparator orderByComparator) throws SystemException {
627 FinderPath finderPath = null;
628 Object[] finderArgs = null;
629
630 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
631 (orderByComparator == null)) {
632 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
633 finderArgs = new Object[] { groupId };
634 }
635 else {
636 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
637 finderArgs = new Object[] { groupId, start, end, orderByComparator };
638 }
639
640 List<LayoutSet> list = (List<LayoutSet>)FinderCacheUtil.getResult(finderPath,
641 finderArgs, this);
642
643 if ((list != null) && !list.isEmpty()) {
644 for (LayoutSet layoutSet : list) {
645 if ((groupId != layoutSet.getGroupId())) {
646 list = null;
647
648 break;
649 }
650 }
651 }
652
653 if (list == null) {
654 StringBundler query = null;
655
656 if (orderByComparator != null) {
657 query = new StringBundler(3 +
658 (orderByComparator.getOrderByFields().length * 3));
659 }
660 else {
661 query = new StringBundler(2);
662 }
663
664 query.append(_SQL_SELECT_LAYOUTSET_WHERE);
665
666 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
667
668 if (orderByComparator != null) {
669 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
670 orderByComparator);
671 }
672
673 String sql = query.toString();
674
675 Session session = null;
676
677 try {
678 session = openSession();
679
680 Query q = session.createQuery(sql);
681
682 QueryPos qPos = QueryPos.getInstance(q);
683
684 qPos.add(groupId);
685
686 list = (List<LayoutSet>)QueryUtil.list(q, getDialect(), start,
687 end);
688 }
689 catch (Exception e) {
690 throw processException(e);
691 }
692 finally {
693 if (list == null) {
694 FinderCacheUtil.removeResult(finderPath, finderArgs);
695 }
696 else {
697 cacheResult(list);
698
699 FinderCacheUtil.putResult(finderPath, finderArgs, list);
700 }
701
702 closeSession(session);
703 }
704 }
705
706 return list;
707 }
708
709
718 public LayoutSet findByGroupId_First(long groupId,
719 OrderByComparator orderByComparator)
720 throws NoSuchLayoutSetException, SystemException {
721 LayoutSet layoutSet = fetchByGroupId_First(groupId, orderByComparator);
722
723 if (layoutSet != null) {
724 return layoutSet;
725 }
726
727 StringBundler msg = new StringBundler(4);
728
729 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
730
731 msg.append("groupId=");
732 msg.append(groupId);
733
734 msg.append(StringPool.CLOSE_CURLY_BRACE);
735
736 throw new NoSuchLayoutSetException(msg.toString());
737 }
738
739
747 public LayoutSet fetchByGroupId_First(long groupId,
748 OrderByComparator orderByComparator) throws SystemException {
749 List<LayoutSet> list = findByGroupId(groupId, 0, 1, orderByComparator);
750
751 if (!list.isEmpty()) {
752 return list.get(0);
753 }
754
755 return null;
756 }
757
758
767 public LayoutSet findByGroupId_Last(long groupId,
768 OrderByComparator orderByComparator)
769 throws NoSuchLayoutSetException, SystemException {
770 LayoutSet layoutSet = fetchByGroupId_Last(groupId, orderByComparator);
771
772 if (layoutSet != null) {
773 return layoutSet;
774 }
775
776 StringBundler msg = new StringBundler(4);
777
778 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
779
780 msg.append("groupId=");
781 msg.append(groupId);
782
783 msg.append(StringPool.CLOSE_CURLY_BRACE);
784
785 throw new NoSuchLayoutSetException(msg.toString());
786 }
787
788
796 public LayoutSet fetchByGroupId_Last(long groupId,
797 OrderByComparator orderByComparator) throws SystemException {
798 int count = countByGroupId(groupId);
799
800 List<LayoutSet> list = findByGroupId(groupId, count - 1, count,
801 orderByComparator);
802
803 if (!list.isEmpty()) {
804 return list.get(0);
805 }
806
807 return null;
808 }
809
810
820 public LayoutSet[] findByGroupId_PrevAndNext(long layoutSetId,
821 long groupId, OrderByComparator orderByComparator)
822 throws NoSuchLayoutSetException, SystemException {
823 LayoutSet layoutSet = findByPrimaryKey(layoutSetId);
824
825 Session session = null;
826
827 try {
828 session = openSession();
829
830 LayoutSet[] array = new LayoutSetImpl[3];
831
832 array[0] = getByGroupId_PrevAndNext(session, layoutSet, groupId,
833 orderByComparator, true);
834
835 array[1] = layoutSet;
836
837 array[2] = getByGroupId_PrevAndNext(session, layoutSet, groupId,
838 orderByComparator, false);
839
840 return array;
841 }
842 catch (Exception e) {
843 throw processException(e);
844 }
845 finally {
846 closeSession(session);
847 }
848 }
849
850 protected LayoutSet getByGroupId_PrevAndNext(Session session,
851 LayoutSet layoutSet, long groupId, OrderByComparator orderByComparator,
852 boolean previous) {
853 StringBundler query = null;
854
855 if (orderByComparator != null) {
856 query = new StringBundler(6 +
857 (orderByComparator.getOrderByFields().length * 6));
858 }
859 else {
860 query = new StringBundler(3);
861 }
862
863 query.append(_SQL_SELECT_LAYOUTSET_WHERE);
864
865 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
866
867 if (orderByComparator != null) {
868 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
869
870 if (orderByConditionFields.length > 0) {
871 query.append(WHERE_AND);
872 }
873
874 for (int i = 0; i < orderByConditionFields.length; i++) {
875 query.append(_ORDER_BY_ENTITY_ALIAS);
876 query.append(orderByConditionFields[i]);
877
878 if ((i + 1) < orderByConditionFields.length) {
879 if (orderByComparator.isAscending() ^ previous) {
880 query.append(WHERE_GREATER_THAN_HAS_NEXT);
881 }
882 else {
883 query.append(WHERE_LESSER_THAN_HAS_NEXT);
884 }
885 }
886 else {
887 if (orderByComparator.isAscending() ^ previous) {
888 query.append(WHERE_GREATER_THAN);
889 }
890 else {
891 query.append(WHERE_LESSER_THAN);
892 }
893 }
894 }
895
896 query.append(ORDER_BY_CLAUSE);
897
898 String[] orderByFields = orderByComparator.getOrderByFields();
899
900 for (int i = 0; i < orderByFields.length; i++) {
901 query.append(_ORDER_BY_ENTITY_ALIAS);
902 query.append(orderByFields[i]);
903
904 if ((i + 1) < orderByFields.length) {
905 if (orderByComparator.isAscending() ^ previous) {
906 query.append(ORDER_BY_ASC_HAS_NEXT);
907 }
908 else {
909 query.append(ORDER_BY_DESC_HAS_NEXT);
910 }
911 }
912 else {
913 if (orderByComparator.isAscending() ^ previous) {
914 query.append(ORDER_BY_ASC);
915 }
916 else {
917 query.append(ORDER_BY_DESC);
918 }
919 }
920 }
921 }
922
923 String sql = query.toString();
924
925 Query q = session.createQuery(sql);
926
927 q.setFirstResult(0);
928 q.setMaxResults(2);
929
930 QueryPos qPos = QueryPos.getInstance(q);
931
932 qPos.add(groupId);
933
934 if (orderByComparator != null) {
935 Object[] values = orderByComparator.getOrderByConditionValues(layoutSet);
936
937 for (Object value : values) {
938 qPos.add(value);
939 }
940 }
941
942 List<LayoutSet> list = q.list();
943
944 if (list.size() == 2) {
945 return list.get(1);
946 }
947 else {
948 return null;
949 }
950 }
951
952
959 public List<LayoutSet> findByLayoutSetPrototypeUuid(
960 String layoutSetPrototypeUuid) throws SystemException {
961 return findByLayoutSetPrototypeUuid(layoutSetPrototypeUuid,
962 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
963 }
964
965
978 public List<LayoutSet> findByLayoutSetPrototypeUuid(
979 String layoutSetPrototypeUuid, int start, int end)
980 throws SystemException {
981 return findByLayoutSetPrototypeUuid(layoutSetPrototypeUuid, start, end,
982 null);
983 }
984
985
999 public List<LayoutSet> findByLayoutSetPrototypeUuid(
1000 String layoutSetPrototypeUuid, int start, int end,
1001 OrderByComparator orderByComparator) throws SystemException {
1002 FinderPath finderPath = null;
1003 Object[] finderArgs = null;
1004
1005 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1006 (orderByComparator == null)) {
1007 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LAYOUTSETPROTOTYPEUUID;
1008 finderArgs = new Object[] { layoutSetPrototypeUuid };
1009 }
1010 else {
1011 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_LAYOUTSETPROTOTYPEUUID;
1012 finderArgs = new Object[] {
1013 layoutSetPrototypeUuid,
1014
1015 start, end, orderByComparator
1016 };
1017 }
1018
1019 List<LayoutSet> list = (List<LayoutSet>)FinderCacheUtil.getResult(finderPath,
1020 finderArgs, this);
1021
1022 if ((list != null) && !list.isEmpty()) {
1023 for (LayoutSet layoutSet : list) {
1024 if (!Validator.equals(layoutSetPrototypeUuid,
1025 layoutSet.getLayoutSetPrototypeUuid())) {
1026 list = null;
1027
1028 break;
1029 }
1030 }
1031 }
1032
1033 if (list == null) {
1034 StringBundler query = null;
1035
1036 if (orderByComparator != null) {
1037 query = new StringBundler(3 +
1038 (orderByComparator.getOrderByFields().length * 3));
1039 }
1040 else {
1041 query = new StringBundler(2);
1042 }
1043
1044 query.append(_SQL_SELECT_LAYOUTSET_WHERE);
1045
1046 if (layoutSetPrototypeUuid == null) {
1047 query.append(_FINDER_COLUMN_LAYOUTSETPROTOTYPEUUID_LAYOUTSETPROTOTYPEUUID_1);
1048 }
1049 else {
1050 if (layoutSetPrototypeUuid.equals(StringPool.BLANK)) {
1051 query.append(_FINDER_COLUMN_LAYOUTSETPROTOTYPEUUID_LAYOUTSETPROTOTYPEUUID_3);
1052 }
1053 else {
1054 query.append(_FINDER_COLUMN_LAYOUTSETPROTOTYPEUUID_LAYOUTSETPROTOTYPEUUID_2);
1055 }
1056 }
1057
1058 if (orderByComparator != null) {
1059 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1060 orderByComparator);
1061 }
1062
1063 String sql = query.toString();
1064
1065 Session session = null;
1066
1067 try {
1068 session = openSession();
1069
1070 Query q = session.createQuery(sql);
1071
1072 QueryPos qPos = QueryPos.getInstance(q);
1073
1074 if (layoutSetPrototypeUuid != null) {
1075 qPos.add(layoutSetPrototypeUuid);
1076 }
1077
1078 list = (List<LayoutSet>)QueryUtil.list(q, getDialect(), start,
1079 end);
1080 }
1081 catch (Exception e) {
1082 throw processException(e);
1083 }
1084 finally {
1085 if (list == null) {
1086 FinderCacheUtil.removeResult(finderPath, finderArgs);
1087 }
1088 else {
1089 cacheResult(list);
1090
1091 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1092 }
1093
1094 closeSession(session);
1095 }
1096 }
1097
1098 return list;
1099 }
1100
1101
1110 public LayoutSet findByLayoutSetPrototypeUuid_First(
1111 String layoutSetPrototypeUuid, OrderByComparator orderByComparator)
1112 throws NoSuchLayoutSetException, SystemException {
1113 LayoutSet layoutSet = fetchByLayoutSetPrototypeUuid_First(layoutSetPrototypeUuid,
1114 orderByComparator);
1115
1116 if (layoutSet != null) {
1117 return layoutSet;
1118 }
1119
1120 StringBundler msg = new StringBundler(4);
1121
1122 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1123
1124 msg.append("layoutSetPrototypeUuid=");
1125 msg.append(layoutSetPrototypeUuid);
1126
1127 msg.append(StringPool.CLOSE_CURLY_BRACE);
1128
1129 throw new NoSuchLayoutSetException(msg.toString());
1130 }
1131
1132
1140 public LayoutSet fetchByLayoutSetPrototypeUuid_First(
1141 String layoutSetPrototypeUuid, OrderByComparator orderByComparator)
1142 throws SystemException {
1143 List<LayoutSet> list = findByLayoutSetPrototypeUuid(layoutSetPrototypeUuid,
1144 0, 1, orderByComparator);
1145
1146 if (!list.isEmpty()) {
1147 return list.get(0);
1148 }
1149
1150 return null;
1151 }
1152
1153
1162 public LayoutSet findByLayoutSetPrototypeUuid_Last(
1163 String layoutSetPrototypeUuid, OrderByComparator orderByComparator)
1164 throws NoSuchLayoutSetException, SystemException {
1165 LayoutSet layoutSet = fetchByLayoutSetPrototypeUuid_Last(layoutSetPrototypeUuid,
1166 orderByComparator);
1167
1168 if (layoutSet != null) {
1169 return layoutSet;
1170 }
1171
1172 StringBundler msg = new StringBundler(4);
1173
1174 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1175
1176 msg.append("layoutSetPrototypeUuid=");
1177 msg.append(layoutSetPrototypeUuid);
1178
1179 msg.append(StringPool.CLOSE_CURLY_BRACE);
1180
1181 throw new NoSuchLayoutSetException(msg.toString());
1182 }
1183
1184
1192 public LayoutSet fetchByLayoutSetPrototypeUuid_Last(
1193 String layoutSetPrototypeUuid, OrderByComparator orderByComparator)
1194 throws SystemException {
1195 int count = countByLayoutSetPrototypeUuid(layoutSetPrototypeUuid);
1196
1197 List<LayoutSet> list = findByLayoutSetPrototypeUuid(layoutSetPrototypeUuid,
1198 count - 1, count, orderByComparator);
1199
1200 if (!list.isEmpty()) {
1201 return list.get(0);
1202 }
1203
1204 return null;
1205 }
1206
1207
1217 public LayoutSet[] findByLayoutSetPrototypeUuid_PrevAndNext(
1218 long layoutSetId, String layoutSetPrototypeUuid,
1219 OrderByComparator orderByComparator)
1220 throws NoSuchLayoutSetException, SystemException {
1221 LayoutSet layoutSet = findByPrimaryKey(layoutSetId);
1222
1223 Session session = null;
1224
1225 try {
1226 session = openSession();
1227
1228 LayoutSet[] array = new LayoutSetImpl[3];
1229
1230 array[0] = getByLayoutSetPrototypeUuid_PrevAndNext(session,
1231 layoutSet, layoutSetPrototypeUuid, orderByComparator, true);
1232
1233 array[1] = layoutSet;
1234
1235 array[2] = getByLayoutSetPrototypeUuid_PrevAndNext(session,
1236 layoutSet, layoutSetPrototypeUuid, orderByComparator, false);
1237
1238 return array;
1239 }
1240 catch (Exception e) {
1241 throw processException(e);
1242 }
1243 finally {
1244 closeSession(session);
1245 }
1246 }
1247
1248 protected LayoutSet getByLayoutSetPrototypeUuid_PrevAndNext(
1249 Session session, LayoutSet layoutSet, String layoutSetPrototypeUuid,
1250 OrderByComparator orderByComparator, boolean previous) {
1251 StringBundler query = null;
1252
1253 if (orderByComparator != null) {
1254 query = new StringBundler(6 +
1255 (orderByComparator.getOrderByFields().length * 6));
1256 }
1257 else {
1258 query = new StringBundler(3);
1259 }
1260
1261 query.append(_SQL_SELECT_LAYOUTSET_WHERE);
1262
1263 if (layoutSetPrototypeUuid == null) {
1264 query.append(_FINDER_COLUMN_LAYOUTSETPROTOTYPEUUID_LAYOUTSETPROTOTYPEUUID_1);
1265 }
1266 else {
1267 if (layoutSetPrototypeUuid.equals(StringPool.BLANK)) {
1268 query.append(_FINDER_COLUMN_LAYOUTSETPROTOTYPEUUID_LAYOUTSETPROTOTYPEUUID_3);
1269 }
1270 else {
1271 query.append(_FINDER_COLUMN_LAYOUTSETPROTOTYPEUUID_LAYOUTSETPROTOTYPEUUID_2);
1272 }
1273 }
1274
1275 if (orderByComparator != null) {
1276 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1277
1278 if (orderByConditionFields.length > 0) {
1279 query.append(WHERE_AND);
1280 }
1281
1282 for (int i = 0; i < orderByConditionFields.length; i++) {
1283 query.append(_ORDER_BY_ENTITY_ALIAS);
1284 query.append(orderByConditionFields[i]);
1285
1286 if ((i + 1) < orderByConditionFields.length) {
1287 if (orderByComparator.isAscending() ^ previous) {
1288 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1289 }
1290 else {
1291 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1292 }
1293 }
1294 else {
1295 if (orderByComparator.isAscending() ^ previous) {
1296 query.append(WHERE_GREATER_THAN);
1297 }
1298 else {
1299 query.append(WHERE_LESSER_THAN);
1300 }
1301 }
1302 }
1303
1304 query.append(ORDER_BY_CLAUSE);
1305
1306 String[] orderByFields = orderByComparator.getOrderByFields();
1307
1308 for (int i = 0; i < orderByFields.length; i++) {
1309 query.append(_ORDER_BY_ENTITY_ALIAS);
1310 query.append(orderByFields[i]);
1311
1312 if ((i + 1) < orderByFields.length) {
1313 if (orderByComparator.isAscending() ^ previous) {
1314 query.append(ORDER_BY_ASC_HAS_NEXT);
1315 }
1316 else {
1317 query.append(ORDER_BY_DESC_HAS_NEXT);
1318 }
1319 }
1320 else {
1321 if (orderByComparator.isAscending() ^ previous) {
1322 query.append(ORDER_BY_ASC);
1323 }
1324 else {
1325 query.append(ORDER_BY_DESC);
1326 }
1327 }
1328 }
1329 }
1330
1331 String sql = query.toString();
1332
1333 Query q = session.createQuery(sql);
1334
1335 q.setFirstResult(0);
1336 q.setMaxResults(2);
1337
1338 QueryPos qPos = QueryPos.getInstance(q);
1339
1340 if (layoutSetPrototypeUuid != null) {
1341 qPos.add(layoutSetPrototypeUuid);
1342 }
1343
1344 if (orderByComparator != null) {
1345 Object[] values = orderByComparator.getOrderByConditionValues(layoutSet);
1346
1347 for (Object value : values) {
1348 qPos.add(value);
1349 }
1350 }
1351
1352 List<LayoutSet> list = q.list();
1353
1354 if (list.size() == 2) {
1355 return list.get(1);
1356 }
1357 else {
1358 return null;
1359 }
1360 }
1361
1362
1371 public LayoutSet findByG_P(long groupId, boolean privateLayout)
1372 throws NoSuchLayoutSetException, SystemException {
1373 LayoutSet layoutSet = fetchByG_P(groupId, privateLayout);
1374
1375 if (layoutSet == null) {
1376 StringBundler msg = new StringBundler(6);
1377
1378 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1379
1380 msg.append("groupId=");
1381 msg.append(groupId);
1382
1383 msg.append(", privateLayout=");
1384 msg.append(privateLayout);
1385
1386 msg.append(StringPool.CLOSE_CURLY_BRACE);
1387
1388 if (_log.isWarnEnabled()) {
1389 _log.warn(msg.toString());
1390 }
1391
1392 throw new NoSuchLayoutSetException(msg.toString());
1393 }
1394
1395 return layoutSet;
1396 }
1397
1398
1406 public LayoutSet fetchByG_P(long groupId, boolean privateLayout)
1407 throws SystemException {
1408 return fetchByG_P(groupId, privateLayout, true);
1409 }
1410
1411
1420 public LayoutSet fetchByG_P(long groupId, boolean privateLayout,
1421 boolean retrieveFromCache) throws SystemException {
1422 Object[] finderArgs = new Object[] { groupId, privateLayout };
1423
1424 Object result = null;
1425
1426 if (retrieveFromCache) {
1427 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_P,
1428 finderArgs, this);
1429 }
1430
1431 if (result instanceof LayoutSet) {
1432 LayoutSet layoutSet = (LayoutSet)result;
1433
1434 if ((groupId != layoutSet.getGroupId()) ||
1435 (privateLayout != layoutSet.getPrivateLayout())) {
1436 result = null;
1437 }
1438 }
1439
1440 if (result == null) {
1441 StringBundler query = new StringBundler(3);
1442
1443 query.append(_SQL_SELECT_LAYOUTSET_WHERE);
1444
1445 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
1446
1447 query.append(_FINDER_COLUMN_G_P_PRIVATELAYOUT_2);
1448
1449 String sql = query.toString();
1450
1451 Session session = null;
1452
1453 try {
1454 session = openSession();
1455
1456 Query q = session.createQuery(sql);
1457
1458 QueryPos qPos = QueryPos.getInstance(q);
1459
1460 qPos.add(groupId);
1461
1462 qPos.add(privateLayout);
1463
1464 List<LayoutSet> list = q.list();
1465
1466 result = list;
1467
1468 LayoutSet layoutSet = null;
1469
1470 if (list.isEmpty()) {
1471 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P,
1472 finderArgs, list);
1473 }
1474 else {
1475 layoutSet = list.get(0);
1476
1477 cacheResult(layoutSet);
1478
1479 if ((layoutSet.getGroupId() != groupId) ||
1480 (layoutSet.getPrivateLayout() != privateLayout)) {
1481 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P,
1482 finderArgs, layoutSet);
1483 }
1484 }
1485
1486 return layoutSet;
1487 }
1488 catch (Exception e) {
1489 throw processException(e);
1490 }
1491 finally {
1492 if (result == null) {
1493 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_P,
1494 finderArgs);
1495 }
1496
1497 closeSession(session);
1498 }
1499 }
1500 else {
1501 if (result instanceof List<?>) {
1502 return null;
1503 }
1504 else {
1505 return (LayoutSet)result;
1506 }
1507 }
1508 }
1509
1510
1516 public List<LayoutSet> findAll() throws SystemException {
1517 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1518 }
1519
1520
1532 public List<LayoutSet> findAll(int start, int end)
1533 throws SystemException {
1534 return findAll(start, end, null);
1535 }
1536
1537
1550 public List<LayoutSet> findAll(int start, int end,
1551 OrderByComparator orderByComparator) throws SystemException {
1552 FinderPath finderPath = null;
1553 Object[] finderArgs = new Object[] { start, end, orderByComparator };
1554
1555 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1556 (orderByComparator == null)) {
1557 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
1558 finderArgs = FINDER_ARGS_EMPTY;
1559 }
1560 else {
1561 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
1562 finderArgs = new Object[] { start, end, orderByComparator };
1563 }
1564
1565 List<LayoutSet> list = (List<LayoutSet>)FinderCacheUtil.getResult(finderPath,
1566 finderArgs, this);
1567
1568 if (list == null) {
1569 StringBundler query = null;
1570 String sql = null;
1571
1572 if (orderByComparator != null) {
1573 query = new StringBundler(2 +
1574 (orderByComparator.getOrderByFields().length * 3));
1575
1576 query.append(_SQL_SELECT_LAYOUTSET);
1577
1578 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1579 orderByComparator);
1580
1581 sql = query.toString();
1582 }
1583 else {
1584 sql = _SQL_SELECT_LAYOUTSET;
1585 }
1586
1587 Session session = null;
1588
1589 try {
1590 session = openSession();
1591
1592 Query q = session.createQuery(sql);
1593
1594 if (orderByComparator == null) {
1595 list = (List<LayoutSet>)QueryUtil.list(q, getDialect(),
1596 start, end, false);
1597
1598 Collections.sort(list);
1599 }
1600 else {
1601 list = (List<LayoutSet>)QueryUtil.list(q, getDialect(),
1602 start, end);
1603 }
1604 }
1605 catch (Exception e) {
1606 throw processException(e);
1607 }
1608 finally {
1609 if (list == null) {
1610 FinderCacheUtil.removeResult(finderPath, finderArgs);
1611 }
1612 else {
1613 cacheResult(list);
1614
1615 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1616 }
1617
1618 closeSession(session);
1619 }
1620 }
1621
1622 return list;
1623 }
1624
1625
1631 public void removeByGroupId(long groupId) throws SystemException {
1632 for (LayoutSet layoutSet : findByGroupId(groupId)) {
1633 remove(layoutSet);
1634 }
1635 }
1636
1637
1643 public void removeByLayoutSetPrototypeUuid(String layoutSetPrototypeUuid)
1644 throws SystemException {
1645 for (LayoutSet layoutSet : findByLayoutSetPrototypeUuid(
1646 layoutSetPrototypeUuid)) {
1647 remove(layoutSet);
1648 }
1649 }
1650
1651
1659 public LayoutSet removeByG_P(long groupId, boolean privateLayout)
1660 throws NoSuchLayoutSetException, SystemException {
1661 LayoutSet layoutSet = findByG_P(groupId, privateLayout);
1662
1663 return remove(layoutSet);
1664 }
1665
1666
1671 public void removeAll() throws SystemException {
1672 for (LayoutSet layoutSet : findAll()) {
1673 remove(layoutSet);
1674 }
1675 }
1676
1677
1684 public int countByGroupId(long groupId) throws SystemException {
1685 Object[] finderArgs = new Object[] { groupId };
1686
1687 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
1688 finderArgs, this);
1689
1690 if (count == null) {
1691 StringBundler query = new StringBundler(2);
1692
1693 query.append(_SQL_COUNT_LAYOUTSET_WHERE);
1694
1695 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1696
1697 String sql = query.toString();
1698
1699 Session session = null;
1700
1701 try {
1702 session = openSession();
1703
1704 Query q = session.createQuery(sql);
1705
1706 QueryPos qPos = QueryPos.getInstance(q);
1707
1708 qPos.add(groupId);
1709
1710 count = (Long)q.uniqueResult();
1711 }
1712 catch (Exception e) {
1713 throw processException(e);
1714 }
1715 finally {
1716 if (count == null) {
1717 count = Long.valueOf(0);
1718 }
1719
1720 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
1721 finderArgs, count);
1722
1723 closeSession(session);
1724 }
1725 }
1726
1727 return count.intValue();
1728 }
1729
1730
1737 public int countByLayoutSetPrototypeUuid(String layoutSetPrototypeUuid)
1738 throws SystemException {
1739 Object[] finderArgs = new Object[] { layoutSetPrototypeUuid };
1740
1741 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_LAYOUTSETPROTOTYPEUUID,
1742 finderArgs, this);
1743
1744 if (count == null) {
1745 StringBundler query = new StringBundler(2);
1746
1747 query.append(_SQL_COUNT_LAYOUTSET_WHERE);
1748
1749 if (layoutSetPrototypeUuid == null) {
1750 query.append(_FINDER_COLUMN_LAYOUTSETPROTOTYPEUUID_LAYOUTSETPROTOTYPEUUID_1);
1751 }
1752 else {
1753 if (layoutSetPrototypeUuid.equals(StringPool.BLANK)) {
1754 query.append(_FINDER_COLUMN_LAYOUTSETPROTOTYPEUUID_LAYOUTSETPROTOTYPEUUID_3);
1755 }
1756 else {
1757 query.append(_FINDER_COLUMN_LAYOUTSETPROTOTYPEUUID_LAYOUTSETPROTOTYPEUUID_2);
1758 }
1759 }
1760
1761 String sql = query.toString();
1762
1763 Session session = null;
1764
1765 try {
1766 session = openSession();
1767
1768 Query q = session.createQuery(sql);
1769
1770 QueryPos qPos = QueryPos.getInstance(q);
1771
1772 if (layoutSetPrototypeUuid != null) {
1773 qPos.add(layoutSetPrototypeUuid);
1774 }
1775
1776 count = (Long)q.uniqueResult();
1777 }
1778 catch (Exception e) {
1779 throw processException(e);
1780 }
1781 finally {
1782 if (count == null) {
1783 count = Long.valueOf(0);
1784 }
1785
1786 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_LAYOUTSETPROTOTYPEUUID,
1787 finderArgs, count);
1788
1789 closeSession(session);
1790 }
1791 }
1792
1793 return count.intValue();
1794 }
1795
1796
1804 public int countByG_P(long groupId, boolean privateLayout)
1805 throws SystemException {
1806 Object[] finderArgs = new Object[] { groupId, privateLayout };
1807
1808 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_P,
1809 finderArgs, this);
1810
1811 if (count == null) {
1812 StringBundler query = new StringBundler(3);
1813
1814 query.append(_SQL_COUNT_LAYOUTSET_WHERE);
1815
1816 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
1817
1818 query.append(_FINDER_COLUMN_G_P_PRIVATELAYOUT_2);
1819
1820 String sql = query.toString();
1821
1822 Session session = null;
1823
1824 try {
1825 session = openSession();
1826
1827 Query q = session.createQuery(sql);
1828
1829 QueryPos qPos = QueryPos.getInstance(q);
1830
1831 qPos.add(groupId);
1832
1833 qPos.add(privateLayout);
1834
1835 count = (Long)q.uniqueResult();
1836 }
1837 catch (Exception e) {
1838 throw processException(e);
1839 }
1840 finally {
1841 if (count == null) {
1842 count = Long.valueOf(0);
1843 }
1844
1845 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_P, finderArgs,
1846 count);
1847
1848 closeSession(session);
1849 }
1850 }
1851
1852 return count.intValue();
1853 }
1854
1855
1861 public int countAll() throws SystemException {
1862 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1863 FINDER_ARGS_EMPTY, this);
1864
1865 if (count == null) {
1866 Session session = null;
1867
1868 try {
1869 session = openSession();
1870
1871 Query q = session.createQuery(_SQL_COUNT_LAYOUTSET);
1872
1873 count = (Long)q.uniqueResult();
1874 }
1875 catch (Exception e) {
1876 throw processException(e);
1877 }
1878 finally {
1879 if (count == null) {
1880 count = Long.valueOf(0);
1881 }
1882
1883 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
1884 FINDER_ARGS_EMPTY, count);
1885
1886 closeSession(session);
1887 }
1888 }
1889
1890 return count.intValue();
1891 }
1892
1893
1896 public void afterPropertiesSet() {
1897 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1898 com.liferay.portal.util.PropsUtil.get(
1899 "value.object.listener.com.liferay.portal.model.LayoutSet")));
1900
1901 if (listenerClassNames.length > 0) {
1902 try {
1903 List<ModelListener<LayoutSet>> listenersList = new ArrayList<ModelListener<LayoutSet>>();
1904
1905 for (String listenerClassName : listenerClassNames) {
1906 Class<?> clazz = getClass();
1907
1908 listenersList.add((ModelListener<LayoutSet>)InstanceFactory.newInstance(
1909 clazz.getClassLoader(), listenerClassName));
1910 }
1911
1912 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1913 }
1914 catch (Exception e) {
1915 _log.error(e);
1916 }
1917 }
1918 }
1919
1920 public void destroy() {
1921 EntityCacheUtil.removeCache(LayoutSetImpl.class.getName());
1922 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
1923 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1924 }
1925
1926 @BeanReference(type = AccountPersistence.class)
1927 protected AccountPersistence accountPersistence;
1928 @BeanReference(type = AddressPersistence.class)
1929 protected AddressPersistence addressPersistence;
1930 @BeanReference(type = BrowserTrackerPersistence.class)
1931 protected BrowserTrackerPersistence browserTrackerPersistence;
1932 @BeanReference(type = ClassNamePersistence.class)
1933 protected ClassNamePersistence classNamePersistence;
1934 @BeanReference(type = ClusterGroupPersistence.class)
1935 protected ClusterGroupPersistence clusterGroupPersistence;
1936 @BeanReference(type = CompanyPersistence.class)
1937 protected CompanyPersistence companyPersistence;
1938 @BeanReference(type = ContactPersistence.class)
1939 protected ContactPersistence contactPersistence;
1940 @BeanReference(type = CountryPersistence.class)
1941 protected CountryPersistence countryPersistence;
1942 @BeanReference(type = EmailAddressPersistence.class)
1943 protected EmailAddressPersistence emailAddressPersistence;
1944 @BeanReference(type = GroupPersistence.class)
1945 protected GroupPersistence groupPersistence;
1946 @BeanReference(type = ImagePersistence.class)
1947 protected ImagePersistence imagePersistence;
1948 @BeanReference(type = LayoutPersistence.class)
1949 protected LayoutPersistence layoutPersistence;
1950 @BeanReference(type = LayoutBranchPersistence.class)
1951 protected LayoutBranchPersistence layoutBranchPersistence;
1952 @BeanReference(type = LayoutPrototypePersistence.class)
1953 protected LayoutPrototypePersistence layoutPrototypePersistence;
1954 @BeanReference(type = LayoutRevisionPersistence.class)
1955 protected LayoutRevisionPersistence layoutRevisionPersistence;
1956 @BeanReference(type = LayoutSetPersistence.class)
1957 protected LayoutSetPersistence layoutSetPersistence;
1958 @BeanReference(type = LayoutSetBranchPersistence.class)
1959 protected LayoutSetBranchPersistence layoutSetBranchPersistence;
1960 @BeanReference(type = LayoutSetPrototypePersistence.class)
1961 protected LayoutSetPrototypePersistence layoutSetPrototypePersistence;
1962 @BeanReference(type = ListTypePersistence.class)
1963 protected ListTypePersistence listTypePersistence;
1964 @BeanReference(type = LockPersistence.class)
1965 protected LockPersistence lockPersistence;
1966 @BeanReference(type = MembershipRequestPersistence.class)
1967 protected MembershipRequestPersistence membershipRequestPersistence;
1968 @BeanReference(type = OrganizationPersistence.class)
1969 protected OrganizationPersistence organizationPersistence;
1970 @BeanReference(type = OrgGroupPermissionPersistence.class)
1971 protected OrgGroupPermissionPersistence orgGroupPermissionPersistence;
1972 @BeanReference(type = OrgGroupRolePersistence.class)
1973 protected OrgGroupRolePersistence orgGroupRolePersistence;
1974 @BeanReference(type = OrgLaborPersistence.class)
1975 protected OrgLaborPersistence orgLaborPersistence;
1976 @BeanReference(type = PasswordPolicyPersistence.class)
1977 protected PasswordPolicyPersistence passwordPolicyPersistence;
1978 @BeanReference(type = PasswordPolicyRelPersistence.class)
1979 protected PasswordPolicyRelPersistence passwordPolicyRelPersistence;
1980 @BeanReference(type = PasswordTrackerPersistence.class)
1981 protected PasswordTrackerPersistence passwordTrackerPersistence;
1982 @BeanReference(type = PermissionPersistence.class)
1983 protected PermissionPersistence permissionPersistence;
1984 @BeanReference(type = PhonePersistence.class)
1985 protected PhonePersistence phonePersistence;
1986 @BeanReference(type = PluginSettingPersistence.class)
1987 protected PluginSettingPersistence pluginSettingPersistence;
1988 @BeanReference(type = PortalPreferencesPersistence.class)
1989 protected PortalPreferencesPersistence portalPreferencesPersistence;
1990 @BeanReference(type = PortletPersistence.class)
1991 protected PortletPersistence portletPersistence;
1992 @BeanReference(type = PortletItemPersistence.class)
1993 protected PortletItemPersistence portletItemPersistence;
1994 @BeanReference(type = PortletPreferencesPersistence.class)
1995 protected PortletPreferencesPersistence portletPreferencesPersistence;
1996 @BeanReference(type = RegionPersistence.class)
1997 protected RegionPersistence regionPersistence;
1998 @BeanReference(type = ReleasePersistence.class)
1999 protected ReleasePersistence releasePersistence;
2000 @BeanReference(type = RepositoryPersistence.class)
2001 protected RepositoryPersistence repositoryPersistence;
2002 @BeanReference(type = RepositoryEntryPersistence.class)
2003 protected RepositoryEntryPersistence repositoryEntryPersistence;
2004 @BeanReference(type = ResourcePersistence.class)
2005 protected ResourcePersistence resourcePersistence;
2006 @BeanReference(type = ResourceActionPersistence.class)
2007 protected ResourceActionPersistence resourceActionPersistence;
2008 @BeanReference(type = ResourceBlockPersistence.class)
2009 protected ResourceBlockPersistence resourceBlockPersistence;
2010 @BeanReference(type = ResourceBlockPermissionPersistence.class)
2011 protected ResourceBlockPermissionPersistence resourceBlockPermissionPersistence;
2012 @BeanReference(type = ResourceCodePersistence.class)
2013 protected ResourceCodePersistence resourceCodePersistence;
2014 @BeanReference(type = ResourcePermissionPersistence.class)
2015 protected ResourcePermissionPersistence resourcePermissionPersistence;
2016 @BeanReference(type = ResourceTypePermissionPersistence.class)
2017 protected ResourceTypePermissionPersistence resourceTypePermissionPersistence;
2018 @BeanReference(type = RolePersistence.class)
2019 protected RolePersistence rolePersistence;
2020 @BeanReference(type = ServiceComponentPersistence.class)
2021 protected ServiceComponentPersistence serviceComponentPersistence;
2022 @BeanReference(type = ShardPersistence.class)
2023 protected ShardPersistence shardPersistence;
2024 @BeanReference(type = SubscriptionPersistence.class)
2025 protected SubscriptionPersistence subscriptionPersistence;
2026 @BeanReference(type = TeamPersistence.class)
2027 protected TeamPersistence teamPersistence;
2028 @BeanReference(type = TicketPersistence.class)
2029 protected TicketPersistence ticketPersistence;
2030 @BeanReference(type = UserPersistence.class)
2031 protected UserPersistence userPersistence;
2032 @BeanReference(type = UserGroupPersistence.class)
2033 protected UserGroupPersistence userGroupPersistence;
2034 @BeanReference(type = UserGroupGroupRolePersistence.class)
2035 protected UserGroupGroupRolePersistence userGroupGroupRolePersistence;
2036 @BeanReference(type = UserGroupRolePersistence.class)
2037 protected UserGroupRolePersistence userGroupRolePersistence;
2038 @BeanReference(type = UserIdMapperPersistence.class)
2039 protected UserIdMapperPersistence userIdMapperPersistence;
2040 @BeanReference(type = UserNotificationEventPersistence.class)
2041 protected UserNotificationEventPersistence userNotificationEventPersistence;
2042 @BeanReference(type = UserTrackerPersistence.class)
2043 protected UserTrackerPersistence userTrackerPersistence;
2044 @BeanReference(type = UserTrackerPathPersistence.class)
2045 protected UserTrackerPathPersistence userTrackerPathPersistence;
2046 @BeanReference(type = VirtualHostPersistence.class)
2047 protected VirtualHostPersistence virtualHostPersistence;
2048 @BeanReference(type = WebDAVPropsPersistence.class)
2049 protected WebDAVPropsPersistence webDAVPropsPersistence;
2050 @BeanReference(type = WebsitePersistence.class)
2051 protected WebsitePersistence websitePersistence;
2052 @BeanReference(type = WorkflowDefinitionLinkPersistence.class)
2053 protected WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
2054 @BeanReference(type = WorkflowInstanceLinkPersistence.class)
2055 protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
2056 private static final String _SQL_SELECT_LAYOUTSET = "SELECT layoutSet FROM LayoutSet layoutSet";
2057 private static final String _SQL_SELECT_LAYOUTSET_WHERE = "SELECT layoutSet FROM LayoutSet layoutSet WHERE ";
2058 private static final String _SQL_COUNT_LAYOUTSET = "SELECT COUNT(layoutSet) FROM LayoutSet layoutSet";
2059 private static final String _SQL_COUNT_LAYOUTSET_WHERE = "SELECT COUNT(layoutSet) FROM LayoutSet layoutSet WHERE ";
2060 private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "layoutSet.groupId = ?";
2061 private static final String _FINDER_COLUMN_LAYOUTSETPROTOTYPEUUID_LAYOUTSETPROTOTYPEUUID_1 =
2062 "layoutSet.layoutSetPrototypeUuid IS NULL";
2063 private static final String _FINDER_COLUMN_LAYOUTSETPROTOTYPEUUID_LAYOUTSETPROTOTYPEUUID_2 =
2064 "layoutSet.layoutSetPrototypeUuid = ?";
2065 private static final String _FINDER_COLUMN_LAYOUTSETPROTOTYPEUUID_LAYOUTSETPROTOTYPEUUID_3 =
2066 "(layoutSet.layoutSetPrototypeUuid IS NULL OR layoutSet.layoutSetPrototypeUuid = ?)";
2067 private static final String _FINDER_COLUMN_G_P_GROUPID_2 = "layoutSet.groupId = ? AND ";
2068 private static final String _FINDER_COLUMN_G_P_PRIVATELAYOUT_2 = "layoutSet.privateLayout = ?";
2069 private static final String _ORDER_BY_ENTITY_ALIAS = "layoutSet.";
2070 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No LayoutSet exists with the primary key ";
2071 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No LayoutSet exists with the key {";
2072 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
2073 private static Log _log = LogFactoryUtil.getLog(LayoutSetPersistenceImpl.class);
2074 private static LayoutSet _nullLayoutSet = new LayoutSetImpl() {
2075 @Override
2076 public Object clone() {
2077 return this;
2078 }
2079
2080 @Override
2081 public CacheModel<LayoutSet> toCacheModel() {
2082 return _nullLayoutSetCacheModel;
2083 }
2084 };
2085
2086 private static CacheModel<LayoutSet> _nullLayoutSetCacheModel = new CacheModel<LayoutSet>() {
2087 public LayoutSet toEntityModel() {
2088 return _nullLayoutSet;
2089 }
2090 };
2091 }