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