1
22
23 package com.liferay.portal.service.persistence;
24
25 import com.liferay.portal.NoSuchPluginSettingException;
26 import com.liferay.portal.SystemException;
27 import com.liferay.portal.kernel.annotation.BeanReference;
28 import com.liferay.portal.kernel.cache.CacheRegistry;
29 import com.liferay.portal.kernel.dao.orm.DynamicQuery;
30 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
31 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
32 import com.liferay.portal.kernel.dao.orm.FinderPath;
33 import com.liferay.portal.kernel.dao.orm.Query;
34 import com.liferay.portal.kernel.dao.orm.QueryPos;
35 import com.liferay.portal.kernel.dao.orm.QueryUtil;
36 import com.liferay.portal.kernel.dao.orm.Session;
37 import com.liferay.portal.kernel.log.Log;
38 import com.liferay.portal.kernel.log.LogFactoryUtil;
39 import com.liferay.portal.kernel.util.GetterUtil;
40 import com.liferay.portal.kernel.util.OrderByComparator;
41 import com.liferay.portal.kernel.util.StringPool;
42 import com.liferay.portal.kernel.util.StringUtil;
43 import com.liferay.portal.model.ModelListener;
44 import com.liferay.portal.model.PluginSetting;
45 import com.liferay.portal.model.impl.PluginSettingImpl;
46 import com.liferay.portal.model.impl.PluginSettingModelImpl;
47 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
48
49 import java.util.ArrayList;
50 import java.util.Collections;
51 import java.util.List;
52
53
59 public class PluginSettingPersistenceImpl extends BasePersistenceImpl
60 implements PluginSettingPersistence {
61 public static final String FINDER_CLASS_NAME_ENTITY = PluginSettingImpl.class.getName();
62 public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
63 ".List";
64 public static final FinderPath FINDER_PATH_FIND_BY_COMPANYID = new FinderPath(PluginSettingModelImpl.ENTITY_CACHE_ENABLED,
65 PluginSettingModelImpl.FINDER_CACHE_ENABLED,
66 FINDER_CLASS_NAME_LIST, "findByCompanyId",
67 new String[] { Long.class.getName() });
68 public static final FinderPath FINDER_PATH_FIND_BY_OBC_COMPANYID = new FinderPath(PluginSettingModelImpl.ENTITY_CACHE_ENABLED,
69 PluginSettingModelImpl.FINDER_CACHE_ENABLED,
70 FINDER_CLASS_NAME_LIST, "findByCompanyId",
71 new String[] {
72 Long.class.getName(),
73
74 "java.lang.Integer", "java.lang.Integer",
75 "com.liferay.portal.kernel.util.OrderByComparator"
76 });
77 public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(PluginSettingModelImpl.ENTITY_CACHE_ENABLED,
78 PluginSettingModelImpl.FINDER_CACHE_ENABLED,
79 FINDER_CLASS_NAME_LIST, "countByCompanyId",
80 new String[] { Long.class.getName() });
81 public static final FinderPath FINDER_PATH_FETCH_BY_C_I_T = new FinderPath(PluginSettingModelImpl.ENTITY_CACHE_ENABLED,
82 PluginSettingModelImpl.FINDER_CACHE_ENABLED,
83 FINDER_CLASS_NAME_ENTITY, "fetchByC_I_T",
84 new String[] {
85 Long.class.getName(), String.class.getName(),
86 String.class.getName()
87 });
88 public static final FinderPath FINDER_PATH_COUNT_BY_C_I_T = new FinderPath(PluginSettingModelImpl.ENTITY_CACHE_ENABLED,
89 PluginSettingModelImpl.FINDER_CACHE_ENABLED,
90 FINDER_CLASS_NAME_LIST, "countByC_I_T",
91 new String[] {
92 Long.class.getName(), String.class.getName(),
93 String.class.getName()
94 });
95 public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(PluginSettingModelImpl.ENTITY_CACHE_ENABLED,
96 PluginSettingModelImpl.FINDER_CACHE_ENABLED,
97 FINDER_CLASS_NAME_LIST, "findAll", new String[0]);
98 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(PluginSettingModelImpl.ENTITY_CACHE_ENABLED,
99 PluginSettingModelImpl.FINDER_CACHE_ENABLED,
100 FINDER_CLASS_NAME_LIST, "countAll", new String[0]);
101
102 public void cacheResult(PluginSetting pluginSetting) {
103 EntityCacheUtil.putResult(PluginSettingModelImpl.ENTITY_CACHE_ENABLED,
104 PluginSettingImpl.class, pluginSetting.getPrimaryKey(),
105 pluginSetting);
106
107 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_I_T,
108 new Object[] {
109 new Long(pluginSetting.getCompanyId()),
110
111 pluginSetting.getPluginId(),
112
113 pluginSetting.getPluginType()
114 }, pluginSetting);
115 }
116
117 public void cacheResult(List<PluginSetting> pluginSettings) {
118 for (PluginSetting pluginSetting : pluginSettings) {
119 if (EntityCacheUtil.getResult(
120 PluginSettingModelImpl.ENTITY_CACHE_ENABLED,
121 PluginSettingImpl.class, pluginSetting.getPrimaryKey(),
122 this) == null) {
123 cacheResult(pluginSetting);
124 }
125 }
126 }
127
128 public void clearCache() {
129 CacheRegistry.clear(PluginSettingImpl.class.getName());
130 EntityCacheUtil.clearCache(PluginSettingImpl.class.getName());
131 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
132 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
133 }
134
135 public PluginSetting create(long pluginSettingId) {
136 PluginSetting pluginSetting = new PluginSettingImpl();
137
138 pluginSetting.setNew(true);
139 pluginSetting.setPrimaryKey(pluginSettingId);
140
141 return pluginSetting;
142 }
143
144 public PluginSetting remove(long pluginSettingId)
145 throws NoSuchPluginSettingException, SystemException {
146 Session session = null;
147
148 try {
149 session = openSession();
150
151 PluginSetting pluginSetting = (PluginSetting)session.get(PluginSettingImpl.class,
152 new Long(pluginSettingId));
153
154 if (pluginSetting == null) {
155 if (_log.isWarnEnabled()) {
156 _log.warn("No PluginSetting exists with the primary key " +
157 pluginSettingId);
158 }
159
160 throw new NoSuchPluginSettingException(
161 "No PluginSetting exists with the primary key " +
162 pluginSettingId);
163 }
164
165 return remove(pluginSetting);
166 }
167 catch (NoSuchPluginSettingException nsee) {
168 throw nsee;
169 }
170 catch (Exception e) {
171 throw processException(e);
172 }
173 finally {
174 closeSession(session);
175 }
176 }
177
178 public PluginSetting remove(PluginSetting pluginSetting)
179 throws SystemException {
180 for (ModelListener<PluginSetting> listener : listeners) {
181 listener.onBeforeRemove(pluginSetting);
182 }
183
184 pluginSetting = removeImpl(pluginSetting);
185
186 for (ModelListener<PluginSetting> listener : listeners) {
187 listener.onAfterRemove(pluginSetting);
188 }
189
190 return pluginSetting;
191 }
192
193 protected PluginSetting removeImpl(PluginSetting pluginSetting)
194 throws SystemException {
195 Session session = null;
196
197 try {
198 session = openSession();
199
200 if (pluginSetting.isCachedModel() || BatchSessionUtil.isEnabled()) {
201 Object staleObject = session.get(PluginSettingImpl.class,
202 pluginSetting.getPrimaryKeyObj());
203
204 if (staleObject != null) {
205 session.evict(staleObject);
206 }
207 }
208
209 session.delete(pluginSetting);
210
211 session.flush();
212 }
213 catch (Exception e) {
214 throw processException(e);
215 }
216 finally {
217 closeSession(session);
218 }
219
220 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
221
222 PluginSettingModelImpl pluginSettingModelImpl = (PluginSettingModelImpl)pluginSetting;
223
224 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_I_T,
225 new Object[] {
226 new Long(pluginSettingModelImpl.getOriginalCompanyId()),
227
228 pluginSettingModelImpl.getOriginalPluginId(),
229
230 pluginSettingModelImpl.getOriginalPluginType()
231 });
232
233 EntityCacheUtil.removeResult(PluginSettingModelImpl.ENTITY_CACHE_ENABLED,
234 PluginSettingImpl.class, pluginSetting.getPrimaryKey());
235
236 return pluginSetting;
237 }
238
239
242 public PluginSetting update(PluginSetting pluginSetting)
243 throws SystemException {
244 if (_log.isWarnEnabled()) {
245 _log.warn(
246 "Using the deprecated update(PluginSetting pluginSetting) method. Use update(PluginSetting pluginSetting, boolean merge) instead.");
247 }
248
249 return update(pluginSetting, false);
250 }
251
252
265 public PluginSetting update(PluginSetting pluginSetting, boolean merge)
266 throws SystemException {
267 boolean isNew = pluginSetting.isNew();
268
269 for (ModelListener<PluginSetting> listener : listeners) {
270 if (isNew) {
271 listener.onBeforeCreate(pluginSetting);
272 }
273 else {
274 listener.onBeforeUpdate(pluginSetting);
275 }
276 }
277
278 pluginSetting = updateImpl(pluginSetting, merge);
279
280 for (ModelListener<PluginSetting> listener : listeners) {
281 if (isNew) {
282 listener.onAfterCreate(pluginSetting);
283 }
284 else {
285 listener.onAfterUpdate(pluginSetting);
286 }
287 }
288
289 return pluginSetting;
290 }
291
292 public PluginSetting updateImpl(
293 com.liferay.portal.model.PluginSetting pluginSetting, boolean merge)
294 throws SystemException {
295 boolean isNew = pluginSetting.isNew();
296
297 PluginSettingModelImpl pluginSettingModelImpl = (PluginSettingModelImpl)pluginSetting;
298
299 Session session = null;
300
301 try {
302 session = openSession();
303
304 BatchSessionUtil.update(session, pluginSetting, merge);
305
306 pluginSetting.setNew(false);
307 }
308 catch (Exception e) {
309 throw processException(e);
310 }
311 finally {
312 closeSession(session);
313 }
314
315 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
316
317 EntityCacheUtil.putResult(PluginSettingModelImpl.ENTITY_CACHE_ENABLED,
318 PluginSettingImpl.class, pluginSetting.getPrimaryKey(),
319 pluginSetting);
320
321 if (!isNew &&
322 ((pluginSetting.getCompanyId() != pluginSettingModelImpl.getOriginalCompanyId()) ||
323 !pluginSetting.getPluginId()
324 .equals(pluginSettingModelImpl.getOriginalPluginId()) ||
325 !pluginSetting.getPluginType()
326 .equals(pluginSettingModelImpl.getOriginalPluginType()))) {
327 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_I_T,
328 new Object[] {
329 new Long(pluginSettingModelImpl.getOriginalCompanyId()),
330
331 pluginSettingModelImpl.getOriginalPluginId(),
332
333 pluginSettingModelImpl.getOriginalPluginType()
334 });
335 }
336
337 if (isNew ||
338 ((pluginSetting.getCompanyId() != pluginSettingModelImpl.getOriginalCompanyId()) ||
339 !pluginSetting.getPluginId()
340 .equals(pluginSettingModelImpl.getOriginalPluginId()) ||
341 !pluginSetting.getPluginType()
342 .equals(pluginSettingModelImpl.getOriginalPluginType()))) {
343 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_I_T,
344 new Object[] {
345 new Long(pluginSetting.getCompanyId()),
346
347 pluginSetting.getPluginId(),
348
349 pluginSetting.getPluginType()
350 }, pluginSetting);
351 }
352
353 return pluginSetting;
354 }
355
356 public PluginSetting findByPrimaryKey(long pluginSettingId)
357 throws NoSuchPluginSettingException, SystemException {
358 PluginSetting pluginSetting = fetchByPrimaryKey(pluginSettingId);
359
360 if (pluginSetting == null) {
361 if (_log.isWarnEnabled()) {
362 _log.warn("No PluginSetting exists with the primary key " +
363 pluginSettingId);
364 }
365
366 throw new NoSuchPluginSettingException(
367 "No PluginSetting exists with the primary key " +
368 pluginSettingId);
369 }
370
371 return pluginSetting;
372 }
373
374 public PluginSetting fetchByPrimaryKey(long pluginSettingId)
375 throws SystemException {
376 PluginSetting pluginSetting = (PluginSetting)EntityCacheUtil.getResult(PluginSettingModelImpl.ENTITY_CACHE_ENABLED,
377 PluginSettingImpl.class, pluginSettingId, this);
378
379 if (pluginSetting == null) {
380 Session session = null;
381
382 try {
383 session = openSession();
384
385 pluginSetting = (PluginSetting)session.get(PluginSettingImpl.class,
386 new Long(pluginSettingId));
387 }
388 catch (Exception e) {
389 throw processException(e);
390 }
391 finally {
392 if (pluginSetting != null) {
393 cacheResult(pluginSetting);
394 }
395
396 closeSession(session);
397 }
398 }
399
400 return pluginSetting;
401 }
402
403 public List<PluginSetting> findByCompanyId(long companyId)
404 throws SystemException {
405 Object[] finderArgs = new Object[] { new Long(companyId) };
406
407 List<PluginSetting> list = (List<PluginSetting>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_COMPANYID,
408 finderArgs, this);
409
410 if (list == null) {
411 Session session = null;
412
413 try {
414 session = openSession();
415
416 StringBuilder query = new StringBuilder();
417
418 query.append(
419 "FROM com.liferay.portal.model.PluginSetting WHERE ");
420
421 query.append("companyId = ?");
422
423 query.append(" ");
424
425 Query q = session.createQuery(query.toString());
426
427 QueryPos qPos = QueryPos.getInstance(q);
428
429 qPos.add(companyId);
430
431 list = q.list();
432 }
433 catch (Exception e) {
434 throw processException(e);
435 }
436 finally {
437 if (list == null) {
438 list = new ArrayList<PluginSetting>();
439 }
440
441 cacheResult(list);
442
443 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_COMPANYID,
444 finderArgs, list);
445
446 closeSession(session);
447 }
448 }
449
450 return list;
451 }
452
453 public List<PluginSetting> findByCompanyId(long companyId, int start,
454 int end) throws SystemException {
455 return findByCompanyId(companyId, start, end, null);
456 }
457
458 public List<PluginSetting> findByCompanyId(long companyId, int start,
459 int end, OrderByComparator obc) throws SystemException {
460 Object[] finderArgs = new Object[] {
461 new Long(companyId),
462
463 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
464 };
465
466 List<PluginSetting> list = (List<PluginSetting>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_COMPANYID,
467 finderArgs, this);
468
469 if (list == null) {
470 Session session = null;
471
472 try {
473 session = openSession();
474
475 StringBuilder query = new StringBuilder();
476
477 query.append(
478 "FROM com.liferay.portal.model.PluginSetting WHERE ");
479
480 query.append("companyId = ?");
481
482 query.append(" ");
483
484 if (obc != null) {
485 query.append("ORDER BY ");
486 query.append(obc.getOrderBy());
487 }
488
489 Query q = session.createQuery(query.toString());
490
491 QueryPos qPos = QueryPos.getInstance(q);
492
493 qPos.add(companyId);
494
495 list = (List<PluginSetting>)QueryUtil.list(q, getDialect(),
496 start, end);
497 }
498 catch (Exception e) {
499 throw processException(e);
500 }
501 finally {
502 if (list == null) {
503 list = new ArrayList<PluginSetting>();
504 }
505
506 cacheResult(list);
507
508 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_COMPANYID,
509 finderArgs, list);
510
511 closeSession(session);
512 }
513 }
514
515 return list;
516 }
517
518 public PluginSetting findByCompanyId_First(long companyId,
519 OrderByComparator obc)
520 throws NoSuchPluginSettingException, SystemException {
521 List<PluginSetting> list = findByCompanyId(companyId, 0, 1, obc);
522
523 if (list.isEmpty()) {
524 StringBuilder msg = new StringBuilder();
525
526 msg.append("No PluginSetting exists with the key {");
527
528 msg.append("companyId=" + companyId);
529
530 msg.append(StringPool.CLOSE_CURLY_BRACE);
531
532 throw new NoSuchPluginSettingException(msg.toString());
533 }
534 else {
535 return list.get(0);
536 }
537 }
538
539 public PluginSetting findByCompanyId_Last(long companyId,
540 OrderByComparator obc)
541 throws NoSuchPluginSettingException, SystemException {
542 int count = countByCompanyId(companyId);
543
544 List<PluginSetting> list = findByCompanyId(companyId, count - 1, count,
545 obc);
546
547 if (list.isEmpty()) {
548 StringBuilder msg = new StringBuilder();
549
550 msg.append("No PluginSetting exists with the key {");
551
552 msg.append("companyId=" + companyId);
553
554 msg.append(StringPool.CLOSE_CURLY_BRACE);
555
556 throw new NoSuchPluginSettingException(msg.toString());
557 }
558 else {
559 return list.get(0);
560 }
561 }
562
563 public PluginSetting[] findByCompanyId_PrevAndNext(long pluginSettingId,
564 long companyId, OrderByComparator obc)
565 throws NoSuchPluginSettingException, SystemException {
566 PluginSetting pluginSetting = findByPrimaryKey(pluginSettingId);
567
568 int count = countByCompanyId(companyId);
569
570 Session session = null;
571
572 try {
573 session = openSession();
574
575 StringBuilder query = new StringBuilder();
576
577 query.append("FROM com.liferay.portal.model.PluginSetting WHERE ");
578
579 query.append("companyId = ?");
580
581 query.append(" ");
582
583 if (obc != null) {
584 query.append("ORDER BY ");
585 query.append(obc.getOrderBy());
586 }
587
588 Query q = session.createQuery(query.toString());
589
590 QueryPos qPos = QueryPos.getInstance(q);
591
592 qPos.add(companyId);
593
594 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
595 pluginSetting);
596
597 PluginSetting[] array = new PluginSettingImpl[3];
598
599 array[0] = (PluginSetting)objArray[0];
600 array[1] = (PluginSetting)objArray[1];
601 array[2] = (PluginSetting)objArray[2];
602
603 return array;
604 }
605 catch (Exception e) {
606 throw processException(e);
607 }
608 finally {
609 closeSession(session);
610 }
611 }
612
613 public PluginSetting findByC_I_T(long companyId, String pluginId,
614 String pluginType) throws NoSuchPluginSettingException, SystemException {
615 PluginSetting pluginSetting = fetchByC_I_T(companyId, pluginId,
616 pluginType);
617
618 if (pluginSetting == null) {
619 StringBuilder msg = new StringBuilder();
620
621 msg.append("No PluginSetting exists with the key {");
622
623 msg.append("companyId=" + companyId);
624
625 msg.append(", ");
626 msg.append("pluginId=" + pluginId);
627
628 msg.append(", ");
629 msg.append("pluginType=" + pluginType);
630
631 msg.append(StringPool.CLOSE_CURLY_BRACE);
632
633 if (_log.isWarnEnabled()) {
634 _log.warn(msg.toString());
635 }
636
637 throw new NoSuchPluginSettingException(msg.toString());
638 }
639
640 return pluginSetting;
641 }
642
643 public PluginSetting fetchByC_I_T(long companyId, String pluginId,
644 String pluginType) throws SystemException {
645 return fetchByC_I_T(companyId, pluginId, pluginType, true);
646 }
647
648 public PluginSetting fetchByC_I_T(long companyId, String pluginId,
649 String pluginType, boolean retrieveFromCache) throws SystemException {
650 Object[] finderArgs = new Object[] {
651 new Long(companyId),
652
653 pluginId,
654
655 pluginType
656 };
657
658 Object result = null;
659
660 if (retrieveFromCache) {
661 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_I_T,
662 finderArgs, this);
663 }
664
665 if (result == null) {
666 Session session = null;
667
668 try {
669 session = openSession();
670
671 StringBuilder query = new StringBuilder();
672
673 query.append(
674 "FROM com.liferay.portal.model.PluginSetting WHERE ");
675
676 query.append("companyId = ?");
677
678 query.append(" AND ");
679
680 if (pluginId == null) {
681 query.append("pluginId IS NULL");
682 }
683 else {
684 query.append("pluginId = ?");
685 }
686
687 query.append(" AND ");
688
689 if (pluginType == null) {
690 query.append("pluginType IS NULL");
691 }
692 else {
693 query.append("pluginType = ?");
694 }
695
696 query.append(" ");
697
698 Query q = session.createQuery(query.toString());
699
700 QueryPos qPos = QueryPos.getInstance(q);
701
702 qPos.add(companyId);
703
704 if (pluginId != null) {
705 qPos.add(pluginId);
706 }
707
708 if (pluginType != null) {
709 qPos.add(pluginType);
710 }
711
712 List<PluginSetting> list = q.list();
713
714 result = list;
715
716 PluginSetting pluginSetting = null;
717
718 if (list.isEmpty()) {
719 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_I_T,
720 finderArgs, list);
721 }
722 else {
723 pluginSetting = list.get(0);
724
725 cacheResult(pluginSetting);
726
727 if ((pluginSetting.getCompanyId() != companyId) ||
728 (pluginSetting.getPluginId() == null) ||
729 !pluginSetting.getPluginId().equals(pluginId) ||
730 (pluginSetting.getPluginType() == null) ||
731 !pluginSetting.getPluginType().equals(pluginType)) {
732 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_I_T,
733 finderArgs, list);
734 }
735 }
736
737 return pluginSetting;
738 }
739 catch (Exception e) {
740 throw processException(e);
741 }
742 finally {
743 if (result == null) {
744 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_I_T,
745 finderArgs, new ArrayList<PluginSetting>());
746 }
747
748 closeSession(session);
749 }
750 }
751 else {
752 if (result instanceof List) {
753 return null;
754 }
755 else {
756 return (PluginSetting)result;
757 }
758 }
759 }
760
761 public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery)
762 throws SystemException {
763 Session session = null;
764
765 try {
766 session = openSession();
767
768 dynamicQuery.compile(session);
769
770 return dynamicQuery.list();
771 }
772 catch (Exception e) {
773 throw processException(e);
774 }
775 finally {
776 closeSession(session);
777 }
778 }
779
780 public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery,
781 int start, int end) throws SystemException {
782 Session session = null;
783
784 try {
785 session = openSession();
786
787 dynamicQuery.setLimit(start, end);
788
789 dynamicQuery.compile(session);
790
791 return dynamicQuery.list();
792 }
793 catch (Exception e) {
794 throw processException(e);
795 }
796 finally {
797 closeSession(session);
798 }
799 }
800
801 public List<PluginSetting> findAll() throws SystemException {
802 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
803 }
804
805 public List<PluginSetting> findAll(int start, int end)
806 throws SystemException {
807 return findAll(start, end, null);
808 }
809
810 public List<PluginSetting> findAll(int start, int end, OrderByComparator obc)
811 throws SystemException {
812 Object[] finderArgs = new Object[] {
813 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
814 };
815
816 List<PluginSetting> list = (List<PluginSetting>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
817 finderArgs, this);
818
819 if (list == null) {
820 Session session = null;
821
822 try {
823 session = openSession();
824
825 StringBuilder query = new StringBuilder();
826
827 query.append("FROM com.liferay.portal.model.PluginSetting ");
828
829 if (obc != null) {
830 query.append("ORDER BY ");
831 query.append(obc.getOrderBy());
832 }
833
834 Query q = session.createQuery(query.toString());
835
836 if (obc == null) {
837 list = (List<PluginSetting>)QueryUtil.list(q, getDialect(),
838 start, end, false);
839
840 Collections.sort(list);
841 }
842 else {
843 list = (List<PluginSetting>)QueryUtil.list(q, getDialect(),
844 start, end);
845 }
846 }
847 catch (Exception e) {
848 throw processException(e);
849 }
850 finally {
851 if (list == null) {
852 list = new ArrayList<PluginSetting>();
853 }
854
855 cacheResult(list);
856
857 FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
858
859 closeSession(session);
860 }
861 }
862
863 return list;
864 }
865
866 public void removeByCompanyId(long companyId) throws SystemException {
867 for (PluginSetting pluginSetting : findByCompanyId(companyId)) {
868 remove(pluginSetting);
869 }
870 }
871
872 public void removeByC_I_T(long companyId, String pluginId, String pluginType)
873 throws NoSuchPluginSettingException, SystemException {
874 PluginSetting pluginSetting = findByC_I_T(companyId, pluginId,
875 pluginType);
876
877 remove(pluginSetting);
878 }
879
880 public void removeAll() throws SystemException {
881 for (PluginSetting pluginSetting : findAll()) {
882 remove(pluginSetting);
883 }
884 }
885
886 public int countByCompanyId(long companyId) throws SystemException {
887 Object[] finderArgs = new Object[] { new Long(companyId) };
888
889 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
890 finderArgs, this);
891
892 if (count == null) {
893 Session session = null;
894
895 try {
896 session = openSession();
897
898 StringBuilder query = new StringBuilder();
899
900 query.append("SELECT COUNT(*) ");
901 query.append(
902 "FROM com.liferay.portal.model.PluginSetting WHERE ");
903
904 query.append("companyId = ?");
905
906 query.append(" ");
907
908 Query q = session.createQuery(query.toString());
909
910 QueryPos qPos = QueryPos.getInstance(q);
911
912 qPos.add(companyId);
913
914 count = (Long)q.uniqueResult();
915 }
916 catch (Exception e) {
917 throw processException(e);
918 }
919 finally {
920 if (count == null) {
921 count = Long.valueOf(0);
922 }
923
924 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
925 finderArgs, count);
926
927 closeSession(session);
928 }
929 }
930
931 return count.intValue();
932 }
933
934 public int countByC_I_T(long companyId, String pluginId, String pluginType)
935 throws SystemException {
936 Object[] finderArgs = new Object[] {
937 new Long(companyId),
938
939 pluginId,
940
941 pluginType
942 };
943
944 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_I_T,
945 finderArgs, this);
946
947 if (count == null) {
948 Session session = null;
949
950 try {
951 session = openSession();
952
953 StringBuilder query = new StringBuilder();
954
955 query.append("SELECT COUNT(*) ");
956 query.append(
957 "FROM com.liferay.portal.model.PluginSetting WHERE ");
958
959 query.append("companyId = ?");
960
961 query.append(" AND ");
962
963 if (pluginId == null) {
964 query.append("pluginId IS NULL");
965 }
966 else {
967 query.append("pluginId = ?");
968 }
969
970 query.append(" AND ");
971
972 if (pluginType == null) {
973 query.append("pluginType IS NULL");
974 }
975 else {
976 query.append("pluginType = ?");
977 }
978
979 query.append(" ");
980
981 Query q = session.createQuery(query.toString());
982
983 QueryPos qPos = QueryPos.getInstance(q);
984
985 qPos.add(companyId);
986
987 if (pluginId != null) {
988 qPos.add(pluginId);
989 }
990
991 if (pluginType != null) {
992 qPos.add(pluginType);
993 }
994
995 count = (Long)q.uniqueResult();
996 }
997 catch (Exception e) {
998 throw processException(e);
999 }
1000 finally {
1001 if (count == null) {
1002 count = Long.valueOf(0);
1003 }
1004
1005 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_I_T,
1006 finderArgs, count);
1007
1008 closeSession(session);
1009 }
1010 }
1011
1012 return count.intValue();
1013 }
1014
1015 public int countAll() throws SystemException {
1016 Object[] finderArgs = new Object[0];
1017
1018 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1019 finderArgs, this);
1020
1021 if (count == null) {
1022 Session session = null;
1023
1024 try {
1025 session = openSession();
1026
1027 Query q = session.createQuery(
1028 "SELECT COUNT(*) FROM com.liferay.portal.model.PluginSetting");
1029
1030 count = (Long)q.uniqueResult();
1031 }
1032 catch (Exception e) {
1033 throw processException(e);
1034 }
1035 finally {
1036 if (count == null) {
1037 count = Long.valueOf(0);
1038 }
1039
1040 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
1041 count);
1042
1043 closeSession(session);
1044 }
1045 }
1046
1047 return count.intValue();
1048 }
1049
1050 public void afterPropertiesSet() {
1051 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1052 com.liferay.portal.util.PropsUtil.get(
1053 "value.object.listener.com.liferay.portal.model.PluginSetting")));
1054
1055 if (listenerClassNames.length > 0) {
1056 try {
1057 List<ModelListener<PluginSetting>> listenersList = new ArrayList<ModelListener<PluginSetting>>();
1058
1059 for (String listenerClassName : listenerClassNames) {
1060 listenersList.add((ModelListener<PluginSetting>)Class.forName(
1061 listenerClassName).newInstance());
1062 }
1063
1064 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1065 }
1066 catch (Exception e) {
1067 _log.error(e);
1068 }
1069 }
1070 }
1071
1072 @BeanReference(name = "com.liferay.portal.service.persistence.AccountPersistence.impl")
1073 protected com.liferay.portal.service.persistence.AccountPersistence accountPersistence;
1074 @BeanReference(name = "com.liferay.portal.service.persistence.AddressPersistence.impl")
1075 protected com.liferay.portal.service.persistence.AddressPersistence addressPersistence;
1076 @BeanReference(name = "com.liferay.portal.service.persistence.BrowserTrackerPersistence.impl")
1077 protected com.liferay.portal.service.persistence.BrowserTrackerPersistence browserTrackerPersistence;
1078 @BeanReference(name = "com.liferay.portal.service.persistence.ClassNamePersistence.impl")
1079 protected com.liferay.portal.service.persistence.ClassNamePersistence classNamePersistence;
1080 @BeanReference(name = "com.liferay.portal.service.persistence.CompanyPersistence.impl")
1081 protected com.liferay.portal.service.persistence.CompanyPersistence companyPersistence;
1082 @BeanReference(name = "com.liferay.portal.service.persistence.ContactPersistence.impl")
1083 protected com.liferay.portal.service.persistence.ContactPersistence contactPersistence;
1084 @BeanReference(name = "com.liferay.portal.service.persistence.CountryPersistence.impl")
1085 protected com.liferay.portal.service.persistence.CountryPersistence countryPersistence;
1086 @BeanReference(name = "com.liferay.portal.service.persistence.EmailAddressPersistence.impl")
1087 protected com.liferay.portal.service.persistence.EmailAddressPersistence emailAddressPersistence;
1088 @BeanReference(name = "com.liferay.portal.service.persistence.GroupPersistence.impl")
1089 protected com.liferay.portal.service.persistence.GroupPersistence groupPersistence;
1090 @BeanReference(name = "com.liferay.portal.service.persistence.ImagePersistence.impl")
1091 protected com.liferay.portal.service.persistence.ImagePersistence imagePersistence;
1092 @BeanReference(name = "com.liferay.portal.service.persistence.LayoutPersistence.impl")
1093 protected com.liferay.portal.service.persistence.LayoutPersistence layoutPersistence;
1094 @BeanReference(name = "com.liferay.portal.service.persistence.LayoutSetPersistence.impl")
1095 protected com.liferay.portal.service.persistence.LayoutSetPersistence layoutSetPersistence;
1096 @BeanReference(name = "com.liferay.portal.service.persistence.ListTypePersistence.impl")
1097 protected com.liferay.portal.service.persistence.ListTypePersistence listTypePersistence;
1098 @BeanReference(name = "com.liferay.portal.service.persistence.MembershipRequestPersistence.impl")
1099 protected com.liferay.portal.service.persistence.MembershipRequestPersistence membershipRequestPersistence;
1100 @BeanReference(name = "com.liferay.portal.service.persistence.OrganizationPersistence.impl")
1101 protected com.liferay.portal.service.persistence.OrganizationPersistence organizationPersistence;
1102 @BeanReference(name = "com.liferay.portal.service.persistence.OrgGroupPermissionPersistence.impl")
1103 protected com.liferay.portal.service.persistence.OrgGroupPermissionPersistence orgGroupPermissionPersistence;
1104 @BeanReference(name = "com.liferay.portal.service.persistence.OrgGroupRolePersistence.impl")
1105 protected com.liferay.portal.service.persistence.OrgGroupRolePersistence orgGroupRolePersistence;
1106 @BeanReference(name = "com.liferay.portal.service.persistence.OrgLaborPersistence.impl")
1107 protected com.liferay.portal.service.persistence.OrgLaborPersistence orgLaborPersistence;
1108 @BeanReference(name = "com.liferay.portal.service.persistence.PasswordPolicyPersistence.impl")
1109 protected com.liferay.portal.service.persistence.PasswordPolicyPersistence passwordPolicyPersistence;
1110 @BeanReference(name = "com.liferay.portal.service.persistence.PasswordPolicyRelPersistence.impl")
1111 protected com.liferay.portal.service.persistence.PasswordPolicyRelPersistence passwordPolicyRelPersistence;
1112 @BeanReference(name = "com.liferay.portal.service.persistence.PasswordTrackerPersistence.impl")
1113 protected com.liferay.portal.service.persistence.PasswordTrackerPersistence passwordTrackerPersistence;
1114 @BeanReference(name = "com.liferay.portal.service.persistence.PermissionPersistence.impl")
1115 protected com.liferay.portal.service.persistence.PermissionPersistence permissionPersistence;
1116 @BeanReference(name = "com.liferay.portal.service.persistence.PhonePersistence.impl")
1117 protected com.liferay.portal.service.persistence.PhonePersistence phonePersistence;
1118 @BeanReference(name = "com.liferay.portal.service.persistence.PluginSettingPersistence.impl")
1119 protected com.liferay.portal.service.persistence.PluginSettingPersistence pluginSettingPersistence;
1120 @BeanReference(name = "com.liferay.portal.service.persistence.PortletPersistence.impl")
1121 protected com.liferay.portal.service.persistence.PortletPersistence portletPersistence;
1122 @BeanReference(name = "com.liferay.portal.service.persistence.PortletItemPersistence.impl")
1123 protected com.liferay.portal.service.persistence.PortletItemPersistence portletItemPersistence;
1124 @BeanReference(name = "com.liferay.portal.service.persistence.PortletPreferencesPersistence.impl")
1125 protected com.liferay.portal.service.persistence.PortletPreferencesPersistence portletPreferencesPersistence;
1126 @BeanReference(name = "com.liferay.portal.service.persistence.RegionPersistence.impl")
1127 protected com.liferay.portal.service.persistence.RegionPersistence regionPersistence;
1128 @BeanReference(name = "com.liferay.portal.service.persistence.ReleasePersistence.impl")
1129 protected com.liferay.portal.service.persistence.ReleasePersistence releasePersistence;
1130 @BeanReference(name = "com.liferay.portal.service.persistence.ResourcePersistence.impl")
1131 protected com.liferay.portal.service.persistence.ResourcePersistence resourcePersistence;
1132 @BeanReference(name = "com.liferay.portal.service.persistence.ResourceActionPersistence.impl")
1133 protected com.liferay.portal.service.persistence.ResourceActionPersistence resourceActionPersistence;
1134 @BeanReference(name = "com.liferay.portal.service.persistence.ResourceCodePersistence.impl")
1135 protected com.liferay.portal.service.persistence.ResourceCodePersistence resourceCodePersistence;
1136 @BeanReference(name = "com.liferay.portal.service.persistence.ResourcePermissionPersistence.impl")
1137 protected com.liferay.portal.service.persistence.ResourcePermissionPersistence resourcePermissionPersistence;
1138 @BeanReference(name = "com.liferay.portal.service.persistence.RolePersistence.impl")
1139 protected com.liferay.portal.service.persistence.RolePersistence rolePersistence;
1140 @BeanReference(name = "com.liferay.portal.service.persistence.ServiceComponentPersistence.impl")
1141 protected com.liferay.portal.service.persistence.ServiceComponentPersistence serviceComponentPersistence;
1142 @BeanReference(name = "com.liferay.portal.service.persistence.ShardPersistence.impl")
1143 protected com.liferay.portal.service.persistence.ShardPersistence shardPersistence;
1144 @BeanReference(name = "com.liferay.portal.service.persistence.SubscriptionPersistence.impl")
1145 protected com.liferay.portal.service.persistence.SubscriptionPersistence subscriptionPersistence;
1146 @BeanReference(name = "com.liferay.portal.service.persistence.UserPersistence.impl")
1147 protected com.liferay.portal.service.persistence.UserPersistence userPersistence;
1148 @BeanReference(name = "com.liferay.portal.service.persistence.UserGroupPersistence.impl")
1149 protected com.liferay.portal.service.persistence.UserGroupPersistence userGroupPersistence;
1150 @BeanReference(name = "com.liferay.portal.service.persistence.UserGroupRolePersistence.impl")
1151 protected com.liferay.portal.service.persistence.UserGroupRolePersistence userGroupRolePersistence;
1152 @BeanReference(name = "com.liferay.portal.service.persistence.UserIdMapperPersistence.impl")
1153 protected com.liferay.portal.service.persistence.UserIdMapperPersistence userIdMapperPersistence;
1154 @BeanReference(name = "com.liferay.portal.service.persistence.UserTrackerPersistence.impl")
1155 protected com.liferay.portal.service.persistence.UserTrackerPersistence userTrackerPersistence;
1156 @BeanReference(name = "com.liferay.portal.service.persistence.UserTrackerPathPersistence.impl")
1157 protected com.liferay.portal.service.persistence.UserTrackerPathPersistence userTrackerPathPersistence;
1158 @BeanReference(name = "com.liferay.portal.service.persistence.WebDAVPropsPersistence.impl")
1159 protected com.liferay.portal.service.persistence.WebDAVPropsPersistence webDAVPropsPersistence;
1160 @BeanReference(name = "com.liferay.portal.service.persistence.WebsitePersistence.impl")
1161 protected com.liferay.portal.service.persistence.WebsitePersistence websitePersistence;
1162 private static Log _log = LogFactoryUtil.getLog(PluginSettingPersistenceImpl.class);
1163}