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 if (organization.isCachedModel()) {
363 organization = (Organization)session.get(OrganizationImpl.class,
364 organization.getPrimaryKeyObj());
365 }
366
367 session.delete(organization);
368 }
369 catch (Exception e) {
370 throw processException(e);
371 }
372 finally {
373 closeSession(session);
374 }
375
376 clearCache(organization);
377
378 return organization;
379 }
380
381 @Override
382 public Organization updateImpl(
383 com.liferay.portal.model.Organization organization)
384 throws SystemException {
385 organization = toUnwrappedModel(organization);
386
387 boolean isNew = organization.isNew();
388
389 OrganizationModelImpl organizationModelImpl = (OrganizationModelImpl)organization;
390
391 Session session = null;
392
393 try {
394 session = openSession();
395
396 if (organization.isNew()) {
397 session.save(organization);
398
399 organization.setNew(false);
400 }
401 else {
402 session.merge(organization);
403 }
404 }
405 catch (Exception e) {
406 throw processException(e);
407 }
408 finally {
409 closeSession(session);
410 }
411
412 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
413
414 if (isNew || !OrganizationModelImpl.COLUMN_BITMASK_ENABLED) {
415 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
416 }
417
418 else {
419 if ((organizationModelImpl.getColumnBitmask() &
420 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
421 Object[] args = new Object[] {
422 Long.valueOf(organizationModelImpl.getOriginalCompanyId())
423 };
424
425 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
426 args);
427 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
428 args);
429
430 args = new Object[] {
431 Long.valueOf(organizationModelImpl.getCompanyId())
432 };
433
434 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
435 args);
436 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
437 args);
438 }
439
440 if ((organizationModelImpl.getColumnBitmask() &
441 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LOCATIONS.getColumnBitmask()) != 0) {
442 Object[] args = new Object[] {
443 Long.valueOf(organizationModelImpl.getOriginalCompanyId())
444 };
445
446 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_LOCATIONS,
447 args);
448 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LOCATIONS,
449 args);
450
451 args = new Object[] {
452 Long.valueOf(organizationModelImpl.getCompanyId())
453 };
454
455 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_LOCATIONS,
456 args);
457 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LOCATIONS,
458 args);
459 }
460
461 if ((organizationModelImpl.getColumnBitmask() &
462 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_P.getColumnBitmask()) != 0) {
463 Object[] args = new Object[] {
464 Long.valueOf(organizationModelImpl.getOriginalCompanyId()),
465 Long.valueOf(organizationModelImpl.getOriginalParentOrganizationId())
466 };
467
468 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_P, args);
469 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_P,
470 args);
471
472 args = new Object[] {
473 Long.valueOf(organizationModelImpl.getCompanyId()),
474 Long.valueOf(organizationModelImpl.getParentOrganizationId())
475 };
476
477 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_P, args);
478 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_P,
479 args);
480 }
481 }
482
483 EntityCacheUtil.putResult(OrganizationModelImpl.ENTITY_CACHE_ENABLED,
484 OrganizationImpl.class, organization.getPrimaryKey(), organization);
485
486 if (isNew) {
487 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N,
488 new Object[] {
489 Long.valueOf(organization.getCompanyId()),
490
491 organization.getName()
492 }, organization);
493 }
494 else {
495 if ((organizationModelImpl.getColumnBitmask() &
496 FINDER_PATH_FETCH_BY_C_N.getColumnBitmask()) != 0) {
497 Object[] args = new Object[] {
498 Long.valueOf(organizationModelImpl.getOriginalCompanyId()),
499
500 organizationModelImpl.getOriginalName()
501 };
502
503 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_N, args);
504
505 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_N, args);
506
507 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N,
508 new Object[] {
509 Long.valueOf(organization.getCompanyId()),
510
511 organization.getName()
512 }, organization);
513 }
514 }
515
516 return organization;
517 }
518
519 protected Organization toUnwrappedModel(Organization organization) {
520 if (organization instanceof OrganizationImpl) {
521 return organization;
522 }
523
524 OrganizationImpl organizationImpl = new OrganizationImpl();
525
526 organizationImpl.setNew(organization.isNew());
527 organizationImpl.setPrimaryKey(organization.getPrimaryKey());
528
529 organizationImpl.setOrganizationId(organization.getOrganizationId());
530 organizationImpl.setCompanyId(organization.getCompanyId());
531 organizationImpl.setParentOrganizationId(organization.getParentOrganizationId());
532 organizationImpl.setTreePath(organization.getTreePath());
533 organizationImpl.setName(organization.getName());
534 organizationImpl.setType(organization.getType());
535 organizationImpl.setRecursable(organization.isRecursable());
536 organizationImpl.setRegionId(organization.getRegionId());
537 organizationImpl.setCountryId(organization.getCountryId());
538 organizationImpl.setStatusId(organization.getStatusId());
539 organizationImpl.setComments(organization.getComments());
540
541 return organizationImpl;
542 }
543
544
552 @Override
553 public Organization findByPrimaryKey(Serializable primaryKey)
554 throws NoSuchModelException, SystemException {
555 return findByPrimaryKey(((Long)primaryKey).longValue());
556 }
557
558
566 public Organization findByPrimaryKey(long organizationId)
567 throws NoSuchOrganizationException, SystemException {
568 Organization organization = fetchByPrimaryKey(organizationId);
569
570 if (organization == null) {
571 if (_log.isWarnEnabled()) {
572 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + organizationId);
573 }
574
575 throw new NoSuchOrganizationException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
576 organizationId);
577 }
578
579 return organization;
580 }
581
582
589 @Override
590 public Organization fetchByPrimaryKey(Serializable primaryKey)
591 throws SystemException {
592 return fetchByPrimaryKey(((Long)primaryKey).longValue());
593 }
594
595
602 public Organization fetchByPrimaryKey(long organizationId)
603 throws SystemException {
604 Organization organization = (Organization)EntityCacheUtil.getResult(OrganizationModelImpl.ENTITY_CACHE_ENABLED,
605 OrganizationImpl.class, organizationId);
606
607 if (organization == _nullOrganization) {
608 return null;
609 }
610
611 if (organization == null) {
612 Session session = null;
613
614 boolean hasException = false;
615
616 try {
617 session = openSession();
618
619 organization = (Organization)session.get(OrganizationImpl.class,
620 Long.valueOf(organizationId));
621 }
622 catch (Exception e) {
623 hasException = true;
624
625 throw processException(e);
626 }
627 finally {
628 if (organization != null) {
629 cacheResult(organization);
630 }
631 else if (!hasException) {
632 EntityCacheUtil.putResult(OrganizationModelImpl.ENTITY_CACHE_ENABLED,
633 OrganizationImpl.class, organizationId,
634 _nullOrganization);
635 }
636
637 closeSession(session);
638 }
639 }
640
641 return organization;
642 }
643
644
651 public List<Organization> findByCompanyId(long companyId)
652 throws SystemException {
653 return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
654 null);
655 }
656
657
670 public List<Organization> findByCompanyId(long companyId, int start, int end)
671 throws SystemException {
672 return findByCompanyId(companyId, start, end, null);
673 }
674
675
689 public List<Organization> findByCompanyId(long companyId, int start,
690 int end, OrderByComparator orderByComparator) throws SystemException {
691 FinderPath finderPath = null;
692 Object[] finderArgs = null;
693
694 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
695 (orderByComparator == null)) {
696 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID;
697 finderArgs = new Object[] { companyId };
698 }
699 else {
700 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID;
701 finderArgs = new Object[] { companyId, start, end, orderByComparator };
702 }
703
704 List<Organization> list = (List<Organization>)FinderCacheUtil.getResult(finderPath,
705 finderArgs, this);
706
707 if ((list != null) && !list.isEmpty()) {
708 for (Organization organization : list) {
709 if ((companyId != organization.getCompanyId())) {
710 list = null;
711
712 break;
713 }
714 }
715 }
716
717 if (list == null) {
718 StringBundler query = null;
719
720 if (orderByComparator != null) {
721 query = new StringBundler(3 +
722 (orderByComparator.getOrderByFields().length * 3));
723 }
724 else {
725 query = new StringBundler(3);
726 }
727
728 query.append(_SQL_SELECT_ORGANIZATION_WHERE);
729
730 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
731
732 if (orderByComparator != null) {
733 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
734 orderByComparator);
735 }
736
737 else {
738 query.append(OrganizationModelImpl.ORDER_BY_JPQL);
739 }
740
741 String sql = query.toString();
742
743 Session session = null;
744
745 try {
746 session = openSession();
747
748 Query q = session.createQuery(sql);
749
750 QueryPos qPos = QueryPos.getInstance(q);
751
752 qPos.add(companyId);
753
754 list = (List<Organization>)QueryUtil.list(q, getDialect(),
755 start, end);
756 }
757 catch (Exception e) {
758 throw processException(e);
759 }
760 finally {
761 if (list == null) {
762 FinderCacheUtil.removeResult(finderPath, finderArgs);
763 }
764 else {
765 cacheResult(list);
766
767 FinderCacheUtil.putResult(finderPath, finderArgs, list);
768 }
769
770 closeSession(session);
771 }
772 }
773
774 return list;
775 }
776
777
786 public Organization findByCompanyId_First(long companyId,
787 OrderByComparator orderByComparator)
788 throws NoSuchOrganizationException, SystemException {
789 Organization organization = fetchByCompanyId_First(companyId,
790 orderByComparator);
791
792 if (organization != null) {
793 return organization;
794 }
795
796 StringBundler msg = new StringBundler(4);
797
798 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
799
800 msg.append("companyId=");
801 msg.append(companyId);
802
803 msg.append(StringPool.CLOSE_CURLY_BRACE);
804
805 throw new NoSuchOrganizationException(msg.toString());
806 }
807
808
816 public Organization fetchByCompanyId_First(long companyId,
817 OrderByComparator orderByComparator) throws SystemException {
818 List<Organization> list = findByCompanyId(companyId, 0, 1,
819 orderByComparator);
820
821 if (!list.isEmpty()) {
822 return list.get(0);
823 }
824
825 return null;
826 }
827
828
837 public Organization findByCompanyId_Last(long companyId,
838 OrderByComparator orderByComparator)
839 throws NoSuchOrganizationException, SystemException {
840 Organization organization = fetchByCompanyId_Last(companyId,
841 orderByComparator);
842
843 if (organization != null) {
844 return organization;
845 }
846
847 StringBundler msg = new StringBundler(4);
848
849 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
850
851 msg.append("companyId=");
852 msg.append(companyId);
853
854 msg.append(StringPool.CLOSE_CURLY_BRACE);
855
856 throw new NoSuchOrganizationException(msg.toString());
857 }
858
859
867 public Organization fetchByCompanyId_Last(long companyId,
868 OrderByComparator orderByComparator) throws SystemException {
869 int count = countByCompanyId(companyId);
870
871 List<Organization> list = findByCompanyId(companyId, count - 1, count,
872 orderByComparator);
873
874 if (!list.isEmpty()) {
875 return list.get(0);
876 }
877
878 return null;
879 }
880
881
891 public Organization[] findByCompanyId_PrevAndNext(long organizationId,
892 long companyId, OrderByComparator orderByComparator)
893 throws NoSuchOrganizationException, SystemException {
894 Organization organization = findByPrimaryKey(organizationId);
895
896 Session session = null;
897
898 try {
899 session = openSession();
900
901 Organization[] array = new OrganizationImpl[3];
902
903 array[0] = getByCompanyId_PrevAndNext(session, organization,
904 companyId, orderByComparator, true);
905
906 array[1] = organization;
907
908 array[2] = getByCompanyId_PrevAndNext(session, organization,
909 companyId, orderByComparator, false);
910
911 return array;
912 }
913 catch (Exception e) {
914 throw processException(e);
915 }
916 finally {
917 closeSession(session);
918 }
919 }
920
921 protected Organization getByCompanyId_PrevAndNext(Session session,
922 Organization organization, long companyId,
923 OrderByComparator orderByComparator, boolean previous) {
924 StringBundler query = null;
925
926 if (orderByComparator != null) {
927 query = new StringBundler(6 +
928 (orderByComparator.getOrderByFields().length * 6));
929 }
930 else {
931 query = new StringBundler(3);
932 }
933
934 query.append(_SQL_SELECT_ORGANIZATION_WHERE);
935
936 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
937
938 if (orderByComparator != null) {
939 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
940
941 if (orderByConditionFields.length > 0) {
942 query.append(WHERE_AND);
943 }
944
945 for (int i = 0; i < orderByConditionFields.length; i++) {
946 query.append(_ORDER_BY_ENTITY_ALIAS);
947 query.append(orderByConditionFields[i]);
948
949 if ((i + 1) < orderByConditionFields.length) {
950 if (orderByComparator.isAscending() ^ previous) {
951 query.append(WHERE_GREATER_THAN_HAS_NEXT);
952 }
953 else {
954 query.append(WHERE_LESSER_THAN_HAS_NEXT);
955 }
956 }
957 else {
958 if (orderByComparator.isAscending() ^ previous) {
959 query.append(WHERE_GREATER_THAN);
960 }
961 else {
962 query.append(WHERE_LESSER_THAN);
963 }
964 }
965 }
966
967 query.append(ORDER_BY_CLAUSE);
968
969 String[] orderByFields = orderByComparator.getOrderByFields();
970
971 for (int i = 0; i < orderByFields.length; i++) {
972 query.append(_ORDER_BY_ENTITY_ALIAS);
973 query.append(orderByFields[i]);
974
975 if ((i + 1) < orderByFields.length) {
976 if (orderByComparator.isAscending() ^ previous) {
977 query.append(ORDER_BY_ASC_HAS_NEXT);
978 }
979 else {
980 query.append(ORDER_BY_DESC_HAS_NEXT);
981 }
982 }
983 else {
984 if (orderByComparator.isAscending() ^ previous) {
985 query.append(ORDER_BY_ASC);
986 }
987 else {
988 query.append(ORDER_BY_DESC);
989 }
990 }
991 }
992 }
993
994 else {
995 query.append(OrganizationModelImpl.ORDER_BY_JPQL);
996 }
997
998 String sql = query.toString();
999
1000 Query q = session.createQuery(sql);
1001
1002 q.setFirstResult(0);
1003 q.setMaxResults(2);
1004
1005 QueryPos qPos = QueryPos.getInstance(q);
1006
1007 qPos.add(companyId);
1008
1009 if (orderByComparator != null) {
1010 Object[] values = orderByComparator.getOrderByConditionValues(organization);
1011
1012 for (Object value : values) {
1013 qPos.add(value);
1014 }
1015 }
1016
1017 List<Organization> list = q.list();
1018
1019 if (list.size() == 2) {
1020 return list.get(1);
1021 }
1022 else {
1023 return null;
1024 }
1025 }
1026
1027
1034 public List<Organization> filterFindByCompanyId(long companyId)
1035 throws SystemException {
1036 return filterFindByCompanyId(companyId, QueryUtil.ALL_POS,
1037 QueryUtil.ALL_POS, null);
1038 }
1039
1040
1053 public List<Organization> filterFindByCompanyId(long companyId, int start,
1054 int end) throws SystemException {
1055 return filterFindByCompanyId(companyId, start, end, null);
1056 }
1057
1058
1072 public List<Organization> filterFindByCompanyId(long companyId, int start,
1073 int end, OrderByComparator orderByComparator) throws SystemException {
1074 if (!InlineSQLHelperUtil.isEnabled()) {
1075 return findByCompanyId(companyId, start, end, orderByComparator);
1076 }
1077
1078 StringBundler query = null;
1079
1080 if (orderByComparator != null) {
1081 query = new StringBundler(3 +
1082 (orderByComparator.getOrderByFields().length * 3));
1083 }
1084 else {
1085 query = new StringBundler(3);
1086 }
1087
1088 if (getDB().isSupportsInlineDistinct()) {
1089 query.append(_FILTER_SQL_SELECT_ORGANIZATION_WHERE);
1090 }
1091 else {
1092 query.append(_FILTER_SQL_SELECT_ORGANIZATION_NO_INLINE_DISTINCT_WHERE_1);
1093 }
1094
1095 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1096
1097 if (!getDB().isSupportsInlineDistinct()) {
1098 query.append(_FILTER_SQL_SELECT_ORGANIZATION_NO_INLINE_DISTINCT_WHERE_2);
1099 }
1100
1101 if (orderByComparator != null) {
1102 if (getDB().isSupportsInlineDistinct()) {
1103 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1104 orderByComparator);
1105 }
1106 else {
1107 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
1108 orderByComparator);
1109 }
1110 }
1111
1112 else {
1113 if (getDB().isSupportsInlineDistinct()) {
1114 query.append(OrganizationModelImpl.ORDER_BY_JPQL);
1115 }
1116 else {
1117 query.append(OrganizationModelImpl.ORDER_BY_SQL);
1118 }
1119 }
1120
1121 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1122 Organization.class.getName(),
1123 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
1124
1125 Session session = null;
1126
1127 try {
1128 session = openSession();
1129
1130 SQLQuery q = session.createSQLQuery(sql);
1131
1132 if (getDB().isSupportsInlineDistinct()) {
1133 q.addEntity(_FILTER_ENTITY_ALIAS, OrganizationImpl.class);
1134 }
1135 else {
1136 q.addEntity(_FILTER_ENTITY_TABLE, OrganizationImpl.class);
1137 }
1138
1139 QueryPos qPos = QueryPos.getInstance(q);
1140
1141 qPos.add(companyId);
1142
1143 return (List<Organization>)QueryUtil.list(q, getDialect(), start,
1144 end);
1145 }
1146 catch (Exception e) {
1147 throw processException(e);
1148 }
1149 finally {
1150 closeSession(session);
1151 }
1152 }
1153
1154
1164 public Organization[] filterFindByCompanyId_PrevAndNext(
1165 long organizationId, long companyId, OrderByComparator orderByComparator)
1166 throws NoSuchOrganizationException, SystemException {
1167 if (!InlineSQLHelperUtil.isEnabled()) {
1168 return findByCompanyId_PrevAndNext(organizationId, companyId,
1169 orderByComparator);
1170 }
1171
1172 Organization organization = findByPrimaryKey(organizationId);
1173
1174 Session session = null;
1175
1176 try {
1177 session = openSession();
1178
1179 Organization[] array = new OrganizationImpl[3];
1180
1181 array[0] = filterGetByCompanyId_PrevAndNext(session, organization,
1182 companyId, orderByComparator, true);
1183
1184 array[1] = organization;
1185
1186 array[2] = filterGetByCompanyId_PrevAndNext(session, organization,
1187 companyId, orderByComparator, false);
1188
1189 return array;
1190 }
1191 catch (Exception e) {
1192 throw processException(e);
1193 }
1194 finally {
1195 closeSession(session);
1196 }
1197 }
1198
1199 protected Organization filterGetByCompanyId_PrevAndNext(Session session,
1200 Organization organization, long companyId,
1201 OrderByComparator orderByComparator, boolean previous) {
1202 StringBundler query = null;
1203
1204 if (orderByComparator != null) {
1205 query = new StringBundler(6 +
1206 (orderByComparator.getOrderByFields().length * 6));
1207 }
1208 else {
1209 query = new StringBundler(3);
1210 }
1211
1212 if (getDB().isSupportsInlineDistinct()) {
1213 query.append(_FILTER_SQL_SELECT_ORGANIZATION_WHERE);
1214 }
1215 else {
1216 query.append(_FILTER_SQL_SELECT_ORGANIZATION_NO_INLINE_DISTINCT_WHERE_1);
1217 }
1218
1219 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1220
1221 if (!getDB().isSupportsInlineDistinct()) {
1222 query.append(_FILTER_SQL_SELECT_ORGANIZATION_NO_INLINE_DISTINCT_WHERE_2);
1223 }
1224
1225 if (orderByComparator != null) {
1226 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1227
1228 if (orderByConditionFields.length > 0) {
1229 query.append(WHERE_AND);
1230 }
1231
1232 for (int i = 0; i < orderByConditionFields.length; i++) {
1233 if (getDB().isSupportsInlineDistinct()) {
1234 query.append(_ORDER_BY_ENTITY_ALIAS);
1235 }
1236 else {
1237 query.append(_ORDER_BY_ENTITY_TABLE);
1238 }
1239
1240 query.append(orderByConditionFields[i]);
1241
1242 if ((i + 1) < orderByConditionFields.length) {
1243 if (orderByComparator.isAscending() ^ previous) {
1244 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1245 }
1246 else {
1247 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1248 }
1249 }
1250 else {
1251 if (orderByComparator.isAscending() ^ previous) {
1252 query.append(WHERE_GREATER_THAN);
1253 }
1254 else {
1255 query.append(WHERE_LESSER_THAN);
1256 }
1257 }
1258 }
1259
1260 query.append(ORDER_BY_CLAUSE);
1261
1262 String[] orderByFields = orderByComparator.getOrderByFields();
1263
1264 for (int i = 0; i < orderByFields.length; i++) {
1265 if (getDB().isSupportsInlineDistinct()) {
1266 query.append(_ORDER_BY_ENTITY_ALIAS);
1267 }
1268 else {
1269 query.append(_ORDER_BY_ENTITY_TABLE);
1270 }
1271
1272 query.append(orderByFields[i]);
1273
1274 if ((i + 1) < orderByFields.length) {
1275 if (orderByComparator.isAscending() ^ previous) {
1276 query.append(ORDER_BY_ASC_HAS_NEXT);
1277 }
1278 else {
1279 query.append(ORDER_BY_DESC_HAS_NEXT);
1280 }
1281 }
1282 else {
1283 if (orderByComparator.isAscending() ^ previous) {
1284 query.append(ORDER_BY_ASC);
1285 }
1286 else {
1287 query.append(ORDER_BY_DESC);
1288 }
1289 }
1290 }
1291 }
1292
1293 else {
1294 if (getDB().isSupportsInlineDistinct()) {
1295 query.append(OrganizationModelImpl.ORDER_BY_JPQL);
1296 }
1297 else {
1298 query.append(OrganizationModelImpl.ORDER_BY_SQL);
1299 }
1300 }
1301
1302 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1303 Organization.class.getName(),
1304 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
1305
1306 SQLQuery q = session.createSQLQuery(sql);
1307
1308 q.setFirstResult(0);
1309 q.setMaxResults(2);
1310
1311 if (getDB().isSupportsInlineDistinct()) {
1312 q.addEntity(_FILTER_ENTITY_ALIAS, OrganizationImpl.class);
1313 }
1314 else {
1315 q.addEntity(_FILTER_ENTITY_TABLE, OrganizationImpl.class);
1316 }
1317
1318 QueryPos qPos = QueryPos.getInstance(q);
1319
1320 qPos.add(companyId);
1321
1322 if (orderByComparator != null) {
1323 Object[] values = orderByComparator.getOrderByConditionValues(organization);
1324
1325 for (Object value : values) {
1326 qPos.add(value);
1327 }
1328 }
1329
1330 List<Organization> list = q.list();
1331
1332 if (list.size() == 2) {
1333 return list.get(1);
1334 }
1335 else {
1336 return null;
1337 }
1338 }
1339
1340
1347 public List<Organization> findByLocations(long companyId)
1348 throws SystemException {
1349 return findByLocations(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
1350 null);
1351 }
1352
1353
1366 public List<Organization> findByLocations(long companyId, int start, int end)
1367 throws SystemException {
1368 return findByLocations(companyId, start, end, null);
1369 }
1370
1371
1385 public List<Organization> findByLocations(long companyId, int start,
1386 int end, OrderByComparator orderByComparator) throws SystemException {
1387 FinderPath finderPath = null;
1388 Object[] finderArgs = null;
1389
1390 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1391 (orderByComparator == null)) {
1392 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LOCATIONS;
1393 finderArgs = new Object[] { companyId };
1394 }
1395 else {
1396 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_LOCATIONS;
1397 finderArgs = new Object[] { companyId, start, end, orderByComparator };
1398 }
1399
1400 List<Organization> list = (List<Organization>)FinderCacheUtil.getResult(finderPath,
1401 finderArgs, this);
1402
1403 if ((list != null) && !list.isEmpty()) {
1404 for (Organization organization : list) {
1405 if ((companyId != organization.getCompanyId())) {
1406 list = null;
1407
1408 break;
1409 }
1410 }
1411 }
1412
1413 if (list == null) {
1414 StringBundler query = null;
1415
1416 if (orderByComparator != null) {
1417 query = new StringBundler(3 +
1418 (orderByComparator.getOrderByFields().length * 3));
1419 }
1420 else {
1421 query = new StringBundler(3);
1422 }
1423
1424 query.append(_SQL_SELECT_ORGANIZATION_WHERE);
1425
1426 query.append(_FINDER_COLUMN_LOCATIONS_COMPANYID_2);
1427
1428 if (orderByComparator != null) {
1429 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1430 orderByComparator);
1431 }
1432
1433 else {
1434 query.append(OrganizationModelImpl.ORDER_BY_JPQL);
1435 }
1436
1437 String sql = query.toString();
1438
1439 Session session = null;
1440
1441 try {
1442 session = openSession();
1443
1444 Query q = session.createQuery(sql);
1445
1446 QueryPos qPos = QueryPos.getInstance(q);
1447
1448 qPos.add(companyId);
1449
1450 list = (List<Organization>)QueryUtil.list(q, getDialect(),
1451 start, end);
1452 }
1453 catch (Exception e) {
1454 throw processException(e);
1455 }
1456 finally {
1457 if (list == null) {
1458 FinderCacheUtil.removeResult(finderPath, finderArgs);
1459 }
1460 else {
1461 cacheResult(list);
1462
1463 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1464 }
1465
1466 closeSession(session);
1467 }
1468 }
1469
1470 return list;
1471 }
1472
1473
1482 public Organization findByLocations_First(long companyId,
1483 OrderByComparator orderByComparator)
1484 throws NoSuchOrganizationException, SystemException {
1485 Organization organization = fetchByLocations_First(companyId,
1486 orderByComparator);
1487
1488 if (organization != null) {
1489 return organization;
1490 }
1491
1492 StringBundler msg = new StringBundler(4);
1493
1494 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1495
1496 msg.append("companyId=");
1497 msg.append(companyId);
1498
1499 msg.append(StringPool.CLOSE_CURLY_BRACE);
1500
1501 throw new NoSuchOrganizationException(msg.toString());
1502 }
1503
1504
1512 public Organization fetchByLocations_First(long companyId,
1513 OrderByComparator orderByComparator) throws SystemException {
1514 List<Organization> list = findByLocations(companyId, 0, 1,
1515 orderByComparator);
1516
1517 if (!list.isEmpty()) {
1518 return list.get(0);
1519 }
1520
1521 return null;
1522 }
1523
1524
1533 public Organization findByLocations_Last(long companyId,
1534 OrderByComparator orderByComparator)
1535 throws NoSuchOrganizationException, SystemException {
1536 Organization organization = fetchByLocations_Last(companyId,
1537 orderByComparator);
1538
1539 if (organization != null) {
1540 return organization;
1541 }
1542
1543 StringBundler msg = new StringBundler(4);
1544
1545 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1546
1547 msg.append("companyId=");
1548 msg.append(companyId);
1549
1550 msg.append(StringPool.CLOSE_CURLY_BRACE);
1551
1552 throw new NoSuchOrganizationException(msg.toString());
1553 }
1554
1555
1563 public Organization fetchByLocations_Last(long companyId,
1564 OrderByComparator orderByComparator) throws SystemException {
1565 int count = countByLocations(companyId);
1566
1567 List<Organization> list = findByLocations(companyId, count - 1, count,
1568 orderByComparator);
1569
1570 if (!list.isEmpty()) {
1571 return list.get(0);
1572 }
1573
1574 return null;
1575 }
1576
1577
1587 public Organization[] findByLocations_PrevAndNext(long organizationId,
1588 long companyId, OrderByComparator orderByComparator)
1589 throws NoSuchOrganizationException, SystemException {
1590 Organization organization = findByPrimaryKey(organizationId);
1591
1592 Session session = null;
1593
1594 try {
1595 session = openSession();
1596
1597 Organization[] array = new OrganizationImpl[3];
1598
1599 array[0] = getByLocations_PrevAndNext(session, organization,
1600 companyId, orderByComparator, true);
1601
1602 array[1] = organization;
1603
1604 array[2] = getByLocations_PrevAndNext(session, organization,
1605 companyId, orderByComparator, false);
1606
1607 return array;
1608 }
1609 catch (Exception e) {
1610 throw processException(e);
1611 }
1612 finally {
1613 closeSession(session);
1614 }
1615 }
1616
1617 protected Organization getByLocations_PrevAndNext(Session session,
1618 Organization organization, long companyId,
1619 OrderByComparator orderByComparator, boolean previous) {
1620 StringBundler query = null;
1621
1622 if (orderByComparator != null) {
1623 query = new StringBundler(6 +
1624 (orderByComparator.getOrderByFields().length * 6));
1625 }
1626 else {
1627 query = new StringBundler(3);
1628 }
1629
1630 query.append(_SQL_SELECT_ORGANIZATION_WHERE);
1631
1632 query.append(_FINDER_COLUMN_LOCATIONS_COMPANYID_2);
1633
1634 if (orderByComparator != null) {
1635 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1636
1637 if (orderByConditionFields.length > 0) {
1638 query.append(WHERE_AND);
1639 }
1640
1641 for (int i = 0; i < orderByConditionFields.length; i++) {
1642 query.append(_ORDER_BY_ENTITY_ALIAS);
1643 query.append(orderByConditionFields[i]);
1644
1645 if ((i + 1) < orderByConditionFields.length) {
1646 if (orderByComparator.isAscending() ^ previous) {
1647 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1648 }
1649 else {
1650 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1651 }
1652 }
1653 else {
1654 if (orderByComparator.isAscending() ^ previous) {
1655 query.append(WHERE_GREATER_THAN);
1656 }
1657 else {
1658 query.append(WHERE_LESSER_THAN);
1659 }
1660 }
1661 }
1662
1663 query.append(ORDER_BY_CLAUSE);
1664
1665 String[] orderByFields = orderByComparator.getOrderByFields();
1666
1667 for (int i = 0; i < orderByFields.length; i++) {
1668 query.append(_ORDER_BY_ENTITY_ALIAS);
1669 query.append(orderByFields[i]);
1670
1671 if ((i + 1) < orderByFields.length) {
1672 if (orderByComparator.isAscending() ^ previous) {
1673 query.append(ORDER_BY_ASC_HAS_NEXT);
1674 }
1675 else {
1676 query.append(ORDER_BY_DESC_HAS_NEXT);
1677 }
1678 }
1679 else {
1680 if (orderByComparator.isAscending() ^ previous) {
1681 query.append(ORDER_BY_ASC);
1682 }
1683 else {
1684 query.append(ORDER_BY_DESC);
1685 }
1686 }
1687 }
1688 }
1689
1690 else {
1691 query.append(OrganizationModelImpl.ORDER_BY_JPQL);
1692 }
1693
1694 String sql = query.toString();
1695
1696 Query q = session.createQuery(sql);
1697
1698 q.setFirstResult(0);
1699 q.setMaxResults(2);
1700
1701 QueryPos qPos = QueryPos.getInstance(q);
1702
1703 qPos.add(companyId);
1704
1705 if (orderByComparator != null) {
1706 Object[] values = orderByComparator.getOrderByConditionValues(organization);
1707
1708 for (Object value : values) {
1709 qPos.add(value);
1710 }
1711 }
1712
1713 List<Organization> list = q.list();
1714
1715 if (list.size() == 2) {
1716 return list.get(1);
1717 }
1718 else {
1719 return null;
1720 }
1721 }
1722
1723
1730 public List<Organization> filterFindByLocations(long companyId)
1731 throws SystemException {
1732 return filterFindByLocations(companyId, QueryUtil.ALL_POS,
1733 QueryUtil.ALL_POS, null);
1734 }
1735
1736
1749 public List<Organization> filterFindByLocations(long companyId, int start,
1750 int end) throws SystemException {
1751 return filterFindByLocations(companyId, start, end, null);
1752 }
1753
1754
1768 public List<Organization> filterFindByLocations(long companyId, int start,
1769 int end, OrderByComparator orderByComparator) throws SystemException {
1770 if (!InlineSQLHelperUtil.isEnabled()) {
1771 return findByLocations(companyId, start, end, orderByComparator);
1772 }
1773
1774 StringBundler query = null;
1775
1776 if (orderByComparator != null) {
1777 query = new StringBundler(3 +
1778 (orderByComparator.getOrderByFields().length * 3));
1779 }
1780 else {
1781 query = new StringBundler(3);
1782 }
1783
1784 if (getDB().isSupportsInlineDistinct()) {
1785 query.append(_FILTER_SQL_SELECT_ORGANIZATION_WHERE);
1786 }
1787 else {
1788 query.append(_FILTER_SQL_SELECT_ORGANIZATION_NO_INLINE_DISTINCT_WHERE_1);
1789 }
1790
1791 query.append(_FINDER_COLUMN_LOCATIONS_COMPANYID_2);
1792
1793 if (!getDB().isSupportsInlineDistinct()) {
1794 query.append(_FILTER_SQL_SELECT_ORGANIZATION_NO_INLINE_DISTINCT_WHERE_2);
1795 }
1796
1797 if (orderByComparator != null) {
1798 if (getDB().isSupportsInlineDistinct()) {
1799 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1800 orderByComparator);
1801 }
1802 else {
1803 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
1804 orderByComparator);
1805 }
1806 }
1807
1808 else {
1809 if (getDB().isSupportsInlineDistinct()) {
1810 query.append(OrganizationModelImpl.ORDER_BY_JPQL);
1811 }
1812 else {
1813 query.append(OrganizationModelImpl.ORDER_BY_SQL);
1814 }
1815 }
1816
1817 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1818 Organization.class.getName(),
1819 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
1820
1821 Session session = null;
1822
1823 try {
1824 session = openSession();
1825
1826 SQLQuery q = session.createSQLQuery(sql);
1827
1828 if (getDB().isSupportsInlineDistinct()) {
1829 q.addEntity(_FILTER_ENTITY_ALIAS, OrganizationImpl.class);
1830 }
1831 else {
1832 q.addEntity(_FILTER_ENTITY_TABLE, OrganizationImpl.class);
1833 }
1834
1835 QueryPos qPos = QueryPos.getInstance(q);
1836
1837 qPos.add(companyId);
1838
1839 return (List<Organization>)QueryUtil.list(q, getDialect(), start,
1840 end);
1841 }
1842 catch (Exception e) {
1843 throw processException(e);
1844 }
1845 finally {
1846 closeSession(session);
1847 }
1848 }
1849
1850
1860 public Organization[] filterFindByLocations_PrevAndNext(
1861 long organizationId, long companyId, OrderByComparator orderByComparator)
1862 throws NoSuchOrganizationException, SystemException {
1863 if (!InlineSQLHelperUtil.isEnabled()) {
1864 return findByLocations_PrevAndNext(organizationId, companyId,
1865 orderByComparator);
1866 }
1867
1868 Organization organization = findByPrimaryKey(organizationId);
1869
1870 Session session = null;
1871
1872 try {
1873 session = openSession();
1874
1875 Organization[] array = new OrganizationImpl[3];
1876
1877 array[0] = filterGetByLocations_PrevAndNext(session, organization,
1878 companyId, orderByComparator, true);
1879
1880 array[1] = organization;
1881
1882 array[2] = filterGetByLocations_PrevAndNext(session, organization,
1883 companyId, orderByComparator, false);
1884
1885 return array;
1886 }
1887 catch (Exception e) {
1888 throw processException(e);
1889 }
1890 finally {
1891 closeSession(session);
1892 }
1893 }
1894
1895 protected Organization filterGetByLocations_PrevAndNext(Session session,
1896 Organization organization, long companyId,
1897 OrderByComparator orderByComparator, boolean previous) {
1898 StringBundler query = null;
1899
1900 if (orderByComparator != null) {
1901 query = new StringBundler(6 +
1902 (orderByComparator.getOrderByFields().length * 6));
1903 }
1904 else {
1905 query = new StringBundler(3);
1906 }
1907
1908 if (getDB().isSupportsInlineDistinct()) {
1909 query.append(_FILTER_SQL_SELECT_ORGANIZATION_WHERE);
1910 }
1911 else {
1912 query.append(_FILTER_SQL_SELECT_ORGANIZATION_NO_INLINE_DISTINCT_WHERE_1);
1913 }
1914
1915 query.append(_FINDER_COLUMN_LOCATIONS_COMPANYID_2);
1916
1917 if (!getDB().isSupportsInlineDistinct()) {
1918 query.append(_FILTER_SQL_SELECT_ORGANIZATION_NO_INLINE_DISTINCT_WHERE_2);
1919 }
1920
1921 if (orderByComparator != null) {
1922 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1923
1924 if (orderByConditionFields.length > 0) {
1925 query.append(WHERE_AND);
1926 }
1927
1928 for (int i = 0; i < orderByConditionFields.length; i++) {
1929 if (getDB().isSupportsInlineDistinct()) {
1930 query.append(_ORDER_BY_ENTITY_ALIAS);
1931 }
1932 else {
1933 query.append(_ORDER_BY_ENTITY_TABLE);
1934 }
1935
1936 query.append(orderByConditionFields[i]);
1937
1938 if ((i + 1) < orderByConditionFields.length) {
1939 if (orderByComparator.isAscending() ^ previous) {
1940 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1941 }
1942 else {
1943 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1944 }
1945 }
1946 else {
1947 if (orderByComparator.isAscending() ^ previous) {
1948 query.append(WHERE_GREATER_THAN);
1949 }
1950 else {
1951 query.append(WHERE_LESSER_THAN);
1952 }
1953 }
1954 }
1955
1956 query.append(ORDER_BY_CLAUSE);
1957
1958 String[] orderByFields = orderByComparator.getOrderByFields();
1959
1960 for (int i = 0; i < orderByFields.length; i++) {
1961 if (getDB().isSupportsInlineDistinct()) {
1962 query.append(_ORDER_BY_ENTITY_ALIAS);
1963 }
1964 else {
1965 query.append(_ORDER_BY_ENTITY_TABLE);
1966 }
1967
1968 query.append(orderByFields[i]);
1969
1970 if ((i + 1) < orderByFields.length) {
1971 if (orderByComparator.isAscending() ^ previous) {
1972 query.append(ORDER_BY_ASC_HAS_NEXT);
1973 }
1974 else {
1975 query.append(ORDER_BY_DESC_HAS_NEXT);
1976 }
1977 }
1978 else {
1979 if (orderByComparator.isAscending() ^ previous) {
1980 query.append(ORDER_BY_ASC);
1981 }
1982 else {
1983 query.append(ORDER_BY_DESC);
1984 }
1985 }
1986 }
1987 }
1988
1989 else {
1990 if (getDB().isSupportsInlineDistinct()) {
1991 query.append(OrganizationModelImpl.ORDER_BY_JPQL);
1992 }
1993 else {
1994 query.append(OrganizationModelImpl.ORDER_BY_SQL);
1995 }
1996 }
1997
1998 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1999 Organization.class.getName(),
2000 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
2001
2002 SQLQuery q = session.createSQLQuery(sql);
2003
2004 q.setFirstResult(0);
2005 q.setMaxResults(2);
2006
2007 if (getDB().isSupportsInlineDistinct()) {
2008 q.addEntity(_FILTER_ENTITY_ALIAS, OrganizationImpl.class);
2009 }
2010 else {
2011 q.addEntity(_FILTER_ENTITY_TABLE, OrganizationImpl.class);
2012 }
2013
2014 QueryPos qPos = QueryPos.getInstance(q);
2015
2016 qPos.add(companyId);
2017
2018 if (orderByComparator != null) {
2019 Object[] values = orderByComparator.getOrderByConditionValues(organization);
2020
2021 for (Object value : values) {
2022 qPos.add(value);
2023 }
2024 }
2025
2026 List<Organization> list = q.list();
2027
2028 if (list.size() == 2) {
2029 return list.get(1);
2030 }
2031 else {
2032 return null;
2033 }
2034 }
2035
2036
2044 public List<Organization> findByC_P(long companyId,
2045 long parentOrganizationId) throws SystemException {
2046 return findByC_P(companyId, parentOrganizationId, QueryUtil.ALL_POS,
2047 QueryUtil.ALL_POS, null);
2048 }
2049
2050
2064 public List<Organization> findByC_P(long companyId,
2065 long parentOrganizationId, int start, int end)
2066 throws SystemException {
2067 return findByC_P(companyId, parentOrganizationId, start, end, null);
2068 }
2069
2070
2085 public List<Organization> findByC_P(long companyId,
2086 long parentOrganizationId, int start, int end,
2087 OrderByComparator orderByComparator) throws SystemException {
2088 FinderPath finderPath = null;
2089 Object[] finderArgs = null;
2090
2091 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2092 (orderByComparator == null)) {
2093 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_P;
2094 finderArgs = new Object[] { companyId, parentOrganizationId };
2095 }
2096 else {
2097 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_P;
2098 finderArgs = new Object[] {
2099 companyId, parentOrganizationId,
2100
2101 start, end, orderByComparator
2102 };
2103 }
2104
2105 List<Organization> list = (List<Organization>)FinderCacheUtil.getResult(finderPath,
2106 finderArgs, this);
2107
2108 if ((list != null) && !list.isEmpty()) {
2109 for (Organization organization : list) {
2110 if ((companyId != organization.getCompanyId()) ||
2111 (parentOrganizationId != organization.getParentOrganizationId())) {
2112 list = null;
2113
2114 break;
2115 }
2116 }
2117 }
2118
2119 if (list == null) {
2120 StringBundler query = null;
2121
2122 if (orderByComparator != null) {
2123 query = new StringBundler(4 +
2124 (orderByComparator.getOrderByFields().length * 3));
2125 }
2126 else {
2127 query = new StringBundler(4);
2128 }
2129
2130 query.append(_SQL_SELECT_ORGANIZATION_WHERE);
2131
2132 query.append(_FINDER_COLUMN_C_P_COMPANYID_2);
2133
2134 query.append(_FINDER_COLUMN_C_P_PARENTORGANIZATIONID_2);
2135
2136 if (orderByComparator != null) {
2137 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2138 orderByComparator);
2139 }
2140
2141 else {
2142 query.append(OrganizationModelImpl.ORDER_BY_JPQL);
2143 }
2144
2145 String sql = query.toString();
2146
2147 Session session = null;
2148
2149 try {
2150 session = openSession();
2151
2152 Query q = session.createQuery(sql);
2153
2154 QueryPos qPos = QueryPos.getInstance(q);
2155
2156 qPos.add(companyId);
2157
2158 qPos.add(parentOrganizationId);
2159
2160 list = (List<Organization>)QueryUtil.list(q, getDialect(),
2161 start, end);
2162 }
2163 catch (Exception e) {
2164 throw processException(e);
2165 }
2166 finally {
2167 if (list == null) {
2168 FinderCacheUtil.removeResult(finderPath, finderArgs);
2169 }
2170 else {
2171 cacheResult(list);
2172
2173 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2174 }
2175
2176 closeSession(session);
2177 }
2178 }
2179
2180 return list;
2181 }
2182
2183
2193 public Organization findByC_P_First(long companyId,
2194 long parentOrganizationId, OrderByComparator orderByComparator)
2195 throws NoSuchOrganizationException, SystemException {
2196 Organization organization = fetchByC_P_First(companyId,
2197 parentOrganizationId, orderByComparator);
2198
2199 if (organization != null) {
2200 return organization;
2201 }
2202
2203 StringBundler msg = new StringBundler(6);
2204
2205 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2206
2207 msg.append("companyId=");
2208 msg.append(companyId);
2209
2210 msg.append(", parentOrganizationId=");
2211 msg.append(parentOrganizationId);
2212
2213 msg.append(StringPool.CLOSE_CURLY_BRACE);
2214
2215 throw new NoSuchOrganizationException(msg.toString());
2216 }
2217
2218
2227 public Organization fetchByC_P_First(long companyId,
2228 long parentOrganizationId, OrderByComparator orderByComparator)
2229 throws SystemException {
2230 List<Organization> list = findByC_P(companyId, parentOrganizationId, 0,
2231 1, orderByComparator);
2232
2233 if (!list.isEmpty()) {
2234 return list.get(0);
2235 }
2236
2237 return null;
2238 }
2239
2240
2250 public Organization findByC_P_Last(long companyId,
2251 long parentOrganizationId, OrderByComparator orderByComparator)
2252 throws NoSuchOrganizationException, SystemException {
2253 Organization organization = fetchByC_P_Last(companyId,
2254 parentOrganizationId, orderByComparator);
2255
2256 if (organization != null) {
2257 return organization;
2258 }
2259
2260 StringBundler msg = new StringBundler(6);
2261
2262 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2263
2264 msg.append("companyId=");
2265 msg.append(companyId);
2266
2267 msg.append(", parentOrganizationId=");
2268 msg.append(parentOrganizationId);
2269
2270 msg.append(StringPool.CLOSE_CURLY_BRACE);
2271
2272 throw new NoSuchOrganizationException(msg.toString());
2273 }
2274
2275
2284 public Organization fetchByC_P_Last(long companyId,
2285 long parentOrganizationId, OrderByComparator orderByComparator)
2286 throws SystemException {
2287 int count = countByC_P(companyId, parentOrganizationId);
2288
2289 List<Organization> list = findByC_P(companyId, parentOrganizationId,
2290 count - 1, count, orderByComparator);
2291
2292 if (!list.isEmpty()) {
2293 return list.get(0);
2294 }
2295
2296 return null;
2297 }
2298
2299
2310 public Organization[] findByC_P_PrevAndNext(long organizationId,
2311 long companyId, long parentOrganizationId,
2312 OrderByComparator orderByComparator)
2313 throws NoSuchOrganizationException, SystemException {
2314 Organization organization = findByPrimaryKey(organizationId);
2315
2316 Session session = null;
2317
2318 try {
2319 session = openSession();
2320
2321 Organization[] array = new OrganizationImpl[3];
2322
2323 array[0] = getByC_P_PrevAndNext(session, organization, companyId,
2324 parentOrganizationId, orderByComparator, true);
2325
2326 array[1] = organization;
2327
2328 array[2] = getByC_P_PrevAndNext(session, organization, companyId,
2329 parentOrganizationId, orderByComparator, false);
2330
2331 return array;
2332 }
2333 catch (Exception e) {
2334 throw processException(e);
2335 }
2336 finally {
2337 closeSession(session);
2338 }
2339 }
2340
2341 protected Organization getByC_P_PrevAndNext(Session session,
2342 Organization organization, long companyId, long parentOrganizationId,
2343 OrderByComparator orderByComparator, boolean previous) {
2344 StringBundler query = null;
2345
2346 if (orderByComparator != null) {
2347 query = new StringBundler(6 +
2348 (orderByComparator.getOrderByFields().length * 6));
2349 }
2350 else {
2351 query = new StringBundler(3);
2352 }
2353
2354 query.append(_SQL_SELECT_ORGANIZATION_WHERE);
2355
2356 query.append(_FINDER_COLUMN_C_P_COMPANYID_2);
2357
2358 query.append(_FINDER_COLUMN_C_P_PARENTORGANIZATIONID_2);
2359
2360 if (orderByComparator != null) {
2361 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2362
2363 if (orderByConditionFields.length > 0) {
2364 query.append(WHERE_AND);
2365 }
2366
2367 for (int i = 0; i < orderByConditionFields.length; i++) {
2368 query.append(_ORDER_BY_ENTITY_ALIAS);
2369 query.append(orderByConditionFields[i]);
2370
2371 if ((i + 1) < orderByConditionFields.length) {
2372 if (orderByComparator.isAscending() ^ previous) {
2373 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2374 }
2375 else {
2376 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2377 }
2378 }
2379 else {
2380 if (orderByComparator.isAscending() ^ previous) {
2381 query.append(WHERE_GREATER_THAN);
2382 }
2383 else {
2384 query.append(WHERE_LESSER_THAN);
2385 }
2386 }
2387 }
2388
2389 query.append(ORDER_BY_CLAUSE);
2390
2391 String[] orderByFields = orderByComparator.getOrderByFields();
2392
2393 for (int i = 0; i < orderByFields.length; i++) {
2394 query.append(_ORDER_BY_ENTITY_ALIAS);
2395 query.append(orderByFields[i]);
2396
2397 if ((i + 1) < orderByFields.length) {
2398 if (orderByComparator.isAscending() ^ previous) {
2399 query.append(ORDER_BY_ASC_HAS_NEXT);
2400 }
2401 else {
2402 query.append(ORDER_BY_DESC_HAS_NEXT);
2403 }
2404 }
2405 else {
2406 if (orderByComparator.isAscending() ^ previous) {
2407 query.append(ORDER_BY_ASC);
2408 }
2409 else {
2410 query.append(ORDER_BY_DESC);
2411 }
2412 }
2413 }
2414 }
2415
2416 else {
2417 query.append(OrganizationModelImpl.ORDER_BY_JPQL);
2418 }
2419
2420 String sql = query.toString();
2421
2422 Query q = session.createQuery(sql);
2423
2424 q.setFirstResult(0);
2425 q.setMaxResults(2);
2426
2427 QueryPos qPos = QueryPos.getInstance(q);
2428
2429 qPos.add(companyId);
2430
2431 qPos.add(parentOrganizationId);
2432
2433 if (orderByComparator != null) {
2434 Object[] values = orderByComparator.getOrderByConditionValues(organization);
2435
2436 for (Object value : values) {
2437 qPos.add(value);
2438 }
2439 }
2440
2441 List<Organization> list = q.list();
2442
2443 if (list.size() == 2) {
2444 return list.get(1);
2445 }
2446 else {
2447 return null;
2448 }
2449 }
2450
2451
2459 public List<Organization> filterFindByC_P(long companyId,
2460 long parentOrganizationId) throws SystemException {
2461 return filterFindByC_P(companyId, parentOrganizationId,
2462 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2463 }
2464
2465
2479 public List<Organization> filterFindByC_P(long companyId,
2480 long parentOrganizationId, int start, int end)
2481 throws SystemException {
2482 return filterFindByC_P(companyId, parentOrganizationId, start, end, null);
2483 }
2484
2485
2500 public List<Organization> filterFindByC_P(long companyId,
2501 long parentOrganizationId, int start, int end,
2502 OrderByComparator orderByComparator) throws SystemException {
2503 if (!InlineSQLHelperUtil.isEnabled()) {
2504 return findByC_P(companyId, parentOrganizationId, start, end,
2505 orderByComparator);
2506 }
2507
2508 StringBundler query = null;
2509
2510 if (orderByComparator != null) {
2511 query = new StringBundler(4 +
2512 (orderByComparator.getOrderByFields().length * 3));
2513 }
2514 else {
2515 query = new StringBundler(4);
2516 }
2517
2518 if (getDB().isSupportsInlineDistinct()) {
2519 query.append(_FILTER_SQL_SELECT_ORGANIZATION_WHERE);
2520 }
2521 else {
2522 query.append(_FILTER_SQL_SELECT_ORGANIZATION_NO_INLINE_DISTINCT_WHERE_1);
2523 }
2524
2525 query.append(_FINDER_COLUMN_C_P_COMPANYID_2);
2526
2527 query.append(_FINDER_COLUMN_C_P_PARENTORGANIZATIONID_2);
2528
2529 if (!getDB().isSupportsInlineDistinct()) {
2530 query.append(_FILTER_SQL_SELECT_ORGANIZATION_NO_INLINE_DISTINCT_WHERE_2);
2531 }
2532
2533 if (orderByComparator != null) {
2534 if (getDB().isSupportsInlineDistinct()) {
2535 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2536 orderByComparator);
2537 }
2538 else {
2539 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
2540 orderByComparator);
2541 }
2542 }
2543
2544 else {
2545 if (getDB().isSupportsInlineDistinct()) {
2546 query.append(OrganizationModelImpl.ORDER_BY_JPQL);
2547 }
2548 else {
2549 query.append(OrganizationModelImpl.ORDER_BY_SQL);
2550 }
2551 }
2552
2553 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2554 Organization.class.getName(),
2555 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
2556
2557 Session session = null;
2558
2559 try {
2560 session = openSession();
2561
2562 SQLQuery q = session.createSQLQuery(sql);
2563
2564 if (getDB().isSupportsInlineDistinct()) {
2565 q.addEntity(_FILTER_ENTITY_ALIAS, OrganizationImpl.class);
2566 }
2567 else {
2568 q.addEntity(_FILTER_ENTITY_TABLE, OrganizationImpl.class);
2569 }
2570
2571 QueryPos qPos = QueryPos.getInstance(q);
2572
2573 qPos.add(companyId);
2574
2575 qPos.add(parentOrganizationId);
2576
2577 return (List<Organization>)QueryUtil.list(q, getDialect(), start,
2578 end);
2579 }
2580 catch (Exception e) {
2581 throw processException(e);
2582 }
2583 finally {
2584 closeSession(session);
2585 }
2586 }
2587
2588
2599 public Organization[] filterFindByC_P_PrevAndNext(long organizationId,
2600 long companyId, long parentOrganizationId,
2601 OrderByComparator orderByComparator)
2602 throws NoSuchOrganizationException, SystemException {
2603 if (!InlineSQLHelperUtil.isEnabled()) {
2604 return findByC_P_PrevAndNext(organizationId, companyId,
2605 parentOrganizationId, orderByComparator);
2606 }
2607
2608 Organization organization = findByPrimaryKey(organizationId);
2609
2610 Session session = null;
2611
2612 try {
2613 session = openSession();
2614
2615 Organization[] array = new OrganizationImpl[3];
2616
2617 array[0] = filterGetByC_P_PrevAndNext(session, organization,
2618 companyId, parentOrganizationId, orderByComparator, true);
2619
2620 array[1] = organization;
2621
2622 array[2] = filterGetByC_P_PrevAndNext(session, organization,
2623 companyId, parentOrganizationId, orderByComparator, false);
2624
2625 return array;
2626 }
2627 catch (Exception e) {
2628 throw processException(e);
2629 }
2630 finally {
2631 closeSession(session);
2632 }
2633 }
2634
2635 protected Organization filterGetByC_P_PrevAndNext(Session session,
2636 Organization organization, long companyId, long parentOrganizationId,
2637 OrderByComparator orderByComparator, boolean previous) {
2638 StringBundler query = null;
2639
2640 if (orderByComparator != null) {
2641 query = new StringBundler(6 +
2642 (orderByComparator.getOrderByFields().length * 6));
2643 }
2644 else {
2645 query = new StringBundler(3);
2646 }
2647
2648 if (getDB().isSupportsInlineDistinct()) {
2649 query.append(_FILTER_SQL_SELECT_ORGANIZATION_WHERE);
2650 }
2651 else {
2652 query.append(_FILTER_SQL_SELECT_ORGANIZATION_NO_INLINE_DISTINCT_WHERE_1);
2653 }
2654
2655 query.append(_FINDER_COLUMN_C_P_COMPANYID_2);
2656
2657 query.append(_FINDER_COLUMN_C_P_PARENTORGANIZATIONID_2);
2658
2659 if (!getDB().isSupportsInlineDistinct()) {
2660 query.append(_FILTER_SQL_SELECT_ORGANIZATION_NO_INLINE_DISTINCT_WHERE_2);
2661 }
2662
2663 if (orderByComparator != null) {
2664 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2665
2666 if (orderByConditionFields.length > 0) {
2667 query.append(WHERE_AND);
2668 }
2669
2670 for (int i = 0; i < orderByConditionFields.length; i++) {
2671 if (getDB().isSupportsInlineDistinct()) {
2672 query.append(_ORDER_BY_ENTITY_ALIAS);
2673 }
2674 else {
2675 query.append(_ORDER_BY_ENTITY_TABLE);
2676 }
2677
2678 query.append(orderByConditionFields[i]);
2679
2680 if ((i + 1) < orderByConditionFields.length) {
2681 if (orderByComparator.isAscending() ^ previous) {
2682 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2683 }
2684 else {
2685 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2686 }
2687 }
2688 else {
2689 if (orderByComparator.isAscending() ^ previous) {
2690 query.append(WHERE_GREATER_THAN);
2691 }
2692 else {
2693 query.append(WHERE_LESSER_THAN);
2694 }
2695 }
2696 }
2697
2698 query.append(ORDER_BY_CLAUSE);
2699
2700 String[] orderByFields = orderByComparator.getOrderByFields();
2701
2702 for (int i = 0; i < orderByFields.length; i++) {
2703 if (getDB().isSupportsInlineDistinct()) {
2704 query.append(_ORDER_BY_ENTITY_ALIAS);
2705 }
2706 else {
2707 query.append(_ORDER_BY_ENTITY_TABLE);
2708 }
2709
2710 query.append(orderByFields[i]);
2711
2712 if ((i + 1) < orderByFields.length) {
2713 if (orderByComparator.isAscending() ^ previous) {
2714 query.append(ORDER_BY_ASC_HAS_NEXT);
2715 }
2716 else {
2717 query.append(ORDER_BY_DESC_HAS_NEXT);
2718 }
2719 }
2720 else {
2721 if (orderByComparator.isAscending() ^ previous) {
2722 query.append(ORDER_BY_ASC);
2723 }
2724 else {
2725 query.append(ORDER_BY_DESC);
2726 }
2727 }
2728 }
2729 }
2730
2731 else {
2732 if (getDB().isSupportsInlineDistinct()) {
2733 query.append(OrganizationModelImpl.ORDER_BY_JPQL);
2734 }
2735 else {
2736 query.append(OrganizationModelImpl.ORDER_BY_SQL);
2737 }
2738 }
2739
2740 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2741 Organization.class.getName(),
2742 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
2743
2744 SQLQuery q = session.createSQLQuery(sql);
2745
2746 q.setFirstResult(0);
2747 q.setMaxResults(2);
2748
2749 if (getDB().isSupportsInlineDistinct()) {
2750 q.addEntity(_FILTER_ENTITY_ALIAS, OrganizationImpl.class);
2751 }
2752 else {
2753 q.addEntity(_FILTER_ENTITY_TABLE, OrganizationImpl.class);
2754 }
2755
2756 QueryPos qPos = QueryPos.getInstance(q);
2757
2758 qPos.add(companyId);
2759
2760 qPos.add(parentOrganizationId);
2761
2762 if (orderByComparator != null) {
2763 Object[] values = orderByComparator.getOrderByConditionValues(organization);
2764
2765 for (Object value : values) {
2766 qPos.add(value);
2767 }
2768 }
2769
2770 List<Organization> list = q.list();
2771
2772 if (list.size() == 2) {
2773 return list.get(1);
2774 }
2775 else {
2776 return null;
2777 }
2778 }
2779
2780
2789 public Organization findByC_N(long companyId, String name)
2790 throws NoSuchOrganizationException, SystemException {
2791 Organization organization = fetchByC_N(companyId, name);
2792
2793 if (organization == null) {
2794 StringBundler msg = new StringBundler(6);
2795
2796 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2797
2798 msg.append("companyId=");
2799 msg.append(companyId);
2800
2801 msg.append(", name=");
2802 msg.append(name);
2803
2804 msg.append(StringPool.CLOSE_CURLY_BRACE);
2805
2806 if (_log.isWarnEnabled()) {
2807 _log.warn(msg.toString());
2808 }
2809
2810 throw new NoSuchOrganizationException(msg.toString());
2811 }
2812
2813 return organization;
2814 }
2815
2816
2824 public Organization fetchByC_N(long companyId, String name)
2825 throws SystemException {
2826 return fetchByC_N(companyId, name, true);
2827 }
2828
2829
2838 public Organization fetchByC_N(long companyId, String name,
2839 boolean retrieveFromCache) throws SystemException {
2840 Object[] finderArgs = new Object[] { companyId, name };
2841
2842 Object result = null;
2843
2844 if (retrieveFromCache) {
2845 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_N,
2846 finderArgs, this);
2847 }
2848
2849 if (result instanceof Organization) {
2850 Organization organization = (Organization)result;
2851
2852 if ((companyId != organization.getCompanyId()) ||
2853 !Validator.equals(name, organization.getName())) {
2854 result = null;
2855 }
2856 }
2857
2858 if (result == null) {
2859 StringBundler query = new StringBundler(4);
2860
2861 query.append(_SQL_SELECT_ORGANIZATION_WHERE);
2862
2863 query.append(_FINDER_COLUMN_C_N_COMPANYID_2);
2864
2865 if (name == null) {
2866 query.append(_FINDER_COLUMN_C_N_NAME_1);
2867 }
2868 else {
2869 if (name.equals(StringPool.BLANK)) {
2870 query.append(_FINDER_COLUMN_C_N_NAME_3);
2871 }
2872 else {
2873 query.append(_FINDER_COLUMN_C_N_NAME_2);
2874 }
2875 }
2876
2877 query.append(OrganizationModelImpl.ORDER_BY_JPQL);
2878
2879 String sql = query.toString();
2880
2881 Session session = null;
2882
2883 try {
2884 session = openSession();
2885
2886 Query q = session.createQuery(sql);
2887
2888 QueryPos qPos = QueryPos.getInstance(q);
2889
2890 qPos.add(companyId);
2891
2892 if (name != null) {
2893 qPos.add(name);
2894 }
2895
2896 List<Organization> list = q.list();
2897
2898 result = list;
2899
2900 Organization organization = null;
2901
2902 if (list.isEmpty()) {
2903 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N,
2904 finderArgs, list);
2905 }
2906 else {
2907 organization = list.get(0);
2908
2909 cacheResult(organization);
2910
2911 if ((organization.getCompanyId() != companyId) ||
2912 (organization.getName() == null) ||
2913 !organization.getName().equals(name)) {
2914 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N,
2915 finderArgs, organization);
2916 }
2917 }
2918
2919 return organization;
2920 }
2921 catch (Exception e) {
2922 throw processException(e);
2923 }
2924 finally {
2925 if (result == null) {
2926 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_N,
2927 finderArgs);
2928 }
2929
2930 closeSession(session);
2931 }
2932 }
2933 else {
2934 if (result instanceof List<?>) {
2935 return null;
2936 }
2937 else {
2938 return (Organization)result;
2939 }
2940 }
2941 }
2942
2943
2949 public List<Organization> findAll() throws SystemException {
2950 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2951 }
2952
2953
2965 public List<Organization> findAll(int start, int end)
2966 throws SystemException {
2967 return findAll(start, end, null);
2968 }
2969
2970
2983 public List<Organization> findAll(int start, int end,
2984 OrderByComparator orderByComparator) throws SystemException {
2985 FinderPath finderPath = null;
2986 Object[] finderArgs = new Object[] { start, end, orderByComparator };
2987
2988 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2989 (orderByComparator == null)) {
2990 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
2991 finderArgs = FINDER_ARGS_EMPTY;
2992 }
2993 else {
2994 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
2995 finderArgs = new Object[] { start, end, orderByComparator };
2996 }
2997
2998 List<Organization> list = (List<Organization>)FinderCacheUtil.getResult(finderPath,
2999 finderArgs, this);
3000
3001 if (list == null) {
3002 StringBundler query = null;
3003 String sql = null;
3004
3005 if (orderByComparator != null) {
3006 query = new StringBundler(2 +
3007 (orderByComparator.getOrderByFields().length * 3));
3008
3009 query.append(_SQL_SELECT_ORGANIZATION);
3010
3011 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3012 orderByComparator);
3013
3014 sql = query.toString();
3015 }
3016 else {
3017 sql = _SQL_SELECT_ORGANIZATION.concat(OrganizationModelImpl.ORDER_BY_JPQL);
3018 }
3019
3020 Session session = null;
3021
3022 try {
3023 session = openSession();
3024
3025 Query q = session.createQuery(sql);
3026
3027 if (orderByComparator == null) {
3028 list = (List<Organization>)QueryUtil.list(q, getDialect(),
3029 start, end, false);
3030
3031 Collections.sort(list);
3032 }
3033 else {
3034 list = (List<Organization>)QueryUtil.list(q, getDialect(),
3035 start, end);
3036 }
3037 }
3038 catch (Exception e) {
3039 throw processException(e);
3040 }
3041 finally {
3042 if (list == null) {
3043 FinderCacheUtil.removeResult(finderPath, finderArgs);
3044 }
3045 else {
3046 cacheResult(list);
3047
3048 FinderCacheUtil.putResult(finderPath, finderArgs, list);
3049 }
3050
3051 closeSession(session);
3052 }
3053 }
3054
3055 return list;
3056 }
3057
3058
3064 public void removeByCompanyId(long companyId) throws SystemException {
3065 for (Organization organization : findByCompanyId(companyId)) {
3066 remove(organization);
3067 }
3068 }
3069
3070
3076 public void removeByLocations(long companyId) throws SystemException {
3077 for (Organization organization : findByLocations(companyId)) {
3078 remove(organization);
3079 }
3080 }
3081
3082
3089 public void removeByC_P(long companyId, long parentOrganizationId)
3090 throws SystemException {
3091 for (Organization organization : findByC_P(companyId,
3092 parentOrganizationId)) {
3093 remove(organization);
3094 }
3095 }
3096
3097
3105 public Organization removeByC_N(long companyId, String name)
3106 throws NoSuchOrganizationException, SystemException {
3107 Organization organization = findByC_N(companyId, name);
3108
3109 return remove(organization);
3110 }
3111
3112
3117 public void removeAll() throws SystemException {
3118 for (Organization organization : findAll()) {
3119 remove(organization);
3120 }
3121 }
3122
3123
3130 public int countByCompanyId(long companyId) throws SystemException {
3131 Object[] finderArgs = new Object[] { companyId };
3132
3133 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
3134 finderArgs, this);
3135
3136 if (count == null) {
3137 StringBundler query = new StringBundler(2);
3138
3139 query.append(_SQL_COUNT_ORGANIZATION_WHERE);
3140
3141 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
3142
3143 String sql = query.toString();
3144
3145 Session session = null;
3146
3147 try {
3148 session = openSession();
3149
3150 Query q = session.createQuery(sql);
3151
3152 QueryPos qPos = QueryPos.getInstance(q);
3153
3154 qPos.add(companyId);
3155
3156 count = (Long)q.uniqueResult();
3157 }
3158 catch (Exception e) {
3159 throw processException(e);
3160 }
3161 finally {
3162 if (count == null) {
3163 count = Long.valueOf(0);
3164 }
3165
3166 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
3167 finderArgs, count);
3168
3169 closeSession(session);
3170 }
3171 }
3172
3173 return count.intValue();
3174 }
3175
3176
3183 public int filterCountByCompanyId(long companyId) throws SystemException {
3184 if (!InlineSQLHelperUtil.isEnabled()) {
3185 return countByCompanyId(companyId);
3186 }
3187
3188 StringBundler query = new StringBundler(2);
3189
3190 query.append(_FILTER_SQL_COUNT_ORGANIZATION_WHERE);
3191
3192 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
3193
3194 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3195 Organization.class.getName(),
3196 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
3197
3198 Session session = null;
3199
3200 try {
3201 session = openSession();
3202
3203 SQLQuery q = session.createSQLQuery(sql);
3204
3205 q.addScalar(COUNT_COLUMN_NAME,
3206 com.liferay.portal.kernel.dao.orm.Type.LONG);
3207
3208 QueryPos qPos = QueryPos.getInstance(q);
3209
3210 qPos.add(companyId);
3211
3212 Long count = (Long)q.uniqueResult();
3213
3214 return count.intValue();
3215 }
3216 catch (Exception e) {
3217 throw processException(e);
3218 }
3219 finally {
3220 closeSession(session);
3221 }
3222 }
3223
3224
3231 public int countByLocations(long companyId) throws SystemException {
3232 Object[] finderArgs = new Object[] { companyId };
3233
3234 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_LOCATIONS,
3235 finderArgs, this);
3236
3237 if (count == null) {
3238 StringBundler query = new StringBundler(2);
3239
3240 query.append(_SQL_COUNT_ORGANIZATION_WHERE);
3241
3242 query.append(_FINDER_COLUMN_LOCATIONS_COMPANYID_2);
3243
3244 String sql = query.toString();
3245
3246 Session session = null;
3247
3248 try {
3249 session = openSession();
3250
3251 Query q = session.createQuery(sql);
3252
3253 QueryPos qPos = QueryPos.getInstance(q);
3254
3255 qPos.add(companyId);
3256
3257 count = (Long)q.uniqueResult();
3258 }
3259 catch (Exception e) {
3260 throw processException(e);
3261 }
3262 finally {
3263 if (count == null) {
3264 count = Long.valueOf(0);
3265 }
3266
3267 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_LOCATIONS,
3268 finderArgs, count);
3269
3270 closeSession(session);
3271 }
3272 }
3273
3274 return count.intValue();
3275 }
3276
3277
3284 public int filterCountByLocations(long companyId) throws SystemException {
3285 if (!InlineSQLHelperUtil.isEnabled()) {
3286 return countByLocations(companyId);
3287 }
3288
3289 StringBundler query = new StringBundler(2);
3290
3291 query.append(_FILTER_SQL_COUNT_ORGANIZATION_WHERE);
3292
3293 query.append(_FINDER_COLUMN_LOCATIONS_COMPANYID_2);
3294
3295 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3296 Organization.class.getName(),
3297 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
3298
3299 Session session = null;
3300
3301 try {
3302 session = openSession();
3303
3304 SQLQuery q = session.createSQLQuery(sql);
3305
3306 q.addScalar(COUNT_COLUMN_NAME,
3307 com.liferay.portal.kernel.dao.orm.Type.LONG);
3308
3309 QueryPos qPos = QueryPos.getInstance(q);
3310
3311 qPos.add(companyId);
3312
3313 Long count = (Long)q.uniqueResult();
3314
3315 return count.intValue();
3316 }
3317 catch (Exception e) {
3318 throw processException(e);
3319 }
3320 finally {
3321 closeSession(session);
3322 }
3323 }
3324
3325
3333 public int countByC_P(long companyId, long parentOrganizationId)
3334 throws SystemException {
3335 Object[] finderArgs = new Object[] { companyId, parentOrganizationId };
3336
3337 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_P,
3338 finderArgs, this);
3339
3340 if (count == null) {
3341 StringBundler query = new StringBundler(3);
3342
3343 query.append(_SQL_COUNT_ORGANIZATION_WHERE);
3344
3345 query.append(_FINDER_COLUMN_C_P_COMPANYID_2);
3346
3347 query.append(_FINDER_COLUMN_C_P_PARENTORGANIZATIONID_2);
3348
3349 String sql = query.toString();
3350
3351 Session session = null;
3352
3353 try {
3354 session = openSession();
3355
3356 Query q = session.createQuery(sql);
3357
3358 QueryPos qPos = QueryPos.getInstance(q);
3359
3360 qPos.add(companyId);
3361
3362 qPos.add(parentOrganizationId);
3363
3364 count = (Long)q.uniqueResult();
3365 }
3366 catch (Exception e) {
3367 throw processException(e);
3368 }
3369 finally {
3370 if (count == null) {
3371 count = Long.valueOf(0);
3372 }
3373
3374 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_P, finderArgs,
3375 count);
3376
3377 closeSession(session);
3378 }
3379 }
3380
3381 return count.intValue();
3382 }
3383
3384
3392 public int filterCountByC_P(long companyId, long parentOrganizationId)
3393 throws SystemException {
3394 if (!InlineSQLHelperUtil.isEnabled()) {
3395 return countByC_P(companyId, parentOrganizationId);
3396 }
3397
3398 StringBundler query = new StringBundler(3);
3399
3400 query.append(_FILTER_SQL_COUNT_ORGANIZATION_WHERE);
3401
3402 query.append(_FINDER_COLUMN_C_P_COMPANYID_2);
3403
3404 query.append(_FINDER_COLUMN_C_P_PARENTORGANIZATIONID_2);
3405
3406 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3407 Organization.class.getName(),
3408 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
3409
3410 Session session = null;
3411
3412 try {
3413 session = openSession();
3414
3415 SQLQuery q = session.createSQLQuery(sql);
3416
3417 q.addScalar(COUNT_COLUMN_NAME,
3418 com.liferay.portal.kernel.dao.orm.Type.LONG);
3419
3420 QueryPos qPos = QueryPos.getInstance(q);
3421
3422 qPos.add(companyId);
3423
3424 qPos.add(parentOrganizationId);
3425
3426 Long count = (Long)q.uniqueResult();
3427
3428 return count.intValue();
3429 }
3430 catch (Exception e) {
3431 throw processException(e);
3432 }
3433 finally {
3434 closeSession(session);
3435 }
3436 }
3437
3438
3446 public int countByC_N(long companyId, String name)
3447 throws SystemException {
3448 Object[] finderArgs = new Object[] { companyId, name };
3449
3450 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_N,
3451 finderArgs, this);
3452
3453 if (count == null) {
3454 StringBundler query = new StringBundler(3);
3455
3456 query.append(_SQL_COUNT_ORGANIZATION_WHERE);
3457
3458 query.append(_FINDER_COLUMN_C_N_COMPANYID_2);
3459
3460 if (name == null) {
3461 query.append(_FINDER_COLUMN_C_N_NAME_1);
3462 }
3463 else {
3464 if (name.equals(StringPool.BLANK)) {
3465 query.append(_FINDER_COLUMN_C_N_NAME_3);
3466 }
3467 else {
3468 query.append(_FINDER_COLUMN_C_N_NAME_2);
3469 }
3470 }
3471
3472 String sql = query.toString();
3473
3474 Session session = null;
3475
3476 try {
3477 session = openSession();
3478
3479 Query q = session.createQuery(sql);
3480
3481 QueryPos qPos = QueryPos.getInstance(q);
3482
3483 qPos.add(companyId);
3484
3485 if (name != null) {
3486 qPos.add(name);
3487 }
3488
3489 count = (Long)q.uniqueResult();
3490 }
3491 catch (Exception e) {
3492 throw processException(e);
3493 }
3494 finally {
3495 if (count == null) {
3496 count = Long.valueOf(0);
3497 }
3498
3499 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_N, finderArgs,
3500 count);
3501
3502 closeSession(session);
3503 }
3504 }
3505
3506 return count.intValue();
3507 }
3508
3509
3515 public int countAll() throws SystemException {
3516 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
3517 FINDER_ARGS_EMPTY, this);
3518
3519 if (count == null) {
3520 Session session = null;
3521
3522 try {
3523 session = openSession();
3524
3525 Query q = session.createQuery(_SQL_COUNT_ORGANIZATION);
3526
3527 count = (Long)q.uniqueResult();
3528 }
3529 catch (Exception e) {
3530 throw processException(e);
3531 }
3532 finally {
3533 if (count == null) {
3534 count = Long.valueOf(0);
3535 }
3536
3537 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
3538 FINDER_ARGS_EMPTY, count);
3539
3540 closeSession(session);
3541 }
3542 }
3543
3544 return count.intValue();
3545 }
3546
3547
3554 public List<com.liferay.portal.model.Group> getGroups(long pk)
3555 throws SystemException {
3556 return getGroups(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
3557 }
3558
3559
3572 public List<com.liferay.portal.model.Group> getGroups(long pk, int start,
3573 int end) throws SystemException {
3574 return getGroups(pk, start, end, null);
3575 }
3576
3577 public static final FinderPath FINDER_PATH_GET_GROUPS = new FinderPath(com.liferay.portal.model.impl.GroupModelImpl.ENTITY_CACHE_ENABLED,
3578 OrganizationModelImpl.FINDER_CACHE_ENABLED_GROUPS_ORGS,
3579 com.liferay.portal.model.impl.GroupImpl.class,
3580 OrganizationModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME, "getGroups",
3581 new String[] {
3582 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
3583 "com.liferay.portal.kernel.util.OrderByComparator"
3584 });
3585
3586 static {
3587 FINDER_PATH_GET_GROUPS.setCacheKeyGeneratorCacheName(null);
3588 }
3589
3590
3604 public List<com.liferay.portal.model.Group> getGroups(long pk, int start,
3605 int end, OrderByComparator orderByComparator) throws SystemException {
3606 Object[] finderArgs = new Object[] { pk, start, end, orderByComparator };
3607
3608 List<com.liferay.portal.model.Group> list = (List<com.liferay.portal.model.Group>)FinderCacheUtil.getResult(FINDER_PATH_GET_GROUPS,
3609 finderArgs, this);
3610
3611 if (list == null) {
3612 Session session = null;
3613
3614 try {
3615 session = openSession();
3616
3617 String sql = null;
3618
3619 if (orderByComparator != null) {
3620 sql = _SQL_GETGROUPS.concat(ORDER_BY_CLAUSE)
3621 .concat(orderByComparator.getOrderBy());
3622 }
3623 else {
3624 sql = _SQL_GETGROUPS.concat(com.liferay.portal.model.impl.GroupModelImpl.ORDER_BY_SQL);
3625 }
3626
3627 SQLQuery q = session.createSQLQuery(sql);
3628
3629 q.addEntity("Group_",
3630 com.liferay.portal.model.impl.GroupImpl.class);
3631
3632 QueryPos qPos = QueryPos.getInstance(q);
3633
3634 qPos.add(pk);
3635
3636 list = (List<com.liferay.portal.model.Group>)QueryUtil.list(q,
3637 getDialect(), start, end);
3638 }
3639 catch (Exception e) {
3640 throw processException(e);
3641 }
3642 finally {
3643 if (list == null) {
3644 FinderCacheUtil.removeResult(FINDER_PATH_GET_GROUPS,
3645 finderArgs);
3646 }
3647 else {
3648 groupPersistence.cacheResult(list);
3649
3650 FinderCacheUtil.putResult(FINDER_PATH_GET_GROUPS,
3651 finderArgs, list);
3652 }
3653
3654 closeSession(session);
3655 }
3656 }
3657
3658 return list;
3659 }
3660
3661 public static final FinderPath FINDER_PATH_GET_GROUPS_SIZE = new FinderPath(com.liferay.portal.model.impl.GroupModelImpl.ENTITY_CACHE_ENABLED,
3662 OrganizationModelImpl.FINDER_CACHE_ENABLED_GROUPS_ORGS, Long.class,
3663 OrganizationModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME,
3664 "getGroupsSize", new String[] { Long.class.getName() });
3665
3666 static {
3667 FINDER_PATH_GET_GROUPS_SIZE.setCacheKeyGeneratorCacheName(null);
3668 }
3669
3670
3677 public int getGroupsSize(long pk) throws SystemException {
3678 Object[] finderArgs = new Object[] { pk };
3679
3680 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_GROUPS_SIZE,
3681 finderArgs, this);
3682
3683 if (count == null) {
3684 Session session = null;
3685
3686 try {
3687 session = openSession();
3688
3689 SQLQuery q = session.createSQLQuery(_SQL_GETGROUPSSIZE);
3690
3691 q.addScalar(COUNT_COLUMN_NAME,
3692 com.liferay.portal.kernel.dao.orm.Type.LONG);
3693
3694 QueryPos qPos = QueryPos.getInstance(q);
3695
3696 qPos.add(pk);
3697
3698 count = (Long)q.uniqueResult();
3699 }
3700 catch (Exception e) {
3701 throw processException(e);
3702 }
3703 finally {
3704 if (count == null) {
3705 count = Long.valueOf(0);
3706 }
3707
3708 FinderCacheUtil.putResult(FINDER_PATH_GET_GROUPS_SIZE,
3709 finderArgs, count);
3710
3711 closeSession(session);
3712 }
3713 }
3714
3715 return count.intValue();
3716 }
3717
3718 public static final FinderPath FINDER_PATH_CONTAINS_GROUP = new FinderPath(com.liferay.portal.model.impl.GroupModelImpl.ENTITY_CACHE_ENABLED,
3719 OrganizationModelImpl.FINDER_CACHE_ENABLED_GROUPS_ORGS,
3720 Boolean.class,
3721 OrganizationModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME,
3722 "containsGroup",
3723 new String[] { Long.class.getName(), Long.class.getName() });
3724
3725
3733 public boolean containsGroup(long pk, long groupPK)
3734 throws SystemException {
3735 Object[] finderArgs = new Object[] { pk, groupPK };
3736
3737 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_GROUP,
3738 finderArgs, this);
3739
3740 if (value == null) {
3741 try {
3742 value = Boolean.valueOf(containsGroup.contains(pk, groupPK));
3743 }
3744 catch (Exception e) {
3745 throw processException(e);
3746 }
3747 finally {
3748 if (value == null) {
3749 value = Boolean.FALSE;
3750 }
3751
3752 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_GROUP,
3753 finderArgs, value);
3754 }
3755 }
3756
3757 return value.booleanValue();
3758 }
3759
3760
3767 public boolean containsGroups(long pk) throws SystemException {
3768 if (getGroupsSize(pk) > 0) {
3769 return true;
3770 }
3771 else {
3772 return false;
3773 }
3774 }
3775
3776
3783 public void addGroup(long pk, long groupPK) throws SystemException {
3784 try {
3785 addGroup.add(pk, groupPK);
3786 }
3787 catch (Exception e) {
3788 throw processException(e);
3789 }
3790 finally {
3791 FinderCacheUtil.clearCache(OrganizationModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME);
3792 }
3793 }
3794
3795
3802 public void addGroup(long pk, com.liferay.portal.model.Group group)
3803 throws SystemException {
3804 try {
3805 addGroup.add(pk, group.getPrimaryKey());
3806 }
3807 catch (Exception e) {
3808 throw processException(e);
3809 }
3810 finally {
3811 FinderCacheUtil.clearCache(OrganizationModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME);
3812 }
3813 }
3814
3815
3822 public void addGroups(long pk, long[] groupPKs) throws SystemException {
3823 try {
3824 for (long groupPK : groupPKs) {
3825 addGroup.add(pk, groupPK);
3826 }
3827 }
3828 catch (Exception e) {
3829 throw processException(e);
3830 }
3831 finally {
3832 FinderCacheUtil.clearCache(OrganizationModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME);
3833 }
3834 }
3835
3836
3843 public void addGroups(long pk, List<com.liferay.portal.model.Group> groups)
3844 throws SystemException {
3845 try {
3846 for (com.liferay.portal.model.Group group : groups) {
3847 addGroup.add(pk, group.getPrimaryKey());
3848 }
3849 }
3850 catch (Exception e) {
3851 throw processException(e);
3852 }
3853 finally {
3854 FinderCacheUtil.clearCache(OrganizationModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME);
3855 }
3856 }
3857
3858
3864 public void clearGroups(long pk) throws SystemException {
3865 try {
3866 clearGroups.clear(pk);
3867 }
3868 catch (Exception e) {
3869 throw processException(e);
3870 }
3871 finally {
3872 FinderCacheUtil.clearCache(OrganizationModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME);
3873 }
3874 }
3875
3876
3883 public void removeGroup(long pk, long groupPK) throws SystemException {
3884 try {
3885 removeGroup.remove(pk, groupPK);
3886 }
3887 catch (Exception e) {
3888 throw processException(e);
3889 }
3890 finally {
3891 FinderCacheUtil.clearCache(OrganizationModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME);
3892 }
3893 }
3894
3895
3902 public void removeGroup(long pk, com.liferay.portal.model.Group group)
3903 throws SystemException {
3904 try {
3905 removeGroup.remove(pk, group.getPrimaryKey());
3906 }
3907 catch (Exception e) {
3908 throw processException(e);
3909 }
3910 finally {
3911 FinderCacheUtil.clearCache(OrganizationModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME);
3912 }
3913 }
3914
3915
3922 public void removeGroups(long pk, long[] groupPKs)
3923 throws SystemException {
3924 try {
3925 for (long groupPK : groupPKs) {
3926 removeGroup.remove(pk, groupPK);
3927 }
3928 }
3929 catch (Exception e) {
3930 throw processException(e);
3931 }
3932 finally {
3933 FinderCacheUtil.clearCache(OrganizationModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME);
3934 }
3935 }
3936
3937
3944 public void removeGroups(long pk,
3945 List<com.liferay.portal.model.Group> groups) throws SystemException {
3946 try {
3947 for (com.liferay.portal.model.Group group : groups) {
3948 removeGroup.remove(pk, group.getPrimaryKey());
3949 }
3950 }
3951 catch (Exception e) {
3952 throw processException(e);
3953 }
3954 finally {
3955 FinderCacheUtil.clearCache(OrganizationModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME);
3956 }
3957 }
3958
3959
3966 public void setGroups(long pk, long[] groupPKs) throws SystemException {
3967 try {
3968 Set<Long> groupPKSet = SetUtil.fromArray(groupPKs);
3969
3970 List<com.liferay.portal.model.Group> groups = getGroups(pk);
3971
3972 for (com.liferay.portal.model.Group group : groups) {
3973 if (!groupPKSet.remove(group.getPrimaryKey())) {
3974 removeGroup.remove(pk, group.getPrimaryKey());
3975 }
3976 }
3977
3978 for (Long groupPK : groupPKSet) {
3979 addGroup.add(pk, groupPK);
3980 }
3981 }
3982 catch (Exception e) {
3983 throw processException(e);
3984 }
3985 finally {
3986 FinderCacheUtil.clearCache(OrganizationModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME);
3987 }
3988 }
3989
3990
3997 public void setGroups(long pk, List<com.liferay.portal.model.Group> groups)
3998 throws SystemException {
3999 try {
4000 long[] groupPKs = new long[groups.size()];
4001
4002 for (int i = 0; i < groups.size(); i++) {
4003 com.liferay.portal.model.Group group = groups.get(i);
4004
4005 groupPKs[i] = group.getPrimaryKey();
4006 }
4007
4008 setGroups(pk, groupPKs);
4009 }
4010 catch (Exception e) {
4011 throw processException(e);
4012 }
4013 finally {
4014 FinderCacheUtil.clearCache(OrganizationModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME);
4015 }
4016 }
4017
4018
4025 public List<com.liferay.portal.model.User> getUsers(long pk)
4026 throws SystemException {
4027 return getUsers(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
4028 }
4029
4030
4043 public List<com.liferay.portal.model.User> getUsers(long pk, int start,
4044 int end) throws SystemException {
4045 return getUsers(pk, start, end, null);
4046 }
4047
4048 public static final FinderPath FINDER_PATH_GET_USERS = new FinderPath(com.liferay.portal.model.impl.UserModelImpl.ENTITY_CACHE_ENABLED,
4049 OrganizationModelImpl.FINDER_CACHE_ENABLED_USERS_ORGS,
4050 com.liferay.portal.model.impl.UserImpl.class,
4051 OrganizationModelImpl.MAPPING_TABLE_USERS_ORGS_NAME, "getUsers",
4052 new String[] {
4053 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
4054 "com.liferay.portal.kernel.util.OrderByComparator"
4055 });
4056
4057 static {
4058 FINDER_PATH_GET_USERS.setCacheKeyGeneratorCacheName(null);
4059 }
4060
4061
4075 public List<com.liferay.portal.model.User> getUsers(long pk, int start,
4076 int end, OrderByComparator orderByComparator) throws SystemException {
4077 Object[] finderArgs = new Object[] { pk, start, end, orderByComparator };
4078
4079 List<com.liferay.portal.model.User> list = (List<com.liferay.portal.model.User>)FinderCacheUtil.getResult(FINDER_PATH_GET_USERS,
4080 finderArgs, this);
4081
4082 if (list == null) {
4083 Session session = null;
4084
4085 try {
4086 session = openSession();
4087
4088 String sql = null;
4089
4090 if (orderByComparator != null) {
4091 sql = _SQL_GETUSERS.concat(ORDER_BY_CLAUSE)
4092 .concat(orderByComparator.getOrderBy());
4093 }
4094 else {
4095 sql = _SQL_GETUSERS;
4096 }
4097
4098 SQLQuery q = session.createSQLQuery(sql);
4099
4100 q.addEntity("User_",
4101 com.liferay.portal.model.impl.UserImpl.class);
4102
4103 QueryPos qPos = QueryPos.getInstance(q);
4104
4105 qPos.add(pk);
4106
4107 list = (List<com.liferay.portal.model.User>)QueryUtil.list(q,
4108 getDialect(), start, end);
4109 }
4110 catch (Exception e) {
4111 throw processException(e);
4112 }
4113 finally {
4114 if (list == null) {
4115 FinderCacheUtil.removeResult(FINDER_PATH_GET_USERS,
4116 finderArgs);
4117 }
4118 else {
4119 userPersistence.cacheResult(list);
4120
4121 FinderCacheUtil.putResult(FINDER_PATH_GET_USERS,
4122 finderArgs, list);
4123 }
4124
4125 closeSession(session);
4126 }
4127 }
4128
4129 return list;
4130 }
4131
4132 public static final FinderPath FINDER_PATH_GET_USERS_SIZE = new FinderPath(com.liferay.portal.model.impl.UserModelImpl.ENTITY_CACHE_ENABLED,
4133 OrganizationModelImpl.FINDER_CACHE_ENABLED_USERS_ORGS, Long.class,
4134 OrganizationModelImpl.MAPPING_TABLE_USERS_ORGS_NAME,
4135 "getUsersSize", new String[] { Long.class.getName() });
4136
4137 static {
4138 FINDER_PATH_GET_USERS_SIZE.setCacheKeyGeneratorCacheName(null);
4139 }
4140
4141
4148 public int getUsersSize(long pk) throws SystemException {
4149 Object[] finderArgs = new Object[] { pk };
4150
4151 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_USERS_SIZE,
4152 finderArgs, this);
4153
4154 if (count == null) {
4155 Session session = null;
4156
4157 try {
4158 session = openSession();
4159
4160 SQLQuery q = session.createSQLQuery(_SQL_GETUSERSSIZE);
4161
4162 q.addScalar(COUNT_COLUMN_NAME,
4163 com.liferay.portal.kernel.dao.orm.Type.LONG);
4164
4165 QueryPos qPos = QueryPos.getInstance(q);
4166
4167 qPos.add(pk);
4168
4169 count = (Long)q.uniqueResult();
4170 }
4171 catch (Exception e) {
4172 throw processException(e);
4173 }
4174 finally {
4175 if (count == null) {
4176 count = Long.valueOf(0);
4177 }
4178
4179 FinderCacheUtil.putResult(FINDER_PATH_GET_USERS_SIZE,
4180 finderArgs, count);
4181
4182 closeSession(session);
4183 }
4184 }
4185
4186 return count.intValue();
4187 }
4188
4189 public static final FinderPath FINDER_PATH_CONTAINS_USER = new FinderPath(com.liferay.portal.model.impl.UserModelImpl.ENTITY_CACHE_ENABLED,
4190 OrganizationModelImpl.FINDER_CACHE_ENABLED_USERS_ORGS,
4191 Boolean.class, OrganizationModelImpl.MAPPING_TABLE_USERS_ORGS_NAME,
4192 "containsUser",
4193 new String[] { Long.class.getName(), Long.class.getName() });
4194
4195
4203 public boolean containsUser(long pk, long userPK) throws SystemException {
4204 Object[] finderArgs = new Object[] { pk, userPK };
4205
4206 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_USER,
4207 finderArgs, this);
4208
4209 if (value == null) {
4210 try {
4211 value = Boolean.valueOf(containsUser.contains(pk, userPK));
4212 }
4213 catch (Exception e) {
4214 throw processException(e);
4215 }
4216 finally {
4217 if (value == null) {
4218 value = Boolean.FALSE;
4219 }
4220
4221 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_USER,
4222 finderArgs, value);
4223 }
4224 }
4225
4226 return value.booleanValue();
4227 }
4228
4229
4236 public boolean containsUsers(long pk) throws SystemException {
4237 if (getUsersSize(pk) > 0) {
4238 return true;
4239 }
4240 else {
4241 return false;
4242 }
4243 }
4244
4245
4252 public void addUser(long pk, long userPK) throws SystemException {
4253 try {
4254 addUser.add(pk, userPK);
4255 }
4256 catch (Exception e) {
4257 throw processException(e);
4258 }
4259 finally {
4260 FinderCacheUtil.clearCache(OrganizationModelImpl.MAPPING_TABLE_USERS_ORGS_NAME);
4261 }
4262 }
4263
4264
4271 public void addUser(long pk, com.liferay.portal.model.User user)
4272 throws SystemException {
4273 try {
4274 addUser.add(pk, user.getPrimaryKey());
4275 }
4276 catch (Exception e) {
4277 throw processException(e);
4278 }
4279 finally {
4280 FinderCacheUtil.clearCache(OrganizationModelImpl.MAPPING_TABLE_USERS_ORGS_NAME);
4281 }
4282 }
4283
4284
4291 public void addUsers(long pk, long[] userPKs) throws SystemException {
4292 try {
4293 for (long userPK : userPKs) {
4294 addUser.add(pk, userPK);
4295 }
4296 }
4297 catch (Exception e) {
4298 throw processException(e);
4299 }
4300 finally {
4301 FinderCacheUtil.clearCache(OrganizationModelImpl.MAPPING_TABLE_USERS_ORGS_NAME);
4302 }
4303 }
4304
4305
4312 public void addUsers(long pk, List<com.liferay.portal.model.User> users)
4313 throws SystemException {
4314 try {
4315 for (com.liferay.portal.model.User user : users) {
4316 addUser.add(pk, user.getPrimaryKey());
4317 }
4318 }
4319 catch (Exception e) {
4320 throw processException(e);
4321 }
4322 finally {
4323 FinderCacheUtil.clearCache(OrganizationModelImpl.MAPPING_TABLE_USERS_ORGS_NAME);
4324 }
4325 }
4326
4327
4333 public void clearUsers(long pk) throws SystemException {
4334 try {
4335 clearUsers.clear(pk);
4336 }
4337 catch (Exception e) {
4338 throw processException(e);
4339 }
4340 finally {
4341 FinderCacheUtil.clearCache(OrganizationModelImpl.MAPPING_TABLE_USERS_ORGS_NAME);
4342 }
4343 }
4344
4345
4352 public void removeUser(long pk, long userPK) throws SystemException {
4353 try {
4354 removeUser.remove(pk, userPK);
4355 }
4356 catch (Exception e) {
4357 throw processException(e);
4358 }
4359 finally {
4360 FinderCacheUtil.clearCache(OrganizationModelImpl.MAPPING_TABLE_USERS_ORGS_NAME);
4361 }
4362 }
4363
4364
4371 public void removeUser(long pk, com.liferay.portal.model.User user)
4372 throws SystemException {
4373 try {
4374 removeUser.remove(pk, user.getPrimaryKey());
4375 }
4376 catch (Exception e) {
4377 throw processException(e);
4378 }
4379 finally {
4380 FinderCacheUtil.clearCache(OrganizationModelImpl.MAPPING_TABLE_USERS_ORGS_NAME);
4381 }
4382 }
4383
4384
4391 public void removeUsers(long pk, long[] userPKs) throws SystemException {
4392 try {
4393 for (long userPK : userPKs) {
4394 removeUser.remove(pk, userPK);
4395 }
4396 }
4397 catch (Exception e) {
4398 throw processException(e);
4399 }
4400 finally {
4401 FinderCacheUtil.clearCache(OrganizationModelImpl.MAPPING_TABLE_USERS_ORGS_NAME);
4402 }
4403 }
4404
4405
4412 public void removeUsers(long pk, List<com.liferay.portal.model.User> users)
4413 throws SystemException {
4414 try {
4415 for (com.liferay.portal.model.User user : users) {
4416 removeUser.remove(pk, user.getPrimaryKey());
4417 }
4418 }
4419 catch (Exception e) {
4420 throw processException(e);
4421 }
4422 finally {
4423 FinderCacheUtil.clearCache(OrganizationModelImpl.MAPPING_TABLE_USERS_ORGS_NAME);
4424 }
4425 }
4426
4427
4434 public void setUsers(long pk, long[] userPKs) throws SystemException {
4435 try {
4436 Set<Long> userPKSet = SetUtil.fromArray(userPKs);
4437
4438 List<com.liferay.portal.model.User> users = getUsers(pk);
4439
4440 for (com.liferay.portal.model.User user : users) {
4441 if (!userPKSet.remove(user.getPrimaryKey())) {
4442 removeUser.remove(pk, user.getPrimaryKey());
4443 }
4444 }
4445
4446 for (Long userPK : userPKSet) {
4447 addUser.add(pk, userPK);
4448 }
4449 }
4450 catch (Exception e) {
4451 throw processException(e);
4452 }
4453 finally {
4454 FinderCacheUtil.clearCache(OrganizationModelImpl.MAPPING_TABLE_USERS_ORGS_NAME);
4455 }
4456 }
4457
4458
4465 public void setUsers(long pk, List<com.liferay.portal.model.User> users)
4466 throws SystemException {
4467 try {
4468 long[] userPKs = new long[users.size()];
4469
4470 for (int i = 0; i < users.size(); i++) {
4471 com.liferay.portal.model.User user = users.get(i);
4472
4473 userPKs[i] = user.getPrimaryKey();
4474 }
4475
4476 setUsers(pk, userPKs);
4477 }
4478 catch (Exception e) {
4479 throw processException(e);
4480 }
4481 finally {
4482 FinderCacheUtil.clearCache(OrganizationModelImpl.MAPPING_TABLE_USERS_ORGS_NAME);
4483 }
4484 }
4485
4486
4489 public void afterPropertiesSet() {
4490 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
4491 com.liferay.portal.util.PropsUtil.get(
4492 "value.object.listener.com.liferay.portal.model.Organization")));
4493
4494 if (listenerClassNames.length > 0) {
4495 try {
4496 List<ModelListener<Organization>> listenersList = new ArrayList<ModelListener<Organization>>();
4497
4498 for (String listenerClassName : listenerClassNames) {
4499 listenersList.add((ModelListener<Organization>)InstanceFactory.newInstance(
4500 listenerClassName));
4501 }
4502
4503 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
4504 }
4505 catch (Exception e) {
4506 _log.error(e);
4507 }
4508 }
4509
4510 containsGroup = new ContainsGroup();
4511
4512 addGroup = new AddGroup();
4513 clearGroups = new ClearGroups();
4514 removeGroup = new RemoveGroup();
4515
4516 containsUser = new ContainsUser();
4517
4518 addUser = new AddUser();
4519 clearUsers = new ClearUsers();
4520 removeUser = new RemoveUser();
4521 }
4522
4523 public void destroy() {
4524 EntityCacheUtil.removeCache(OrganizationImpl.class.getName());
4525 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
4526 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
4527 }
4528
4529 @BeanReference(type = AccountPersistence.class)
4530 protected AccountPersistence accountPersistence;
4531 @BeanReference(type = AddressPersistence.class)
4532 protected AddressPersistence addressPersistence;
4533 @BeanReference(type = BrowserTrackerPersistence.class)
4534 protected BrowserTrackerPersistence browserTrackerPersistence;
4535 @BeanReference(type = ClassNamePersistence.class)
4536 protected ClassNamePersistence classNamePersistence;
4537 @BeanReference(type = ClusterGroupPersistence.class)
4538 protected ClusterGroupPersistence clusterGroupPersistence;
4539 @BeanReference(type = CompanyPersistence.class)
4540 protected CompanyPersistence companyPersistence;
4541 @BeanReference(type = ContactPersistence.class)
4542 protected ContactPersistence contactPersistence;
4543 @BeanReference(type = CountryPersistence.class)
4544 protected CountryPersistence countryPersistence;
4545 @BeanReference(type = EmailAddressPersistence.class)
4546 protected EmailAddressPersistence emailAddressPersistence;
4547 @BeanReference(type = GroupPersistence.class)
4548 protected GroupPersistence groupPersistence;
4549 @BeanReference(type = ImagePersistence.class)
4550 protected ImagePersistence imagePersistence;
4551 @BeanReference(type = LayoutPersistence.class)
4552 protected LayoutPersistence layoutPersistence;
4553 @BeanReference(type = LayoutBranchPersistence.class)
4554 protected LayoutBranchPersistence layoutBranchPersistence;
4555 @BeanReference(type = LayoutPrototypePersistence.class)
4556 protected LayoutPrototypePersistence layoutPrototypePersistence;
4557 @BeanReference(type = LayoutRevisionPersistence.class)
4558 protected LayoutRevisionPersistence layoutRevisionPersistence;
4559 @BeanReference(type = LayoutSetPersistence.class)
4560 protected LayoutSetPersistence layoutSetPersistence;
4561 @BeanReference(type = LayoutSetBranchPersistence.class)
4562 protected LayoutSetBranchPersistence layoutSetBranchPersistence;
4563 @BeanReference(type = LayoutSetPrototypePersistence.class)
4564 protected LayoutSetPrototypePersistence layoutSetPrototypePersistence;
4565 @BeanReference(type = ListTypePersistence.class)
4566 protected ListTypePersistence listTypePersistence;
4567 @BeanReference(type = LockPersistence.class)
4568 protected LockPersistence lockPersistence;
4569 @BeanReference(type = MembershipRequestPersistence.class)
4570 protected MembershipRequestPersistence membershipRequestPersistence;
4571 @BeanReference(type = OrganizationPersistence.class)
4572 protected OrganizationPersistence organizationPersistence;
4573 @BeanReference(type = OrgGroupRolePersistence.class)
4574 protected OrgGroupRolePersistence orgGroupRolePersistence;
4575 @BeanReference(type = OrgLaborPersistence.class)
4576 protected OrgLaborPersistence orgLaborPersistence;
4577 @BeanReference(type = PasswordPolicyPersistence.class)
4578 protected PasswordPolicyPersistence passwordPolicyPersistence;
4579 @BeanReference(type = PasswordPolicyRelPersistence.class)
4580 protected PasswordPolicyRelPersistence passwordPolicyRelPersistence;
4581 @BeanReference(type = PasswordTrackerPersistence.class)
4582 protected PasswordTrackerPersistence passwordTrackerPersistence;
4583 @BeanReference(type = PhonePersistence.class)
4584 protected PhonePersistence phonePersistence;
4585 @BeanReference(type = PluginSettingPersistence.class)
4586 protected PluginSettingPersistence pluginSettingPersistence;
4587 @BeanReference(type = PortalPreferencesPersistence.class)
4588 protected PortalPreferencesPersistence portalPreferencesPersistence;
4589 @BeanReference(type = PortletPersistence.class)
4590 protected PortletPersistence portletPersistence;
4591 @BeanReference(type = PortletItemPersistence.class)
4592 protected PortletItemPersistence portletItemPersistence;
4593 @BeanReference(type = PortletPreferencesPersistence.class)
4594 protected PortletPreferencesPersistence portletPreferencesPersistence;
4595 @BeanReference(type = RegionPersistence.class)
4596 protected RegionPersistence regionPersistence;
4597 @BeanReference(type = ReleasePersistence.class)
4598 protected ReleasePersistence releasePersistence;
4599 @BeanReference(type = RepositoryPersistence.class)
4600 protected RepositoryPersistence repositoryPersistence;
4601 @BeanReference(type = RepositoryEntryPersistence.class)
4602 protected RepositoryEntryPersistence repositoryEntryPersistence;
4603 @BeanReference(type = ResourceActionPersistence.class)
4604 protected ResourceActionPersistence resourceActionPersistence;
4605 @BeanReference(type = ResourceBlockPersistence.class)
4606 protected ResourceBlockPersistence resourceBlockPersistence;
4607 @BeanReference(type = ResourceBlockPermissionPersistence.class)
4608 protected ResourceBlockPermissionPersistence resourceBlockPermissionPersistence;
4609 @BeanReference(type = ResourcePermissionPersistence.class)
4610 protected ResourcePermissionPersistence resourcePermissionPersistence;
4611 @BeanReference(type = ResourceTypePermissionPersistence.class)
4612 protected ResourceTypePermissionPersistence resourceTypePermissionPersistence;
4613 @BeanReference(type = RolePersistence.class)
4614 protected RolePersistence rolePersistence;
4615 @BeanReference(type = ServiceComponentPersistence.class)
4616 protected ServiceComponentPersistence serviceComponentPersistence;
4617 @BeanReference(type = ShardPersistence.class)
4618 protected ShardPersistence shardPersistence;
4619 @BeanReference(type = SubscriptionPersistence.class)
4620 protected SubscriptionPersistence subscriptionPersistence;
4621 @BeanReference(type = TeamPersistence.class)
4622 protected TeamPersistence teamPersistence;
4623 @BeanReference(type = TicketPersistence.class)
4624 protected TicketPersistence ticketPersistence;
4625 @BeanReference(type = UserPersistence.class)
4626 protected UserPersistence userPersistence;
4627 @BeanReference(type = UserGroupPersistence.class)
4628 protected UserGroupPersistence userGroupPersistence;
4629 @BeanReference(type = UserGroupGroupRolePersistence.class)
4630 protected UserGroupGroupRolePersistence userGroupGroupRolePersistence;
4631 @BeanReference(type = UserGroupRolePersistence.class)
4632 protected UserGroupRolePersistence userGroupRolePersistence;
4633 @BeanReference(type = UserIdMapperPersistence.class)
4634 protected UserIdMapperPersistence userIdMapperPersistence;
4635 @BeanReference(type = UserNotificationEventPersistence.class)
4636 protected UserNotificationEventPersistence userNotificationEventPersistence;
4637 @BeanReference(type = UserTrackerPersistence.class)
4638 protected UserTrackerPersistence userTrackerPersistence;
4639 @BeanReference(type = UserTrackerPathPersistence.class)
4640 protected UserTrackerPathPersistence userTrackerPathPersistence;
4641 @BeanReference(type = VirtualHostPersistence.class)
4642 protected VirtualHostPersistence virtualHostPersistence;
4643 @BeanReference(type = WebDAVPropsPersistence.class)
4644 protected WebDAVPropsPersistence webDAVPropsPersistence;
4645 @BeanReference(type = WebsitePersistence.class)
4646 protected WebsitePersistence websitePersistence;
4647 @BeanReference(type = WorkflowDefinitionLinkPersistence.class)
4648 protected WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
4649 @BeanReference(type = WorkflowInstanceLinkPersistence.class)
4650 protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
4651 @BeanReference(type = AssetEntryPersistence.class)
4652 protected AssetEntryPersistence assetEntryPersistence;
4653 @BeanReference(type = ExpandoValuePersistence.class)
4654 protected ExpandoValuePersistence expandoValuePersistence;
4655 protected ContainsGroup containsGroup;
4656 protected AddGroup addGroup;
4657 protected ClearGroups clearGroups;
4658 protected RemoveGroup removeGroup;
4659 protected ContainsUser containsUser;
4660 protected AddUser addUser;
4661 protected ClearUsers clearUsers;
4662 protected RemoveUser removeUser;
4663
4664 protected class ContainsGroup {
4665 protected ContainsGroup() {
4666 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
4667 _SQL_CONTAINSGROUP,
4668 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
4669 RowMapper.COUNT);
4670 }
4671
4672 protected boolean contains(long organizationId, long groupId) {
4673 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
4674 new Long(organizationId), new Long(groupId)
4675 });
4676
4677 if (results.size() > 0) {
4678 Integer count = results.get(0);
4679
4680 if (count.intValue() > 0) {
4681 return true;
4682 }
4683 }
4684
4685 return false;
4686 }
4687
4688 private MappingSqlQuery<Integer> _mappingSqlQuery;
4689 }
4690
4691 protected class AddGroup {
4692 protected AddGroup() {
4693 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4694 "INSERT INTO Groups_Orgs (organizationId, groupId) VALUES (?, ?)",
4695 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
4696 }
4697
4698 protected void add(long organizationId, long groupId)
4699 throws SystemException {
4700 if (!containsGroup.contains(organizationId, groupId)) {
4701 ModelListener<com.liferay.portal.model.Group>[] groupListeners = groupPersistence.getListeners();
4702
4703 for (ModelListener<Organization> listener : listeners) {
4704 listener.onBeforeAddAssociation(organizationId,
4705 com.liferay.portal.model.Group.class.getName(), groupId);
4706 }
4707
4708 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
4709 listener.onBeforeAddAssociation(groupId,
4710 Organization.class.getName(), organizationId);
4711 }
4712
4713 _sqlUpdate.update(new Object[] {
4714 new Long(organizationId), new Long(groupId)
4715 });
4716
4717 for (ModelListener<Organization> listener : listeners) {
4718 listener.onAfterAddAssociation(organizationId,
4719 com.liferay.portal.model.Group.class.getName(), groupId);
4720 }
4721
4722 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
4723 listener.onAfterAddAssociation(groupId,
4724 Organization.class.getName(), organizationId);
4725 }
4726 }
4727 }
4728
4729 private SqlUpdate _sqlUpdate;
4730 }
4731
4732 protected class ClearGroups {
4733 protected ClearGroups() {
4734 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4735 "DELETE FROM Groups_Orgs WHERE organizationId = ?",
4736 new int[] { java.sql.Types.BIGINT });
4737 }
4738
4739 protected void clear(long organizationId) throws SystemException {
4740 ModelListener<com.liferay.portal.model.Group>[] groupListeners = groupPersistence.getListeners();
4741
4742 List<com.liferay.portal.model.Group> groups = null;
4743
4744 if ((listeners.length > 0) || (groupListeners.length > 0)) {
4745 groups = getGroups(organizationId);
4746
4747 for (com.liferay.portal.model.Group group : groups) {
4748 for (ModelListener<Organization> listener : listeners) {
4749 listener.onBeforeRemoveAssociation(organizationId,
4750 com.liferay.portal.model.Group.class.getName(),
4751 group.getPrimaryKey());
4752 }
4753
4754 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
4755 listener.onBeforeRemoveAssociation(group.getPrimaryKey(),
4756 Organization.class.getName(), organizationId);
4757 }
4758 }
4759 }
4760
4761 _sqlUpdate.update(new Object[] { new Long(organizationId) });
4762
4763 if ((listeners.length > 0) || (groupListeners.length > 0)) {
4764 for (com.liferay.portal.model.Group group : groups) {
4765 for (ModelListener<Organization> listener : listeners) {
4766 listener.onAfterRemoveAssociation(organizationId,
4767 com.liferay.portal.model.Group.class.getName(),
4768 group.getPrimaryKey());
4769 }
4770
4771 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
4772 listener.onAfterRemoveAssociation(group.getPrimaryKey(),
4773 Organization.class.getName(), organizationId);
4774 }
4775 }
4776 }
4777 }
4778
4779 private SqlUpdate _sqlUpdate;
4780 }
4781
4782 protected class RemoveGroup {
4783 protected RemoveGroup() {
4784 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4785 "DELETE FROM Groups_Orgs WHERE organizationId = ? AND groupId = ?",
4786 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
4787 }
4788
4789 protected void remove(long organizationId, long groupId)
4790 throws SystemException {
4791 if (containsGroup.contains(organizationId, groupId)) {
4792 ModelListener<com.liferay.portal.model.Group>[] groupListeners = groupPersistence.getListeners();
4793
4794 for (ModelListener<Organization> listener : listeners) {
4795 listener.onBeforeRemoveAssociation(organizationId,
4796 com.liferay.portal.model.Group.class.getName(), groupId);
4797 }
4798
4799 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
4800 listener.onBeforeRemoveAssociation(groupId,
4801 Organization.class.getName(), organizationId);
4802 }
4803
4804 _sqlUpdate.update(new Object[] {
4805 new Long(organizationId), new Long(groupId)
4806 });
4807
4808 for (ModelListener<Organization> listener : listeners) {
4809 listener.onAfterRemoveAssociation(organizationId,
4810 com.liferay.portal.model.Group.class.getName(), groupId);
4811 }
4812
4813 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
4814 listener.onAfterRemoveAssociation(groupId,
4815 Organization.class.getName(), organizationId);
4816 }
4817 }
4818 }
4819
4820 private SqlUpdate _sqlUpdate;
4821 }
4822
4823 protected class ContainsUser {
4824 protected ContainsUser() {
4825 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
4826 _SQL_CONTAINSUSER,
4827 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
4828 RowMapper.COUNT);
4829 }
4830
4831 protected boolean contains(long organizationId, long userId) {
4832 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
4833 new Long(organizationId), new Long(userId)
4834 });
4835
4836 if (results.size() > 0) {
4837 Integer count = results.get(0);
4838
4839 if (count.intValue() > 0) {
4840 return true;
4841 }
4842 }
4843
4844 return false;
4845 }
4846
4847 private MappingSqlQuery<Integer> _mappingSqlQuery;
4848 }
4849
4850 protected class AddUser {
4851 protected AddUser() {
4852 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4853 "INSERT INTO Users_Orgs (organizationId, userId) VALUES (?, ?)",
4854 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
4855 }
4856
4857 protected void add(long organizationId, long userId)
4858 throws SystemException {
4859 if (!containsUser.contains(organizationId, userId)) {
4860 ModelListener<com.liferay.portal.model.User>[] userListeners = userPersistence.getListeners();
4861
4862 for (ModelListener<Organization> listener : listeners) {
4863 listener.onBeforeAddAssociation(organizationId,
4864 com.liferay.portal.model.User.class.getName(), userId);
4865 }
4866
4867 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
4868 listener.onBeforeAddAssociation(userId,
4869 Organization.class.getName(), organizationId);
4870 }
4871
4872 _sqlUpdate.update(new Object[] {
4873 new Long(organizationId), new Long(userId)
4874 });
4875
4876 for (ModelListener<Organization> listener : listeners) {
4877 listener.onAfterAddAssociation(organizationId,
4878 com.liferay.portal.model.User.class.getName(), userId);
4879 }
4880
4881 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
4882 listener.onAfterAddAssociation(userId,
4883 Organization.class.getName(), organizationId);
4884 }
4885 }
4886 }
4887
4888 private SqlUpdate _sqlUpdate;
4889 }
4890
4891 protected class ClearUsers {
4892 protected ClearUsers() {
4893 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4894 "DELETE FROM Users_Orgs WHERE organizationId = ?",
4895 new int[] { java.sql.Types.BIGINT });
4896 }
4897
4898 protected void clear(long organizationId) throws SystemException {
4899 ModelListener<com.liferay.portal.model.User>[] userListeners = userPersistence.getListeners();
4900
4901 List<com.liferay.portal.model.User> users = null;
4902
4903 if ((listeners.length > 0) || (userListeners.length > 0)) {
4904 users = getUsers(organizationId);
4905
4906 for (com.liferay.portal.model.User user : users) {
4907 for (ModelListener<Organization> listener : listeners) {
4908 listener.onBeforeRemoveAssociation(organizationId,
4909 com.liferay.portal.model.User.class.getName(),
4910 user.getPrimaryKey());
4911 }
4912
4913 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
4914 listener.onBeforeRemoveAssociation(user.getPrimaryKey(),
4915 Organization.class.getName(), organizationId);
4916 }
4917 }
4918 }
4919
4920 _sqlUpdate.update(new Object[] { new Long(organizationId) });
4921
4922 if ((listeners.length > 0) || (userListeners.length > 0)) {
4923 for (com.liferay.portal.model.User user : users) {
4924 for (ModelListener<Organization> listener : listeners) {
4925 listener.onAfterRemoveAssociation(organizationId,
4926 com.liferay.portal.model.User.class.getName(),
4927 user.getPrimaryKey());
4928 }
4929
4930 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
4931 listener.onAfterRemoveAssociation(user.getPrimaryKey(),
4932 Organization.class.getName(), organizationId);
4933 }
4934 }
4935 }
4936 }
4937
4938 private SqlUpdate _sqlUpdate;
4939 }
4940
4941 protected class RemoveUser {
4942 protected RemoveUser() {
4943 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4944 "DELETE FROM Users_Orgs WHERE organizationId = ? AND userId = ?",
4945 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
4946 }
4947
4948 protected void remove(long organizationId, long userId)
4949 throws SystemException {
4950 if (containsUser.contains(organizationId, userId)) {
4951 ModelListener<com.liferay.portal.model.User>[] userListeners = userPersistence.getListeners();
4952
4953 for (ModelListener<Organization> listener : listeners) {
4954 listener.onBeforeRemoveAssociation(organizationId,
4955 com.liferay.portal.model.User.class.getName(), userId);
4956 }
4957
4958 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
4959 listener.onBeforeRemoveAssociation(userId,
4960 Organization.class.getName(), organizationId);
4961 }
4962
4963 _sqlUpdate.update(new Object[] {
4964 new Long(organizationId), new Long(userId)
4965 });
4966
4967 for (ModelListener<Organization> listener : listeners) {
4968 listener.onAfterRemoveAssociation(organizationId,
4969 com.liferay.portal.model.User.class.getName(), userId);
4970 }
4971
4972 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
4973 listener.onAfterRemoveAssociation(userId,
4974 Organization.class.getName(), organizationId);
4975 }
4976 }
4977 }
4978
4979 private SqlUpdate _sqlUpdate;
4980 }
4981
4982 private static final String _SQL_SELECT_ORGANIZATION = "SELECT organization FROM Organization organization";
4983 private static final String _SQL_SELECT_ORGANIZATION_WHERE = "SELECT organization FROM Organization organization WHERE ";
4984 private static final String _SQL_COUNT_ORGANIZATION = "SELECT COUNT(organization) FROM Organization organization";
4985 private static final String _SQL_COUNT_ORGANIZATION_WHERE = "SELECT COUNT(organization) FROM Organization organization WHERE ";
4986 private static final String _SQL_GETGROUPS = "SELECT {Group_.*} FROM Group_ INNER JOIN Groups_Orgs ON (Groups_Orgs.groupId = Group_.groupId) WHERE (Groups_Orgs.organizationId = ?)";
4987 private static final String _SQL_GETGROUPSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Groups_Orgs WHERE organizationId = ?";
4988 private static final String _SQL_CONTAINSGROUP = "SELECT COUNT(*) AS COUNT_VALUE FROM Groups_Orgs WHERE organizationId = ? AND groupId = ?";
4989 private static final String _SQL_GETUSERS = "SELECT {User_.*} FROM User_ INNER JOIN Users_Orgs ON (Users_Orgs.userId = User_.userId) WHERE (Users_Orgs.organizationId = ?)";
4990 private static final String _SQL_GETUSERSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_Orgs WHERE organizationId = ?";
4991 private static final String _SQL_CONTAINSUSER = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_Orgs WHERE organizationId = ? AND userId = ?";
4992 private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "organization.companyId = ?";
4993 private static final String _FINDER_COLUMN_LOCATIONS_COMPANYID_2 = "organization.companyId = ? AND organization.parentOrganizationId != 0";
4994 private static final String _FINDER_COLUMN_C_P_COMPANYID_2 = "organization.companyId = ? AND ";
4995 private static final String _FINDER_COLUMN_C_P_PARENTORGANIZATIONID_2 = "organization.parentOrganizationId = ?";
4996 private static final String _FINDER_COLUMN_C_N_COMPANYID_2 = "organization.companyId = ? AND ";
4997 private static final String _FINDER_COLUMN_C_N_NAME_1 = "organization.name IS NULL";
4998 private static final String _FINDER_COLUMN_C_N_NAME_2 = "organization.name = ?";
4999 private static final String _FINDER_COLUMN_C_N_NAME_3 = "(organization.name IS NULL OR organization.name = ?)";
5000 private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "organization.organizationId";
5001 private static final String _FILTER_SQL_SELECT_ORGANIZATION_WHERE = "SELECT DISTINCT {organization.*} FROM Organization_ organization WHERE ";
5002 private static final String _FILTER_SQL_SELECT_ORGANIZATION_NO_INLINE_DISTINCT_WHERE_1 =
5003 "SELECT {Organization_.*} FROM (SELECT DISTINCT organization.organizationId FROM Organization_ organization WHERE ";
5004 private static final String _FILTER_SQL_SELECT_ORGANIZATION_NO_INLINE_DISTINCT_WHERE_2 =
5005 ") TEMP_TABLE INNER JOIN Organization_ ON TEMP_TABLE.organizationId = Organization_.organizationId";
5006 private static final String _FILTER_SQL_COUNT_ORGANIZATION_WHERE = "SELECT COUNT(DISTINCT organization.organizationId) AS COUNT_VALUE FROM Organization_ organization WHERE ";
5007 private static final String _FILTER_ENTITY_ALIAS = "organization";
5008 private static final String _FILTER_ENTITY_TABLE = "Organization_";
5009 private static final String _ORDER_BY_ENTITY_ALIAS = "organization.";
5010 private static final String _ORDER_BY_ENTITY_TABLE = "Organization_.";
5011 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No Organization exists with the primary key ";
5012 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No Organization exists with the key {";
5013 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
5014 private static Log _log = LogFactoryUtil.getLog(OrganizationPersistenceImpl.class);
5015 private static Organization _nullOrganization = new OrganizationImpl() {
5016 @Override
5017 public Object clone() {
5018 return this;
5019 }
5020
5021 @Override
5022 public CacheModel<Organization> toCacheModel() {
5023 return _nullOrganizationCacheModel;
5024 }
5025 };
5026
5027 private static CacheModel<Organization> _nullOrganizationCacheModel = new CacheModel<Organization>() {
5028 public Organization toEntityModel() {
5029 return _nullOrganization;
5030 }
5031 };
5032 }