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