001
014
015 package com.liferay.portal.service.persistence;
016
017 import com.liferay.portal.NoSuchModelException;
018 import com.liferay.portal.NoSuchOrganizationException;
019 import com.liferay.portal.kernel.bean.BeanReference;
020 import com.liferay.portal.kernel.cache.CacheRegistryUtil;
021 import com.liferay.portal.kernel.dao.jdbc.MappingSqlQuery;
022 import com.liferay.portal.kernel.dao.jdbc.MappingSqlQueryFactoryUtil;
023 import com.liferay.portal.kernel.dao.jdbc.RowMapper;
024 import com.liferay.portal.kernel.dao.jdbc.SqlUpdate;
025 import com.liferay.portal.kernel.dao.jdbc.SqlUpdateFactoryUtil;
026 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
027 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
028 import com.liferay.portal.kernel.dao.orm.FinderPath;
029 import com.liferay.portal.kernel.dao.orm.Query;
030 import com.liferay.portal.kernel.dao.orm.QueryPos;
031 import com.liferay.portal.kernel.dao.orm.QueryUtil;
032 import com.liferay.portal.kernel.dao.orm.SQLQuery;
033 import com.liferay.portal.kernel.dao.orm.Session;
034 import com.liferay.portal.kernel.exception.SystemException;
035 import com.liferay.portal.kernel.log.Log;
036 import com.liferay.portal.kernel.log.LogFactoryUtil;
037 import com.liferay.portal.kernel.util.GetterUtil;
038 import com.liferay.portal.kernel.util.InstanceFactory;
039 import com.liferay.portal.kernel.util.OrderByComparator;
040 import com.liferay.portal.kernel.util.SetUtil;
041 import com.liferay.portal.kernel.util.StringBundler;
042 import com.liferay.portal.kernel.util.StringPool;
043 import com.liferay.portal.kernel.util.StringUtil;
044 import com.liferay.portal.kernel.util.Validator;
045 import com.liferay.portal.model.CacheModel;
046 import com.liferay.portal.model.ModelListener;
047 import com.liferay.portal.model.Organization;
048 import com.liferay.portal.model.impl.OrganizationImpl;
049 import com.liferay.portal.model.impl.OrganizationModelImpl;
050 import com.liferay.portal.security.permission.InlineSQLHelperUtil;
051 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
052
053 import com.liferay.portlet.asset.service.persistence.AssetEntryPersistence;
054 import com.liferay.portlet.expando.service.persistence.ExpandoValuePersistence;
055
056 import java.io.Serializable;
057
058 import java.util.ArrayList;
059 import java.util.Collections;
060 import java.util.List;
061 import java.util.Set;
062
063
075 public class OrganizationPersistenceImpl extends BasePersistenceImpl<Organization>
076 implements OrganizationPersistence {
077
082 public static final String FINDER_CLASS_NAME_ENTITY = OrganizationImpl.class.getName();
083 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
084 ".List1";
085 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
086 ".List2";
087 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID =
088 new FinderPath(OrganizationModelImpl.ENTITY_CACHE_ENABLED,
089 OrganizationModelImpl.FINDER_CACHE_ENABLED, OrganizationImpl.class,
090 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByCompanyId",
091 new String[] {
092 Long.class.getName(),
093
094 "java.lang.Integer", "java.lang.Integer",
095 "com.liferay.portal.kernel.util.OrderByComparator"
096 });
097 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID =
098 new FinderPath(OrganizationModelImpl.ENTITY_CACHE_ENABLED,
099 OrganizationModelImpl.FINDER_CACHE_ENABLED, OrganizationImpl.class,
100 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCompanyId",
101 new String[] { Long.class.getName() },
102 OrganizationModelImpl.COMPANYID_COLUMN_BITMASK);
103 public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(OrganizationModelImpl.ENTITY_CACHE_ENABLED,
104 OrganizationModelImpl.FINDER_CACHE_ENABLED, Long.class,
105 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCompanyId",
106 new String[] { Long.class.getName() });
107 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_LOCATIONS =
108 new FinderPath(OrganizationModelImpl.ENTITY_CACHE_ENABLED,
109 OrganizationModelImpl.FINDER_CACHE_ENABLED, OrganizationImpl.class,
110 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByLocations",
111 new String[] {
112 Long.class.getName(),
113
114 "java.lang.Integer", "java.lang.Integer",
115 "com.liferay.portal.kernel.util.OrderByComparator"
116 });
117 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LOCATIONS =
118 new FinderPath(OrganizationModelImpl.ENTITY_CACHE_ENABLED,
119 OrganizationModelImpl.FINDER_CACHE_ENABLED, OrganizationImpl.class,
120 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByLocations",
121 new String[] { Long.class.getName() },
122 OrganizationModelImpl.COMPANYID_COLUMN_BITMASK);
123 public static final FinderPath FINDER_PATH_COUNT_BY_LOCATIONS = new FinderPath(OrganizationModelImpl.ENTITY_CACHE_ENABLED,
124 OrganizationModelImpl.FINDER_CACHE_ENABLED, Long.class,
125 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByLocations",
126 new String[] { Long.class.getName() });
127 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_P = new FinderPath(OrganizationModelImpl.ENTITY_CACHE_ENABLED,
128 OrganizationModelImpl.FINDER_CACHE_ENABLED, OrganizationImpl.class,
129 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_P",
130 new String[] {
131 Long.class.getName(), Long.class.getName(),
132
133 "java.lang.Integer", "java.lang.Integer",
134 "com.liferay.portal.kernel.util.OrderByComparator"
135 });
136 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_P = new FinderPath(OrganizationModelImpl.ENTITY_CACHE_ENABLED,
137 OrganizationModelImpl.FINDER_CACHE_ENABLED, OrganizationImpl.class,
138 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_P",
139 new String[] { Long.class.getName(), Long.class.getName() },
140 OrganizationModelImpl.COMPANYID_COLUMN_BITMASK |
141 OrganizationModelImpl.PARENTORGANIZATIONID_COLUMN_BITMASK);
142 public static final FinderPath FINDER_PATH_COUNT_BY_C_P = new FinderPath(OrganizationModelImpl.ENTITY_CACHE_ENABLED,
143 OrganizationModelImpl.FINDER_CACHE_ENABLED, Long.class,
144 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_P",
145 new String[] { Long.class.getName(), Long.class.getName() });
146 public static final FinderPath FINDER_PATH_FETCH_BY_C_N = new FinderPath(OrganizationModelImpl.ENTITY_CACHE_ENABLED,
147 OrganizationModelImpl.FINDER_CACHE_ENABLED, OrganizationImpl.class,
148 FINDER_CLASS_NAME_ENTITY, "fetchByC_N",
149 new String[] { Long.class.getName(), String.class.getName() },
150 OrganizationModelImpl.COMPANYID_COLUMN_BITMASK |
151 OrganizationModelImpl.NAME_COLUMN_BITMASK);
152 public static final FinderPath FINDER_PATH_COUNT_BY_C_N = new FinderPath(OrganizationModelImpl.ENTITY_CACHE_ENABLED,
153 OrganizationModelImpl.FINDER_CACHE_ENABLED, Long.class,
154 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_N",
155 new String[] { Long.class.getName(), String.class.getName() });
156 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(OrganizationModelImpl.ENTITY_CACHE_ENABLED,
157 OrganizationModelImpl.FINDER_CACHE_ENABLED, OrganizationImpl.class,
158 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
159 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(OrganizationModelImpl.ENTITY_CACHE_ENABLED,
160 OrganizationModelImpl.FINDER_CACHE_ENABLED, OrganizationImpl.class,
161 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
162 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(OrganizationModelImpl.ENTITY_CACHE_ENABLED,
163 OrganizationModelImpl.FINDER_CACHE_ENABLED, Long.class,
164 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
165
166
171 public void cacheResult(Organization organization) {
172 EntityCacheUtil.putResult(OrganizationModelImpl.ENTITY_CACHE_ENABLED,
173 OrganizationImpl.class, organization.getPrimaryKey(), organization);
174
175 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N,
176 new Object[] {
177 Long.valueOf(organization.getCompanyId()),
178
179 organization.getName()
180 }, organization);
181
182 organization.resetOriginalValues();
183 }
184
185
190 public void cacheResult(List<Organization> organizations) {
191 for (Organization organization : organizations) {
192 if (EntityCacheUtil.getResult(
193 OrganizationModelImpl.ENTITY_CACHE_ENABLED,
194 OrganizationImpl.class, organization.getPrimaryKey()) == null) {
195 cacheResult(organization);
196 }
197 else {
198 organization.resetOriginalValues();
199 }
200 }
201 }
202
203
210 @Override
211 public void clearCache() {
212 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
213 CacheRegistryUtil.clear(OrganizationImpl.class.getName());
214 }
215
216 EntityCacheUtil.clearCache(OrganizationImpl.class.getName());
217
218 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
219 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
220 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
221 }
222
223
230 @Override
231 public void clearCache(Organization organization) {
232 EntityCacheUtil.removeResult(OrganizationModelImpl.ENTITY_CACHE_ENABLED,
233 OrganizationImpl.class, organization.getPrimaryKey());
234
235 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
236 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
237
238 clearUniqueFindersCache(organization);
239 }
240
241 @Override
242 public void clearCache(List<Organization> organizations) {
243 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
244 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
245
246 for (Organization organization : organizations) {
247 EntityCacheUtil.removeResult(OrganizationModelImpl.ENTITY_CACHE_ENABLED,
248 OrganizationImpl.class, organization.getPrimaryKey());
249
250 clearUniqueFindersCache(organization);
251 }
252 }
253
254 protected void clearUniqueFindersCache(Organization organization) {
255 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_N,
256 new Object[] {
257 Long.valueOf(organization.getCompanyId()),
258
259 organization.getName()
260 });
261 }
262
263
269 public Organization create(long organizationId) {
270 Organization organization = new OrganizationImpl();
271
272 organization.setNew(true);
273 organization.setPrimaryKey(organizationId);
274
275 return organization;
276 }
277
278
286 public Organization remove(long organizationId)
287 throws NoSuchOrganizationException, SystemException {
288 return remove(Long.valueOf(organizationId));
289 }
290
291
299 @Override
300 public Organization remove(Serializable primaryKey)
301 throws NoSuchOrganizationException, SystemException {
302 Session session = null;
303
304 try {
305 session = openSession();
306
307 Organization organization = (Organization)session.get(OrganizationImpl.class,
308 primaryKey);
309
310 if (organization == null) {
311 if (_log.isWarnEnabled()) {
312 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
313 }
314
315 throw new NoSuchOrganizationException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
316 primaryKey);
317 }
318
319 return remove(organization);
320 }
321 catch (NoSuchOrganizationException nsee) {
322 throw nsee;
323 }
324 catch (Exception e) {
325 throw processException(e);
326 }
327 finally {
328 closeSession(session);
329 }
330 }
331
332 @Override
333 protected Organization removeImpl(Organization organization)
334 throws SystemException {
335 organization = toUnwrappedModel(organization);
336
337 try {
338 clearGroups.clear(organization.getPrimaryKey());
339 }
340 catch (Exception e) {
341 throw processException(e);
342 }
343 finally {
344 FinderCacheUtil.clearCache(OrganizationModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME);
345 }
346
347 try {
348 clearUsers.clear(organization.getPrimaryKey());
349 }
350 catch (Exception e) {
351 throw processException(e);
352 }
353 finally {
354 FinderCacheUtil.clearCache(OrganizationModelImpl.MAPPING_TABLE_USERS_ORGS_NAME);
355 }
356
357 Session session = null;
358
359 try {
360 session = openSession();
361
362 BatchSessionUtil.delete(session, organization);
363 }
364 catch (Exception e) {
365 throw processException(e);
366 }
367 finally {
368 closeSession(session);
369 }
370
371 clearCache(organization);
372
373 return organization;
374 }
375
376 @Override
377 public Organization updateImpl(
378 com.liferay.portal.model.Organization organization, boolean merge)
379 throws SystemException {
380 organization = toUnwrappedModel(organization);
381
382 boolean isNew = organization.isNew();
383
384 OrganizationModelImpl organizationModelImpl = (OrganizationModelImpl)organization;
385
386 Session session = null;
387
388 try {
389 session = openSession();
390
391 BatchSessionUtil.update(session, organization, merge);
392
393 organization.setNew(false);
394 }
395 catch (Exception e) {
396 throw processException(e);
397 }
398 finally {
399 closeSession(session);
400 }
401
402 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
403
404 if (isNew || !OrganizationModelImpl.COLUMN_BITMASK_ENABLED) {
405 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
406 }
407
408 else {
409 if ((organizationModelImpl.getColumnBitmask() &
410 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
411 Object[] args = new Object[] {
412 Long.valueOf(organizationModelImpl.getOriginalCompanyId())
413 };
414
415 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
416 args);
417 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
418 args);
419
420 args = new Object[] {
421 Long.valueOf(organizationModelImpl.getCompanyId())
422 };
423
424 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
425 args);
426 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
427 args);
428 }
429
430 if ((organizationModelImpl.getColumnBitmask() &
431 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LOCATIONS.getColumnBitmask()) != 0) {
432 Object[] args = new Object[] {
433 Long.valueOf(organizationModelImpl.getOriginalCompanyId())
434 };
435
436 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_LOCATIONS,
437 args);
438 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LOCATIONS,
439 args);
440
441 args = new Object[] {
442 Long.valueOf(organizationModelImpl.getCompanyId())
443 };
444
445 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_LOCATIONS,
446 args);
447 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LOCATIONS,
448 args);
449 }
450
451 if ((organizationModelImpl.getColumnBitmask() &
452 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_P.getColumnBitmask()) != 0) {
453 Object[] args = new Object[] {
454 Long.valueOf(organizationModelImpl.getOriginalCompanyId()),
455 Long.valueOf(organizationModelImpl.getOriginalParentOrganizationId())
456 };
457
458 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_P, args);
459 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_P,
460 args);
461
462 args = new Object[] {
463 Long.valueOf(organizationModelImpl.getCompanyId()),
464 Long.valueOf(organizationModelImpl.getParentOrganizationId())
465 };
466
467 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_P, args);
468 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_P,
469 args);
470 }
471 }
472
473 EntityCacheUtil.putResult(OrganizationModelImpl.ENTITY_CACHE_ENABLED,
474 OrganizationImpl.class, organization.getPrimaryKey(), organization);
475
476 if (isNew) {
477 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N,
478 new Object[] {
479 Long.valueOf(organization.getCompanyId()),
480
481 organization.getName()
482 }, organization);
483 }
484 else {
485 if ((organizationModelImpl.getColumnBitmask() &
486 FINDER_PATH_FETCH_BY_C_N.getColumnBitmask()) != 0) {
487 Object[] args = new Object[] {
488 Long.valueOf(organizationModelImpl.getOriginalCompanyId()),
489
490 organizationModelImpl.getOriginalName()
491 };
492
493 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_N, args);
494
495 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_N, args);
496
497 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N,
498 new Object[] {
499 Long.valueOf(organization.getCompanyId()),
500
501 organization.getName()
502 }, organization);
503 }
504 }
505
506 return organization;
507 }
508
509 protected Organization toUnwrappedModel(Organization organization) {
510 if (organization instanceof OrganizationImpl) {
511 return organization;
512 }
513
514 OrganizationImpl organizationImpl = new OrganizationImpl();
515
516 organizationImpl.setNew(organization.isNew());
517 organizationImpl.setPrimaryKey(organization.getPrimaryKey());
518
519 organizationImpl.setOrganizationId(organization.getOrganizationId());
520 organizationImpl.setCompanyId(organization.getCompanyId());
521 organizationImpl.setParentOrganizationId(organization.getParentOrganizationId());
522 organizationImpl.setTreePath(organization.getTreePath());
523 organizationImpl.setName(organization.getName());
524 organizationImpl.setType(organization.getType());
525 organizationImpl.setRecursable(organization.isRecursable());
526 organizationImpl.setRegionId(organization.getRegionId());
527 organizationImpl.setCountryId(organization.getCountryId());
528 organizationImpl.setStatusId(organization.getStatusId());
529 organizationImpl.setComments(organization.getComments());
530
531 return organizationImpl;
532 }
533
534
542 @Override
543 public Organization findByPrimaryKey(Serializable primaryKey)
544 throws NoSuchModelException, SystemException {
545 return findByPrimaryKey(((Long)primaryKey).longValue());
546 }
547
548
556 public Organization findByPrimaryKey(long organizationId)
557 throws NoSuchOrganizationException, SystemException {
558 Organization organization = fetchByPrimaryKey(organizationId);
559
560 if (organization == null) {
561 if (_log.isWarnEnabled()) {
562 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + organizationId);
563 }
564
565 throw new NoSuchOrganizationException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
566 organizationId);
567 }
568
569 return organization;
570 }
571
572
579 @Override
580 public Organization fetchByPrimaryKey(Serializable primaryKey)
581 throws SystemException {
582 return fetchByPrimaryKey(((Long)primaryKey).longValue());
583 }
584
585
592 public Organization fetchByPrimaryKey(long organizationId)
593 throws SystemException {
594 Organization organization = (Organization)EntityCacheUtil.getResult(OrganizationModelImpl.ENTITY_CACHE_ENABLED,
595 OrganizationImpl.class, organizationId);
596
597 if (organization == _nullOrganization) {
598 return null;
599 }
600
601 if (organization == null) {
602 Session session = null;
603
604 boolean hasException = false;
605
606 try {
607 session = openSession();
608
609 organization = (Organization)session.get(OrganizationImpl.class,
610 Long.valueOf(organizationId));
611 }
612 catch (Exception e) {
613 hasException = true;
614
615 throw processException(e);
616 }
617 finally {
618 if (organization != null) {
619 cacheResult(organization);
620 }
621 else if (!hasException) {
622 EntityCacheUtil.putResult(OrganizationModelImpl.ENTITY_CACHE_ENABLED,
623 OrganizationImpl.class, organizationId,
624 _nullOrganization);
625 }
626
627 closeSession(session);
628 }
629 }
630
631 return organization;
632 }
633
634
641 public List<Organization> findByCompanyId(long companyId)
642 throws SystemException {
643 return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
644 null);
645 }
646
647
660 public List<Organization> findByCompanyId(long companyId, int start, int end)
661 throws SystemException {
662 return findByCompanyId(companyId, start, end, null);
663 }
664
665
679 public List<Organization> findByCompanyId(long companyId, int start,
680 int end, OrderByComparator orderByComparator) throws SystemException {
681 FinderPath finderPath = null;
682 Object[] finderArgs = null;
683
684 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
685 (orderByComparator == null)) {
686 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID;
687 finderArgs = new Object[] { companyId };
688 }
689 else {
690 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID;
691 finderArgs = new Object[] { companyId, start, end, orderByComparator };
692 }
693
694 List<Organization> list = (List<Organization>)FinderCacheUtil.getResult(finderPath,
695 finderArgs, this);
696
697 if ((list != null) && !list.isEmpty()) {
698 for (Organization organization : list) {
699 if ((companyId != organization.getCompanyId())) {
700 list = null;
701
702 break;
703 }
704 }
705 }
706
707 if (list == null) {
708 StringBundler query = null;
709
710 if (orderByComparator != null) {
711 query = new StringBundler(3 +
712 (orderByComparator.getOrderByFields().length * 3));
713 }
714 else {
715 query = new StringBundler(3);
716 }
717
718 query.append(_SQL_SELECT_ORGANIZATION_WHERE);
719
720 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
721
722 if (orderByComparator != null) {
723 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
724 orderByComparator);
725 }
726
727 else {
728 query.append(OrganizationModelImpl.ORDER_BY_JPQL);
729 }
730
731 String sql = query.toString();
732
733 Session session = null;
734
735 try {
736 session = openSession();
737
738 Query q = session.createQuery(sql);
739
740 QueryPos qPos = QueryPos.getInstance(q);
741
742 qPos.add(companyId);
743
744 list = (List<Organization>)QueryUtil.list(q, getDialect(),
745 start, end);
746 }
747 catch (Exception e) {
748 throw processException(e);
749 }
750 finally {
751 if (list == null) {
752 FinderCacheUtil.removeResult(finderPath, finderArgs);
753 }
754 else {
755 cacheResult(list);
756
757 FinderCacheUtil.putResult(finderPath, finderArgs, list);
758 }
759
760 closeSession(session);
761 }
762 }
763
764 return list;
765 }
766
767
776 public Organization findByCompanyId_First(long companyId,
777 OrderByComparator orderByComparator)
778 throws NoSuchOrganizationException, SystemException {
779 Organization organization = fetchByCompanyId_First(companyId,
780 orderByComparator);
781
782 if (organization != null) {
783 return organization;
784 }
785
786 StringBundler msg = new StringBundler(4);
787
788 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
789
790 msg.append("companyId=");
791 msg.append(companyId);
792
793 msg.append(StringPool.CLOSE_CURLY_BRACE);
794
795 throw new NoSuchOrganizationException(msg.toString());
796 }
797
798
806 public Organization fetchByCompanyId_First(long companyId,
807 OrderByComparator orderByComparator) throws SystemException {
808 List<Organization> list = findByCompanyId(companyId, 0, 1,
809 orderByComparator);
810
811 if (!list.isEmpty()) {
812 return list.get(0);
813 }
814
815 return null;
816 }
817
818
827 public Organization findByCompanyId_Last(long companyId,
828 OrderByComparator orderByComparator)
829 throws NoSuchOrganizationException, SystemException {
830 Organization organization = fetchByCompanyId_Last(companyId,
831 orderByComparator);
832
833 if (organization != null) {
834 return organization;
835 }
836
837 StringBundler msg = new StringBundler(4);
838
839 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
840
841 msg.append("companyId=");
842 msg.append(companyId);
843
844 msg.append(StringPool.CLOSE_CURLY_BRACE);
845
846 throw new NoSuchOrganizationException(msg.toString());
847 }
848
849
857 public Organization fetchByCompanyId_Last(long companyId,
858 OrderByComparator orderByComparator) throws SystemException {
859 int count = countByCompanyId(companyId);
860
861 List<Organization> list = findByCompanyId(companyId, count - 1, count,
862 orderByComparator);
863
864 if (!list.isEmpty()) {
865 return list.get(0);
866 }
867
868 return null;
869 }
870
871
881 public Organization[] findByCompanyId_PrevAndNext(long organizationId,
882 long companyId, OrderByComparator orderByComparator)
883 throws NoSuchOrganizationException, SystemException {
884 Organization organization = findByPrimaryKey(organizationId);
885
886 Session session = null;
887
888 try {
889 session = openSession();
890
891 Organization[] array = new OrganizationImpl[3];
892
893 array[0] = getByCompanyId_PrevAndNext(session, organization,
894 companyId, orderByComparator, true);
895
896 array[1] = organization;
897
898 array[2] = getByCompanyId_PrevAndNext(session, organization,
899 companyId, orderByComparator, false);
900
901 return array;
902 }
903 catch (Exception e) {
904 throw processException(e);
905 }
906 finally {
907 closeSession(session);
908 }
909 }
910
911 protected Organization getByCompanyId_PrevAndNext(Session session,
912 Organization organization, long companyId,
913 OrderByComparator orderByComparator, boolean previous) {
914 StringBundler query = null;
915
916 if (orderByComparator != null) {
917 query = new StringBundler(6 +
918 (orderByComparator.getOrderByFields().length * 6));
919 }
920 else {
921 query = new StringBundler(3);
922 }
923
924 query.append(_SQL_SELECT_ORGANIZATION_WHERE);
925
926 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
927
928 if (orderByComparator != null) {
929 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
930
931 if (orderByConditionFields.length > 0) {
932 query.append(WHERE_AND);
933 }
934
935 for (int i = 0; i < orderByConditionFields.length; i++) {
936 query.append(_ORDER_BY_ENTITY_ALIAS);
937 query.append(orderByConditionFields[i]);
938
939 if ((i + 1) < orderByConditionFields.length) {
940 if (orderByComparator.isAscending() ^ previous) {
941 query.append(WHERE_GREATER_THAN_HAS_NEXT);
942 }
943 else {
944 query.append(WHERE_LESSER_THAN_HAS_NEXT);
945 }
946 }
947 else {
948 if (orderByComparator.isAscending() ^ previous) {
949 query.append(WHERE_GREATER_THAN);
950 }
951 else {
952 query.append(WHERE_LESSER_THAN);
953 }
954 }
955 }
956
957 query.append(ORDER_BY_CLAUSE);
958
959 String[] orderByFields = orderByComparator.getOrderByFields();
960
961 for (int i = 0; i < orderByFields.length; i++) {
962 query.append(_ORDER_BY_ENTITY_ALIAS);
963 query.append(orderByFields[i]);
964
965 if ((i + 1) < orderByFields.length) {
966 if (orderByComparator.isAscending() ^ previous) {
967 query.append(ORDER_BY_ASC_HAS_NEXT);
968 }
969 else {
970 query.append(ORDER_BY_DESC_HAS_NEXT);
971 }
972 }
973 else {
974 if (orderByComparator.isAscending() ^ previous) {
975 query.append(ORDER_BY_ASC);
976 }
977 else {
978 query.append(ORDER_BY_DESC);
979 }
980 }
981 }
982 }
983
984 else {
985 query.append(OrganizationModelImpl.ORDER_BY_JPQL);
986 }
987
988 String sql = query.toString();
989
990 Query q = session.createQuery(sql);
991
992 q.setFirstResult(0);
993 q.setMaxResults(2);
994
995 QueryPos qPos = QueryPos.getInstance(q);
996
997 qPos.add(companyId);
998
999 if (orderByComparator != null) {
1000 Object[] values = orderByComparator.getOrderByConditionValues(organization);
1001
1002 for (Object value : values) {
1003 qPos.add(value);
1004 }
1005 }
1006
1007 List<Organization> list = q.list();
1008
1009 if (list.size() == 2) {
1010 return list.get(1);
1011 }
1012 else {
1013 return null;
1014 }
1015 }
1016
1017
1024 public List<Organization> filterFindByCompanyId(long companyId)
1025 throws SystemException {
1026 return filterFindByCompanyId(companyId, QueryUtil.ALL_POS,
1027 QueryUtil.ALL_POS, null);
1028 }
1029
1030
1043 public List<Organization> filterFindByCompanyId(long companyId, int start,
1044 int end) throws SystemException {
1045 return filterFindByCompanyId(companyId, start, end, null);
1046 }
1047
1048
1062 public List<Organization> filterFindByCompanyId(long companyId, int start,
1063 int end, OrderByComparator orderByComparator) throws SystemException {
1064 if (!InlineSQLHelperUtil.isEnabled()) {
1065 return findByCompanyId(companyId, start, end, orderByComparator);
1066 }
1067
1068 StringBundler query = null;
1069
1070 if (orderByComparator != null) {
1071 query = new StringBundler(3 +
1072 (orderByComparator.getOrderByFields().length * 3));
1073 }
1074 else {
1075 query = new StringBundler(3);
1076 }
1077
1078 if (getDB().isSupportsInlineDistinct()) {
1079 query.append(_FILTER_SQL_SELECT_ORGANIZATION_WHERE);
1080 }
1081 else {
1082 query.append(_FILTER_SQL_SELECT_ORGANIZATION_NO_INLINE_DISTINCT_WHERE_1);
1083 }
1084
1085 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1086
1087 if (!getDB().isSupportsInlineDistinct()) {
1088 query.append(_FILTER_SQL_SELECT_ORGANIZATION_NO_INLINE_DISTINCT_WHERE_2);
1089 }
1090
1091 if (orderByComparator != null) {
1092 if (getDB().isSupportsInlineDistinct()) {
1093 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1094 orderByComparator);
1095 }
1096 else {
1097 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
1098 orderByComparator);
1099 }
1100 }
1101
1102 else {
1103 if (getDB().isSupportsInlineDistinct()) {
1104 query.append(OrganizationModelImpl.ORDER_BY_JPQL);
1105 }
1106 else {
1107 query.append(OrganizationModelImpl.ORDER_BY_SQL);
1108 }
1109 }
1110
1111 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1112 Organization.class.getName(),
1113 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
1114
1115 Session session = null;
1116
1117 try {
1118 session = openSession();
1119
1120 SQLQuery q = session.createSQLQuery(sql);
1121
1122 if (getDB().isSupportsInlineDistinct()) {
1123 q.addEntity(_FILTER_ENTITY_ALIAS, OrganizationImpl.class);
1124 }
1125 else {
1126 q.addEntity(_FILTER_ENTITY_TABLE, OrganizationImpl.class);
1127 }
1128
1129 QueryPos qPos = QueryPos.getInstance(q);
1130
1131 qPos.add(companyId);
1132
1133 return (List<Organization>)QueryUtil.list(q, getDialect(), start,
1134 end);
1135 }
1136 catch (Exception e) {
1137 throw processException(e);
1138 }
1139 finally {
1140 closeSession(session);
1141 }
1142 }
1143
1144
1154 public Organization[] filterFindByCompanyId_PrevAndNext(
1155 long organizationId, long companyId, OrderByComparator orderByComparator)
1156 throws NoSuchOrganizationException, SystemException {
1157 if (!InlineSQLHelperUtil.isEnabled()) {
1158 return findByCompanyId_PrevAndNext(organizationId, companyId,
1159 orderByComparator);
1160 }
1161
1162 Organization organization = findByPrimaryKey(organizationId);
1163
1164 Session session = null;
1165
1166 try {
1167 session = openSession();
1168
1169 Organization[] array = new OrganizationImpl[3];
1170
1171 array[0] = filterGetByCompanyId_PrevAndNext(session, organization,
1172 companyId, orderByComparator, true);
1173
1174 array[1] = organization;
1175
1176 array[2] = filterGetByCompanyId_PrevAndNext(session, organization,
1177 companyId, orderByComparator, false);
1178
1179 return array;
1180 }
1181 catch (Exception e) {
1182 throw processException(e);
1183 }
1184 finally {
1185 closeSession(session);
1186 }
1187 }
1188
1189 protected Organization filterGetByCompanyId_PrevAndNext(Session session,
1190 Organization organization, long companyId,
1191 OrderByComparator orderByComparator, boolean previous) {
1192 StringBundler query = null;
1193
1194 if (orderByComparator != null) {
1195 query = new StringBundler(6 +
1196 (orderByComparator.getOrderByFields().length * 6));
1197 }
1198 else {
1199 query = new StringBundler(3);
1200 }
1201
1202 if (getDB().isSupportsInlineDistinct()) {
1203 query.append(_FILTER_SQL_SELECT_ORGANIZATION_WHERE);
1204 }
1205 else {
1206 query.append(_FILTER_SQL_SELECT_ORGANIZATION_NO_INLINE_DISTINCT_WHERE_1);
1207 }
1208
1209 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1210
1211 if (!getDB().isSupportsInlineDistinct()) {
1212 query.append(_FILTER_SQL_SELECT_ORGANIZATION_NO_INLINE_DISTINCT_WHERE_2);
1213 }
1214
1215 if (orderByComparator != null) {
1216 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1217
1218 if (orderByConditionFields.length > 0) {
1219 query.append(WHERE_AND);
1220 }
1221
1222 for (int i = 0; i < orderByConditionFields.length; i++) {
1223 if (getDB().isSupportsInlineDistinct()) {
1224 query.append(_ORDER_BY_ENTITY_ALIAS);
1225 }
1226 else {
1227 query.append(_ORDER_BY_ENTITY_TABLE);
1228 }
1229
1230 query.append(orderByConditionFields[i]);
1231
1232 if ((i + 1) < orderByConditionFields.length) {
1233 if (orderByComparator.isAscending() ^ previous) {
1234 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1235 }
1236 else {
1237 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1238 }
1239 }
1240 else {
1241 if (orderByComparator.isAscending() ^ previous) {
1242 query.append(WHERE_GREATER_THAN);
1243 }
1244 else {
1245 query.append(WHERE_LESSER_THAN);
1246 }
1247 }
1248 }
1249
1250 query.append(ORDER_BY_CLAUSE);
1251
1252 String[] orderByFields = orderByComparator.getOrderByFields();
1253
1254 for (int i = 0; i < orderByFields.length; i++) {
1255 if (getDB().isSupportsInlineDistinct()) {
1256 query.append(_ORDER_BY_ENTITY_ALIAS);
1257 }
1258 else {
1259 query.append(_ORDER_BY_ENTITY_TABLE);
1260 }
1261
1262 query.append(orderByFields[i]);
1263
1264 if ((i + 1) < orderByFields.length) {
1265 if (orderByComparator.isAscending() ^ previous) {
1266 query.append(ORDER_BY_ASC_HAS_NEXT);
1267 }
1268 else {
1269 query.append(ORDER_BY_DESC_HAS_NEXT);
1270 }
1271 }
1272 else {
1273 if (orderByComparator.isAscending() ^ previous) {
1274 query.append(ORDER_BY_ASC);
1275 }
1276 else {
1277 query.append(ORDER_BY_DESC);
1278 }
1279 }
1280 }
1281 }
1282
1283 else {
1284 if (getDB().isSupportsInlineDistinct()) {
1285 query.append(OrganizationModelImpl.ORDER_BY_JPQL);
1286 }
1287 else {
1288 query.append(OrganizationModelImpl.ORDER_BY_SQL);
1289 }
1290 }
1291
1292 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1293 Organization.class.getName(),
1294 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
1295
1296 SQLQuery q = session.createSQLQuery(sql);
1297
1298 q.setFirstResult(0);
1299 q.setMaxResults(2);
1300
1301 if (getDB().isSupportsInlineDistinct()) {
1302 q.addEntity(_FILTER_ENTITY_ALIAS, OrganizationImpl.class);
1303 }
1304 else {
1305 q.addEntity(_FILTER_ENTITY_TABLE, OrganizationImpl.class);
1306 }
1307
1308 QueryPos qPos = QueryPos.getInstance(q);
1309
1310 qPos.add(companyId);
1311
1312 if (orderByComparator != null) {
1313 Object[] values = orderByComparator.getOrderByConditionValues(organization);
1314
1315 for (Object value : values) {
1316 qPos.add(value);
1317 }
1318 }
1319
1320 List<Organization> list = q.list();
1321
1322 if (list.size() == 2) {
1323 return list.get(1);
1324 }
1325 else {
1326 return null;
1327 }
1328 }
1329
1330
1337 public List<Organization> findByLocations(long companyId)
1338 throws SystemException {
1339 return findByLocations(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
1340 null);
1341 }
1342
1343
1356 public List<Organization> findByLocations(long companyId, int start, int end)
1357 throws SystemException {
1358 return findByLocations(companyId, start, end, null);
1359 }
1360
1361
1375 public List<Organization> findByLocations(long companyId, int start,
1376 int end, OrderByComparator orderByComparator) throws SystemException {
1377 FinderPath finderPath = null;
1378 Object[] finderArgs = null;
1379
1380 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1381 (orderByComparator == null)) {
1382 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LOCATIONS;
1383 finderArgs = new Object[] { companyId };
1384 }
1385 else {
1386 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_LOCATIONS;
1387 finderArgs = new Object[] { companyId, start, end, orderByComparator };
1388 }
1389
1390 List<Organization> list = (List<Organization>)FinderCacheUtil.getResult(finderPath,
1391 finderArgs, this);
1392
1393 if ((list != null) && !list.isEmpty()) {
1394 for (Organization organization : list) {
1395 if ((companyId != organization.getCompanyId())) {
1396 list = null;
1397
1398 break;
1399 }
1400 }
1401 }
1402
1403 if (list == null) {
1404 StringBundler query = null;
1405
1406 if (orderByComparator != null) {
1407 query = new StringBundler(3 +
1408 (orderByComparator.getOrderByFields().length * 3));
1409 }
1410 else {
1411 query = new StringBundler(3);
1412 }
1413
1414 query.append(_SQL_SELECT_ORGANIZATION_WHERE);
1415
1416 query.append(_FINDER_COLUMN_LOCATIONS_COMPANYID_2);
1417
1418 if (orderByComparator != null) {
1419 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1420 orderByComparator);
1421 }
1422
1423 else {
1424 query.append(OrganizationModelImpl.ORDER_BY_JPQL);
1425 }
1426
1427 String sql = query.toString();
1428
1429 Session session = null;
1430
1431 try {
1432 session = openSession();
1433
1434 Query q = session.createQuery(sql);
1435
1436 QueryPos qPos = QueryPos.getInstance(q);
1437
1438 qPos.add(companyId);
1439
1440 list = (List<Organization>)QueryUtil.list(q, getDialect(),
1441 start, end);
1442 }
1443 catch (Exception e) {
1444 throw processException(e);
1445 }
1446 finally {
1447 if (list == null) {
1448 FinderCacheUtil.removeResult(finderPath, finderArgs);
1449 }
1450 else {
1451 cacheResult(list);
1452
1453 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1454 }
1455
1456 closeSession(session);
1457 }
1458 }
1459
1460 return list;
1461 }
1462
1463
1472 public Organization findByLocations_First(long companyId,
1473 OrderByComparator orderByComparator)
1474 throws NoSuchOrganizationException, SystemException {
1475 Organization organization = fetchByLocations_First(companyId,
1476 orderByComparator);
1477
1478 if (organization != null) {
1479 return organization;
1480 }
1481
1482 StringBundler msg = new StringBundler(4);
1483
1484 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1485
1486 msg.append("companyId=");
1487 msg.append(companyId);
1488
1489 msg.append(StringPool.CLOSE_CURLY_BRACE);
1490
1491 throw new NoSuchOrganizationException(msg.toString());
1492 }
1493
1494
1502 public Organization fetchByLocations_First(long companyId,
1503 OrderByComparator orderByComparator) throws SystemException {
1504 List<Organization> list = findByLocations(companyId, 0, 1,
1505 orderByComparator);
1506
1507 if (!list.isEmpty()) {
1508 return list.get(0);
1509 }
1510
1511 return null;
1512 }
1513
1514
1523 public Organization findByLocations_Last(long companyId,
1524 OrderByComparator orderByComparator)
1525 throws NoSuchOrganizationException, SystemException {
1526 Organization organization = fetchByLocations_Last(companyId,
1527 orderByComparator);
1528
1529 if (organization != null) {
1530 return organization;
1531 }
1532
1533 StringBundler msg = new StringBundler(4);
1534
1535 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1536
1537 msg.append("companyId=");
1538 msg.append(companyId);
1539
1540 msg.append(StringPool.CLOSE_CURLY_BRACE);
1541
1542 throw new NoSuchOrganizationException(msg.toString());
1543 }
1544
1545
1553 public Organization fetchByLocations_Last(long companyId,
1554 OrderByComparator orderByComparator) throws SystemException {
1555 int count = countByLocations(companyId);
1556
1557 List<Organization> list = findByLocations(companyId, count - 1, count,
1558 orderByComparator);
1559
1560 if (!list.isEmpty()) {
1561 return list.get(0);
1562 }
1563
1564 return null;
1565 }
1566
1567
1577 public Organization[] findByLocations_PrevAndNext(long organizationId,
1578 long companyId, OrderByComparator orderByComparator)
1579 throws NoSuchOrganizationException, SystemException {
1580 Organization organization = findByPrimaryKey(organizationId);
1581
1582 Session session = null;
1583
1584 try {
1585 session = openSession();
1586
1587 Organization[] array = new OrganizationImpl[3];
1588
1589 array[0] = getByLocations_PrevAndNext(session, organization,
1590 companyId, orderByComparator, true);
1591
1592 array[1] = organization;
1593
1594 array[2] = getByLocations_PrevAndNext(session, organization,
1595 companyId, orderByComparator, false);
1596
1597 return array;
1598 }
1599 catch (Exception e) {
1600 throw processException(e);
1601 }
1602 finally {
1603 closeSession(session);
1604 }
1605 }
1606
1607 protected Organization getByLocations_PrevAndNext(Session session,
1608 Organization organization, long companyId,
1609 OrderByComparator orderByComparator, boolean previous) {
1610 StringBundler query = null;
1611
1612 if (orderByComparator != null) {
1613 query = new StringBundler(6 +
1614 (orderByComparator.getOrderByFields().length * 6));
1615 }
1616 else {
1617 query = new StringBundler(3);
1618 }
1619
1620 query.append(_SQL_SELECT_ORGANIZATION_WHERE);
1621
1622 query.append(_FINDER_COLUMN_LOCATIONS_COMPANYID_2);
1623
1624 if (orderByComparator != null) {
1625 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1626
1627 if (orderByConditionFields.length > 0) {
1628 query.append(WHERE_AND);
1629 }
1630
1631 for (int i = 0; i < orderByConditionFields.length; i++) {
1632 query.append(_ORDER_BY_ENTITY_ALIAS);
1633 query.append(orderByConditionFields[i]);
1634
1635 if ((i + 1) < orderByConditionFields.length) {
1636 if (orderByComparator.isAscending() ^ previous) {
1637 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1638 }
1639 else {
1640 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1641 }
1642 }
1643 else {
1644 if (orderByComparator.isAscending() ^ previous) {
1645 query.append(WHERE_GREATER_THAN);
1646 }
1647 else {
1648 query.append(WHERE_LESSER_THAN);
1649 }
1650 }
1651 }
1652
1653 query.append(ORDER_BY_CLAUSE);
1654
1655 String[] orderByFields = orderByComparator.getOrderByFields();
1656
1657 for (int i = 0; i < orderByFields.length; i++) {
1658 query.append(_ORDER_BY_ENTITY_ALIAS);
1659 query.append(orderByFields[i]);
1660
1661 if ((i + 1) < orderByFields.length) {
1662 if (orderByComparator.isAscending() ^ previous) {
1663 query.append(ORDER_BY_ASC_HAS_NEXT);
1664 }
1665 else {
1666 query.append(ORDER_BY_DESC_HAS_NEXT);
1667 }
1668 }
1669 else {
1670 if (orderByComparator.isAscending() ^ previous) {
1671 query.append(ORDER_BY_ASC);
1672 }
1673 else {
1674 query.append(ORDER_BY_DESC);
1675 }
1676 }
1677 }
1678 }
1679
1680 else {
1681 query.append(OrganizationModelImpl.ORDER_BY_JPQL);
1682 }
1683
1684 String sql = query.toString();
1685
1686 Query q = session.createQuery(sql);
1687
1688 q.setFirstResult(0);
1689 q.setMaxResults(2);
1690
1691 QueryPos qPos = QueryPos.getInstance(q);
1692
1693 qPos.add(companyId);
1694
1695 if (orderByComparator != null) {
1696 Object[] values = orderByComparator.getOrderByConditionValues(organization);
1697
1698 for (Object value : values) {
1699 qPos.add(value);
1700 }
1701 }
1702
1703 List<Organization> list = q.list();
1704
1705 if (list.size() == 2) {
1706 return list.get(1);
1707 }
1708 else {
1709 return null;
1710 }
1711 }
1712
1713
1720 public List<Organization> filterFindByLocations(long companyId)
1721 throws SystemException {
1722 return filterFindByLocations(companyId, QueryUtil.ALL_POS,
1723 QueryUtil.ALL_POS, null);
1724 }
1725
1726
1739 public List<Organization> filterFindByLocations(long companyId, int start,
1740 int end) throws SystemException {
1741 return filterFindByLocations(companyId, start, end, null);
1742 }
1743
1744
1758 public List<Organization> filterFindByLocations(long companyId, int start,
1759 int end, OrderByComparator orderByComparator) throws SystemException {
1760 if (!InlineSQLHelperUtil.isEnabled()) {
1761 return findByLocations(companyId, start, end, orderByComparator);
1762 }
1763
1764 StringBundler query = null;
1765
1766 if (orderByComparator != null) {
1767 query = new StringBundler(3 +
1768 (orderByComparator.getOrderByFields().length * 3));
1769 }
1770 else {
1771 query = new StringBundler(3);
1772 }
1773
1774 if (getDB().isSupportsInlineDistinct()) {
1775 query.append(_FILTER_SQL_SELECT_ORGANIZATION_WHERE);
1776 }
1777 else {
1778 query.append(_FILTER_SQL_SELECT_ORGANIZATION_NO_INLINE_DISTINCT_WHERE_1);
1779 }
1780
1781 query.append(_FINDER_COLUMN_LOCATIONS_COMPANYID_2);
1782
1783 if (!getDB().isSupportsInlineDistinct()) {
1784 query.append(_FILTER_SQL_SELECT_ORGANIZATION_NO_INLINE_DISTINCT_WHERE_2);
1785 }
1786
1787 if (orderByComparator != null) {
1788 if (getDB().isSupportsInlineDistinct()) {
1789 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1790 orderByComparator);
1791 }
1792 else {
1793 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
1794 orderByComparator);
1795 }
1796 }
1797
1798 else {
1799 if (getDB().isSupportsInlineDistinct()) {
1800 query.append(OrganizationModelImpl.ORDER_BY_JPQL);
1801 }
1802 else {
1803 query.append(OrganizationModelImpl.ORDER_BY_SQL);
1804 }
1805 }
1806
1807 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1808 Organization.class.getName(),
1809 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
1810
1811 Session session = null;
1812
1813 try {
1814 session = openSession();
1815
1816 SQLQuery q = session.createSQLQuery(sql);
1817
1818 if (getDB().isSupportsInlineDistinct()) {
1819 q.addEntity(_FILTER_ENTITY_ALIAS, OrganizationImpl.class);
1820 }
1821 else {
1822 q.addEntity(_FILTER_ENTITY_TABLE, OrganizationImpl.class);
1823 }
1824
1825 QueryPos qPos = QueryPos.getInstance(q);
1826
1827 qPos.add(companyId);
1828
1829 return (List<Organization>)QueryUtil.list(q, getDialect(), start,
1830 end);
1831 }
1832 catch (Exception e) {
1833 throw processException(e);
1834 }
1835 finally {
1836 closeSession(session);
1837 }
1838 }
1839
1840
1850 public Organization[] filterFindByLocations_PrevAndNext(
1851 long organizationId, long companyId, OrderByComparator orderByComparator)
1852 throws NoSuchOrganizationException, SystemException {
1853 if (!InlineSQLHelperUtil.isEnabled()) {
1854 return findByLocations_PrevAndNext(organizationId, companyId,
1855 orderByComparator);
1856 }
1857
1858 Organization organization = findByPrimaryKey(organizationId);
1859
1860 Session session = null;
1861
1862 try {
1863 session = openSession();
1864
1865 Organization[] array = new OrganizationImpl[3];
1866
1867 array[0] = filterGetByLocations_PrevAndNext(session, organization,
1868 companyId, orderByComparator, true);
1869
1870 array[1] = organization;
1871
1872 array[2] = filterGetByLocations_PrevAndNext(session, organization,
1873 companyId, orderByComparator, false);
1874
1875 return array;
1876 }
1877 catch (Exception e) {
1878 throw processException(e);
1879 }
1880 finally {
1881 closeSession(session);
1882 }
1883 }
1884
1885 protected Organization filterGetByLocations_PrevAndNext(Session session,
1886 Organization organization, long companyId,
1887 OrderByComparator orderByComparator, boolean previous) {
1888 StringBundler query = null;
1889
1890 if (orderByComparator != null) {
1891 query = new StringBundler(6 +
1892 (orderByComparator.getOrderByFields().length * 6));
1893 }
1894 else {
1895 query = new StringBundler(3);
1896 }
1897
1898 if (getDB().isSupportsInlineDistinct()) {
1899 query.append(_FILTER_SQL_SELECT_ORGANIZATION_WHERE);
1900 }
1901 else {
1902 query.append(_FILTER_SQL_SELECT_ORGANIZATION_NO_INLINE_DISTINCT_WHERE_1);
1903 }
1904
1905 query.append(_FINDER_COLUMN_LOCATIONS_COMPANYID_2);
1906
1907 if (!getDB().isSupportsInlineDistinct()) {
1908 query.append(_FILTER_SQL_SELECT_ORGANIZATION_NO_INLINE_DISTINCT_WHERE_2);
1909 }
1910
1911 if (orderByComparator != null) {
1912 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1913
1914 if (orderByConditionFields.length > 0) {
1915 query.append(WHERE_AND);
1916 }
1917
1918 for (int i = 0; i < orderByConditionFields.length; i++) {
1919 if (getDB().isSupportsInlineDistinct()) {
1920 query.append(_ORDER_BY_ENTITY_ALIAS);
1921 }
1922 else {
1923 query.append(_ORDER_BY_ENTITY_TABLE);
1924 }
1925
1926 query.append(orderByConditionFields[i]);
1927
1928 if ((i + 1) < orderByConditionFields.length) {
1929 if (orderByComparator.isAscending() ^ previous) {
1930 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1931 }
1932 else {
1933 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1934 }
1935 }
1936 else {
1937 if (orderByComparator.isAscending() ^ previous) {
1938 query.append(WHERE_GREATER_THAN);
1939 }
1940 else {
1941 query.append(WHERE_LESSER_THAN);
1942 }
1943 }
1944 }
1945
1946 query.append(ORDER_BY_CLAUSE);
1947
1948 String[] orderByFields = orderByComparator.getOrderByFields();
1949
1950 for (int i = 0; i < orderByFields.length; i++) {
1951 if (getDB().isSupportsInlineDistinct()) {
1952 query.append(_ORDER_BY_ENTITY_ALIAS);
1953 }
1954 else {
1955 query.append(_ORDER_BY_ENTITY_TABLE);
1956 }
1957
1958 query.append(orderByFields[i]);
1959
1960 if ((i + 1) < orderByFields.length) {
1961 if (orderByComparator.isAscending() ^ previous) {
1962 query.append(ORDER_BY_ASC_HAS_NEXT);
1963 }
1964 else {
1965 query.append(ORDER_BY_DESC_HAS_NEXT);
1966 }
1967 }
1968 else {
1969 if (orderByComparator.isAscending() ^ previous) {
1970 query.append(ORDER_BY_ASC);
1971 }
1972 else {
1973 query.append(ORDER_BY_DESC);
1974 }
1975 }
1976 }
1977 }
1978
1979 else {
1980 if (getDB().isSupportsInlineDistinct()) {
1981 query.append(OrganizationModelImpl.ORDER_BY_JPQL);
1982 }
1983 else {
1984 query.append(OrganizationModelImpl.ORDER_BY_SQL);
1985 }
1986 }
1987
1988 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1989 Organization.class.getName(),
1990 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
1991
1992 SQLQuery q = session.createSQLQuery(sql);
1993
1994 q.setFirstResult(0);
1995 q.setMaxResults(2);
1996
1997 if (getDB().isSupportsInlineDistinct()) {
1998 q.addEntity(_FILTER_ENTITY_ALIAS, OrganizationImpl.class);
1999 }
2000 else {
2001 q.addEntity(_FILTER_ENTITY_TABLE, OrganizationImpl.class);
2002 }
2003
2004 QueryPos qPos = QueryPos.getInstance(q);
2005
2006 qPos.add(companyId);
2007
2008 if (orderByComparator != null) {
2009 Object[] values = orderByComparator.getOrderByConditionValues(organization);
2010
2011 for (Object value : values) {
2012 qPos.add(value);
2013 }
2014 }
2015
2016 List<Organization> list = q.list();
2017
2018 if (list.size() == 2) {
2019 return list.get(1);
2020 }
2021 else {
2022 return null;
2023 }
2024 }
2025
2026
2034 public List<Organization> findByC_P(long companyId,
2035 long parentOrganizationId) throws SystemException {
2036 return findByC_P(companyId, parentOrganizationId, QueryUtil.ALL_POS,
2037 QueryUtil.ALL_POS, null);
2038 }
2039
2040
2054 public List<Organization> findByC_P(long companyId,
2055 long parentOrganizationId, int start, int end)
2056 throws SystemException {
2057 return findByC_P(companyId, parentOrganizationId, start, end, null);
2058 }
2059
2060
2075 public List<Organization> findByC_P(long companyId,
2076 long parentOrganizationId, int start, int end,
2077 OrderByComparator orderByComparator) throws SystemException {
2078 FinderPath finderPath = null;
2079 Object[] finderArgs = null;
2080
2081 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2082 (orderByComparator == null)) {
2083 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_P;
2084 finderArgs = new Object[] { companyId, parentOrganizationId };
2085 }
2086 else {
2087 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_P;
2088 finderArgs = new Object[] {
2089 companyId, parentOrganizationId,
2090
2091 start, end, orderByComparator
2092 };
2093 }
2094
2095 List<Organization> list = (List<Organization>)FinderCacheUtil.getResult(finderPath,
2096 finderArgs, this);
2097
2098 if ((list != null) && !list.isEmpty()) {
2099 for (Organization organization : list) {
2100 if ((companyId != organization.getCompanyId()) ||
2101 (parentOrganizationId != organization.getParentOrganizationId())) {
2102 list = null;
2103
2104 break;
2105 }
2106 }
2107 }
2108
2109 if (list == null) {
2110 StringBundler query = null;
2111
2112 if (orderByComparator != null) {
2113 query = new StringBundler(4 +
2114 (orderByComparator.getOrderByFields().length * 3));
2115 }
2116 else {
2117 query = new StringBundler(4);
2118 }
2119
2120 query.append(_SQL_SELECT_ORGANIZATION_WHERE);
2121
2122 query.append(_FINDER_COLUMN_C_P_COMPANYID_2);
2123
2124 query.append(_FINDER_COLUMN_C_P_PARENTORGANIZATIONID_2);
2125
2126 if (orderByComparator != null) {
2127 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2128 orderByComparator);
2129 }
2130
2131 else {
2132 query.append(OrganizationModelImpl.ORDER_BY_JPQL);
2133 }
2134
2135 String sql = query.toString();
2136
2137 Session session = null;
2138
2139 try {
2140 session = openSession();
2141
2142 Query q = session.createQuery(sql);
2143
2144 QueryPos qPos = QueryPos.getInstance(q);
2145
2146 qPos.add(companyId);
2147
2148 qPos.add(parentOrganizationId);
2149
2150 list = (List<Organization>)QueryUtil.list(q, getDialect(),
2151 start, end);
2152 }
2153 catch (Exception e) {
2154 throw processException(e);
2155 }
2156 finally {
2157 if (list == null) {
2158 FinderCacheUtil.removeResult(finderPath, finderArgs);
2159 }
2160 else {
2161 cacheResult(list);
2162
2163 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2164 }
2165
2166 closeSession(session);
2167 }
2168 }
2169
2170 return list;
2171 }
2172
2173
2183 public Organization findByC_P_First(long companyId,
2184 long parentOrganizationId, OrderByComparator orderByComparator)
2185 throws NoSuchOrganizationException, SystemException {
2186 Organization organization = fetchByC_P_First(companyId,
2187 parentOrganizationId, orderByComparator);
2188
2189 if (organization != null) {
2190 return organization;
2191 }
2192
2193 StringBundler msg = new StringBundler(6);
2194
2195 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2196
2197 msg.append("companyId=");
2198 msg.append(companyId);
2199
2200 msg.append(", parentOrganizationId=");
2201 msg.append(parentOrganizationId);
2202
2203 msg.append(StringPool.CLOSE_CURLY_BRACE);
2204
2205 throw new NoSuchOrganizationException(msg.toString());
2206 }
2207
2208
2217 public Organization fetchByC_P_First(long companyId,
2218 long parentOrganizationId, OrderByComparator orderByComparator)
2219 throws SystemException {
2220 List<Organization> list = findByC_P(companyId, parentOrganizationId, 0,
2221 1, orderByComparator);
2222
2223 if (!list.isEmpty()) {
2224 return list.get(0);
2225 }
2226
2227 return null;
2228 }
2229
2230
2240 public Organization findByC_P_Last(long companyId,
2241 long parentOrganizationId, OrderByComparator orderByComparator)
2242 throws NoSuchOrganizationException, SystemException {
2243 Organization organization = fetchByC_P_Last(companyId,
2244 parentOrganizationId, orderByComparator);
2245
2246 if (organization != null) {
2247 return organization;
2248 }
2249
2250 StringBundler msg = new StringBundler(6);
2251
2252 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2253
2254 msg.append("companyId=");
2255 msg.append(companyId);
2256
2257 msg.append(", parentOrganizationId=");
2258 msg.append(parentOrganizationId);
2259
2260 msg.append(StringPool.CLOSE_CURLY_BRACE);
2261
2262 throw new NoSuchOrganizationException(msg.toString());
2263 }
2264
2265
2274 public Organization fetchByC_P_Last(long companyId,
2275 long parentOrganizationId, OrderByComparator orderByComparator)
2276 throws SystemException {
2277 int count = countByC_P(companyId, parentOrganizationId);
2278
2279 List<Organization> list = findByC_P(companyId, parentOrganizationId,
2280 count - 1, count, orderByComparator);
2281
2282 if (!list.isEmpty()) {
2283 return list.get(0);
2284 }
2285
2286 return null;
2287 }
2288
2289
2300 public Organization[] findByC_P_PrevAndNext(long organizationId,
2301 long companyId, long parentOrganizationId,
2302 OrderByComparator orderByComparator)
2303 throws NoSuchOrganizationException, SystemException {
2304 Organization organization = findByPrimaryKey(organizationId);
2305
2306 Session session = null;
2307
2308 try {
2309 session = openSession();
2310
2311 Organization[] array = new OrganizationImpl[3];
2312
2313 array[0] = getByC_P_PrevAndNext(session, organization, companyId,
2314 parentOrganizationId, orderByComparator, true);
2315
2316 array[1] = organization;
2317
2318 array[2] = getByC_P_PrevAndNext(session, organization, companyId,
2319 parentOrganizationId, orderByComparator, false);
2320
2321 return array;
2322 }
2323 catch (Exception e) {
2324 throw processException(e);
2325 }
2326 finally {
2327 closeSession(session);
2328 }
2329 }
2330
2331 protected Organization getByC_P_PrevAndNext(Session session,
2332 Organization organization, long companyId, long parentOrganizationId,
2333 OrderByComparator orderByComparator, boolean previous) {
2334 StringBundler query = null;
2335
2336 if (orderByComparator != null) {
2337 query = new StringBundler(6 +
2338 (orderByComparator.getOrderByFields().length * 6));
2339 }
2340 else {
2341 query = new StringBundler(3);
2342 }
2343
2344 query.append(_SQL_SELECT_ORGANIZATION_WHERE);
2345
2346 query.append(_FINDER_COLUMN_C_P_COMPANYID_2);
2347
2348 query.append(_FINDER_COLUMN_C_P_PARENTORGANIZATIONID_2);
2349
2350 if (orderByComparator != null) {
2351 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2352
2353 if (orderByConditionFields.length > 0) {
2354 query.append(WHERE_AND);
2355 }
2356
2357 for (int i = 0; i < orderByConditionFields.length; i++) {
2358 query.append(_ORDER_BY_ENTITY_ALIAS);
2359 query.append(orderByConditionFields[i]);
2360
2361 if ((i + 1) < orderByConditionFields.length) {
2362 if (orderByComparator.isAscending() ^ previous) {
2363 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2364 }
2365 else {
2366 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2367 }
2368 }
2369 else {
2370 if (orderByComparator.isAscending() ^ previous) {
2371 query.append(WHERE_GREATER_THAN);
2372 }
2373 else {
2374 query.append(WHERE_LESSER_THAN);
2375 }
2376 }
2377 }
2378
2379 query.append(ORDER_BY_CLAUSE);
2380
2381 String[] orderByFields = orderByComparator.getOrderByFields();
2382
2383 for (int i = 0; i < orderByFields.length; i++) {
2384 query.append(_ORDER_BY_ENTITY_ALIAS);
2385 query.append(orderByFields[i]);
2386
2387 if ((i + 1) < orderByFields.length) {
2388 if (orderByComparator.isAscending() ^ previous) {
2389 query.append(ORDER_BY_ASC_HAS_NEXT);
2390 }
2391 else {
2392 query.append(ORDER_BY_DESC_HAS_NEXT);
2393 }
2394 }
2395 else {
2396 if (orderByComparator.isAscending() ^ previous) {
2397 query.append(ORDER_BY_ASC);
2398 }
2399 else {
2400 query.append(ORDER_BY_DESC);
2401 }
2402 }
2403 }
2404 }
2405
2406 else {
2407 query.append(OrganizationModelImpl.ORDER_BY_JPQL);
2408 }
2409
2410 String sql = query.toString();
2411
2412 Query q = session.createQuery(sql);
2413
2414 q.setFirstResult(0);
2415 q.setMaxResults(2);
2416
2417 QueryPos qPos = QueryPos.getInstance(q);
2418
2419 qPos.add(companyId);
2420
2421 qPos.add(parentOrganizationId);
2422
2423 if (orderByComparator != null) {
2424 Object[] values = orderByComparator.getOrderByConditionValues(organization);
2425
2426 for (Object value : values) {
2427 qPos.add(value);
2428 }
2429 }
2430
2431 List<Organization> list = q.list();
2432
2433 if (list.size() == 2) {
2434 return list.get(1);
2435 }
2436 else {
2437 return null;
2438 }
2439 }
2440
2441
2449 public List<Organization> filterFindByC_P(long companyId,
2450 long parentOrganizationId) throws SystemException {
2451 return filterFindByC_P(companyId, parentOrganizationId,
2452 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2453 }
2454
2455
2469 public List<Organization> filterFindByC_P(long companyId,
2470 long parentOrganizationId, int start, int end)
2471 throws SystemException {
2472 return filterFindByC_P(companyId, parentOrganizationId, start, end, null);
2473 }
2474
2475
2490 public List<Organization> filterFindByC_P(long companyId,
2491 long parentOrganizationId, int start, int end,
2492 OrderByComparator orderByComparator) throws SystemException {
2493 if (!InlineSQLHelperUtil.isEnabled()) {
2494 return findByC_P(companyId, parentOrganizationId, start, end,
2495 orderByComparator);
2496 }
2497
2498 StringBundler query = null;
2499
2500 if (orderByComparator != null) {
2501 query = new StringBundler(4 +
2502 (orderByComparator.getOrderByFields().length * 3));
2503 }
2504 else {
2505 query = new StringBundler(4);
2506 }
2507
2508 if (getDB().isSupportsInlineDistinct()) {
2509 query.append(_FILTER_SQL_SELECT_ORGANIZATION_WHERE);
2510 }
2511 else {
2512 query.append(_FILTER_SQL_SELECT_ORGANIZATION_NO_INLINE_DISTINCT_WHERE_1);
2513 }
2514
2515 query.append(_FINDER_COLUMN_C_P_COMPANYID_2);
2516
2517 query.append(_FINDER_COLUMN_C_P_PARENTORGANIZATIONID_2);
2518
2519 if (!getDB().isSupportsInlineDistinct()) {
2520 query.append(_FILTER_SQL_SELECT_ORGANIZATION_NO_INLINE_DISTINCT_WHERE_2);
2521 }
2522
2523 if (orderByComparator != null) {
2524 if (getDB().isSupportsInlineDistinct()) {
2525 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2526 orderByComparator);
2527 }
2528 else {
2529 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
2530 orderByComparator);
2531 }
2532 }
2533
2534 else {
2535 if (getDB().isSupportsInlineDistinct()) {
2536 query.append(OrganizationModelImpl.ORDER_BY_JPQL);
2537 }
2538 else {
2539 query.append(OrganizationModelImpl.ORDER_BY_SQL);
2540 }
2541 }
2542
2543 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2544 Organization.class.getName(),
2545 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
2546
2547 Session session = null;
2548
2549 try {
2550 session = openSession();
2551
2552 SQLQuery q = session.createSQLQuery(sql);
2553
2554 if (getDB().isSupportsInlineDistinct()) {
2555 q.addEntity(_FILTER_ENTITY_ALIAS, OrganizationImpl.class);
2556 }
2557 else {
2558 q.addEntity(_FILTER_ENTITY_TABLE, OrganizationImpl.class);
2559 }
2560
2561 QueryPos qPos = QueryPos.getInstance(q);
2562
2563 qPos.add(companyId);
2564
2565 qPos.add(parentOrganizationId);
2566
2567 return (List<Organization>)QueryUtil.list(q, getDialect(), start,
2568 end);
2569 }
2570 catch (Exception e) {
2571 throw processException(e);
2572 }
2573 finally {
2574 closeSession(session);
2575 }
2576 }
2577
2578
2589 public Organization[] filterFindByC_P_PrevAndNext(long organizationId,
2590 long companyId, long parentOrganizationId,
2591 OrderByComparator orderByComparator)
2592 throws NoSuchOrganizationException, SystemException {
2593 if (!InlineSQLHelperUtil.isEnabled()) {
2594 return findByC_P_PrevAndNext(organizationId, companyId,
2595 parentOrganizationId, orderByComparator);
2596 }
2597
2598 Organization organization = findByPrimaryKey(organizationId);
2599
2600 Session session = null;
2601
2602 try {
2603 session = openSession();
2604
2605 Organization[] array = new OrganizationImpl[3];
2606
2607 array[0] = filterGetByC_P_PrevAndNext(session, organization,
2608 companyId, parentOrganizationId, orderByComparator, true);
2609
2610 array[1] = organization;
2611
2612 array[2] = filterGetByC_P_PrevAndNext(session, organization,
2613 companyId, parentOrganizationId, orderByComparator, false);
2614
2615 return array;
2616 }
2617 catch (Exception e) {
2618 throw processException(e);
2619 }
2620 finally {
2621 closeSession(session);
2622 }
2623 }
2624
2625 protected Organization filterGetByC_P_PrevAndNext(Session session,
2626 Organization organization, long companyId, long parentOrganizationId,
2627 OrderByComparator orderByComparator, boolean previous) {
2628 StringBundler query = null;
2629
2630 if (orderByComparator != null) {
2631 query = new StringBundler(6 +
2632 (orderByComparator.getOrderByFields().length * 6));
2633 }
2634 else {
2635 query = new StringBundler(3);
2636 }
2637
2638 if (getDB().isSupportsInlineDistinct()) {
2639 query.append(_FILTER_SQL_SELECT_ORGANIZATION_WHERE);
2640 }
2641 else {
2642 query.append(_FILTER_SQL_SELECT_ORGANIZATION_NO_INLINE_DISTINCT_WHERE_1);
2643 }
2644
2645 query.append(_FINDER_COLUMN_C_P_COMPANYID_2);
2646
2647 query.append(_FINDER_COLUMN_C_P_PARENTORGANIZATIONID_2);
2648
2649 if (!getDB().isSupportsInlineDistinct()) {
2650 query.append(_FILTER_SQL_SELECT_ORGANIZATION_NO_INLINE_DISTINCT_WHERE_2);
2651 }
2652
2653 if (orderByComparator != null) {
2654 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2655
2656 if (orderByConditionFields.length > 0) {
2657 query.append(WHERE_AND);
2658 }
2659
2660 for (int i = 0; i < orderByConditionFields.length; i++) {
2661 if (getDB().isSupportsInlineDistinct()) {
2662 query.append(_ORDER_BY_ENTITY_ALIAS);
2663 }
2664 else {
2665 query.append(_ORDER_BY_ENTITY_TABLE);
2666 }
2667
2668 query.append(orderByConditionFields[i]);
2669
2670 if ((i + 1) < orderByConditionFields.length) {
2671 if (orderByComparator.isAscending() ^ previous) {
2672 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2673 }
2674 else {
2675 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2676 }
2677 }
2678 else {
2679 if (orderByComparator.isAscending() ^ previous) {
2680 query.append(WHERE_GREATER_THAN);
2681 }
2682 else {
2683 query.append(WHERE_LESSER_THAN);
2684 }
2685 }
2686 }
2687
2688 query.append(ORDER_BY_CLAUSE);
2689
2690 String[] orderByFields = orderByComparator.getOrderByFields();
2691
2692 for (int i = 0; i < orderByFields.length; i++) {
2693 if (getDB().isSupportsInlineDistinct()) {
2694 query.append(_ORDER_BY_ENTITY_ALIAS);
2695 }
2696 else {
2697 query.append(_ORDER_BY_ENTITY_TABLE);
2698 }
2699
2700 query.append(orderByFields[i]);
2701
2702 if ((i + 1) < orderByFields.length) {
2703 if (orderByComparator.isAscending() ^ previous) {
2704 query.append(ORDER_BY_ASC_HAS_NEXT);
2705 }
2706 else {
2707 query.append(ORDER_BY_DESC_HAS_NEXT);
2708 }
2709 }
2710 else {
2711 if (orderByComparator.isAscending() ^ previous) {
2712 query.append(ORDER_BY_ASC);
2713 }
2714 else {
2715 query.append(ORDER_BY_DESC);
2716 }
2717 }
2718 }
2719 }
2720
2721 else {
2722 if (getDB().isSupportsInlineDistinct()) {
2723 query.append(OrganizationModelImpl.ORDER_BY_JPQL);
2724 }
2725 else {
2726 query.append(OrganizationModelImpl.ORDER_BY_SQL);
2727 }
2728 }
2729
2730 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2731 Organization.class.getName(),
2732 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
2733
2734 SQLQuery q = session.createSQLQuery(sql);
2735
2736 q.setFirstResult(0);
2737 q.setMaxResults(2);
2738
2739 if (getDB().isSupportsInlineDistinct()) {
2740 q.addEntity(_FILTER_ENTITY_ALIAS, OrganizationImpl.class);
2741 }
2742 else {
2743 q.addEntity(_FILTER_ENTITY_TABLE, OrganizationImpl.class);
2744 }
2745
2746 QueryPos qPos = QueryPos.getInstance(q);
2747
2748 qPos.add(companyId);
2749
2750 qPos.add(parentOrganizationId);
2751
2752 if (orderByComparator != null) {
2753 Object[] values = orderByComparator.getOrderByConditionValues(organization);
2754
2755 for (Object value : values) {
2756 qPos.add(value);
2757 }
2758 }
2759
2760 List<Organization> list = q.list();
2761
2762 if (list.size() == 2) {
2763 return list.get(1);
2764 }
2765 else {
2766 return null;
2767 }
2768 }
2769
2770
2779 public Organization findByC_N(long companyId, String name)
2780 throws NoSuchOrganizationException, SystemException {
2781 Organization organization = fetchByC_N(companyId, name);
2782
2783 if (organization == null) {
2784 StringBundler msg = new StringBundler(6);
2785
2786 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2787
2788 msg.append("companyId=");
2789 msg.append(companyId);
2790
2791 msg.append(", name=");
2792 msg.append(name);
2793
2794 msg.append(StringPool.CLOSE_CURLY_BRACE);
2795
2796 if (_log.isWarnEnabled()) {
2797 _log.warn(msg.toString());
2798 }
2799
2800 throw new NoSuchOrganizationException(msg.toString());
2801 }
2802
2803 return organization;
2804 }
2805
2806
2814 public Organization fetchByC_N(long companyId, String name)
2815 throws SystemException {
2816 return fetchByC_N(companyId, name, true);
2817 }
2818
2819
2828 public Organization fetchByC_N(long companyId, String name,
2829 boolean retrieveFromCache) throws SystemException {
2830 Object[] finderArgs = new Object[] { companyId, name };
2831
2832 Object result = null;
2833
2834 if (retrieveFromCache) {
2835 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_N,
2836 finderArgs, this);
2837 }
2838
2839 if (result instanceof Organization) {
2840 Organization organization = (Organization)result;
2841
2842 if ((companyId != organization.getCompanyId()) ||
2843 !Validator.equals(name, organization.getName())) {
2844 result = null;
2845 }
2846 }
2847
2848 if (result == null) {
2849 StringBundler query = new StringBundler(4);
2850
2851 query.append(_SQL_SELECT_ORGANIZATION_WHERE);
2852
2853 query.append(_FINDER_COLUMN_C_N_COMPANYID_2);
2854
2855 if (name == null) {
2856 query.append(_FINDER_COLUMN_C_N_NAME_1);
2857 }
2858 else {
2859 if (name.equals(StringPool.BLANK)) {
2860 query.append(_FINDER_COLUMN_C_N_NAME_3);
2861 }
2862 else {
2863 query.append(_FINDER_COLUMN_C_N_NAME_2);
2864 }
2865 }
2866
2867 query.append(OrganizationModelImpl.ORDER_BY_JPQL);
2868
2869 String sql = query.toString();
2870
2871 Session session = null;
2872
2873 try {
2874 session = openSession();
2875
2876 Query q = session.createQuery(sql);
2877
2878 QueryPos qPos = QueryPos.getInstance(q);
2879
2880 qPos.add(companyId);
2881
2882 if (name != null) {
2883 qPos.add(name);
2884 }
2885
2886 List<Organization> list = q.list();
2887
2888 result = list;
2889
2890 Organization organization = null;
2891
2892 if (list.isEmpty()) {
2893 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N,
2894 finderArgs, list);
2895 }
2896 else {
2897 organization = list.get(0);
2898
2899 cacheResult(organization);
2900
2901 if ((organization.getCompanyId() != companyId) ||
2902 (organization.getName() == null) ||
2903 !organization.getName().equals(name)) {
2904 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N,
2905 finderArgs, organization);
2906 }
2907 }
2908
2909 return organization;
2910 }
2911 catch (Exception e) {
2912 throw processException(e);
2913 }
2914 finally {
2915 if (result == null) {
2916 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_N,
2917 finderArgs);
2918 }
2919
2920 closeSession(session);
2921 }
2922 }
2923 else {
2924 if (result instanceof List<?>) {
2925 return null;
2926 }
2927 else {
2928 return (Organization)result;
2929 }
2930 }
2931 }
2932
2933
2939 public List<Organization> findAll() throws SystemException {
2940 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2941 }
2942
2943
2955 public List<Organization> findAll(int start, int end)
2956 throws SystemException {
2957 return findAll(start, end, null);
2958 }
2959
2960
2973 public List<Organization> findAll(int start, int end,
2974 OrderByComparator orderByComparator) throws SystemException {
2975 FinderPath finderPath = null;
2976 Object[] finderArgs = new Object[] { start, end, orderByComparator };
2977
2978 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2979 (orderByComparator == null)) {
2980 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
2981 finderArgs = FINDER_ARGS_EMPTY;
2982 }
2983 else {
2984 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
2985 finderArgs = new Object[] { start, end, orderByComparator };
2986 }
2987
2988 List<Organization> list = (List<Organization>)FinderCacheUtil.getResult(finderPath,
2989 finderArgs, this);
2990
2991 if (list == null) {
2992 StringBundler query = null;
2993 String sql = null;
2994
2995 if (orderByComparator != null) {
2996 query = new StringBundler(2 +
2997 (orderByComparator.getOrderByFields().length * 3));
2998
2999 query.append(_SQL_SELECT_ORGANIZATION);
3000
3001 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3002 orderByComparator);
3003
3004 sql = query.toString();
3005 }
3006 else {
3007 sql = _SQL_SELECT_ORGANIZATION.concat(OrganizationModelImpl.ORDER_BY_JPQL);
3008 }
3009
3010 Session session = null;
3011
3012 try {
3013 session = openSession();
3014
3015 Query q = session.createQuery(sql);
3016
3017 if (orderByComparator == null) {
3018 list = (List<Organization>)QueryUtil.list(q, getDialect(),
3019 start, end, false);
3020
3021 Collections.sort(list);
3022 }
3023 else {
3024 list = (List<Organization>)QueryUtil.list(q, getDialect(),
3025 start, end);
3026 }
3027 }
3028 catch (Exception e) {
3029 throw processException(e);
3030 }
3031 finally {
3032 if (list == null) {
3033 FinderCacheUtil.removeResult(finderPath, finderArgs);
3034 }
3035 else {
3036 cacheResult(list);
3037
3038 FinderCacheUtil.putResult(finderPath, finderArgs, list);
3039 }
3040
3041 closeSession(session);
3042 }
3043 }
3044
3045 return list;
3046 }
3047
3048
3054 public void removeByCompanyId(long companyId) throws SystemException {
3055 for (Organization organization : findByCompanyId(companyId)) {
3056 remove(organization);
3057 }
3058 }
3059
3060
3066 public void removeByLocations(long companyId) throws SystemException {
3067 for (Organization organization : findByLocations(companyId)) {
3068 remove(organization);
3069 }
3070 }
3071
3072
3079 public void removeByC_P(long companyId, long parentOrganizationId)
3080 throws SystemException {
3081 for (Organization organization : findByC_P(companyId,
3082 parentOrganizationId)) {
3083 remove(organization);
3084 }
3085 }
3086
3087
3095 public Organization removeByC_N(long companyId, String name)
3096 throws NoSuchOrganizationException, SystemException {
3097 Organization organization = findByC_N(companyId, name);
3098
3099 return remove(organization);
3100 }
3101
3102
3107 public void removeAll() throws SystemException {
3108 for (Organization organization : findAll()) {
3109 remove(organization);
3110 }
3111 }
3112
3113
3120 public int countByCompanyId(long companyId) throws SystemException {
3121 Object[] finderArgs = new Object[] { companyId };
3122
3123 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
3124 finderArgs, this);
3125
3126 if (count == null) {
3127 StringBundler query = new StringBundler(2);
3128
3129 query.append(_SQL_COUNT_ORGANIZATION_WHERE);
3130
3131 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
3132
3133 String sql = query.toString();
3134
3135 Session session = null;
3136
3137 try {
3138 session = openSession();
3139
3140 Query q = session.createQuery(sql);
3141
3142 QueryPos qPos = QueryPos.getInstance(q);
3143
3144 qPos.add(companyId);
3145
3146 count = (Long)q.uniqueResult();
3147 }
3148 catch (Exception e) {
3149 throw processException(e);
3150 }
3151 finally {
3152 if (count == null) {
3153 count = Long.valueOf(0);
3154 }
3155
3156 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
3157 finderArgs, count);
3158
3159 closeSession(session);
3160 }
3161 }
3162
3163 return count.intValue();
3164 }
3165
3166
3173 public int filterCountByCompanyId(long companyId) throws SystemException {
3174 if (!InlineSQLHelperUtil.isEnabled()) {
3175 return countByCompanyId(companyId);
3176 }
3177
3178 StringBundler query = new StringBundler(2);
3179
3180 query.append(_FILTER_SQL_COUNT_ORGANIZATION_WHERE);
3181
3182 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
3183
3184 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3185 Organization.class.getName(),
3186 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
3187
3188 Session session = null;
3189
3190 try {
3191 session = openSession();
3192
3193 SQLQuery q = session.createSQLQuery(sql);
3194
3195 q.addScalar(COUNT_COLUMN_NAME,
3196 com.liferay.portal.kernel.dao.orm.Type.LONG);
3197
3198 QueryPos qPos = QueryPos.getInstance(q);
3199
3200 qPos.add(companyId);
3201
3202 Long count = (Long)q.uniqueResult();
3203
3204 return count.intValue();
3205 }
3206 catch (Exception e) {
3207 throw processException(e);
3208 }
3209 finally {
3210 closeSession(session);
3211 }
3212 }
3213
3214
3221 public int countByLocations(long companyId) throws SystemException {
3222 Object[] finderArgs = new Object[] { companyId };
3223
3224 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_LOCATIONS,
3225 finderArgs, this);
3226
3227 if (count == null) {
3228 StringBundler query = new StringBundler(2);
3229
3230 query.append(_SQL_COUNT_ORGANIZATION_WHERE);
3231
3232 query.append(_FINDER_COLUMN_LOCATIONS_COMPANYID_2);
3233
3234 String sql = query.toString();
3235
3236 Session session = null;
3237
3238 try {
3239 session = openSession();
3240
3241 Query q = session.createQuery(sql);
3242
3243 QueryPos qPos = QueryPos.getInstance(q);
3244
3245 qPos.add(companyId);
3246
3247 count = (Long)q.uniqueResult();
3248 }
3249 catch (Exception e) {
3250 throw processException(e);
3251 }
3252 finally {
3253 if (count == null) {
3254 count = Long.valueOf(0);
3255 }
3256
3257 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_LOCATIONS,
3258 finderArgs, count);
3259
3260 closeSession(session);
3261 }
3262 }
3263
3264 return count.intValue();
3265 }
3266
3267
3274 public int filterCountByLocations(long companyId) throws SystemException {
3275 if (!InlineSQLHelperUtil.isEnabled()) {
3276 return countByLocations(companyId);
3277 }
3278
3279 StringBundler query = new StringBundler(2);
3280
3281 query.append(_FILTER_SQL_COUNT_ORGANIZATION_WHERE);
3282
3283 query.append(_FINDER_COLUMN_LOCATIONS_COMPANYID_2);
3284
3285 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3286 Organization.class.getName(),
3287 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
3288
3289 Session session = null;
3290
3291 try {
3292 session = openSession();
3293
3294 SQLQuery q = session.createSQLQuery(sql);
3295
3296 q.addScalar(COUNT_COLUMN_NAME,
3297 com.liferay.portal.kernel.dao.orm.Type.LONG);
3298
3299 QueryPos qPos = QueryPos.getInstance(q);
3300
3301 qPos.add(companyId);
3302
3303 Long count = (Long)q.uniqueResult();
3304
3305 return count.intValue();
3306 }
3307 catch (Exception e) {
3308 throw processException(e);
3309 }
3310 finally {
3311 closeSession(session);
3312 }
3313 }
3314
3315
3323 public int countByC_P(long companyId, long parentOrganizationId)
3324 throws SystemException {
3325 Object[] finderArgs = new Object[] { companyId, parentOrganizationId };
3326
3327 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_P,
3328 finderArgs, this);
3329
3330 if (count == null) {
3331 StringBundler query = new StringBundler(3);
3332
3333 query.append(_SQL_COUNT_ORGANIZATION_WHERE);
3334
3335 query.append(_FINDER_COLUMN_C_P_COMPANYID_2);
3336
3337 query.append(_FINDER_COLUMN_C_P_PARENTORGANIZATIONID_2);
3338
3339 String sql = query.toString();
3340
3341 Session session = null;
3342
3343 try {
3344 session = openSession();
3345
3346 Query q = session.createQuery(sql);
3347
3348 QueryPos qPos = QueryPos.getInstance(q);
3349
3350 qPos.add(companyId);
3351
3352 qPos.add(parentOrganizationId);
3353
3354 count = (Long)q.uniqueResult();
3355 }
3356 catch (Exception e) {
3357 throw processException(e);
3358 }
3359 finally {
3360 if (count == null) {
3361 count = Long.valueOf(0);
3362 }
3363
3364 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_P, finderArgs,
3365 count);
3366
3367 closeSession(session);
3368 }
3369 }
3370
3371 return count.intValue();
3372 }
3373
3374
3382 public int filterCountByC_P(long companyId, long parentOrganizationId)
3383 throws SystemException {
3384 if (!InlineSQLHelperUtil.isEnabled()) {
3385 return countByC_P(companyId, parentOrganizationId);
3386 }
3387
3388 StringBundler query = new StringBundler(3);
3389
3390 query.append(_FILTER_SQL_COUNT_ORGANIZATION_WHERE);
3391
3392 query.append(_FINDER_COLUMN_C_P_COMPANYID_2);
3393
3394 query.append(_FINDER_COLUMN_C_P_PARENTORGANIZATIONID_2);
3395
3396 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3397 Organization.class.getName(),
3398 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
3399
3400 Session session = null;
3401
3402 try {
3403 session = openSession();
3404
3405 SQLQuery q = session.createSQLQuery(sql);
3406
3407 q.addScalar(COUNT_COLUMN_NAME,
3408 com.liferay.portal.kernel.dao.orm.Type.LONG);
3409
3410 QueryPos qPos = QueryPos.getInstance(q);
3411
3412 qPos.add(companyId);
3413
3414 qPos.add(parentOrganizationId);
3415
3416 Long count = (Long)q.uniqueResult();
3417
3418 return count.intValue();
3419 }
3420 catch (Exception e) {
3421 throw processException(e);
3422 }
3423 finally {
3424 closeSession(session);
3425 }
3426 }
3427
3428
3436 public int countByC_N(long companyId, String name)
3437 throws SystemException {
3438 Object[] finderArgs = new Object[] { companyId, name };
3439
3440 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_N,
3441 finderArgs, this);
3442
3443 if (count == null) {
3444 StringBundler query = new StringBundler(3);
3445
3446 query.append(_SQL_COUNT_ORGANIZATION_WHERE);
3447
3448 query.append(_FINDER_COLUMN_C_N_COMPANYID_2);
3449
3450 if (name == null) {
3451 query.append(_FINDER_COLUMN_C_N_NAME_1);
3452 }
3453 else {
3454 if (name.equals(StringPool.BLANK)) {
3455 query.append(_FINDER_COLUMN_C_N_NAME_3);
3456 }
3457 else {
3458 query.append(_FINDER_COLUMN_C_N_NAME_2);
3459 }
3460 }
3461
3462 String sql = query.toString();
3463
3464 Session session = null;
3465
3466 try {
3467 session = openSession();
3468
3469 Query q = session.createQuery(sql);
3470
3471 QueryPos qPos = QueryPos.getInstance(q);
3472
3473 qPos.add(companyId);
3474
3475 if (name != null) {
3476 qPos.add(name);
3477 }
3478
3479 count = (Long)q.uniqueResult();
3480 }
3481 catch (Exception e) {
3482 throw processException(e);
3483 }
3484 finally {
3485 if (count == null) {
3486 count = Long.valueOf(0);
3487 }
3488
3489 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_N, finderArgs,
3490 count);
3491
3492 closeSession(session);
3493 }
3494 }
3495
3496 return count.intValue();
3497 }
3498
3499
3505 public int countAll() throws SystemException {
3506 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
3507 FINDER_ARGS_EMPTY, this);
3508
3509 if (count == null) {
3510 Session session = null;
3511
3512 try {
3513 session = openSession();
3514
3515 Query q = session.createQuery(_SQL_COUNT_ORGANIZATION);
3516
3517 count = (Long)q.uniqueResult();
3518 }
3519 catch (Exception e) {
3520 throw processException(e);
3521 }
3522 finally {
3523 if (count == null) {
3524 count = Long.valueOf(0);
3525 }
3526
3527 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
3528 FINDER_ARGS_EMPTY, count);
3529
3530 closeSession(session);
3531 }
3532 }
3533
3534 return count.intValue();
3535 }
3536
3537
3544 public List<com.liferay.portal.model.Group> getGroups(long pk)
3545 throws SystemException {
3546 return getGroups(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
3547 }
3548
3549
3562 public List<com.liferay.portal.model.Group> getGroups(long pk, int start,
3563 int end) throws SystemException {
3564 return getGroups(pk, start, end, null);
3565 }
3566
3567 public static final FinderPath FINDER_PATH_GET_GROUPS = new FinderPath(com.liferay.portal.model.impl.GroupModelImpl.ENTITY_CACHE_ENABLED,
3568 OrganizationModelImpl.FINDER_CACHE_ENABLED_GROUPS_ORGS,
3569 com.liferay.portal.model.impl.GroupImpl.class,
3570 OrganizationModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME, "getGroups",
3571 new String[] {
3572 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
3573 "com.liferay.portal.kernel.util.OrderByComparator"
3574 });
3575
3576 static {
3577 FINDER_PATH_GET_GROUPS.setCacheKeyGeneratorCacheName(null);
3578 }
3579
3580
3594 public List<com.liferay.portal.model.Group> getGroups(long pk, int start,
3595 int end, OrderByComparator orderByComparator) throws SystemException {
3596 Object[] finderArgs = new Object[] { pk, start, end, orderByComparator };
3597
3598 List<com.liferay.portal.model.Group> list = (List<com.liferay.portal.model.Group>)FinderCacheUtil.getResult(FINDER_PATH_GET_GROUPS,
3599 finderArgs, this);
3600
3601 if (list == null) {
3602 Session session = null;
3603
3604 try {
3605 session = openSession();
3606
3607 String sql = null;
3608
3609 if (orderByComparator != null) {
3610 sql = _SQL_GETGROUPS.concat(ORDER_BY_CLAUSE)
3611 .concat(orderByComparator.getOrderBy());
3612 }
3613 else {
3614 sql = _SQL_GETGROUPS.concat(com.liferay.portal.model.impl.GroupModelImpl.ORDER_BY_SQL);
3615 }
3616
3617 SQLQuery q = session.createSQLQuery(sql);
3618
3619 q.addEntity("Group_",
3620 com.liferay.portal.model.impl.GroupImpl.class);
3621
3622 QueryPos qPos = QueryPos.getInstance(q);
3623
3624 qPos.add(pk);
3625
3626 list = (List<com.liferay.portal.model.Group>)QueryUtil.list(q,
3627 getDialect(), start, end);
3628 }
3629 catch (Exception e) {
3630 throw processException(e);
3631 }
3632 finally {
3633 if (list == null) {
3634 FinderCacheUtil.removeResult(FINDER_PATH_GET_GROUPS,
3635 finderArgs);
3636 }
3637 else {
3638 groupPersistence.cacheResult(list);
3639
3640 FinderCacheUtil.putResult(FINDER_PATH_GET_GROUPS,
3641 finderArgs, list);
3642 }
3643
3644 closeSession(session);
3645 }
3646 }
3647
3648 return list;
3649 }
3650
3651 public static final FinderPath FINDER_PATH_GET_GROUPS_SIZE = new FinderPath(com.liferay.portal.model.impl.GroupModelImpl.ENTITY_CACHE_ENABLED,
3652 OrganizationModelImpl.FINDER_CACHE_ENABLED_GROUPS_ORGS, Long.class,
3653 OrganizationModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME,
3654 "getGroupsSize", new String[] { Long.class.getName() });
3655
3656 static {
3657 FINDER_PATH_GET_GROUPS_SIZE.setCacheKeyGeneratorCacheName(null);
3658 }
3659
3660
3667 public int getGroupsSize(long pk) throws SystemException {
3668 Object[] finderArgs = new Object[] { pk };
3669
3670 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_GROUPS_SIZE,
3671 finderArgs, this);
3672
3673 if (count == null) {
3674 Session session = null;
3675
3676 try {
3677 session = openSession();
3678
3679 SQLQuery q = session.createSQLQuery(_SQL_GETGROUPSSIZE);
3680
3681 q.addScalar(COUNT_COLUMN_NAME,
3682 com.liferay.portal.kernel.dao.orm.Type.LONG);
3683
3684 QueryPos qPos = QueryPos.getInstance(q);
3685
3686 qPos.add(pk);
3687
3688 count = (Long)q.uniqueResult();
3689 }
3690 catch (Exception e) {
3691 throw processException(e);
3692 }
3693 finally {
3694 if (count == null) {
3695 count = Long.valueOf(0);
3696 }
3697
3698 FinderCacheUtil.putResult(FINDER_PATH_GET_GROUPS_SIZE,
3699 finderArgs, count);
3700
3701 closeSession(session);
3702 }
3703 }
3704
3705 return count.intValue();
3706 }
3707
3708 public static final FinderPath FINDER_PATH_CONTAINS_GROUP = new FinderPath(com.liferay.portal.model.impl.GroupModelImpl.ENTITY_CACHE_ENABLED,
3709 OrganizationModelImpl.FINDER_CACHE_ENABLED_GROUPS_ORGS,
3710 Boolean.class,
3711 OrganizationModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME,
3712 "containsGroup",
3713 new String[] { Long.class.getName(), Long.class.getName() });
3714
3715
3723 public boolean containsGroup(long pk, long groupPK)
3724 throws SystemException {
3725 Object[] finderArgs = new Object[] { pk, groupPK };
3726
3727 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_GROUP,
3728 finderArgs, this);
3729
3730 if (value == null) {
3731 try {
3732 value = Boolean.valueOf(containsGroup.contains(pk, groupPK));
3733 }
3734 catch (Exception e) {
3735 throw processException(e);
3736 }
3737 finally {
3738 if (value == null) {
3739 value = Boolean.FALSE;
3740 }
3741
3742 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_GROUP,
3743 finderArgs, value);
3744 }
3745 }
3746
3747 return value.booleanValue();
3748 }
3749
3750
3757 public boolean containsGroups(long pk) throws SystemException {
3758 if (getGroupsSize(pk) > 0) {
3759 return true;
3760 }
3761 else {
3762 return false;
3763 }
3764 }
3765
3766
3773 public void addGroup(long pk, long groupPK) throws SystemException {
3774 try {
3775 addGroup.add(pk, groupPK);
3776 }
3777 catch (Exception e) {
3778 throw processException(e);
3779 }
3780 finally {
3781 FinderCacheUtil.clearCache(OrganizationModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME);
3782 }
3783 }
3784
3785
3792 public void addGroup(long pk, com.liferay.portal.model.Group group)
3793 throws SystemException {
3794 try {
3795 addGroup.add(pk, group.getPrimaryKey());
3796 }
3797 catch (Exception e) {
3798 throw processException(e);
3799 }
3800 finally {
3801 FinderCacheUtil.clearCache(OrganizationModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME);
3802 }
3803 }
3804
3805
3812 public void addGroups(long pk, long[] groupPKs) throws SystemException {
3813 try {
3814 for (long groupPK : groupPKs) {
3815 addGroup.add(pk, groupPK);
3816 }
3817 }
3818 catch (Exception e) {
3819 throw processException(e);
3820 }
3821 finally {
3822 FinderCacheUtil.clearCache(OrganizationModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME);
3823 }
3824 }
3825
3826
3833 public void addGroups(long pk, List<com.liferay.portal.model.Group> groups)
3834 throws SystemException {
3835 try {
3836 for (com.liferay.portal.model.Group group : groups) {
3837 addGroup.add(pk, group.getPrimaryKey());
3838 }
3839 }
3840 catch (Exception e) {
3841 throw processException(e);
3842 }
3843 finally {
3844 FinderCacheUtil.clearCache(OrganizationModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME);
3845 }
3846 }
3847
3848
3854 public void clearGroups(long pk) throws SystemException {
3855 try {
3856 clearGroups.clear(pk);
3857 }
3858 catch (Exception e) {
3859 throw processException(e);
3860 }
3861 finally {
3862 FinderCacheUtil.clearCache(OrganizationModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME);
3863 }
3864 }
3865
3866
3873 public void removeGroup(long pk, long groupPK) throws SystemException {
3874 try {
3875 removeGroup.remove(pk, groupPK);
3876 }
3877 catch (Exception e) {
3878 throw processException(e);
3879 }
3880 finally {
3881 FinderCacheUtil.clearCache(OrganizationModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME);
3882 }
3883 }
3884
3885
3892 public void removeGroup(long pk, com.liferay.portal.model.Group group)
3893 throws SystemException {
3894 try {
3895 removeGroup.remove(pk, group.getPrimaryKey());
3896 }
3897 catch (Exception e) {
3898 throw processException(e);
3899 }
3900 finally {
3901 FinderCacheUtil.clearCache(OrganizationModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME);
3902 }
3903 }
3904
3905
3912 public void removeGroups(long pk, long[] groupPKs)
3913 throws SystemException {
3914 try {
3915 for (long groupPK : groupPKs) {
3916 removeGroup.remove(pk, groupPK);
3917 }
3918 }
3919 catch (Exception e) {
3920 throw processException(e);
3921 }
3922 finally {
3923 FinderCacheUtil.clearCache(OrganizationModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME);
3924 }
3925 }
3926
3927
3934 public void removeGroups(long pk,
3935 List<com.liferay.portal.model.Group> groups) throws SystemException {
3936 try {
3937 for (com.liferay.portal.model.Group group : groups) {
3938 removeGroup.remove(pk, group.getPrimaryKey());
3939 }
3940 }
3941 catch (Exception e) {
3942 throw processException(e);
3943 }
3944 finally {
3945 FinderCacheUtil.clearCache(OrganizationModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME);
3946 }
3947 }
3948
3949
3956 public void setGroups(long pk, long[] groupPKs) throws SystemException {
3957 try {
3958 Set<Long> groupPKSet = SetUtil.fromArray(groupPKs);
3959
3960 List<com.liferay.portal.model.Group> groups = getGroups(pk);
3961
3962 for (com.liferay.portal.model.Group group : groups) {
3963 if (!groupPKSet.remove(group.getPrimaryKey())) {
3964 removeGroup.remove(pk, group.getPrimaryKey());
3965 }
3966 }
3967
3968 for (Long groupPK : groupPKSet) {
3969 addGroup.add(pk, groupPK);
3970 }
3971 }
3972 catch (Exception e) {
3973 throw processException(e);
3974 }
3975 finally {
3976 FinderCacheUtil.clearCache(OrganizationModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME);
3977 }
3978 }
3979
3980
3987 public void setGroups(long pk, List<com.liferay.portal.model.Group> groups)
3988 throws SystemException {
3989 try {
3990 long[] groupPKs = new long[groups.size()];
3991
3992 for (int i = 0; i < groups.size(); i++) {
3993 com.liferay.portal.model.Group group = groups.get(i);
3994
3995 groupPKs[i] = group.getPrimaryKey();
3996 }
3997
3998 setGroups(pk, groupPKs);
3999 }
4000 catch (Exception e) {
4001 throw processException(e);
4002 }
4003 finally {
4004 FinderCacheUtil.clearCache(OrganizationModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME);
4005 }
4006 }
4007
4008
4015 public List<com.liferay.portal.model.User> getUsers(long pk)
4016 throws SystemException {
4017 return getUsers(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
4018 }
4019
4020
4033 public List<com.liferay.portal.model.User> getUsers(long pk, int start,
4034 int end) throws SystemException {
4035 return getUsers(pk, start, end, null);
4036 }
4037
4038 public static final FinderPath FINDER_PATH_GET_USERS = new FinderPath(com.liferay.portal.model.impl.UserModelImpl.ENTITY_CACHE_ENABLED,
4039 OrganizationModelImpl.FINDER_CACHE_ENABLED_USERS_ORGS,
4040 com.liferay.portal.model.impl.UserImpl.class,
4041 OrganizationModelImpl.MAPPING_TABLE_USERS_ORGS_NAME, "getUsers",
4042 new String[] {
4043 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
4044 "com.liferay.portal.kernel.util.OrderByComparator"
4045 });
4046
4047 static {
4048 FINDER_PATH_GET_USERS.setCacheKeyGeneratorCacheName(null);
4049 }
4050
4051
4065 public List<com.liferay.portal.model.User> getUsers(long pk, int start,
4066 int end, OrderByComparator orderByComparator) throws SystemException {
4067 Object[] finderArgs = new Object[] { pk, start, end, orderByComparator };
4068
4069 List<com.liferay.portal.model.User> list = (List<com.liferay.portal.model.User>)FinderCacheUtil.getResult(FINDER_PATH_GET_USERS,
4070 finderArgs, this);
4071
4072 if (list == null) {
4073 Session session = null;
4074
4075 try {
4076 session = openSession();
4077
4078 String sql = null;
4079
4080 if (orderByComparator != null) {
4081 sql = _SQL_GETUSERS.concat(ORDER_BY_CLAUSE)
4082 .concat(orderByComparator.getOrderBy());
4083 }
4084 else {
4085 sql = _SQL_GETUSERS;
4086 }
4087
4088 SQLQuery q = session.createSQLQuery(sql);
4089
4090 q.addEntity("User_",
4091 com.liferay.portal.model.impl.UserImpl.class);
4092
4093 QueryPos qPos = QueryPos.getInstance(q);
4094
4095 qPos.add(pk);
4096
4097 list = (List<com.liferay.portal.model.User>)QueryUtil.list(q,
4098 getDialect(), start, end);
4099 }
4100 catch (Exception e) {
4101 throw processException(e);
4102 }
4103 finally {
4104 if (list == null) {
4105 FinderCacheUtil.removeResult(FINDER_PATH_GET_USERS,
4106 finderArgs);
4107 }
4108 else {
4109 userPersistence.cacheResult(list);
4110
4111 FinderCacheUtil.putResult(FINDER_PATH_GET_USERS,
4112 finderArgs, list);
4113 }
4114
4115 closeSession(session);
4116 }
4117 }
4118
4119 return list;
4120 }
4121
4122 public static final FinderPath FINDER_PATH_GET_USERS_SIZE = new FinderPath(com.liferay.portal.model.impl.UserModelImpl.ENTITY_CACHE_ENABLED,
4123 OrganizationModelImpl.FINDER_CACHE_ENABLED_USERS_ORGS, Long.class,
4124 OrganizationModelImpl.MAPPING_TABLE_USERS_ORGS_NAME,
4125 "getUsersSize", new String[] { Long.class.getName() });
4126
4127 static {
4128 FINDER_PATH_GET_USERS_SIZE.setCacheKeyGeneratorCacheName(null);
4129 }
4130
4131
4138 public int getUsersSize(long pk) throws SystemException {
4139 Object[] finderArgs = new Object[] { pk };
4140
4141 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_USERS_SIZE,
4142 finderArgs, this);
4143
4144 if (count == null) {
4145 Session session = null;
4146
4147 try {
4148 session = openSession();
4149
4150 SQLQuery q = session.createSQLQuery(_SQL_GETUSERSSIZE);
4151
4152 q.addScalar(COUNT_COLUMN_NAME,
4153 com.liferay.portal.kernel.dao.orm.Type.LONG);
4154
4155 QueryPos qPos = QueryPos.getInstance(q);
4156
4157 qPos.add(pk);
4158
4159 count = (Long)q.uniqueResult();
4160 }
4161 catch (Exception e) {
4162 throw processException(e);
4163 }
4164 finally {
4165 if (count == null) {
4166 count = Long.valueOf(0);
4167 }
4168
4169 FinderCacheUtil.putResult(FINDER_PATH_GET_USERS_SIZE,
4170 finderArgs, count);
4171
4172 closeSession(session);
4173 }
4174 }
4175
4176 return count.intValue();
4177 }
4178
4179 public static final FinderPath FINDER_PATH_CONTAINS_USER = new FinderPath(com.liferay.portal.model.impl.UserModelImpl.ENTITY_CACHE_ENABLED,
4180 OrganizationModelImpl.FINDER_CACHE_ENABLED_USERS_ORGS,
4181 Boolean.class, OrganizationModelImpl.MAPPING_TABLE_USERS_ORGS_NAME,
4182 "containsUser",
4183 new String[] { Long.class.getName(), Long.class.getName() });
4184
4185
4193 public boolean containsUser(long pk, long userPK) throws SystemException {
4194 Object[] finderArgs = new Object[] { pk, userPK };
4195
4196 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_USER,
4197 finderArgs, this);
4198
4199 if (value == null) {
4200 try {
4201 value = Boolean.valueOf(containsUser.contains(pk, userPK));
4202 }
4203 catch (Exception e) {
4204 throw processException(e);
4205 }
4206 finally {
4207 if (value == null) {
4208 value = Boolean.FALSE;
4209 }
4210
4211 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_USER,
4212 finderArgs, value);
4213 }
4214 }
4215
4216 return value.booleanValue();
4217 }
4218
4219
4226 public boolean containsUsers(long pk) throws SystemException {
4227 if (getUsersSize(pk) > 0) {
4228 return true;
4229 }
4230 else {
4231 return false;
4232 }
4233 }
4234
4235
4242 public void addUser(long pk, long userPK) throws SystemException {
4243 try {
4244 addUser.add(pk, userPK);
4245 }
4246 catch (Exception e) {
4247 throw processException(e);
4248 }
4249 finally {
4250 FinderCacheUtil.clearCache(OrganizationModelImpl.MAPPING_TABLE_USERS_ORGS_NAME);
4251 }
4252 }
4253
4254
4261 public void addUser(long pk, com.liferay.portal.model.User user)
4262 throws SystemException {
4263 try {
4264 addUser.add(pk, user.getPrimaryKey());
4265 }
4266 catch (Exception e) {
4267 throw processException(e);
4268 }
4269 finally {
4270 FinderCacheUtil.clearCache(OrganizationModelImpl.MAPPING_TABLE_USERS_ORGS_NAME);
4271 }
4272 }
4273
4274
4281 public void addUsers(long pk, long[] userPKs) throws SystemException {
4282 try {
4283 for (long userPK : userPKs) {
4284 addUser.add(pk, userPK);
4285 }
4286 }
4287 catch (Exception e) {
4288 throw processException(e);
4289 }
4290 finally {
4291 FinderCacheUtil.clearCache(OrganizationModelImpl.MAPPING_TABLE_USERS_ORGS_NAME);
4292 }
4293 }
4294
4295
4302 public void addUsers(long pk, List<com.liferay.portal.model.User> users)
4303 throws SystemException {
4304 try {
4305 for (com.liferay.portal.model.User user : users) {
4306 addUser.add(pk, user.getPrimaryKey());
4307 }
4308 }
4309 catch (Exception e) {
4310 throw processException(e);
4311 }
4312 finally {
4313 FinderCacheUtil.clearCache(OrganizationModelImpl.MAPPING_TABLE_USERS_ORGS_NAME);
4314 }
4315 }
4316
4317
4323 public void clearUsers(long pk) throws SystemException {
4324 try {
4325 clearUsers.clear(pk);
4326 }
4327 catch (Exception e) {
4328 throw processException(e);
4329 }
4330 finally {
4331 FinderCacheUtil.clearCache(OrganizationModelImpl.MAPPING_TABLE_USERS_ORGS_NAME);
4332 }
4333 }
4334
4335
4342 public void removeUser(long pk, long userPK) throws SystemException {
4343 try {
4344 removeUser.remove(pk, userPK);
4345 }
4346 catch (Exception e) {
4347 throw processException(e);
4348 }
4349 finally {
4350 FinderCacheUtil.clearCache(OrganizationModelImpl.MAPPING_TABLE_USERS_ORGS_NAME);
4351 }
4352 }
4353
4354
4361 public void removeUser(long pk, com.liferay.portal.model.User user)
4362 throws SystemException {
4363 try {
4364 removeUser.remove(pk, user.getPrimaryKey());
4365 }
4366 catch (Exception e) {
4367 throw processException(e);
4368 }
4369 finally {
4370 FinderCacheUtil.clearCache(OrganizationModelImpl.MAPPING_TABLE_USERS_ORGS_NAME);
4371 }
4372 }
4373
4374
4381 public void removeUsers(long pk, long[] userPKs) throws SystemException {
4382 try {
4383 for (long userPK : userPKs) {
4384 removeUser.remove(pk, userPK);
4385 }
4386 }
4387 catch (Exception e) {
4388 throw processException(e);
4389 }
4390 finally {
4391 FinderCacheUtil.clearCache(OrganizationModelImpl.MAPPING_TABLE_USERS_ORGS_NAME);
4392 }
4393 }
4394
4395
4402 public void removeUsers(long pk, List<com.liferay.portal.model.User> users)
4403 throws SystemException {
4404 try {
4405 for (com.liferay.portal.model.User user : users) {
4406 removeUser.remove(pk, user.getPrimaryKey());
4407 }
4408 }
4409 catch (Exception e) {
4410 throw processException(e);
4411 }
4412 finally {
4413 FinderCacheUtil.clearCache(OrganizationModelImpl.MAPPING_TABLE_USERS_ORGS_NAME);
4414 }
4415 }
4416
4417
4424 public void setUsers(long pk, long[] userPKs) throws SystemException {
4425 try {
4426 Set<Long> userPKSet = SetUtil.fromArray(userPKs);
4427
4428 List<com.liferay.portal.model.User> users = getUsers(pk);
4429
4430 for (com.liferay.portal.model.User user : users) {
4431 if (!userPKSet.remove(user.getPrimaryKey())) {
4432 removeUser.remove(pk, user.getPrimaryKey());
4433 }
4434 }
4435
4436 for (Long userPK : userPKSet) {
4437 addUser.add(pk, userPK);
4438 }
4439 }
4440 catch (Exception e) {
4441 throw processException(e);
4442 }
4443 finally {
4444 FinderCacheUtil.clearCache(OrganizationModelImpl.MAPPING_TABLE_USERS_ORGS_NAME);
4445 }
4446 }
4447
4448
4455 public void setUsers(long pk, List<com.liferay.portal.model.User> users)
4456 throws SystemException {
4457 try {
4458 long[] userPKs = new long[users.size()];
4459
4460 for (int i = 0; i < users.size(); i++) {
4461 com.liferay.portal.model.User user = users.get(i);
4462
4463 userPKs[i] = user.getPrimaryKey();
4464 }
4465
4466 setUsers(pk, userPKs);
4467 }
4468 catch (Exception e) {
4469 throw processException(e);
4470 }
4471 finally {
4472 FinderCacheUtil.clearCache(OrganizationModelImpl.MAPPING_TABLE_USERS_ORGS_NAME);
4473 }
4474 }
4475
4476
4479 public void afterPropertiesSet() {
4480 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
4481 com.liferay.portal.util.PropsUtil.get(
4482 "value.object.listener.com.liferay.portal.model.Organization")));
4483
4484 if (listenerClassNames.length > 0) {
4485 try {
4486 List<ModelListener<Organization>> listenersList = new ArrayList<ModelListener<Organization>>();
4487
4488 for (String listenerClassName : listenerClassNames) {
4489 listenersList.add((ModelListener<Organization>)InstanceFactory.newInstance(
4490 listenerClassName));
4491 }
4492
4493 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
4494 }
4495 catch (Exception e) {
4496 _log.error(e);
4497 }
4498 }
4499
4500 containsGroup = new ContainsGroup();
4501
4502 addGroup = new AddGroup();
4503 clearGroups = new ClearGroups();
4504 removeGroup = new RemoveGroup();
4505
4506 containsUser = new ContainsUser();
4507
4508 addUser = new AddUser();
4509 clearUsers = new ClearUsers();
4510 removeUser = new RemoveUser();
4511 }
4512
4513 public void destroy() {
4514 EntityCacheUtil.removeCache(OrganizationImpl.class.getName());
4515 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
4516 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
4517 }
4518
4519 @BeanReference(type = AccountPersistence.class)
4520 protected AccountPersistence accountPersistence;
4521 @BeanReference(type = AddressPersistence.class)
4522 protected AddressPersistence addressPersistence;
4523 @BeanReference(type = BrowserTrackerPersistence.class)
4524 protected BrowserTrackerPersistence browserTrackerPersistence;
4525 @BeanReference(type = ClassNamePersistence.class)
4526 protected ClassNamePersistence classNamePersistence;
4527 @BeanReference(type = ClusterGroupPersistence.class)
4528 protected ClusterGroupPersistence clusterGroupPersistence;
4529 @BeanReference(type = CompanyPersistence.class)
4530 protected CompanyPersistence companyPersistence;
4531 @BeanReference(type = ContactPersistence.class)
4532 protected ContactPersistence contactPersistence;
4533 @BeanReference(type = CountryPersistence.class)
4534 protected CountryPersistence countryPersistence;
4535 @BeanReference(type = EmailAddressPersistence.class)
4536 protected EmailAddressPersistence emailAddressPersistence;
4537 @BeanReference(type = GroupPersistence.class)
4538 protected GroupPersistence groupPersistence;
4539 @BeanReference(type = ImagePersistence.class)
4540 protected ImagePersistence imagePersistence;
4541 @BeanReference(type = LayoutPersistence.class)
4542 protected LayoutPersistence layoutPersistence;
4543 @BeanReference(type = LayoutBranchPersistence.class)
4544 protected LayoutBranchPersistence layoutBranchPersistence;
4545 @BeanReference(type = LayoutPrototypePersistence.class)
4546 protected LayoutPrototypePersistence layoutPrototypePersistence;
4547 @BeanReference(type = LayoutRevisionPersistence.class)
4548 protected LayoutRevisionPersistence layoutRevisionPersistence;
4549 @BeanReference(type = LayoutSetPersistence.class)
4550 protected LayoutSetPersistence layoutSetPersistence;
4551 @BeanReference(type = LayoutSetBranchPersistence.class)
4552 protected LayoutSetBranchPersistence layoutSetBranchPersistence;
4553 @BeanReference(type = LayoutSetPrototypePersistence.class)
4554 protected LayoutSetPrototypePersistence layoutSetPrototypePersistence;
4555 @BeanReference(type = ListTypePersistence.class)
4556 protected ListTypePersistence listTypePersistence;
4557 @BeanReference(type = LockPersistence.class)
4558 protected LockPersistence lockPersistence;
4559 @BeanReference(type = MembershipRequestPersistence.class)
4560 protected MembershipRequestPersistence membershipRequestPersistence;
4561 @BeanReference(type = OrganizationPersistence.class)
4562 protected OrganizationPersistence organizationPersistence;
4563 @BeanReference(type = OrgGroupPermissionPersistence.class)
4564 protected OrgGroupPermissionPersistence orgGroupPermissionPersistence;
4565 @BeanReference(type = OrgGroupRolePersistence.class)
4566 protected OrgGroupRolePersistence orgGroupRolePersistence;
4567 @BeanReference(type = OrgLaborPersistence.class)
4568 protected OrgLaborPersistence orgLaborPersistence;
4569 @BeanReference(type = PasswordPolicyPersistence.class)
4570 protected PasswordPolicyPersistence passwordPolicyPersistence;
4571 @BeanReference(type = PasswordPolicyRelPersistence.class)
4572 protected PasswordPolicyRelPersistence passwordPolicyRelPersistence;
4573 @BeanReference(type = PasswordTrackerPersistence.class)
4574 protected PasswordTrackerPersistence passwordTrackerPersistence;
4575 @BeanReference(type = PermissionPersistence.class)
4576 protected PermissionPersistence permissionPersistence;
4577 @BeanReference(type = PhonePersistence.class)
4578 protected PhonePersistence phonePersistence;
4579 @BeanReference(type = PluginSettingPersistence.class)
4580 protected PluginSettingPersistence pluginSettingPersistence;
4581 @BeanReference(type = PortalPreferencesPersistence.class)
4582 protected PortalPreferencesPersistence portalPreferencesPersistence;
4583 @BeanReference(type = PortletPersistence.class)
4584 protected PortletPersistence portletPersistence;
4585 @BeanReference(type = PortletItemPersistence.class)
4586 protected PortletItemPersistence portletItemPersistence;
4587 @BeanReference(type = PortletPreferencesPersistence.class)
4588 protected PortletPreferencesPersistence portletPreferencesPersistence;
4589 @BeanReference(type = RegionPersistence.class)
4590 protected RegionPersistence regionPersistence;
4591 @BeanReference(type = ReleasePersistence.class)
4592 protected ReleasePersistence releasePersistence;
4593 @BeanReference(type = RepositoryPersistence.class)
4594 protected RepositoryPersistence repositoryPersistence;
4595 @BeanReference(type = RepositoryEntryPersistence.class)
4596 protected RepositoryEntryPersistence repositoryEntryPersistence;
4597 @BeanReference(type = ResourcePersistence.class)
4598 protected ResourcePersistence resourcePersistence;
4599 @BeanReference(type = ResourceActionPersistence.class)
4600 protected ResourceActionPersistence resourceActionPersistence;
4601 @BeanReference(type = ResourceBlockPersistence.class)
4602 protected ResourceBlockPersistence resourceBlockPersistence;
4603 @BeanReference(type = ResourceBlockPermissionPersistence.class)
4604 protected ResourceBlockPermissionPersistence resourceBlockPermissionPersistence;
4605 @BeanReference(type = ResourceCodePersistence.class)
4606 protected ResourceCodePersistence resourceCodePersistence;
4607 @BeanReference(type = ResourcePermissionPersistence.class)
4608 protected ResourcePermissionPersistence resourcePermissionPersistence;
4609 @BeanReference(type = ResourceTypePermissionPersistence.class)
4610 protected ResourceTypePermissionPersistence resourceTypePermissionPersistence;
4611 @BeanReference(type = RolePersistence.class)
4612 protected RolePersistence rolePersistence;
4613 @BeanReference(type = ServiceComponentPersistence.class)
4614 protected ServiceComponentPersistence serviceComponentPersistence;
4615 @BeanReference(type = ShardPersistence.class)
4616 protected ShardPersistence shardPersistence;
4617 @BeanReference(type = SubscriptionPersistence.class)
4618 protected SubscriptionPersistence subscriptionPersistence;
4619 @BeanReference(type = TeamPersistence.class)
4620 protected TeamPersistence teamPersistence;
4621 @BeanReference(type = TicketPersistence.class)
4622 protected TicketPersistence ticketPersistence;
4623 @BeanReference(type = UserPersistence.class)
4624 protected UserPersistence userPersistence;
4625 @BeanReference(type = UserGroupPersistence.class)
4626 protected UserGroupPersistence userGroupPersistence;
4627 @BeanReference(type = UserGroupGroupRolePersistence.class)
4628 protected UserGroupGroupRolePersistence userGroupGroupRolePersistence;
4629 @BeanReference(type = UserGroupRolePersistence.class)
4630 protected UserGroupRolePersistence userGroupRolePersistence;
4631 @BeanReference(type = UserIdMapperPersistence.class)
4632 protected UserIdMapperPersistence userIdMapperPersistence;
4633 @BeanReference(type = UserNotificationEventPersistence.class)
4634 protected UserNotificationEventPersistence userNotificationEventPersistence;
4635 @BeanReference(type = UserTrackerPersistence.class)
4636 protected UserTrackerPersistence userTrackerPersistence;
4637 @BeanReference(type = UserTrackerPathPersistence.class)
4638 protected UserTrackerPathPersistence userTrackerPathPersistence;
4639 @BeanReference(type = VirtualHostPersistence.class)
4640 protected VirtualHostPersistence virtualHostPersistence;
4641 @BeanReference(type = WebDAVPropsPersistence.class)
4642 protected WebDAVPropsPersistence webDAVPropsPersistence;
4643 @BeanReference(type = WebsitePersistence.class)
4644 protected WebsitePersistence websitePersistence;
4645 @BeanReference(type = WorkflowDefinitionLinkPersistence.class)
4646 protected WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
4647 @BeanReference(type = WorkflowInstanceLinkPersistence.class)
4648 protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
4649 @BeanReference(type = AssetEntryPersistence.class)
4650 protected AssetEntryPersistence assetEntryPersistence;
4651 @BeanReference(type = ExpandoValuePersistence.class)
4652 protected ExpandoValuePersistence expandoValuePersistence;
4653 protected ContainsGroup containsGroup;
4654 protected AddGroup addGroup;
4655 protected ClearGroups clearGroups;
4656 protected RemoveGroup removeGroup;
4657 protected ContainsUser containsUser;
4658 protected AddUser addUser;
4659 protected ClearUsers clearUsers;
4660 protected RemoveUser removeUser;
4661
4662 protected class ContainsGroup {
4663 protected ContainsGroup() {
4664 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
4665 _SQL_CONTAINSGROUP,
4666 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
4667 RowMapper.COUNT);
4668 }
4669
4670 protected boolean contains(long organizationId, long groupId) {
4671 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
4672 new Long(organizationId), new Long(groupId)
4673 });
4674
4675 if (results.size() > 0) {
4676 Integer count = results.get(0);
4677
4678 if (count.intValue() > 0) {
4679 return true;
4680 }
4681 }
4682
4683 return false;
4684 }
4685
4686 private MappingSqlQuery<Integer> _mappingSqlQuery;
4687 }
4688
4689 protected class AddGroup {
4690 protected AddGroup() {
4691 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4692 "INSERT INTO Groups_Orgs (organizationId, groupId) VALUES (?, ?)",
4693 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
4694 }
4695
4696 protected void add(long organizationId, long groupId)
4697 throws SystemException {
4698 if (!containsGroup.contains(organizationId, groupId)) {
4699 ModelListener<com.liferay.portal.model.Group>[] groupListeners = groupPersistence.getListeners();
4700
4701 for (ModelListener<Organization> listener : listeners) {
4702 listener.onBeforeAddAssociation(organizationId,
4703 com.liferay.portal.model.Group.class.getName(), groupId);
4704 }
4705
4706 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
4707 listener.onBeforeAddAssociation(groupId,
4708 Organization.class.getName(), organizationId);
4709 }
4710
4711 _sqlUpdate.update(new Object[] {
4712 new Long(organizationId), new Long(groupId)
4713 });
4714
4715 for (ModelListener<Organization> listener : listeners) {
4716 listener.onAfterAddAssociation(organizationId,
4717 com.liferay.portal.model.Group.class.getName(), groupId);
4718 }
4719
4720 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
4721 listener.onAfterAddAssociation(groupId,
4722 Organization.class.getName(), organizationId);
4723 }
4724 }
4725 }
4726
4727 private SqlUpdate _sqlUpdate;
4728 }
4729
4730 protected class ClearGroups {
4731 protected ClearGroups() {
4732 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4733 "DELETE FROM Groups_Orgs WHERE organizationId = ?",
4734 new int[] { java.sql.Types.BIGINT });
4735 }
4736
4737 protected void clear(long organizationId) throws SystemException {
4738 ModelListener<com.liferay.portal.model.Group>[] groupListeners = groupPersistence.getListeners();
4739
4740 List<com.liferay.portal.model.Group> groups = null;
4741
4742 if ((listeners.length > 0) || (groupListeners.length > 0)) {
4743 groups = getGroups(organizationId);
4744
4745 for (com.liferay.portal.model.Group group : groups) {
4746 for (ModelListener<Organization> listener : listeners) {
4747 listener.onBeforeRemoveAssociation(organizationId,
4748 com.liferay.portal.model.Group.class.getName(),
4749 group.getPrimaryKey());
4750 }
4751
4752 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
4753 listener.onBeforeRemoveAssociation(group.getPrimaryKey(),
4754 Organization.class.getName(), organizationId);
4755 }
4756 }
4757 }
4758
4759 _sqlUpdate.update(new Object[] { new Long(organizationId) });
4760
4761 if ((listeners.length > 0) || (groupListeners.length > 0)) {
4762 for (com.liferay.portal.model.Group group : groups) {
4763 for (ModelListener<Organization> listener : listeners) {
4764 listener.onAfterRemoveAssociation(organizationId,
4765 com.liferay.portal.model.Group.class.getName(),
4766 group.getPrimaryKey());
4767 }
4768
4769 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
4770 listener.onAfterRemoveAssociation(group.getPrimaryKey(),
4771 Organization.class.getName(), organizationId);
4772 }
4773 }
4774 }
4775 }
4776
4777 private SqlUpdate _sqlUpdate;
4778 }
4779
4780 protected class RemoveGroup {
4781 protected RemoveGroup() {
4782 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4783 "DELETE FROM Groups_Orgs WHERE organizationId = ? AND groupId = ?",
4784 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
4785 }
4786
4787 protected void remove(long organizationId, long groupId)
4788 throws SystemException {
4789 if (containsGroup.contains(organizationId, groupId)) {
4790 ModelListener<com.liferay.portal.model.Group>[] groupListeners = groupPersistence.getListeners();
4791
4792 for (ModelListener<Organization> listener : listeners) {
4793 listener.onBeforeRemoveAssociation(organizationId,
4794 com.liferay.portal.model.Group.class.getName(), groupId);
4795 }
4796
4797 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
4798 listener.onBeforeRemoveAssociation(groupId,
4799 Organization.class.getName(), organizationId);
4800 }
4801
4802 _sqlUpdate.update(new Object[] {
4803 new Long(organizationId), new Long(groupId)
4804 });
4805
4806 for (ModelListener<Organization> listener : listeners) {
4807 listener.onAfterRemoveAssociation(organizationId,
4808 com.liferay.portal.model.Group.class.getName(), groupId);
4809 }
4810
4811 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
4812 listener.onAfterRemoveAssociation(groupId,
4813 Organization.class.getName(), organizationId);
4814 }
4815 }
4816 }
4817
4818 private SqlUpdate _sqlUpdate;
4819 }
4820
4821 protected class ContainsUser {
4822 protected ContainsUser() {
4823 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
4824 _SQL_CONTAINSUSER,
4825 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
4826 RowMapper.COUNT);
4827 }
4828
4829 protected boolean contains(long organizationId, long userId) {
4830 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
4831 new Long(organizationId), new Long(userId)
4832 });
4833
4834 if (results.size() > 0) {
4835 Integer count = results.get(0);
4836
4837 if (count.intValue() > 0) {
4838 return true;
4839 }
4840 }
4841
4842 return false;
4843 }
4844
4845 private MappingSqlQuery<Integer> _mappingSqlQuery;
4846 }
4847
4848 protected class AddUser {
4849 protected AddUser() {
4850 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4851 "INSERT INTO Users_Orgs (organizationId, userId) VALUES (?, ?)",
4852 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
4853 }
4854
4855 protected void add(long organizationId, long userId)
4856 throws SystemException {
4857 if (!containsUser.contains(organizationId, userId)) {
4858 ModelListener<com.liferay.portal.model.User>[] userListeners = userPersistence.getListeners();
4859
4860 for (ModelListener<Organization> listener : listeners) {
4861 listener.onBeforeAddAssociation(organizationId,
4862 com.liferay.portal.model.User.class.getName(), userId);
4863 }
4864
4865 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
4866 listener.onBeforeAddAssociation(userId,
4867 Organization.class.getName(), organizationId);
4868 }
4869
4870 _sqlUpdate.update(new Object[] {
4871 new Long(organizationId), new Long(userId)
4872 });
4873
4874 for (ModelListener<Organization> listener : listeners) {
4875 listener.onAfterAddAssociation(organizationId,
4876 com.liferay.portal.model.User.class.getName(), userId);
4877 }
4878
4879 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
4880 listener.onAfterAddAssociation(userId,
4881 Organization.class.getName(), organizationId);
4882 }
4883 }
4884 }
4885
4886 private SqlUpdate _sqlUpdate;
4887 }
4888
4889 protected class ClearUsers {
4890 protected ClearUsers() {
4891 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4892 "DELETE FROM Users_Orgs WHERE organizationId = ?",
4893 new int[] { java.sql.Types.BIGINT });
4894 }
4895
4896 protected void clear(long organizationId) throws SystemException {
4897 ModelListener<com.liferay.portal.model.User>[] userListeners = userPersistence.getListeners();
4898
4899 List<com.liferay.portal.model.User> users = null;
4900
4901 if ((listeners.length > 0) || (userListeners.length > 0)) {
4902 users = getUsers(organizationId);
4903
4904 for (com.liferay.portal.model.User user : users) {
4905 for (ModelListener<Organization> listener : listeners) {
4906 listener.onBeforeRemoveAssociation(organizationId,
4907 com.liferay.portal.model.User.class.getName(),
4908 user.getPrimaryKey());
4909 }
4910
4911 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
4912 listener.onBeforeRemoveAssociation(user.getPrimaryKey(),
4913 Organization.class.getName(), organizationId);
4914 }
4915 }
4916 }
4917
4918 _sqlUpdate.update(new Object[] { new Long(organizationId) });
4919
4920 if ((listeners.length > 0) || (userListeners.length > 0)) {
4921 for (com.liferay.portal.model.User user : users) {
4922 for (ModelListener<Organization> listener : listeners) {
4923 listener.onAfterRemoveAssociation(organizationId,
4924 com.liferay.portal.model.User.class.getName(),
4925 user.getPrimaryKey());
4926 }
4927
4928 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
4929 listener.onAfterRemoveAssociation(user.getPrimaryKey(),
4930 Organization.class.getName(), organizationId);
4931 }
4932 }
4933 }
4934 }
4935
4936 private SqlUpdate _sqlUpdate;
4937 }
4938
4939 protected class RemoveUser {
4940 protected RemoveUser() {
4941 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4942 "DELETE FROM Users_Orgs WHERE organizationId = ? AND userId = ?",
4943 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
4944 }
4945
4946 protected void remove(long organizationId, long userId)
4947 throws SystemException {
4948 if (containsUser.contains(organizationId, userId)) {
4949 ModelListener<com.liferay.portal.model.User>[] userListeners = userPersistence.getListeners();
4950
4951 for (ModelListener<Organization> listener : listeners) {
4952 listener.onBeforeRemoveAssociation(organizationId,
4953 com.liferay.portal.model.User.class.getName(), userId);
4954 }
4955
4956 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
4957 listener.onBeforeRemoveAssociation(userId,
4958 Organization.class.getName(), organizationId);
4959 }
4960
4961 _sqlUpdate.update(new Object[] {
4962 new Long(organizationId), new Long(userId)
4963 });
4964
4965 for (ModelListener<Organization> listener : listeners) {
4966 listener.onAfterRemoveAssociation(organizationId,
4967 com.liferay.portal.model.User.class.getName(), userId);
4968 }
4969
4970 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
4971 listener.onAfterRemoveAssociation(userId,
4972 Organization.class.getName(), organizationId);
4973 }
4974 }
4975 }
4976
4977 private SqlUpdate _sqlUpdate;
4978 }
4979
4980 private static final String _SQL_SELECT_ORGANIZATION = "SELECT organization FROM Organization organization";
4981 private static final String _SQL_SELECT_ORGANIZATION_WHERE = "SELECT organization FROM Organization organization WHERE ";
4982 private static final String _SQL_COUNT_ORGANIZATION = "SELECT COUNT(organization) FROM Organization organization";
4983 private static final String _SQL_COUNT_ORGANIZATION_WHERE = "SELECT COUNT(organization) FROM Organization organization WHERE ";
4984 private static final String _SQL_GETGROUPS = "SELECT {Group_.*} FROM Group_ INNER JOIN Groups_Orgs ON (Groups_Orgs.groupId = Group_.groupId) WHERE (Groups_Orgs.organizationId = ?)";
4985 private static final String _SQL_GETGROUPSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Groups_Orgs WHERE organizationId = ?";
4986 private static final String _SQL_CONTAINSGROUP = "SELECT COUNT(*) AS COUNT_VALUE FROM Groups_Orgs WHERE organizationId = ? AND groupId = ?";
4987 private static final String _SQL_GETUSERS = "SELECT {User_.*} FROM User_ INNER JOIN Users_Orgs ON (Users_Orgs.userId = User_.userId) WHERE (Users_Orgs.organizationId = ?)";
4988 private static final String _SQL_GETUSERSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_Orgs WHERE organizationId = ?";
4989 private static final String _SQL_CONTAINSUSER = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_Orgs WHERE organizationId = ? AND userId = ?";
4990 private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "organization.companyId = ?";
4991 private static final String _FINDER_COLUMN_LOCATIONS_COMPANYID_2 = "organization.companyId = ? AND organization.parentOrganizationId != 0";
4992 private static final String _FINDER_COLUMN_C_P_COMPANYID_2 = "organization.companyId = ? AND ";
4993 private static final String _FINDER_COLUMN_C_P_PARENTORGANIZATIONID_2 = "organization.parentOrganizationId = ?";
4994 private static final String _FINDER_COLUMN_C_N_COMPANYID_2 = "organization.companyId = ? AND ";
4995 private static final String _FINDER_COLUMN_C_N_NAME_1 = "organization.name IS NULL";
4996 private static final String _FINDER_COLUMN_C_N_NAME_2 = "organization.name = ?";
4997 private static final String _FINDER_COLUMN_C_N_NAME_3 = "(organization.name IS NULL OR organization.name = ?)";
4998 private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "organization.organizationId";
4999 private static final String _FILTER_SQL_SELECT_ORGANIZATION_WHERE = "SELECT DISTINCT {organization.*} FROM Organization_ organization WHERE ";
5000 private static final String _FILTER_SQL_SELECT_ORGANIZATION_NO_INLINE_DISTINCT_WHERE_1 =
5001 "SELECT {Organization_.*} FROM (SELECT DISTINCT organization.organizationId FROM Organization_ organization WHERE ";
5002 private static final String _FILTER_SQL_SELECT_ORGANIZATION_NO_INLINE_DISTINCT_WHERE_2 =
5003 ") TEMP_TABLE INNER JOIN Organization_ ON TEMP_TABLE.organizationId = Organization_.organizationId";
5004 private static final String _FILTER_SQL_COUNT_ORGANIZATION_WHERE = "SELECT COUNT(DISTINCT organization.organizationId) AS COUNT_VALUE FROM Organization_ organization WHERE ";
5005 private static final String _FILTER_ENTITY_ALIAS = "organization";
5006 private static final String _FILTER_ENTITY_TABLE = "Organization_";
5007 private static final String _ORDER_BY_ENTITY_ALIAS = "organization.";
5008 private static final String _ORDER_BY_ENTITY_TABLE = "Organization_.";
5009 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No Organization exists with the primary key ";
5010 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No Organization exists with the key {";
5011 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
5012 private static Log _log = LogFactoryUtil.getLog(OrganizationPersistenceImpl.class);
5013 private static Organization _nullOrganization = new OrganizationImpl() {
5014 @Override
5015 public Object clone() {
5016 return this;
5017 }
5018
5019 @Override
5020 public CacheModel<Organization> toCacheModel() {
5021 return _nullOrganizationCacheModel;
5022 }
5023 };
5024
5025 private static CacheModel<Organization> _nullOrganizationCacheModel = new CacheModel<Organization>() {
5026 public Organization toEntityModel() {
5027 return _nullOrganization;
5028 }
5029 };
5030 }