001
014
015 package com.liferay.portal.service.persistence;
016
017 import com.liferay.portal.NoSuchModelException;
018 import com.liferay.portal.NoSuchPortletPreferencesException;
019 import com.liferay.portal.kernel.bean.BeanReference;
020 import com.liferay.portal.kernel.cache.CacheRegistryUtil;
021 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
022 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
023 import com.liferay.portal.kernel.dao.orm.FinderPath;
024 import com.liferay.portal.kernel.dao.orm.Query;
025 import com.liferay.portal.kernel.dao.orm.QueryPos;
026 import com.liferay.portal.kernel.dao.orm.QueryUtil;
027 import com.liferay.portal.kernel.dao.orm.Session;
028 import com.liferay.portal.kernel.exception.SystemException;
029 import com.liferay.portal.kernel.log.Log;
030 import com.liferay.portal.kernel.log.LogFactoryUtil;
031 import com.liferay.portal.kernel.util.GetterUtil;
032 import com.liferay.portal.kernel.util.InstanceFactory;
033 import com.liferay.portal.kernel.util.OrderByComparator;
034 import com.liferay.portal.kernel.util.StringBundler;
035 import com.liferay.portal.kernel.util.StringPool;
036 import com.liferay.portal.kernel.util.StringUtil;
037 import com.liferay.portal.kernel.util.Validator;
038 import com.liferay.portal.model.CacheModel;
039 import com.liferay.portal.model.ModelListener;
040 import com.liferay.portal.model.PortletPreferences;
041 import com.liferay.portal.model.impl.PortletPreferencesImpl;
042 import com.liferay.portal.model.impl.PortletPreferencesModelImpl;
043 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
044
045 import java.io.Serializable;
046
047 import java.util.ArrayList;
048 import java.util.Collections;
049 import java.util.List;
050
051
063 public class PortletPreferencesPersistenceImpl extends BasePersistenceImpl<PortletPreferences>
064 implements PortletPreferencesPersistence {
065
070 public static final String FINDER_CLASS_NAME_ENTITY = PortletPreferencesImpl.class.getName();
071 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
072 ".List1";
073 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
074 ".List2";
075 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_PLID = new FinderPath(PortletPreferencesModelImpl.ENTITY_CACHE_ENABLED,
076 PortletPreferencesModelImpl.FINDER_CACHE_ENABLED,
077 PortletPreferencesImpl.class,
078 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByPlid",
079 new String[] {
080 Long.class.getName(),
081
082 "java.lang.Integer", "java.lang.Integer",
083 "com.liferay.portal.kernel.util.OrderByComparator"
084 });
085 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PLID = new FinderPath(PortletPreferencesModelImpl.ENTITY_CACHE_ENABLED,
086 PortletPreferencesModelImpl.FINDER_CACHE_ENABLED,
087 PortletPreferencesImpl.class,
088 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByPlid",
089 new String[] { Long.class.getName() },
090 PortletPreferencesModelImpl.PLID_COLUMN_BITMASK);
091 public static final FinderPath FINDER_PATH_COUNT_BY_PLID = new FinderPath(PortletPreferencesModelImpl.ENTITY_CACHE_ENABLED,
092 PortletPreferencesModelImpl.FINDER_CACHE_ENABLED, Long.class,
093 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByPlid",
094 new String[] { Long.class.getName() });
095 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_PORTLETID =
096 new FinderPath(PortletPreferencesModelImpl.ENTITY_CACHE_ENABLED,
097 PortletPreferencesModelImpl.FINDER_CACHE_ENABLED,
098 PortletPreferencesImpl.class,
099 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByPortletId",
100 new String[] {
101 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_WITHOUT_PAGINATION_FIND_BY_PORTLETID =
107 new FinderPath(PortletPreferencesModelImpl.ENTITY_CACHE_ENABLED,
108 PortletPreferencesModelImpl.FINDER_CACHE_ENABLED,
109 PortletPreferencesImpl.class,
110 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByPortletId",
111 new String[] { String.class.getName() },
112 PortletPreferencesModelImpl.PORTLETID_COLUMN_BITMASK);
113 public static final FinderPath FINDER_PATH_COUNT_BY_PORTLETID = new FinderPath(PortletPreferencesModelImpl.ENTITY_CACHE_ENABLED,
114 PortletPreferencesModelImpl.FINDER_CACHE_ENABLED, Long.class,
115 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByPortletId",
116 new String[] { String.class.getName() });
117 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_P_P = new FinderPath(PortletPreferencesModelImpl.ENTITY_CACHE_ENABLED,
118 PortletPreferencesModelImpl.FINDER_CACHE_ENABLED,
119 PortletPreferencesImpl.class,
120 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByP_P",
121 new String[] {
122 Long.class.getName(), String.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_WITHOUT_PAGINATION_FIND_BY_P_P = new FinderPath(PortletPreferencesModelImpl.ENTITY_CACHE_ENABLED,
128 PortletPreferencesModelImpl.FINDER_CACHE_ENABLED,
129 PortletPreferencesImpl.class,
130 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByP_P",
131 new String[] { Long.class.getName(), String.class.getName() },
132 PortletPreferencesModelImpl.PLID_COLUMN_BITMASK |
133 PortletPreferencesModelImpl.PORTLETID_COLUMN_BITMASK);
134 public static final FinderPath FINDER_PATH_COUNT_BY_P_P = new FinderPath(PortletPreferencesModelImpl.ENTITY_CACHE_ENABLED,
135 PortletPreferencesModelImpl.FINDER_CACHE_ENABLED, Long.class,
136 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByP_P",
137 new String[] { Long.class.getName(), String.class.getName() });
138 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_O_O_P = new FinderPath(PortletPreferencesModelImpl.ENTITY_CACHE_ENABLED,
139 PortletPreferencesModelImpl.FINDER_CACHE_ENABLED,
140 PortletPreferencesImpl.class,
141 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByO_O_P",
142 new String[] {
143 Long.class.getName(), Integer.class.getName(),
144 Long.class.getName(),
145
146 "java.lang.Integer", "java.lang.Integer",
147 "com.liferay.portal.kernel.util.OrderByComparator"
148 });
149 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_O_O_P = new FinderPath(PortletPreferencesModelImpl.ENTITY_CACHE_ENABLED,
150 PortletPreferencesModelImpl.FINDER_CACHE_ENABLED,
151 PortletPreferencesImpl.class,
152 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByO_O_P",
153 new String[] {
154 Long.class.getName(), Integer.class.getName(),
155 Long.class.getName()
156 },
157 PortletPreferencesModelImpl.OWNERID_COLUMN_BITMASK |
158 PortletPreferencesModelImpl.OWNERTYPE_COLUMN_BITMASK |
159 PortletPreferencesModelImpl.PLID_COLUMN_BITMASK);
160 public static final FinderPath FINDER_PATH_COUNT_BY_O_O_P = new FinderPath(PortletPreferencesModelImpl.ENTITY_CACHE_ENABLED,
161 PortletPreferencesModelImpl.FINDER_CACHE_ENABLED, Long.class,
162 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByO_O_P",
163 new String[] {
164 Long.class.getName(), Integer.class.getName(),
165 Long.class.getName()
166 });
167 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_O_P_P = new FinderPath(PortletPreferencesModelImpl.ENTITY_CACHE_ENABLED,
168 PortletPreferencesModelImpl.FINDER_CACHE_ENABLED,
169 PortletPreferencesImpl.class,
170 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByO_P_P",
171 new String[] {
172 Integer.class.getName(), Long.class.getName(),
173 String.class.getName(),
174
175 "java.lang.Integer", "java.lang.Integer",
176 "com.liferay.portal.kernel.util.OrderByComparator"
177 });
178 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_O_P_P = new FinderPath(PortletPreferencesModelImpl.ENTITY_CACHE_ENABLED,
179 PortletPreferencesModelImpl.FINDER_CACHE_ENABLED,
180 PortletPreferencesImpl.class,
181 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByO_P_P",
182 new String[] {
183 Integer.class.getName(), Long.class.getName(),
184 String.class.getName()
185 },
186 PortletPreferencesModelImpl.OWNERTYPE_COLUMN_BITMASK |
187 PortletPreferencesModelImpl.PLID_COLUMN_BITMASK |
188 PortletPreferencesModelImpl.PORTLETID_COLUMN_BITMASK);
189 public static final FinderPath FINDER_PATH_COUNT_BY_O_P_P = new FinderPath(PortletPreferencesModelImpl.ENTITY_CACHE_ENABLED,
190 PortletPreferencesModelImpl.FINDER_CACHE_ENABLED, Long.class,
191 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByO_P_P",
192 new String[] {
193 Integer.class.getName(), Long.class.getName(),
194 String.class.getName()
195 });
196 public static final FinderPath FINDER_PATH_FETCH_BY_O_O_P_P = new FinderPath(PortletPreferencesModelImpl.ENTITY_CACHE_ENABLED,
197 PortletPreferencesModelImpl.FINDER_CACHE_ENABLED,
198 PortletPreferencesImpl.class, FINDER_CLASS_NAME_ENTITY,
199 "fetchByO_O_P_P",
200 new String[] {
201 Long.class.getName(), Integer.class.getName(),
202 Long.class.getName(), String.class.getName()
203 },
204 PortletPreferencesModelImpl.OWNERID_COLUMN_BITMASK |
205 PortletPreferencesModelImpl.OWNERTYPE_COLUMN_BITMASK |
206 PortletPreferencesModelImpl.PLID_COLUMN_BITMASK |
207 PortletPreferencesModelImpl.PORTLETID_COLUMN_BITMASK);
208 public static final FinderPath FINDER_PATH_COUNT_BY_O_O_P_P = new FinderPath(PortletPreferencesModelImpl.ENTITY_CACHE_ENABLED,
209 PortletPreferencesModelImpl.FINDER_CACHE_ENABLED, Long.class,
210 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByO_O_P_P",
211 new String[] {
212 Long.class.getName(), Integer.class.getName(),
213 Long.class.getName(), String.class.getName()
214 });
215 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(PortletPreferencesModelImpl.ENTITY_CACHE_ENABLED,
216 PortletPreferencesModelImpl.FINDER_CACHE_ENABLED,
217 PortletPreferencesImpl.class,
218 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
219 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(PortletPreferencesModelImpl.ENTITY_CACHE_ENABLED,
220 PortletPreferencesModelImpl.FINDER_CACHE_ENABLED,
221 PortletPreferencesImpl.class,
222 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
223 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(PortletPreferencesModelImpl.ENTITY_CACHE_ENABLED,
224 PortletPreferencesModelImpl.FINDER_CACHE_ENABLED, Long.class,
225 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
226
227
232 public void cacheResult(PortletPreferences portletPreferences) {
233 EntityCacheUtil.putResult(PortletPreferencesModelImpl.ENTITY_CACHE_ENABLED,
234 PortletPreferencesImpl.class, portletPreferences.getPrimaryKey(),
235 portletPreferences);
236
237 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_O_O_P_P,
238 new Object[] {
239 Long.valueOf(portletPreferences.getOwnerId()),
240 Integer.valueOf(portletPreferences.getOwnerType()),
241 Long.valueOf(portletPreferences.getPlid()),
242
243 portletPreferences.getPortletId()
244 }, portletPreferences);
245
246 portletPreferences.resetOriginalValues();
247 }
248
249
254 public void cacheResult(List<PortletPreferences> portletPreferenceses) {
255 for (PortletPreferences portletPreferences : portletPreferenceses) {
256 if (EntityCacheUtil.getResult(
257 PortletPreferencesModelImpl.ENTITY_CACHE_ENABLED,
258 PortletPreferencesImpl.class,
259 portletPreferences.getPrimaryKey()) == null) {
260 cacheResult(portletPreferences);
261 }
262 else {
263 portletPreferences.resetOriginalValues();
264 }
265 }
266 }
267
268
275 @Override
276 public void clearCache() {
277 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
278 CacheRegistryUtil.clear(PortletPreferencesImpl.class.getName());
279 }
280
281 EntityCacheUtil.clearCache(PortletPreferencesImpl.class.getName());
282
283 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
284 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
285 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
286 }
287
288
295 @Override
296 public void clearCache(PortletPreferences portletPreferences) {
297 EntityCacheUtil.removeResult(PortletPreferencesModelImpl.ENTITY_CACHE_ENABLED,
298 PortletPreferencesImpl.class, portletPreferences.getPrimaryKey());
299
300 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
301 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
302
303 clearUniqueFindersCache(portletPreferences);
304 }
305
306 @Override
307 public void clearCache(List<PortletPreferences> portletPreferenceses) {
308 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
309 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
310
311 for (PortletPreferences portletPreferences : portletPreferenceses) {
312 EntityCacheUtil.removeResult(PortletPreferencesModelImpl.ENTITY_CACHE_ENABLED,
313 PortletPreferencesImpl.class, portletPreferences.getPrimaryKey());
314
315 clearUniqueFindersCache(portletPreferences);
316 }
317 }
318
319 protected void cacheUniqueFindersCache(
320 PortletPreferences portletPreferences) {
321 if (portletPreferences.isNew()) {
322 Object[] args = new Object[] {
323 Long.valueOf(portletPreferences.getOwnerId()),
324 Integer.valueOf(portletPreferences.getOwnerType()),
325 Long.valueOf(portletPreferences.getPlid()),
326
327 portletPreferences.getPortletId()
328 };
329
330 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_O_O_P_P, args,
331 Long.valueOf(1));
332 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_O_O_P_P, args,
333 portletPreferences);
334 }
335 else {
336 PortletPreferencesModelImpl portletPreferencesModelImpl = (PortletPreferencesModelImpl)portletPreferences;
337
338 if ((portletPreferencesModelImpl.getColumnBitmask() &
339 FINDER_PATH_FETCH_BY_O_O_P_P.getColumnBitmask()) != 0) {
340 Object[] args = new Object[] {
341 Long.valueOf(portletPreferences.getOwnerId()),
342 Integer.valueOf(portletPreferences.getOwnerType()),
343 Long.valueOf(portletPreferences.getPlid()),
344
345 portletPreferences.getPortletId()
346 };
347
348 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_O_O_P_P, args,
349 Long.valueOf(1));
350 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_O_O_P_P, args,
351 portletPreferences);
352 }
353 }
354 }
355
356 protected void clearUniqueFindersCache(
357 PortletPreferences portletPreferences) {
358 PortletPreferencesModelImpl portletPreferencesModelImpl = (PortletPreferencesModelImpl)portletPreferences;
359
360 Object[] args = new Object[] {
361 Long.valueOf(portletPreferences.getOwnerId()),
362 Integer.valueOf(portletPreferences.getOwnerType()),
363 Long.valueOf(portletPreferences.getPlid()),
364
365 portletPreferences.getPortletId()
366 };
367
368 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_O_O_P_P, args);
369 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_O_O_P_P, args);
370
371 if ((portletPreferencesModelImpl.getColumnBitmask() &
372 FINDER_PATH_FETCH_BY_O_O_P_P.getColumnBitmask()) != 0) {
373 args = new Object[] {
374 Long.valueOf(portletPreferencesModelImpl.getOriginalOwnerId()),
375 Integer.valueOf(portletPreferencesModelImpl.getOriginalOwnerType()),
376 Long.valueOf(portletPreferencesModelImpl.getOriginalPlid()),
377
378 portletPreferencesModelImpl.getOriginalPortletId()
379 };
380
381 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_O_O_P_P, args);
382 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_O_O_P_P, args);
383 }
384 }
385
386
392 public PortletPreferences create(long portletPreferencesId) {
393 PortletPreferences portletPreferences = new PortletPreferencesImpl();
394
395 portletPreferences.setNew(true);
396 portletPreferences.setPrimaryKey(portletPreferencesId);
397
398 return portletPreferences;
399 }
400
401
409 public PortletPreferences remove(long portletPreferencesId)
410 throws NoSuchPortletPreferencesException, SystemException {
411 return remove(Long.valueOf(portletPreferencesId));
412 }
413
414
422 @Override
423 public PortletPreferences remove(Serializable primaryKey)
424 throws NoSuchPortletPreferencesException, SystemException {
425 Session session = null;
426
427 try {
428 session = openSession();
429
430 PortletPreferences portletPreferences = (PortletPreferences)session.get(PortletPreferencesImpl.class,
431 primaryKey);
432
433 if (portletPreferences == null) {
434 if (_log.isWarnEnabled()) {
435 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
436 }
437
438 throw new NoSuchPortletPreferencesException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
439 primaryKey);
440 }
441
442 return remove(portletPreferences);
443 }
444 catch (NoSuchPortletPreferencesException nsee) {
445 throw nsee;
446 }
447 catch (Exception e) {
448 throw processException(e);
449 }
450 finally {
451 closeSession(session);
452 }
453 }
454
455 @Override
456 protected PortletPreferences removeImpl(
457 PortletPreferences portletPreferences) throws SystemException {
458 portletPreferences = toUnwrappedModel(portletPreferences);
459
460 Session session = null;
461
462 try {
463 session = openSession();
464
465 BatchSessionUtil.delete(session, portletPreferences);
466 }
467 catch (Exception e) {
468 throw processException(e);
469 }
470 finally {
471 closeSession(session);
472 }
473
474 clearCache(portletPreferences);
475
476 return portletPreferences;
477 }
478
479 @Override
480 public PortletPreferences updateImpl(
481 com.liferay.portal.model.PortletPreferences portletPreferences,
482 boolean merge) throws SystemException {
483 portletPreferences = toUnwrappedModel(portletPreferences);
484
485 boolean isNew = portletPreferences.isNew();
486
487 PortletPreferencesModelImpl portletPreferencesModelImpl = (PortletPreferencesModelImpl)portletPreferences;
488
489 Session session = null;
490
491 try {
492 session = openSession();
493
494 BatchSessionUtil.update(session, portletPreferences, merge);
495
496 portletPreferences.setNew(false);
497 }
498 catch (Exception e) {
499 throw processException(e);
500 }
501 finally {
502 closeSession(session);
503 }
504
505 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
506
507 if (isNew || !PortletPreferencesModelImpl.COLUMN_BITMASK_ENABLED) {
508 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
509 }
510
511 else {
512 if ((portletPreferencesModelImpl.getColumnBitmask() &
513 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PLID.getColumnBitmask()) != 0) {
514 Object[] args = new Object[] {
515 Long.valueOf(portletPreferencesModelImpl.getOriginalPlid())
516 };
517
518 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_PLID, args);
519 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PLID,
520 args);
521
522 args = new Object[] {
523 Long.valueOf(portletPreferencesModelImpl.getPlid())
524 };
525
526 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_PLID, args);
527 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PLID,
528 args);
529 }
530
531 if ((portletPreferencesModelImpl.getColumnBitmask() &
532 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PORTLETID.getColumnBitmask()) != 0) {
533 Object[] args = new Object[] {
534 portletPreferencesModelImpl.getOriginalPortletId()
535 };
536
537 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_PORTLETID,
538 args);
539 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PORTLETID,
540 args);
541
542 args = new Object[] { portletPreferencesModelImpl.getPortletId() };
543
544 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_PORTLETID,
545 args);
546 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PORTLETID,
547 args);
548 }
549
550 if ((portletPreferencesModelImpl.getColumnBitmask() &
551 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_P.getColumnBitmask()) != 0) {
552 Object[] args = new Object[] {
553 Long.valueOf(portletPreferencesModelImpl.getOriginalPlid()),
554
555 portletPreferencesModelImpl.getOriginalPortletId()
556 };
557
558 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_P_P, args);
559 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_P,
560 args);
561
562 args = new Object[] {
563 Long.valueOf(portletPreferencesModelImpl.getPlid()),
564
565 portletPreferencesModelImpl.getPortletId()
566 };
567
568 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_P_P, args);
569 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_P,
570 args);
571 }
572
573 if ((portletPreferencesModelImpl.getColumnBitmask() &
574 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_O_O_P.getColumnBitmask()) != 0) {
575 Object[] args = new Object[] {
576 Long.valueOf(portletPreferencesModelImpl.getOriginalOwnerId()),
577 Integer.valueOf(portletPreferencesModelImpl.getOriginalOwnerType()),
578 Long.valueOf(portletPreferencesModelImpl.getOriginalPlid())
579 };
580
581 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_O_O_P, args);
582 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_O_O_P,
583 args);
584
585 args = new Object[] {
586 Long.valueOf(portletPreferencesModelImpl.getOwnerId()),
587 Integer.valueOf(portletPreferencesModelImpl.getOwnerType()),
588 Long.valueOf(portletPreferencesModelImpl.getPlid())
589 };
590
591 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_O_O_P, args);
592 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_O_O_P,
593 args);
594 }
595
596 if ((portletPreferencesModelImpl.getColumnBitmask() &
597 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_O_P_P.getColumnBitmask()) != 0) {
598 Object[] args = new Object[] {
599 Integer.valueOf(portletPreferencesModelImpl.getOriginalOwnerType()),
600 Long.valueOf(portletPreferencesModelImpl.getOriginalPlid()),
601
602 portletPreferencesModelImpl.getOriginalPortletId()
603 };
604
605 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_O_P_P, args);
606 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_O_P_P,
607 args);
608
609 args = new Object[] {
610 Integer.valueOf(portletPreferencesModelImpl.getOwnerType()),
611 Long.valueOf(portletPreferencesModelImpl.getPlid()),
612
613 portletPreferencesModelImpl.getPortletId()
614 };
615
616 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_O_P_P, args);
617 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_O_P_P,
618 args);
619 }
620 }
621
622 EntityCacheUtil.putResult(PortletPreferencesModelImpl.ENTITY_CACHE_ENABLED,
623 PortletPreferencesImpl.class, portletPreferences.getPrimaryKey(),
624 portletPreferences);
625
626 clearUniqueFindersCache(portletPreferences);
627 cacheUniqueFindersCache(portletPreferences);
628
629 return portletPreferences;
630 }
631
632 protected PortletPreferences toUnwrappedModel(
633 PortletPreferences portletPreferences) {
634 if (portletPreferences instanceof PortletPreferencesImpl) {
635 return portletPreferences;
636 }
637
638 PortletPreferencesImpl portletPreferencesImpl = new PortletPreferencesImpl();
639
640 portletPreferencesImpl.setNew(portletPreferences.isNew());
641 portletPreferencesImpl.setPrimaryKey(portletPreferences.getPrimaryKey());
642
643 portletPreferencesImpl.setPortletPreferencesId(portletPreferences.getPortletPreferencesId());
644 portletPreferencesImpl.setOwnerId(portletPreferences.getOwnerId());
645 portletPreferencesImpl.setOwnerType(portletPreferences.getOwnerType());
646 portletPreferencesImpl.setPlid(portletPreferences.getPlid());
647 portletPreferencesImpl.setPortletId(portletPreferences.getPortletId());
648 portletPreferencesImpl.setPreferences(portletPreferences.getPreferences());
649
650 return portletPreferencesImpl;
651 }
652
653
661 @Override
662 public PortletPreferences findByPrimaryKey(Serializable primaryKey)
663 throws NoSuchModelException, SystemException {
664 return findByPrimaryKey(((Long)primaryKey).longValue());
665 }
666
667
675 public PortletPreferences findByPrimaryKey(long portletPreferencesId)
676 throws NoSuchPortletPreferencesException, SystemException {
677 PortletPreferences portletPreferences = fetchByPrimaryKey(portletPreferencesId);
678
679 if (portletPreferences == null) {
680 if (_log.isWarnEnabled()) {
681 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
682 portletPreferencesId);
683 }
684
685 throw new NoSuchPortletPreferencesException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
686 portletPreferencesId);
687 }
688
689 return portletPreferences;
690 }
691
692
699 @Override
700 public PortletPreferences fetchByPrimaryKey(Serializable primaryKey)
701 throws SystemException {
702 return fetchByPrimaryKey(((Long)primaryKey).longValue());
703 }
704
705
712 public PortletPreferences fetchByPrimaryKey(long portletPreferencesId)
713 throws SystemException {
714 PortletPreferences portletPreferences = (PortletPreferences)EntityCacheUtil.getResult(PortletPreferencesModelImpl.ENTITY_CACHE_ENABLED,
715 PortletPreferencesImpl.class, portletPreferencesId);
716
717 if (portletPreferences == _nullPortletPreferences) {
718 return null;
719 }
720
721 if (portletPreferences == null) {
722 Session session = null;
723
724 boolean hasException = false;
725
726 try {
727 session = openSession();
728
729 portletPreferences = (PortletPreferences)session.get(PortletPreferencesImpl.class,
730 Long.valueOf(portletPreferencesId));
731 }
732 catch (Exception e) {
733 hasException = true;
734
735 throw processException(e);
736 }
737 finally {
738 if (portletPreferences != null) {
739 cacheResult(portletPreferences);
740 }
741 else if (!hasException) {
742 EntityCacheUtil.putResult(PortletPreferencesModelImpl.ENTITY_CACHE_ENABLED,
743 PortletPreferencesImpl.class, portletPreferencesId,
744 _nullPortletPreferences);
745 }
746
747 closeSession(session);
748 }
749 }
750
751 return portletPreferences;
752 }
753
754
761 public List<PortletPreferences> findByPlid(long plid)
762 throws SystemException {
763 return findByPlid(plid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
764 }
765
766
779 public List<PortletPreferences> findByPlid(long plid, int start, int end)
780 throws SystemException {
781 return findByPlid(plid, start, end, null);
782 }
783
784
798 public List<PortletPreferences> findByPlid(long plid, int start, int end,
799 OrderByComparator orderByComparator) throws SystemException {
800 FinderPath finderPath = null;
801 Object[] finderArgs = null;
802
803 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
804 (orderByComparator == null)) {
805 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PLID;
806 finderArgs = new Object[] { plid };
807 }
808 else {
809 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_PLID;
810 finderArgs = new Object[] { plid, start, end, orderByComparator };
811 }
812
813 List<PortletPreferences> list = (List<PortletPreferences>)FinderCacheUtil.getResult(finderPath,
814 finderArgs, this);
815
816 if ((list != null) && !list.isEmpty()) {
817 for (PortletPreferences portletPreferences : list) {
818 if ((plid != portletPreferences.getPlid())) {
819 list = null;
820
821 break;
822 }
823 }
824 }
825
826 if (list == null) {
827 StringBundler query = null;
828
829 if (orderByComparator != null) {
830 query = new StringBundler(3 +
831 (orderByComparator.getOrderByFields().length * 3));
832 }
833 else {
834 query = new StringBundler(2);
835 }
836
837 query.append(_SQL_SELECT_PORTLETPREFERENCES_WHERE);
838
839 query.append(_FINDER_COLUMN_PLID_PLID_2);
840
841 if (orderByComparator != null) {
842 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
843 orderByComparator);
844 }
845
846 String sql = query.toString();
847
848 Session session = null;
849
850 try {
851 session = openSession();
852
853 Query q = session.createQuery(sql);
854
855 QueryPos qPos = QueryPos.getInstance(q);
856
857 qPos.add(plid);
858
859 list = (List<PortletPreferences>)QueryUtil.list(q,
860 getDialect(), start, end);
861 }
862 catch (Exception e) {
863 throw processException(e);
864 }
865 finally {
866 if (list == null) {
867 FinderCacheUtil.removeResult(finderPath, finderArgs);
868 }
869 else {
870 cacheResult(list);
871
872 FinderCacheUtil.putResult(finderPath, finderArgs, list);
873 }
874
875 closeSession(session);
876 }
877 }
878
879 return list;
880 }
881
882
891 public PortletPreferences findByPlid_First(long plid,
892 OrderByComparator orderByComparator)
893 throws NoSuchPortletPreferencesException, SystemException {
894 PortletPreferences portletPreferences = fetchByPlid_First(plid,
895 orderByComparator);
896
897 if (portletPreferences != null) {
898 return portletPreferences;
899 }
900
901 StringBundler msg = new StringBundler(4);
902
903 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
904
905 msg.append("plid=");
906 msg.append(plid);
907
908 msg.append(StringPool.CLOSE_CURLY_BRACE);
909
910 throw new NoSuchPortletPreferencesException(msg.toString());
911 }
912
913
921 public PortletPreferences fetchByPlid_First(long plid,
922 OrderByComparator orderByComparator) throws SystemException {
923 List<PortletPreferences> list = findByPlid(plid, 0, 1, orderByComparator);
924
925 if (!list.isEmpty()) {
926 return list.get(0);
927 }
928
929 return null;
930 }
931
932
941 public PortletPreferences findByPlid_Last(long plid,
942 OrderByComparator orderByComparator)
943 throws NoSuchPortletPreferencesException, SystemException {
944 PortletPreferences portletPreferences = fetchByPlid_Last(plid,
945 orderByComparator);
946
947 if (portletPreferences != null) {
948 return portletPreferences;
949 }
950
951 StringBundler msg = new StringBundler(4);
952
953 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
954
955 msg.append("plid=");
956 msg.append(plid);
957
958 msg.append(StringPool.CLOSE_CURLY_BRACE);
959
960 throw new NoSuchPortletPreferencesException(msg.toString());
961 }
962
963
971 public PortletPreferences fetchByPlid_Last(long plid,
972 OrderByComparator orderByComparator) throws SystemException {
973 int count = countByPlid(plid);
974
975 List<PortletPreferences> list = findByPlid(plid, count - 1, count,
976 orderByComparator);
977
978 if (!list.isEmpty()) {
979 return list.get(0);
980 }
981
982 return null;
983 }
984
985
995 public PortletPreferences[] findByPlid_PrevAndNext(
996 long portletPreferencesId, long plid,
997 OrderByComparator orderByComparator)
998 throws NoSuchPortletPreferencesException, SystemException {
999 PortletPreferences portletPreferences = findByPrimaryKey(portletPreferencesId);
1000
1001 Session session = null;
1002
1003 try {
1004 session = openSession();
1005
1006 PortletPreferences[] array = new PortletPreferencesImpl[3];
1007
1008 array[0] = getByPlid_PrevAndNext(session, portletPreferences, plid,
1009 orderByComparator, true);
1010
1011 array[1] = portletPreferences;
1012
1013 array[2] = getByPlid_PrevAndNext(session, portletPreferences, plid,
1014 orderByComparator, false);
1015
1016 return array;
1017 }
1018 catch (Exception e) {
1019 throw processException(e);
1020 }
1021 finally {
1022 closeSession(session);
1023 }
1024 }
1025
1026 protected PortletPreferences getByPlid_PrevAndNext(Session session,
1027 PortletPreferences portletPreferences, long plid,
1028 OrderByComparator orderByComparator, boolean previous) {
1029 StringBundler query = null;
1030
1031 if (orderByComparator != null) {
1032 query = new StringBundler(6 +
1033 (orderByComparator.getOrderByFields().length * 6));
1034 }
1035 else {
1036 query = new StringBundler(3);
1037 }
1038
1039 query.append(_SQL_SELECT_PORTLETPREFERENCES_WHERE);
1040
1041 query.append(_FINDER_COLUMN_PLID_PLID_2);
1042
1043 if (orderByComparator != null) {
1044 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1045
1046 if (orderByConditionFields.length > 0) {
1047 query.append(WHERE_AND);
1048 }
1049
1050 for (int i = 0; i < orderByConditionFields.length; i++) {
1051 query.append(_ORDER_BY_ENTITY_ALIAS);
1052 query.append(orderByConditionFields[i]);
1053
1054 if ((i + 1) < orderByConditionFields.length) {
1055 if (orderByComparator.isAscending() ^ previous) {
1056 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1057 }
1058 else {
1059 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1060 }
1061 }
1062 else {
1063 if (orderByComparator.isAscending() ^ previous) {
1064 query.append(WHERE_GREATER_THAN);
1065 }
1066 else {
1067 query.append(WHERE_LESSER_THAN);
1068 }
1069 }
1070 }
1071
1072 query.append(ORDER_BY_CLAUSE);
1073
1074 String[] orderByFields = orderByComparator.getOrderByFields();
1075
1076 for (int i = 0; i < orderByFields.length; i++) {
1077 query.append(_ORDER_BY_ENTITY_ALIAS);
1078 query.append(orderByFields[i]);
1079
1080 if ((i + 1) < orderByFields.length) {
1081 if (orderByComparator.isAscending() ^ previous) {
1082 query.append(ORDER_BY_ASC_HAS_NEXT);
1083 }
1084 else {
1085 query.append(ORDER_BY_DESC_HAS_NEXT);
1086 }
1087 }
1088 else {
1089 if (orderByComparator.isAscending() ^ previous) {
1090 query.append(ORDER_BY_ASC);
1091 }
1092 else {
1093 query.append(ORDER_BY_DESC);
1094 }
1095 }
1096 }
1097 }
1098
1099 String sql = query.toString();
1100
1101 Query q = session.createQuery(sql);
1102
1103 q.setFirstResult(0);
1104 q.setMaxResults(2);
1105
1106 QueryPos qPos = QueryPos.getInstance(q);
1107
1108 qPos.add(plid);
1109
1110 if (orderByComparator != null) {
1111 Object[] values = orderByComparator.getOrderByConditionValues(portletPreferences);
1112
1113 for (Object value : values) {
1114 qPos.add(value);
1115 }
1116 }
1117
1118 List<PortletPreferences> list = q.list();
1119
1120 if (list.size() == 2) {
1121 return list.get(1);
1122 }
1123 else {
1124 return null;
1125 }
1126 }
1127
1128
1135 public List<PortletPreferences> findByPortletId(String portletId)
1136 throws SystemException {
1137 return findByPortletId(portletId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
1138 null);
1139 }
1140
1141
1154 public List<PortletPreferences> findByPortletId(String portletId,
1155 int start, int end) throws SystemException {
1156 return findByPortletId(portletId, start, end, null);
1157 }
1158
1159
1173 public List<PortletPreferences> findByPortletId(String portletId,
1174 int start, int end, OrderByComparator orderByComparator)
1175 throws SystemException {
1176 FinderPath finderPath = null;
1177 Object[] finderArgs = null;
1178
1179 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1180 (orderByComparator == null)) {
1181 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PORTLETID;
1182 finderArgs = new Object[] { portletId };
1183 }
1184 else {
1185 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_PORTLETID;
1186 finderArgs = new Object[] { portletId, start, end, orderByComparator };
1187 }
1188
1189 List<PortletPreferences> list = (List<PortletPreferences>)FinderCacheUtil.getResult(finderPath,
1190 finderArgs, this);
1191
1192 if ((list != null) && !list.isEmpty()) {
1193 for (PortletPreferences portletPreferences : list) {
1194 if (!Validator.equals(portletId,
1195 portletPreferences.getPortletId())) {
1196 list = null;
1197
1198 break;
1199 }
1200 }
1201 }
1202
1203 if (list == null) {
1204 StringBundler query = null;
1205
1206 if (orderByComparator != null) {
1207 query = new StringBundler(3 +
1208 (orderByComparator.getOrderByFields().length * 3));
1209 }
1210 else {
1211 query = new StringBundler(2);
1212 }
1213
1214 query.append(_SQL_SELECT_PORTLETPREFERENCES_WHERE);
1215
1216 if (portletId == null) {
1217 query.append(_FINDER_COLUMN_PORTLETID_PORTLETID_1);
1218 }
1219 else {
1220 if (portletId.equals(StringPool.BLANK)) {
1221 query.append(_FINDER_COLUMN_PORTLETID_PORTLETID_3);
1222 }
1223 else {
1224 query.append(_FINDER_COLUMN_PORTLETID_PORTLETID_2);
1225 }
1226 }
1227
1228 if (orderByComparator != null) {
1229 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1230 orderByComparator);
1231 }
1232
1233 String sql = query.toString();
1234
1235 Session session = null;
1236
1237 try {
1238 session = openSession();
1239
1240 Query q = session.createQuery(sql);
1241
1242 QueryPos qPos = QueryPos.getInstance(q);
1243
1244 if (portletId != null) {
1245 qPos.add(portletId);
1246 }
1247
1248 list = (List<PortletPreferences>)QueryUtil.list(q,
1249 getDialect(), start, end);
1250 }
1251 catch (Exception e) {
1252 throw processException(e);
1253 }
1254 finally {
1255 if (list == null) {
1256 FinderCacheUtil.removeResult(finderPath, finderArgs);
1257 }
1258 else {
1259 cacheResult(list);
1260
1261 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1262 }
1263
1264 closeSession(session);
1265 }
1266 }
1267
1268 return list;
1269 }
1270
1271
1280 public PortletPreferences findByPortletId_First(String portletId,
1281 OrderByComparator orderByComparator)
1282 throws NoSuchPortletPreferencesException, SystemException {
1283 PortletPreferences portletPreferences = fetchByPortletId_First(portletId,
1284 orderByComparator);
1285
1286 if (portletPreferences != null) {
1287 return portletPreferences;
1288 }
1289
1290 StringBundler msg = new StringBundler(4);
1291
1292 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1293
1294 msg.append("portletId=");
1295 msg.append(portletId);
1296
1297 msg.append(StringPool.CLOSE_CURLY_BRACE);
1298
1299 throw new NoSuchPortletPreferencesException(msg.toString());
1300 }
1301
1302
1310 public PortletPreferences fetchByPortletId_First(String portletId,
1311 OrderByComparator orderByComparator) throws SystemException {
1312 List<PortletPreferences> list = findByPortletId(portletId, 0, 1,
1313 orderByComparator);
1314
1315 if (!list.isEmpty()) {
1316 return list.get(0);
1317 }
1318
1319 return null;
1320 }
1321
1322
1331 public PortletPreferences findByPortletId_Last(String portletId,
1332 OrderByComparator orderByComparator)
1333 throws NoSuchPortletPreferencesException, SystemException {
1334 PortletPreferences portletPreferences = fetchByPortletId_Last(portletId,
1335 orderByComparator);
1336
1337 if (portletPreferences != null) {
1338 return portletPreferences;
1339 }
1340
1341 StringBundler msg = new StringBundler(4);
1342
1343 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1344
1345 msg.append("portletId=");
1346 msg.append(portletId);
1347
1348 msg.append(StringPool.CLOSE_CURLY_BRACE);
1349
1350 throw new NoSuchPortletPreferencesException(msg.toString());
1351 }
1352
1353
1361 public PortletPreferences fetchByPortletId_Last(String portletId,
1362 OrderByComparator orderByComparator) throws SystemException {
1363 int count = countByPortletId(portletId);
1364
1365 List<PortletPreferences> list = findByPortletId(portletId, count - 1,
1366 count, orderByComparator);
1367
1368 if (!list.isEmpty()) {
1369 return list.get(0);
1370 }
1371
1372 return null;
1373 }
1374
1375
1385 public PortletPreferences[] findByPortletId_PrevAndNext(
1386 long portletPreferencesId, String portletId,
1387 OrderByComparator orderByComparator)
1388 throws NoSuchPortletPreferencesException, SystemException {
1389 PortletPreferences portletPreferences = findByPrimaryKey(portletPreferencesId);
1390
1391 Session session = null;
1392
1393 try {
1394 session = openSession();
1395
1396 PortletPreferences[] array = new PortletPreferencesImpl[3];
1397
1398 array[0] = getByPortletId_PrevAndNext(session, portletPreferences,
1399 portletId, orderByComparator, true);
1400
1401 array[1] = portletPreferences;
1402
1403 array[2] = getByPortletId_PrevAndNext(session, portletPreferences,
1404 portletId, orderByComparator, false);
1405
1406 return array;
1407 }
1408 catch (Exception e) {
1409 throw processException(e);
1410 }
1411 finally {
1412 closeSession(session);
1413 }
1414 }
1415
1416 protected PortletPreferences getByPortletId_PrevAndNext(Session session,
1417 PortletPreferences portletPreferences, String portletId,
1418 OrderByComparator orderByComparator, boolean previous) {
1419 StringBundler query = null;
1420
1421 if (orderByComparator != null) {
1422 query = new StringBundler(6 +
1423 (orderByComparator.getOrderByFields().length * 6));
1424 }
1425 else {
1426 query = new StringBundler(3);
1427 }
1428
1429 query.append(_SQL_SELECT_PORTLETPREFERENCES_WHERE);
1430
1431 if (portletId == null) {
1432 query.append(_FINDER_COLUMN_PORTLETID_PORTLETID_1);
1433 }
1434 else {
1435 if (portletId.equals(StringPool.BLANK)) {
1436 query.append(_FINDER_COLUMN_PORTLETID_PORTLETID_3);
1437 }
1438 else {
1439 query.append(_FINDER_COLUMN_PORTLETID_PORTLETID_2);
1440 }
1441 }
1442
1443 if (orderByComparator != null) {
1444 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1445
1446 if (orderByConditionFields.length > 0) {
1447 query.append(WHERE_AND);
1448 }
1449
1450 for (int i = 0; i < orderByConditionFields.length; i++) {
1451 query.append(_ORDER_BY_ENTITY_ALIAS);
1452 query.append(orderByConditionFields[i]);
1453
1454 if ((i + 1) < orderByConditionFields.length) {
1455 if (orderByComparator.isAscending() ^ previous) {
1456 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1457 }
1458 else {
1459 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1460 }
1461 }
1462 else {
1463 if (orderByComparator.isAscending() ^ previous) {
1464 query.append(WHERE_GREATER_THAN);
1465 }
1466 else {
1467 query.append(WHERE_LESSER_THAN);
1468 }
1469 }
1470 }
1471
1472 query.append(ORDER_BY_CLAUSE);
1473
1474 String[] orderByFields = orderByComparator.getOrderByFields();
1475
1476 for (int i = 0; i < orderByFields.length; i++) {
1477 query.append(_ORDER_BY_ENTITY_ALIAS);
1478 query.append(orderByFields[i]);
1479
1480 if ((i + 1) < orderByFields.length) {
1481 if (orderByComparator.isAscending() ^ previous) {
1482 query.append(ORDER_BY_ASC_HAS_NEXT);
1483 }
1484 else {
1485 query.append(ORDER_BY_DESC_HAS_NEXT);
1486 }
1487 }
1488 else {
1489 if (orderByComparator.isAscending() ^ previous) {
1490 query.append(ORDER_BY_ASC);
1491 }
1492 else {
1493 query.append(ORDER_BY_DESC);
1494 }
1495 }
1496 }
1497 }
1498
1499 String sql = query.toString();
1500
1501 Query q = session.createQuery(sql);
1502
1503 q.setFirstResult(0);
1504 q.setMaxResults(2);
1505
1506 QueryPos qPos = QueryPos.getInstance(q);
1507
1508 if (portletId != null) {
1509 qPos.add(portletId);
1510 }
1511
1512 if (orderByComparator != null) {
1513 Object[] values = orderByComparator.getOrderByConditionValues(portletPreferences);
1514
1515 for (Object value : values) {
1516 qPos.add(value);
1517 }
1518 }
1519
1520 List<PortletPreferences> list = q.list();
1521
1522 if (list.size() == 2) {
1523 return list.get(1);
1524 }
1525 else {
1526 return null;
1527 }
1528 }
1529
1530
1538 public List<PortletPreferences> findByP_P(long plid, String portletId)
1539 throws SystemException {
1540 return findByP_P(plid, portletId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
1541 null);
1542 }
1543
1544
1558 public List<PortletPreferences> findByP_P(long plid, String portletId,
1559 int start, int end) throws SystemException {
1560 return findByP_P(plid, portletId, start, end, null);
1561 }
1562
1563
1578 public List<PortletPreferences> findByP_P(long plid, String portletId,
1579 int start, int end, OrderByComparator orderByComparator)
1580 throws SystemException {
1581 FinderPath finderPath = null;
1582 Object[] finderArgs = null;
1583
1584 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1585 (orderByComparator == null)) {
1586 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_P;
1587 finderArgs = new Object[] { plid, portletId };
1588 }
1589 else {
1590 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_P_P;
1591 finderArgs = new Object[] {
1592 plid, portletId,
1593
1594 start, end, orderByComparator
1595 };
1596 }
1597
1598 List<PortletPreferences> list = (List<PortletPreferences>)FinderCacheUtil.getResult(finderPath,
1599 finderArgs, this);
1600
1601 if ((list != null) && !list.isEmpty()) {
1602 for (PortletPreferences portletPreferences : list) {
1603 if ((plid != portletPreferences.getPlid()) ||
1604 !Validator.equals(portletId,
1605 portletPreferences.getPortletId())) {
1606 list = null;
1607
1608 break;
1609 }
1610 }
1611 }
1612
1613 if (list == null) {
1614 StringBundler query = null;
1615
1616 if (orderByComparator != null) {
1617 query = new StringBundler(4 +
1618 (orderByComparator.getOrderByFields().length * 3));
1619 }
1620 else {
1621 query = new StringBundler(3);
1622 }
1623
1624 query.append(_SQL_SELECT_PORTLETPREFERENCES_WHERE);
1625
1626 query.append(_FINDER_COLUMN_P_P_PLID_2);
1627
1628 if (portletId == null) {
1629 query.append(_FINDER_COLUMN_P_P_PORTLETID_1);
1630 }
1631 else {
1632 if (portletId.equals(StringPool.BLANK)) {
1633 query.append(_FINDER_COLUMN_P_P_PORTLETID_3);
1634 }
1635 else {
1636 query.append(_FINDER_COLUMN_P_P_PORTLETID_2);
1637 }
1638 }
1639
1640 if (orderByComparator != null) {
1641 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1642 orderByComparator);
1643 }
1644
1645 String sql = query.toString();
1646
1647 Session session = null;
1648
1649 try {
1650 session = openSession();
1651
1652 Query q = session.createQuery(sql);
1653
1654 QueryPos qPos = QueryPos.getInstance(q);
1655
1656 qPos.add(plid);
1657
1658 if (portletId != null) {
1659 qPos.add(portletId);
1660 }
1661
1662 list = (List<PortletPreferences>)QueryUtil.list(q,
1663 getDialect(), start, end);
1664 }
1665 catch (Exception e) {
1666 throw processException(e);
1667 }
1668 finally {
1669 if (list == null) {
1670 FinderCacheUtil.removeResult(finderPath, finderArgs);
1671 }
1672 else {
1673 cacheResult(list);
1674
1675 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1676 }
1677
1678 closeSession(session);
1679 }
1680 }
1681
1682 return list;
1683 }
1684
1685
1695 public PortletPreferences findByP_P_First(long plid, String portletId,
1696 OrderByComparator orderByComparator)
1697 throws NoSuchPortletPreferencesException, SystemException {
1698 PortletPreferences portletPreferences = fetchByP_P_First(plid,
1699 portletId, orderByComparator);
1700
1701 if (portletPreferences != null) {
1702 return portletPreferences;
1703 }
1704
1705 StringBundler msg = new StringBundler(6);
1706
1707 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1708
1709 msg.append("plid=");
1710 msg.append(plid);
1711
1712 msg.append(", portletId=");
1713 msg.append(portletId);
1714
1715 msg.append(StringPool.CLOSE_CURLY_BRACE);
1716
1717 throw new NoSuchPortletPreferencesException(msg.toString());
1718 }
1719
1720
1729 public PortletPreferences fetchByP_P_First(long plid, String portletId,
1730 OrderByComparator orderByComparator) throws SystemException {
1731 List<PortletPreferences> list = findByP_P(plid, portletId, 0, 1,
1732 orderByComparator);
1733
1734 if (!list.isEmpty()) {
1735 return list.get(0);
1736 }
1737
1738 return null;
1739 }
1740
1741
1751 public PortletPreferences findByP_P_Last(long plid, String portletId,
1752 OrderByComparator orderByComparator)
1753 throws NoSuchPortletPreferencesException, SystemException {
1754 PortletPreferences portletPreferences = fetchByP_P_Last(plid,
1755 portletId, orderByComparator);
1756
1757 if (portletPreferences != null) {
1758 return portletPreferences;
1759 }
1760
1761 StringBundler msg = new StringBundler(6);
1762
1763 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1764
1765 msg.append("plid=");
1766 msg.append(plid);
1767
1768 msg.append(", portletId=");
1769 msg.append(portletId);
1770
1771 msg.append(StringPool.CLOSE_CURLY_BRACE);
1772
1773 throw new NoSuchPortletPreferencesException(msg.toString());
1774 }
1775
1776
1785 public PortletPreferences fetchByP_P_Last(long plid, String portletId,
1786 OrderByComparator orderByComparator) throws SystemException {
1787 int count = countByP_P(plid, portletId);
1788
1789 List<PortletPreferences> list = findByP_P(plid, portletId, count - 1,
1790 count, orderByComparator);
1791
1792 if (!list.isEmpty()) {
1793 return list.get(0);
1794 }
1795
1796 return null;
1797 }
1798
1799
1810 public PortletPreferences[] findByP_P_PrevAndNext(
1811 long portletPreferencesId, long plid, String portletId,
1812 OrderByComparator orderByComparator)
1813 throws NoSuchPortletPreferencesException, SystemException {
1814 PortletPreferences portletPreferences = findByPrimaryKey(portletPreferencesId);
1815
1816 Session session = null;
1817
1818 try {
1819 session = openSession();
1820
1821 PortletPreferences[] array = new PortletPreferencesImpl[3];
1822
1823 array[0] = getByP_P_PrevAndNext(session, portletPreferences, plid,
1824 portletId, orderByComparator, true);
1825
1826 array[1] = portletPreferences;
1827
1828 array[2] = getByP_P_PrevAndNext(session, portletPreferences, plid,
1829 portletId, orderByComparator, false);
1830
1831 return array;
1832 }
1833 catch (Exception e) {
1834 throw processException(e);
1835 }
1836 finally {
1837 closeSession(session);
1838 }
1839 }
1840
1841 protected PortletPreferences getByP_P_PrevAndNext(Session session,
1842 PortletPreferences portletPreferences, long plid, String portletId,
1843 OrderByComparator orderByComparator, boolean previous) {
1844 StringBundler query = null;
1845
1846 if (orderByComparator != null) {
1847 query = new StringBundler(6 +
1848 (orderByComparator.getOrderByFields().length * 6));
1849 }
1850 else {
1851 query = new StringBundler(3);
1852 }
1853
1854 query.append(_SQL_SELECT_PORTLETPREFERENCES_WHERE);
1855
1856 query.append(_FINDER_COLUMN_P_P_PLID_2);
1857
1858 if (portletId == null) {
1859 query.append(_FINDER_COLUMN_P_P_PORTLETID_1);
1860 }
1861 else {
1862 if (portletId.equals(StringPool.BLANK)) {
1863 query.append(_FINDER_COLUMN_P_P_PORTLETID_3);
1864 }
1865 else {
1866 query.append(_FINDER_COLUMN_P_P_PORTLETID_2);
1867 }
1868 }
1869
1870 if (orderByComparator != null) {
1871 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1872
1873 if (orderByConditionFields.length > 0) {
1874 query.append(WHERE_AND);
1875 }
1876
1877 for (int i = 0; i < orderByConditionFields.length; i++) {
1878 query.append(_ORDER_BY_ENTITY_ALIAS);
1879 query.append(orderByConditionFields[i]);
1880
1881 if ((i + 1) < orderByConditionFields.length) {
1882 if (orderByComparator.isAscending() ^ previous) {
1883 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1884 }
1885 else {
1886 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1887 }
1888 }
1889 else {
1890 if (orderByComparator.isAscending() ^ previous) {
1891 query.append(WHERE_GREATER_THAN);
1892 }
1893 else {
1894 query.append(WHERE_LESSER_THAN);
1895 }
1896 }
1897 }
1898
1899 query.append(ORDER_BY_CLAUSE);
1900
1901 String[] orderByFields = orderByComparator.getOrderByFields();
1902
1903 for (int i = 0; i < orderByFields.length; i++) {
1904 query.append(_ORDER_BY_ENTITY_ALIAS);
1905 query.append(orderByFields[i]);
1906
1907 if ((i + 1) < orderByFields.length) {
1908 if (orderByComparator.isAscending() ^ previous) {
1909 query.append(ORDER_BY_ASC_HAS_NEXT);
1910 }
1911 else {
1912 query.append(ORDER_BY_DESC_HAS_NEXT);
1913 }
1914 }
1915 else {
1916 if (orderByComparator.isAscending() ^ previous) {
1917 query.append(ORDER_BY_ASC);
1918 }
1919 else {
1920 query.append(ORDER_BY_DESC);
1921 }
1922 }
1923 }
1924 }
1925
1926 String sql = query.toString();
1927
1928 Query q = session.createQuery(sql);
1929
1930 q.setFirstResult(0);
1931 q.setMaxResults(2);
1932
1933 QueryPos qPos = QueryPos.getInstance(q);
1934
1935 qPos.add(plid);
1936
1937 if (portletId != null) {
1938 qPos.add(portletId);
1939 }
1940
1941 if (orderByComparator != null) {
1942 Object[] values = orderByComparator.getOrderByConditionValues(portletPreferences);
1943
1944 for (Object value : values) {
1945 qPos.add(value);
1946 }
1947 }
1948
1949 List<PortletPreferences> list = q.list();
1950
1951 if (list.size() == 2) {
1952 return list.get(1);
1953 }
1954 else {
1955 return null;
1956 }
1957 }
1958
1959
1968 public List<PortletPreferences> findByO_O_P(long ownerId, int ownerType,
1969 long plid) throws SystemException {
1970 return findByO_O_P(ownerId, ownerType, plid, QueryUtil.ALL_POS,
1971 QueryUtil.ALL_POS, null);
1972 }
1973
1974
1989 public List<PortletPreferences> findByO_O_P(long ownerId, int ownerType,
1990 long plid, int start, int end) throws SystemException {
1991 return findByO_O_P(ownerId, ownerType, plid, start, end, null);
1992 }
1993
1994
2010 public List<PortletPreferences> findByO_O_P(long ownerId, int ownerType,
2011 long plid, int start, int end, OrderByComparator orderByComparator)
2012 throws SystemException {
2013 FinderPath finderPath = null;
2014 Object[] finderArgs = null;
2015
2016 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2017 (orderByComparator == null)) {
2018 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_O_O_P;
2019 finderArgs = new Object[] { ownerId, ownerType, plid };
2020 }
2021 else {
2022 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_O_O_P;
2023 finderArgs = new Object[] {
2024 ownerId, ownerType, plid,
2025
2026 start, end, orderByComparator
2027 };
2028 }
2029
2030 List<PortletPreferences> list = (List<PortletPreferences>)FinderCacheUtil.getResult(finderPath,
2031 finderArgs, this);
2032
2033 if ((list != null) && !list.isEmpty()) {
2034 for (PortletPreferences portletPreferences : list) {
2035 if ((ownerId != portletPreferences.getOwnerId()) ||
2036 (ownerType != portletPreferences.getOwnerType()) ||
2037 (plid != portletPreferences.getPlid())) {
2038 list = null;
2039
2040 break;
2041 }
2042 }
2043 }
2044
2045 if (list == null) {
2046 StringBundler query = null;
2047
2048 if (orderByComparator != null) {
2049 query = new StringBundler(5 +
2050 (orderByComparator.getOrderByFields().length * 3));
2051 }
2052 else {
2053 query = new StringBundler(4);
2054 }
2055
2056 query.append(_SQL_SELECT_PORTLETPREFERENCES_WHERE);
2057
2058 query.append(_FINDER_COLUMN_O_O_P_OWNERID_2);
2059
2060 query.append(_FINDER_COLUMN_O_O_P_OWNERTYPE_2);
2061
2062 query.append(_FINDER_COLUMN_O_O_P_PLID_2);
2063
2064 if (orderByComparator != null) {
2065 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2066 orderByComparator);
2067 }
2068
2069 String sql = query.toString();
2070
2071 Session session = null;
2072
2073 try {
2074 session = openSession();
2075
2076 Query q = session.createQuery(sql);
2077
2078 QueryPos qPos = QueryPos.getInstance(q);
2079
2080 qPos.add(ownerId);
2081
2082 qPos.add(ownerType);
2083
2084 qPos.add(plid);
2085
2086 list = (List<PortletPreferences>)QueryUtil.list(q,
2087 getDialect(), start, end);
2088 }
2089 catch (Exception e) {
2090 throw processException(e);
2091 }
2092 finally {
2093 if (list == null) {
2094 FinderCacheUtil.removeResult(finderPath, finderArgs);
2095 }
2096 else {
2097 cacheResult(list);
2098
2099 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2100 }
2101
2102 closeSession(session);
2103 }
2104 }
2105
2106 return list;
2107 }
2108
2109
2120 public PortletPreferences findByO_O_P_First(long ownerId, int ownerType,
2121 long plid, OrderByComparator orderByComparator)
2122 throws NoSuchPortletPreferencesException, SystemException {
2123 PortletPreferences portletPreferences = fetchByO_O_P_First(ownerId,
2124 ownerType, plid, orderByComparator);
2125
2126 if (portletPreferences != null) {
2127 return portletPreferences;
2128 }
2129
2130 StringBundler msg = new StringBundler(8);
2131
2132 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2133
2134 msg.append("ownerId=");
2135 msg.append(ownerId);
2136
2137 msg.append(", ownerType=");
2138 msg.append(ownerType);
2139
2140 msg.append(", plid=");
2141 msg.append(plid);
2142
2143 msg.append(StringPool.CLOSE_CURLY_BRACE);
2144
2145 throw new NoSuchPortletPreferencesException(msg.toString());
2146 }
2147
2148
2158 public PortletPreferences fetchByO_O_P_First(long ownerId, int ownerType,
2159 long plid, OrderByComparator orderByComparator)
2160 throws SystemException {
2161 List<PortletPreferences> list = findByO_O_P(ownerId, ownerType, plid,
2162 0, 1, orderByComparator);
2163
2164 if (!list.isEmpty()) {
2165 return list.get(0);
2166 }
2167
2168 return null;
2169 }
2170
2171
2182 public PortletPreferences findByO_O_P_Last(long ownerId, int ownerType,
2183 long plid, OrderByComparator orderByComparator)
2184 throws NoSuchPortletPreferencesException, SystemException {
2185 PortletPreferences portletPreferences = fetchByO_O_P_Last(ownerId,
2186 ownerType, plid, orderByComparator);
2187
2188 if (portletPreferences != null) {
2189 return portletPreferences;
2190 }
2191
2192 StringBundler msg = new StringBundler(8);
2193
2194 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2195
2196 msg.append("ownerId=");
2197 msg.append(ownerId);
2198
2199 msg.append(", ownerType=");
2200 msg.append(ownerType);
2201
2202 msg.append(", plid=");
2203 msg.append(plid);
2204
2205 msg.append(StringPool.CLOSE_CURLY_BRACE);
2206
2207 throw new NoSuchPortletPreferencesException(msg.toString());
2208 }
2209
2210
2220 public PortletPreferences fetchByO_O_P_Last(long ownerId, int ownerType,
2221 long plid, OrderByComparator orderByComparator)
2222 throws SystemException {
2223 int count = countByO_O_P(ownerId, ownerType, plid);
2224
2225 List<PortletPreferences> list = findByO_O_P(ownerId, ownerType, plid,
2226 count - 1, count, orderByComparator);
2227
2228 if (!list.isEmpty()) {
2229 return list.get(0);
2230 }
2231
2232 return null;
2233 }
2234
2235
2247 public PortletPreferences[] findByO_O_P_PrevAndNext(
2248 long portletPreferencesId, long ownerId, int ownerType, long plid,
2249 OrderByComparator orderByComparator)
2250 throws NoSuchPortletPreferencesException, SystemException {
2251 PortletPreferences portletPreferences = findByPrimaryKey(portletPreferencesId);
2252
2253 Session session = null;
2254
2255 try {
2256 session = openSession();
2257
2258 PortletPreferences[] array = new PortletPreferencesImpl[3];
2259
2260 array[0] = getByO_O_P_PrevAndNext(session, portletPreferences,
2261 ownerId, ownerType, plid, orderByComparator, true);
2262
2263 array[1] = portletPreferences;
2264
2265 array[2] = getByO_O_P_PrevAndNext(session, portletPreferences,
2266 ownerId, ownerType, plid, orderByComparator, false);
2267
2268 return array;
2269 }
2270 catch (Exception e) {
2271 throw processException(e);
2272 }
2273 finally {
2274 closeSession(session);
2275 }
2276 }
2277
2278 protected PortletPreferences getByO_O_P_PrevAndNext(Session session,
2279 PortletPreferences portletPreferences, long ownerId, int ownerType,
2280 long plid, OrderByComparator orderByComparator, boolean previous) {
2281 StringBundler query = null;
2282
2283 if (orderByComparator != null) {
2284 query = new StringBundler(6 +
2285 (orderByComparator.getOrderByFields().length * 6));
2286 }
2287 else {
2288 query = new StringBundler(3);
2289 }
2290
2291 query.append(_SQL_SELECT_PORTLETPREFERENCES_WHERE);
2292
2293 query.append(_FINDER_COLUMN_O_O_P_OWNERID_2);
2294
2295 query.append(_FINDER_COLUMN_O_O_P_OWNERTYPE_2);
2296
2297 query.append(_FINDER_COLUMN_O_O_P_PLID_2);
2298
2299 if (orderByComparator != null) {
2300 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2301
2302 if (orderByConditionFields.length > 0) {
2303 query.append(WHERE_AND);
2304 }
2305
2306 for (int i = 0; i < orderByConditionFields.length; i++) {
2307 query.append(_ORDER_BY_ENTITY_ALIAS);
2308 query.append(orderByConditionFields[i]);
2309
2310 if ((i + 1) < orderByConditionFields.length) {
2311 if (orderByComparator.isAscending() ^ previous) {
2312 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2313 }
2314 else {
2315 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2316 }
2317 }
2318 else {
2319 if (orderByComparator.isAscending() ^ previous) {
2320 query.append(WHERE_GREATER_THAN);
2321 }
2322 else {
2323 query.append(WHERE_LESSER_THAN);
2324 }
2325 }
2326 }
2327
2328 query.append(ORDER_BY_CLAUSE);
2329
2330 String[] orderByFields = orderByComparator.getOrderByFields();
2331
2332 for (int i = 0; i < orderByFields.length; i++) {
2333 query.append(_ORDER_BY_ENTITY_ALIAS);
2334 query.append(orderByFields[i]);
2335
2336 if ((i + 1) < orderByFields.length) {
2337 if (orderByComparator.isAscending() ^ previous) {
2338 query.append(ORDER_BY_ASC_HAS_NEXT);
2339 }
2340 else {
2341 query.append(ORDER_BY_DESC_HAS_NEXT);
2342 }
2343 }
2344 else {
2345 if (orderByComparator.isAscending() ^ previous) {
2346 query.append(ORDER_BY_ASC);
2347 }
2348 else {
2349 query.append(ORDER_BY_DESC);
2350 }
2351 }
2352 }
2353 }
2354
2355 String sql = query.toString();
2356
2357 Query q = session.createQuery(sql);
2358
2359 q.setFirstResult(0);
2360 q.setMaxResults(2);
2361
2362 QueryPos qPos = QueryPos.getInstance(q);
2363
2364 qPos.add(ownerId);
2365
2366 qPos.add(ownerType);
2367
2368 qPos.add(plid);
2369
2370 if (orderByComparator != null) {
2371 Object[] values = orderByComparator.getOrderByConditionValues(portletPreferences);
2372
2373 for (Object value : values) {
2374 qPos.add(value);
2375 }
2376 }
2377
2378 List<PortletPreferences> list = q.list();
2379
2380 if (list.size() == 2) {
2381 return list.get(1);
2382 }
2383 else {
2384 return null;
2385 }
2386 }
2387
2388
2397 public List<PortletPreferences> findByO_P_P(int ownerType, long plid,
2398 String portletId) throws SystemException {
2399 return findByO_P_P(ownerType, plid, portletId, QueryUtil.ALL_POS,
2400 QueryUtil.ALL_POS, null);
2401 }
2402
2403
2418 public List<PortletPreferences> findByO_P_P(int ownerType, long plid,
2419 String portletId, int start, int end) throws SystemException {
2420 return findByO_P_P(ownerType, plid, portletId, start, end, null);
2421 }
2422
2423
2439 public List<PortletPreferences> findByO_P_P(int ownerType, long plid,
2440 String portletId, int start, int end,
2441 OrderByComparator orderByComparator) throws SystemException {
2442 FinderPath finderPath = null;
2443 Object[] finderArgs = null;
2444
2445 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2446 (orderByComparator == null)) {
2447 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_O_P_P;
2448 finderArgs = new Object[] { ownerType, plid, portletId };
2449 }
2450 else {
2451 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_O_P_P;
2452 finderArgs = new Object[] {
2453 ownerType, plid, portletId,
2454
2455 start, end, orderByComparator
2456 };
2457 }
2458
2459 List<PortletPreferences> list = (List<PortletPreferences>)FinderCacheUtil.getResult(finderPath,
2460 finderArgs, this);
2461
2462 if ((list != null) && !list.isEmpty()) {
2463 for (PortletPreferences portletPreferences : list) {
2464 if ((ownerType != portletPreferences.getOwnerType()) ||
2465 (plid != portletPreferences.getPlid()) ||
2466 !Validator.equals(portletId,
2467 portletPreferences.getPortletId())) {
2468 list = null;
2469
2470 break;
2471 }
2472 }
2473 }
2474
2475 if (list == null) {
2476 StringBundler query = null;
2477
2478 if (orderByComparator != null) {
2479 query = new StringBundler(5 +
2480 (orderByComparator.getOrderByFields().length * 3));
2481 }
2482 else {
2483 query = new StringBundler(4);
2484 }
2485
2486 query.append(_SQL_SELECT_PORTLETPREFERENCES_WHERE);
2487
2488 query.append(_FINDER_COLUMN_O_P_P_OWNERTYPE_2);
2489
2490 query.append(_FINDER_COLUMN_O_P_P_PLID_2);
2491
2492 if (portletId == null) {
2493 query.append(_FINDER_COLUMN_O_P_P_PORTLETID_1);
2494 }
2495 else {
2496 if (portletId.equals(StringPool.BLANK)) {
2497 query.append(_FINDER_COLUMN_O_P_P_PORTLETID_3);
2498 }
2499 else {
2500 query.append(_FINDER_COLUMN_O_P_P_PORTLETID_2);
2501 }
2502 }
2503
2504 if (orderByComparator != null) {
2505 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2506 orderByComparator);
2507 }
2508
2509 String sql = query.toString();
2510
2511 Session session = null;
2512
2513 try {
2514 session = openSession();
2515
2516 Query q = session.createQuery(sql);
2517
2518 QueryPos qPos = QueryPos.getInstance(q);
2519
2520 qPos.add(ownerType);
2521
2522 qPos.add(plid);
2523
2524 if (portletId != null) {
2525 qPos.add(portletId);
2526 }
2527
2528 list = (List<PortletPreferences>)QueryUtil.list(q,
2529 getDialect(), start, end);
2530 }
2531 catch (Exception e) {
2532 throw processException(e);
2533 }
2534 finally {
2535 if (list == null) {
2536 FinderCacheUtil.removeResult(finderPath, finderArgs);
2537 }
2538 else {
2539 cacheResult(list);
2540
2541 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2542 }
2543
2544 closeSession(session);
2545 }
2546 }
2547
2548 return list;
2549 }
2550
2551
2562 public PortletPreferences findByO_P_P_First(int ownerType, long plid,
2563 String portletId, OrderByComparator orderByComparator)
2564 throws NoSuchPortletPreferencesException, SystemException {
2565 PortletPreferences portletPreferences = fetchByO_P_P_First(ownerType,
2566 plid, portletId, orderByComparator);
2567
2568 if (portletPreferences != null) {
2569 return portletPreferences;
2570 }
2571
2572 StringBundler msg = new StringBundler(8);
2573
2574 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2575
2576 msg.append("ownerType=");
2577 msg.append(ownerType);
2578
2579 msg.append(", plid=");
2580 msg.append(plid);
2581
2582 msg.append(", portletId=");
2583 msg.append(portletId);
2584
2585 msg.append(StringPool.CLOSE_CURLY_BRACE);
2586
2587 throw new NoSuchPortletPreferencesException(msg.toString());
2588 }
2589
2590
2600 public PortletPreferences fetchByO_P_P_First(int ownerType, long plid,
2601 String portletId, OrderByComparator orderByComparator)
2602 throws SystemException {
2603 List<PortletPreferences> list = findByO_P_P(ownerType, plid, portletId,
2604 0, 1, orderByComparator);
2605
2606 if (!list.isEmpty()) {
2607 return list.get(0);
2608 }
2609
2610 return null;
2611 }
2612
2613
2624 public PortletPreferences findByO_P_P_Last(int ownerType, long plid,
2625 String portletId, OrderByComparator orderByComparator)
2626 throws NoSuchPortletPreferencesException, SystemException {
2627 PortletPreferences portletPreferences = fetchByO_P_P_Last(ownerType,
2628 plid, portletId, orderByComparator);
2629
2630 if (portletPreferences != null) {
2631 return portletPreferences;
2632 }
2633
2634 StringBundler msg = new StringBundler(8);
2635
2636 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2637
2638 msg.append("ownerType=");
2639 msg.append(ownerType);
2640
2641 msg.append(", plid=");
2642 msg.append(plid);
2643
2644 msg.append(", portletId=");
2645 msg.append(portletId);
2646
2647 msg.append(StringPool.CLOSE_CURLY_BRACE);
2648
2649 throw new NoSuchPortletPreferencesException(msg.toString());
2650 }
2651
2652
2662 public PortletPreferences fetchByO_P_P_Last(int ownerType, long plid,
2663 String portletId, OrderByComparator orderByComparator)
2664 throws SystemException {
2665 int count = countByO_P_P(ownerType, plid, portletId);
2666
2667 List<PortletPreferences> list = findByO_P_P(ownerType, plid, portletId,
2668 count - 1, count, orderByComparator);
2669
2670 if (!list.isEmpty()) {
2671 return list.get(0);
2672 }
2673
2674 return null;
2675 }
2676
2677
2689 public PortletPreferences[] findByO_P_P_PrevAndNext(
2690 long portletPreferencesId, int ownerType, long plid, String portletId,
2691 OrderByComparator orderByComparator)
2692 throws NoSuchPortletPreferencesException, SystemException {
2693 PortletPreferences portletPreferences = findByPrimaryKey(portletPreferencesId);
2694
2695 Session session = null;
2696
2697 try {
2698 session = openSession();
2699
2700 PortletPreferences[] array = new PortletPreferencesImpl[3];
2701
2702 array[0] = getByO_P_P_PrevAndNext(session, portletPreferences,
2703 ownerType, plid, portletId, orderByComparator, true);
2704
2705 array[1] = portletPreferences;
2706
2707 array[2] = getByO_P_P_PrevAndNext(session, portletPreferences,
2708 ownerType, plid, portletId, orderByComparator, false);
2709
2710 return array;
2711 }
2712 catch (Exception e) {
2713 throw processException(e);
2714 }
2715 finally {
2716 closeSession(session);
2717 }
2718 }
2719
2720 protected PortletPreferences getByO_P_P_PrevAndNext(Session session,
2721 PortletPreferences portletPreferences, int ownerType, long plid,
2722 String portletId, OrderByComparator orderByComparator, boolean previous) {
2723 StringBundler query = null;
2724
2725 if (orderByComparator != null) {
2726 query = new StringBundler(6 +
2727 (orderByComparator.getOrderByFields().length * 6));
2728 }
2729 else {
2730 query = new StringBundler(3);
2731 }
2732
2733 query.append(_SQL_SELECT_PORTLETPREFERENCES_WHERE);
2734
2735 query.append(_FINDER_COLUMN_O_P_P_OWNERTYPE_2);
2736
2737 query.append(_FINDER_COLUMN_O_P_P_PLID_2);
2738
2739 if (portletId == null) {
2740 query.append(_FINDER_COLUMN_O_P_P_PORTLETID_1);
2741 }
2742 else {
2743 if (portletId.equals(StringPool.BLANK)) {
2744 query.append(_FINDER_COLUMN_O_P_P_PORTLETID_3);
2745 }
2746 else {
2747 query.append(_FINDER_COLUMN_O_P_P_PORTLETID_2);
2748 }
2749 }
2750
2751 if (orderByComparator != null) {
2752 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2753
2754 if (orderByConditionFields.length > 0) {
2755 query.append(WHERE_AND);
2756 }
2757
2758 for (int i = 0; i < orderByConditionFields.length; i++) {
2759 query.append(_ORDER_BY_ENTITY_ALIAS);
2760 query.append(orderByConditionFields[i]);
2761
2762 if ((i + 1) < orderByConditionFields.length) {
2763 if (orderByComparator.isAscending() ^ previous) {
2764 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2765 }
2766 else {
2767 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2768 }
2769 }
2770 else {
2771 if (orderByComparator.isAscending() ^ previous) {
2772 query.append(WHERE_GREATER_THAN);
2773 }
2774 else {
2775 query.append(WHERE_LESSER_THAN);
2776 }
2777 }
2778 }
2779
2780 query.append(ORDER_BY_CLAUSE);
2781
2782 String[] orderByFields = orderByComparator.getOrderByFields();
2783
2784 for (int i = 0; i < orderByFields.length; i++) {
2785 query.append(_ORDER_BY_ENTITY_ALIAS);
2786 query.append(orderByFields[i]);
2787
2788 if ((i + 1) < orderByFields.length) {
2789 if (orderByComparator.isAscending() ^ previous) {
2790 query.append(ORDER_BY_ASC_HAS_NEXT);
2791 }
2792 else {
2793 query.append(ORDER_BY_DESC_HAS_NEXT);
2794 }
2795 }
2796 else {
2797 if (orderByComparator.isAscending() ^ previous) {
2798 query.append(ORDER_BY_ASC);
2799 }
2800 else {
2801 query.append(ORDER_BY_DESC);
2802 }
2803 }
2804 }
2805 }
2806
2807 String sql = query.toString();
2808
2809 Query q = session.createQuery(sql);
2810
2811 q.setFirstResult(0);
2812 q.setMaxResults(2);
2813
2814 QueryPos qPos = QueryPos.getInstance(q);
2815
2816 qPos.add(ownerType);
2817
2818 qPos.add(plid);
2819
2820 if (portletId != null) {
2821 qPos.add(portletId);
2822 }
2823
2824 if (orderByComparator != null) {
2825 Object[] values = orderByComparator.getOrderByConditionValues(portletPreferences);
2826
2827 for (Object value : values) {
2828 qPos.add(value);
2829 }
2830 }
2831
2832 List<PortletPreferences> list = q.list();
2833
2834 if (list.size() == 2) {
2835 return list.get(1);
2836 }
2837 else {
2838 return null;
2839 }
2840 }
2841
2842
2853 public PortletPreferences findByO_O_P_P(long ownerId, int ownerType,
2854 long plid, String portletId)
2855 throws NoSuchPortletPreferencesException, SystemException {
2856 PortletPreferences portletPreferences = fetchByO_O_P_P(ownerId,
2857 ownerType, plid, portletId);
2858
2859 if (portletPreferences == null) {
2860 StringBundler msg = new StringBundler(10);
2861
2862 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2863
2864 msg.append("ownerId=");
2865 msg.append(ownerId);
2866
2867 msg.append(", ownerType=");
2868 msg.append(ownerType);
2869
2870 msg.append(", plid=");
2871 msg.append(plid);
2872
2873 msg.append(", portletId=");
2874 msg.append(portletId);
2875
2876 msg.append(StringPool.CLOSE_CURLY_BRACE);
2877
2878 if (_log.isWarnEnabled()) {
2879 _log.warn(msg.toString());
2880 }
2881
2882 throw new NoSuchPortletPreferencesException(msg.toString());
2883 }
2884
2885 return portletPreferences;
2886 }
2887
2888
2898 public PortletPreferences fetchByO_O_P_P(long ownerId, int ownerType,
2899 long plid, String portletId) throws SystemException {
2900 return fetchByO_O_P_P(ownerId, ownerType, plid, portletId, true);
2901 }
2902
2903
2914 public PortletPreferences fetchByO_O_P_P(long ownerId, int ownerType,
2915 long plid, String portletId, boolean retrieveFromCache)
2916 throws SystemException {
2917 Object[] finderArgs = new Object[] { ownerId, ownerType, plid, portletId };
2918
2919 Object result = null;
2920
2921 if (retrieveFromCache) {
2922 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_O_O_P_P,
2923 finderArgs, this);
2924 }
2925
2926 if (result instanceof PortletPreferences) {
2927 PortletPreferences portletPreferences = (PortletPreferences)result;
2928
2929 if ((ownerId != portletPreferences.getOwnerId()) ||
2930 (ownerType != portletPreferences.getOwnerType()) ||
2931 (plid != portletPreferences.getPlid()) ||
2932 !Validator.equals(portletId,
2933 portletPreferences.getPortletId())) {
2934 result = null;
2935 }
2936 }
2937
2938 if (result == null) {
2939 StringBundler query = new StringBundler(5);
2940
2941 query.append(_SQL_SELECT_PORTLETPREFERENCES_WHERE);
2942
2943 query.append(_FINDER_COLUMN_O_O_P_P_OWNERID_2);
2944
2945 query.append(_FINDER_COLUMN_O_O_P_P_OWNERTYPE_2);
2946
2947 query.append(_FINDER_COLUMN_O_O_P_P_PLID_2);
2948
2949 if (portletId == null) {
2950 query.append(_FINDER_COLUMN_O_O_P_P_PORTLETID_1);
2951 }
2952 else {
2953 if (portletId.equals(StringPool.BLANK)) {
2954 query.append(_FINDER_COLUMN_O_O_P_P_PORTLETID_3);
2955 }
2956 else {
2957 query.append(_FINDER_COLUMN_O_O_P_P_PORTLETID_2);
2958 }
2959 }
2960
2961 String sql = query.toString();
2962
2963 Session session = null;
2964
2965 try {
2966 session = openSession();
2967
2968 Query q = session.createQuery(sql);
2969
2970 QueryPos qPos = QueryPos.getInstance(q);
2971
2972 qPos.add(ownerId);
2973
2974 qPos.add(ownerType);
2975
2976 qPos.add(plid);
2977
2978 if (portletId != null) {
2979 qPos.add(portletId);
2980 }
2981
2982 List<PortletPreferences> list = q.list();
2983
2984 result = list;
2985
2986 PortletPreferences portletPreferences = null;
2987
2988 if (list.isEmpty()) {
2989 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_O_O_P_P,
2990 finderArgs, list);
2991 }
2992 else {
2993 portletPreferences = list.get(0);
2994
2995 cacheResult(portletPreferences);
2996
2997 if ((portletPreferences.getOwnerId() != ownerId) ||
2998 (portletPreferences.getOwnerType() != ownerType) ||
2999 (portletPreferences.getPlid() != plid) ||
3000 (portletPreferences.getPortletId() == null) ||
3001 !portletPreferences.getPortletId().equals(portletId)) {
3002 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_O_O_P_P,
3003 finderArgs, portletPreferences);
3004 }
3005 }
3006
3007 return portletPreferences;
3008 }
3009 catch (Exception e) {
3010 throw processException(e);
3011 }
3012 finally {
3013 if (result == null) {
3014 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_O_O_P_P,
3015 finderArgs);
3016 }
3017
3018 closeSession(session);
3019 }
3020 }
3021 else {
3022 if (result instanceof List<?>) {
3023 return null;
3024 }
3025 else {
3026 return (PortletPreferences)result;
3027 }
3028 }
3029 }
3030
3031
3037 public List<PortletPreferences> findAll() throws SystemException {
3038 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
3039 }
3040
3041
3053 public List<PortletPreferences> findAll(int start, int end)
3054 throws SystemException {
3055 return findAll(start, end, null);
3056 }
3057
3058
3071 public List<PortletPreferences> findAll(int start, int end,
3072 OrderByComparator orderByComparator) throws SystemException {
3073 FinderPath finderPath = null;
3074 Object[] finderArgs = new Object[] { start, end, orderByComparator };
3075
3076 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3077 (orderByComparator == null)) {
3078 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
3079 finderArgs = FINDER_ARGS_EMPTY;
3080 }
3081 else {
3082 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
3083 finderArgs = new Object[] { start, end, orderByComparator };
3084 }
3085
3086 List<PortletPreferences> list = (List<PortletPreferences>)FinderCacheUtil.getResult(finderPath,
3087 finderArgs, this);
3088
3089 if (list == null) {
3090 StringBundler query = null;
3091 String sql = null;
3092
3093 if (orderByComparator != null) {
3094 query = new StringBundler(2 +
3095 (orderByComparator.getOrderByFields().length * 3));
3096
3097 query.append(_SQL_SELECT_PORTLETPREFERENCES);
3098
3099 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3100 orderByComparator);
3101
3102 sql = query.toString();
3103 }
3104 else {
3105 sql = _SQL_SELECT_PORTLETPREFERENCES;
3106 }
3107
3108 Session session = null;
3109
3110 try {
3111 session = openSession();
3112
3113 Query q = session.createQuery(sql);
3114
3115 if (orderByComparator == null) {
3116 list = (List<PortletPreferences>)QueryUtil.list(q,
3117 getDialect(), start, end, false);
3118
3119 Collections.sort(list);
3120 }
3121 else {
3122 list = (List<PortletPreferences>)QueryUtil.list(q,
3123 getDialect(), start, end);
3124 }
3125 }
3126 catch (Exception e) {
3127 throw processException(e);
3128 }
3129 finally {
3130 if (list == null) {
3131 FinderCacheUtil.removeResult(finderPath, finderArgs);
3132 }
3133 else {
3134 cacheResult(list);
3135
3136 FinderCacheUtil.putResult(finderPath, finderArgs, list);
3137 }
3138
3139 closeSession(session);
3140 }
3141 }
3142
3143 return list;
3144 }
3145
3146
3152 public void removeByPlid(long plid) throws SystemException {
3153 for (PortletPreferences portletPreferences : findByPlid(plid)) {
3154 remove(portletPreferences);
3155 }
3156 }
3157
3158
3164 public void removeByPortletId(String portletId) throws SystemException {
3165 for (PortletPreferences portletPreferences : findByPortletId(portletId)) {
3166 remove(portletPreferences);
3167 }
3168 }
3169
3170
3177 public void removeByP_P(long plid, String portletId)
3178 throws SystemException {
3179 for (PortletPreferences portletPreferences : findByP_P(plid, portletId)) {
3180 remove(portletPreferences);
3181 }
3182 }
3183
3184
3192 public void removeByO_O_P(long ownerId, int ownerType, long plid)
3193 throws SystemException {
3194 for (PortletPreferences portletPreferences : findByO_O_P(ownerId,
3195 ownerType, plid)) {
3196 remove(portletPreferences);
3197 }
3198 }
3199
3200
3208 public void removeByO_P_P(int ownerType, long plid, String portletId)
3209 throws SystemException {
3210 for (PortletPreferences portletPreferences : findByO_P_P(ownerType,
3211 plid, portletId)) {
3212 remove(portletPreferences);
3213 }
3214 }
3215
3216
3226 public PortletPreferences removeByO_O_P_P(long ownerId, int ownerType,
3227 long plid, String portletId)
3228 throws NoSuchPortletPreferencesException, SystemException {
3229 PortletPreferences portletPreferences = findByO_O_P_P(ownerId,
3230 ownerType, plid, portletId);
3231
3232 return remove(portletPreferences);
3233 }
3234
3235
3240 public void removeAll() throws SystemException {
3241 for (PortletPreferences portletPreferences : findAll()) {
3242 remove(portletPreferences);
3243 }
3244 }
3245
3246
3253 public int countByPlid(long plid) throws SystemException {
3254 Object[] finderArgs = new Object[] { plid };
3255
3256 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_PLID,
3257 finderArgs, this);
3258
3259 if (count == null) {
3260 StringBundler query = new StringBundler(2);
3261
3262 query.append(_SQL_COUNT_PORTLETPREFERENCES_WHERE);
3263
3264 query.append(_FINDER_COLUMN_PLID_PLID_2);
3265
3266 String sql = query.toString();
3267
3268 Session session = null;
3269
3270 try {
3271 session = openSession();
3272
3273 Query q = session.createQuery(sql);
3274
3275 QueryPos qPos = QueryPos.getInstance(q);
3276
3277 qPos.add(plid);
3278
3279 count = (Long)q.uniqueResult();
3280 }
3281 catch (Exception e) {
3282 throw processException(e);
3283 }
3284 finally {
3285 if (count == null) {
3286 count = Long.valueOf(0);
3287 }
3288
3289 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_PLID,
3290 finderArgs, count);
3291
3292 closeSession(session);
3293 }
3294 }
3295
3296 return count.intValue();
3297 }
3298
3299
3306 public int countByPortletId(String portletId) throws SystemException {
3307 Object[] finderArgs = new Object[] { portletId };
3308
3309 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_PORTLETID,
3310 finderArgs, this);
3311
3312 if (count == null) {
3313 StringBundler query = new StringBundler(2);
3314
3315 query.append(_SQL_COUNT_PORTLETPREFERENCES_WHERE);
3316
3317 if (portletId == null) {
3318 query.append(_FINDER_COLUMN_PORTLETID_PORTLETID_1);
3319 }
3320 else {
3321 if (portletId.equals(StringPool.BLANK)) {
3322 query.append(_FINDER_COLUMN_PORTLETID_PORTLETID_3);
3323 }
3324 else {
3325 query.append(_FINDER_COLUMN_PORTLETID_PORTLETID_2);
3326 }
3327 }
3328
3329 String sql = query.toString();
3330
3331 Session session = null;
3332
3333 try {
3334 session = openSession();
3335
3336 Query q = session.createQuery(sql);
3337
3338 QueryPos qPos = QueryPos.getInstance(q);
3339
3340 if (portletId != null) {
3341 qPos.add(portletId);
3342 }
3343
3344 count = (Long)q.uniqueResult();
3345 }
3346 catch (Exception e) {
3347 throw processException(e);
3348 }
3349 finally {
3350 if (count == null) {
3351 count = Long.valueOf(0);
3352 }
3353
3354 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_PORTLETID,
3355 finderArgs, count);
3356
3357 closeSession(session);
3358 }
3359 }
3360
3361 return count.intValue();
3362 }
3363
3364
3372 public int countByP_P(long plid, String portletId)
3373 throws SystemException {
3374 Object[] finderArgs = new Object[] { plid, portletId };
3375
3376 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_P_P,
3377 finderArgs, this);
3378
3379 if (count == null) {
3380 StringBundler query = new StringBundler(3);
3381
3382 query.append(_SQL_COUNT_PORTLETPREFERENCES_WHERE);
3383
3384 query.append(_FINDER_COLUMN_P_P_PLID_2);
3385
3386 if (portletId == null) {
3387 query.append(_FINDER_COLUMN_P_P_PORTLETID_1);
3388 }
3389 else {
3390 if (portletId.equals(StringPool.BLANK)) {
3391 query.append(_FINDER_COLUMN_P_P_PORTLETID_3);
3392 }
3393 else {
3394 query.append(_FINDER_COLUMN_P_P_PORTLETID_2);
3395 }
3396 }
3397
3398 String sql = query.toString();
3399
3400 Session session = null;
3401
3402 try {
3403 session = openSession();
3404
3405 Query q = session.createQuery(sql);
3406
3407 QueryPos qPos = QueryPos.getInstance(q);
3408
3409 qPos.add(plid);
3410
3411 if (portletId != null) {
3412 qPos.add(portletId);
3413 }
3414
3415 count = (Long)q.uniqueResult();
3416 }
3417 catch (Exception e) {
3418 throw processException(e);
3419 }
3420 finally {
3421 if (count == null) {
3422 count = Long.valueOf(0);
3423 }
3424
3425 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_P_P, finderArgs,
3426 count);
3427
3428 closeSession(session);
3429 }
3430 }
3431
3432 return count.intValue();
3433 }
3434
3435
3444 public int countByO_O_P(long ownerId, int ownerType, long plid)
3445 throws SystemException {
3446 Object[] finderArgs = new Object[] { ownerId, ownerType, plid };
3447
3448 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_O_O_P,
3449 finderArgs, this);
3450
3451 if (count == null) {
3452 StringBundler query = new StringBundler(4);
3453
3454 query.append(_SQL_COUNT_PORTLETPREFERENCES_WHERE);
3455
3456 query.append(_FINDER_COLUMN_O_O_P_OWNERID_2);
3457
3458 query.append(_FINDER_COLUMN_O_O_P_OWNERTYPE_2);
3459
3460 query.append(_FINDER_COLUMN_O_O_P_PLID_2);
3461
3462 String sql = query.toString();
3463
3464 Session session = null;
3465
3466 try {
3467 session = openSession();
3468
3469 Query q = session.createQuery(sql);
3470
3471 QueryPos qPos = QueryPos.getInstance(q);
3472
3473 qPos.add(ownerId);
3474
3475 qPos.add(ownerType);
3476
3477 qPos.add(plid);
3478
3479 count = (Long)q.uniqueResult();
3480 }
3481 catch (Exception e) {
3482 throw processException(e);
3483 }
3484 finally {
3485 if (count == null) {
3486 count = Long.valueOf(0);
3487 }
3488
3489 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_O_O_P,
3490 finderArgs, count);
3491
3492 closeSession(session);
3493 }
3494 }
3495
3496 return count.intValue();
3497 }
3498
3499
3508 public int countByO_P_P(int ownerType, long plid, String portletId)
3509 throws SystemException {
3510 Object[] finderArgs = new Object[] { ownerType, plid, portletId };
3511
3512 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_O_P_P,
3513 finderArgs, this);
3514
3515 if (count == null) {
3516 StringBundler query = new StringBundler(4);
3517
3518 query.append(_SQL_COUNT_PORTLETPREFERENCES_WHERE);
3519
3520 query.append(_FINDER_COLUMN_O_P_P_OWNERTYPE_2);
3521
3522 query.append(_FINDER_COLUMN_O_P_P_PLID_2);
3523
3524 if (portletId == null) {
3525 query.append(_FINDER_COLUMN_O_P_P_PORTLETID_1);
3526 }
3527 else {
3528 if (portletId.equals(StringPool.BLANK)) {
3529 query.append(_FINDER_COLUMN_O_P_P_PORTLETID_3);
3530 }
3531 else {
3532 query.append(_FINDER_COLUMN_O_P_P_PORTLETID_2);
3533 }
3534 }
3535
3536 String sql = query.toString();
3537
3538 Session session = null;
3539
3540 try {
3541 session = openSession();
3542
3543 Query q = session.createQuery(sql);
3544
3545 QueryPos qPos = QueryPos.getInstance(q);
3546
3547 qPos.add(ownerType);
3548
3549 qPos.add(plid);
3550
3551 if (portletId != null) {
3552 qPos.add(portletId);
3553 }
3554
3555 count = (Long)q.uniqueResult();
3556 }
3557 catch (Exception e) {
3558 throw processException(e);
3559 }
3560 finally {
3561 if (count == null) {
3562 count = Long.valueOf(0);
3563 }
3564
3565 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_O_P_P,
3566 finderArgs, count);
3567
3568 closeSession(session);
3569 }
3570 }
3571
3572 return count.intValue();
3573 }
3574
3575
3585 public int countByO_O_P_P(long ownerId, int ownerType, long plid,
3586 String portletId) throws SystemException {
3587 Object[] finderArgs = new Object[] { ownerId, ownerType, plid, portletId };
3588
3589 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_O_O_P_P,
3590 finderArgs, this);
3591
3592 if (count == null) {
3593 StringBundler query = new StringBundler(5);
3594
3595 query.append(_SQL_COUNT_PORTLETPREFERENCES_WHERE);
3596
3597 query.append(_FINDER_COLUMN_O_O_P_P_OWNERID_2);
3598
3599 query.append(_FINDER_COLUMN_O_O_P_P_OWNERTYPE_2);
3600
3601 query.append(_FINDER_COLUMN_O_O_P_P_PLID_2);
3602
3603 if (portletId == null) {
3604 query.append(_FINDER_COLUMN_O_O_P_P_PORTLETID_1);
3605 }
3606 else {
3607 if (portletId.equals(StringPool.BLANK)) {
3608 query.append(_FINDER_COLUMN_O_O_P_P_PORTLETID_3);
3609 }
3610 else {
3611 query.append(_FINDER_COLUMN_O_O_P_P_PORTLETID_2);
3612 }
3613 }
3614
3615 String sql = query.toString();
3616
3617 Session session = null;
3618
3619 try {
3620 session = openSession();
3621
3622 Query q = session.createQuery(sql);
3623
3624 QueryPos qPos = QueryPos.getInstance(q);
3625
3626 qPos.add(ownerId);
3627
3628 qPos.add(ownerType);
3629
3630 qPos.add(plid);
3631
3632 if (portletId != null) {
3633 qPos.add(portletId);
3634 }
3635
3636 count = (Long)q.uniqueResult();
3637 }
3638 catch (Exception e) {
3639 throw processException(e);
3640 }
3641 finally {
3642 if (count == null) {
3643 count = Long.valueOf(0);
3644 }
3645
3646 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_O_O_P_P,
3647 finderArgs, count);
3648
3649 closeSession(session);
3650 }
3651 }
3652
3653 return count.intValue();
3654 }
3655
3656
3662 public int countAll() throws SystemException {
3663 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
3664 FINDER_ARGS_EMPTY, this);
3665
3666 if (count == null) {
3667 Session session = null;
3668
3669 try {
3670 session = openSession();
3671
3672 Query q = session.createQuery(_SQL_COUNT_PORTLETPREFERENCES);
3673
3674 count = (Long)q.uniqueResult();
3675 }
3676 catch (Exception e) {
3677 throw processException(e);
3678 }
3679 finally {
3680 if (count == null) {
3681 count = Long.valueOf(0);
3682 }
3683
3684 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
3685 FINDER_ARGS_EMPTY, count);
3686
3687 closeSession(session);
3688 }
3689 }
3690
3691 return count.intValue();
3692 }
3693
3694
3697 public void afterPropertiesSet() {
3698 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
3699 com.liferay.portal.util.PropsUtil.get(
3700 "value.object.listener.com.liferay.portal.model.PortletPreferences")));
3701
3702 if (listenerClassNames.length > 0) {
3703 try {
3704 List<ModelListener<PortletPreferences>> listenersList = new ArrayList<ModelListener<PortletPreferences>>();
3705
3706 for (String listenerClassName : listenerClassNames) {
3707 Class<?> clazz = getClass();
3708
3709 listenersList.add((ModelListener<PortletPreferences>)InstanceFactory.newInstance(
3710 clazz.getClassLoader(), listenerClassName));
3711 }
3712
3713 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
3714 }
3715 catch (Exception e) {
3716 _log.error(e);
3717 }
3718 }
3719 }
3720
3721 public void destroy() {
3722 EntityCacheUtil.removeCache(PortletPreferencesImpl.class.getName());
3723 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
3724 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
3725 }
3726
3727 @BeanReference(type = AccountPersistence.class)
3728 protected AccountPersistence accountPersistence;
3729 @BeanReference(type = AddressPersistence.class)
3730 protected AddressPersistence addressPersistence;
3731 @BeanReference(type = BrowserTrackerPersistence.class)
3732 protected BrowserTrackerPersistence browserTrackerPersistence;
3733 @BeanReference(type = ClassNamePersistence.class)
3734 protected ClassNamePersistence classNamePersistence;
3735 @BeanReference(type = ClusterGroupPersistence.class)
3736 protected ClusterGroupPersistence clusterGroupPersistence;
3737 @BeanReference(type = CompanyPersistence.class)
3738 protected CompanyPersistence companyPersistence;
3739 @BeanReference(type = ContactPersistence.class)
3740 protected ContactPersistence contactPersistence;
3741 @BeanReference(type = CountryPersistence.class)
3742 protected CountryPersistence countryPersistence;
3743 @BeanReference(type = EmailAddressPersistence.class)
3744 protected EmailAddressPersistence emailAddressPersistence;
3745 @BeanReference(type = GroupPersistence.class)
3746 protected GroupPersistence groupPersistence;
3747 @BeanReference(type = ImagePersistence.class)
3748 protected ImagePersistence imagePersistence;
3749 @BeanReference(type = LayoutPersistence.class)
3750 protected LayoutPersistence layoutPersistence;
3751 @BeanReference(type = LayoutBranchPersistence.class)
3752 protected LayoutBranchPersistence layoutBranchPersistence;
3753 @BeanReference(type = LayoutPrototypePersistence.class)
3754 protected LayoutPrototypePersistence layoutPrototypePersistence;
3755 @BeanReference(type = LayoutRevisionPersistence.class)
3756 protected LayoutRevisionPersistence layoutRevisionPersistence;
3757 @BeanReference(type = LayoutSetPersistence.class)
3758 protected LayoutSetPersistence layoutSetPersistence;
3759 @BeanReference(type = LayoutSetBranchPersistence.class)
3760 protected LayoutSetBranchPersistence layoutSetBranchPersistence;
3761 @BeanReference(type = LayoutSetPrototypePersistence.class)
3762 protected LayoutSetPrototypePersistence layoutSetPrototypePersistence;
3763 @BeanReference(type = ListTypePersistence.class)
3764 protected ListTypePersistence listTypePersistence;
3765 @BeanReference(type = LockPersistence.class)
3766 protected LockPersistence lockPersistence;
3767 @BeanReference(type = MembershipRequestPersistence.class)
3768 protected MembershipRequestPersistence membershipRequestPersistence;
3769 @BeanReference(type = OrganizationPersistence.class)
3770 protected OrganizationPersistence organizationPersistence;
3771 @BeanReference(type = OrgGroupPermissionPersistence.class)
3772 protected OrgGroupPermissionPersistence orgGroupPermissionPersistence;
3773 @BeanReference(type = OrgGroupRolePersistence.class)
3774 protected OrgGroupRolePersistence orgGroupRolePersistence;
3775 @BeanReference(type = OrgLaborPersistence.class)
3776 protected OrgLaborPersistence orgLaborPersistence;
3777 @BeanReference(type = PasswordPolicyPersistence.class)
3778 protected PasswordPolicyPersistence passwordPolicyPersistence;
3779 @BeanReference(type = PasswordPolicyRelPersistence.class)
3780 protected PasswordPolicyRelPersistence passwordPolicyRelPersistence;
3781 @BeanReference(type = PasswordTrackerPersistence.class)
3782 protected PasswordTrackerPersistence passwordTrackerPersistence;
3783 @BeanReference(type = PermissionPersistence.class)
3784 protected PermissionPersistence permissionPersistence;
3785 @BeanReference(type = PhonePersistence.class)
3786 protected PhonePersistence phonePersistence;
3787 @BeanReference(type = PluginSettingPersistence.class)
3788 protected PluginSettingPersistence pluginSettingPersistence;
3789 @BeanReference(type = PortalPreferencesPersistence.class)
3790 protected PortalPreferencesPersistence portalPreferencesPersistence;
3791 @BeanReference(type = PortletPersistence.class)
3792 protected PortletPersistence portletPersistence;
3793 @BeanReference(type = PortletItemPersistence.class)
3794 protected PortletItemPersistence portletItemPersistence;
3795 @BeanReference(type = PortletPreferencesPersistence.class)
3796 protected PortletPreferencesPersistence portletPreferencesPersistence;
3797 @BeanReference(type = RegionPersistence.class)
3798 protected RegionPersistence regionPersistence;
3799 @BeanReference(type = ReleasePersistence.class)
3800 protected ReleasePersistence releasePersistence;
3801 @BeanReference(type = RepositoryPersistence.class)
3802 protected RepositoryPersistence repositoryPersistence;
3803 @BeanReference(type = RepositoryEntryPersistence.class)
3804 protected RepositoryEntryPersistence repositoryEntryPersistence;
3805 @BeanReference(type = ResourcePersistence.class)
3806 protected ResourcePersistence resourcePersistence;
3807 @BeanReference(type = ResourceActionPersistence.class)
3808 protected ResourceActionPersistence resourceActionPersistence;
3809 @BeanReference(type = ResourceBlockPersistence.class)
3810 protected ResourceBlockPersistence resourceBlockPersistence;
3811 @BeanReference(type = ResourceBlockPermissionPersistence.class)
3812 protected ResourceBlockPermissionPersistence resourceBlockPermissionPersistence;
3813 @BeanReference(type = ResourceCodePersistence.class)
3814 protected ResourceCodePersistence resourceCodePersistence;
3815 @BeanReference(type = ResourcePermissionPersistence.class)
3816 protected ResourcePermissionPersistence resourcePermissionPersistence;
3817 @BeanReference(type = ResourceTypePermissionPersistence.class)
3818 protected ResourceTypePermissionPersistence resourceTypePermissionPersistence;
3819 @BeanReference(type = RolePersistence.class)
3820 protected RolePersistence rolePersistence;
3821 @BeanReference(type = ServiceComponentPersistence.class)
3822 protected ServiceComponentPersistence serviceComponentPersistence;
3823 @BeanReference(type = ShardPersistence.class)
3824 protected ShardPersistence shardPersistence;
3825 @BeanReference(type = SubscriptionPersistence.class)
3826 protected SubscriptionPersistence subscriptionPersistence;
3827 @BeanReference(type = TeamPersistence.class)
3828 protected TeamPersistence teamPersistence;
3829 @BeanReference(type = TicketPersistence.class)
3830 protected TicketPersistence ticketPersistence;
3831 @BeanReference(type = UserPersistence.class)
3832 protected UserPersistence userPersistence;
3833 @BeanReference(type = UserGroupPersistence.class)
3834 protected UserGroupPersistence userGroupPersistence;
3835 @BeanReference(type = UserGroupGroupRolePersistence.class)
3836 protected UserGroupGroupRolePersistence userGroupGroupRolePersistence;
3837 @BeanReference(type = UserGroupRolePersistence.class)
3838 protected UserGroupRolePersistence userGroupRolePersistence;
3839 @BeanReference(type = UserIdMapperPersistence.class)
3840 protected UserIdMapperPersistence userIdMapperPersistence;
3841 @BeanReference(type = UserNotificationEventPersistence.class)
3842 protected UserNotificationEventPersistence userNotificationEventPersistence;
3843 @BeanReference(type = UserTrackerPersistence.class)
3844 protected UserTrackerPersistence userTrackerPersistence;
3845 @BeanReference(type = UserTrackerPathPersistence.class)
3846 protected UserTrackerPathPersistence userTrackerPathPersistence;
3847 @BeanReference(type = VirtualHostPersistence.class)
3848 protected VirtualHostPersistence virtualHostPersistence;
3849 @BeanReference(type = WebDAVPropsPersistence.class)
3850 protected WebDAVPropsPersistence webDAVPropsPersistence;
3851 @BeanReference(type = WebsitePersistence.class)
3852 protected WebsitePersistence websitePersistence;
3853 @BeanReference(type = WorkflowDefinitionLinkPersistence.class)
3854 protected WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
3855 @BeanReference(type = WorkflowInstanceLinkPersistence.class)
3856 protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
3857 private static final String _SQL_SELECT_PORTLETPREFERENCES = "SELECT portletPreferences FROM PortletPreferences portletPreferences";
3858 private static final String _SQL_SELECT_PORTLETPREFERENCES_WHERE = "SELECT portletPreferences FROM PortletPreferences portletPreferences WHERE ";
3859 private static final String _SQL_COUNT_PORTLETPREFERENCES = "SELECT COUNT(portletPreferences) FROM PortletPreferences portletPreferences";
3860 private static final String _SQL_COUNT_PORTLETPREFERENCES_WHERE = "SELECT COUNT(portletPreferences) FROM PortletPreferences portletPreferences WHERE ";
3861 private static final String _FINDER_COLUMN_PLID_PLID_2 = "portletPreferences.plid = ?";
3862 private static final String _FINDER_COLUMN_PORTLETID_PORTLETID_1 = "portletPreferences.portletId IS NULL";
3863 private static final String _FINDER_COLUMN_PORTLETID_PORTLETID_2 = "portletPreferences.portletId = ?";
3864 private static final String _FINDER_COLUMN_PORTLETID_PORTLETID_3 = "(portletPreferences.portletId IS NULL OR portletPreferences.portletId = ?)";
3865 private static final String _FINDER_COLUMN_P_P_PLID_2 = "portletPreferences.plid = ? AND ";
3866 private static final String _FINDER_COLUMN_P_P_PORTLETID_1 = "portletPreferences.portletId IS NULL";
3867 private static final String _FINDER_COLUMN_P_P_PORTLETID_2 = "portletPreferences.portletId = ?";
3868 private static final String _FINDER_COLUMN_P_P_PORTLETID_3 = "(portletPreferences.portletId IS NULL OR portletPreferences.portletId = ?)";
3869 private static final String _FINDER_COLUMN_O_O_P_OWNERID_2 = "portletPreferences.ownerId = ? AND ";
3870 private static final String _FINDER_COLUMN_O_O_P_OWNERTYPE_2 = "portletPreferences.ownerType = ? AND ";
3871 private static final String _FINDER_COLUMN_O_O_P_PLID_2 = "portletPreferences.plid = ?";
3872 private static final String _FINDER_COLUMN_O_P_P_OWNERTYPE_2 = "portletPreferences.ownerType = ? AND ";
3873 private static final String _FINDER_COLUMN_O_P_P_PLID_2 = "portletPreferences.plid = ? AND ";
3874 private static final String _FINDER_COLUMN_O_P_P_PORTLETID_1 = "portletPreferences.portletId IS NULL";
3875 private static final String _FINDER_COLUMN_O_P_P_PORTLETID_2 = "portletPreferences.portletId = ?";
3876 private static final String _FINDER_COLUMN_O_P_P_PORTLETID_3 = "(portletPreferences.portletId IS NULL OR portletPreferences.portletId = ?)";
3877 private static final String _FINDER_COLUMN_O_O_P_P_OWNERID_2 = "portletPreferences.ownerId = ? AND ";
3878 private static final String _FINDER_COLUMN_O_O_P_P_OWNERTYPE_2 = "portletPreferences.ownerType = ? AND ";
3879 private static final String _FINDER_COLUMN_O_O_P_P_PLID_2 = "portletPreferences.plid = ? AND ";
3880 private static final String _FINDER_COLUMN_O_O_P_P_PORTLETID_1 = "portletPreferences.portletId IS NULL";
3881 private static final String _FINDER_COLUMN_O_O_P_P_PORTLETID_2 = "portletPreferences.portletId = ?";
3882 private static final String _FINDER_COLUMN_O_O_P_P_PORTLETID_3 = "(portletPreferences.portletId IS NULL OR portletPreferences.portletId = ?)";
3883 private static final String _ORDER_BY_ENTITY_ALIAS = "portletPreferences.";
3884 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No PortletPreferences exists with the primary key ";
3885 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No PortletPreferences exists with the key {";
3886 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
3887 private static Log _log = LogFactoryUtil.getLog(PortletPreferencesPersistenceImpl.class);
3888 private static PortletPreferences _nullPortletPreferences = new PortletPreferencesImpl() {
3889 @Override
3890 public Object clone() {
3891 return this;
3892 }
3893
3894 @Override
3895 public CacheModel<PortletPreferences> toCacheModel() {
3896 return _nullPortletPreferencesCacheModel;
3897 }
3898 };
3899
3900 private static CacheModel<PortletPreferences> _nullPortletPreferencesCacheModel =
3901 new CacheModel<PortletPreferences>() {
3902 public PortletPreferences toEntityModel() {
3903 return _nullPortletPreferences;
3904 }
3905 };
3906 }