001
014
015 package com.liferay.portal.service.persistence;
016
017 import com.liferay.portal.NoSuchCompanyException;
018 import com.liferay.portal.NoSuchModelException;
019 import com.liferay.portal.kernel.bean.BeanReference;
020 import com.liferay.portal.kernel.cache.CacheRegistryUtil;
021 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
022 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
023 import com.liferay.portal.kernel.dao.orm.FinderPath;
024 import com.liferay.portal.kernel.dao.orm.Query;
025 import com.liferay.portal.kernel.dao.orm.QueryPos;
026 import com.liferay.portal.kernel.dao.orm.QueryUtil;
027 import com.liferay.portal.kernel.dao.orm.Session;
028 import com.liferay.portal.kernel.exception.SystemException;
029 import com.liferay.portal.kernel.log.Log;
030 import com.liferay.portal.kernel.log.LogFactoryUtil;
031 import com.liferay.portal.kernel.util.GetterUtil;
032 import com.liferay.portal.kernel.util.InstanceFactory;
033 import com.liferay.portal.kernel.util.OrderByComparator;
034 import com.liferay.portal.kernel.util.StringBundler;
035 import com.liferay.portal.kernel.util.StringPool;
036 import com.liferay.portal.kernel.util.StringUtil;
037 import com.liferay.portal.kernel.util.Validator;
038 import com.liferay.portal.model.CacheModel;
039 import com.liferay.portal.model.Company;
040 import com.liferay.portal.model.ModelListener;
041 import com.liferay.portal.model.impl.CompanyImpl;
042 import com.liferay.portal.model.impl.CompanyModelImpl;
043 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
044
045 import java.io.Serializable;
046
047 import java.util.ArrayList;
048 import java.util.Collections;
049 import java.util.List;
050
051
063 public class CompanyPersistenceImpl extends BasePersistenceImpl<Company>
064 implements CompanyPersistence {
065
070 public static final String FINDER_CLASS_NAME_ENTITY = CompanyImpl.class.getName();
071 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
072 ".List1";
073 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
074 ".List2";
075 public static final FinderPath FINDER_PATH_FETCH_BY_WEBID = new FinderPath(CompanyModelImpl.ENTITY_CACHE_ENABLED,
076 CompanyModelImpl.FINDER_CACHE_ENABLED, CompanyImpl.class,
077 FINDER_CLASS_NAME_ENTITY, "fetchByWebId",
078 new String[] { String.class.getName() },
079 CompanyModelImpl.WEBID_COLUMN_BITMASK);
080 public static final FinderPath FINDER_PATH_COUNT_BY_WEBID = new FinderPath(CompanyModelImpl.ENTITY_CACHE_ENABLED,
081 CompanyModelImpl.FINDER_CACHE_ENABLED, Long.class,
082 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByWebId",
083 new String[] { String.class.getName() });
084 public static final FinderPath FINDER_PATH_FETCH_BY_MX = new FinderPath(CompanyModelImpl.ENTITY_CACHE_ENABLED,
085 CompanyModelImpl.FINDER_CACHE_ENABLED, CompanyImpl.class,
086 FINDER_CLASS_NAME_ENTITY, "fetchByMx",
087 new String[] { String.class.getName() },
088 CompanyModelImpl.MX_COLUMN_BITMASK);
089 public static final FinderPath FINDER_PATH_COUNT_BY_MX = new FinderPath(CompanyModelImpl.ENTITY_CACHE_ENABLED,
090 CompanyModelImpl.FINDER_CACHE_ENABLED, Long.class,
091 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByMx",
092 new String[] { String.class.getName() });
093 public static final FinderPath FINDER_PATH_FETCH_BY_LOGOID = new FinderPath(CompanyModelImpl.ENTITY_CACHE_ENABLED,
094 CompanyModelImpl.FINDER_CACHE_ENABLED, CompanyImpl.class,
095 FINDER_CLASS_NAME_ENTITY, "fetchByLogoId",
096 new String[] { Long.class.getName() },
097 CompanyModelImpl.LOGOID_COLUMN_BITMASK);
098 public static final FinderPath FINDER_PATH_COUNT_BY_LOGOID = new FinderPath(CompanyModelImpl.ENTITY_CACHE_ENABLED,
099 CompanyModelImpl.FINDER_CACHE_ENABLED, Long.class,
100 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByLogoId",
101 new String[] { Long.class.getName() });
102 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_SYSTEM = new FinderPath(CompanyModelImpl.ENTITY_CACHE_ENABLED,
103 CompanyModelImpl.FINDER_CACHE_ENABLED, CompanyImpl.class,
104 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findBySystem",
105 new String[] {
106 Boolean.class.getName(),
107
108 "java.lang.Integer", "java.lang.Integer",
109 "com.liferay.portal.kernel.util.OrderByComparator"
110 });
111 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SYSTEM =
112 new FinderPath(CompanyModelImpl.ENTITY_CACHE_ENABLED,
113 CompanyModelImpl.FINDER_CACHE_ENABLED, CompanyImpl.class,
114 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findBySystem",
115 new String[] { Boolean.class.getName() },
116 CompanyModelImpl.SYSTEM_COLUMN_BITMASK);
117 public static final FinderPath FINDER_PATH_COUNT_BY_SYSTEM = new FinderPath(CompanyModelImpl.ENTITY_CACHE_ENABLED,
118 CompanyModelImpl.FINDER_CACHE_ENABLED, Long.class,
119 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countBySystem",
120 new String[] { Boolean.class.getName() });
121 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(CompanyModelImpl.ENTITY_CACHE_ENABLED,
122 CompanyModelImpl.FINDER_CACHE_ENABLED, CompanyImpl.class,
123 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
124 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(CompanyModelImpl.ENTITY_CACHE_ENABLED,
125 CompanyModelImpl.FINDER_CACHE_ENABLED, CompanyImpl.class,
126 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
127 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(CompanyModelImpl.ENTITY_CACHE_ENABLED,
128 CompanyModelImpl.FINDER_CACHE_ENABLED, Long.class,
129 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
130
131
136 public void cacheResult(Company company) {
137 EntityCacheUtil.putResult(CompanyModelImpl.ENTITY_CACHE_ENABLED,
138 CompanyImpl.class, company.getPrimaryKey(), company);
139
140 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_WEBID,
141 new Object[] { company.getWebId() }, company);
142
143 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_MX,
144 new Object[] { company.getMx() }, company);
145
146 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_LOGOID,
147 new Object[] { Long.valueOf(company.getLogoId()) }, company);
148
149 company.resetOriginalValues();
150 }
151
152
157 public void cacheResult(List<Company> companies) {
158 for (Company company : companies) {
159 if (EntityCacheUtil.getResult(
160 CompanyModelImpl.ENTITY_CACHE_ENABLED,
161 CompanyImpl.class, company.getPrimaryKey()) == null) {
162 cacheResult(company);
163 }
164 else {
165 company.resetOriginalValues();
166 }
167 }
168 }
169
170
177 @Override
178 public void clearCache() {
179 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
180 CacheRegistryUtil.clear(CompanyImpl.class.getName());
181 }
182
183 EntityCacheUtil.clearCache(CompanyImpl.class.getName());
184
185 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
186 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
187 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
188 }
189
190
197 @Override
198 public void clearCache(Company company) {
199 EntityCacheUtil.removeResult(CompanyModelImpl.ENTITY_CACHE_ENABLED,
200 CompanyImpl.class, company.getPrimaryKey());
201
202 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
203 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
204
205 clearUniqueFindersCache(company);
206 }
207
208 @Override
209 public void clearCache(List<Company> companies) {
210 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
211 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
212
213 for (Company company : companies) {
214 EntityCacheUtil.removeResult(CompanyModelImpl.ENTITY_CACHE_ENABLED,
215 CompanyImpl.class, company.getPrimaryKey());
216
217 clearUniqueFindersCache(company);
218 }
219 }
220
221 protected void cacheUniqueFindersCache(Company company) {
222 if (company.isNew()) {
223 Object[] args = new Object[] { company.getWebId() };
224
225 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_WEBID, args,
226 Long.valueOf(1));
227 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_WEBID, args, company);
228
229 args = new Object[] { company.getMx() };
230
231 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_MX, args,
232 Long.valueOf(1));
233 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_MX, args, company);
234
235 args = new Object[] { Long.valueOf(company.getLogoId()) };
236
237 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_LOGOID, args,
238 Long.valueOf(1));
239 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_LOGOID, args, company);
240 }
241 else {
242 CompanyModelImpl companyModelImpl = (CompanyModelImpl)company;
243
244 if ((companyModelImpl.getColumnBitmask() &
245 FINDER_PATH_FETCH_BY_WEBID.getColumnBitmask()) != 0) {
246 Object[] args = new Object[] { company.getWebId() };
247
248 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_WEBID, args,
249 Long.valueOf(1));
250 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_WEBID, args,
251 company);
252 }
253
254 if ((companyModelImpl.getColumnBitmask() &
255 FINDER_PATH_FETCH_BY_MX.getColumnBitmask()) != 0) {
256 Object[] args = new Object[] { company.getMx() };
257
258 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_MX, args,
259 Long.valueOf(1));
260 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_MX, args, company);
261 }
262
263 if ((companyModelImpl.getColumnBitmask() &
264 FINDER_PATH_FETCH_BY_LOGOID.getColumnBitmask()) != 0) {
265 Object[] args = new Object[] { Long.valueOf(company.getLogoId()) };
266
267 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_LOGOID, args,
268 Long.valueOf(1));
269 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_LOGOID, args,
270 company);
271 }
272 }
273 }
274
275 protected void clearUniqueFindersCache(Company company) {
276 CompanyModelImpl companyModelImpl = (CompanyModelImpl)company;
277
278 Object[] args = new Object[] { company.getWebId() };
279
280 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_WEBID, args);
281 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_WEBID, args);
282
283 if ((companyModelImpl.getColumnBitmask() &
284 FINDER_PATH_FETCH_BY_WEBID.getColumnBitmask()) != 0) {
285 args = new Object[] { companyModelImpl.getOriginalWebId() };
286
287 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_WEBID, args);
288 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_WEBID, args);
289 }
290
291 args = new Object[] { company.getMx() };
292
293 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_MX, args);
294 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_MX, args);
295
296 if ((companyModelImpl.getColumnBitmask() &
297 FINDER_PATH_FETCH_BY_MX.getColumnBitmask()) != 0) {
298 args = new Object[] { companyModelImpl.getOriginalMx() };
299
300 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_MX, args);
301 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_MX, args);
302 }
303
304 args = new Object[] { Long.valueOf(company.getLogoId()) };
305
306 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_LOGOID, args);
307 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_LOGOID, args);
308
309 if ((companyModelImpl.getColumnBitmask() &
310 FINDER_PATH_FETCH_BY_LOGOID.getColumnBitmask()) != 0) {
311 args = new Object[] {
312 Long.valueOf(companyModelImpl.getOriginalLogoId())
313 };
314
315 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_LOGOID, args);
316 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_LOGOID, args);
317 }
318 }
319
320
326 public Company create(long companyId) {
327 Company company = new CompanyImpl();
328
329 company.setNew(true);
330 company.setPrimaryKey(companyId);
331
332 return company;
333 }
334
335
343 public Company remove(long companyId)
344 throws NoSuchCompanyException, SystemException {
345 return remove(Long.valueOf(companyId));
346 }
347
348
356 @Override
357 public Company remove(Serializable primaryKey)
358 throws NoSuchCompanyException, SystemException {
359 Session session = null;
360
361 try {
362 session = openSession();
363
364 Company company = (Company)session.get(CompanyImpl.class, primaryKey);
365
366 if (company == null) {
367 if (_log.isWarnEnabled()) {
368 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
369 }
370
371 throw new NoSuchCompanyException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
372 primaryKey);
373 }
374
375 return remove(company);
376 }
377 catch (NoSuchCompanyException nsee) {
378 throw nsee;
379 }
380 catch (Exception e) {
381 throw processException(e);
382 }
383 finally {
384 closeSession(session);
385 }
386 }
387
388 @Override
389 protected Company removeImpl(Company company) throws SystemException {
390 company = toUnwrappedModel(company);
391
392 Session session = null;
393
394 try {
395 session = openSession();
396
397 BatchSessionUtil.delete(session, company);
398 }
399 catch (Exception e) {
400 throw processException(e);
401 }
402 finally {
403 closeSession(session);
404 }
405
406 clearCache(company);
407
408 return company;
409 }
410
411 @Override
412 public Company updateImpl(com.liferay.portal.model.Company company,
413 boolean merge) throws SystemException {
414 company = toUnwrappedModel(company);
415
416 boolean isNew = company.isNew();
417
418 CompanyModelImpl companyModelImpl = (CompanyModelImpl)company;
419
420 Session session = null;
421
422 try {
423 session = openSession();
424
425 BatchSessionUtil.update(session, company, merge);
426
427 company.setNew(false);
428 }
429 catch (Exception e) {
430 throw processException(e);
431 }
432 finally {
433 closeSession(session);
434 }
435
436 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
437
438 if (isNew || !CompanyModelImpl.COLUMN_BITMASK_ENABLED) {
439 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
440 }
441
442 else {
443 if ((companyModelImpl.getColumnBitmask() &
444 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SYSTEM.getColumnBitmask()) != 0) {
445 Object[] args = new Object[] {
446 Boolean.valueOf(companyModelImpl.getOriginalSystem())
447 };
448
449 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_SYSTEM, args);
450 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SYSTEM,
451 args);
452
453 args = new Object[] {
454 Boolean.valueOf(companyModelImpl.getSystem())
455 };
456
457 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_SYSTEM, args);
458 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SYSTEM,
459 args);
460 }
461 }
462
463 EntityCacheUtil.putResult(CompanyModelImpl.ENTITY_CACHE_ENABLED,
464 CompanyImpl.class, company.getPrimaryKey(), company);
465
466 clearUniqueFindersCache(company);
467 cacheUniqueFindersCache(company);
468
469 return company;
470 }
471
472 protected Company toUnwrappedModel(Company company) {
473 if (company instanceof CompanyImpl) {
474 return company;
475 }
476
477 CompanyImpl companyImpl = new CompanyImpl();
478
479 companyImpl.setNew(company.isNew());
480 companyImpl.setPrimaryKey(company.getPrimaryKey());
481
482 companyImpl.setCompanyId(company.getCompanyId());
483 companyImpl.setAccountId(company.getAccountId());
484 companyImpl.setWebId(company.getWebId());
485 companyImpl.setKey(company.getKey());
486 companyImpl.setMx(company.getMx());
487 companyImpl.setHomeURL(company.getHomeURL());
488 companyImpl.setLogoId(company.getLogoId());
489 companyImpl.setSystem(company.isSystem());
490 companyImpl.setMaxUsers(company.getMaxUsers());
491 companyImpl.setActive(company.isActive());
492
493 return companyImpl;
494 }
495
496
504 @Override
505 public Company findByPrimaryKey(Serializable primaryKey)
506 throws NoSuchModelException, SystemException {
507 return findByPrimaryKey(((Long)primaryKey).longValue());
508 }
509
510
518 public Company findByPrimaryKey(long companyId)
519 throws NoSuchCompanyException, SystemException {
520 Company company = fetchByPrimaryKey(companyId);
521
522 if (company == null) {
523 if (_log.isWarnEnabled()) {
524 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + companyId);
525 }
526
527 throw new NoSuchCompanyException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
528 companyId);
529 }
530
531 return company;
532 }
533
534
541 @Override
542 public Company fetchByPrimaryKey(Serializable primaryKey)
543 throws SystemException {
544 return fetchByPrimaryKey(((Long)primaryKey).longValue());
545 }
546
547
554 public Company fetchByPrimaryKey(long companyId) throws SystemException {
555 Company company = (Company)EntityCacheUtil.getResult(CompanyModelImpl.ENTITY_CACHE_ENABLED,
556 CompanyImpl.class, companyId);
557
558 if (company == _nullCompany) {
559 return null;
560 }
561
562 if (company == null) {
563 Session session = null;
564
565 boolean hasException = false;
566
567 try {
568 session = openSession();
569
570 company = (Company)session.get(CompanyImpl.class,
571 Long.valueOf(companyId));
572 }
573 catch (Exception e) {
574 hasException = true;
575
576 throw processException(e);
577 }
578 finally {
579 if (company != null) {
580 cacheResult(company);
581 }
582 else if (!hasException) {
583 EntityCacheUtil.putResult(CompanyModelImpl.ENTITY_CACHE_ENABLED,
584 CompanyImpl.class, companyId, _nullCompany);
585 }
586
587 closeSession(session);
588 }
589 }
590
591 return company;
592 }
593
594
602 public Company findByWebId(String webId)
603 throws NoSuchCompanyException, SystemException {
604 Company company = fetchByWebId(webId);
605
606 if (company == null) {
607 StringBundler msg = new StringBundler(4);
608
609 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
610
611 msg.append("webId=");
612 msg.append(webId);
613
614 msg.append(StringPool.CLOSE_CURLY_BRACE);
615
616 if (_log.isWarnEnabled()) {
617 _log.warn(msg.toString());
618 }
619
620 throw new NoSuchCompanyException(msg.toString());
621 }
622
623 return company;
624 }
625
626
633 public Company fetchByWebId(String webId) throws SystemException {
634 return fetchByWebId(webId, true);
635 }
636
637
645 public Company fetchByWebId(String webId, boolean retrieveFromCache)
646 throws SystemException {
647 Object[] finderArgs = new Object[] { webId };
648
649 Object result = null;
650
651 if (retrieveFromCache) {
652 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_WEBID,
653 finderArgs, this);
654 }
655
656 if (result instanceof Company) {
657 Company company = (Company)result;
658
659 if (!Validator.equals(webId, company.getWebId())) {
660 result = null;
661 }
662 }
663
664 if (result == null) {
665 StringBundler query = new StringBundler(2);
666
667 query.append(_SQL_SELECT_COMPANY_WHERE);
668
669 if (webId == null) {
670 query.append(_FINDER_COLUMN_WEBID_WEBID_1);
671 }
672 else {
673 if (webId.equals(StringPool.BLANK)) {
674 query.append(_FINDER_COLUMN_WEBID_WEBID_3);
675 }
676 else {
677 query.append(_FINDER_COLUMN_WEBID_WEBID_2);
678 }
679 }
680
681 String sql = query.toString();
682
683 Session session = null;
684
685 try {
686 session = openSession();
687
688 Query q = session.createQuery(sql);
689
690 QueryPos qPos = QueryPos.getInstance(q);
691
692 if (webId != null) {
693 qPos.add(webId);
694 }
695
696 List<Company> list = q.list();
697
698 result = list;
699
700 Company company = null;
701
702 if (list.isEmpty()) {
703 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_WEBID,
704 finderArgs, list);
705 }
706 else {
707 company = list.get(0);
708
709 cacheResult(company);
710
711 if ((company.getWebId() == null) ||
712 !company.getWebId().equals(webId)) {
713 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_WEBID,
714 finderArgs, company);
715 }
716 }
717
718 return company;
719 }
720 catch (Exception e) {
721 throw processException(e);
722 }
723 finally {
724 if (result == null) {
725 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_WEBID,
726 finderArgs);
727 }
728
729 closeSession(session);
730 }
731 }
732 else {
733 if (result instanceof List<?>) {
734 return null;
735 }
736 else {
737 return (Company)result;
738 }
739 }
740 }
741
742
750 public Company findByMx(String mx)
751 throws NoSuchCompanyException, SystemException {
752 Company company = fetchByMx(mx);
753
754 if (company == null) {
755 StringBundler msg = new StringBundler(4);
756
757 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
758
759 msg.append("mx=");
760 msg.append(mx);
761
762 msg.append(StringPool.CLOSE_CURLY_BRACE);
763
764 if (_log.isWarnEnabled()) {
765 _log.warn(msg.toString());
766 }
767
768 throw new NoSuchCompanyException(msg.toString());
769 }
770
771 return company;
772 }
773
774
781 public Company fetchByMx(String mx) throws SystemException {
782 return fetchByMx(mx, true);
783 }
784
785
793 public Company fetchByMx(String mx, boolean retrieveFromCache)
794 throws SystemException {
795 Object[] finderArgs = new Object[] { mx };
796
797 Object result = null;
798
799 if (retrieveFromCache) {
800 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_MX,
801 finderArgs, this);
802 }
803
804 if (result instanceof Company) {
805 Company company = (Company)result;
806
807 if (!Validator.equals(mx, company.getMx())) {
808 result = null;
809 }
810 }
811
812 if (result == null) {
813 StringBundler query = new StringBundler(2);
814
815 query.append(_SQL_SELECT_COMPANY_WHERE);
816
817 if (mx == null) {
818 query.append(_FINDER_COLUMN_MX_MX_1);
819 }
820 else {
821 if (mx.equals(StringPool.BLANK)) {
822 query.append(_FINDER_COLUMN_MX_MX_3);
823 }
824 else {
825 query.append(_FINDER_COLUMN_MX_MX_2);
826 }
827 }
828
829 String sql = query.toString();
830
831 Session session = null;
832
833 try {
834 session = openSession();
835
836 Query q = session.createQuery(sql);
837
838 QueryPos qPos = QueryPos.getInstance(q);
839
840 if (mx != null) {
841 qPos.add(mx);
842 }
843
844 List<Company> list = q.list();
845
846 result = list;
847
848 Company company = null;
849
850 if (list.isEmpty()) {
851 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_MX,
852 finderArgs, list);
853 }
854 else {
855 company = list.get(0);
856
857 cacheResult(company);
858
859 if ((company.getMx() == null) ||
860 !company.getMx().equals(mx)) {
861 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_MX,
862 finderArgs, company);
863 }
864 }
865
866 return company;
867 }
868 catch (Exception e) {
869 throw processException(e);
870 }
871 finally {
872 if (result == null) {
873 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_MX,
874 finderArgs);
875 }
876
877 closeSession(session);
878 }
879 }
880 else {
881 if (result instanceof List<?>) {
882 return null;
883 }
884 else {
885 return (Company)result;
886 }
887 }
888 }
889
890
898 public Company findByLogoId(long logoId)
899 throws NoSuchCompanyException, SystemException {
900 Company company = fetchByLogoId(logoId);
901
902 if (company == null) {
903 StringBundler msg = new StringBundler(4);
904
905 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
906
907 msg.append("logoId=");
908 msg.append(logoId);
909
910 msg.append(StringPool.CLOSE_CURLY_BRACE);
911
912 if (_log.isWarnEnabled()) {
913 _log.warn(msg.toString());
914 }
915
916 throw new NoSuchCompanyException(msg.toString());
917 }
918
919 return company;
920 }
921
922
929 public Company fetchByLogoId(long logoId) throws SystemException {
930 return fetchByLogoId(logoId, true);
931 }
932
933
941 public Company fetchByLogoId(long logoId, boolean retrieveFromCache)
942 throws SystemException {
943 Object[] finderArgs = new Object[] { logoId };
944
945 Object result = null;
946
947 if (retrieveFromCache) {
948 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_LOGOID,
949 finderArgs, this);
950 }
951
952 if (result instanceof Company) {
953 Company company = (Company)result;
954
955 if ((logoId != company.getLogoId())) {
956 result = null;
957 }
958 }
959
960 if (result == null) {
961 StringBundler query = new StringBundler(2);
962
963 query.append(_SQL_SELECT_COMPANY_WHERE);
964
965 query.append(_FINDER_COLUMN_LOGOID_LOGOID_2);
966
967 String sql = query.toString();
968
969 Session session = null;
970
971 try {
972 session = openSession();
973
974 Query q = session.createQuery(sql);
975
976 QueryPos qPos = QueryPos.getInstance(q);
977
978 qPos.add(logoId);
979
980 List<Company> list = q.list();
981
982 result = list;
983
984 Company company = null;
985
986 if (list.isEmpty()) {
987 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_LOGOID,
988 finderArgs, list);
989 }
990 else {
991 company = list.get(0);
992
993 cacheResult(company);
994
995 if ((company.getLogoId() != logoId)) {
996 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_LOGOID,
997 finderArgs, company);
998 }
999 }
1000
1001 return company;
1002 }
1003 catch (Exception e) {
1004 throw processException(e);
1005 }
1006 finally {
1007 if (result == null) {
1008 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_LOGOID,
1009 finderArgs);
1010 }
1011
1012 closeSession(session);
1013 }
1014 }
1015 else {
1016 if (result instanceof List<?>) {
1017 return null;
1018 }
1019 else {
1020 return (Company)result;
1021 }
1022 }
1023 }
1024
1025
1032 public List<Company> findBySystem(boolean system) throws SystemException {
1033 return findBySystem(system, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1034 }
1035
1036
1049 public List<Company> findBySystem(boolean system, int start, int end)
1050 throws SystemException {
1051 return findBySystem(system, start, end, null);
1052 }
1053
1054
1068 public List<Company> findBySystem(boolean system, int start, int end,
1069 OrderByComparator orderByComparator) throws SystemException {
1070 FinderPath finderPath = null;
1071 Object[] finderArgs = null;
1072
1073 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1074 (orderByComparator == null)) {
1075 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SYSTEM;
1076 finderArgs = new Object[] { system };
1077 }
1078 else {
1079 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_SYSTEM;
1080 finderArgs = new Object[] { system, start, end, orderByComparator };
1081 }
1082
1083 List<Company> list = (List<Company>)FinderCacheUtil.getResult(finderPath,
1084 finderArgs, this);
1085
1086 if ((list != null) && !list.isEmpty()) {
1087 for (Company company : list) {
1088 if ((system != company.getSystem())) {
1089 list = null;
1090
1091 break;
1092 }
1093 }
1094 }
1095
1096 if (list == null) {
1097 StringBundler query = null;
1098
1099 if (orderByComparator != null) {
1100 query = new StringBundler(3 +
1101 (orderByComparator.getOrderByFields().length * 3));
1102 }
1103 else {
1104 query = new StringBundler(2);
1105 }
1106
1107 query.append(_SQL_SELECT_COMPANY_WHERE);
1108
1109 query.append(_FINDER_COLUMN_SYSTEM_SYSTEM_2);
1110
1111 if (orderByComparator != null) {
1112 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1113 orderByComparator);
1114 }
1115
1116 String sql = query.toString();
1117
1118 Session session = null;
1119
1120 try {
1121 session = openSession();
1122
1123 Query q = session.createQuery(sql);
1124
1125 QueryPos qPos = QueryPos.getInstance(q);
1126
1127 qPos.add(system);
1128
1129 list = (List<Company>)QueryUtil.list(q, getDialect(), start, end);
1130 }
1131 catch (Exception e) {
1132 throw processException(e);
1133 }
1134 finally {
1135 if (list == null) {
1136 FinderCacheUtil.removeResult(finderPath, finderArgs);
1137 }
1138 else {
1139 cacheResult(list);
1140
1141 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1142 }
1143
1144 closeSession(session);
1145 }
1146 }
1147
1148 return list;
1149 }
1150
1151
1160 public Company findBySystem_First(boolean system,
1161 OrderByComparator orderByComparator)
1162 throws NoSuchCompanyException, SystemException {
1163 Company company = fetchBySystem_First(system, orderByComparator);
1164
1165 if (company != null) {
1166 return company;
1167 }
1168
1169 StringBundler msg = new StringBundler(4);
1170
1171 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1172
1173 msg.append("system=");
1174 msg.append(system);
1175
1176 msg.append(StringPool.CLOSE_CURLY_BRACE);
1177
1178 throw new NoSuchCompanyException(msg.toString());
1179 }
1180
1181
1189 public Company fetchBySystem_First(boolean system,
1190 OrderByComparator orderByComparator) throws SystemException {
1191 List<Company> list = findBySystem(system, 0, 1, orderByComparator);
1192
1193 if (!list.isEmpty()) {
1194 return list.get(0);
1195 }
1196
1197 return null;
1198 }
1199
1200
1209 public Company findBySystem_Last(boolean system,
1210 OrderByComparator orderByComparator)
1211 throws NoSuchCompanyException, SystemException {
1212 Company company = fetchBySystem_Last(system, orderByComparator);
1213
1214 if (company != null) {
1215 return company;
1216 }
1217
1218 StringBundler msg = new StringBundler(4);
1219
1220 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1221
1222 msg.append("system=");
1223 msg.append(system);
1224
1225 msg.append(StringPool.CLOSE_CURLY_BRACE);
1226
1227 throw new NoSuchCompanyException(msg.toString());
1228 }
1229
1230
1238 public Company fetchBySystem_Last(boolean system,
1239 OrderByComparator orderByComparator) throws SystemException {
1240 int count = countBySystem(system);
1241
1242 List<Company> list = findBySystem(system, count - 1, count,
1243 orderByComparator);
1244
1245 if (!list.isEmpty()) {
1246 return list.get(0);
1247 }
1248
1249 return null;
1250 }
1251
1252
1262 public Company[] findBySystem_PrevAndNext(long companyId, boolean system,
1263 OrderByComparator orderByComparator)
1264 throws NoSuchCompanyException, SystemException {
1265 Company company = findByPrimaryKey(companyId);
1266
1267 Session session = null;
1268
1269 try {
1270 session = openSession();
1271
1272 Company[] array = new CompanyImpl[3];
1273
1274 array[0] = getBySystem_PrevAndNext(session, company, system,
1275 orderByComparator, true);
1276
1277 array[1] = company;
1278
1279 array[2] = getBySystem_PrevAndNext(session, company, system,
1280 orderByComparator, false);
1281
1282 return array;
1283 }
1284 catch (Exception e) {
1285 throw processException(e);
1286 }
1287 finally {
1288 closeSession(session);
1289 }
1290 }
1291
1292 protected Company getBySystem_PrevAndNext(Session session, Company company,
1293 boolean system, OrderByComparator orderByComparator, boolean previous) {
1294 StringBundler query = null;
1295
1296 if (orderByComparator != null) {
1297 query = new StringBundler(6 +
1298 (orderByComparator.getOrderByFields().length * 6));
1299 }
1300 else {
1301 query = new StringBundler(3);
1302 }
1303
1304 query.append(_SQL_SELECT_COMPANY_WHERE);
1305
1306 query.append(_FINDER_COLUMN_SYSTEM_SYSTEM_2);
1307
1308 if (orderByComparator != null) {
1309 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1310
1311 if (orderByConditionFields.length > 0) {
1312 query.append(WHERE_AND);
1313 }
1314
1315 for (int i = 0; i < orderByConditionFields.length; i++) {
1316 query.append(_ORDER_BY_ENTITY_ALIAS);
1317 query.append(orderByConditionFields[i]);
1318
1319 if ((i + 1) < orderByConditionFields.length) {
1320 if (orderByComparator.isAscending() ^ previous) {
1321 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1322 }
1323 else {
1324 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1325 }
1326 }
1327 else {
1328 if (orderByComparator.isAscending() ^ previous) {
1329 query.append(WHERE_GREATER_THAN);
1330 }
1331 else {
1332 query.append(WHERE_LESSER_THAN);
1333 }
1334 }
1335 }
1336
1337 query.append(ORDER_BY_CLAUSE);
1338
1339 String[] orderByFields = orderByComparator.getOrderByFields();
1340
1341 for (int i = 0; i < orderByFields.length; i++) {
1342 query.append(_ORDER_BY_ENTITY_ALIAS);
1343 query.append(orderByFields[i]);
1344
1345 if ((i + 1) < orderByFields.length) {
1346 if (orderByComparator.isAscending() ^ previous) {
1347 query.append(ORDER_BY_ASC_HAS_NEXT);
1348 }
1349 else {
1350 query.append(ORDER_BY_DESC_HAS_NEXT);
1351 }
1352 }
1353 else {
1354 if (orderByComparator.isAscending() ^ previous) {
1355 query.append(ORDER_BY_ASC);
1356 }
1357 else {
1358 query.append(ORDER_BY_DESC);
1359 }
1360 }
1361 }
1362 }
1363
1364 String sql = query.toString();
1365
1366 Query q = session.createQuery(sql);
1367
1368 q.setFirstResult(0);
1369 q.setMaxResults(2);
1370
1371 QueryPos qPos = QueryPos.getInstance(q);
1372
1373 qPos.add(system);
1374
1375 if (orderByComparator != null) {
1376 Object[] values = orderByComparator.getOrderByConditionValues(company);
1377
1378 for (Object value : values) {
1379 qPos.add(value);
1380 }
1381 }
1382
1383 List<Company> list = q.list();
1384
1385 if (list.size() == 2) {
1386 return list.get(1);
1387 }
1388 else {
1389 return null;
1390 }
1391 }
1392
1393
1399 public List<Company> findAll() throws SystemException {
1400 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1401 }
1402
1403
1415 public List<Company> findAll(int start, int end) throws SystemException {
1416 return findAll(start, end, null);
1417 }
1418
1419
1432 public List<Company> findAll(int start, int end,
1433 OrderByComparator orderByComparator) throws SystemException {
1434 FinderPath finderPath = null;
1435 Object[] finderArgs = new Object[] { start, end, orderByComparator };
1436
1437 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1438 (orderByComparator == null)) {
1439 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
1440 finderArgs = FINDER_ARGS_EMPTY;
1441 }
1442 else {
1443 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
1444 finderArgs = new Object[] { start, end, orderByComparator };
1445 }
1446
1447 List<Company> list = (List<Company>)FinderCacheUtil.getResult(finderPath,
1448 finderArgs, this);
1449
1450 if (list == null) {
1451 StringBundler query = null;
1452 String sql = null;
1453
1454 if (orderByComparator != null) {
1455 query = new StringBundler(2 +
1456 (orderByComparator.getOrderByFields().length * 3));
1457
1458 query.append(_SQL_SELECT_COMPANY);
1459
1460 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1461 orderByComparator);
1462
1463 sql = query.toString();
1464 }
1465 else {
1466 sql = _SQL_SELECT_COMPANY;
1467 }
1468
1469 Session session = null;
1470
1471 try {
1472 session = openSession();
1473
1474 Query q = session.createQuery(sql);
1475
1476 if (orderByComparator == null) {
1477 list = (List<Company>)QueryUtil.list(q, getDialect(),
1478 start, end, false);
1479
1480 Collections.sort(list);
1481 }
1482 else {
1483 list = (List<Company>)QueryUtil.list(q, getDialect(),
1484 start, end);
1485 }
1486 }
1487 catch (Exception e) {
1488 throw processException(e);
1489 }
1490 finally {
1491 if (list == null) {
1492 FinderCacheUtil.removeResult(finderPath, finderArgs);
1493 }
1494 else {
1495 cacheResult(list);
1496
1497 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1498 }
1499
1500 closeSession(session);
1501 }
1502 }
1503
1504 return list;
1505 }
1506
1507
1514 public Company removeByWebId(String webId)
1515 throws NoSuchCompanyException, SystemException {
1516 Company company = findByWebId(webId);
1517
1518 return remove(company);
1519 }
1520
1521
1528 public Company removeByMx(String mx)
1529 throws NoSuchCompanyException, SystemException {
1530 Company company = findByMx(mx);
1531
1532 return remove(company);
1533 }
1534
1535
1542 public Company removeByLogoId(long logoId)
1543 throws NoSuchCompanyException, SystemException {
1544 Company company = findByLogoId(logoId);
1545
1546 return remove(company);
1547 }
1548
1549
1555 public void removeBySystem(boolean system) throws SystemException {
1556 for (Company company : findBySystem(system)) {
1557 remove(company);
1558 }
1559 }
1560
1561
1566 public void removeAll() throws SystemException {
1567 for (Company company : findAll()) {
1568 remove(company);
1569 }
1570 }
1571
1572
1579 public int countByWebId(String webId) throws SystemException {
1580 Object[] finderArgs = new Object[] { webId };
1581
1582 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_WEBID,
1583 finderArgs, this);
1584
1585 if (count == null) {
1586 StringBundler query = new StringBundler(2);
1587
1588 query.append(_SQL_COUNT_COMPANY_WHERE);
1589
1590 if (webId == null) {
1591 query.append(_FINDER_COLUMN_WEBID_WEBID_1);
1592 }
1593 else {
1594 if (webId.equals(StringPool.BLANK)) {
1595 query.append(_FINDER_COLUMN_WEBID_WEBID_3);
1596 }
1597 else {
1598 query.append(_FINDER_COLUMN_WEBID_WEBID_2);
1599 }
1600 }
1601
1602 String sql = query.toString();
1603
1604 Session session = null;
1605
1606 try {
1607 session = openSession();
1608
1609 Query q = session.createQuery(sql);
1610
1611 QueryPos qPos = QueryPos.getInstance(q);
1612
1613 if (webId != null) {
1614 qPos.add(webId);
1615 }
1616
1617 count = (Long)q.uniqueResult();
1618 }
1619 catch (Exception e) {
1620 throw processException(e);
1621 }
1622 finally {
1623 if (count == null) {
1624 count = Long.valueOf(0);
1625 }
1626
1627 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_WEBID,
1628 finderArgs, count);
1629
1630 closeSession(session);
1631 }
1632 }
1633
1634 return count.intValue();
1635 }
1636
1637
1644 public int countByMx(String mx) throws SystemException {
1645 Object[] finderArgs = new Object[] { mx };
1646
1647 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_MX,
1648 finderArgs, this);
1649
1650 if (count == null) {
1651 StringBundler query = new StringBundler(2);
1652
1653 query.append(_SQL_COUNT_COMPANY_WHERE);
1654
1655 if (mx == null) {
1656 query.append(_FINDER_COLUMN_MX_MX_1);
1657 }
1658 else {
1659 if (mx.equals(StringPool.BLANK)) {
1660 query.append(_FINDER_COLUMN_MX_MX_3);
1661 }
1662 else {
1663 query.append(_FINDER_COLUMN_MX_MX_2);
1664 }
1665 }
1666
1667 String sql = query.toString();
1668
1669 Session session = null;
1670
1671 try {
1672 session = openSession();
1673
1674 Query q = session.createQuery(sql);
1675
1676 QueryPos qPos = QueryPos.getInstance(q);
1677
1678 if (mx != null) {
1679 qPos.add(mx);
1680 }
1681
1682 count = (Long)q.uniqueResult();
1683 }
1684 catch (Exception e) {
1685 throw processException(e);
1686 }
1687 finally {
1688 if (count == null) {
1689 count = Long.valueOf(0);
1690 }
1691
1692 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_MX, finderArgs,
1693 count);
1694
1695 closeSession(session);
1696 }
1697 }
1698
1699 return count.intValue();
1700 }
1701
1702
1709 public int countByLogoId(long logoId) throws SystemException {
1710 Object[] finderArgs = new Object[] { logoId };
1711
1712 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_LOGOID,
1713 finderArgs, this);
1714
1715 if (count == null) {
1716 StringBundler query = new StringBundler(2);
1717
1718 query.append(_SQL_COUNT_COMPANY_WHERE);
1719
1720 query.append(_FINDER_COLUMN_LOGOID_LOGOID_2);
1721
1722 String sql = query.toString();
1723
1724 Session session = null;
1725
1726 try {
1727 session = openSession();
1728
1729 Query q = session.createQuery(sql);
1730
1731 QueryPos qPos = QueryPos.getInstance(q);
1732
1733 qPos.add(logoId);
1734
1735 count = (Long)q.uniqueResult();
1736 }
1737 catch (Exception e) {
1738 throw processException(e);
1739 }
1740 finally {
1741 if (count == null) {
1742 count = Long.valueOf(0);
1743 }
1744
1745 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_LOGOID,
1746 finderArgs, count);
1747
1748 closeSession(session);
1749 }
1750 }
1751
1752 return count.intValue();
1753 }
1754
1755
1762 public int countBySystem(boolean system) throws SystemException {
1763 Object[] finderArgs = new Object[] { system };
1764
1765 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_SYSTEM,
1766 finderArgs, this);
1767
1768 if (count == null) {
1769 StringBundler query = new StringBundler(2);
1770
1771 query.append(_SQL_COUNT_COMPANY_WHERE);
1772
1773 query.append(_FINDER_COLUMN_SYSTEM_SYSTEM_2);
1774
1775 String sql = query.toString();
1776
1777 Session session = null;
1778
1779 try {
1780 session = openSession();
1781
1782 Query q = session.createQuery(sql);
1783
1784 QueryPos qPos = QueryPos.getInstance(q);
1785
1786 qPos.add(system);
1787
1788 count = (Long)q.uniqueResult();
1789 }
1790 catch (Exception e) {
1791 throw processException(e);
1792 }
1793 finally {
1794 if (count == null) {
1795 count = Long.valueOf(0);
1796 }
1797
1798 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_SYSTEM,
1799 finderArgs, count);
1800
1801 closeSession(session);
1802 }
1803 }
1804
1805 return count.intValue();
1806 }
1807
1808
1814 public int countAll() throws SystemException {
1815 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1816 FINDER_ARGS_EMPTY, this);
1817
1818 if (count == null) {
1819 Session session = null;
1820
1821 try {
1822 session = openSession();
1823
1824 Query q = session.createQuery(_SQL_COUNT_COMPANY);
1825
1826 count = (Long)q.uniqueResult();
1827 }
1828 catch (Exception e) {
1829 throw processException(e);
1830 }
1831 finally {
1832 if (count == null) {
1833 count = Long.valueOf(0);
1834 }
1835
1836 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
1837 FINDER_ARGS_EMPTY, count);
1838
1839 closeSession(session);
1840 }
1841 }
1842
1843 return count.intValue();
1844 }
1845
1846
1849 public void afterPropertiesSet() {
1850 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1851 com.liferay.portal.util.PropsUtil.get(
1852 "value.object.listener.com.liferay.portal.model.Company")));
1853
1854 if (listenerClassNames.length > 0) {
1855 try {
1856 List<ModelListener<Company>> listenersList = new ArrayList<ModelListener<Company>>();
1857
1858 for (String listenerClassName : listenerClassNames) {
1859 Class<?> clazz = getClass();
1860
1861 listenersList.add((ModelListener<Company>)InstanceFactory.newInstance(
1862 clazz.getClassLoader(), listenerClassName));
1863 }
1864
1865 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1866 }
1867 catch (Exception e) {
1868 _log.error(e);
1869 }
1870 }
1871 }
1872
1873 public void destroy() {
1874 EntityCacheUtil.removeCache(CompanyImpl.class.getName());
1875 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
1876 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1877 }
1878
1879 @BeanReference(type = AccountPersistence.class)
1880 protected AccountPersistence accountPersistence;
1881 @BeanReference(type = AddressPersistence.class)
1882 protected AddressPersistence addressPersistence;
1883 @BeanReference(type = BrowserTrackerPersistence.class)
1884 protected BrowserTrackerPersistence browserTrackerPersistence;
1885 @BeanReference(type = ClassNamePersistence.class)
1886 protected ClassNamePersistence classNamePersistence;
1887 @BeanReference(type = ClusterGroupPersistence.class)
1888 protected ClusterGroupPersistence clusterGroupPersistence;
1889 @BeanReference(type = CompanyPersistence.class)
1890 protected CompanyPersistence companyPersistence;
1891 @BeanReference(type = ContactPersistence.class)
1892 protected ContactPersistence contactPersistence;
1893 @BeanReference(type = CountryPersistence.class)
1894 protected CountryPersistence countryPersistence;
1895 @BeanReference(type = EmailAddressPersistence.class)
1896 protected EmailAddressPersistence emailAddressPersistence;
1897 @BeanReference(type = GroupPersistence.class)
1898 protected GroupPersistence groupPersistence;
1899 @BeanReference(type = ImagePersistence.class)
1900 protected ImagePersistence imagePersistence;
1901 @BeanReference(type = LayoutPersistence.class)
1902 protected LayoutPersistence layoutPersistence;
1903 @BeanReference(type = LayoutBranchPersistence.class)
1904 protected LayoutBranchPersistence layoutBranchPersistence;
1905 @BeanReference(type = LayoutPrototypePersistence.class)
1906 protected LayoutPrototypePersistence layoutPrototypePersistence;
1907 @BeanReference(type = LayoutRevisionPersistence.class)
1908 protected LayoutRevisionPersistence layoutRevisionPersistence;
1909 @BeanReference(type = LayoutSetPersistence.class)
1910 protected LayoutSetPersistence layoutSetPersistence;
1911 @BeanReference(type = LayoutSetBranchPersistence.class)
1912 protected LayoutSetBranchPersistence layoutSetBranchPersistence;
1913 @BeanReference(type = LayoutSetPrototypePersistence.class)
1914 protected LayoutSetPrototypePersistence layoutSetPrototypePersistence;
1915 @BeanReference(type = ListTypePersistence.class)
1916 protected ListTypePersistence listTypePersistence;
1917 @BeanReference(type = LockPersistence.class)
1918 protected LockPersistence lockPersistence;
1919 @BeanReference(type = MembershipRequestPersistence.class)
1920 protected MembershipRequestPersistence membershipRequestPersistence;
1921 @BeanReference(type = OrganizationPersistence.class)
1922 protected OrganizationPersistence organizationPersistence;
1923 @BeanReference(type = OrgGroupPermissionPersistence.class)
1924 protected OrgGroupPermissionPersistence orgGroupPermissionPersistence;
1925 @BeanReference(type = OrgGroupRolePersistence.class)
1926 protected OrgGroupRolePersistence orgGroupRolePersistence;
1927 @BeanReference(type = OrgLaborPersistence.class)
1928 protected OrgLaborPersistence orgLaborPersistence;
1929 @BeanReference(type = PasswordPolicyPersistence.class)
1930 protected PasswordPolicyPersistence passwordPolicyPersistence;
1931 @BeanReference(type = PasswordPolicyRelPersistence.class)
1932 protected PasswordPolicyRelPersistence passwordPolicyRelPersistence;
1933 @BeanReference(type = PasswordTrackerPersistence.class)
1934 protected PasswordTrackerPersistence passwordTrackerPersistence;
1935 @BeanReference(type = PermissionPersistence.class)
1936 protected PermissionPersistence permissionPersistence;
1937 @BeanReference(type = PhonePersistence.class)
1938 protected PhonePersistence phonePersistence;
1939 @BeanReference(type = PluginSettingPersistence.class)
1940 protected PluginSettingPersistence pluginSettingPersistence;
1941 @BeanReference(type = PortalPreferencesPersistence.class)
1942 protected PortalPreferencesPersistence portalPreferencesPersistence;
1943 @BeanReference(type = PortletPersistence.class)
1944 protected PortletPersistence portletPersistence;
1945 @BeanReference(type = PortletItemPersistence.class)
1946 protected PortletItemPersistence portletItemPersistence;
1947 @BeanReference(type = PortletPreferencesPersistence.class)
1948 protected PortletPreferencesPersistence portletPreferencesPersistence;
1949 @BeanReference(type = RegionPersistence.class)
1950 protected RegionPersistence regionPersistence;
1951 @BeanReference(type = ReleasePersistence.class)
1952 protected ReleasePersistence releasePersistence;
1953 @BeanReference(type = RepositoryPersistence.class)
1954 protected RepositoryPersistence repositoryPersistence;
1955 @BeanReference(type = RepositoryEntryPersistence.class)
1956 protected RepositoryEntryPersistence repositoryEntryPersistence;
1957 @BeanReference(type = ResourcePersistence.class)
1958 protected ResourcePersistence resourcePersistence;
1959 @BeanReference(type = ResourceActionPersistence.class)
1960 protected ResourceActionPersistence resourceActionPersistence;
1961 @BeanReference(type = ResourceBlockPersistence.class)
1962 protected ResourceBlockPersistence resourceBlockPersistence;
1963 @BeanReference(type = ResourceBlockPermissionPersistence.class)
1964 protected ResourceBlockPermissionPersistence resourceBlockPermissionPersistence;
1965 @BeanReference(type = ResourceCodePersistence.class)
1966 protected ResourceCodePersistence resourceCodePersistence;
1967 @BeanReference(type = ResourcePermissionPersistence.class)
1968 protected ResourcePermissionPersistence resourcePermissionPersistence;
1969 @BeanReference(type = ResourceTypePermissionPersistence.class)
1970 protected ResourceTypePermissionPersistence resourceTypePermissionPersistence;
1971 @BeanReference(type = RolePersistence.class)
1972 protected RolePersistence rolePersistence;
1973 @BeanReference(type = ServiceComponentPersistence.class)
1974 protected ServiceComponentPersistence serviceComponentPersistence;
1975 @BeanReference(type = ShardPersistence.class)
1976 protected ShardPersistence shardPersistence;
1977 @BeanReference(type = SubscriptionPersistence.class)
1978 protected SubscriptionPersistence subscriptionPersistence;
1979 @BeanReference(type = TeamPersistence.class)
1980 protected TeamPersistence teamPersistence;
1981 @BeanReference(type = TicketPersistence.class)
1982 protected TicketPersistence ticketPersistence;
1983 @BeanReference(type = UserPersistence.class)
1984 protected UserPersistence userPersistence;
1985 @BeanReference(type = UserGroupPersistence.class)
1986 protected UserGroupPersistence userGroupPersistence;
1987 @BeanReference(type = UserGroupGroupRolePersistence.class)
1988 protected UserGroupGroupRolePersistence userGroupGroupRolePersistence;
1989 @BeanReference(type = UserGroupRolePersistence.class)
1990 protected UserGroupRolePersistence userGroupRolePersistence;
1991 @BeanReference(type = UserIdMapperPersistence.class)
1992 protected UserIdMapperPersistence userIdMapperPersistence;
1993 @BeanReference(type = UserNotificationEventPersistence.class)
1994 protected UserNotificationEventPersistence userNotificationEventPersistence;
1995 @BeanReference(type = UserTrackerPersistence.class)
1996 protected UserTrackerPersistence userTrackerPersistence;
1997 @BeanReference(type = UserTrackerPathPersistence.class)
1998 protected UserTrackerPathPersistence userTrackerPathPersistence;
1999 @BeanReference(type = VirtualHostPersistence.class)
2000 protected VirtualHostPersistence virtualHostPersistence;
2001 @BeanReference(type = WebDAVPropsPersistence.class)
2002 protected WebDAVPropsPersistence webDAVPropsPersistence;
2003 @BeanReference(type = WebsitePersistence.class)
2004 protected WebsitePersistence websitePersistence;
2005 @BeanReference(type = WorkflowDefinitionLinkPersistence.class)
2006 protected WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
2007 @BeanReference(type = WorkflowInstanceLinkPersistence.class)
2008 protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
2009 private static final String _SQL_SELECT_COMPANY = "SELECT company FROM Company company";
2010 private static final String _SQL_SELECT_COMPANY_WHERE = "SELECT company FROM Company company WHERE ";
2011 private static final String _SQL_COUNT_COMPANY = "SELECT COUNT(company) FROM Company company";
2012 private static final String _SQL_COUNT_COMPANY_WHERE = "SELECT COUNT(company) FROM Company company WHERE ";
2013 private static final String _FINDER_COLUMN_WEBID_WEBID_1 = "company.webId IS NULL";
2014 private static final String _FINDER_COLUMN_WEBID_WEBID_2 = "company.webId = ?";
2015 private static final String _FINDER_COLUMN_WEBID_WEBID_3 = "(company.webId IS NULL OR company.webId = ?)";
2016 private static final String _FINDER_COLUMN_MX_MX_1 = "company.mx IS NULL";
2017 private static final String _FINDER_COLUMN_MX_MX_2 = "company.mx = ?";
2018 private static final String _FINDER_COLUMN_MX_MX_3 = "(company.mx IS NULL OR company.mx = ?)";
2019 private static final String _FINDER_COLUMN_LOGOID_LOGOID_2 = "company.logoId = ?";
2020 private static final String _FINDER_COLUMN_SYSTEM_SYSTEM_2 = "company.system = ?";
2021 private static final String _ORDER_BY_ENTITY_ALIAS = "company.";
2022 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No Company exists with the primary key ";
2023 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No Company exists with the key {";
2024 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
2025 private static Log _log = LogFactoryUtil.getLog(CompanyPersistenceImpl.class);
2026 private static Company _nullCompany = new CompanyImpl() {
2027 @Override
2028 public Object clone() {
2029 return this;
2030 }
2031
2032 @Override
2033 public CacheModel<Company> toCacheModel() {
2034 return _nullCompanyCacheModel;
2035 }
2036 };
2037
2038 private static CacheModel<Company> _nullCompanyCacheModel = new CacheModel<Company>() {
2039 public Company toEntityModel() {
2040 return _nullCompany;
2041 }
2042 };
2043 }