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