1
22
23 package com.liferay.portal.service.persistence;
24
25 import com.liferay.portal.NoSuchPortletPreferencesException;
26 import com.liferay.portal.SystemException;
27 import com.liferay.portal.kernel.annotation.BeanReference;
28 import com.liferay.portal.kernel.cache.CacheRegistry;
29 import com.liferay.portal.kernel.dao.orm.DynamicQuery;
30 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
31 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
32 import com.liferay.portal.kernel.dao.orm.FinderPath;
33 import com.liferay.portal.kernel.dao.orm.Query;
34 import com.liferay.portal.kernel.dao.orm.QueryPos;
35 import com.liferay.portal.kernel.dao.orm.QueryUtil;
36 import com.liferay.portal.kernel.dao.orm.Session;
37 import com.liferay.portal.kernel.log.Log;
38 import com.liferay.portal.kernel.log.LogFactoryUtil;
39 import com.liferay.portal.kernel.util.GetterUtil;
40 import com.liferay.portal.kernel.util.OrderByComparator;
41 import com.liferay.portal.kernel.util.StringPool;
42 import com.liferay.portal.kernel.util.StringUtil;
43 import com.liferay.portal.model.ModelListener;
44 import com.liferay.portal.model.PortletPreferences;
45 import com.liferay.portal.model.impl.PortletPreferencesImpl;
46 import com.liferay.portal.model.impl.PortletPreferencesModelImpl;
47 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
48
49 import java.util.ArrayList;
50 import java.util.Collections;
51 import java.util.List;
52
53
59 public class PortletPreferencesPersistenceImpl extends BasePersistenceImpl
60 implements PortletPreferencesPersistence {
61 public static final String FINDER_CLASS_NAME_ENTITY = PortletPreferencesImpl.class.getName();
62 public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
63 ".List";
64 public static final FinderPath FINDER_PATH_FIND_BY_PLID = new FinderPath(PortletPreferencesModelImpl.ENTITY_CACHE_ENABLED,
65 PortletPreferencesModelImpl.FINDER_CACHE_ENABLED,
66 FINDER_CLASS_NAME_LIST, "findByPlid",
67 new String[] { Long.class.getName() });
68 public static final FinderPath FINDER_PATH_FIND_BY_OBC_PLID = new FinderPath(PortletPreferencesModelImpl.ENTITY_CACHE_ENABLED,
69 PortletPreferencesModelImpl.FINDER_CACHE_ENABLED,
70 FINDER_CLASS_NAME_LIST, "findByPlid",
71 new String[] {
72 Long.class.getName(),
73
74 "java.lang.Integer", "java.lang.Integer",
75 "com.liferay.portal.kernel.util.OrderByComparator"
76 });
77 public static final FinderPath FINDER_PATH_COUNT_BY_PLID = new FinderPath(PortletPreferencesModelImpl.ENTITY_CACHE_ENABLED,
78 PortletPreferencesModelImpl.FINDER_CACHE_ENABLED,
79 FINDER_CLASS_NAME_LIST, "countByPlid",
80 new String[] { Long.class.getName() });
81 public static final FinderPath FINDER_PATH_FIND_BY_P_P = new FinderPath(PortletPreferencesModelImpl.ENTITY_CACHE_ENABLED,
82 PortletPreferencesModelImpl.FINDER_CACHE_ENABLED,
83 FINDER_CLASS_NAME_LIST, "findByP_P",
84 new String[] { Long.class.getName(), String.class.getName() });
85 public static final FinderPath FINDER_PATH_FIND_BY_OBC_P_P = new FinderPath(PortletPreferencesModelImpl.ENTITY_CACHE_ENABLED,
86 PortletPreferencesModelImpl.FINDER_CACHE_ENABLED,
87 FINDER_CLASS_NAME_LIST, "findByP_P",
88 new String[] {
89 Long.class.getName(), String.class.getName(),
90
91 "java.lang.Integer", "java.lang.Integer",
92 "com.liferay.portal.kernel.util.OrderByComparator"
93 });
94 public static final FinderPath FINDER_PATH_COUNT_BY_P_P = new FinderPath(PortletPreferencesModelImpl.ENTITY_CACHE_ENABLED,
95 PortletPreferencesModelImpl.FINDER_CACHE_ENABLED,
96 FINDER_CLASS_NAME_LIST, "countByP_P",
97 new String[] { Long.class.getName(), String.class.getName() });
98 public static final FinderPath FINDER_PATH_FIND_BY_O_O_P = new FinderPath(PortletPreferencesModelImpl.ENTITY_CACHE_ENABLED,
99 PortletPreferencesModelImpl.FINDER_CACHE_ENABLED,
100 FINDER_CLASS_NAME_LIST, "findByO_O_P",
101 new String[] {
102 Long.class.getName(), Integer.class.getName(),
103 Long.class.getName()
104 });
105 public static final FinderPath FINDER_PATH_FIND_BY_OBC_O_O_P = new FinderPath(PortletPreferencesModelImpl.ENTITY_CACHE_ENABLED,
106 PortletPreferencesModelImpl.FINDER_CACHE_ENABLED,
107 FINDER_CLASS_NAME_LIST, "findByO_O_P",
108 new String[] {
109 Long.class.getName(), Integer.class.getName(),
110 Long.class.getName(),
111
112 "java.lang.Integer", "java.lang.Integer",
113 "com.liferay.portal.kernel.util.OrderByComparator"
114 });
115 public static final FinderPath FINDER_PATH_COUNT_BY_O_O_P = new FinderPath(PortletPreferencesModelImpl.ENTITY_CACHE_ENABLED,
116 PortletPreferencesModelImpl.FINDER_CACHE_ENABLED,
117 FINDER_CLASS_NAME_LIST, "countByO_O_P",
118 new String[] {
119 Long.class.getName(), Integer.class.getName(),
120 Long.class.getName()
121 });
122 public static final FinderPath FINDER_PATH_FETCH_BY_O_O_P_P = new FinderPath(PortletPreferencesModelImpl.ENTITY_CACHE_ENABLED,
123 PortletPreferencesModelImpl.FINDER_CACHE_ENABLED,
124 FINDER_CLASS_NAME_ENTITY, "fetchByO_O_P_P",
125 new String[] {
126 Long.class.getName(), Integer.class.getName(),
127 Long.class.getName(), String.class.getName()
128 });
129 public static final FinderPath FINDER_PATH_COUNT_BY_O_O_P_P = new FinderPath(PortletPreferencesModelImpl.ENTITY_CACHE_ENABLED,
130 PortletPreferencesModelImpl.FINDER_CACHE_ENABLED,
131 FINDER_CLASS_NAME_LIST, "countByO_O_P_P",
132 new String[] {
133 Long.class.getName(), Integer.class.getName(),
134 Long.class.getName(), String.class.getName()
135 });
136 public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(PortletPreferencesModelImpl.ENTITY_CACHE_ENABLED,
137 PortletPreferencesModelImpl.FINDER_CACHE_ENABLED,
138 FINDER_CLASS_NAME_LIST, "findAll", new String[0]);
139 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(PortletPreferencesModelImpl.ENTITY_CACHE_ENABLED,
140 PortletPreferencesModelImpl.FINDER_CACHE_ENABLED,
141 FINDER_CLASS_NAME_LIST, "countAll", new String[0]);
142
143 public void cacheResult(PortletPreferences portletPreferences) {
144 EntityCacheUtil.putResult(PortletPreferencesModelImpl.ENTITY_CACHE_ENABLED,
145 PortletPreferencesImpl.class, portletPreferences.getPrimaryKey(),
146 portletPreferences);
147
148 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_O_O_P_P,
149 new Object[] {
150 new Long(portletPreferences.getOwnerId()),
151 new Integer(portletPreferences.getOwnerType()),
152 new Long(portletPreferences.getPlid()),
153
154 portletPreferences.getPortletId()
155 }, portletPreferences);
156 }
157
158 public void cacheResult(List<PortletPreferences> portletPreferenceses) {
159 for (PortletPreferences portletPreferences : portletPreferenceses) {
160 if (EntityCacheUtil.getResult(
161 PortletPreferencesModelImpl.ENTITY_CACHE_ENABLED,
162 PortletPreferencesImpl.class,
163 portletPreferences.getPrimaryKey(), this) == null) {
164 cacheResult(portletPreferences);
165 }
166 }
167 }
168
169 public void clearCache() {
170 CacheRegistry.clear(PortletPreferencesImpl.class.getName());
171 EntityCacheUtil.clearCache(PortletPreferencesImpl.class.getName());
172 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
173 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
174 }
175
176 public PortletPreferences create(long portletPreferencesId) {
177 PortletPreferences portletPreferences = new PortletPreferencesImpl();
178
179 portletPreferences.setNew(true);
180 portletPreferences.setPrimaryKey(portletPreferencesId);
181
182 return portletPreferences;
183 }
184
185 public PortletPreferences remove(long portletPreferencesId)
186 throws NoSuchPortletPreferencesException, SystemException {
187 Session session = null;
188
189 try {
190 session = openSession();
191
192 PortletPreferences portletPreferences = (PortletPreferences)session.get(PortletPreferencesImpl.class,
193 new Long(portletPreferencesId));
194
195 if (portletPreferences == null) {
196 if (_log.isWarnEnabled()) {
197 _log.warn(
198 "No PortletPreferences exists with the primary key " +
199 portletPreferencesId);
200 }
201
202 throw new NoSuchPortletPreferencesException(
203 "No PortletPreferences exists with the primary key " +
204 portletPreferencesId);
205 }
206
207 return remove(portletPreferences);
208 }
209 catch (NoSuchPortletPreferencesException nsee) {
210 throw nsee;
211 }
212 catch (Exception e) {
213 throw processException(e);
214 }
215 finally {
216 closeSession(session);
217 }
218 }
219
220 public PortletPreferences remove(PortletPreferences portletPreferences)
221 throws SystemException {
222 for (ModelListener<PortletPreferences> listener : listeners) {
223 listener.onBeforeRemove(portletPreferences);
224 }
225
226 portletPreferences = removeImpl(portletPreferences);
227
228 for (ModelListener<PortletPreferences> listener : listeners) {
229 listener.onAfterRemove(portletPreferences);
230 }
231
232 return portletPreferences;
233 }
234
235 protected PortletPreferences removeImpl(
236 PortletPreferences portletPreferences) throws SystemException {
237 Session session = null;
238
239 try {
240 session = openSession();
241
242 if (portletPreferences.isCachedModel() ||
243 BatchSessionUtil.isEnabled()) {
244 Object staleObject = session.get(PortletPreferencesImpl.class,
245 portletPreferences.getPrimaryKeyObj());
246
247 if (staleObject != null) {
248 session.evict(staleObject);
249 }
250 }
251
252 session.delete(portletPreferences);
253
254 session.flush();
255 }
256 catch (Exception e) {
257 throw processException(e);
258 }
259 finally {
260 closeSession(session);
261 }
262
263 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
264
265 PortletPreferencesModelImpl portletPreferencesModelImpl = (PortletPreferencesModelImpl)portletPreferences;
266
267 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_O_O_P_P,
268 new Object[] {
269 new Long(portletPreferencesModelImpl.getOriginalOwnerId()),
270 new Integer(portletPreferencesModelImpl.getOriginalOwnerType()),
271 new Long(portletPreferencesModelImpl.getOriginalPlid()),
272
273 portletPreferencesModelImpl.getOriginalPortletId()
274 });
275
276 EntityCacheUtil.removeResult(PortletPreferencesModelImpl.ENTITY_CACHE_ENABLED,
277 PortletPreferencesImpl.class, portletPreferences.getPrimaryKey());
278
279 return portletPreferences;
280 }
281
282
285 public PortletPreferences update(PortletPreferences portletPreferences)
286 throws SystemException {
287 if (_log.isWarnEnabled()) {
288 _log.warn(
289 "Using the deprecated update(PortletPreferences portletPreferences) method. Use update(PortletPreferences portletPreferences, boolean merge) instead.");
290 }
291
292 return update(portletPreferences, false);
293 }
294
295
308 public PortletPreferences update(PortletPreferences portletPreferences,
309 boolean merge) throws SystemException {
310 boolean isNew = portletPreferences.isNew();
311
312 for (ModelListener<PortletPreferences> listener : listeners) {
313 if (isNew) {
314 listener.onBeforeCreate(portletPreferences);
315 }
316 else {
317 listener.onBeforeUpdate(portletPreferences);
318 }
319 }
320
321 portletPreferences = updateImpl(portletPreferences, merge);
322
323 for (ModelListener<PortletPreferences> listener : listeners) {
324 if (isNew) {
325 listener.onAfterCreate(portletPreferences);
326 }
327 else {
328 listener.onAfterUpdate(portletPreferences);
329 }
330 }
331
332 return portletPreferences;
333 }
334
335 public PortletPreferences updateImpl(
336 com.liferay.portal.model.PortletPreferences portletPreferences,
337 boolean merge) throws SystemException {
338 boolean isNew = portletPreferences.isNew();
339
340 PortletPreferencesModelImpl portletPreferencesModelImpl = (PortletPreferencesModelImpl)portletPreferences;
341
342 Session session = null;
343
344 try {
345 session = openSession();
346
347 BatchSessionUtil.update(session, portletPreferences, merge);
348
349 portletPreferences.setNew(false);
350 }
351 catch (Exception e) {
352 throw processException(e);
353 }
354 finally {
355 closeSession(session);
356 }
357
358 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
359
360 EntityCacheUtil.putResult(PortletPreferencesModelImpl.ENTITY_CACHE_ENABLED,
361 PortletPreferencesImpl.class, portletPreferences.getPrimaryKey(),
362 portletPreferences);
363
364 if (!isNew &&
365 ((portletPreferences.getOwnerId() != portletPreferencesModelImpl.getOriginalOwnerId()) ||
366 (portletPreferences.getOwnerType() != portletPreferencesModelImpl.getOriginalOwnerType()) ||
367 (portletPreferences.getPlid() != portletPreferencesModelImpl.getOriginalPlid()) ||
368 !portletPreferences.getPortletId()
369 .equals(portletPreferencesModelImpl.getOriginalPortletId()))) {
370 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_O_O_P_P,
371 new Object[] {
372 new Long(portletPreferencesModelImpl.getOriginalOwnerId()),
373 new Integer(portletPreferencesModelImpl.getOriginalOwnerType()),
374 new Long(portletPreferencesModelImpl.getOriginalPlid()),
375
376 portletPreferencesModelImpl.getOriginalPortletId()
377 });
378 }
379
380 if (isNew ||
381 ((portletPreferences.getOwnerId() != portletPreferencesModelImpl.getOriginalOwnerId()) ||
382 (portletPreferences.getOwnerType() != portletPreferencesModelImpl.getOriginalOwnerType()) ||
383 (portletPreferences.getPlid() != portletPreferencesModelImpl.getOriginalPlid()) ||
384 !portletPreferences.getPortletId()
385 .equals(portletPreferencesModelImpl.getOriginalPortletId()))) {
386 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_O_O_P_P,
387 new Object[] {
388 new Long(portletPreferences.getOwnerId()),
389 new Integer(portletPreferences.getOwnerType()),
390 new Long(portletPreferences.getPlid()),
391
392 portletPreferences.getPortletId()
393 }, portletPreferences);
394 }
395
396 return portletPreferences;
397 }
398
399 public PortletPreferences findByPrimaryKey(long portletPreferencesId)
400 throws NoSuchPortletPreferencesException, SystemException {
401 PortletPreferences portletPreferences = fetchByPrimaryKey(portletPreferencesId);
402
403 if (portletPreferences == null) {
404 if (_log.isWarnEnabled()) {
405 _log.warn("No PortletPreferences exists with the primary key " +
406 portletPreferencesId);
407 }
408
409 throw new NoSuchPortletPreferencesException(
410 "No PortletPreferences exists with the primary key " +
411 portletPreferencesId);
412 }
413
414 return portletPreferences;
415 }
416
417 public PortletPreferences fetchByPrimaryKey(long portletPreferencesId)
418 throws SystemException {
419 PortletPreferences portletPreferences = (PortletPreferences)EntityCacheUtil.getResult(PortletPreferencesModelImpl.ENTITY_CACHE_ENABLED,
420 PortletPreferencesImpl.class, portletPreferencesId, this);
421
422 if (portletPreferences == null) {
423 Session session = null;
424
425 try {
426 session = openSession();
427
428 portletPreferences = (PortletPreferences)session.get(PortletPreferencesImpl.class,
429 new Long(portletPreferencesId));
430 }
431 catch (Exception e) {
432 throw processException(e);
433 }
434 finally {
435 if (portletPreferences != null) {
436 cacheResult(portletPreferences);
437 }
438
439 closeSession(session);
440 }
441 }
442
443 return portletPreferences;
444 }
445
446 public List<PortletPreferences> findByPlid(long plid)
447 throws SystemException {
448 Object[] finderArgs = new Object[] { new Long(plid) };
449
450 List<PortletPreferences> list = (List<PortletPreferences>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_PLID,
451 finderArgs, this);
452
453 if (list == null) {
454 Session session = null;
455
456 try {
457 session = openSession();
458
459 StringBuilder query = new StringBuilder();
460
461 query.append(
462 "FROM com.liferay.portal.model.PortletPreferences WHERE ");
463
464 query.append("plid = ?");
465
466 query.append(" ");
467
468 Query q = session.createQuery(query.toString());
469
470 QueryPos qPos = QueryPos.getInstance(q);
471
472 qPos.add(plid);
473
474 list = q.list();
475 }
476 catch (Exception e) {
477 throw processException(e);
478 }
479 finally {
480 if (list == null) {
481 list = new ArrayList<PortletPreferences>();
482 }
483
484 cacheResult(list);
485
486 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_PLID, finderArgs,
487 list);
488
489 closeSession(session);
490 }
491 }
492
493 return list;
494 }
495
496 public List<PortletPreferences> findByPlid(long plid, int start, int end)
497 throws SystemException {
498 return findByPlid(plid, start, end, null);
499 }
500
501 public List<PortletPreferences> findByPlid(long plid, int start, int end,
502 OrderByComparator obc) throws SystemException {
503 Object[] finderArgs = new Object[] {
504 new Long(plid),
505
506 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
507 };
508
509 List<PortletPreferences> list = (List<PortletPreferences>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_PLID,
510 finderArgs, this);
511
512 if (list == null) {
513 Session session = null;
514
515 try {
516 session = openSession();
517
518 StringBuilder query = new StringBuilder();
519
520 query.append(
521 "FROM com.liferay.portal.model.PortletPreferences WHERE ");
522
523 query.append("plid = ?");
524
525 query.append(" ");
526
527 if (obc != null) {
528 query.append("ORDER BY ");
529 query.append(obc.getOrderBy());
530 }
531
532 Query q = session.createQuery(query.toString());
533
534 QueryPos qPos = QueryPos.getInstance(q);
535
536 qPos.add(plid);
537
538 list = (List<PortletPreferences>)QueryUtil.list(q,
539 getDialect(), start, end);
540 }
541 catch (Exception e) {
542 throw processException(e);
543 }
544 finally {
545 if (list == null) {
546 list = new ArrayList<PortletPreferences>();
547 }
548
549 cacheResult(list);
550
551 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_PLID,
552 finderArgs, list);
553
554 closeSession(session);
555 }
556 }
557
558 return list;
559 }
560
561 public PortletPreferences findByPlid_First(long plid, OrderByComparator obc)
562 throws NoSuchPortletPreferencesException, SystemException {
563 List<PortletPreferences> list = findByPlid(plid, 0, 1, obc);
564
565 if (list.isEmpty()) {
566 StringBuilder msg = new StringBuilder();
567
568 msg.append("No PortletPreferences exists with the key {");
569
570 msg.append("plid=" + plid);
571
572 msg.append(StringPool.CLOSE_CURLY_BRACE);
573
574 throw new NoSuchPortletPreferencesException(msg.toString());
575 }
576 else {
577 return list.get(0);
578 }
579 }
580
581 public PortletPreferences findByPlid_Last(long plid, OrderByComparator obc)
582 throws NoSuchPortletPreferencesException, SystemException {
583 int count = countByPlid(plid);
584
585 List<PortletPreferences> list = findByPlid(plid, count - 1, count, obc);
586
587 if (list.isEmpty()) {
588 StringBuilder msg = new StringBuilder();
589
590 msg.append("No PortletPreferences exists with the key {");
591
592 msg.append("plid=" + plid);
593
594 msg.append(StringPool.CLOSE_CURLY_BRACE);
595
596 throw new NoSuchPortletPreferencesException(msg.toString());
597 }
598 else {
599 return list.get(0);
600 }
601 }
602
603 public PortletPreferences[] findByPlid_PrevAndNext(
604 long portletPreferencesId, long plid, OrderByComparator obc)
605 throws NoSuchPortletPreferencesException, SystemException {
606 PortletPreferences portletPreferences = findByPrimaryKey(portletPreferencesId);
607
608 int count = countByPlid(plid);
609
610 Session session = null;
611
612 try {
613 session = openSession();
614
615 StringBuilder query = new StringBuilder();
616
617 query.append(
618 "FROM com.liferay.portal.model.PortletPreferences WHERE ");
619
620 query.append("plid = ?");
621
622 query.append(" ");
623
624 if (obc != null) {
625 query.append("ORDER BY ");
626 query.append(obc.getOrderBy());
627 }
628
629 Query q = session.createQuery(query.toString());
630
631 QueryPos qPos = QueryPos.getInstance(q);
632
633 qPos.add(plid);
634
635 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
636 portletPreferences);
637
638 PortletPreferences[] array = new PortletPreferencesImpl[3];
639
640 array[0] = (PortletPreferences)objArray[0];
641 array[1] = (PortletPreferences)objArray[1];
642 array[2] = (PortletPreferences)objArray[2];
643
644 return array;
645 }
646 catch (Exception e) {
647 throw processException(e);
648 }
649 finally {
650 closeSession(session);
651 }
652 }
653
654 public List<PortletPreferences> findByP_P(long plid, String portletId)
655 throws SystemException {
656 Object[] finderArgs = new Object[] { new Long(plid), portletId };
657
658 List<PortletPreferences> list = (List<PortletPreferences>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_P_P,
659 finderArgs, this);
660
661 if (list == null) {
662 Session session = null;
663
664 try {
665 session = openSession();
666
667 StringBuilder query = new StringBuilder();
668
669 query.append(
670 "FROM com.liferay.portal.model.PortletPreferences WHERE ");
671
672 query.append("plid = ?");
673
674 query.append(" AND ");
675
676 if (portletId == null) {
677 query.append("portletId IS NULL");
678 }
679 else {
680 query.append("portletId = ?");
681 }
682
683 query.append(" ");
684
685 Query q = session.createQuery(query.toString());
686
687 QueryPos qPos = QueryPos.getInstance(q);
688
689 qPos.add(plid);
690
691 if (portletId != null) {
692 qPos.add(portletId);
693 }
694
695 list = q.list();
696 }
697 catch (Exception e) {
698 throw processException(e);
699 }
700 finally {
701 if (list == null) {
702 list = new ArrayList<PortletPreferences>();
703 }
704
705 cacheResult(list);
706
707 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_P_P, finderArgs,
708 list);
709
710 closeSession(session);
711 }
712 }
713
714 return list;
715 }
716
717 public List<PortletPreferences> findByP_P(long plid, String portletId,
718 int start, int end) throws SystemException {
719 return findByP_P(plid, portletId, start, end, null);
720 }
721
722 public List<PortletPreferences> findByP_P(long plid, String portletId,
723 int start, int end, OrderByComparator obc) throws SystemException {
724 Object[] finderArgs = new Object[] {
725 new Long(plid),
726
727 portletId,
728
729 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
730 };
731
732 List<PortletPreferences> list = (List<PortletPreferences>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_P_P,
733 finderArgs, this);
734
735 if (list == null) {
736 Session session = null;
737
738 try {
739 session = openSession();
740
741 StringBuilder query = new StringBuilder();
742
743 query.append(
744 "FROM com.liferay.portal.model.PortletPreferences WHERE ");
745
746 query.append("plid = ?");
747
748 query.append(" AND ");
749
750 if (portletId == null) {
751 query.append("portletId IS NULL");
752 }
753 else {
754 query.append("portletId = ?");
755 }
756
757 query.append(" ");
758
759 if (obc != null) {
760 query.append("ORDER BY ");
761 query.append(obc.getOrderBy());
762 }
763
764 Query q = session.createQuery(query.toString());
765
766 QueryPos qPos = QueryPos.getInstance(q);
767
768 qPos.add(plid);
769
770 if (portletId != null) {
771 qPos.add(portletId);
772 }
773
774 list = (List<PortletPreferences>)QueryUtil.list(q,
775 getDialect(), start, end);
776 }
777 catch (Exception e) {
778 throw processException(e);
779 }
780 finally {
781 if (list == null) {
782 list = new ArrayList<PortletPreferences>();
783 }
784
785 cacheResult(list);
786
787 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_P_P,
788 finderArgs, list);
789
790 closeSession(session);
791 }
792 }
793
794 return list;
795 }
796
797 public PortletPreferences findByP_P_First(long plid, String portletId,
798 OrderByComparator obc)
799 throws NoSuchPortletPreferencesException, SystemException {
800 List<PortletPreferences> list = findByP_P(plid, portletId, 0, 1, obc);
801
802 if (list.isEmpty()) {
803 StringBuilder msg = new StringBuilder();
804
805 msg.append("No PortletPreferences exists with the key {");
806
807 msg.append("plid=" + plid);
808
809 msg.append(", ");
810 msg.append("portletId=" + portletId);
811
812 msg.append(StringPool.CLOSE_CURLY_BRACE);
813
814 throw new NoSuchPortletPreferencesException(msg.toString());
815 }
816 else {
817 return list.get(0);
818 }
819 }
820
821 public PortletPreferences findByP_P_Last(long plid, String portletId,
822 OrderByComparator obc)
823 throws NoSuchPortletPreferencesException, SystemException {
824 int count = countByP_P(plid, portletId);
825
826 List<PortletPreferences> list = findByP_P(plid, portletId, count - 1,
827 count, obc);
828
829 if (list.isEmpty()) {
830 StringBuilder msg = new StringBuilder();
831
832 msg.append("No PortletPreferences exists with the key {");
833
834 msg.append("plid=" + plid);
835
836 msg.append(", ");
837 msg.append("portletId=" + portletId);
838
839 msg.append(StringPool.CLOSE_CURLY_BRACE);
840
841 throw new NoSuchPortletPreferencesException(msg.toString());
842 }
843 else {
844 return list.get(0);
845 }
846 }
847
848 public PortletPreferences[] findByP_P_PrevAndNext(
849 long portletPreferencesId, long plid, String portletId,
850 OrderByComparator obc)
851 throws NoSuchPortletPreferencesException, SystemException {
852 PortletPreferences portletPreferences = findByPrimaryKey(portletPreferencesId);
853
854 int count = countByP_P(plid, portletId);
855
856 Session session = null;
857
858 try {
859 session = openSession();
860
861 StringBuilder query = new StringBuilder();
862
863 query.append(
864 "FROM com.liferay.portal.model.PortletPreferences WHERE ");
865
866 query.append("plid = ?");
867
868 query.append(" AND ");
869
870 if (portletId == null) {
871 query.append("portletId IS NULL");
872 }
873 else {
874 query.append("portletId = ?");
875 }
876
877 query.append(" ");
878
879 if (obc != null) {
880 query.append("ORDER BY ");
881 query.append(obc.getOrderBy());
882 }
883
884 Query q = session.createQuery(query.toString());
885
886 QueryPos qPos = QueryPos.getInstance(q);
887
888 qPos.add(plid);
889
890 if (portletId != null) {
891 qPos.add(portletId);
892 }
893
894 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
895 portletPreferences);
896
897 PortletPreferences[] array = new PortletPreferencesImpl[3];
898
899 array[0] = (PortletPreferences)objArray[0];
900 array[1] = (PortletPreferences)objArray[1];
901 array[2] = (PortletPreferences)objArray[2];
902
903 return array;
904 }
905 catch (Exception e) {
906 throw processException(e);
907 }
908 finally {
909 closeSession(session);
910 }
911 }
912
913 public List<PortletPreferences> findByO_O_P(long ownerId, int ownerType,
914 long plid) throws SystemException {
915 Object[] finderArgs = new Object[] {
916 new Long(ownerId), new Integer(ownerType), new Long(plid)
917 };
918
919 List<PortletPreferences> list = (List<PortletPreferences>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_O_O_P,
920 finderArgs, this);
921
922 if (list == null) {
923 Session session = null;
924
925 try {
926 session = openSession();
927
928 StringBuilder query = new StringBuilder();
929
930 query.append(
931 "FROM com.liferay.portal.model.PortletPreferences WHERE ");
932
933 query.append("ownerId = ?");
934
935 query.append(" AND ");
936
937 query.append("ownerType = ?");
938
939 query.append(" AND ");
940
941 query.append("plid = ?");
942
943 query.append(" ");
944
945 Query q = session.createQuery(query.toString());
946
947 QueryPos qPos = QueryPos.getInstance(q);
948
949 qPos.add(ownerId);
950
951 qPos.add(ownerType);
952
953 qPos.add(plid);
954
955 list = q.list();
956 }
957 catch (Exception e) {
958 throw processException(e);
959 }
960 finally {
961 if (list == null) {
962 list = new ArrayList<PortletPreferences>();
963 }
964
965 cacheResult(list);
966
967 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_O_O_P,
968 finderArgs, list);
969
970 closeSession(session);
971 }
972 }
973
974 return list;
975 }
976
977 public List<PortletPreferences> findByO_O_P(long ownerId, int ownerType,
978 long plid, int start, int end) throws SystemException {
979 return findByO_O_P(ownerId, ownerType, plid, start, end, null);
980 }
981
982 public List<PortletPreferences> findByO_O_P(long ownerId, int ownerType,
983 long plid, int start, int end, OrderByComparator obc)
984 throws SystemException {
985 Object[] finderArgs = new Object[] {
986 new Long(ownerId), new Integer(ownerType), new Long(plid),
987
988 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
989 };
990
991 List<PortletPreferences> list = (List<PortletPreferences>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_O_O_P,
992 finderArgs, this);
993
994 if (list == null) {
995 Session session = null;
996
997 try {
998 session = openSession();
999
1000 StringBuilder query = new StringBuilder();
1001
1002 query.append(
1003 "FROM com.liferay.portal.model.PortletPreferences WHERE ");
1004
1005 query.append("ownerId = ?");
1006
1007 query.append(" AND ");
1008
1009 query.append("ownerType = ?");
1010
1011 query.append(" AND ");
1012
1013 query.append("plid = ?");
1014
1015 query.append(" ");
1016
1017 if (obc != null) {
1018 query.append("ORDER BY ");
1019 query.append(obc.getOrderBy());
1020 }
1021
1022 Query q = session.createQuery(query.toString());
1023
1024 QueryPos qPos = QueryPos.getInstance(q);
1025
1026 qPos.add(ownerId);
1027
1028 qPos.add(ownerType);
1029
1030 qPos.add(plid);
1031
1032 list = (List<PortletPreferences>)QueryUtil.list(q,
1033 getDialect(), start, end);
1034 }
1035 catch (Exception e) {
1036 throw processException(e);
1037 }
1038 finally {
1039 if (list == null) {
1040 list = new ArrayList<PortletPreferences>();
1041 }
1042
1043 cacheResult(list);
1044
1045 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_O_O_P,
1046 finderArgs, list);
1047
1048 closeSession(session);
1049 }
1050 }
1051
1052 return list;
1053 }
1054
1055 public PortletPreferences findByO_O_P_First(long ownerId, int ownerType,
1056 long plid, OrderByComparator obc)
1057 throws NoSuchPortletPreferencesException, SystemException {
1058 List<PortletPreferences> list = findByO_O_P(ownerId, ownerType, plid,
1059 0, 1, obc);
1060
1061 if (list.isEmpty()) {
1062 StringBuilder msg = new StringBuilder();
1063
1064 msg.append("No PortletPreferences exists with the key {");
1065
1066 msg.append("ownerId=" + ownerId);
1067
1068 msg.append(", ");
1069 msg.append("ownerType=" + ownerType);
1070
1071 msg.append(", ");
1072 msg.append("plid=" + plid);
1073
1074 msg.append(StringPool.CLOSE_CURLY_BRACE);
1075
1076 throw new NoSuchPortletPreferencesException(msg.toString());
1077 }
1078 else {
1079 return list.get(0);
1080 }
1081 }
1082
1083 public PortletPreferences findByO_O_P_Last(long ownerId, int ownerType,
1084 long plid, OrderByComparator obc)
1085 throws NoSuchPortletPreferencesException, SystemException {
1086 int count = countByO_O_P(ownerId, ownerType, plid);
1087
1088 List<PortletPreferences> list = findByO_O_P(ownerId, ownerType, plid,
1089 count - 1, count, obc);
1090
1091 if (list.isEmpty()) {
1092 StringBuilder msg = new StringBuilder();
1093
1094 msg.append("No PortletPreferences exists with the key {");
1095
1096 msg.append("ownerId=" + ownerId);
1097
1098 msg.append(", ");
1099 msg.append("ownerType=" + ownerType);
1100
1101 msg.append(", ");
1102 msg.append("plid=" + plid);
1103
1104 msg.append(StringPool.CLOSE_CURLY_BRACE);
1105
1106 throw new NoSuchPortletPreferencesException(msg.toString());
1107 }
1108 else {
1109 return list.get(0);
1110 }
1111 }
1112
1113 public PortletPreferences[] findByO_O_P_PrevAndNext(
1114 long portletPreferencesId, long ownerId, int ownerType, long plid,
1115 OrderByComparator obc)
1116 throws NoSuchPortletPreferencesException, SystemException {
1117 PortletPreferences portletPreferences = findByPrimaryKey(portletPreferencesId);
1118
1119 int count = countByO_O_P(ownerId, ownerType, plid);
1120
1121 Session session = null;
1122
1123 try {
1124 session = openSession();
1125
1126 StringBuilder query = new StringBuilder();
1127
1128 query.append(
1129 "FROM com.liferay.portal.model.PortletPreferences WHERE ");
1130
1131 query.append("ownerId = ?");
1132
1133 query.append(" AND ");
1134
1135 query.append("ownerType = ?");
1136
1137 query.append(" AND ");
1138
1139 query.append("plid = ?");
1140
1141 query.append(" ");
1142
1143 if (obc != null) {
1144 query.append("ORDER BY ");
1145 query.append(obc.getOrderBy());
1146 }
1147
1148 Query q = session.createQuery(query.toString());
1149
1150 QueryPos qPos = QueryPos.getInstance(q);
1151
1152 qPos.add(ownerId);
1153
1154 qPos.add(ownerType);
1155
1156 qPos.add(plid);
1157
1158 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
1159 portletPreferences);
1160
1161 PortletPreferences[] array = new PortletPreferencesImpl[3];
1162
1163 array[0] = (PortletPreferences)objArray[0];
1164 array[1] = (PortletPreferences)objArray[1];
1165 array[2] = (PortletPreferences)objArray[2];
1166
1167 return array;
1168 }
1169 catch (Exception e) {
1170 throw processException(e);
1171 }
1172 finally {
1173 closeSession(session);
1174 }
1175 }
1176
1177 public PortletPreferences findByO_O_P_P(long ownerId, int ownerType,
1178 long plid, String portletId)
1179 throws NoSuchPortletPreferencesException, SystemException {
1180 PortletPreferences portletPreferences = fetchByO_O_P_P(ownerId,
1181 ownerType, plid, portletId);
1182
1183 if (portletPreferences == null) {
1184 StringBuilder msg = new StringBuilder();
1185
1186 msg.append("No PortletPreferences exists with the key {");
1187
1188 msg.append("ownerId=" + ownerId);
1189
1190 msg.append(", ");
1191 msg.append("ownerType=" + ownerType);
1192
1193 msg.append(", ");
1194 msg.append("plid=" + plid);
1195
1196 msg.append(", ");
1197 msg.append("portletId=" + portletId);
1198
1199 msg.append(StringPool.CLOSE_CURLY_BRACE);
1200
1201 if (_log.isWarnEnabled()) {
1202 _log.warn(msg.toString());
1203 }
1204
1205 throw new NoSuchPortletPreferencesException(msg.toString());
1206 }
1207
1208 return portletPreferences;
1209 }
1210
1211 public PortletPreferences fetchByO_O_P_P(long ownerId, int ownerType,
1212 long plid, String portletId) throws SystemException {
1213 return fetchByO_O_P_P(ownerId, ownerType, plid, portletId, true);
1214 }
1215
1216 public PortletPreferences fetchByO_O_P_P(long ownerId, int ownerType,
1217 long plid, String portletId, boolean retrieveFromCache)
1218 throws SystemException {
1219 Object[] finderArgs = new Object[] {
1220 new Long(ownerId), new Integer(ownerType), new Long(plid),
1221
1222 portletId
1223 };
1224
1225 Object result = null;
1226
1227 if (retrieveFromCache) {
1228 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_O_O_P_P,
1229 finderArgs, this);
1230 }
1231
1232 if (result == null) {
1233 Session session = null;
1234
1235 try {
1236 session = openSession();
1237
1238 StringBuilder query = new StringBuilder();
1239
1240 query.append(
1241 "FROM com.liferay.portal.model.PortletPreferences WHERE ");
1242
1243 query.append("ownerId = ?");
1244
1245 query.append(" AND ");
1246
1247 query.append("ownerType = ?");
1248
1249 query.append(" AND ");
1250
1251 query.append("plid = ?");
1252
1253 query.append(" AND ");
1254
1255 if (portletId == null) {
1256 query.append("portletId IS NULL");
1257 }
1258 else {
1259 query.append("portletId = ?");
1260 }
1261
1262 query.append(" ");
1263
1264 Query q = session.createQuery(query.toString());
1265
1266 QueryPos qPos = QueryPos.getInstance(q);
1267
1268 qPos.add(ownerId);
1269
1270 qPos.add(ownerType);
1271
1272 qPos.add(plid);
1273
1274 if (portletId != null) {
1275 qPos.add(portletId);
1276 }
1277
1278 List<PortletPreferences> list = q.list();
1279
1280 result = list;
1281
1282 PortletPreferences portletPreferences = null;
1283
1284 if (list.isEmpty()) {
1285 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_O_O_P_P,
1286 finderArgs, list);
1287 }
1288 else {
1289 portletPreferences = list.get(0);
1290
1291 cacheResult(portletPreferences);
1292
1293 if ((portletPreferences.getOwnerId() != ownerId) ||
1294 (portletPreferences.getOwnerType() != ownerType) ||
1295 (portletPreferences.getPlid() != plid) ||
1296 (portletPreferences.getPortletId() == null) ||
1297 !portletPreferences.getPortletId().equals(portletId)) {
1298 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_O_O_P_P,
1299 finderArgs, list);
1300 }
1301 }
1302
1303 return portletPreferences;
1304 }
1305 catch (Exception e) {
1306 throw processException(e);
1307 }
1308 finally {
1309 if (result == null) {
1310 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_O_O_P_P,
1311 finderArgs, new ArrayList<PortletPreferences>());
1312 }
1313
1314 closeSession(session);
1315 }
1316 }
1317 else {
1318 if (result instanceof List) {
1319 return null;
1320 }
1321 else {
1322 return (PortletPreferences)result;
1323 }
1324 }
1325 }
1326
1327 public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery)
1328 throws SystemException {
1329 Session session = null;
1330
1331 try {
1332 session = openSession();
1333
1334 dynamicQuery.compile(session);
1335
1336 return dynamicQuery.list();
1337 }
1338 catch (Exception e) {
1339 throw processException(e);
1340 }
1341 finally {
1342 closeSession(session);
1343 }
1344 }
1345
1346 public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery,
1347 int start, int end) throws SystemException {
1348 Session session = null;
1349
1350 try {
1351 session = openSession();
1352
1353 dynamicQuery.setLimit(start, end);
1354
1355 dynamicQuery.compile(session);
1356
1357 return dynamicQuery.list();
1358 }
1359 catch (Exception e) {
1360 throw processException(e);
1361 }
1362 finally {
1363 closeSession(session);
1364 }
1365 }
1366
1367 public List<PortletPreferences> findAll() throws SystemException {
1368 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1369 }
1370
1371 public List<PortletPreferences> findAll(int start, int end)
1372 throws SystemException {
1373 return findAll(start, end, null);
1374 }
1375
1376 public List<PortletPreferences> findAll(int start, int end,
1377 OrderByComparator obc) throws SystemException {
1378 Object[] finderArgs = new Object[] {
1379 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
1380 };
1381
1382 List<PortletPreferences> list = (List<PortletPreferences>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
1383 finderArgs, this);
1384
1385 if (list == null) {
1386 Session session = null;
1387
1388 try {
1389 session = openSession();
1390
1391 StringBuilder query = new StringBuilder();
1392
1393 query.append(
1394 "FROM com.liferay.portal.model.PortletPreferences ");
1395
1396 if (obc != null) {
1397 query.append("ORDER BY ");
1398 query.append(obc.getOrderBy());
1399 }
1400
1401 Query q = session.createQuery(query.toString());
1402
1403 if (obc == null) {
1404 list = (List<PortletPreferences>)QueryUtil.list(q,
1405 getDialect(), start, end, false);
1406
1407 Collections.sort(list);
1408 }
1409 else {
1410 list = (List<PortletPreferences>)QueryUtil.list(q,
1411 getDialect(), start, end);
1412 }
1413 }
1414 catch (Exception e) {
1415 throw processException(e);
1416 }
1417 finally {
1418 if (list == null) {
1419 list = new ArrayList<PortletPreferences>();
1420 }
1421
1422 cacheResult(list);
1423
1424 FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
1425
1426 closeSession(session);
1427 }
1428 }
1429
1430 return list;
1431 }
1432
1433 public void removeByPlid(long plid) throws SystemException {
1434 for (PortletPreferences portletPreferences : findByPlid(plid)) {
1435 remove(portletPreferences);
1436 }
1437 }
1438
1439 public void removeByP_P(long plid, String portletId)
1440 throws SystemException {
1441 for (PortletPreferences portletPreferences : findByP_P(plid, portletId)) {
1442 remove(portletPreferences);
1443 }
1444 }
1445
1446 public void removeByO_O_P(long ownerId, int ownerType, long plid)
1447 throws SystemException {
1448 for (PortletPreferences portletPreferences : findByO_O_P(ownerId,
1449 ownerType, plid)) {
1450 remove(portletPreferences);
1451 }
1452 }
1453
1454 public void removeByO_O_P_P(long ownerId, int ownerType, long plid,
1455 String portletId)
1456 throws NoSuchPortletPreferencesException, SystemException {
1457 PortletPreferences portletPreferences = findByO_O_P_P(ownerId,
1458 ownerType, plid, portletId);
1459
1460 remove(portletPreferences);
1461 }
1462
1463 public void removeAll() throws SystemException {
1464 for (PortletPreferences portletPreferences : findAll()) {
1465 remove(portletPreferences);
1466 }
1467 }
1468
1469 public int countByPlid(long plid) throws SystemException {
1470 Object[] finderArgs = new Object[] { new Long(plid) };
1471
1472 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_PLID,
1473 finderArgs, this);
1474
1475 if (count == null) {
1476 Session session = null;
1477
1478 try {
1479 session = openSession();
1480
1481 StringBuilder query = new StringBuilder();
1482
1483 query.append("SELECT COUNT(*) ");
1484 query.append(
1485 "FROM com.liferay.portal.model.PortletPreferences WHERE ");
1486
1487 query.append("plid = ?");
1488
1489 query.append(" ");
1490
1491 Query q = session.createQuery(query.toString());
1492
1493 QueryPos qPos = QueryPos.getInstance(q);
1494
1495 qPos.add(plid);
1496
1497 count = (Long)q.uniqueResult();
1498 }
1499 catch (Exception e) {
1500 throw processException(e);
1501 }
1502 finally {
1503 if (count == null) {
1504 count = Long.valueOf(0);
1505 }
1506
1507 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_PLID,
1508 finderArgs, count);
1509
1510 closeSession(session);
1511 }
1512 }
1513
1514 return count.intValue();
1515 }
1516
1517 public int countByP_P(long plid, String portletId)
1518 throws SystemException {
1519 Object[] finderArgs = new Object[] { new Long(plid), portletId };
1520
1521 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_P_P,
1522 finderArgs, this);
1523
1524 if (count == null) {
1525 Session session = null;
1526
1527 try {
1528 session = openSession();
1529
1530 StringBuilder query = new StringBuilder();
1531
1532 query.append("SELECT COUNT(*) ");
1533 query.append(
1534 "FROM com.liferay.portal.model.PortletPreferences WHERE ");
1535
1536 query.append("plid = ?");
1537
1538 query.append(" AND ");
1539
1540 if (portletId == null) {
1541 query.append("portletId IS NULL");
1542 }
1543 else {
1544 query.append("portletId = ?");
1545 }
1546
1547 query.append(" ");
1548
1549 Query q = session.createQuery(query.toString());
1550
1551 QueryPos qPos = QueryPos.getInstance(q);
1552
1553 qPos.add(plid);
1554
1555 if (portletId != null) {
1556 qPos.add(portletId);
1557 }
1558
1559 count = (Long)q.uniqueResult();
1560 }
1561 catch (Exception e) {
1562 throw processException(e);
1563 }
1564 finally {
1565 if (count == null) {
1566 count = Long.valueOf(0);
1567 }
1568
1569 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_P_P, finderArgs,
1570 count);
1571
1572 closeSession(session);
1573 }
1574 }
1575
1576 return count.intValue();
1577 }
1578
1579 public int countByO_O_P(long ownerId, int ownerType, long plid)
1580 throws SystemException {
1581 Object[] finderArgs = new Object[] {
1582 new Long(ownerId), new Integer(ownerType), new Long(plid)
1583 };
1584
1585 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_O_O_P,
1586 finderArgs, this);
1587
1588 if (count == null) {
1589 Session session = null;
1590
1591 try {
1592 session = openSession();
1593
1594 StringBuilder query = new StringBuilder();
1595
1596 query.append("SELECT COUNT(*) ");
1597 query.append(
1598 "FROM com.liferay.portal.model.PortletPreferences WHERE ");
1599
1600 query.append("ownerId = ?");
1601
1602 query.append(" AND ");
1603
1604 query.append("ownerType = ?");
1605
1606 query.append(" AND ");
1607
1608 query.append("plid = ?");
1609
1610 query.append(" ");
1611
1612 Query q = session.createQuery(query.toString());
1613
1614 QueryPos qPos = QueryPos.getInstance(q);
1615
1616 qPos.add(ownerId);
1617
1618 qPos.add(ownerType);
1619
1620 qPos.add(plid);
1621
1622 count = (Long)q.uniqueResult();
1623 }
1624 catch (Exception e) {
1625 throw processException(e);
1626 }
1627 finally {
1628 if (count == null) {
1629 count = Long.valueOf(0);
1630 }
1631
1632 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_O_O_P,
1633 finderArgs, count);
1634
1635 closeSession(session);
1636 }
1637 }
1638
1639 return count.intValue();
1640 }
1641
1642 public int countByO_O_P_P(long ownerId, int ownerType, long plid,
1643 String portletId) throws SystemException {
1644 Object[] finderArgs = new Object[] {
1645 new Long(ownerId), new Integer(ownerType), new Long(plid),
1646
1647 portletId
1648 };
1649
1650 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_O_O_P_P,
1651 finderArgs, this);
1652
1653 if (count == null) {
1654 Session session = null;
1655
1656 try {
1657 session = openSession();
1658
1659 StringBuilder query = new StringBuilder();
1660
1661 query.append("SELECT COUNT(*) ");
1662 query.append(
1663 "FROM com.liferay.portal.model.PortletPreferences WHERE ");
1664
1665 query.append("ownerId = ?");
1666
1667 query.append(" AND ");
1668
1669 query.append("ownerType = ?");
1670
1671 query.append(" AND ");
1672
1673 query.append("plid = ?");
1674
1675 query.append(" AND ");
1676
1677 if (portletId == null) {
1678 query.append("portletId IS NULL");
1679 }
1680 else {
1681 query.append("portletId = ?");
1682 }
1683
1684 query.append(" ");
1685
1686 Query q = session.createQuery(query.toString());
1687
1688 QueryPos qPos = QueryPos.getInstance(q);
1689
1690 qPos.add(ownerId);
1691
1692 qPos.add(ownerType);
1693
1694 qPos.add(plid);
1695
1696 if (portletId != null) {
1697 qPos.add(portletId);
1698 }
1699
1700 count = (Long)q.uniqueResult();
1701 }
1702 catch (Exception e) {
1703 throw processException(e);
1704 }
1705 finally {
1706 if (count == null) {
1707 count = Long.valueOf(0);
1708 }
1709
1710 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_O_O_P_P,
1711 finderArgs, count);
1712
1713 closeSession(session);
1714 }
1715 }
1716
1717 return count.intValue();
1718 }
1719
1720 public int countAll() throws SystemException {
1721 Object[] finderArgs = new Object[0];
1722
1723 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1724 finderArgs, this);
1725
1726 if (count == null) {
1727 Session session = null;
1728
1729 try {
1730 session = openSession();
1731
1732 Query q = session.createQuery(
1733 "SELECT COUNT(*) FROM com.liferay.portal.model.PortletPreferences");
1734
1735 count = (Long)q.uniqueResult();
1736 }
1737 catch (Exception e) {
1738 throw processException(e);
1739 }
1740 finally {
1741 if (count == null) {
1742 count = Long.valueOf(0);
1743 }
1744
1745 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
1746 count);
1747
1748 closeSession(session);
1749 }
1750 }
1751
1752 return count.intValue();
1753 }
1754
1755 public void afterPropertiesSet() {
1756 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1757 com.liferay.portal.util.PropsUtil.get(
1758 "value.object.listener.com.liferay.portal.model.PortletPreferences")));
1759
1760 if (listenerClassNames.length > 0) {
1761 try {
1762 List<ModelListener<PortletPreferences>> listenersList = new ArrayList<ModelListener<PortletPreferences>>();
1763
1764 for (String listenerClassName : listenerClassNames) {
1765 listenersList.add((ModelListener<PortletPreferences>)Class.forName(
1766 listenerClassName).newInstance());
1767 }
1768
1769 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1770 }
1771 catch (Exception e) {
1772 _log.error(e);
1773 }
1774 }
1775 }
1776
1777 @BeanReference(name = "com.liferay.portal.service.persistence.AccountPersistence.impl")
1778 protected com.liferay.portal.service.persistence.AccountPersistence accountPersistence;
1779 @BeanReference(name = "com.liferay.portal.service.persistence.AddressPersistence.impl")
1780 protected com.liferay.portal.service.persistence.AddressPersistence addressPersistence;
1781 @BeanReference(name = "com.liferay.portal.service.persistence.BrowserTrackerPersistence.impl")
1782 protected com.liferay.portal.service.persistence.BrowserTrackerPersistence browserTrackerPersistence;
1783 @BeanReference(name = "com.liferay.portal.service.persistence.ClassNamePersistence.impl")
1784 protected com.liferay.portal.service.persistence.ClassNamePersistence classNamePersistence;
1785 @BeanReference(name = "com.liferay.portal.service.persistence.CompanyPersistence.impl")
1786 protected com.liferay.portal.service.persistence.CompanyPersistence companyPersistence;
1787 @BeanReference(name = "com.liferay.portal.service.persistence.ContactPersistence.impl")
1788 protected com.liferay.portal.service.persistence.ContactPersistence contactPersistence;
1789 @BeanReference(name = "com.liferay.portal.service.persistence.CountryPersistence.impl")
1790 protected com.liferay.portal.service.persistence.CountryPersistence countryPersistence;
1791 @BeanReference(name = "com.liferay.portal.service.persistence.EmailAddressPersistence.impl")
1792 protected com.liferay.portal.service.persistence.EmailAddressPersistence emailAddressPersistence;
1793 @BeanReference(name = "com.liferay.portal.service.persistence.GroupPersistence.impl")
1794 protected com.liferay.portal.service.persistence.GroupPersistence groupPersistence;
1795 @BeanReference(name = "com.liferay.portal.service.persistence.ImagePersistence.impl")
1796 protected com.liferay.portal.service.persistence.ImagePersistence imagePersistence;
1797 @BeanReference(name = "com.liferay.portal.service.persistence.LayoutPersistence.impl")
1798 protected com.liferay.portal.service.persistence.LayoutPersistence layoutPersistence;
1799 @BeanReference(name = "com.liferay.portal.service.persistence.LayoutSetPersistence.impl")
1800 protected com.liferay.portal.service.persistence.LayoutSetPersistence layoutSetPersistence;
1801 @BeanReference(name = "com.liferay.portal.service.persistence.ListTypePersistence.impl")
1802 protected com.liferay.portal.service.persistence.ListTypePersistence listTypePersistence;
1803 @BeanReference(name = "com.liferay.portal.service.persistence.MembershipRequestPersistence.impl")
1804 protected com.liferay.portal.service.persistence.MembershipRequestPersistence membershipRequestPersistence;
1805 @BeanReference(name = "com.liferay.portal.service.persistence.OrganizationPersistence.impl")
1806 protected com.liferay.portal.service.persistence.OrganizationPersistence organizationPersistence;
1807 @BeanReference(name = "com.liferay.portal.service.persistence.OrgGroupPermissionPersistence.impl")
1808 protected com.liferay.portal.service.persistence.OrgGroupPermissionPersistence orgGroupPermissionPersistence;
1809 @BeanReference(name = "com.liferay.portal.service.persistence.OrgGroupRolePersistence.impl")
1810 protected com.liferay.portal.service.persistence.OrgGroupRolePersistence orgGroupRolePersistence;
1811 @BeanReference(name = "com.liferay.portal.service.persistence.OrgLaborPersistence.impl")
1812 protected com.liferay.portal.service.persistence.OrgLaborPersistence orgLaborPersistence;
1813 @BeanReference(name = "com.liferay.portal.service.persistence.PasswordPolicyPersistence.impl")
1814 protected com.liferay.portal.service.persistence.PasswordPolicyPersistence passwordPolicyPersistence;
1815 @BeanReference(name = "com.liferay.portal.service.persistence.PasswordPolicyRelPersistence.impl")
1816 protected com.liferay.portal.service.persistence.PasswordPolicyRelPersistence passwordPolicyRelPersistence;
1817 @BeanReference(name = "com.liferay.portal.service.persistence.PasswordTrackerPersistence.impl")
1818 protected com.liferay.portal.service.persistence.PasswordTrackerPersistence passwordTrackerPersistence;
1819 @BeanReference(name = "com.liferay.portal.service.persistence.PermissionPersistence.impl")
1820 protected com.liferay.portal.service.persistence.PermissionPersistence permissionPersistence;
1821 @BeanReference(name = "com.liferay.portal.service.persistence.PhonePersistence.impl")
1822 protected com.liferay.portal.service.persistence.PhonePersistence phonePersistence;
1823 @BeanReference(name = "com.liferay.portal.service.persistence.PluginSettingPersistence.impl")
1824 protected com.liferay.portal.service.persistence.PluginSettingPersistence pluginSettingPersistence;
1825 @BeanReference(name = "com.liferay.portal.service.persistence.PortletPersistence.impl")
1826 protected com.liferay.portal.service.persistence.PortletPersistence portletPersistence;
1827 @BeanReference(name = "com.liferay.portal.service.persistence.PortletItemPersistence.impl")
1828 protected com.liferay.portal.service.persistence.PortletItemPersistence portletItemPersistence;
1829 @BeanReference(name = "com.liferay.portal.service.persistence.PortletPreferencesPersistence.impl")
1830 protected com.liferay.portal.service.persistence.PortletPreferencesPersistence portletPreferencesPersistence;
1831 @BeanReference(name = "com.liferay.portal.service.persistence.RegionPersistence.impl")
1832 protected com.liferay.portal.service.persistence.RegionPersistence regionPersistence;
1833 @BeanReference(name = "com.liferay.portal.service.persistence.ReleasePersistence.impl")
1834 protected com.liferay.portal.service.persistence.ReleasePersistence releasePersistence;
1835 @BeanReference(name = "com.liferay.portal.service.persistence.ResourcePersistence.impl")
1836 protected com.liferay.portal.service.persistence.ResourcePersistence resourcePersistence;
1837 @BeanReference(name = "com.liferay.portal.service.persistence.ResourceActionPersistence.impl")
1838 protected com.liferay.portal.service.persistence.ResourceActionPersistence resourceActionPersistence;
1839 @BeanReference(name = "com.liferay.portal.service.persistence.ResourceCodePersistence.impl")
1840 protected com.liferay.portal.service.persistence.ResourceCodePersistence resourceCodePersistence;
1841 @BeanReference(name = "com.liferay.portal.service.persistence.ResourcePermissionPersistence.impl")
1842 protected com.liferay.portal.service.persistence.ResourcePermissionPersistence resourcePermissionPersistence;
1843 @BeanReference(name = "com.liferay.portal.service.persistence.RolePersistence.impl")
1844 protected com.liferay.portal.service.persistence.RolePersistence rolePersistence;
1845 @BeanReference(name = "com.liferay.portal.service.persistence.ServiceComponentPersistence.impl")
1846 protected com.liferay.portal.service.persistence.ServiceComponentPersistence serviceComponentPersistence;
1847 @BeanReference(name = "com.liferay.portal.service.persistence.ShardPersistence.impl")
1848 protected com.liferay.portal.service.persistence.ShardPersistence shardPersistence;
1849 @BeanReference(name = "com.liferay.portal.service.persistence.SubscriptionPersistence.impl")
1850 protected com.liferay.portal.service.persistence.SubscriptionPersistence subscriptionPersistence;
1851 @BeanReference(name = "com.liferay.portal.service.persistence.UserPersistence.impl")
1852 protected com.liferay.portal.service.persistence.UserPersistence userPersistence;
1853 @BeanReference(name = "com.liferay.portal.service.persistence.UserGroupPersistence.impl")
1854 protected com.liferay.portal.service.persistence.UserGroupPersistence userGroupPersistence;
1855 @BeanReference(name = "com.liferay.portal.service.persistence.UserGroupRolePersistence.impl")
1856 protected com.liferay.portal.service.persistence.UserGroupRolePersistence userGroupRolePersistence;
1857 @BeanReference(name = "com.liferay.portal.service.persistence.UserIdMapperPersistence.impl")
1858 protected com.liferay.portal.service.persistence.UserIdMapperPersistence userIdMapperPersistence;
1859 @BeanReference(name = "com.liferay.portal.service.persistence.UserTrackerPersistence.impl")
1860 protected com.liferay.portal.service.persistence.UserTrackerPersistence userTrackerPersistence;
1861 @BeanReference(name = "com.liferay.portal.service.persistence.UserTrackerPathPersistence.impl")
1862 protected com.liferay.portal.service.persistence.UserTrackerPathPersistence userTrackerPathPersistence;
1863 @BeanReference(name = "com.liferay.portal.service.persistence.WebDAVPropsPersistence.impl")
1864 protected com.liferay.portal.service.persistence.WebDAVPropsPersistence webDAVPropsPersistence;
1865 @BeanReference(name = "com.liferay.portal.service.persistence.WebsitePersistence.impl")
1866 protected com.liferay.portal.service.persistence.WebsitePersistence websitePersistence;
1867 private static Log _log = LogFactoryUtil.getLog(PortletPreferencesPersistenceImpl.class);
1868}