001
014
015 package com.liferay.portal.service.persistence;
016
017 import com.liferay.portal.NoSuchModelException;
018 import com.liferay.portal.NoSuchPortletItemException;
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.ModelListener;
040 import com.liferay.portal.model.PortletItem;
041 import com.liferay.portal.model.impl.PortletItemImpl;
042 import com.liferay.portal.model.impl.PortletItemModelImpl;
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 PortletItemPersistenceImpl extends BasePersistenceImpl<PortletItem>
064 implements PortletItemPersistence {
065
070 public static final String FINDER_CLASS_NAME_ENTITY = PortletItemImpl.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_G_C = new FinderPath(PortletItemModelImpl.ENTITY_CACHE_ENABLED,
076 PortletItemModelImpl.FINDER_CACHE_ENABLED, PortletItemImpl.class,
077 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_C",
078 new String[] {
079 Long.class.getName(), 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_G_C = new FinderPath(PortletItemModelImpl.ENTITY_CACHE_ENABLED,
085 PortletItemModelImpl.FINDER_CACHE_ENABLED, PortletItemImpl.class,
086 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_C",
087 new String[] { Long.class.getName(), Long.class.getName() },
088 PortletItemModelImpl.GROUPID_COLUMN_BITMASK |
089 PortletItemModelImpl.CLASSNAMEID_COLUMN_BITMASK);
090 public static final FinderPath FINDER_PATH_COUNT_BY_G_C = new FinderPath(PortletItemModelImpl.ENTITY_CACHE_ENABLED,
091 PortletItemModelImpl.FINDER_CACHE_ENABLED, Long.class,
092 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_C",
093 new String[] { Long.class.getName(), Long.class.getName() });
094 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P_C = new FinderPath(PortletItemModelImpl.ENTITY_CACHE_ENABLED,
095 PortletItemModelImpl.FINDER_CACHE_ENABLED, PortletItemImpl.class,
096 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_P_C",
097 new String[] {
098 Long.class.getName(), String.class.getName(),
099 Long.class.getName(),
100
101 "java.lang.Integer", "java.lang.Integer",
102 "com.liferay.portal.kernel.util.OrderByComparator"
103 });
104 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_C = new FinderPath(PortletItemModelImpl.ENTITY_CACHE_ENABLED,
105 PortletItemModelImpl.FINDER_CACHE_ENABLED, PortletItemImpl.class,
106 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_P_C",
107 new String[] {
108 Long.class.getName(), String.class.getName(),
109 Long.class.getName()
110 },
111 PortletItemModelImpl.GROUPID_COLUMN_BITMASK |
112 PortletItemModelImpl.PORTLETID_COLUMN_BITMASK |
113 PortletItemModelImpl.CLASSNAMEID_COLUMN_BITMASK);
114 public static final FinderPath FINDER_PATH_COUNT_BY_G_P_C = new FinderPath(PortletItemModelImpl.ENTITY_CACHE_ENABLED,
115 PortletItemModelImpl.FINDER_CACHE_ENABLED, Long.class,
116 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_P_C",
117 new String[] {
118 Long.class.getName(), String.class.getName(),
119 Long.class.getName()
120 });
121 public static final FinderPath FINDER_PATH_FETCH_BY_G_N_P_C = new FinderPath(PortletItemModelImpl.ENTITY_CACHE_ENABLED,
122 PortletItemModelImpl.FINDER_CACHE_ENABLED, PortletItemImpl.class,
123 FINDER_CLASS_NAME_ENTITY, "fetchByG_N_P_C",
124 new String[] {
125 Long.class.getName(), String.class.getName(),
126 String.class.getName(), Long.class.getName()
127 },
128 PortletItemModelImpl.GROUPID_COLUMN_BITMASK |
129 PortletItemModelImpl.NAME_COLUMN_BITMASK |
130 PortletItemModelImpl.PORTLETID_COLUMN_BITMASK |
131 PortletItemModelImpl.CLASSNAMEID_COLUMN_BITMASK);
132 public static final FinderPath FINDER_PATH_COUNT_BY_G_N_P_C = new FinderPath(PortletItemModelImpl.ENTITY_CACHE_ENABLED,
133 PortletItemModelImpl.FINDER_CACHE_ENABLED, Long.class,
134 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_N_P_C",
135 new String[] {
136 Long.class.getName(), String.class.getName(),
137 String.class.getName(), Long.class.getName()
138 });
139 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(PortletItemModelImpl.ENTITY_CACHE_ENABLED,
140 PortletItemModelImpl.FINDER_CACHE_ENABLED, PortletItemImpl.class,
141 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
142 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(PortletItemModelImpl.ENTITY_CACHE_ENABLED,
143 PortletItemModelImpl.FINDER_CACHE_ENABLED, PortletItemImpl.class,
144 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
145 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(PortletItemModelImpl.ENTITY_CACHE_ENABLED,
146 PortletItemModelImpl.FINDER_CACHE_ENABLED, Long.class,
147 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
148
149
154 public void cacheResult(PortletItem portletItem) {
155 EntityCacheUtil.putResult(PortletItemModelImpl.ENTITY_CACHE_ENABLED,
156 PortletItemImpl.class, portletItem.getPrimaryKey(), portletItem);
157
158 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N_P_C,
159 new Object[] {
160 Long.valueOf(portletItem.getGroupId()),
161
162 portletItem.getName(),
163
164 portletItem.getPortletId(),
165 Long.valueOf(portletItem.getClassNameId())
166 }, portletItem);
167
168 portletItem.resetOriginalValues();
169 }
170
171
176 public void cacheResult(List<PortletItem> portletItems) {
177 for (PortletItem portletItem : portletItems) {
178 if (EntityCacheUtil.getResult(
179 PortletItemModelImpl.ENTITY_CACHE_ENABLED,
180 PortletItemImpl.class, portletItem.getPrimaryKey()) == null) {
181 cacheResult(portletItem);
182 }
183 else {
184 portletItem.resetOriginalValues();
185 }
186 }
187 }
188
189
196 @Override
197 public void clearCache() {
198 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
199 CacheRegistryUtil.clear(PortletItemImpl.class.getName());
200 }
201
202 EntityCacheUtil.clearCache(PortletItemImpl.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(PortletItem portletItem) {
218 EntityCacheUtil.removeResult(PortletItemModelImpl.ENTITY_CACHE_ENABLED,
219 PortletItemImpl.class, portletItem.getPrimaryKey());
220
221 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
222 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
223
224 clearUniqueFindersCache(portletItem);
225 }
226
227 @Override
228 public void clearCache(List<PortletItem> portletItems) {
229 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
230 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
231
232 for (PortletItem portletItem : portletItems) {
233 EntityCacheUtil.removeResult(PortletItemModelImpl.ENTITY_CACHE_ENABLED,
234 PortletItemImpl.class, portletItem.getPrimaryKey());
235
236 clearUniqueFindersCache(portletItem);
237 }
238 }
239
240 protected void clearUniqueFindersCache(PortletItem portletItem) {
241 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_N_P_C,
242 new Object[] {
243 Long.valueOf(portletItem.getGroupId()),
244
245 portletItem.getName(),
246
247 portletItem.getPortletId(),
248 Long.valueOf(portletItem.getClassNameId())
249 });
250 }
251
252
258 public PortletItem create(long portletItemId) {
259 PortletItem portletItem = new PortletItemImpl();
260
261 portletItem.setNew(true);
262 portletItem.setPrimaryKey(portletItemId);
263
264 return portletItem;
265 }
266
267
275 public PortletItem remove(long portletItemId)
276 throws NoSuchPortletItemException, SystemException {
277 return remove(Long.valueOf(portletItemId));
278 }
279
280
288 @Override
289 public PortletItem remove(Serializable primaryKey)
290 throws NoSuchPortletItemException, SystemException {
291 Session session = null;
292
293 try {
294 session = openSession();
295
296 PortletItem portletItem = (PortletItem)session.get(PortletItemImpl.class,
297 primaryKey);
298
299 if (portletItem == null) {
300 if (_log.isWarnEnabled()) {
301 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
302 }
303
304 throw new NoSuchPortletItemException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
305 primaryKey);
306 }
307
308 return remove(portletItem);
309 }
310 catch (NoSuchPortletItemException nsee) {
311 throw nsee;
312 }
313 catch (Exception e) {
314 throw processException(e);
315 }
316 finally {
317 closeSession(session);
318 }
319 }
320
321 @Override
322 protected PortletItem removeImpl(PortletItem portletItem)
323 throws SystemException {
324 portletItem = toUnwrappedModel(portletItem);
325
326 Session session = null;
327
328 try {
329 session = openSession();
330
331 BatchSessionUtil.delete(session, portletItem);
332 }
333 catch (Exception e) {
334 throw processException(e);
335 }
336 finally {
337 closeSession(session);
338 }
339
340 clearCache(portletItem);
341
342 return portletItem;
343 }
344
345 @Override
346 public PortletItem updateImpl(
347 com.liferay.portal.model.PortletItem portletItem, boolean merge)
348 throws SystemException {
349 portletItem = toUnwrappedModel(portletItem);
350
351 boolean isNew = portletItem.isNew();
352
353 PortletItemModelImpl portletItemModelImpl = (PortletItemModelImpl)portletItem;
354
355 Session session = null;
356
357 try {
358 session = openSession();
359
360 BatchSessionUtil.update(session, portletItem, merge);
361
362 portletItem.setNew(false);
363 }
364 catch (Exception e) {
365 throw processException(e);
366 }
367 finally {
368 closeSession(session);
369 }
370
371 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
372
373 if (isNew || !PortletItemModelImpl.COLUMN_BITMASK_ENABLED) {
374 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
375 }
376 else {
377 if ((portletItemModelImpl.getColumnBitmask() &
378 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C.getColumnBitmask()) != 0) {
379 Object[] args = new Object[] {
380 Long.valueOf(portletItemModelImpl.getOriginalGroupId()),
381 Long.valueOf(portletItemModelImpl.getOriginalClassNameId())
382 };
383
384 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C, args);
385 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C,
386 args);
387
388 args = new Object[] {
389 Long.valueOf(portletItemModelImpl.getGroupId()),
390 Long.valueOf(portletItemModelImpl.getClassNameId())
391 };
392
393 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C, args);
394 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C,
395 args);
396 }
397
398 if ((portletItemModelImpl.getColumnBitmask() &
399 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_C.getColumnBitmask()) != 0) {
400 Object[] args = new Object[] {
401 Long.valueOf(portletItemModelImpl.getOriginalGroupId()),
402
403 portletItemModelImpl.getOriginalPortletId(),
404 Long.valueOf(portletItemModelImpl.getOriginalClassNameId())
405 };
406
407 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P_C, args);
408 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_C,
409 args);
410
411 args = new Object[] {
412 Long.valueOf(portletItemModelImpl.getGroupId()),
413
414 portletItemModelImpl.getPortletId(),
415 Long.valueOf(portletItemModelImpl.getClassNameId())
416 };
417
418 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P_C, args);
419 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_C,
420 args);
421 }
422 }
423
424 EntityCacheUtil.putResult(PortletItemModelImpl.ENTITY_CACHE_ENABLED,
425 PortletItemImpl.class, portletItem.getPrimaryKey(), portletItem);
426
427 if (isNew) {
428 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N_P_C,
429 new Object[] {
430 Long.valueOf(portletItem.getGroupId()),
431
432 portletItem.getName(),
433
434 portletItem.getPortletId(),
435 Long.valueOf(portletItem.getClassNameId())
436 }, portletItem);
437 }
438 else {
439 if ((portletItemModelImpl.getColumnBitmask() &
440 FINDER_PATH_FETCH_BY_G_N_P_C.getColumnBitmask()) != 0) {
441 Object[] args = new Object[] {
442 Long.valueOf(portletItemModelImpl.getOriginalGroupId()),
443
444 portletItemModelImpl.getOriginalName(),
445
446 portletItemModelImpl.getOriginalPortletId(),
447 Long.valueOf(portletItemModelImpl.getOriginalClassNameId())
448 };
449
450 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_N_P_C, args);
451 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_N_P_C, args);
452
453 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N_P_C,
454 new Object[] {
455 Long.valueOf(portletItem.getGroupId()),
456
457 portletItem.getName(),
458
459 portletItem.getPortletId(),
460 Long.valueOf(portletItem.getClassNameId())
461 }, portletItem);
462 }
463 }
464
465 return portletItem;
466 }
467
468 protected PortletItem toUnwrappedModel(PortletItem portletItem) {
469 if (portletItem instanceof PortletItemImpl) {
470 return portletItem;
471 }
472
473 PortletItemImpl portletItemImpl = new PortletItemImpl();
474
475 portletItemImpl.setNew(portletItem.isNew());
476 portletItemImpl.setPrimaryKey(portletItem.getPrimaryKey());
477
478 portletItemImpl.setPortletItemId(portletItem.getPortletItemId());
479 portletItemImpl.setGroupId(portletItem.getGroupId());
480 portletItemImpl.setCompanyId(portletItem.getCompanyId());
481 portletItemImpl.setUserId(portletItem.getUserId());
482 portletItemImpl.setUserName(portletItem.getUserName());
483 portletItemImpl.setCreateDate(portletItem.getCreateDate());
484 portletItemImpl.setModifiedDate(portletItem.getModifiedDate());
485 portletItemImpl.setName(portletItem.getName());
486 portletItemImpl.setPortletId(portletItem.getPortletId());
487 portletItemImpl.setClassNameId(portletItem.getClassNameId());
488
489 return portletItemImpl;
490 }
491
492
500 @Override
501 public PortletItem findByPrimaryKey(Serializable primaryKey)
502 throws NoSuchModelException, SystemException {
503 return findByPrimaryKey(((Long)primaryKey).longValue());
504 }
505
506
514 public PortletItem findByPrimaryKey(long portletItemId)
515 throws NoSuchPortletItemException, SystemException {
516 PortletItem portletItem = fetchByPrimaryKey(portletItemId);
517
518 if (portletItem == null) {
519 if (_log.isWarnEnabled()) {
520 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + portletItemId);
521 }
522
523 throw new NoSuchPortletItemException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
524 portletItemId);
525 }
526
527 return portletItem;
528 }
529
530
537 @Override
538 public PortletItem fetchByPrimaryKey(Serializable primaryKey)
539 throws SystemException {
540 return fetchByPrimaryKey(((Long)primaryKey).longValue());
541 }
542
543
550 public PortletItem fetchByPrimaryKey(long portletItemId)
551 throws SystemException {
552 PortletItem portletItem = (PortletItem)EntityCacheUtil.getResult(PortletItemModelImpl.ENTITY_CACHE_ENABLED,
553 PortletItemImpl.class, portletItemId);
554
555 if (portletItem == _nullPortletItem) {
556 return null;
557 }
558
559 if (portletItem == null) {
560 Session session = null;
561
562 boolean hasException = false;
563
564 try {
565 session = openSession();
566
567 portletItem = (PortletItem)session.get(PortletItemImpl.class,
568 Long.valueOf(portletItemId));
569 }
570 catch (Exception e) {
571 hasException = true;
572
573 throw processException(e);
574 }
575 finally {
576 if (portletItem != null) {
577 cacheResult(portletItem);
578 }
579 else if (!hasException) {
580 EntityCacheUtil.putResult(PortletItemModelImpl.ENTITY_CACHE_ENABLED,
581 PortletItemImpl.class, portletItemId, _nullPortletItem);
582 }
583
584 closeSession(session);
585 }
586 }
587
588 return portletItem;
589 }
590
591
599 public List<PortletItem> findByG_C(long groupId, long classNameId)
600 throws SystemException {
601 return findByG_C(groupId, classNameId, QueryUtil.ALL_POS,
602 QueryUtil.ALL_POS, null);
603 }
604
605
619 public List<PortletItem> findByG_C(long groupId, long classNameId,
620 int start, int end) throws SystemException {
621 return findByG_C(groupId, classNameId, start, end, null);
622 }
623
624
639 public List<PortletItem> findByG_C(long groupId, long classNameId,
640 int start, int end, OrderByComparator orderByComparator)
641 throws SystemException {
642 FinderPath finderPath = null;
643 Object[] finderArgs = null;
644
645 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
646 (orderByComparator == null)) {
647 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C;
648 finderArgs = new Object[] { groupId, classNameId };
649 }
650 else {
651 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C;
652 finderArgs = new Object[] {
653 groupId, classNameId,
654
655 start, end, orderByComparator
656 };
657 }
658
659 List<PortletItem> list = (List<PortletItem>)FinderCacheUtil.getResult(finderPath,
660 finderArgs, this);
661
662 if ((list != null) && !list.isEmpty()) {
663 for (PortletItem portletItem : list) {
664 if ((groupId != portletItem.getGroupId()) ||
665 (classNameId != portletItem.getClassNameId())) {
666 list = null;
667
668 break;
669 }
670 }
671 }
672
673 if (list == null) {
674 StringBundler query = null;
675
676 if (orderByComparator != null) {
677 query = new StringBundler(4 +
678 (orderByComparator.getOrderByFields().length * 3));
679 }
680 else {
681 query = new StringBundler(3);
682 }
683
684 query.append(_SQL_SELECT_PORTLETITEM_WHERE);
685
686 query.append(_FINDER_COLUMN_G_C_GROUPID_2);
687
688 query.append(_FINDER_COLUMN_G_C_CLASSNAMEID_2);
689
690 if (orderByComparator != null) {
691 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
692 orderByComparator);
693 }
694
695 String sql = query.toString();
696
697 Session session = null;
698
699 try {
700 session = openSession();
701
702 Query q = session.createQuery(sql);
703
704 QueryPos qPos = QueryPos.getInstance(q);
705
706 qPos.add(groupId);
707
708 qPos.add(classNameId);
709
710 list = (List<PortletItem>)QueryUtil.list(q, getDialect(),
711 start, end);
712 }
713 catch (Exception e) {
714 throw processException(e);
715 }
716 finally {
717 if (list == null) {
718 FinderCacheUtil.removeResult(finderPath, finderArgs);
719 }
720 else {
721 cacheResult(list);
722
723 FinderCacheUtil.putResult(finderPath, finderArgs, list);
724 }
725
726 closeSession(session);
727 }
728 }
729
730 return list;
731 }
732
733
747 public PortletItem findByG_C_First(long groupId, long classNameId,
748 OrderByComparator orderByComparator)
749 throws NoSuchPortletItemException, SystemException {
750 List<PortletItem> list = findByG_C(groupId, classNameId, 0, 1,
751 orderByComparator);
752
753 if (list.isEmpty()) {
754 StringBundler msg = new StringBundler(6);
755
756 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
757
758 msg.append("groupId=");
759 msg.append(groupId);
760
761 msg.append(", classNameId=");
762 msg.append(classNameId);
763
764 msg.append(StringPool.CLOSE_CURLY_BRACE);
765
766 throw new NoSuchPortletItemException(msg.toString());
767 }
768 else {
769 return list.get(0);
770 }
771 }
772
773
787 public PortletItem findByG_C_Last(long groupId, long classNameId,
788 OrderByComparator orderByComparator)
789 throws NoSuchPortletItemException, SystemException {
790 int count = countByG_C(groupId, classNameId);
791
792 List<PortletItem> list = findByG_C(groupId, classNameId, count - 1,
793 count, orderByComparator);
794
795 if (list.isEmpty()) {
796 StringBundler msg = new StringBundler(6);
797
798 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
799
800 msg.append("groupId=");
801 msg.append(groupId);
802
803 msg.append(", classNameId=");
804 msg.append(classNameId);
805
806 msg.append(StringPool.CLOSE_CURLY_BRACE);
807
808 throw new NoSuchPortletItemException(msg.toString());
809 }
810 else {
811 return list.get(0);
812 }
813 }
814
815
830 public PortletItem[] findByG_C_PrevAndNext(long portletItemId,
831 long groupId, long classNameId, OrderByComparator orderByComparator)
832 throws NoSuchPortletItemException, SystemException {
833 PortletItem portletItem = findByPrimaryKey(portletItemId);
834
835 Session session = null;
836
837 try {
838 session = openSession();
839
840 PortletItem[] array = new PortletItemImpl[3];
841
842 array[0] = getByG_C_PrevAndNext(session, portletItem, groupId,
843 classNameId, orderByComparator, true);
844
845 array[1] = portletItem;
846
847 array[2] = getByG_C_PrevAndNext(session, portletItem, groupId,
848 classNameId, orderByComparator, false);
849
850 return array;
851 }
852 catch (Exception e) {
853 throw processException(e);
854 }
855 finally {
856 closeSession(session);
857 }
858 }
859
860 protected PortletItem getByG_C_PrevAndNext(Session session,
861 PortletItem portletItem, long groupId, long classNameId,
862 OrderByComparator orderByComparator, boolean previous) {
863 StringBundler query = null;
864
865 if (orderByComparator != null) {
866 query = new StringBundler(6 +
867 (orderByComparator.getOrderByFields().length * 6));
868 }
869 else {
870 query = new StringBundler(3);
871 }
872
873 query.append(_SQL_SELECT_PORTLETITEM_WHERE);
874
875 query.append(_FINDER_COLUMN_G_C_GROUPID_2);
876
877 query.append(_FINDER_COLUMN_G_C_CLASSNAMEID_2);
878
879 if (orderByComparator != null) {
880 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
881
882 if (orderByConditionFields.length > 0) {
883 query.append(WHERE_AND);
884 }
885
886 for (int i = 0; i < orderByConditionFields.length; i++) {
887 query.append(_ORDER_BY_ENTITY_ALIAS);
888 query.append(orderByConditionFields[i]);
889
890 if ((i + 1) < orderByConditionFields.length) {
891 if (orderByComparator.isAscending() ^ previous) {
892 query.append(WHERE_GREATER_THAN_HAS_NEXT);
893 }
894 else {
895 query.append(WHERE_LESSER_THAN_HAS_NEXT);
896 }
897 }
898 else {
899 if (orderByComparator.isAscending() ^ previous) {
900 query.append(WHERE_GREATER_THAN);
901 }
902 else {
903 query.append(WHERE_LESSER_THAN);
904 }
905 }
906 }
907
908 query.append(ORDER_BY_CLAUSE);
909
910 String[] orderByFields = orderByComparator.getOrderByFields();
911
912 for (int i = 0; i < orderByFields.length; i++) {
913 query.append(_ORDER_BY_ENTITY_ALIAS);
914 query.append(orderByFields[i]);
915
916 if ((i + 1) < orderByFields.length) {
917 if (orderByComparator.isAscending() ^ previous) {
918 query.append(ORDER_BY_ASC_HAS_NEXT);
919 }
920 else {
921 query.append(ORDER_BY_DESC_HAS_NEXT);
922 }
923 }
924 else {
925 if (orderByComparator.isAscending() ^ previous) {
926 query.append(ORDER_BY_ASC);
927 }
928 else {
929 query.append(ORDER_BY_DESC);
930 }
931 }
932 }
933 }
934
935 String sql = query.toString();
936
937 Query q = session.createQuery(sql);
938
939 q.setFirstResult(0);
940 q.setMaxResults(2);
941
942 QueryPos qPos = QueryPos.getInstance(q);
943
944 qPos.add(groupId);
945
946 qPos.add(classNameId);
947
948 if (orderByComparator != null) {
949 Object[] values = orderByComparator.getOrderByConditionValues(portletItem);
950
951 for (Object value : values) {
952 qPos.add(value);
953 }
954 }
955
956 List<PortletItem> list = q.list();
957
958 if (list.size() == 2) {
959 return list.get(1);
960 }
961 else {
962 return null;
963 }
964 }
965
966
975 public List<PortletItem> findByG_P_C(long groupId, String portletId,
976 long classNameId) throws SystemException {
977 return findByG_P_C(groupId, portletId, classNameId, QueryUtil.ALL_POS,
978 QueryUtil.ALL_POS, null);
979 }
980
981
996 public List<PortletItem> findByG_P_C(long groupId, String portletId,
997 long classNameId, int start, int end) throws SystemException {
998 return findByG_P_C(groupId, portletId, classNameId, start, end, null);
999 }
1000
1001
1017 public List<PortletItem> findByG_P_C(long groupId, String portletId,
1018 long classNameId, int start, int end,
1019 OrderByComparator orderByComparator) throws SystemException {
1020 FinderPath finderPath = null;
1021 Object[] finderArgs = null;
1022
1023 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1024 (orderByComparator == null)) {
1025 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_C;
1026 finderArgs = new Object[] { groupId, portletId, classNameId };
1027 }
1028 else {
1029 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P_C;
1030 finderArgs = new Object[] {
1031 groupId, portletId, classNameId,
1032
1033 start, end, orderByComparator
1034 };
1035 }
1036
1037 List<PortletItem> list = (List<PortletItem>)FinderCacheUtil.getResult(finderPath,
1038 finderArgs, this);
1039
1040 if ((list != null) && !list.isEmpty()) {
1041 for (PortletItem portletItem : list) {
1042 if ((groupId != portletItem.getGroupId()) ||
1043 !Validator.equals(portletId, portletItem.getPortletId()) ||
1044 (classNameId != portletItem.getClassNameId())) {
1045 list = null;
1046
1047 break;
1048 }
1049 }
1050 }
1051
1052 if (list == null) {
1053 StringBundler query = null;
1054
1055 if (orderByComparator != null) {
1056 query = new StringBundler(5 +
1057 (orderByComparator.getOrderByFields().length * 3));
1058 }
1059 else {
1060 query = new StringBundler(4);
1061 }
1062
1063 query.append(_SQL_SELECT_PORTLETITEM_WHERE);
1064
1065 query.append(_FINDER_COLUMN_G_P_C_GROUPID_2);
1066
1067 if (portletId == null) {
1068 query.append(_FINDER_COLUMN_G_P_C_PORTLETID_1);
1069 }
1070 else {
1071 if (portletId.equals(StringPool.BLANK)) {
1072 query.append(_FINDER_COLUMN_G_P_C_PORTLETID_3);
1073 }
1074 else {
1075 query.append(_FINDER_COLUMN_G_P_C_PORTLETID_2);
1076 }
1077 }
1078
1079 query.append(_FINDER_COLUMN_G_P_C_CLASSNAMEID_2);
1080
1081 if (orderByComparator != null) {
1082 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1083 orderByComparator);
1084 }
1085
1086 String sql = query.toString();
1087
1088 Session session = null;
1089
1090 try {
1091 session = openSession();
1092
1093 Query q = session.createQuery(sql);
1094
1095 QueryPos qPos = QueryPos.getInstance(q);
1096
1097 qPos.add(groupId);
1098
1099 if (portletId != null) {
1100 qPos.add(portletId);
1101 }
1102
1103 qPos.add(classNameId);
1104
1105 list = (List<PortletItem>)QueryUtil.list(q, getDialect(),
1106 start, end);
1107 }
1108 catch (Exception e) {
1109 throw processException(e);
1110 }
1111 finally {
1112 if (list == null) {
1113 FinderCacheUtil.removeResult(finderPath, finderArgs);
1114 }
1115 else {
1116 cacheResult(list);
1117
1118 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1119 }
1120
1121 closeSession(session);
1122 }
1123 }
1124
1125 return list;
1126 }
1127
1128
1143 public PortletItem findByG_P_C_First(long groupId, String portletId,
1144 long classNameId, OrderByComparator orderByComparator)
1145 throws NoSuchPortletItemException, SystemException {
1146 List<PortletItem> list = findByG_P_C(groupId, portletId, classNameId,
1147 0, 1, orderByComparator);
1148
1149 if (list.isEmpty()) {
1150 StringBundler msg = new StringBundler(8);
1151
1152 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1153
1154 msg.append("groupId=");
1155 msg.append(groupId);
1156
1157 msg.append(", portletId=");
1158 msg.append(portletId);
1159
1160 msg.append(", classNameId=");
1161 msg.append(classNameId);
1162
1163 msg.append(StringPool.CLOSE_CURLY_BRACE);
1164
1165 throw new NoSuchPortletItemException(msg.toString());
1166 }
1167 else {
1168 return list.get(0);
1169 }
1170 }
1171
1172
1187 public PortletItem findByG_P_C_Last(long groupId, String portletId,
1188 long classNameId, OrderByComparator orderByComparator)
1189 throws NoSuchPortletItemException, SystemException {
1190 int count = countByG_P_C(groupId, portletId, classNameId);
1191
1192 List<PortletItem> list = findByG_P_C(groupId, portletId, classNameId,
1193 count - 1, count, orderByComparator);
1194
1195 if (list.isEmpty()) {
1196 StringBundler msg = new StringBundler(8);
1197
1198 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1199
1200 msg.append("groupId=");
1201 msg.append(groupId);
1202
1203 msg.append(", portletId=");
1204 msg.append(portletId);
1205
1206 msg.append(", classNameId=");
1207 msg.append(classNameId);
1208
1209 msg.append(StringPool.CLOSE_CURLY_BRACE);
1210
1211 throw new NoSuchPortletItemException(msg.toString());
1212 }
1213 else {
1214 return list.get(0);
1215 }
1216 }
1217
1218
1234 public PortletItem[] findByG_P_C_PrevAndNext(long portletItemId,
1235 long groupId, String portletId, long classNameId,
1236 OrderByComparator orderByComparator)
1237 throws NoSuchPortletItemException, SystemException {
1238 PortletItem portletItem = findByPrimaryKey(portletItemId);
1239
1240 Session session = null;
1241
1242 try {
1243 session = openSession();
1244
1245 PortletItem[] array = new PortletItemImpl[3];
1246
1247 array[0] = getByG_P_C_PrevAndNext(session, portletItem, groupId,
1248 portletId, classNameId, orderByComparator, true);
1249
1250 array[1] = portletItem;
1251
1252 array[2] = getByG_P_C_PrevAndNext(session, portletItem, groupId,
1253 portletId, classNameId, orderByComparator, false);
1254
1255 return array;
1256 }
1257 catch (Exception e) {
1258 throw processException(e);
1259 }
1260 finally {
1261 closeSession(session);
1262 }
1263 }
1264
1265 protected PortletItem getByG_P_C_PrevAndNext(Session session,
1266 PortletItem portletItem, long groupId, String portletId,
1267 long classNameId, OrderByComparator orderByComparator, boolean previous) {
1268 StringBundler query = null;
1269
1270 if (orderByComparator != null) {
1271 query = new StringBundler(6 +
1272 (orderByComparator.getOrderByFields().length * 6));
1273 }
1274 else {
1275 query = new StringBundler(3);
1276 }
1277
1278 query.append(_SQL_SELECT_PORTLETITEM_WHERE);
1279
1280 query.append(_FINDER_COLUMN_G_P_C_GROUPID_2);
1281
1282 if (portletId == null) {
1283 query.append(_FINDER_COLUMN_G_P_C_PORTLETID_1);
1284 }
1285 else {
1286 if (portletId.equals(StringPool.BLANK)) {
1287 query.append(_FINDER_COLUMN_G_P_C_PORTLETID_3);
1288 }
1289 else {
1290 query.append(_FINDER_COLUMN_G_P_C_PORTLETID_2);
1291 }
1292 }
1293
1294 query.append(_FINDER_COLUMN_G_P_C_CLASSNAMEID_2);
1295
1296 if (orderByComparator != null) {
1297 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1298
1299 if (orderByConditionFields.length > 0) {
1300 query.append(WHERE_AND);
1301 }
1302
1303 for (int i = 0; i < orderByConditionFields.length; i++) {
1304 query.append(_ORDER_BY_ENTITY_ALIAS);
1305 query.append(orderByConditionFields[i]);
1306
1307 if ((i + 1) < orderByConditionFields.length) {
1308 if (orderByComparator.isAscending() ^ previous) {
1309 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1310 }
1311 else {
1312 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1313 }
1314 }
1315 else {
1316 if (orderByComparator.isAscending() ^ previous) {
1317 query.append(WHERE_GREATER_THAN);
1318 }
1319 else {
1320 query.append(WHERE_LESSER_THAN);
1321 }
1322 }
1323 }
1324
1325 query.append(ORDER_BY_CLAUSE);
1326
1327 String[] orderByFields = orderByComparator.getOrderByFields();
1328
1329 for (int i = 0; i < orderByFields.length; i++) {
1330 query.append(_ORDER_BY_ENTITY_ALIAS);
1331 query.append(orderByFields[i]);
1332
1333 if ((i + 1) < orderByFields.length) {
1334 if (orderByComparator.isAscending() ^ previous) {
1335 query.append(ORDER_BY_ASC_HAS_NEXT);
1336 }
1337 else {
1338 query.append(ORDER_BY_DESC_HAS_NEXT);
1339 }
1340 }
1341 else {
1342 if (orderByComparator.isAscending() ^ previous) {
1343 query.append(ORDER_BY_ASC);
1344 }
1345 else {
1346 query.append(ORDER_BY_DESC);
1347 }
1348 }
1349 }
1350 }
1351
1352 String sql = query.toString();
1353
1354 Query q = session.createQuery(sql);
1355
1356 q.setFirstResult(0);
1357 q.setMaxResults(2);
1358
1359 QueryPos qPos = QueryPos.getInstance(q);
1360
1361 qPos.add(groupId);
1362
1363 if (portletId != null) {
1364 qPos.add(portletId);
1365 }
1366
1367 qPos.add(classNameId);
1368
1369 if (orderByComparator != null) {
1370 Object[] values = orderByComparator.getOrderByConditionValues(portletItem);
1371
1372 for (Object value : values) {
1373 qPos.add(value);
1374 }
1375 }
1376
1377 List<PortletItem> list = q.list();
1378
1379 if (list.size() == 2) {
1380 return list.get(1);
1381 }
1382 else {
1383 return null;
1384 }
1385 }
1386
1387
1398 public PortletItem findByG_N_P_C(long groupId, String name,
1399 String portletId, long classNameId)
1400 throws NoSuchPortletItemException, SystemException {
1401 PortletItem portletItem = fetchByG_N_P_C(groupId, name, portletId,
1402 classNameId);
1403
1404 if (portletItem == null) {
1405 StringBundler msg = new StringBundler(10);
1406
1407 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1408
1409 msg.append("groupId=");
1410 msg.append(groupId);
1411
1412 msg.append(", name=");
1413 msg.append(name);
1414
1415 msg.append(", portletId=");
1416 msg.append(portletId);
1417
1418 msg.append(", classNameId=");
1419 msg.append(classNameId);
1420
1421 msg.append(StringPool.CLOSE_CURLY_BRACE);
1422
1423 if (_log.isWarnEnabled()) {
1424 _log.warn(msg.toString());
1425 }
1426
1427 throw new NoSuchPortletItemException(msg.toString());
1428 }
1429
1430 return portletItem;
1431 }
1432
1433
1443 public PortletItem fetchByG_N_P_C(long groupId, String name,
1444 String portletId, long classNameId) throws SystemException {
1445 return fetchByG_N_P_C(groupId, name, portletId, classNameId, true);
1446 }
1447
1448
1459 public PortletItem fetchByG_N_P_C(long groupId, String name,
1460 String portletId, long classNameId, boolean retrieveFromCache)
1461 throws SystemException {
1462 Object[] finderArgs = new Object[] { groupId, name, portletId, classNameId };
1463
1464 Object result = null;
1465
1466 if (retrieveFromCache) {
1467 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_N_P_C,
1468 finderArgs, this);
1469 }
1470
1471 if (result instanceof PortletItem) {
1472 PortletItem portletItem = (PortletItem)result;
1473
1474 if ((groupId != portletItem.getGroupId()) ||
1475 !Validator.equals(name, portletItem.getName()) ||
1476 !Validator.equals(portletId, portletItem.getPortletId()) ||
1477 (classNameId != portletItem.getClassNameId())) {
1478 result = null;
1479 }
1480 }
1481
1482 if (result == null) {
1483 StringBundler query = new StringBundler(5);
1484
1485 query.append(_SQL_SELECT_PORTLETITEM_WHERE);
1486
1487 query.append(_FINDER_COLUMN_G_N_P_C_GROUPID_2);
1488
1489 if (name == null) {
1490 query.append(_FINDER_COLUMN_G_N_P_C_NAME_1);
1491 }
1492 else {
1493 if (name.equals(StringPool.BLANK)) {
1494 query.append(_FINDER_COLUMN_G_N_P_C_NAME_3);
1495 }
1496 else {
1497 query.append(_FINDER_COLUMN_G_N_P_C_NAME_2);
1498 }
1499 }
1500
1501 if (portletId == null) {
1502 query.append(_FINDER_COLUMN_G_N_P_C_PORTLETID_1);
1503 }
1504 else {
1505 if (portletId.equals(StringPool.BLANK)) {
1506 query.append(_FINDER_COLUMN_G_N_P_C_PORTLETID_3);
1507 }
1508 else {
1509 query.append(_FINDER_COLUMN_G_N_P_C_PORTLETID_2);
1510 }
1511 }
1512
1513 query.append(_FINDER_COLUMN_G_N_P_C_CLASSNAMEID_2);
1514
1515 String sql = query.toString();
1516
1517 Session session = null;
1518
1519 try {
1520 session = openSession();
1521
1522 Query q = session.createQuery(sql);
1523
1524 QueryPos qPos = QueryPos.getInstance(q);
1525
1526 qPos.add(groupId);
1527
1528 if (name != null) {
1529 qPos.add(name);
1530 }
1531
1532 if (portletId != null) {
1533 qPos.add(portletId);
1534 }
1535
1536 qPos.add(classNameId);
1537
1538 List<PortletItem> list = q.list();
1539
1540 result = list;
1541
1542 PortletItem portletItem = null;
1543
1544 if (list.isEmpty()) {
1545 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N_P_C,
1546 finderArgs, list);
1547 }
1548 else {
1549 portletItem = list.get(0);
1550
1551 cacheResult(portletItem);
1552
1553 if ((portletItem.getGroupId() != groupId) ||
1554 (portletItem.getName() == null) ||
1555 !portletItem.getName().equals(name) ||
1556 (portletItem.getPortletId() == null) ||
1557 !portletItem.getPortletId().equals(portletId) ||
1558 (portletItem.getClassNameId() != classNameId)) {
1559 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N_P_C,
1560 finderArgs, portletItem);
1561 }
1562 }
1563
1564 return portletItem;
1565 }
1566 catch (Exception e) {
1567 throw processException(e);
1568 }
1569 finally {
1570 if (result == null) {
1571 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_N_P_C,
1572 finderArgs);
1573 }
1574
1575 closeSession(session);
1576 }
1577 }
1578 else {
1579 if (result instanceof List<?>) {
1580 return null;
1581 }
1582 else {
1583 return (PortletItem)result;
1584 }
1585 }
1586 }
1587
1588
1594 public List<PortletItem> findAll() throws SystemException {
1595 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1596 }
1597
1598
1610 public List<PortletItem> findAll(int start, int end)
1611 throws SystemException {
1612 return findAll(start, end, null);
1613 }
1614
1615
1628 public List<PortletItem> findAll(int start, int end,
1629 OrderByComparator orderByComparator) throws SystemException {
1630 FinderPath finderPath = null;
1631 Object[] finderArgs = new Object[] { start, end, orderByComparator };
1632
1633 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1634 (orderByComparator == null)) {
1635 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
1636 finderArgs = FINDER_ARGS_EMPTY;
1637 }
1638 else {
1639 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
1640 finderArgs = new Object[] { start, end, orderByComparator };
1641 }
1642
1643 List<PortletItem> list = (List<PortletItem>)FinderCacheUtil.getResult(finderPath,
1644 finderArgs, this);
1645
1646 if (list == null) {
1647 StringBundler query = null;
1648 String sql = null;
1649
1650 if (orderByComparator != null) {
1651 query = new StringBundler(2 +
1652 (orderByComparator.getOrderByFields().length * 3));
1653
1654 query.append(_SQL_SELECT_PORTLETITEM);
1655
1656 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1657 orderByComparator);
1658
1659 sql = query.toString();
1660 }
1661 else {
1662 sql = _SQL_SELECT_PORTLETITEM;
1663 }
1664
1665 Session session = null;
1666
1667 try {
1668 session = openSession();
1669
1670 Query q = session.createQuery(sql);
1671
1672 if (orderByComparator == null) {
1673 list = (List<PortletItem>)QueryUtil.list(q, getDialect(),
1674 start, end, false);
1675
1676 Collections.sort(list);
1677 }
1678 else {
1679 list = (List<PortletItem>)QueryUtil.list(q, getDialect(),
1680 start, end);
1681 }
1682 }
1683 catch (Exception e) {
1684 throw processException(e);
1685 }
1686 finally {
1687 if (list == null) {
1688 FinderCacheUtil.removeResult(finderPath, finderArgs);
1689 }
1690 else {
1691 cacheResult(list);
1692
1693 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1694 }
1695
1696 closeSession(session);
1697 }
1698 }
1699
1700 return list;
1701 }
1702
1703
1710 public void removeByG_C(long groupId, long classNameId)
1711 throws SystemException {
1712 for (PortletItem portletItem : findByG_C(groupId, classNameId)) {
1713 remove(portletItem);
1714 }
1715 }
1716
1717
1725 public void removeByG_P_C(long groupId, String portletId, long classNameId)
1726 throws SystemException {
1727 for (PortletItem portletItem : findByG_P_C(groupId, portletId,
1728 classNameId)) {
1729 remove(portletItem);
1730 }
1731 }
1732
1733
1742 public void removeByG_N_P_C(long groupId, String name, String portletId,
1743 long classNameId) throws NoSuchPortletItemException, SystemException {
1744 PortletItem portletItem = findByG_N_P_C(groupId, name, portletId,
1745 classNameId);
1746
1747 remove(portletItem);
1748 }
1749
1750
1755 public void removeAll() throws SystemException {
1756 for (PortletItem portletItem : findAll()) {
1757 remove(portletItem);
1758 }
1759 }
1760
1761
1769 public int countByG_C(long groupId, long classNameId)
1770 throws SystemException {
1771 Object[] finderArgs = new Object[] { groupId, classNameId };
1772
1773 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_C,
1774 finderArgs, this);
1775
1776 if (count == null) {
1777 StringBundler query = new StringBundler(3);
1778
1779 query.append(_SQL_COUNT_PORTLETITEM_WHERE);
1780
1781 query.append(_FINDER_COLUMN_G_C_GROUPID_2);
1782
1783 query.append(_FINDER_COLUMN_G_C_CLASSNAMEID_2);
1784
1785 String sql = query.toString();
1786
1787 Session session = null;
1788
1789 try {
1790 session = openSession();
1791
1792 Query q = session.createQuery(sql);
1793
1794 QueryPos qPos = QueryPos.getInstance(q);
1795
1796 qPos.add(groupId);
1797
1798 qPos.add(classNameId);
1799
1800 count = (Long)q.uniqueResult();
1801 }
1802 catch (Exception e) {
1803 throw processException(e);
1804 }
1805 finally {
1806 if (count == null) {
1807 count = Long.valueOf(0);
1808 }
1809
1810 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_C, finderArgs,
1811 count);
1812
1813 closeSession(session);
1814 }
1815 }
1816
1817 return count.intValue();
1818 }
1819
1820
1829 public int countByG_P_C(long groupId, String portletId, long classNameId)
1830 throws SystemException {
1831 Object[] finderArgs = new Object[] { groupId, portletId, classNameId };
1832
1833 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_P_C,
1834 finderArgs, this);
1835
1836 if (count == null) {
1837 StringBundler query = new StringBundler(4);
1838
1839 query.append(_SQL_COUNT_PORTLETITEM_WHERE);
1840
1841 query.append(_FINDER_COLUMN_G_P_C_GROUPID_2);
1842
1843 if (portletId == null) {
1844 query.append(_FINDER_COLUMN_G_P_C_PORTLETID_1);
1845 }
1846 else {
1847 if (portletId.equals(StringPool.BLANK)) {
1848 query.append(_FINDER_COLUMN_G_P_C_PORTLETID_3);
1849 }
1850 else {
1851 query.append(_FINDER_COLUMN_G_P_C_PORTLETID_2);
1852 }
1853 }
1854
1855 query.append(_FINDER_COLUMN_G_P_C_CLASSNAMEID_2);
1856
1857 String sql = query.toString();
1858
1859 Session session = null;
1860
1861 try {
1862 session = openSession();
1863
1864 Query q = session.createQuery(sql);
1865
1866 QueryPos qPos = QueryPos.getInstance(q);
1867
1868 qPos.add(groupId);
1869
1870 if (portletId != null) {
1871 qPos.add(portletId);
1872 }
1873
1874 qPos.add(classNameId);
1875
1876 count = (Long)q.uniqueResult();
1877 }
1878 catch (Exception e) {
1879 throw processException(e);
1880 }
1881 finally {
1882 if (count == null) {
1883 count = Long.valueOf(0);
1884 }
1885
1886 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_P_C,
1887 finderArgs, count);
1888
1889 closeSession(session);
1890 }
1891 }
1892
1893 return count.intValue();
1894 }
1895
1896
1906 public int countByG_N_P_C(long groupId, String name, String portletId,
1907 long classNameId) throws SystemException {
1908 Object[] finderArgs = new Object[] { groupId, name, portletId, classNameId };
1909
1910 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_N_P_C,
1911 finderArgs, this);
1912
1913 if (count == null) {
1914 StringBundler query = new StringBundler(5);
1915
1916 query.append(_SQL_COUNT_PORTLETITEM_WHERE);
1917
1918 query.append(_FINDER_COLUMN_G_N_P_C_GROUPID_2);
1919
1920 if (name == null) {
1921 query.append(_FINDER_COLUMN_G_N_P_C_NAME_1);
1922 }
1923 else {
1924 if (name.equals(StringPool.BLANK)) {
1925 query.append(_FINDER_COLUMN_G_N_P_C_NAME_3);
1926 }
1927 else {
1928 query.append(_FINDER_COLUMN_G_N_P_C_NAME_2);
1929 }
1930 }
1931
1932 if (portletId == null) {
1933 query.append(_FINDER_COLUMN_G_N_P_C_PORTLETID_1);
1934 }
1935 else {
1936 if (portletId.equals(StringPool.BLANK)) {
1937 query.append(_FINDER_COLUMN_G_N_P_C_PORTLETID_3);
1938 }
1939 else {
1940 query.append(_FINDER_COLUMN_G_N_P_C_PORTLETID_2);
1941 }
1942 }
1943
1944 query.append(_FINDER_COLUMN_G_N_P_C_CLASSNAMEID_2);
1945
1946 String sql = query.toString();
1947
1948 Session session = null;
1949
1950 try {
1951 session = openSession();
1952
1953 Query q = session.createQuery(sql);
1954
1955 QueryPos qPos = QueryPos.getInstance(q);
1956
1957 qPos.add(groupId);
1958
1959 if (name != null) {
1960 qPos.add(name);
1961 }
1962
1963 if (portletId != null) {
1964 qPos.add(portletId);
1965 }
1966
1967 qPos.add(classNameId);
1968
1969 count = (Long)q.uniqueResult();
1970 }
1971 catch (Exception e) {
1972 throw processException(e);
1973 }
1974 finally {
1975 if (count == null) {
1976 count = Long.valueOf(0);
1977 }
1978
1979 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_N_P_C,
1980 finderArgs, count);
1981
1982 closeSession(session);
1983 }
1984 }
1985
1986 return count.intValue();
1987 }
1988
1989
1995 public int countAll() throws SystemException {
1996 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1997 FINDER_ARGS_EMPTY, this);
1998
1999 if (count == null) {
2000 Session session = null;
2001
2002 try {
2003 session = openSession();
2004
2005 Query q = session.createQuery(_SQL_COUNT_PORTLETITEM);
2006
2007 count = (Long)q.uniqueResult();
2008 }
2009 catch (Exception e) {
2010 throw processException(e);
2011 }
2012 finally {
2013 if (count == null) {
2014 count = Long.valueOf(0);
2015 }
2016
2017 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
2018 FINDER_ARGS_EMPTY, count);
2019
2020 closeSession(session);
2021 }
2022 }
2023
2024 return count.intValue();
2025 }
2026
2027
2030 public void afterPropertiesSet() {
2031 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
2032 com.liferay.portal.util.PropsUtil.get(
2033 "value.object.listener.com.liferay.portal.model.PortletItem")));
2034
2035 if (listenerClassNames.length > 0) {
2036 try {
2037 List<ModelListener<PortletItem>> listenersList = new ArrayList<ModelListener<PortletItem>>();
2038
2039 for (String listenerClassName : listenerClassNames) {
2040 listenersList.add((ModelListener<PortletItem>)InstanceFactory.newInstance(
2041 listenerClassName));
2042 }
2043
2044 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
2045 }
2046 catch (Exception e) {
2047 _log.error(e);
2048 }
2049 }
2050 }
2051
2052 public void destroy() {
2053 EntityCacheUtil.removeCache(PortletItemImpl.class.getName());
2054 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
2055 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2056 }
2057
2058 @BeanReference(type = AccountPersistence.class)
2059 protected AccountPersistence accountPersistence;
2060 @BeanReference(type = AddressPersistence.class)
2061 protected AddressPersistence addressPersistence;
2062 @BeanReference(type = BrowserTrackerPersistence.class)
2063 protected BrowserTrackerPersistence browserTrackerPersistence;
2064 @BeanReference(type = ClassNamePersistence.class)
2065 protected ClassNamePersistence classNamePersistence;
2066 @BeanReference(type = ClusterGroupPersistence.class)
2067 protected ClusterGroupPersistence clusterGroupPersistence;
2068 @BeanReference(type = CompanyPersistence.class)
2069 protected CompanyPersistence companyPersistence;
2070 @BeanReference(type = ContactPersistence.class)
2071 protected ContactPersistence contactPersistence;
2072 @BeanReference(type = CountryPersistence.class)
2073 protected CountryPersistence countryPersistence;
2074 @BeanReference(type = EmailAddressPersistence.class)
2075 protected EmailAddressPersistence emailAddressPersistence;
2076 @BeanReference(type = GroupPersistence.class)
2077 protected GroupPersistence groupPersistence;
2078 @BeanReference(type = ImagePersistence.class)
2079 protected ImagePersistence imagePersistence;
2080 @BeanReference(type = LayoutPersistence.class)
2081 protected LayoutPersistence layoutPersistence;
2082 @BeanReference(type = LayoutBranchPersistence.class)
2083 protected LayoutBranchPersistence layoutBranchPersistence;
2084 @BeanReference(type = LayoutPrototypePersistence.class)
2085 protected LayoutPrototypePersistence layoutPrototypePersistence;
2086 @BeanReference(type = LayoutRevisionPersistence.class)
2087 protected LayoutRevisionPersistence layoutRevisionPersistence;
2088 @BeanReference(type = LayoutSetPersistence.class)
2089 protected LayoutSetPersistence layoutSetPersistence;
2090 @BeanReference(type = LayoutSetBranchPersistence.class)
2091 protected LayoutSetBranchPersistence layoutSetBranchPersistence;
2092 @BeanReference(type = LayoutSetPrototypePersistence.class)
2093 protected LayoutSetPrototypePersistence layoutSetPrototypePersistence;
2094 @BeanReference(type = ListTypePersistence.class)
2095 protected ListTypePersistence listTypePersistence;
2096 @BeanReference(type = LockPersistence.class)
2097 protected LockPersistence lockPersistence;
2098 @BeanReference(type = MembershipRequestPersistence.class)
2099 protected MembershipRequestPersistence membershipRequestPersistence;
2100 @BeanReference(type = OrganizationPersistence.class)
2101 protected OrganizationPersistence organizationPersistence;
2102 @BeanReference(type = OrgGroupPermissionPersistence.class)
2103 protected OrgGroupPermissionPersistence orgGroupPermissionPersistence;
2104 @BeanReference(type = OrgGroupRolePersistence.class)
2105 protected OrgGroupRolePersistence orgGroupRolePersistence;
2106 @BeanReference(type = OrgLaborPersistence.class)
2107 protected OrgLaborPersistence orgLaborPersistence;
2108 @BeanReference(type = PasswordPolicyPersistence.class)
2109 protected PasswordPolicyPersistence passwordPolicyPersistence;
2110 @BeanReference(type = PasswordPolicyRelPersistence.class)
2111 protected PasswordPolicyRelPersistence passwordPolicyRelPersistence;
2112 @BeanReference(type = PasswordTrackerPersistence.class)
2113 protected PasswordTrackerPersistence passwordTrackerPersistence;
2114 @BeanReference(type = PermissionPersistence.class)
2115 protected PermissionPersistence permissionPersistence;
2116 @BeanReference(type = PhonePersistence.class)
2117 protected PhonePersistence phonePersistence;
2118 @BeanReference(type = PluginSettingPersistence.class)
2119 protected PluginSettingPersistence pluginSettingPersistence;
2120 @BeanReference(type = PortalPreferencesPersistence.class)
2121 protected PortalPreferencesPersistence portalPreferencesPersistence;
2122 @BeanReference(type = PortletPersistence.class)
2123 protected PortletPersistence portletPersistence;
2124 @BeanReference(type = PortletItemPersistence.class)
2125 protected PortletItemPersistence portletItemPersistence;
2126 @BeanReference(type = PortletPreferencesPersistence.class)
2127 protected PortletPreferencesPersistence portletPreferencesPersistence;
2128 @BeanReference(type = RegionPersistence.class)
2129 protected RegionPersistence regionPersistence;
2130 @BeanReference(type = ReleasePersistence.class)
2131 protected ReleasePersistence releasePersistence;
2132 @BeanReference(type = RepositoryPersistence.class)
2133 protected RepositoryPersistence repositoryPersistence;
2134 @BeanReference(type = RepositoryEntryPersistence.class)
2135 protected RepositoryEntryPersistence repositoryEntryPersistence;
2136 @BeanReference(type = ResourcePersistence.class)
2137 protected ResourcePersistence resourcePersistence;
2138 @BeanReference(type = ResourceActionPersistence.class)
2139 protected ResourceActionPersistence resourceActionPersistence;
2140 @BeanReference(type = ResourceBlockPersistence.class)
2141 protected ResourceBlockPersistence resourceBlockPersistence;
2142 @BeanReference(type = ResourceBlockPermissionPersistence.class)
2143 protected ResourceBlockPermissionPersistence resourceBlockPermissionPersistence;
2144 @BeanReference(type = ResourceCodePersistence.class)
2145 protected ResourceCodePersistence resourceCodePersistence;
2146 @BeanReference(type = ResourcePermissionPersistence.class)
2147 protected ResourcePermissionPersistence resourcePermissionPersistence;
2148 @BeanReference(type = ResourceTypePermissionPersistence.class)
2149 protected ResourceTypePermissionPersistence resourceTypePermissionPersistence;
2150 @BeanReference(type = RolePersistence.class)
2151 protected RolePersistence rolePersistence;
2152 @BeanReference(type = ServiceComponentPersistence.class)
2153 protected ServiceComponentPersistence serviceComponentPersistence;
2154 @BeanReference(type = ShardPersistence.class)
2155 protected ShardPersistence shardPersistence;
2156 @BeanReference(type = SubscriptionPersistence.class)
2157 protected SubscriptionPersistence subscriptionPersistence;
2158 @BeanReference(type = TeamPersistence.class)
2159 protected TeamPersistence teamPersistence;
2160 @BeanReference(type = TicketPersistence.class)
2161 protected TicketPersistence ticketPersistence;
2162 @BeanReference(type = UserPersistence.class)
2163 protected UserPersistence userPersistence;
2164 @BeanReference(type = UserGroupPersistence.class)
2165 protected UserGroupPersistence userGroupPersistence;
2166 @BeanReference(type = UserGroupGroupRolePersistence.class)
2167 protected UserGroupGroupRolePersistence userGroupGroupRolePersistence;
2168 @BeanReference(type = UserGroupRolePersistence.class)
2169 protected UserGroupRolePersistence userGroupRolePersistence;
2170 @BeanReference(type = UserIdMapperPersistence.class)
2171 protected UserIdMapperPersistence userIdMapperPersistence;
2172 @BeanReference(type = UserNotificationEventPersistence.class)
2173 protected UserNotificationEventPersistence userNotificationEventPersistence;
2174 @BeanReference(type = UserTrackerPersistence.class)
2175 protected UserTrackerPersistence userTrackerPersistence;
2176 @BeanReference(type = UserTrackerPathPersistence.class)
2177 protected UserTrackerPathPersistence userTrackerPathPersistence;
2178 @BeanReference(type = VirtualHostPersistence.class)
2179 protected VirtualHostPersistence virtualHostPersistence;
2180 @BeanReference(type = WebDAVPropsPersistence.class)
2181 protected WebDAVPropsPersistence webDAVPropsPersistence;
2182 @BeanReference(type = WebsitePersistence.class)
2183 protected WebsitePersistence websitePersistence;
2184 @BeanReference(type = WorkflowDefinitionLinkPersistence.class)
2185 protected WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
2186 @BeanReference(type = WorkflowInstanceLinkPersistence.class)
2187 protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
2188 private static final String _SQL_SELECT_PORTLETITEM = "SELECT portletItem FROM PortletItem portletItem";
2189 private static final String _SQL_SELECT_PORTLETITEM_WHERE = "SELECT portletItem FROM PortletItem portletItem WHERE ";
2190 private static final String _SQL_COUNT_PORTLETITEM = "SELECT COUNT(portletItem) FROM PortletItem portletItem";
2191 private static final String _SQL_COUNT_PORTLETITEM_WHERE = "SELECT COUNT(portletItem) FROM PortletItem portletItem WHERE ";
2192 private static final String _FINDER_COLUMN_G_C_GROUPID_2 = "portletItem.groupId = ? AND ";
2193 private static final String _FINDER_COLUMN_G_C_CLASSNAMEID_2 = "portletItem.classNameId = ?";
2194 private static final String _FINDER_COLUMN_G_P_C_GROUPID_2 = "portletItem.groupId = ? AND ";
2195 private static final String _FINDER_COLUMN_G_P_C_PORTLETID_1 = "portletItem.portletId IS NULL AND ";
2196 private static final String _FINDER_COLUMN_G_P_C_PORTLETID_2 = "portletItem.portletId = ? AND ";
2197 private static final String _FINDER_COLUMN_G_P_C_PORTLETID_3 = "(portletItem.portletId IS NULL OR portletItem.portletId = ?) AND ";
2198 private static final String _FINDER_COLUMN_G_P_C_CLASSNAMEID_2 = "portletItem.classNameId = ?";
2199 private static final String _FINDER_COLUMN_G_N_P_C_GROUPID_2 = "portletItem.groupId = ? AND ";
2200 private static final String _FINDER_COLUMN_G_N_P_C_NAME_1 = "portletItem.name IS NULL AND ";
2201 private static final String _FINDER_COLUMN_G_N_P_C_NAME_2 = "lower(portletItem.name) = lower(CAST_TEXT(?)) AND ";
2202 private static final String _FINDER_COLUMN_G_N_P_C_NAME_3 = "(portletItem.name IS NULL OR lower(portletItem.name) = lower(CAST_TEXT(?))) AND ";
2203 private static final String _FINDER_COLUMN_G_N_P_C_PORTLETID_1 = "portletItem.portletId IS NULL AND ";
2204 private static final String _FINDER_COLUMN_G_N_P_C_PORTLETID_2 = "portletItem.portletId = ? AND ";
2205 private static final String _FINDER_COLUMN_G_N_P_C_PORTLETID_3 = "(portletItem.portletId IS NULL OR portletItem.portletId = ?) AND ";
2206 private static final String _FINDER_COLUMN_G_N_P_C_CLASSNAMEID_2 = "portletItem.classNameId = ?";
2207 private static final String _ORDER_BY_ENTITY_ALIAS = "portletItem.";
2208 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No PortletItem exists with the primary key ";
2209 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No PortletItem exists with the key {";
2210 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
2211 private static Log _log = LogFactoryUtil.getLog(PortletItemPersistenceImpl.class);
2212 private static PortletItem _nullPortletItem = new PortletItemImpl() {
2213 @Override
2214 public Object clone() {
2215 return this;
2216 }
2217
2218 @Override
2219 public CacheModel<PortletItem> toCacheModel() {
2220 return _nullPortletItemCacheModel;
2221 }
2222 };
2223
2224 private static CacheModel<PortletItem> _nullPortletItemCacheModel = new CacheModel<PortletItem>() {
2225 public PortletItem toEntityModel() {
2226 return _nullPortletItem;
2227 }
2228 };
2229 }