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