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