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.bean.InitializingBean;
28 import com.liferay.portal.kernel.dao.orm.DynamicQuery;
29 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
30 import com.liferay.portal.kernel.dao.orm.Query;
31 import com.liferay.portal.kernel.dao.orm.QueryPos;
32 import com.liferay.portal.kernel.dao.orm.QueryUtil;
33 import com.liferay.portal.kernel.dao.orm.Session;
34 import com.liferay.portal.kernel.util.GetterUtil;
35 import com.liferay.portal.kernel.util.ListUtil;
36 import com.liferay.portal.kernel.util.OrderByComparator;
37 import com.liferay.portal.kernel.util.StringPool;
38 import com.liferay.portal.kernel.util.StringUtil;
39 import com.liferay.portal.model.ModelListener;
40 import com.liferay.portal.model.PluginSetting;
41 import com.liferay.portal.model.impl.PluginSettingImpl;
42 import com.liferay.portal.model.impl.PluginSettingModelImpl;
43 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
44
45 import org.apache.commons.logging.Log;
46 import org.apache.commons.logging.LogFactory;
47
48 import java.util.ArrayList;
49 import java.util.Collections;
50 import java.util.Iterator;
51 import java.util.List;
52
53
59 public class PluginSettingPersistenceImpl extends BasePersistenceImpl
60 implements PluginSettingPersistence, InitializingBean {
61 public PluginSetting create(long pluginSettingId) {
62 PluginSetting pluginSetting = new PluginSettingImpl();
63
64 pluginSetting.setNew(true);
65 pluginSetting.setPrimaryKey(pluginSettingId);
66
67 return pluginSetting;
68 }
69
70 public PluginSetting remove(long pluginSettingId)
71 throws NoSuchPluginSettingException, SystemException {
72 Session session = null;
73
74 try {
75 session = openSession();
76
77 PluginSetting pluginSetting = (PluginSetting)session.get(PluginSettingImpl.class,
78 new Long(pluginSettingId));
79
80 if (pluginSetting == null) {
81 if (_log.isWarnEnabled()) {
82 _log.warn("No PluginSetting exists with the primary key " +
83 pluginSettingId);
84 }
85
86 throw new NoSuchPluginSettingException(
87 "No PluginSetting exists with the primary key " +
88 pluginSettingId);
89 }
90
91 return remove(pluginSetting);
92 }
93 catch (NoSuchPluginSettingException nsee) {
94 throw nsee;
95 }
96 catch (Exception e) {
97 throw processException(e);
98 }
99 finally {
100 closeSession(session);
101 }
102 }
103
104 public PluginSetting remove(PluginSetting pluginSetting)
105 throws SystemException {
106 if (_listeners.length > 0) {
107 for (ModelListener listener : _listeners) {
108 listener.onBeforeRemove(pluginSetting);
109 }
110 }
111
112 pluginSetting = removeImpl(pluginSetting);
113
114 if (_listeners.length > 0) {
115 for (ModelListener listener : _listeners) {
116 listener.onAfterRemove(pluginSetting);
117 }
118 }
119
120 return pluginSetting;
121 }
122
123 protected PluginSetting removeImpl(PluginSetting pluginSetting)
124 throws SystemException {
125 Session session = null;
126
127 try {
128 session = openSession();
129
130 session.delete(pluginSetting);
131
132 session.flush();
133
134 return pluginSetting;
135 }
136 catch (Exception e) {
137 throw processException(e);
138 }
139 finally {
140 closeSession(session);
141
142 FinderCacheUtil.clearCache(PluginSetting.class.getName());
143 }
144 }
145
146
149 public PluginSetting update(PluginSetting pluginSetting)
150 throws SystemException {
151 if (_log.isWarnEnabled()) {
152 _log.warn(
153 "Using the deprecated update(PluginSetting pluginSetting) method. Use update(PluginSetting pluginSetting, boolean merge) instead.");
154 }
155
156 return update(pluginSetting, false);
157 }
158
159
172 public PluginSetting update(PluginSetting pluginSetting, boolean merge)
173 throws SystemException {
174 boolean isNew = pluginSetting.isNew();
175
176 if (_listeners.length > 0) {
177 for (ModelListener listener : _listeners) {
178 if (isNew) {
179 listener.onBeforeCreate(pluginSetting);
180 }
181 else {
182 listener.onBeforeUpdate(pluginSetting);
183 }
184 }
185 }
186
187 pluginSetting = updateImpl(pluginSetting, merge);
188
189 if (_listeners.length > 0) {
190 for (ModelListener listener : _listeners) {
191 if (isNew) {
192 listener.onAfterCreate(pluginSetting);
193 }
194 else {
195 listener.onAfterUpdate(pluginSetting);
196 }
197 }
198 }
199
200 return pluginSetting;
201 }
202
203 public PluginSetting updateImpl(
204 com.liferay.portal.model.PluginSetting pluginSetting, boolean merge)
205 throws SystemException {
206 Session session = null;
207
208 try {
209 session = openSession();
210
211 if (merge) {
212 session.merge(pluginSetting);
213 }
214 else {
215 if (pluginSetting.isNew()) {
216 session.save(pluginSetting);
217 }
218 }
219
220 session.flush();
221
222 pluginSetting.setNew(false);
223
224 return pluginSetting;
225 }
226 catch (Exception e) {
227 throw processException(e);
228 }
229 finally {
230 closeSession(session);
231
232 FinderCacheUtil.clearCache(PluginSetting.class.getName());
233 }
234 }
235
236 public PluginSetting findByPrimaryKey(long pluginSettingId)
237 throws NoSuchPluginSettingException, SystemException {
238 PluginSetting pluginSetting = fetchByPrimaryKey(pluginSettingId);
239
240 if (pluginSetting == null) {
241 if (_log.isWarnEnabled()) {
242 _log.warn("No PluginSetting exists with the primary key " +
243 pluginSettingId);
244 }
245
246 throw new NoSuchPluginSettingException(
247 "No PluginSetting exists with the primary key " +
248 pluginSettingId);
249 }
250
251 return pluginSetting;
252 }
253
254 public PluginSetting fetchByPrimaryKey(long pluginSettingId)
255 throws SystemException {
256 Session session = null;
257
258 try {
259 session = openSession();
260
261 return (PluginSetting)session.get(PluginSettingImpl.class,
262 new Long(pluginSettingId));
263 }
264 catch (Exception e) {
265 throw processException(e);
266 }
267 finally {
268 closeSession(session);
269 }
270 }
271
272 public List<PluginSetting> findByCompanyId(long companyId)
273 throws SystemException {
274 boolean finderClassNameCacheEnabled = PluginSettingModelImpl.CACHE_ENABLED;
275 String finderClassName = PluginSetting.class.getName();
276 String finderMethodName = "findByCompanyId";
277 String[] finderParams = new String[] { Long.class.getName() };
278 Object[] finderArgs = new Object[] { new Long(companyId) };
279
280 Object result = null;
281
282 if (finderClassNameCacheEnabled) {
283 result = FinderCacheUtil.getResult(finderClassName,
284 finderMethodName, finderParams, finderArgs, this);
285 }
286
287 if (result == null) {
288 Session session = null;
289
290 try {
291 session = openSession();
292
293 StringBuilder query = new StringBuilder();
294
295 query.append(
296 "FROM com.liferay.portal.model.PluginSetting WHERE ");
297
298 query.append("companyId = ?");
299
300 query.append(" ");
301
302 Query q = session.createQuery(query.toString());
303
304 QueryPos qPos = QueryPos.getInstance(q);
305
306 qPos.add(companyId);
307
308 List<PluginSetting> list = q.list();
309
310 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
311 finderClassName, finderMethodName, finderParams,
312 finderArgs, list);
313
314 return list;
315 }
316 catch (Exception e) {
317 throw processException(e);
318 }
319 finally {
320 closeSession(session);
321 }
322 }
323 else {
324 return (List<PluginSetting>)result;
325 }
326 }
327
328 public List<PluginSetting> findByCompanyId(long companyId, int start,
329 int end) throws SystemException {
330 return findByCompanyId(companyId, start, end, null);
331 }
332
333 public List<PluginSetting> findByCompanyId(long companyId, int start,
334 int end, OrderByComparator obc) throws SystemException {
335 boolean finderClassNameCacheEnabled = PluginSettingModelImpl.CACHE_ENABLED;
336 String finderClassName = PluginSetting.class.getName();
337 String finderMethodName = "findByCompanyId";
338 String[] finderParams = new String[] {
339 Long.class.getName(),
340
341 "java.lang.Integer", "java.lang.Integer",
342 "com.liferay.portal.kernel.util.OrderByComparator"
343 };
344 Object[] finderArgs = new Object[] {
345 new Long(companyId),
346
347 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
348 };
349
350 Object result = null;
351
352 if (finderClassNameCacheEnabled) {
353 result = FinderCacheUtil.getResult(finderClassName,
354 finderMethodName, finderParams, finderArgs, this);
355 }
356
357 if (result == null) {
358 Session session = null;
359
360 try {
361 session = openSession();
362
363 StringBuilder query = new StringBuilder();
364
365 query.append(
366 "FROM com.liferay.portal.model.PluginSetting WHERE ");
367
368 query.append("companyId = ?");
369
370 query.append(" ");
371
372 if (obc != null) {
373 query.append("ORDER BY ");
374 query.append(obc.getOrderBy());
375 }
376
377 Query q = session.createQuery(query.toString());
378
379 QueryPos qPos = QueryPos.getInstance(q);
380
381 qPos.add(companyId);
382
383 List<PluginSetting> list = (List<PluginSetting>)QueryUtil.list(q,
384 getDialect(), start, end);
385
386 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
387 finderClassName, finderMethodName, finderParams,
388 finderArgs, list);
389
390 return list;
391 }
392 catch (Exception e) {
393 throw processException(e);
394 }
395 finally {
396 closeSession(session);
397 }
398 }
399 else {
400 return (List<PluginSetting>)result;
401 }
402 }
403
404 public PluginSetting findByCompanyId_First(long companyId,
405 OrderByComparator obc)
406 throws NoSuchPluginSettingException, SystemException {
407 List<PluginSetting> list = findByCompanyId(companyId, 0, 1, obc);
408
409 if (list.size() == 0) {
410 StringBuilder msg = new StringBuilder();
411
412 msg.append("No PluginSetting exists with the key {");
413
414 msg.append("companyId=" + companyId);
415
416 msg.append(StringPool.CLOSE_CURLY_BRACE);
417
418 throw new NoSuchPluginSettingException(msg.toString());
419 }
420 else {
421 return list.get(0);
422 }
423 }
424
425 public PluginSetting findByCompanyId_Last(long companyId,
426 OrderByComparator obc)
427 throws NoSuchPluginSettingException, SystemException {
428 int count = countByCompanyId(companyId);
429
430 List<PluginSetting> list = findByCompanyId(companyId, count - 1, count,
431 obc);
432
433 if (list.size() == 0) {
434 StringBuilder msg = new StringBuilder();
435
436 msg.append("No PluginSetting exists with the key {");
437
438 msg.append("companyId=" + companyId);
439
440 msg.append(StringPool.CLOSE_CURLY_BRACE);
441
442 throw new NoSuchPluginSettingException(msg.toString());
443 }
444 else {
445 return list.get(0);
446 }
447 }
448
449 public PluginSetting[] findByCompanyId_PrevAndNext(long pluginSettingId,
450 long companyId, OrderByComparator obc)
451 throws NoSuchPluginSettingException, SystemException {
452 PluginSetting pluginSetting = findByPrimaryKey(pluginSettingId);
453
454 int count = countByCompanyId(companyId);
455
456 Session session = null;
457
458 try {
459 session = openSession();
460
461 StringBuilder query = new StringBuilder();
462
463 query.append("FROM com.liferay.portal.model.PluginSetting WHERE ");
464
465 query.append("companyId = ?");
466
467 query.append(" ");
468
469 if (obc != null) {
470 query.append("ORDER BY ");
471 query.append(obc.getOrderBy());
472 }
473
474 Query q = session.createQuery(query.toString());
475
476 QueryPos qPos = QueryPos.getInstance(q);
477
478 qPos.add(companyId);
479
480 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
481 pluginSetting);
482
483 PluginSetting[] array = new PluginSettingImpl[3];
484
485 array[0] = (PluginSetting)objArray[0];
486 array[1] = (PluginSetting)objArray[1];
487 array[2] = (PluginSetting)objArray[2];
488
489 return array;
490 }
491 catch (Exception e) {
492 throw processException(e);
493 }
494 finally {
495 closeSession(session);
496 }
497 }
498
499 public PluginSetting findByC_I_T(long companyId, String pluginId,
500 String pluginType) throws NoSuchPluginSettingException, SystemException {
501 PluginSetting pluginSetting = fetchByC_I_T(companyId, pluginId,
502 pluginType);
503
504 if (pluginSetting == null) {
505 StringBuilder msg = new StringBuilder();
506
507 msg.append("No PluginSetting exists with the key {");
508
509 msg.append("companyId=" + companyId);
510
511 msg.append(", ");
512 msg.append("pluginId=" + pluginId);
513
514 msg.append(", ");
515 msg.append("pluginType=" + pluginType);
516
517 msg.append(StringPool.CLOSE_CURLY_BRACE);
518
519 if (_log.isWarnEnabled()) {
520 _log.warn(msg.toString());
521 }
522
523 throw new NoSuchPluginSettingException(msg.toString());
524 }
525
526 return pluginSetting;
527 }
528
529 public PluginSetting fetchByC_I_T(long companyId, String pluginId,
530 String pluginType) throws SystemException {
531 boolean finderClassNameCacheEnabled = PluginSettingModelImpl.CACHE_ENABLED;
532 String finderClassName = PluginSetting.class.getName();
533 String finderMethodName = "fetchByC_I_T";
534 String[] finderParams = new String[] {
535 Long.class.getName(), String.class.getName(),
536 String.class.getName()
537 };
538 Object[] finderArgs = new Object[] {
539 new Long(companyId),
540
541 pluginId,
542
543 pluginType
544 };
545
546 Object result = null;
547
548 if (finderClassNameCacheEnabled) {
549 result = FinderCacheUtil.getResult(finderClassName,
550 finderMethodName, finderParams, finderArgs, this);
551 }
552
553 if (result == null) {
554 Session session = null;
555
556 try {
557 session = openSession();
558
559 StringBuilder query = new StringBuilder();
560
561 query.append(
562 "FROM com.liferay.portal.model.PluginSetting WHERE ");
563
564 query.append("companyId = ?");
565
566 query.append(" AND ");
567
568 if (pluginId == null) {
569 query.append("pluginId IS NULL");
570 }
571 else {
572 query.append("pluginId = ?");
573 }
574
575 query.append(" AND ");
576
577 if (pluginType == null) {
578 query.append("pluginType IS NULL");
579 }
580 else {
581 query.append("pluginType = ?");
582 }
583
584 query.append(" ");
585
586 Query q = session.createQuery(query.toString());
587
588 QueryPos qPos = QueryPos.getInstance(q);
589
590 qPos.add(companyId);
591
592 if (pluginId != null) {
593 qPos.add(pluginId);
594 }
595
596 if (pluginType != null) {
597 qPos.add(pluginType);
598 }
599
600 List<PluginSetting> list = q.list();
601
602 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
603 finderClassName, finderMethodName, finderParams,
604 finderArgs, list);
605
606 if (list.size() == 0) {
607 return null;
608 }
609 else {
610 return list.get(0);
611 }
612 }
613 catch (Exception e) {
614 throw processException(e);
615 }
616 finally {
617 closeSession(session);
618 }
619 }
620 else {
621 List<PluginSetting> list = (List<PluginSetting>)result;
622
623 if (list.size() == 0) {
624 return null;
625 }
626 else {
627 return list.get(0);
628 }
629 }
630 }
631
632 public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery)
633 throws SystemException {
634 Session session = null;
635
636 try {
637 session = openSession();
638
639 dynamicQuery.compile(session);
640
641 return dynamicQuery.list();
642 }
643 catch (Exception e) {
644 throw processException(e);
645 }
646 finally {
647 closeSession(session);
648 }
649 }
650
651 public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery,
652 int start, int end) throws SystemException {
653 Session session = null;
654
655 try {
656 session = openSession();
657
658 dynamicQuery.setLimit(start, end);
659
660 dynamicQuery.compile(session);
661
662 return dynamicQuery.list();
663 }
664 catch (Exception e) {
665 throw processException(e);
666 }
667 finally {
668 closeSession(session);
669 }
670 }
671
672 public List<PluginSetting> findAll() throws SystemException {
673 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
674 }
675
676 public List<PluginSetting> findAll(int start, int end)
677 throws SystemException {
678 return findAll(start, end, null);
679 }
680
681 public List<PluginSetting> findAll(int start, int end, OrderByComparator obc)
682 throws SystemException {
683 boolean finderClassNameCacheEnabled = PluginSettingModelImpl.CACHE_ENABLED;
684 String finderClassName = PluginSetting.class.getName();
685 String finderMethodName = "findAll";
686 String[] finderParams = new String[] {
687 "java.lang.Integer", "java.lang.Integer",
688 "com.liferay.portal.kernel.util.OrderByComparator"
689 };
690 Object[] finderArgs = new Object[] {
691 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
692 };
693
694 Object result = null;
695
696 if (finderClassNameCacheEnabled) {
697 result = FinderCacheUtil.getResult(finderClassName,
698 finderMethodName, finderParams, finderArgs, this);
699 }
700
701 if (result == null) {
702 Session session = null;
703
704 try {
705 session = openSession();
706
707 StringBuilder query = new StringBuilder();
708
709 query.append("FROM com.liferay.portal.model.PluginSetting ");
710
711 if (obc != null) {
712 query.append("ORDER BY ");
713 query.append(obc.getOrderBy());
714 }
715
716 Query q = session.createQuery(query.toString());
717
718 List<PluginSetting> list = (List<PluginSetting>)QueryUtil.list(q,
719 getDialect(), start, end);
720
721 if (obc == null) {
722 Collections.sort(list);
723 }
724
725 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
726 finderClassName, finderMethodName, finderParams,
727 finderArgs, list);
728
729 return list;
730 }
731 catch (Exception e) {
732 throw processException(e);
733 }
734 finally {
735 closeSession(session);
736 }
737 }
738 else {
739 return (List<PluginSetting>)result;
740 }
741 }
742
743 public void removeByCompanyId(long companyId) throws SystemException {
744 for (PluginSetting pluginSetting : findByCompanyId(companyId)) {
745 remove(pluginSetting);
746 }
747 }
748
749 public void removeByC_I_T(long companyId, String pluginId, String pluginType)
750 throws NoSuchPluginSettingException, SystemException {
751 PluginSetting pluginSetting = findByC_I_T(companyId, pluginId,
752 pluginType);
753
754 remove(pluginSetting);
755 }
756
757 public void removeAll() throws SystemException {
758 for (PluginSetting pluginSetting : findAll()) {
759 remove(pluginSetting);
760 }
761 }
762
763 public int countByCompanyId(long companyId) throws SystemException {
764 boolean finderClassNameCacheEnabled = PluginSettingModelImpl.CACHE_ENABLED;
765 String finderClassName = PluginSetting.class.getName();
766 String finderMethodName = "countByCompanyId";
767 String[] finderParams = new String[] { Long.class.getName() };
768 Object[] finderArgs = new Object[] { new Long(companyId) };
769
770 Object result = null;
771
772 if (finderClassNameCacheEnabled) {
773 result = FinderCacheUtil.getResult(finderClassName,
774 finderMethodName, finderParams, finderArgs, this);
775 }
776
777 if (result == null) {
778 Session session = null;
779
780 try {
781 session = openSession();
782
783 StringBuilder query = new StringBuilder();
784
785 query.append("SELECT COUNT(*) ");
786 query.append(
787 "FROM com.liferay.portal.model.PluginSetting WHERE ");
788
789 query.append("companyId = ?");
790
791 query.append(" ");
792
793 Query q = session.createQuery(query.toString());
794
795 QueryPos qPos = QueryPos.getInstance(q);
796
797 qPos.add(companyId);
798
799 Long count = null;
800
801 Iterator<Long> itr = q.list().iterator();
802
803 if (itr.hasNext()) {
804 count = itr.next();
805 }
806
807 if (count == null) {
808 count = new Long(0);
809 }
810
811 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
812 finderClassName, finderMethodName, finderParams,
813 finderArgs, count);
814
815 return count.intValue();
816 }
817 catch (Exception e) {
818 throw processException(e);
819 }
820 finally {
821 closeSession(session);
822 }
823 }
824 else {
825 return ((Long)result).intValue();
826 }
827 }
828
829 public int countByC_I_T(long companyId, String pluginId, String pluginType)
830 throws SystemException {
831 boolean finderClassNameCacheEnabled = PluginSettingModelImpl.CACHE_ENABLED;
832 String finderClassName = PluginSetting.class.getName();
833 String finderMethodName = "countByC_I_T";
834 String[] finderParams = new String[] {
835 Long.class.getName(), String.class.getName(),
836 String.class.getName()
837 };
838 Object[] finderArgs = new Object[] {
839 new Long(companyId),
840
841 pluginId,
842
843 pluginType
844 };
845
846 Object result = null;
847
848 if (finderClassNameCacheEnabled) {
849 result = FinderCacheUtil.getResult(finderClassName,
850 finderMethodName, finderParams, finderArgs, this);
851 }
852
853 if (result == null) {
854 Session session = null;
855
856 try {
857 session = openSession();
858
859 StringBuilder query = new StringBuilder();
860
861 query.append("SELECT COUNT(*) ");
862 query.append(
863 "FROM com.liferay.portal.model.PluginSetting WHERE ");
864
865 query.append("companyId = ?");
866
867 query.append(" AND ");
868
869 if (pluginId == null) {
870 query.append("pluginId IS NULL");
871 }
872 else {
873 query.append("pluginId = ?");
874 }
875
876 query.append(" AND ");
877
878 if (pluginType == null) {
879 query.append("pluginType IS NULL");
880 }
881 else {
882 query.append("pluginType = ?");
883 }
884
885 query.append(" ");
886
887 Query q = session.createQuery(query.toString());
888
889 QueryPos qPos = QueryPos.getInstance(q);
890
891 qPos.add(companyId);
892
893 if (pluginId != null) {
894 qPos.add(pluginId);
895 }
896
897 if (pluginType != null) {
898 qPos.add(pluginType);
899 }
900
901 Long count = null;
902
903 Iterator<Long> itr = q.list().iterator();
904
905 if (itr.hasNext()) {
906 count = itr.next();
907 }
908
909 if (count == null) {
910 count = new Long(0);
911 }
912
913 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
914 finderClassName, finderMethodName, finderParams,
915 finderArgs, count);
916
917 return count.intValue();
918 }
919 catch (Exception e) {
920 throw processException(e);
921 }
922 finally {
923 closeSession(session);
924 }
925 }
926 else {
927 return ((Long)result).intValue();
928 }
929 }
930
931 public int countAll() throws SystemException {
932 boolean finderClassNameCacheEnabled = PluginSettingModelImpl.CACHE_ENABLED;
933 String finderClassName = PluginSetting.class.getName();
934 String finderMethodName = "countAll";
935 String[] finderParams = new String[] { };
936 Object[] finderArgs = new Object[] { };
937
938 Object result = null;
939
940 if (finderClassNameCacheEnabled) {
941 result = FinderCacheUtil.getResult(finderClassName,
942 finderMethodName, finderParams, finderArgs, this);
943 }
944
945 if (result == null) {
946 Session session = null;
947
948 try {
949 session = openSession();
950
951 Query q = session.createQuery(
952 "SELECT COUNT(*) FROM com.liferay.portal.model.PluginSetting");
953
954 Long count = null;
955
956 Iterator<Long> itr = q.list().iterator();
957
958 if (itr.hasNext()) {
959 count = itr.next();
960 }
961
962 if (count == null) {
963 count = new Long(0);
964 }
965
966 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
967 finderClassName, finderMethodName, finderParams,
968 finderArgs, count);
969
970 return count.intValue();
971 }
972 catch (Exception e) {
973 throw processException(e);
974 }
975 finally {
976 closeSession(session);
977 }
978 }
979 else {
980 return ((Long)result).intValue();
981 }
982 }
983
984 public void registerListener(ModelListener listener) {
985 List<ModelListener> listeners = ListUtil.fromArray(_listeners);
986
987 listeners.add(listener);
988
989 _listeners = listeners.toArray(new ModelListener[listeners.size()]);
990 }
991
992 public void unregisterListener(ModelListener listener) {
993 List<ModelListener> listeners = ListUtil.fromArray(_listeners);
994
995 listeners.remove(listener);
996
997 _listeners = listeners.toArray(new ModelListener[listeners.size()]);
998 }
999
1000 public void afterPropertiesSet() {
1001 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1002 com.liferay.portal.util.PropsUtil.get(
1003 "value.object.listener.com.liferay.portal.model.PluginSetting")));
1004
1005 if (listenerClassNames.length > 0) {
1006 try {
1007 List<ModelListener> listeners = new ArrayList<ModelListener>();
1008
1009 for (String listenerClassName : listenerClassNames) {
1010 listeners.add((ModelListener)Class.forName(
1011 listenerClassName).newInstance());
1012 }
1013
1014 _listeners = listeners.toArray(new ModelListener[listeners.size()]);
1015 }
1016 catch (Exception e) {
1017 _log.error(e);
1018 }
1019 }
1020 }
1021
1022 private static Log _log = LogFactory.getLog(PluginSettingPersistenceImpl.class);
1023 private ModelListener[] _listeners = new ModelListener[0];
1024}