001
014
015 package com.liferay.portal.service.persistence;
016
017 import com.liferay.portal.NoSuchOrganizationException;
018 import com.liferay.portal.kernel.bean.BeanReference;
019 import com.liferay.portal.kernel.cache.CacheRegistryUtil;
020 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
021 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
022 import com.liferay.portal.kernel.dao.orm.FinderPath;
023 import com.liferay.portal.kernel.dao.orm.Query;
024 import com.liferay.portal.kernel.dao.orm.QueryPos;
025 import com.liferay.portal.kernel.dao.orm.QueryUtil;
026 import com.liferay.portal.kernel.dao.orm.SQLQuery;
027 import com.liferay.portal.kernel.dao.orm.Session;
028 import com.liferay.portal.kernel.exception.SystemException;
029 import com.liferay.portal.kernel.log.Log;
030 import com.liferay.portal.kernel.log.LogFactoryUtil;
031 import com.liferay.portal.kernel.util.GetterUtil;
032 import com.liferay.portal.kernel.util.InstanceFactory;
033 import com.liferay.portal.kernel.util.OrderByComparator;
034 import com.liferay.portal.kernel.util.SetUtil;
035 import com.liferay.portal.kernel.util.StringBundler;
036 import com.liferay.portal.kernel.util.StringPool;
037 import com.liferay.portal.kernel.util.StringUtil;
038 import com.liferay.portal.kernel.util.UnmodifiableList;
039 import com.liferay.portal.kernel.util.Validator;
040 import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
041 import com.liferay.portal.model.CacheModel;
042 import com.liferay.portal.model.ModelListener;
043 import com.liferay.portal.model.Organization;
044 import com.liferay.portal.model.impl.OrganizationImpl;
045 import com.liferay.portal.model.impl.OrganizationModelImpl;
046 import com.liferay.portal.security.permission.InlineSQLHelperUtil;
047 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
048 import com.liferay.portal.service.persistence.impl.TableMapper;
049 import com.liferay.portal.service.persistence.impl.TableMapperFactory;
050
051 import java.io.Serializable;
052
053 import java.util.ArrayList;
054 import java.util.Collections;
055 import java.util.List;
056 import java.util.Set;
057
058
070 public class OrganizationPersistenceImpl extends BasePersistenceImpl<Organization>
071 implements OrganizationPersistence {
072
077 public static final String FINDER_CLASS_NAME_ENTITY = OrganizationImpl.class.getName();
078 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
079 ".List1";
080 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
081 ".List2";
082 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(OrganizationModelImpl.ENTITY_CACHE_ENABLED,
083 OrganizationModelImpl.FINDER_CACHE_ENABLED, OrganizationImpl.class,
084 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
085 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(OrganizationModelImpl.ENTITY_CACHE_ENABLED,
086 OrganizationModelImpl.FINDER_CACHE_ENABLED, OrganizationImpl.class,
087 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
088 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(OrganizationModelImpl.ENTITY_CACHE_ENABLED,
089 OrganizationModelImpl.FINDER_CACHE_ENABLED, Long.class,
090 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
091 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(OrganizationModelImpl.ENTITY_CACHE_ENABLED,
092 OrganizationModelImpl.FINDER_CACHE_ENABLED, OrganizationImpl.class,
093 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid",
094 new String[] {
095 String.class.getName(),
096
097 Integer.class.getName(), Integer.class.getName(),
098 OrderByComparator.class.getName()
099 });
100 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(OrganizationModelImpl.ENTITY_CACHE_ENABLED,
101 OrganizationModelImpl.FINDER_CACHE_ENABLED, OrganizationImpl.class,
102 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
103 new String[] { String.class.getName() },
104 OrganizationModelImpl.UUID_COLUMN_BITMASK |
105 OrganizationModelImpl.NAME_COLUMN_BITMASK);
106 public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(OrganizationModelImpl.ENTITY_CACHE_ENABLED,
107 OrganizationModelImpl.FINDER_CACHE_ENABLED, Long.class,
108 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
109 new String[] { String.class.getName() });
110
111
118 @Override
119 public List<Organization> findByUuid(String uuid) throws SystemException {
120 return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
121 }
122
123
136 @Override
137 public List<Organization> findByUuid(String uuid, int start, int end)
138 throws SystemException {
139 return findByUuid(uuid, start, end, null);
140 }
141
142
156 @Override
157 public List<Organization> findByUuid(String uuid, int start, int end,
158 OrderByComparator orderByComparator) throws SystemException {
159 boolean pagination = true;
160 FinderPath finderPath = null;
161 Object[] finderArgs = null;
162
163 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
164 (orderByComparator == null)) {
165 pagination = false;
166 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
167 finderArgs = new Object[] { uuid };
168 }
169 else {
170 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
171 finderArgs = new Object[] { uuid, start, end, orderByComparator };
172 }
173
174 List<Organization> list = (List<Organization>)FinderCacheUtil.getResult(finderPath,
175 finderArgs, this);
176
177 if ((list != null) && !list.isEmpty()) {
178 for (Organization organization : list) {
179 if (!Validator.equals(uuid, organization.getUuid())) {
180 list = null;
181
182 break;
183 }
184 }
185 }
186
187 if (list == null) {
188 StringBundler query = null;
189
190 if (orderByComparator != null) {
191 query = new StringBundler(3 +
192 (orderByComparator.getOrderByFields().length * 3));
193 }
194 else {
195 query = new StringBundler(3);
196 }
197
198 query.append(_SQL_SELECT_ORGANIZATION_WHERE);
199
200 boolean bindUuid = false;
201
202 if (uuid == null) {
203 query.append(_FINDER_COLUMN_UUID_UUID_1);
204 }
205 else if (uuid.equals(StringPool.BLANK)) {
206 query.append(_FINDER_COLUMN_UUID_UUID_3);
207 }
208 else {
209 bindUuid = true;
210
211 query.append(_FINDER_COLUMN_UUID_UUID_2);
212 }
213
214 if (orderByComparator != null) {
215 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
216 orderByComparator);
217 }
218 else
219 if (pagination) {
220 query.append(OrganizationModelImpl.ORDER_BY_JPQL);
221 }
222
223 String sql = query.toString();
224
225 Session session = null;
226
227 try {
228 session = openSession();
229
230 Query q = session.createQuery(sql);
231
232 QueryPos qPos = QueryPos.getInstance(q);
233
234 if (bindUuid) {
235 qPos.add(uuid);
236 }
237
238 if (!pagination) {
239 list = (List<Organization>)QueryUtil.list(q, getDialect(),
240 start, end, false);
241
242 Collections.sort(list);
243
244 list = new UnmodifiableList<Organization>(list);
245 }
246 else {
247 list = (List<Organization>)QueryUtil.list(q, getDialect(),
248 start, end);
249 }
250
251 cacheResult(list);
252
253 FinderCacheUtil.putResult(finderPath, finderArgs, list);
254 }
255 catch (Exception e) {
256 FinderCacheUtil.removeResult(finderPath, finderArgs);
257
258 throw processException(e);
259 }
260 finally {
261 closeSession(session);
262 }
263 }
264
265 return list;
266 }
267
268
277 @Override
278 public Organization findByUuid_First(String uuid,
279 OrderByComparator orderByComparator)
280 throws NoSuchOrganizationException, SystemException {
281 Organization organization = fetchByUuid_First(uuid, orderByComparator);
282
283 if (organization != null) {
284 return organization;
285 }
286
287 StringBundler msg = new StringBundler(4);
288
289 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
290
291 msg.append("uuid=");
292 msg.append(uuid);
293
294 msg.append(StringPool.CLOSE_CURLY_BRACE);
295
296 throw new NoSuchOrganizationException(msg.toString());
297 }
298
299
307 @Override
308 public Organization fetchByUuid_First(String uuid,
309 OrderByComparator orderByComparator) throws SystemException {
310 List<Organization> list = findByUuid(uuid, 0, 1, orderByComparator);
311
312 if (!list.isEmpty()) {
313 return list.get(0);
314 }
315
316 return null;
317 }
318
319
328 @Override
329 public Organization findByUuid_Last(String uuid,
330 OrderByComparator orderByComparator)
331 throws NoSuchOrganizationException, SystemException {
332 Organization organization = fetchByUuid_Last(uuid, orderByComparator);
333
334 if (organization != null) {
335 return organization;
336 }
337
338 StringBundler msg = new StringBundler(4);
339
340 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
341
342 msg.append("uuid=");
343 msg.append(uuid);
344
345 msg.append(StringPool.CLOSE_CURLY_BRACE);
346
347 throw new NoSuchOrganizationException(msg.toString());
348 }
349
350
358 @Override
359 public Organization fetchByUuid_Last(String uuid,
360 OrderByComparator orderByComparator) throws SystemException {
361 int count = countByUuid(uuid);
362
363 if (count == 0) {
364 return null;
365 }
366
367 List<Organization> list = findByUuid(uuid, count - 1, count,
368 orderByComparator);
369
370 if (!list.isEmpty()) {
371 return list.get(0);
372 }
373
374 return null;
375 }
376
377
387 @Override
388 public Organization[] findByUuid_PrevAndNext(long organizationId,
389 String uuid, OrderByComparator orderByComparator)
390 throws NoSuchOrganizationException, SystemException {
391 Organization organization = findByPrimaryKey(organizationId);
392
393 Session session = null;
394
395 try {
396 session = openSession();
397
398 Organization[] array = new OrganizationImpl[3];
399
400 array[0] = getByUuid_PrevAndNext(session, organization, uuid,
401 orderByComparator, true);
402
403 array[1] = organization;
404
405 array[2] = getByUuid_PrevAndNext(session, organization, uuid,
406 orderByComparator, false);
407
408 return array;
409 }
410 catch (Exception e) {
411 throw processException(e);
412 }
413 finally {
414 closeSession(session);
415 }
416 }
417
418 protected Organization getByUuid_PrevAndNext(Session session,
419 Organization organization, String uuid,
420 OrderByComparator orderByComparator, boolean previous) {
421 StringBundler query = null;
422
423 if (orderByComparator != null) {
424 query = new StringBundler(6 +
425 (orderByComparator.getOrderByFields().length * 6));
426 }
427 else {
428 query = new StringBundler(3);
429 }
430
431 query.append(_SQL_SELECT_ORGANIZATION_WHERE);
432
433 boolean bindUuid = false;
434
435 if (uuid == null) {
436 query.append(_FINDER_COLUMN_UUID_UUID_1);
437 }
438 else if (uuid.equals(StringPool.BLANK)) {
439 query.append(_FINDER_COLUMN_UUID_UUID_3);
440 }
441 else {
442 bindUuid = true;
443
444 query.append(_FINDER_COLUMN_UUID_UUID_2);
445 }
446
447 if (orderByComparator != null) {
448 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
449
450 if (orderByConditionFields.length > 0) {
451 query.append(WHERE_AND);
452 }
453
454 for (int i = 0; i < orderByConditionFields.length; i++) {
455 query.append(_ORDER_BY_ENTITY_ALIAS);
456 query.append(orderByConditionFields[i]);
457
458 if ((i + 1) < orderByConditionFields.length) {
459 if (orderByComparator.isAscending() ^ previous) {
460 query.append(WHERE_GREATER_THAN_HAS_NEXT);
461 }
462 else {
463 query.append(WHERE_LESSER_THAN_HAS_NEXT);
464 }
465 }
466 else {
467 if (orderByComparator.isAscending() ^ previous) {
468 query.append(WHERE_GREATER_THAN);
469 }
470 else {
471 query.append(WHERE_LESSER_THAN);
472 }
473 }
474 }
475
476 query.append(ORDER_BY_CLAUSE);
477
478 String[] orderByFields = orderByComparator.getOrderByFields();
479
480 for (int i = 0; i < orderByFields.length; i++) {
481 query.append(_ORDER_BY_ENTITY_ALIAS);
482 query.append(orderByFields[i]);
483
484 if ((i + 1) < orderByFields.length) {
485 if (orderByComparator.isAscending() ^ previous) {
486 query.append(ORDER_BY_ASC_HAS_NEXT);
487 }
488 else {
489 query.append(ORDER_BY_DESC_HAS_NEXT);
490 }
491 }
492 else {
493 if (orderByComparator.isAscending() ^ previous) {
494 query.append(ORDER_BY_ASC);
495 }
496 else {
497 query.append(ORDER_BY_DESC);
498 }
499 }
500 }
501 }
502 else {
503 query.append(OrganizationModelImpl.ORDER_BY_JPQL);
504 }
505
506 String sql = query.toString();
507
508 Query q = session.createQuery(sql);
509
510 q.setFirstResult(0);
511 q.setMaxResults(2);
512
513 QueryPos qPos = QueryPos.getInstance(q);
514
515 if (bindUuid) {
516 qPos.add(uuid);
517 }
518
519 if (orderByComparator != null) {
520 Object[] values = orderByComparator.getOrderByConditionValues(organization);
521
522 for (Object value : values) {
523 qPos.add(value);
524 }
525 }
526
527 List<Organization> list = q.list();
528
529 if (list.size() == 2) {
530 return list.get(1);
531 }
532 else {
533 return null;
534 }
535 }
536
537
544 @Override
545 public List<Organization> filterFindByUuid(String uuid)
546 throws SystemException {
547 return filterFindByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
548 }
549
550
563 @Override
564 public List<Organization> filterFindByUuid(String uuid, int start, int end)
565 throws SystemException {
566 return filterFindByUuid(uuid, start, end, null);
567 }
568
569
583 @Override
584 public List<Organization> filterFindByUuid(String uuid, int start, int end,
585 OrderByComparator orderByComparator) throws SystemException {
586 if (!InlineSQLHelperUtil.isEnabled()) {
587 return findByUuid(uuid, start, end, orderByComparator);
588 }
589
590 StringBundler query = null;
591
592 if (orderByComparator != null) {
593 query = new StringBundler(3 +
594 (orderByComparator.getOrderByFields().length * 3));
595 }
596 else {
597 query = new StringBundler(3);
598 }
599
600 if (getDB().isSupportsInlineDistinct()) {
601 query.append(_FILTER_SQL_SELECT_ORGANIZATION_WHERE);
602 }
603 else {
604 query.append(_FILTER_SQL_SELECT_ORGANIZATION_NO_INLINE_DISTINCT_WHERE_1);
605 }
606
607 boolean bindUuid = false;
608
609 if (uuid == null) {
610 query.append(_FINDER_COLUMN_UUID_UUID_1_SQL);
611 }
612 else if (uuid.equals(StringPool.BLANK)) {
613 query.append(_FINDER_COLUMN_UUID_UUID_3_SQL);
614 }
615 else {
616 bindUuid = true;
617
618 query.append(_FINDER_COLUMN_UUID_UUID_2_SQL);
619 }
620
621 if (!getDB().isSupportsInlineDistinct()) {
622 query.append(_FILTER_SQL_SELECT_ORGANIZATION_NO_INLINE_DISTINCT_WHERE_2);
623 }
624
625 if (orderByComparator != null) {
626 if (getDB().isSupportsInlineDistinct()) {
627 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
628 orderByComparator, true);
629 }
630 else {
631 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
632 orderByComparator, true);
633 }
634 }
635 else {
636 if (getDB().isSupportsInlineDistinct()) {
637 query.append(OrganizationModelImpl.ORDER_BY_JPQL);
638 }
639 else {
640 query.append(OrganizationModelImpl.ORDER_BY_SQL);
641 }
642 }
643
644 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
645 Organization.class.getName(),
646 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
647
648 Session session = null;
649
650 try {
651 session = openSession();
652
653 SQLQuery q = session.createSQLQuery(sql);
654
655 if (getDB().isSupportsInlineDistinct()) {
656 q.addEntity(_FILTER_ENTITY_ALIAS, OrganizationImpl.class);
657 }
658 else {
659 q.addEntity(_FILTER_ENTITY_TABLE, OrganizationImpl.class);
660 }
661
662 QueryPos qPos = QueryPos.getInstance(q);
663
664 if (bindUuid) {
665 qPos.add(uuid);
666 }
667
668 return (List<Organization>)QueryUtil.list(q, getDialect(), start,
669 end);
670 }
671 catch (Exception e) {
672 throw processException(e);
673 }
674 finally {
675 closeSession(session);
676 }
677 }
678
679
689 @Override
690 public Organization[] filterFindByUuid_PrevAndNext(long organizationId,
691 String uuid, OrderByComparator orderByComparator)
692 throws NoSuchOrganizationException, SystemException {
693 if (!InlineSQLHelperUtil.isEnabled()) {
694 return findByUuid_PrevAndNext(organizationId, uuid,
695 orderByComparator);
696 }
697
698 Organization organization = findByPrimaryKey(organizationId);
699
700 Session session = null;
701
702 try {
703 session = openSession();
704
705 Organization[] array = new OrganizationImpl[3];
706
707 array[0] = filterGetByUuid_PrevAndNext(session, organization, uuid,
708 orderByComparator, true);
709
710 array[1] = organization;
711
712 array[2] = filterGetByUuid_PrevAndNext(session, organization, uuid,
713 orderByComparator, false);
714
715 return array;
716 }
717 catch (Exception e) {
718 throw processException(e);
719 }
720 finally {
721 closeSession(session);
722 }
723 }
724
725 protected Organization filterGetByUuid_PrevAndNext(Session session,
726 Organization organization, String uuid,
727 OrderByComparator orderByComparator, boolean previous) {
728 StringBundler query = null;
729
730 if (orderByComparator != null) {
731 query = new StringBundler(6 +
732 (orderByComparator.getOrderByFields().length * 6));
733 }
734 else {
735 query = new StringBundler(3);
736 }
737
738 if (getDB().isSupportsInlineDistinct()) {
739 query.append(_FILTER_SQL_SELECT_ORGANIZATION_WHERE);
740 }
741 else {
742 query.append(_FILTER_SQL_SELECT_ORGANIZATION_NO_INLINE_DISTINCT_WHERE_1);
743 }
744
745 boolean bindUuid = false;
746
747 if (uuid == null) {
748 query.append(_FINDER_COLUMN_UUID_UUID_1_SQL);
749 }
750 else if (uuid.equals(StringPool.BLANK)) {
751 query.append(_FINDER_COLUMN_UUID_UUID_3_SQL);
752 }
753 else {
754 bindUuid = true;
755
756 query.append(_FINDER_COLUMN_UUID_UUID_2_SQL);
757 }
758
759 if (!getDB().isSupportsInlineDistinct()) {
760 query.append(_FILTER_SQL_SELECT_ORGANIZATION_NO_INLINE_DISTINCT_WHERE_2);
761 }
762
763 if (orderByComparator != null) {
764 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
765
766 if (orderByConditionFields.length > 0) {
767 query.append(WHERE_AND);
768 }
769
770 for (int i = 0; i < orderByConditionFields.length; i++) {
771 if (getDB().isSupportsInlineDistinct()) {
772 query.append(_ORDER_BY_ENTITY_ALIAS);
773 }
774 else {
775 query.append(_ORDER_BY_ENTITY_TABLE);
776 }
777
778 query.append(orderByConditionFields[i]);
779
780 if ((i + 1) < orderByConditionFields.length) {
781 if (orderByComparator.isAscending() ^ previous) {
782 query.append(WHERE_GREATER_THAN_HAS_NEXT);
783 }
784 else {
785 query.append(WHERE_LESSER_THAN_HAS_NEXT);
786 }
787 }
788 else {
789 if (orderByComparator.isAscending() ^ previous) {
790 query.append(WHERE_GREATER_THAN);
791 }
792 else {
793 query.append(WHERE_LESSER_THAN);
794 }
795 }
796 }
797
798 query.append(ORDER_BY_CLAUSE);
799
800 String[] orderByFields = orderByComparator.getOrderByFields();
801
802 for (int i = 0; i < orderByFields.length; i++) {
803 if (getDB().isSupportsInlineDistinct()) {
804 query.append(_ORDER_BY_ENTITY_ALIAS);
805 }
806 else {
807 query.append(_ORDER_BY_ENTITY_TABLE);
808 }
809
810 query.append(orderByFields[i]);
811
812 if ((i + 1) < orderByFields.length) {
813 if (orderByComparator.isAscending() ^ previous) {
814 query.append(ORDER_BY_ASC_HAS_NEXT);
815 }
816 else {
817 query.append(ORDER_BY_DESC_HAS_NEXT);
818 }
819 }
820 else {
821 if (orderByComparator.isAscending() ^ previous) {
822 query.append(ORDER_BY_ASC);
823 }
824 else {
825 query.append(ORDER_BY_DESC);
826 }
827 }
828 }
829 }
830 else {
831 if (getDB().isSupportsInlineDistinct()) {
832 query.append(OrganizationModelImpl.ORDER_BY_JPQL);
833 }
834 else {
835 query.append(OrganizationModelImpl.ORDER_BY_SQL);
836 }
837 }
838
839 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
840 Organization.class.getName(),
841 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
842
843 SQLQuery q = session.createSQLQuery(sql);
844
845 q.setFirstResult(0);
846 q.setMaxResults(2);
847
848 if (getDB().isSupportsInlineDistinct()) {
849 q.addEntity(_FILTER_ENTITY_ALIAS, OrganizationImpl.class);
850 }
851 else {
852 q.addEntity(_FILTER_ENTITY_TABLE, OrganizationImpl.class);
853 }
854
855 QueryPos qPos = QueryPos.getInstance(q);
856
857 if (bindUuid) {
858 qPos.add(uuid);
859 }
860
861 if (orderByComparator != null) {
862 Object[] values = orderByComparator.getOrderByConditionValues(organization);
863
864 for (Object value : values) {
865 qPos.add(value);
866 }
867 }
868
869 List<Organization> list = q.list();
870
871 if (list.size() == 2) {
872 return list.get(1);
873 }
874 else {
875 return null;
876 }
877 }
878
879
885 @Override
886 public void removeByUuid(String uuid) throws SystemException {
887 for (Organization organization : findByUuid(uuid, QueryUtil.ALL_POS,
888 QueryUtil.ALL_POS, null)) {
889 remove(organization);
890 }
891 }
892
893
900 @Override
901 public int countByUuid(String uuid) throws SystemException {
902 FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID;
903
904 Object[] finderArgs = new Object[] { uuid };
905
906 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
907 this);
908
909 if (count == null) {
910 StringBundler query = new StringBundler(2);
911
912 query.append(_SQL_COUNT_ORGANIZATION_WHERE);
913
914 boolean bindUuid = false;
915
916 if (uuid == null) {
917 query.append(_FINDER_COLUMN_UUID_UUID_1);
918 }
919 else if (uuid.equals(StringPool.BLANK)) {
920 query.append(_FINDER_COLUMN_UUID_UUID_3);
921 }
922 else {
923 bindUuid = true;
924
925 query.append(_FINDER_COLUMN_UUID_UUID_2);
926 }
927
928 String sql = query.toString();
929
930 Session session = null;
931
932 try {
933 session = openSession();
934
935 Query q = session.createQuery(sql);
936
937 QueryPos qPos = QueryPos.getInstance(q);
938
939 if (bindUuid) {
940 qPos.add(uuid);
941 }
942
943 count = (Long)q.uniqueResult();
944
945 FinderCacheUtil.putResult(finderPath, finderArgs, count);
946 }
947 catch (Exception e) {
948 FinderCacheUtil.removeResult(finderPath, finderArgs);
949
950 throw processException(e);
951 }
952 finally {
953 closeSession(session);
954 }
955 }
956
957 return count.intValue();
958 }
959
960
967 @Override
968 public int filterCountByUuid(String uuid) throws SystemException {
969 if (!InlineSQLHelperUtil.isEnabled()) {
970 return countByUuid(uuid);
971 }
972
973 StringBundler query = new StringBundler(2);
974
975 query.append(_FILTER_SQL_COUNT_ORGANIZATION_WHERE);
976
977 boolean bindUuid = false;
978
979 if (uuid == null) {
980 query.append(_FINDER_COLUMN_UUID_UUID_1_SQL);
981 }
982 else if (uuid.equals(StringPool.BLANK)) {
983 query.append(_FINDER_COLUMN_UUID_UUID_3_SQL);
984 }
985 else {
986 bindUuid = true;
987
988 query.append(_FINDER_COLUMN_UUID_UUID_2_SQL);
989 }
990
991 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
992 Organization.class.getName(),
993 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
994
995 Session session = null;
996
997 try {
998 session = openSession();
999
1000 SQLQuery q = session.createSQLQuery(sql);
1001
1002 q.addScalar(COUNT_COLUMN_NAME,
1003 com.liferay.portal.kernel.dao.orm.Type.LONG);
1004
1005 QueryPos qPos = QueryPos.getInstance(q);
1006
1007 if (bindUuid) {
1008 qPos.add(uuid);
1009 }
1010
1011 Long count = (Long)q.uniqueResult();
1012
1013 return count.intValue();
1014 }
1015 catch (Exception e) {
1016 throw processException(e);
1017 }
1018 finally {
1019 closeSession(session);
1020 }
1021 }
1022
1023 private static final String _FINDER_COLUMN_UUID_UUID_1 = "organization.uuid IS NULL";
1024 private static final String _FINDER_COLUMN_UUID_UUID_2 = "organization.uuid = ?";
1025 private static final String _FINDER_COLUMN_UUID_UUID_3 = "(organization.uuid IS NULL OR organization.uuid = '')";
1026 private static final String _FINDER_COLUMN_UUID_UUID_1_SQL = "organization.uuid_ IS NULL";
1027 private static final String _FINDER_COLUMN_UUID_UUID_2_SQL = "organization.uuid_ = ?";
1028 private static final String _FINDER_COLUMN_UUID_UUID_3_SQL = "(organization.uuid_ IS NULL OR organization.uuid_ = '')";
1029 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C = new FinderPath(OrganizationModelImpl.ENTITY_CACHE_ENABLED,
1030 OrganizationModelImpl.FINDER_CACHE_ENABLED, OrganizationImpl.class,
1031 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid_C",
1032 new String[] {
1033 String.class.getName(), Long.class.getName(),
1034
1035 Integer.class.getName(), Integer.class.getName(),
1036 OrderByComparator.class.getName()
1037 });
1038 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C =
1039 new FinderPath(OrganizationModelImpl.ENTITY_CACHE_ENABLED,
1040 OrganizationModelImpl.FINDER_CACHE_ENABLED, OrganizationImpl.class,
1041 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid_C",
1042 new String[] { String.class.getName(), Long.class.getName() },
1043 OrganizationModelImpl.UUID_COLUMN_BITMASK |
1044 OrganizationModelImpl.COMPANYID_COLUMN_BITMASK |
1045 OrganizationModelImpl.NAME_COLUMN_BITMASK);
1046 public static final FinderPath FINDER_PATH_COUNT_BY_UUID_C = new FinderPath(OrganizationModelImpl.ENTITY_CACHE_ENABLED,
1047 OrganizationModelImpl.FINDER_CACHE_ENABLED, Long.class,
1048 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid_C",
1049 new String[] { String.class.getName(), Long.class.getName() });
1050
1051
1059 @Override
1060 public List<Organization> findByUuid_C(String uuid, long companyId)
1061 throws SystemException {
1062 return findByUuid_C(uuid, companyId, QueryUtil.ALL_POS,
1063 QueryUtil.ALL_POS, null);
1064 }
1065
1066
1080 @Override
1081 public List<Organization> findByUuid_C(String uuid, long companyId,
1082 int start, int end) throws SystemException {
1083 return findByUuid_C(uuid, companyId, start, end, null);
1084 }
1085
1086
1101 @Override
1102 public List<Organization> findByUuid_C(String uuid, long companyId,
1103 int start, int end, OrderByComparator orderByComparator)
1104 throws SystemException {
1105 boolean pagination = true;
1106 FinderPath finderPath = null;
1107 Object[] finderArgs = null;
1108
1109 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1110 (orderByComparator == null)) {
1111 pagination = false;
1112 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C;
1113 finderArgs = new Object[] { uuid, companyId };
1114 }
1115 else {
1116 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C;
1117 finderArgs = new Object[] {
1118 uuid, companyId,
1119
1120 start, end, orderByComparator
1121 };
1122 }
1123
1124 List<Organization> list = (List<Organization>)FinderCacheUtil.getResult(finderPath,
1125 finderArgs, this);
1126
1127 if ((list != null) && !list.isEmpty()) {
1128 for (Organization organization : list) {
1129 if (!Validator.equals(uuid, organization.getUuid()) ||
1130 (companyId != organization.getCompanyId())) {
1131 list = null;
1132
1133 break;
1134 }
1135 }
1136 }
1137
1138 if (list == null) {
1139 StringBundler query = null;
1140
1141 if (orderByComparator != null) {
1142 query = new StringBundler(4 +
1143 (orderByComparator.getOrderByFields().length * 3));
1144 }
1145 else {
1146 query = new StringBundler(4);
1147 }
1148
1149 query.append(_SQL_SELECT_ORGANIZATION_WHERE);
1150
1151 boolean bindUuid = false;
1152
1153 if (uuid == null) {
1154 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1155 }
1156 else if (uuid.equals(StringPool.BLANK)) {
1157 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1158 }
1159 else {
1160 bindUuid = true;
1161
1162 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1163 }
1164
1165 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1166
1167 if (orderByComparator != null) {
1168 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1169 orderByComparator);
1170 }
1171 else
1172 if (pagination) {
1173 query.append(OrganizationModelImpl.ORDER_BY_JPQL);
1174 }
1175
1176 String sql = query.toString();
1177
1178 Session session = null;
1179
1180 try {
1181 session = openSession();
1182
1183 Query q = session.createQuery(sql);
1184
1185 QueryPos qPos = QueryPos.getInstance(q);
1186
1187 if (bindUuid) {
1188 qPos.add(uuid);
1189 }
1190
1191 qPos.add(companyId);
1192
1193 if (!pagination) {
1194 list = (List<Organization>)QueryUtil.list(q, getDialect(),
1195 start, end, false);
1196
1197 Collections.sort(list);
1198
1199 list = new UnmodifiableList<Organization>(list);
1200 }
1201 else {
1202 list = (List<Organization>)QueryUtil.list(q, getDialect(),
1203 start, end);
1204 }
1205
1206 cacheResult(list);
1207
1208 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1209 }
1210 catch (Exception e) {
1211 FinderCacheUtil.removeResult(finderPath, finderArgs);
1212
1213 throw processException(e);
1214 }
1215 finally {
1216 closeSession(session);
1217 }
1218 }
1219
1220 return list;
1221 }
1222
1223
1233 @Override
1234 public Organization findByUuid_C_First(String uuid, long companyId,
1235 OrderByComparator orderByComparator)
1236 throws NoSuchOrganizationException, SystemException {
1237 Organization organization = fetchByUuid_C_First(uuid, companyId,
1238 orderByComparator);
1239
1240 if (organization != null) {
1241 return organization;
1242 }
1243
1244 StringBundler msg = new StringBundler(6);
1245
1246 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1247
1248 msg.append("uuid=");
1249 msg.append(uuid);
1250
1251 msg.append(", companyId=");
1252 msg.append(companyId);
1253
1254 msg.append(StringPool.CLOSE_CURLY_BRACE);
1255
1256 throw new NoSuchOrganizationException(msg.toString());
1257 }
1258
1259
1268 @Override
1269 public Organization fetchByUuid_C_First(String uuid, long companyId,
1270 OrderByComparator orderByComparator) throws SystemException {
1271 List<Organization> list = findByUuid_C(uuid, companyId, 0, 1,
1272 orderByComparator);
1273
1274 if (!list.isEmpty()) {
1275 return list.get(0);
1276 }
1277
1278 return null;
1279 }
1280
1281
1291 @Override
1292 public Organization findByUuid_C_Last(String uuid, long companyId,
1293 OrderByComparator orderByComparator)
1294 throws NoSuchOrganizationException, SystemException {
1295 Organization organization = fetchByUuid_C_Last(uuid, companyId,
1296 orderByComparator);
1297
1298 if (organization != null) {
1299 return organization;
1300 }
1301
1302 StringBundler msg = new StringBundler(6);
1303
1304 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1305
1306 msg.append("uuid=");
1307 msg.append(uuid);
1308
1309 msg.append(", companyId=");
1310 msg.append(companyId);
1311
1312 msg.append(StringPool.CLOSE_CURLY_BRACE);
1313
1314 throw new NoSuchOrganizationException(msg.toString());
1315 }
1316
1317
1326 @Override
1327 public Organization fetchByUuid_C_Last(String uuid, long companyId,
1328 OrderByComparator orderByComparator) throws SystemException {
1329 int count = countByUuid_C(uuid, companyId);
1330
1331 if (count == 0) {
1332 return null;
1333 }
1334
1335 List<Organization> list = findByUuid_C(uuid, companyId, count - 1,
1336 count, orderByComparator);
1337
1338 if (!list.isEmpty()) {
1339 return list.get(0);
1340 }
1341
1342 return null;
1343 }
1344
1345
1356 @Override
1357 public Organization[] findByUuid_C_PrevAndNext(long organizationId,
1358 String uuid, long companyId, OrderByComparator orderByComparator)
1359 throws NoSuchOrganizationException, SystemException {
1360 Organization organization = findByPrimaryKey(organizationId);
1361
1362 Session session = null;
1363
1364 try {
1365 session = openSession();
1366
1367 Organization[] array = new OrganizationImpl[3];
1368
1369 array[0] = getByUuid_C_PrevAndNext(session, organization, uuid,
1370 companyId, orderByComparator, true);
1371
1372 array[1] = organization;
1373
1374 array[2] = getByUuid_C_PrevAndNext(session, organization, uuid,
1375 companyId, orderByComparator, false);
1376
1377 return array;
1378 }
1379 catch (Exception e) {
1380 throw processException(e);
1381 }
1382 finally {
1383 closeSession(session);
1384 }
1385 }
1386
1387 protected Organization getByUuid_C_PrevAndNext(Session session,
1388 Organization organization, String uuid, long companyId,
1389 OrderByComparator orderByComparator, boolean previous) {
1390 StringBundler query = null;
1391
1392 if (orderByComparator != null) {
1393 query = new StringBundler(6 +
1394 (orderByComparator.getOrderByFields().length * 6));
1395 }
1396 else {
1397 query = new StringBundler(3);
1398 }
1399
1400 query.append(_SQL_SELECT_ORGANIZATION_WHERE);
1401
1402 boolean bindUuid = false;
1403
1404 if (uuid == null) {
1405 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1406 }
1407 else if (uuid.equals(StringPool.BLANK)) {
1408 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1409 }
1410 else {
1411 bindUuid = true;
1412
1413 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1414 }
1415
1416 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1417
1418 if (orderByComparator != null) {
1419 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1420
1421 if (orderByConditionFields.length > 0) {
1422 query.append(WHERE_AND);
1423 }
1424
1425 for (int i = 0; i < orderByConditionFields.length; i++) {
1426 query.append(_ORDER_BY_ENTITY_ALIAS);
1427 query.append(orderByConditionFields[i]);
1428
1429 if ((i + 1) < orderByConditionFields.length) {
1430 if (orderByComparator.isAscending() ^ previous) {
1431 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1432 }
1433 else {
1434 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1435 }
1436 }
1437 else {
1438 if (orderByComparator.isAscending() ^ previous) {
1439 query.append(WHERE_GREATER_THAN);
1440 }
1441 else {
1442 query.append(WHERE_LESSER_THAN);
1443 }
1444 }
1445 }
1446
1447 query.append(ORDER_BY_CLAUSE);
1448
1449 String[] orderByFields = orderByComparator.getOrderByFields();
1450
1451 for (int i = 0; i < orderByFields.length; i++) {
1452 query.append(_ORDER_BY_ENTITY_ALIAS);
1453 query.append(orderByFields[i]);
1454
1455 if ((i + 1) < orderByFields.length) {
1456 if (orderByComparator.isAscending() ^ previous) {
1457 query.append(ORDER_BY_ASC_HAS_NEXT);
1458 }
1459 else {
1460 query.append(ORDER_BY_DESC_HAS_NEXT);
1461 }
1462 }
1463 else {
1464 if (orderByComparator.isAscending() ^ previous) {
1465 query.append(ORDER_BY_ASC);
1466 }
1467 else {
1468 query.append(ORDER_BY_DESC);
1469 }
1470 }
1471 }
1472 }
1473 else {
1474 query.append(OrganizationModelImpl.ORDER_BY_JPQL);
1475 }
1476
1477 String sql = query.toString();
1478
1479 Query q = session.createQuery(sql);
1480
1481 q.setFirstResult(0);
1482 q.setMaxResults(2);
1483
1484 QueryPos qPos = QueryPos.getInstance(q);
1485
1486 if (bindUuid) {
1487 qPos.add(uuid);
1488 }
1489
1490 qPos.add(companyId);
1491
1492 if (orderByComparator != null) {
1493 Object[] values = orderByComparator.getOrderByConditionValues(organization);
1494
1495 for (Object value : values) {
1496 qPos.add(value);
1497 }
1498 }
1499
1500 List<Organization> list = q.list();
1501
1502 if (list.size() == 2) {
1503 return list.get(1);
1504 }
1505 else {
1506 return null;
1507 }
1508 }
1509
1510
1518 @Override
1519 public List<Organization> filterFindByUuid_C(String uuid, long companyId)
1520 throws SystemException {
1521 return filterFindByUuid_C(uuid, companyId, QueryUtil.ALL_POS,
1522 QueryUtil.ALL_POS, null);
1523 }
1524
1525
1539 @Override
1540 public List<Organization> filterFindByUuid_C(String uuid, long companyId,
1541 int start, int end) throws SystemException {
1542 return filterFindByUuid_C(uuid, companyId, start, end, null);
1543 }
1544
1545
1560 @Override
1561 public List<Organization> filterFindByUuid_C(String uuid, long companyId,
1562 int start, int end, OrderByComparator orderByComparator)
1563 throws SystemException {
1564 if (!InlineSQLHelperUtil.isEnabled()) {
1565 return findByUuid_C(uuid, companyId, start, end, orderByComparator);
1566 }
1567
1568 StringBundler query = null;
1569
1570 if (orderByComparator != null) {
1571 query = new StringBundler(4 +
1572 (orderByComparator.getOrderByFields().length * 3));
1573 }
1574 else {
1575 query = new StringBundler(4);
1576 }
1577
1578 if (getDB().isSupportsInlineDistinct()) {
1579 query.append(_FILTER_SQL_SELECT_ORGANIZATION_WHERE);
1580 }
1581 else {
1582 query.append(_FILTER_SQL_SELECT_ORGANIZATION_NO_INLINE_DISTINCT_WHERE_1);
1583 }
1584
1585 boolean bindUuid = false;
1586
1587 if (uuid == null) {
1588 query.append(_FINDER_COLUMN_UUID_C_UUID_1_SQL);
1589 }
1590 else if (uuid.equals(StringPool.BLANK)) {
1591 query.append(_FINDER_COLUMN_UUID_C_UUID_3_SQL);
1592 }
1593 else {
1594 bindUuid = true;
1595
1596 query.append(_FINDER_COLUMN_UUID_C_UUID_2_SQL);
1597 }
1598
1599 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1600
1601 if (!getDB().isSupportsInlineDistinct()) {
1602 query.append(_FILTER_SQL_SELECT_ORGANIZATION_NO_INLINE_DISTINCT_WHERE_2);
1603 }
1604
1605 if (orderByComparator != null) {
1606 if (getDB().isSupportsInlineDistinct()) {
1607 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1608 orderByComparator, true);
1609 }
1610 else {
1611 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
1612 orderByComparator, true);
1613 }
1614 }
1615 else {
1616 if (getDB().isSupportsInlineDistinct()) {
1617 query.append(OrganizationModelImpl.ORDER_BY_JPQL);
1618 }
1619 else {
1620 query.append(OrganizationModelImpl.ORDER_BY_SQL);
1621 }
1622 }
1623
1624 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1625 Organization.class.getName(),
1626 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
1627
1628 Session session = null;
1629
1630 try {
1631 session = openSession();
1632
1633 SQLQuery q = session.createSQLQuery(sql);
1634
1635 if (getDB().isSupportsInlineDistinct()) {
1636 q.addEntity(_FILTER_ENTITY_ALIAS, OrganizationImpl.class);
1637 }
1638 else {
1639 q.addEntity(_FILTER_ENTITY_TABLE, OrganizationImpl.class);
1640 }
1641
1642 QueryPos qPos = QueryPos.getInstance(q);
1643
1644 if (bindUuid) {
1645 qPos.add(uuid);
1646 }
1647
1648 qPos.add(companyId);
1649
1650 return (List<Organization>)QueryUtil.list(q, getDialect(), start,
1651 end);
1652 }
1653 catch (Exception e) {
1654 throw processException(e);
1655 }
1656 finally {
1657 closeSession(session);
1658 }
1659 }
1660
1661
1672 @Override
1673 public Organization[] filterFindByUuid_C_PrevAndNext(long organizationId,
1674 String uuid, long companyId, OrderByComparator orderByComparator)
1675 throws NoSuchOrganizationException, SystemException {
1676 if (!InlineSQLHelperUtil.isEnabled()) {
1677 return findByUuid_C_PrevAndNext(organizationId, uuid, companyId,
1678 orderByComparator);
1679 }
1680
1681 Organization organization = findByPrimaryKey(organizationId);
1682
1683 Session session = null;
1684
1685 try {
1686 session = openSession();
1687
1688 Organization[] array = new OrganizationImpl[3];
1689
1690 array[0] = filterGetByUuid_C_PrevAndNext(session, organization,
1691 uuid, companyId, orderByComparator, true);
1692
1693 array[1] = organization;
1694
1695 array[2] = filterGetByUuid_C_PrevAndNext(session, organization,
1696 uuid, companyId, orderByComparator, false);
1697
1698 return array;
1699 }
1700 catch (Exception e) {
1701 throw processException(e);
1702 }
1703 finally {
1704 closeSession(session);
1705 }
1706 }
1707
1708 protected Organization filterGetByUuid_C_PrevAndNext(Session session,
1709 Organization organization, String uuid, long companyId,
1710 OrderByComparator orderByComparator, boolean previous) {
1711 StringBundler query = null;
1712
1713 if (orderByComparator != null) {
1714 query = new StringBundler(6 +
1715 (orderByComparator.getOrderByFields().length * 6));
1716 }
1717 else {
1718 query = new StringBundler(3);
1719 }
1720
1721 if (getDB().isSupportsInlineDistinct()) {
1722 query.append(_FILTER_SQL_SELECT_ORGANIZATION_WHERE);
1723 }
1724 else {
1725 query.append(_FILTER_SQL_SELECT_ORGANIZATION_NO_INLINE_DISTINCT_WHERE_1);
1726 }
1727
1728 boolean bindUuid = false;
1729
1730 if (uuid == null) {
1731 query.append(_FINDER_COLUMN_UUID_C_UUID_1_SQL);
1732 }
1733 else if (uuid.equals(StringPool.BLANK)) {
1734 query.append(_FINDER_COLUMN_UUID_C_UUID_3_SQL);
1735 }
1736 else {
1737 bindUuid = true;
1738
1739 query.append(_FINDER_COLUMN_UUID_C_UUID_2_SQL);
1740 }
1741
1742 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1743
1744 if (!getDB().isSupportsInlineDistinct()) {
1745 query.append(_FILTER_SQL_SELECT_ORGANIZATION_NO_INLINE_DISTINCT_WHERE_2);
1746 }
1747
1748 if (orderByComparator != null) {
1749 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1750
1751 if (orderByConditionFields.length > 0) {
1752 query.append(WHERE_AND);
1753 }
1754
1755 for (int i = 0; i < orderByConditionFields.length; i++) {
1756 if (getDB().isSupportsInlineDistinct()) {
1757 query.append(_ORDER_BY_ENTITY_ALIAS);
1758 }
1759 else {
1760 query.append(_ORDER_BY_ENTITY_TABLE);
1761 }
1762
1763 query.append(orderByConditionFields[i]);
1764
1765 if ((i + 1) < orderByConditionFields.length) {
1766 if (orderByComparator.isAscending() ^ previous) {
1767 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1768 }
1769 else {
1770 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1771 }
1772 }
1773 else {
1774 if (orderByComparator.isAscending() ^ previous) {
1775 query.append(WHERE_GREATER_THAN);
1776 }
1777 else {
1778 query.append(WHERE_LESSER_THAN);
1779 }
1780 }
1781 }
1782
1783 query.append(ORDER_BY_CLAUSE);
1784
1785 String[] orderByFields = orderByComparator.getOrderByFields();
1786
1787 for (int i = 0; i < orderByFields.length; i++) {
1788 if (getDB().isSupportsInlineDistinct()) {
1789 query.append(_ORDER_BY_ENTITY_ALIAS);
1790 }
1791 else {
1792 query.append(_ORDER_BY_ENTITY_TABLE);
1793 }
1794
1795 query.append(orderByFields[i]);
1796
1797 if ((i + 1) < orderByFields.length) {
1798 if (orderByComparator.isAscending() ^ previous) {
1799 query.append(ORDER_BY_ASC_HAS_NEXT);
1800 }
1801 else {
1802 query.append(ORDER_BY_DESC_HAS_NEXT);
1803 }
1804 }
1805 else {
1806 if (orderByComparator.isAscending() ^ previous) {
1807 query.append(ORDER_BY_ASC);
1808 }
1809 else {
1810 query.append(ORDER_BY_DESC);
1811 }
1812 }
1813 }
1814 }
1815 else {
1816 if (getDB().isSupportsInlineDistinct()) {
1817 query.append(OrganizationModelImpl.ORDER_BY_JPQL);
1818 }
1819 else {
1820 query.append(OrganizationModelImpl.ORDER_BY_SQL);
1821 }
1822 }
1823
1824 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1825 Organization.class.getName(),
1826 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
1827
1828 SQLQuery q = session.createSQLQuery(sql);
1829
1830 q.setFirstResult(0);
1831 q.setMaxResults(2);
1832
1833 if (getDB().isSupportsInlineDistinct()) {
1834 q.addEntity(_FILTER_ENTITY_ALIAS, OrganizationImpl.class);
1835 }
1836 else {
1837 q.addEntity(_FILTER_ENTITY_TABLE, OrganizationImpl.class);
1838 }
1839
1840 QueryPos qPos = QueryPos.getInstance(q);
1841
1842 if (bindUuid) {
1843 qPos.add(uuid);
1844 }
1845
1846 qPos.add(companyId);
1847
1848 if (orderByComparator != null) {
1849 Object[] values = orderByComparator.getOrderByConditionValues(organization);
1850
1851 for (Object value : values) {
1852 qPos.add(value);
1853 }
1854 }
1855
1856 List<Organization> list = q.list();
1857
1858 if (list.size() == 2) {
1859 return list.get(1);
1860 }
1861 else {
1862 return null;
1863 }
1864 }
1865
1866
1873 @Override
1874 public void removeByUuid_C(String uuid, long companyId)
1875 throws SystemException {
1876 for (Organization organization : findByUuid_C(uuid, companyId,
1877 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1878 remove(organization);
1879 }
1880 }
1881
1882
1890 @Override
1891 public int countByUuid_C(String uuid, long companyId)
1892 throws SystemException {
1893 FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_C;
1894
1895 Object[] finderArgs = new Object[] { uuid, companyId };
1896
1897 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1898 this);
1899
1900 if (count == null) {
1901 StringBundler query = new StringBundler(3);
1902
1903 query.append(_SQL_COUNT_ORGANIZATION_WHERE);
1904
1905 boolean bindUuid = false;
1906
1907 if (uuid == null) {
1908 query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1909 }
1910 else if (uuid.equals(StringPool.BLANK)) {
1911 query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1912 }
1913 else {
1914 bindUuid = true;
1915
1916 query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1917 }
1918
1919 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1920
1921 String sql = query.toString();
1922
1923 Session session = null;
1924
1925 try {
1926 session = openSession();
1927
1928 Query q = session.createQuery(sql);
1929
1930 QueryPos qPos = QueryPos.getInstance(q);
1931
1932 if (bindUuid) {
1933 qPos.add(uuid);
1934 }
1935
1936 qPos.add(companyId);
1937
1938 count = (Long)q.uniqueResult();
1939
1940 FinderCacheUtil.putResult(finderPath, finderArgs, count);
1941 }
1942 catch (Exception e) {
1943 FinderCacheUtil.removeResult(finderPath, finderArgs);
1944
1945 throw processException(e);
1946 }
1947 finally {
1948 closeSession(session);
1949 }
1950 }
1951
1952 return count.intValue();
1953 }
1954
1955
1963 @Override
1964 public int filterCountByUuid_C(String uuid, long companyId)
1965 throws SystemException {
1966 if (!InlineSQLHelperUtil.isEnabled()) {
1967 return countByUuid_C(uuid, companyId);
1968 }
1969
1970 StringBundler query = new StringBundler(3);
1971
1972 query.append(_FILTER_SQL_COUNT_ORGANIZATION_WHERE);
1973
1974 boolean bindUuid = false;
1975
1976 if (uuid == null) {
1977 query.append(_FINDER_COLUMN_UUID_C_UUID_1_SQL);
1978 }
1979 else if (uuid.equals(StringPool.BLANK)) {
1980 query.append(_FINDER_COLUMN_UUID_C_UUID_3_SQL);
1981 }
1982 else {
1983 bindUuid = true;
1984
1985 query.append(_FINDER_COLUMN_UUID_C_UUID_2_SQL);
1986 }
1987
1988 query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1989
1990 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1991 Organization.class.getName(),
1992 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
1993
1994 Session session = null;
1995
1996 try {
1997 session = openSession();
1998
1999 SQLQuery q = session.createSQLQuery(sql);
2000
2001 q.addScalar(COUNT_COLUMN_NAME,
2002 com.liferay.portal.kernel.dao.orm.Type.LONG);
2003
2004 QueryPos qPos = QueryPos.getInstance(q);
2005
2006 if (bindUuid) {
2007 qPos.add(uuid);
2008 }
2009
2010 qPos.add(companyId);
2011
2012 Long count = (Long)q.uniqueResult();
2013
2014 return count.intValue();
2015 }
2016 catch (Exception e) {
2017 throw processException(e);
2018 }
2019 finally {
2020 closeSession(session);
2021 }
2022 }
2023
2024 private static final String _FINDER_COLUMN_UUID_C_UUID_1 = "organization.uuid IS NULL AND ";
2025 private static final String _FINDER_COLUMN_UUID_C_UUID_2 = "organization.uuid = ? AND ";
2026 private static final String _FINDER_COLUMN_UUID_C_UUID_3 = "(organization.uuid IS NULL OR organization.uuid = '') AND ";
2027 private static final String _FINDER_COLUMN_UUID_C_UUID_1_SQL = "organization.uuid_ IS NULL AND ";
2028 private static final String _FINDER_COLUMN_UUID_C_UUID_2_SQL = "organization.uuid_ = ? AND ";
2029 private static final String _FINDER_COLUMN_UUID_C_UUID_3_SQL = "(organization.uuid_ IS NULL OR organization.uuid_ = '') AND ";
2030 private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 = "organization.companyId = ?";
2031 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID =
2032 new FinderPath(OrganizationModelImpl.ENTITY_CACHE_ENABLED,
2033 OrganizationModelImpl.FINDER_CACHE_ENABLED, OrganizationImpl.class,
2034 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByCompanyId",
2035 new String[] {
2036 Long.class.getName(),
2037
2038 Integer.class.getName(), Integer.class.getName(),
2039 OrderByComparator.class.getName()
2040 });
2041 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID =
2042 new FinderPath(OrganizationModelImpl.ENTITY_CACHE_ENABLED,
2043 OrganizationModelImpl.FINDER_CACHE_ENABLED, OrganizationImpl.class,
2044 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCompanyId",
2045 new String[] { Long.class.getName() },
2046 OrganizationModelImpl.COMPANYID_COLUMN_BITMASK |
2047 OrganizationModelImpl.NAME_COLUMN_BITMASK);
2048 public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(OrganizationModelImpl.ENTITY_CACHE_ENABLED,
2049 OrganizationModelImpl.FINDER_CACHE_ENABLED, Long.class,
2050 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCompanyId",
2051 new String[] { Long.class.getName() });
2052
2053
2060 @Override
2061 public List<Organization> findByCompanyId(long companyId)
2062 throws SystemException {
2063 return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
2064 null);
2065 }
2066
2067
2080 @Override
2081 public List<Organization> findByCompanyId(long companyId, int start, int end)
2082 throws SystemException {
2083 return findByCompanyId(companyId, start, end, null);
2084 }
2085
2086
2100 @Override
2101 public List<Organization> findByCompanyId(long companyId, int start,
2102 int end, OrderByComparator orderByComparator) throws SystemException {
2103 boolean pagination = true;
2104 FinderPath finderPath = null;
2105 Object[] finderArgs = null;
2106
2107 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2108 (orderByComparator == null)) {
2109 pagination = false;
2110 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID;
2111 finderArgs = new Object[] { companyId };
2112 }
2113 else {
2114 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID;
2115 finderArgs = new Object[] { companyId, start, end, orderByComparator };
2116 }
2117
2118 List<Organization> list = (List<Organization>)FinderCacheUtil.getResult(finderPath,
2119 finderArgs, this);
2120
2121 if ((list != null) && !list.isEmpty()) {
2122 for (Organization organization : list) {
2123 if ((companyId != organization.getCompanyId())) {
2124 list = null;
2125
2126 break;
2127 }
2128 }
2129 }
2130
2131 if (list == null) {
2132 StringBundler query = null;
2133
2134 if (orderByComparator != null) {
2135 query = new StringBundler(3 +
2136 (orderByComparator.getOrderByFields().length * 3));
2137 }
2138 else {
2139 query = new StringBundler(3);
2140 }
2141
2142 query.append(_SQL_SELECT_ORGANIZATION_WHERE);
2143
2144 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2145
2146 if (orderByComparator != null) {
2147 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2148 orderByComparator);
2149 }
2150 else
2151 if (pagination) {
2152 query.append(OrganizationModelImpl.ORDER_BY_JPQL);
2153 }
2154
2155 String sql = query.toString();
2156
2157 Session session = null;
2158
2159 try {
2160 session = openSession();
2161
2162 Query q = session.createQuery(sql);
2163
2164 QueryPos qPos = QueryPos.getInstance(q);
2165
2166 qPos.add(companyId);
2167
2168 if (!pagination) {
2169 list = (List<Organization>)QueryUtil.list(q, getDialect(),
2170 start, end, false);
2171
2172 Collections.sort(list);
2173
2174 list = new UnmodifiableList<Organization>(list);
2175 }
2176 else {
2177 list = (List<Organization>)QueryUtil.list(q, getDialect(),
2178 start, end);
2179 }
2180
2181 cacheResult(list);
2182
2183 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2184 }
2185 catch (Exception e) {
2186 FinderCacheUtil.removeResult(finderPath, finderArgs);
2187
2188 throw processException(e);
2189 }
2190 finally {
2191 closeSession(session);
2192 }
2193 }
2194
2195 return list;
2196 }
2197
2198
2207 @Override
2208 public Organization findByCompanyId_First(long companyId,
2209 OrderByComparator orderByComparator)
2210 throws NoSuchOrganizationException, SystemException {
2211 Organization organization = fetchByCompanyId_First(companyId,
2212 orderByComparator);
2213
2214 if (organization != null) {
2215 return organization;
2216 }
2217
2218 StringBundler msg = new StringBundler(4);
2219
2220 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2221
2222 msg.append("companyId=");
2223 msg.append(companyId);
2224
2225 msg.append(StringPool.CLOSE_CURLY_BRACE);
2226
2227 throw new NoSuchOrganizationException(msg.toString());
2228 }
2229
2230
2238 @Override
2239 public Organization fetchByCompanyId_First(long companyId,
2240 OrderByComparator orderByComparator) throws SystemException {
2241 List<Organization> list = findByCompanyId(companyId, 0, 1,
2242 orderByComparator);
2243
2244 if (!list.isEmpty()) {
2245 return list.get(0);
2246 }
2247
2248 return null;
2249 }
2250
2251
2260 @Override
2261 public Organization findByCompanyId_Last(long companyId,
2262 OrderByComparator orderByComparator)
2263 throws NoSuchOrganizationException, SystemException {
2264 Organization organization = fetchByCompanyId_Last(companyId,
2265 orderByComparator);
2266
2267 if (organization != null) {
2268 return organization;
2269 }
2270
2271 StringBundler msg = new StringBundler(4);
2272
2273 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2274
2275 msg.append("companyId=");
2276 msg.append(companyId);
2277
2278 msg.append(StringPool.CLOSE_CURLY_BRACE);
2279
2280 throw new NoSuchOrganizationException(msg.toString());
2281 }
2282
2283
2291 @Override
2292 public Organization fetchByCompanyId_Last(long companyId,
2293 OrderByComparator orderByComparator) throws SystemException {
2294 int count = countByCompanyId(companyId);
2295
2296 if (count == 0) {
2297 return null;
2298 }
2299
2300 List<Organization> list = findByCompanyId(companyId, count - 1, count,
2301 orderByComparator);
2302
2303 if (!list.isEmpty()) {
2304 return list.get(0);
2305 }
2306
2307 return null;
2308 }
2309
2310
2320 @Override
2321 public Organization[] findByCompanyId_PrevAndNext(long organizationId,
2322 long companyId, OrderByComparator orderByComparator)
2323 throws NoSuchOrganizationException, SystemException {
2324 Organization organization = findByPrimaryKey(organizationId);
2325
2326 Session session = null;
2327
2328 try {
2329 session = openSession();
2330
2331 Organization[] array = new OrganizationImpl[3];
2332
2333 array[0] = getByCompanyId_PrevAndNext(session, organization,
2334 companyId, orderByComparator, true);
2335
2336 array[1] = organization;
2337
2338 array[2] = getByCompanyId_PrevAndNext(session, organization,
2339 companyId, orderByComparator, false);
2340
2341 return array;
2342 }
2343 catch (Exception e) {
2344 throw processException(e);
2345 }
2346 finally {
2347 closeSession(session);
2348 }
2349 }
2350
2351 protected Organization getByCompanyId_PrevAndNext(Session session,
2352 Organization organization, long companyId,
2353 OrderByComparator orderByComparator, boolean previous) {
2354 StringBundler query = null;
2355
2356 if (orderByComparator != null) {
2357 query = new StringBundler(6 +
2358 (orderByComparator.getOrderByFields().length * 6));
2359 }
2360 else {
2361 query = new StringBundler(3);
2362 }
2363
2364 query.append(_SQL_SELECT_ORGANIZATION_WHERE);
2365
2366 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2367
2368 if (orderByComparator != null) {
2369 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2370
2371 if (orderByConditionFields.length > 0) {
2372 query.append(WHERE_AND);
2373 }
2374
2375 for (int i = 0; i < orderByConditionFields.length; i++) {
2376 query.append(_ORDER_BY_ENTITY_ALIAS);
2377 query.append(orderByConditionFields[i]);
2378
2379 if ((i + 1) < orderByConditionFields.length) {
2380 if (orderByComparator.isAscending() ^ previous) {
2381 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2382 }
2383 else {
2384 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2385 }
2386 }
2387 else {
2388 if (orderByComparator.isAscending() ^ previous) {
2389 query.append(WHERE_GREATER_THAN);
2390 }
2391 else {
2392 query.append(WHERE_LESSER_THAN);
2393 }
2394 }
2395 }
2396
2397 query.append(ORDER_BY_CLAUSE);
2398
2399 String[] orderByFields = orderByComparator.getOrderByFields();
2400
2401 for (int i = 0; i < orderByFields.length; i++) {
2402 query.append(_ORDER_BY_ENTITY_ALIAS);
2403 query.append(orderByFields[i]);
2404
2405 if ((i + 1) < orderByFields.length) {
2406 if (orderByComparator.isAscending() ^ previous) {
2407 query.append(ORDER_BY_ASC_HAS_NEXT);
2408 }
2409 else {
2410 query.append(ORDER_BY_DESC_HAS_NEXT);
2411 }
2412 }
2413 else {
2414 if (orderByComparator.isAscending() ^ previous) {
2415 query.append(ORDER_BY_ASC);
2416 }
2417 else {
2418 query.append(ORDER_BY_DESC);
2419 }
2420 }
2421 }
2422 }
2423 else {
2424 query.append(OrganizationModelImpl.ORDER_BY_JPQL);
2425 }
2426
2427 String sql = query.toString();
2428
2429 Query q = session.createQuery(sql);
2430
2431 q.setFirstResult(0);
2432 q.setMaxResults(2);
2433
2434 QueryPos qPos = QueryPos.getInstance(q);
2435
2436 qPos.add(companyId);
2437
2438 if (orderByComparator != null) {
2439 Object[] values = orderByComparator.getOrderByConditionValues(organization);
2440
2441 for (Object value : values) {
2442 qPos.add(value);
2443 }
2444 }
2445
2446 List<Organization> list = q.list();
2447
2448 if (list.size() == 2) {
2449 return list.get(1);
2450 }
2451 else {
2452 return null;
2453 }
2454 }
2455
2456
2463 @Override
2464 public List<Organization> filterFindByCompanyId(long companyId)
2465 throws SystemException {
2466 return filterFindByCompanyId(companyId, QueryUtil.ALL_POS,
2467 QueryUtil.ALL_POS, null);
2468 }
2469
2470
2483 @Override
2484 public List<Organization> filterFindByCompanyId(long companyId, int start,
2485 int end) throws SystemException {
2486 return filterFindByCompanyId(companyId, start, end, null);
2487 }
2488
2489
2503 @Override
2504 public List<Organization> filterFindByCompanyId(long companyId, int start,
2505 int end, OrderByComparator orderByComparator) throws SystemException {
2506 if (!InlineSQLHelperUtil.isEnabled()) {
2507 return findByCompanyId(companyId, start, end, orderByComparator);
2508 }
2509
2510 StringBundler query = null;
2511
2512 if (orderByComparator != null) {
2513 query = new StringBundler(3 +
2514 (orderByComparator.getOrderByFields().length * 3));
2515 }
2516 else {
2517 query = new StringBundler(3);
2518 }
2519
2520 if (getDB().isSupportsInlineDistinct()) {
2521 query.append(_FILTER_SQL_SELECT_ORGANIZATION_WHERE);
2522 }
2523 else {
2524 query.append(_FILTER_SQL_SELECT_ORGANIZATION_NO_INLINE_DISTINCT_WHERE_1);
2525 }
2526
2527 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_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, true);
2537 }
2538 else {
2539 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
2540 orderByComparator, true);
2541 }
2542 }
2543 else {
2544 if (getDB().isSupportsInlineDistinct()) {
2545 query.append(OrganizationModelImpl.ORDER_BY_JPQL);
2546 }
2547 else {
2548 query.append(OrganizationModelImpl.ORDER_BY_SQL);
2549 }
2550 }
2551
2552 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2553 Organization.class.getName(),
2554 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
2555
2556 Session session = null;
2557
2558 try {
2559 session = openSession();
2560
2561 SQLQuery q = session.createSQLQuery(sql);
2562
2563 if (getDB().isSupportsInlineDistinct()) {
2564 q.addEntity(_FILTER_ENTITY_ALIAS, OrganizationImpl.class);
2565 }
2566 else {
2567 q.addEntity(_FILTER_ENTITY_TABLE, OrganizationImpl.class);
2568 }
2569
2570 QueryPos qPos = QueryPos.getInstance(q);
2571
2572 qPos.add(companyId);
2573
2574 return (List<Organization>)QueryUtil.list(q, getDialect(), start,
2575 end);
2576 }
2577 catch (Exception e) {
2578 throw processException(e);
2579 }
2580 finally {
2581 closeSession(session);
2582 }
2583 }
2584
2585
2595 @Override
2596 public Organization[] filterFindByCompanyId_PrevAndNext(
2597 long organizationId, long companyId, OrderByComparator orderByComparator)
2598 throws NoSuchOrganizationException, SystemException {
2599 if (!InlineSQLHelperUtil.isEnabled()) {
2600 return findByCompanyId_PrevAndNext(organizationId, companyId,
2601 orderByComparator);
2602 }
2603
2604 Organization organization = findByPrimaryKey(organizationId);
2605
2606 Session session = null;
2607
2608 try {
2609 session = openSession();
2610
2611 Organization[] array = new OrganizationImpl[3];
2612
2613 array[0] = filterGetByCompanyId_PrevAndNext(session, organization,
2614 companyId, orderByComparator, true);
2615
2616 array[1] = organization;
2617
2618 array[2] = filterGetByCompanyId_PrevAndNext(session, organization,
2619 companyId, orderByComparator, false);
2620
2621 return array;
2622 }
2623 catch (Exception e) {
2624 throw processException(e);
2625 }
2626 finally {
2627 closeSession(session);
2628 }
2629 }
2630
2631 protected Organization filterGetByCompanyId_PrevAndNext(Session session,
2632 Organization organization, long companyId,
2633 OrderByComparator orderByComparator, boolean previous) {
2634 StringBundler query = null;
2635
2636 if (orderByComparator != null) {
2637 query = new StringBundler(6 +
2638 (orderByComparator.getOrderByFields().length * 6));
2639 }
2640 else {
2641 query = new StringBundler(3);
2642 }
2643
2644 if (getDB().isSupportsInlineDistinct()) {
2645 query.append(_FILTER_SQL_SELECT_ORGANIZATION_WHERE);
2646 }
2647 else {
2648 query.append(_FILTER_SQL_SELECT_ORGANIZATION_NO_INLINE_DISTINCT_WHERE_1);
2649 }
2650
2651 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2652
2653 if (!getDB().isSupportsInlineDistinct()) {
2654 query.append(_FILTER_SQL_SELECT_ORGANIZATION_NO_INLINE_DISTINCT_WHERE_2);
2655 }
2656
2657 if (orderByComparator != null) {
2658 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2659
2660 if (orderByConditionFields.length > 0) {
2661 query.append(WHERE_AND);
2662 }
2663
2664 for (int i = 0; i < orderByConditionFields.length; i++) {
2665 if (getDB().isSupportsInlineDistinct()) {
2666 query.append(_ORDER_BY_ENTITY_ALIAS);
2667 }
2668 else {
2669 query.append(_ORDER_BY_ENTITY_TABLE);
2670 }
2671
2672 query.append(orderByConditionFields[i]);
2673
2674 if ((i + 1) < orderByConditionFields.length) {
2675 if (orderByComparator.isAscending() ^ previous) {
2676 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2677 }
2678 else {
2679 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2680 }
2681 }
2682 else {
2683 if (orderByComparator.isAscending() ^ previous) {
2684 query.append(WHERE_GREATER_THAN);
2685 }
2686 else {
2687 query.append(WHERE_LESSER_THAN);
2688 }
2689 }
2690 }
2691
2692 query.append(ORDER_BY_CLAUSE);
2693
2694 String[] orderByFields = orderByComparator.getOrderByFields();
2695
2696 for (int i = 0; i < orderByFields.length; i++) {
2697 if (getDB().isSupportsInlineDistinct()) {
2698 query.append(_ORDER_BY_ENTITY_ALIAS);
2699 }
2700 else {
2701 query.append(_ORDER_BY_ENTITY_TABLE);
2702 }
2703
2704 query.append(orderByFields[i]);
2705
2706 if ((i + 1) < orderByFields.length) {
2707 if (orderByComparator.isAscending() ^ previous) {
2708 query.append(ORDER_BY_ASC_HAS_NEXT);
2709 }
2710 else {
2711 query.append(ORDER_BY_DESC_HAS_NEXT);
2712 }
2713 }
2714 else {
2715 if (orderByComparator.isAscending() ^ previous) {
2716 query.append(ORDER_BY_ASC);
2717 }
2718 else {
2719 query.append(ORDER_BY_DESC);
2720 }
2721 }
2722 }
2723 }
2724 else {
2725 if (getDB().isSupportsInlineDistinct()) {
2726 query.append(OrganizationModelImpl.ORDER_BY_JPQL);
2727 }
2728 else {
2729 query.append(OrganizationModelImpl.ORDER_BY_SQL);
2730 }
2731 }
2732
2733 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2734 Organization.class.getName(),
2735 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
2736
2737 SQLQuery q = session.createSQLQuery(sql);
2738
2739 q.setFirstResult(0);
2740 q.setMaxResults(2);
2741
2742 if (getDB().isSupportsInlineDistinct()) {
2743 q.addEntity(_FILTER_ENTITY_ALIAS, OrganizationImpl.class);
2744 }
2745 else {
2746 q.addEntity(_FILTER_ENTITY_TABLE, OrganizationImpl.class);
2747 }
2748
2749 QueryPos qPos = QueryPos.getInstance(q);
2750
2751 qPos.add(companyId);
2752
2753 if (orderByComparator != null) {
2754 Object[] values = orderByComparator.getOrderByConditionValues(organization);
2755
2756 for (Object value : values) {
2757 qPos.add(value);
2758 }
2759 }
2760
2761 List<Organization> list = q.list();
2762
2763 if (list.size() == 2) {
2764 return list.get(1);
2765 }
2766 else {
2767 return null;
2768 }
2769 }
2770
2771
2777 @Override
2778 public void removeByCompanyId(long companyId) throws SystemException {
2779 for (Organization organization : findByCompanyId(companyId,
2780 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
2781 remove(organization);
2782 }
2783 }
2784
2785
2792 @Override
2793 public int countByCompanyId(long companyId) throws SystemException {
2794 FinderPath finderPath = FINDER_PATH_COUNT_BY_COMPANYID;
2795
2796 Object[] finderArgs = new Object[] { companyId };
2797
2798 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
2799 this);
2800
2801 if (count == null) {
2802 StringBundler query = new StringBundler(2);
2803
2804 query.append(_SQL_COUNT_ORGANIZATION_WHERE);
2805
2806 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2807
2808 String sql = query.toString();
2809
2810 Session session = null;
2811
2812 try {
2813 session = openSession();
2814
2815 Query q = session.createQuery(sql);
2816
2817 QueryPos qPos = QueryPos.getInstance(q);
2818
2819 qPos.add(companyId);
2820
2821 count = (Long)q.uniqueResult();
2822
2823 FinderCacheUtil.putResult(finderPath, finderArgs, count);
2824 }
2825 catch (Exception e) {
2826 FinderCacheUtil.removeResult(finderPath, finderArgs);
2827
2828 throw processException(e);
2829 }
2830 finally {
2831 closeSession(session);
2832 }
2833 }
2834
2835 return count.intValue();
2836 }
2837
2838
2845 @Override
2846 public int filterCountByCompanyId(long companyId) throws SystemException {
2847 if (!InlineSQLHelperUtil.isEnabled()) {
2848 return countByCompanyId(companyId);
2849 }
2850
2851 StringBundler query = new StringBundler(2);
2852
2853 query.append(_FILTER_SQL_COUNT_ORGANIZATION_WHERE);
2854
2855 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2856
2857 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2858 Organization.class.getName(),
2859 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
2860
2861 Session session = null;
2862
2863 try {
2864 session = openSession();
2865
2866 SQLQuery q = session.createSQLQuery(sql);
2867
2868 q.addScalar(COUNT_COLUMN_NAME,
2869 com.liferay.portal.kernel.dao.orm.Type.LONG);
2870
2871 QueryPos qPos = QueryPos.getInstance(q);
2872
2873 qPos.add(companyId);
2874
2875 Long count = (Long)q.uniqueResult();
2876
2877 return count.intValue();
2878 }
2879 catch (Exception e) {
2880 throw processException(e);
2881 }
2882 finally {
2883 closeSession(session);
2884 }
2885 }
2886
2887 private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "organization.companyId = ?";
2888 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_LOCATIONS =
2889 new FinderPath(OrganizationModelImpl.ENTITY_CACHE_ENABLED,
2890 OrganizationModelImpl.FINDER_CACHE_ENABLED, OrganizationImpl.class,
2891 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByLocations",
2892 new String[] {
2893 Long.class.getName(),
2894
2895 Integer.class.getName(), Integer.class.getName(),
2896 OrderByComparator.class.getName()
2897 });
2898 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LOCATIONS =
2899 new FinderPath(OrganizationModelImpl.ENTITY_CACHE_ENABLED,
2900 OrganizationModelImpl.FINDER_CACHE_ENABLED, OrganizationImpl.class,
2901 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByLocations",
2902 new String[] { Long.class.getName() },
2903 OrganizationModelImpl.COMPANYID_COLUMN_BITMASK |
2904 OrganizationModelImpl.NAME_COLUMN_BITMASK);
2905 public static final FinderPath FINDER_PATH_COUNT_BY_LOCATIONS = new FinderPath(OrganizationModelImpl.ENTITY_CACHE_ENABLED,
2906 OrganizationModelImpl.FINDER_CACHE_ENABLED, Long.class,
2907 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByLocations",
2908 new String[] { Long.class.getName() });
2909
2910
2917 @Override
2918 public List<Organization> findByLocations(long companyId)
2919 throws SystemException {
2920 return findByLocations(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
2921 null);
2922 }
2923
2924
2937 @Override
2938 public List<Organization> findByLocations(long companyId, int start, int end)
2939 throws SystemException {
2940 return findByLocations(companyId, start, end, null);
2941 }
2942
2943
2957 @Override
2958 public List<Organization> findByLocations(long companyId, int start,
2959 int end, OrderByComparator orderByComparator) throws SystemException {
2960 boolean pagination = true;
2961 FinderPath finderPath = null;
2962 Object[] finderArgs = null;
2963
2964 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2965 (orderByComparator == null)) {
2966 pagination = false;
2967 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LOCATIONS;
2968 finderArgs = new Object[] { companyId };
2969 }
2970 else {
2971 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_LOCATIONS;
2972 finderArgs = new Object[] { companyId, start, end, orderByComparator };
2973 }
2974
2975 List<Organization> list = (List<Organization>)FinderCacheUtil.getResult(finderPath,
2976 finderArgs, this);
2977
2978 if ((list != null) && !list.isEmpty()) {
2979 for (Organization organization : list) {
2980 if ((companyId != organization.getCompanyId())) {
2981 list = null;
2982
2983 break;
2984 }
2985 }
2986 }
2987
2988 if (list == null) {
2989 StringBundler query = null;
2990
2991 if (orderByComparator != null) {
2992 query = new StringBundler(3 +
2993 (orderByComparator.getOrderByFields().length * 3));
2994 }
2995 else {
2996 query = new StringBundler(3);
2997 }
2998
2999 query.append(_SQL_SELECT_ORGANIZATION_WHERE);
3000
3001 query.append(_FINDER_COLUMN_LOCATIONS_COMPANYID_2);
3002
3003 if (orderByComparator != null) {
3004 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3005 orderByComparator);
3006 }
3007 else
3008 if (pagination) {
3009 query.append(OrganizationModelImpl.ORDER_BY_JPQL);
3010 }
3011
3012 String sql = query.toString();
3013
3014 Session session = null;
3015
3016 try {
3017 session = openSession();
3018
3019 Query q = session.createQuery(sql);
3020
3021 QueryPos qPos = QueryPos.getInstance(q);
3022
3023 qPos.add(companyId);
3024
3025 if (!pagination) {
3026 list = (List<Organization>)QueryUtil.list(q, getDialect(),
3027 start, end, false);
3028
3029 Collections.sort(list);
3030
3031 list = new UnmodifiableList<Organization>(list);
3032 }
3033 else {
3034 list = (List<Organization>)QueryUtil.list(q, getDialect(),
3035 start, end);
3036 }
3037
3038 cacheResult(list);
3039
3040 FinderCacheUtil.putResult(finderPath, finderArgs, list);
3041 }
3042 catch (Exception e) {
3043 FinderCacheUtil.removeResult(finderPath, finderArgs);
3044
3045 throw processException(e);
3046 }
3047 finally {
3048 closeSession(session);
3049 }
3050 }
3051
3052 return list;
3053 }
3054
3055
3064 @Override
3065 public Organization findByLocations_First(long companyId,
3066 OrderByComparator orderByComparator)
3067 throws NoSuchOrganizationException, SystemException {
3068 Organization organization = fetchByLocations_First(companyId,
3069 orderByComparator);
3070
3071 if (organization != null) {
3072 return organization;
3073 }
3074
3075 StringBundler msg = new StringBundler(4);
3076
3077 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3078
3079 msg.append("companyId=");
3080 msg.append(companyId);
3081
3082 msg.append(StringPool.CLOSE_CURLY_BRACE);
3083
3084 throw new NoSuchOrganizationException(msg.toString());
3085 }
3086
3087
3095 @Override
3096 public Organization fetchByLocations_First(long companyId,
3097 OrderByComparator orderByComparator) throws SystemException {
3098 List<Organization> list = findByLocations(companyId, 0, 1,
3099 orderByComparator);
3100
3101 if (!list.isEmpty()) {
3102 return list.get(0);
3103 }
3104
3105 return null;
3106 }
3107
3108
3117 @Override
3118 public Organization findByLocations_Last(long companyId,
3119 OrderByComparator orderByComparator)
3120 throws NoSuchOrganizationException, SystemException {
3121 Organization organization = fetchByLocations_Last(companyId,
3122 orderByComparator);
3123
3124 if (organization != null) {
3125 return organization;
3126 }
3127
3128 StringBundler msg = new StringBundler(4);
3129
3130 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3131
3132 msg.append("companyId=");
3133 msg.append(companyId);
3134
3135 msg.append(StringPool.CLOSE_CURLY_BRACE);
3136
3137 throw new NoSuchOrganizationException(msg.toString());
3138 }
3139
3140
3148 @Override
3149 public Organization fetchByLocations_Last(long companyId,
3150 OrderByComparator orderByComparator) throws SystemException {
3151 int count = countByLocations(companyId);
3152
3153 if (count == 0) {
3154 return null;
3155 }
3156
3157 List<Organization> list = findByLocations(companyId, count - 1, count,
3158 orderByComparator);
3159
3160 if (!list.isEmpty()) {
3161 return list.get(0);
3162 }
3163
3164 return null;
3165 }
3166
3167
3177 @Override
3178 public Organization[] findByLocations_PrevAndNext(long organizationId,
3179 long companyId, OrderByComparator orderByComparator)
3180 throws NoSuchOrganizationException, SystemException {
3181 Organization organization = findByPrimaryKey(organizationId);
3182
3183 Session session = null;
3184
3185 try {
3186 session = openSession();
3187
3188 Organization[] array = new OrganizationImpl[3];
3189
3190 array[0] = getByLocations_PrevAndNext(session, organization,
3191 companyId, orderByComparator, true);
3192
3193 array[1] = organization;
3194
3195 array[2] = getByLocations_PrevAndNext(session, organization,
3196 companyId, orderByComparator, false);
3197
3198 return array;
3199 }
3200 catch (Exception e) {
3201 throw processException(e);
3202 }
3203 finally {
3204 closeSession(session);
3205 }
3206 }
3207
3208 protected Organization getByLocations_PrevAndNext(Session session,
3209 Organization organization, long companyId,
3210 OrderByComparator orderByComparator, boolean previous) {
3211 StringBundler query = null;
3212
3213 if (orderByComparator != null) {
3214 query = new StringBundler(6 +
3215 (orderByComparator.getOrderByFields().length * 6));
3216 }
3217 else {
3218 query = new StringBundler(3);
3219 }
3220
3221 query.append(_SQL_SELECT_ORGANIZATION_WHERE);
3222
3223 query.append(_FINDER_COLUMN_LOCATIONS_COMPANYID_2);
3224
3225 if (orderByComparator != null) {
3226 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3227
3228 if (orderByConditionFields.length > 0) {
3229 query.append(WHERE_AND);
3230 }
3231
3232 for (int i = 0; i < orderByConditionFields.length; i++) {
3233 query.append(_ORDER_BY_ENTITY_ALIAS);
3234 query.append(orderByConditionFields[i]);
3235
3236 if ((i + 1) < orderByConditionFields.length) {
3237 if (orderByComparator.isAscending() ^ previous) {
3238 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3239 }
3240 else {
3241 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3242 }
3243 }
3244 else {
3245 if (orderByComparator.isAscending() ^ previous) {
3246 query.append(WHERE_GREATER_THAN);
3247 }
3248 else {
3249 query.append(WHERE_LESSER_THAN);
3250 }
3251 }
3252 }
3253
3254 query.append(ORDER_BY_CLAUSE);
3255
3256 String[] orderByFields = orderByComparator.getOrderByFields();
3257
3258 for (int i = 0; i < orderByFields.length; i++) {
3259 query.append(_ORDER_BY_ENTITY_ALIAS);
3260 query.append(orderByFields[i]);
3261
3262 if ((i + 1) < orderByFields.length) {
3263 if (orderByComparator.isAscending() ^ previous) {
3264 query.append(ORDER_BY_ASC_HAS_NEXT);
3265 }
3266 else {
3267 query.append(ORDER_BY_DESC_HAS_NEXT);
3268 }
3269 }
3270 else {
3271 if (orderByComparator.isAscending() ^ previous) {
3272 query.append(ORDER_BY_ASC);
3273 }
3274 else {
3275 query.append(ORDER_BY_DESC);
3276 }
3277 }
3278 }
3279 }
3280 else {
3281 query.append(OrganizationModelImpl.ORDER_BY_JPQL);
3282 }
3283
3284 String sql = query.toString();
3285
3286 Query q = session.createQuery(sql);
3287
3288 q.setFirstResult(0);
3289 q.setMaxResults(2);
3290
3291 QueryPos qPos = QueryPos.getInstance(q);
3292
3293 qPos.add(companyId);
3294
3295 if (orderByComparator != null) {
3296 Object[] values = orderByComparator.getOrderByConditionValues(organization);
3297
3298 for (Object value : values) {
3299 qPos.add(value);
3300 }
3301 }
3302
3303 List<Organization> list = q.list();
3304
3305 if (list.size() == 2) {
3306 return list.get(1);
3307 }
3308 else {
3309 return null;
3310 }
3311 }
3312
3313
3320 @Override
3321 public List<Organization> filterFindByLocations(long companyId)
3322 throws SystemException {
3323 return filterFindByLocations(companyId, QueryUtil.ALL_POS,
3324 QueryUtil.ALL_POS, null);
3325 }
3326
3327
3340 @Override
3341 public List<Organization> filterFindByLocations(long companyId, int start,
3342 int end) throws SystemException {
3343 return filterFindByLocations(companyId, start, end, null);
3344 }
3345
3346
3360 @Override
3361 public List<Organization> filterFindByLocations(long companyId, int start,
3362 int end, OrderByComparator orderByComparator) throws SystemException {
3363 if (!InlineSQLHelperUtil.isEnabled()) {
3364 return findByLocations(companyId, start, end, orderByComparator);
3365 }
3366
3367 StringBundler query = null;
3368
3369 if (orderByComparator != null) {
3370 query = new StringBundler(3 +
3371 (orderByComparator.getOrderByFields().length * 3));
3372 }
3373 else {
3374 query = new StringBundler(3);
3375 }
3376
3377 if (getDB().isSupportsInlineDistinct()) {
3378 query.append(_FILTER_SQL_SELECT_ORGANIZATION_WHERE);
3379 }
3380 else {
3381 query.append(_FILTER_SQL_SELECT_ORGANIZATION_NO_INLINE_DISTINCT_WHERE_1);
3382 }
3383
3384 query.append(_FINDER_COLUMN_LOCATIONS_COMPANYID_2);
3385
3386 if (!getDB().isSupportsInlineDistinct()) {
3387 query.append(_FILTER_SQL_SELECT_ORGANIZATION_NO_INLINE_DISTINCT_WHERE_2);
3388 }
3389
3390 if (orderByComparator != null) {
3391 if (getDB().isSupportsInlineDistinct()) {
3392 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3393 orderByComparator, true);
3394 }
3395 else {
3396 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
3397 orderByComparator, true);
3398 }
3399 }
3400 else {
3401 if (getDB().isSupportsInlineDistinct()) {
3402 query.append(OrganizationModelImpl.ORDER_BY_JPQL);
3403 }
3404 else {
3405 query.append(OrganizationModelImpl.ORDER_BY_SQL);
3406 }
3407 }
3408
3409 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3410 Organization.class.getName(),
3411 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
3412
3413 Session session = null;
3414
3415 try {
3416 session = openSession();
3417
3418 SQLQuery q = session.createSQLQuery(sql);
3419
3420 if (getDB().isSupportsInlineDistinct()) {
3421 q.addEntity(_FILTER_ENTITY_ALIAS, OrganizationImpl.class);
3422 }
3423 else {
3424 q.addEntity(_FILTER_ENTITY_TABLE, OrganizationImpl.class);
3425 }
3426
3427 QueryPos qPos = QueryPos.getInstance(q);
3428
3429 qPos.add(companyId);
3430
3431 return (List<Organization>)QueryUtil.list(q, getDialect(), start,
3432 end);
3433 }
3434 catch (Exception e) {
3435 throw processException(e);
3436 }
3437 finally {
3438 closeSession(session);
3439 }
3440 }
3441
3442
3452 @Override
3453 public Organization[] filterFindByLocations_PrevAndNext(
3454 long organizationId, long companyId, OrderByComparator orderByComparator)
3455 throws NoSuchOrganizationException, SystemException {
3456 if (!InlineSQLHelperUtil.isEnabled()) {
3457 return findByLocations_PrevAndNext(organizationId, companyId,
3458 orderByComparator);
3459 }
3460
3461 Organization organization = findByPrimaryKey(organizationId);
3462
3463 Session session = null;
3464
3465 try {
3466 session = openSession();
3467
3468 Organization[] array = new OrganizationImpl[3];
3469
3470 array[0] = filterGetByLocations_PrevAndNext(session, organization,
3471 companyId, orderByComparator, true);
3472
3473 array[1] = organization;
3474
3475 array[2] = filterGetByLocations_PrevAndNext(session, organization,
3476 companyId, orderByComparator, false);
3477
3478 return array;
3479 }
3480 catch (Exception e) {
3481 throw processException(e);
3482 }
3483 finally {
3484 closeSession(session);
3485 }
3486 }
3487
3488 protected Organization filterGetByLocations_PrevAndNext(Session session,
3489 Organization organization, long companyId,
3490 OrderByComparator orderByComparator, boolean previous) {
3491 StringBundler query = null;
3492
3493 if (orderByComparator != null) {
3494 query = new StringBundler(6 +
3495 (orderByComparator.getOrderByFields().length * 6));
3496 }
3497 else {
3498 query = new StringBundler(3);
3499 }
3500
3501 if (getDB().isSupportsInlineDistinct()) {
3502 query.append(_FILTER_SQL_SELECT_ORGANIZATION_WHERE);
3503 }
3504 else {
3505 query.append(_FILTER_SQL_SELECT_ORGANIZATION_NO_INLINE_DISTINCT_WHERE_1);
3506 }
3507
3508 query.append(_FINDER_COLUMN_LOCATIONS_COMPANYID_2);
3509
3510 if (!getDB().isSupportsInlineDistinct()) {
3511 query.append(_FILTER_SQL_SELECT_ORGANIZATION_NO_INLINE_DISTINCT_WHERE_2);
3512 }
3513
3514 if (orderByComparator != null) {
3515 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3516
3517 if (orderByConditionFields.length > 0) {
3518 query.append(WHERE_AND);
3519 }
3520
3521 for (int i = 0; i < orderByConditionFields.length; i++) {
3522 if (getDB().isSupportsInlineDistinct()) {
3523 query.append(_ORDER_BY_ENTITY_ALIAS);
3524 }
3525 else {
3526 query.append(_ORDER_BY_ENTITY_TABLE);
3527 }
3528
3529 query.append(orderByConditionFields[i]);
3530
3531 if ((i + 1) < orderByConditionFields.length) {
3532 if (orderByComparator.isAscending() ^ previous) {
3533 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3534 }
3535 else {
3536 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3537 }
3538 }
3539 else {
3540 if (orderByComparator.isAscending() ^ previous) {
3541 query.append(WHERE_GREATER_THAN);
3542 }
3543 else {
3544 query.append(WHERE_LESSER_THAN);
3545 }
3546 }
3547 }
3548
3549 query.append(ORDER_BY_CLAUSE);
3550
3551 String[] orderByFields = orderByComparator.getOrderByFields();
3552
3553 for (int i = 0; i < orderByFields.length; i++) {
3554 if (getDB().isSupportsInlineDistinct()) {
3555 query.append(_ORDER_BY_ENTITY_ALIAS);
3556 }
3557 else {
3558 query.append(_ORDER_BY_ENTITY_TABLE);
3559 }
3560
3561 query.append(orderByFields[i]);
3562
3563 if ((i + 1) < orderByFields.length) {
3564 if (orderByComparator.isAscending() ^ previous) {
3565 query.append(ORDER_BY_ASC_HAS_NEXT);
3566 }
3567 else {
3568 query.append(ORDER_BY_DESC_HAS_NEXT);
3569 }
3570 }
3571 else {
3572 if (orderByComparator.isAscending() ^ previous) {
3573 query.append(ORDER_BY_ASC);
3574 }
3575 else {
3576 query.append(ORDER_BY_DESC);
3577 }
3578 }
3579 }
3580 }
3581 else {
3582 if (getDB().isSupportsInlineDistinct()) {
3583 query.append(OrganizationModelImpl.ORDER_BY_JPQL);
3584 }
3585 else {
3586 query.append(OrganizationModelImpl.ORDER_BY_SQL);
3587 }
3588 }
3589
3590 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3591 Organization.class.getName(),
3592 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
3593
3594 SQLQuery q = session.createSQLQuery(sql);
3595
3596 q.setFirstResult(0);
3597 q.setMaxResults(2);
3598
3599 if (getDB().isSupportsInlineDistinct()) {
3600 q.addEntity(_FILTER_ENTITY_ALIAS, OrganizationImpl.class);
3601 }
3602 else {
3603 q.addEntity(_FILTER_ENTITY_TABLE, OrganizationImpl.class);
3604 }
3605
3606 QueryPos qPos = QueryPos.getInstance(q);
3607
3608 qPos.add(companyId);
3609
3610 if (orderByComparator != null) {
3611 Object[] values = orderByComparator.getOrderByConditionValues(organization);
3612
3613 for (Object value : values) {
3614 qPos.add(value);
3615 }
3616 }
3617
3618 List<Organization> list = q.list();
3619
3620 if (list.size() == 2) {
3621 return list.get(1);
3622 }
3623 else {
3624 return null;
3625 }
3626 }
3627
3628
3634 @Override
3635 public void removeByLocations(long companyId) throws SystemException {
3636 for (Organization organization : findByLocations(companyId,
3637 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
3638 remove(organization);
3639 }
3640 }
3641
3642
3649 @Override
3650 public int countByLocations(long companyId) throws SystemException {
3651 FinderPath finderPath = FINDER_PATH_COUNT_BY_LOCATIONS;
3652
3653 Object[] finderArgs = new Object[] { companyId };
3654
3655 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
3656 this);
3657
3658 if (count == null) {
3659 StringBundler query = new StringBundler(2);
3660
3661 query.append(_SQL_COUNT_ORGANIZATION_WHERE);
3662
3663 query.append(_FINDER_COLUMN_LOCATIONS_COMPANYID_2);
3664
3665 String sql = query.toString();
3666
3667 Session session = null;
3668
3669 try {
3670 session = openSession();
3671
3672 Query q = session.createQuery(sql);
3673
3674 QueryPos qPos = QueryPos.getInstance(q);
3675
3676 qPos.add(companyId);
3677
3678 count = (Long)q.uniqueResult();
3679
3680 FinderCacheUtil.putResult(finderPath, finderArgs, count);
3681 }
3682 catch (Exception e) {
3683 FinderCacheUtil.removeResult(finderPath, finderArgs);
3684
3685 throw processException(e);
3686 }
3687 finally {
3688 closeSession(session);
3689 }
3690 }
3691
3692 return count.intValue();
3693 }
3694
3695
3702 @Override
3703 public int filterCountByLocations(long companyId) throws SystemException {
3704 if (!InlineSQLHelperUtil.isEnabled()) {
3705 return countByLocations(companyId);
3706 }
3707
3708 StringBundler query = new StringBundler(2);
3709
3710 query.append(_FILTER_SQL_COUNT_ORGANIZATION_WHERE);
3711
3712 query.append(_FINDER_COLUMN_LOCATIONS_COMPANYID_2);
3713
3714 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3715 Organization.class.getName(),
3716 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
3717
3718 Session session = null;
3719
3720 try {
3721 session = openSession();
3722
3723 SQLQuery q = session.createSQLQuery(sql);
3724
3725 q.addScalar(COUNT_COLUMN_NAME,
3726 com.liferay.portal.kernel.dao.orm.Type.LONG);
3727
3728 QueryPos qPos = QueryPos.getInstance(q);
3729
3730 qPos.add(companyId);
3731
3732 Long count = (Long)q.uniqueResult();
3733
3734 return count.intValue();
3735 }
3736 catch (Exception e) {
3737 throw processException(e);
3738 }
3739 finally {
3740 closeSession(session);
3741 }
3742 }
3743
3744 private static final String _FINDER_COLUMN_LOCATIONS_COMPANYID_2 = "organization.companyId = ? AND organization.parentOrganizationId != 0";
3745 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_P = new FinderPath(OrganizationModelImpl.ENTITY_CACHE_ENABLED,
3746 OrganizationModelImpl.FINDER_CACHE_ENABLED, OrganizationImpl.class,
3747 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_P",
3748 new String[] {
3749 Long.class.getName(), Long.class.getName(),
3750
3751 Integer.class.getName(), Integer.class.getName(),
3752 OrderByComparator.class.getName()
3753 });
3754 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_P = new FinderPath(OrganizationModelImpl.ENTITY_CACHE_ENABLED,
3755 OrganizationModelImpl.FINDER_CACHE_ENABLED, OrganizationImpl.class,
3756 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_P",
3757 new String[] { Long.class.getName(), Long.class.getName() },
3758 OrganizationModelImpl.COMPANYID_COLUMN_BITMASK |
3759 OrganizationModelImpl.PARENTORGANIZATIONID_COLUMN_BITMASK |
3760 OrganizationModelImpl.NAME_COLUMN_BITMASK);
3761 public static final FinderPath FINDER_PATH_COUNT_BY_C_P = new FinderPath(OrganizationModelImpl.ENTITY_CACHE_ENABLED,
3762 OrganizationModelImpl.FINDER_CACHE_ENABLED, Long.class,
3763 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_P",
3764 new String[] { Long.class.getName(), Long.class.getName() });
3765
3766
3774 @Override
3775 public List<Organization> findByC_P(long companyId,
3776 long parentOrganizationId) throws SystemException {
3777 return findByC_P(companyId, parentOrganizationId, QueryUtil.ALL_POS,
3778 QueryUtil.ALL_POS, null);
3779 }
3780
3781
3795 @Override
3796 public List<Organization> findByC_P(long companyId,
3797 long parentOrganizationId, int start, int end)
3798 throws SystemException {
3799 return findByC_P(companyId, parentOrganizationId, start, end, null);
3800 }
3801
3802
3817 @Override
3818 public List<Organization> findByC_P(long companyId,
3819 long parentOrganizationId, int start, int end,
3820 OrderByComparator orderByComparator) throws SystemException {
3821 boolean pagination = true;
3822 FinderPath finderPath = null;
3823 Object[] finderArgs = null;
3824
3825 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3826 (orderByComparator == null)) {
3827 pagination = false;
3828 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_P;
3829 finderArgs = new Object[] { companyId, parentOrganizationId };
3830 }
3831 else {
3832 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_P;
3833 finderArgs = new Object[] {
3834 companyId, parentOrganizationId,
3835
3836 start, end, orderByComparator
3837 };
3838 }
3839
3840 List<Organization> list = (List<Organization>)FinderCacheUtil.getResult(finderPath,
3841 finderArgs, this);
3842
3843 if ((list != null) && !list.isEmpty()) {
3844 for (Organization organization : list) {
3845 if ((companyId != organization.getCompanyId()) ||
3846 (parentOrganizationId != organization.getParentOrganizationId())) {
3847 list = null;
3848
3849 break;
3850 }
3851 }
3852 }
3853
3854 if (list == null) {
3855 StringBundler query = null;
3856
3857 if (orderByComparator != null) {
3858 query = new StringBundler(4 +
3859 (orderByComparator.getOrderByFields().length * 3));
3860 }
3861 else {
3862 query = new StringBundler(4);
3863 }
3864
3865 query.append(_SQL_SELECT_ORGANIZATION_WHERE);
3866
3867 query.append(_FINDER_COLUMN_C_P_COMPANYID_2);
3868
3869 query.append(_FINDER_COLUMN_C_P_PARENTORGANIZATIONID_2);
3870
3871 if (orderByComparator != null) {
3872 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3873 orderByComparator);
3874 }
3875 else
3876 if (pagination) {
3877 query.append(OrganizationModelImpl.ORDER_BY_JPQL);
3878 }
3879
3880 String sql = query.toString();
3881
3882 Session session = null;
3883
3884 try {
3885 session = openSession();
3886
3887 Query q = session.createQuery(sql);
3888
3889 QueryPos qPos = QueryPos.getInstance(q);
3890
3891 qPos.add(companyId);
3892
3893 qPos.add(parentOrganizationId);
3894
3895 if (!pagination) {
3896 list = (List<Organization>)QueryUtil.list(q, getDialect(),
3897 start, end, false);
3898
3899 Collections.sort(list);
3900
3901 list = new UnmodifiableList<Organization>(list);
3902 }
3903 else {
3904 list = (List<Organization>)QueryUtil.list(q, getDialect(),
3905 start, end);
3906 }
3907
3908 cacheResult(list);
3909
3910 FinderCacheUtil.putResult(finderPath, finderArgs, list);
3911 }
3912 catch (Exception e) {
3913 FinderCacheUtil.removeResult(finderPath, finderArgs);
3914
3915 throw processException(e);
3916 }
3917 finally {
3918 closeSession(session);
3919 }
3920 }
3921
3922 return list;
3923 }
3924
3925
3935 @Override
3936 public Organization findByC_P_First(long companyId,
3937 long parentOrganizationId, OrderByComparator orderByComparator)
3938 throws NoSuchOrganizationException, SystemException {
3939 Organization organization = fetchByC_P_First(companyId,
3940 parentOrganizationId, orderByComparator);
3941
3942 if (organization != null) {
3943 return organization;
3944 }
3945
3946 StringBundler msg = new StringBundler(6);
3947
3948 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3949
3950 msg.append("companyId=");
3951 msg.append(companyId);
3952
3953 msg.append(", parentOrganizationId=");
3954 msg.append(parentOrganizationId);
3955
3956 msg.append(StringPool.CLOSE_CURLY_BRACE);
3957
3958 throw new NoSuchOrganizationException(msg.toString());
3959 }
3960
3961
3970 @Override
3971 public Organization fetchByC_P_First(long companyId,
3972 long parentOrganizationId, OrderByComparator orderByComparator)
3973 throws SystemException {
3974 List<Organization> list = findByC_P(companyId, parentOrganizationId, 0,
3975 1, orderByComparator);
3976
3977 if (!list.isEmpty()) {
3978 return list.get(0);
3979 }
3980
3981 return null;
3982 }
3983
3984
3994 @Override
3995 public Organization findByC_P_Last(long companyId,
3996 long parentOrganizationId, OrderByComparator orderByComparator)
3997 throws NoSuchOrganizationException, SystemException {
3998 Organization organization = fetchByC_P_Last(companyId,
3999 parentOrganizationId, orderByComparator);
4000
4001 if (organization != null) {
4002 return organization;
4003 }
4004
4005 StringBundler msg = new StringBundler(6);
4006
4007 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4008
4009 msg.append("companyId=");
4010 msg.append(companyId);
4011
4012 msg.append(", parentOrganizationId=");
4013 msg.append(parentOrganizationId);
4014
4015 msg.append(StringPool.CLOSE_CURLY_BRACE);
4016
4017 throw new NoSuchOrganizationException(msg.toString());
4018 }
4019
4020
4029 @Override
4030 public Organization fetchByC_P_Last(long companyId,
4031 long parentOrganizationId, OrderByComparator orderByComparator)
4032 throws SystemException {
4033 int count = countByC_P(companyId, parentOrganizationId);
4034
4035 if (count == 0) {
4036 return null;
4037 }
4038
4039 List<Organization> list = findByC_P(companyId, parentOrganizationId,
4040 count - 1, count, orderByComparator);
4041
4042 if (!list.isEmpty()) {
4043 return list.get(0);
4044 }
4045
4046 return null;
4047 }
4048
4049
4060 @Override
4061 public Organization[] findByC_P_PrevAndNext(long organizationId,
4062 long companyId, long parentOrganizationId,
4063 OrderByComparator orderByComparator)
4064 throws NoSuchOrganizationException, SystemException {
4065 Organization organization = findByPrimaryKey(organizationId);
4066
4067 Session session = null;
4068
4069 try {
4070 session = openSession();
4071
4072 Organization[] array = new OrganizationImpl[3];
4073
4074 array[0] = getByC_P_PrevAndNext(session, organization, companyId,
4075 parentOrganizationId, orderByComparator, true);
4076
4077 array[1] = organization;
4078
4079 array[2] = getByC_P_PrevAndNext(session, organization, companyId,
4080 parentOrganizationId, orderByComparator, false);
4081
4082 return array;
4083 }
4084 catch (Exception e) {
4085 throw processException(e);
4086 }
4087 finally {
4088 closeSession(session);
4089 }
4090 }
4091
4092 protected Organization getByC_P_PrevAndNext(Session session,
4093 Organization organization, long companyId, long parentOrganizationId,
4094 OrderByComparator orderByComparator, boolean previous) {
4095 StringBundler query = null;
4096
4097 if (orderByComparator != null) {
4098 query = new StringBundler(6 +
4099 (orderByComparator.getOrderByFields().length * 6));
4100 }
4101 else {
4102 query = new StringBundler(3);
4103 }
4104
4105 query.append(_SQL_SELECT_ORGANIZATION_WHERE);
4106
4107 query.append(_FINDER_COLUMN_C_P_COMPANYID_2);
4108
4109 query.append(_FINDER_COLUMN_C_P_PARENTORGANIZATIONID_2);
4110
4111 if (orderByComparator != null) {
4112 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4113
4114 if (orderByConditionFields.length > 0) {
4115 query.append(WHERE_AND);
4116 }
4117
4118 for (int i = 0; i < orderByConditionFields.length; i++) {
4119 query.append(_ORDER_BY_ENTITY_ALIAS);
4120 query.append(orderByConditionFields[i]);
4121
4122 if ((i + 1) < orderByConditionFields.length) {
4123 if (orderByComparator.isAscending() ^ previous) {
4124 query.append(WHERE_GREATER_THAN_HAS_NEXT);
4125 }
4126 else {
4127 query.append(WHERE_LESSER_THAN_HAS_NEXT);
4128 }
4129 }
4130 else {
4131 if (orderByComparator.isAscending() ^ previous) {
4132 query.append(WHERE_GREATER_THAN);
4133 }
4134 else {
4135 query.append(WHERE_LESSER_THAN);
4136 }
4137 }
4138 }
4139
4140 query.append(ORDER_BY_CLAUSE);
4141
4142 String[] orderByFields = orderByComparator.getOrderByFields();
4143
4144 for (int i = 0; i < orderByFields.length; i++) {
4145 query.append(_ORDER_BY_ENTITY_ALIAS);
4146 query.append(orderByFields[i]);
4147
4148 if ((i + 1) < orderByFields.length) {
4149 if (orderByComparator.isAscending() ^ previous) {
4150 query.append(ORDER_BY_ASC_HAS_NEXT);
4151 }
4152 else {
4153 query.append(ORDER_BY_DESC_HAS_NEXT);
4154 }
4155 }
4156 else {
4157 if (orderByComparator.isAscending() ^ previous) {
4158 query.append(ORDER_BY_ASC);
4159 }
4160 else {
4161 query.append(ORDER_BY_DESC);
4162 }
4163 }
4164 }
4165 }
4166 else {
4167 query.append(OrganizationModelImpl.ORDER_BY_JPQL);
4168 }
4169
4170 String sql = query.toString();
4171
4172 Query q = session.createQuery(sql);
4173
4174 q.setFirstResult(0);
4175 q.setMaxResults(2);
4176
4177 QueryPos qPos = QueryPos.getInstance(q);
4178
4179 qPos.add(companyId);
4180
4181 qPos.add(parentOrganizationId);
4182
4183 if (orderByComparator != null) {
4184 Object[] values = orderByComparator.getOrderByConditionValues(organization);
4185
4186 for (Object value : values) {
4187 qPos.add(value);
4188 }
4189 }
4190
4191 List<Organization> list = q.list();
4192
4193 if (list.size() == 2) {
4194 return list.get(1);
4195 }
4196 else {
4197 return null;
4198 }
4199 }
4200
4201
4209 @Override
4210 public List<Organization> filterFindByC_P(long companyId,
4211 long parentOrganizationId) throws SystemException {
4212 return filterFindByC_P(companyId, parentOrganizationId,
4213 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
4214 }
4215
4216
4230 @Override
4231 public List<Organization> filterFindByC_P(long companyId,
4232 long parentOrganizationId, int start, int end)
4233 throws SystemException {
4234 return filterFindByC_P(companyId, parentOrganizationId, start, end, null);
4235 }
4236
4237
4252 @Override
4253 public List<Organization> filterFindByC_P(long companyId,
4254 long parentOrganizationId, int start, int end,
4255 OrderByComparator orderByComparator) throws SystemException {
4256 if (!InlineSQLHelperUtil.isEnabled()) {
4257 return findByC_P(companyId, parentOrganizationId, start, end,
4258 orderByComparator);
4259 }
4260
4261 StringBundler query = null;
4262
4263 if (orderByComparator != null) {
4264 query = new StringBundler(4 +
4265 (orderByComparator.getOrderByFields().length * 3));
4266 }
4267 else {
4268 query = new StringBundler(4);
4269 }
4270
4271 if (getDB().isSupportsInlineDistinct()) {
4272 query.append(_FILTER_SQL_SELECT_ORGANIZATION_WHERE);
4273 }
4274 else {
4275 query.append(_FILTER_SQL_SELECT_ORGANIZATION_NO_INLINE_DISTINCT_WHERE_1);
4276 }
4277
4278 query.append(_FINDER_COLUMN_C_P_COMPANYID_2);
4279
4280 query.append(_FINDER_COLUMN_C_P_PARENTORGANIZATIONID_2);
4281
4282 if (!getDB().isSupportsInlineDistinct()) {
4283 query.append(_FILTER_SQL_SELECT_ORGANIZATION_NO_INLINE_DISTINCT_WHERE_2);
4284 }
4285
4286 if (orderByComparator != null) {
4287 if (getDB().isSupportsInlineDistinct()) {
4288 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4289 orderByComparator, true);
4290 }
4291 else {
4292 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
4293 orderByComparator, true);
4294 }
4295 }
4296 else {
4297 if (getDB().isSupportsInlineDistinct()) {
4298 query.append(OrganizationModelImpl.ORDER_BY_JPQL);
4299 }
4300 else {
4301 query.append(OrganizationModelImpl.ORDER_BY_SQL);
4302 }
4303 }
4304
4305 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4306 Organization.class.getName(),
4307 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
4308
4309 Session session = null;
4310
4311 try {
4312 session = openSession();
4313
4314 SQLQuery q = session.createSQLQuery(sql);
4315
4316 if (getDB().isSupportsInlineDistinct()) {
4317 q.addEntity(_FILTER_ENTITY_ALIAS, OrganizationImpl.class);
4318 }
4319 else {
4320 q.addEntity(_FILTER_ENTITY_TABLE, OrganizationImpl.class);
4321 }
4322
4323 QueryPos qPos = QueryPos.getInstance(q);
4324
4325 qPos.add(companyId);
4326
4327 qPos.add(parentOrganizationId);
4328
4329 return (List<Organization>)QueryUtil.list(q, getDialect(), start,
4330 end);
4331 }
4332 catch (Exception e) {
4333 throw processException(e);
4334 }
4335 finally {
4336 closeSession(session);
4337 }
4338 }
4339
4340
4351 @Override
4352 public Organization[] filterFindByC_P_PrevAndNext(long organizationId,
4353 long companyId, long parentOrganizationId,
4354 OrderByComparator orderByComparator)
4355 throws NoSuchOrganizationException, SystemException {
4356 if (!InlineSQLHelperUtil.isEnabled()) {
4357 return findByC_P_PrevAndNext(organizationId, companyId,
4358 parentOrganizationId, orderByComparator);
4359 }
4360
4361 Organization organization = findByPrimaryKey(organizationId);
4362
4363 Session session = null;
4364
4365 try {
4366 session = openSession();
4367
4368 Organization[] array = new OrganizationImpl[3];
4369
4370 array[0] = filterGetByC_P_PrevAndNext(session, organization,
4371 companyId, parentOrganizationId, orderByComparator, true);
4372
4373 array[1] = organization;
4374
4375 array[2] = filterGetByC_P_PrevAndNext(session, organization,
4376 companyId, parentOrganizationId, orderByComparator, false);
4377
4378 return array;
4379 }
4380 catch (Exception e) {
4381 throw processException(e);
4382 }
4383 finally {
4384 closeSession(session);
4385 }
4386 }
4387
4388 protected Organization filterGetByC_P_PrevAndNext(Session session,
4389 Organization organization, long companyId, long parentOrganizationId,
4390 OrderByComparator orderByComparator, boolean previous) {
4391 StringBundler query = null;
4392
4393 if (orderByComparator != null) {
4394 query = new StringBundler(6 +
4395 (orderByComparator.getOrderByFields().length * 6));
4396 }
4397 else {
4398 query = new StringBundler(3);
4399 }
4400
4401 if (getDB().isSupportsInlineDistinct()) {
4402 query.append(_FILTER_SQL_SELECT_ORGANIZATION_WHERE);
4403 }
4404 else {
4405 query.append(_FILTER_SQL_SELECT_ORGANIZATION_NO_INLINE_DISTINCT_WHERE_1);
4406 }
4407
4408 query.append(_FINDER_COLUMN_C_P_COMPANYID_2);
4409
4410 query.append(_FINDER_COLUMN_C_P_PARENTORGANIZATIONID_2);
4411
4412 if (!getDB().isSupportsInlineDistinct()) {
4413 query.append(_FILTER_SQL_SELECT_ORGANIZATION_NO_INLINE_DISTINCT_WHERE_2);
4414 }
4415
4416 if (orderByComparator != null) {
4417 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4418
4419 if (orderByConditionFields.length > 0) {
4420 query.append(WHERE_AND);
4421 }
4422
4423 for (int i = 0; i < orderByConditionFields.length; i++) {
4424 if (getDB().isSupportsInlineDistinct()) {
4425 query.append(_ORDER_BY_ENTITY_ALIAS);
4426 }
4427 else {
4428 query.append(_ORDER_BY_ENTITY_TABLE);
4429 }
4430
4431 query.append(orderByConditionFields[i]);
4432
4433 if ((i + 1) < orderByConditionFields.length) {
4434 if (orderByComparator.isAscending() ^ previous) {
4435 query.append(WHERE_GREATER_THAN_HAS_NEXT);
4436 }
4437 else {
4438 query.append(WHERE_LESSER_THAN_HAS_NEXT);
4439 }
4440 }
4441 else {
4442 if (orderByComparator.isAscending() ^ previous) {
4443 query.append(WHERE_GREATER_THAN);
4444 }
4445 else {
4446 query.append(WHERE_LESSER_THAN);
4447 }
4448 }
4449 }
4450
4451 query.append(ORDER_BY_CLAUSE);
4452
4453 String[] orderByFields = orderByComparator.getOrderByFields();
4454
4455 for (int i = 0; i < orderByFields.length; i++) {
4456 if (getDB().isSupportsInlineDistinct()) {
4457 query.append(_ORDER_BY_ENTITY_ALIAS);
4458 }
4459 else {
4460 query.append(_ORDER_BY_ENTITY_TABLE);
4461 }
4462
4463 query.append(orderByFields[i]);
4464
4465 if ((i + 1) < orderByFields.length) {
4466 if (orderByComparator.isAscending() ^ previous) {
4467 query.append(ORDER_BY_ASC_HAS_NEXT);
4468 }
4469 else {
4470 query.append(ORDER_BY_DESC_HAS_NEXT);
4471 }
4472 }
4473 else {
4474 if (orderByComparator.isAscending() ^ previous) {
4475 query.append(ORDER_BY_ASC);
4476 }
4477 else {
4478 query.append(ORDER_BY_DESC);
4479 }
4480 }
4481 }
4482 }
4483 else {
4484 if (getDB().isSupportsInlineDistinct()) {
4485 query.append(OrganizationModelImpl.ORDER_BY_JPQL);
4486 }
4487 else {
4488 query.append(OrganizationModelImpl.ORDER_BY_SQL);
4489 }
4490 }
4491
4492 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4493 Organization.class.getName(),
4494 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
4495
4496 SQLQuery q = session.createSQLQuery(sql);
4497
4498 q.setFirstResult(0);
4499 q.setMaxResults(2);
4500
4501 if (getDB().isSupportsInlineDistinct()) {
4502 q.addEntity(_FILTER_ENTITY_ALIAS, OrganizationImpl.class);
4503 }
4504 else {
4505 q.addEntity(_FILTER_ENTITY_TABLE, OrganizationImpl.class);
4506 }
4507
4508 QueryPos qPos = QueryPos.getInstance(q);
4509
4510 qPos.add(companyId);
4511
4512 qPos.add(parentOrganizationId);
4513
4514 if (orderByComparator != null) {
4515 Object[] values = orderByComparator.getOrderByConditionValues(organization);
4516
4517 for (Object value : values) {
4518 qPos.add(value);
4519 }
4520 }
4521
4522 List<Organization> list = q.list();
4523
4524 if (list.size() == 2) {
4525 return list.get(1);
4526 }
4527 else {
4528 return null;
4529 }
4530 }
4531
4532
4539 @Override
4540 public void removeByC_P(long companyId, long parentOrganizationId)
4541 throws SystemException {
4542 for (Organization organization : findByC_P(companyId,
4543 parentOrganizationId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
4544 remove(organization);
4545 }
4546 }
4547
4548
4556 @Override
4557 public int countByC_P(long companyId, long parentOrganizationId)
4558 throws SystemException {
4559 FinderPath finderPath = FINDER_PATH_COUNT_BY_C_P;
4560
4561 Object[] finderArgs = new Object[] { companyId, parentOrganizationId };
4562
4563 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
4564 this);
4565
4566 if (count == null) {
4567 StringBundler query = new StringBundler(3);
4568
4569 query.append(_SQL_COUNT_ORGANIZATION_WHERE);
4570
4571 query.append(_FINDER_COLUMN_C_P_COMPANYID_2);
4572
4573 query.append(_FINDER_COLUMN_C_P_PARENTORGANIZATIONID_2);
4574
4575 String sql = query.toString();
4576
4577 Session session = null;
4578
4579 try {
4580 session = openSession();
4581
4582 Query q = session.createQuery(sql);
4583
4584 QueryPos qPos = QueryPos.getInstance(q);
4585
4586 qPos.add(companyId);
4587
4588 qPos.add(parentOrganizationId);
4589
4590 count = (Long)q.uniqueResult();
4591
4592 FinderCacheUtil.putResult(finderPath, finderArgs, count);
4593 }
4594 catch (Exception e) {
4595 FinderCacheUtil.removeResult(finderPath, finderArgs);
4596
4597 throw processException(e);
4598 }
4599 finally {
4600 closeSession(session);
4601 }
4602 }
4603
4604 return count.intValue();
4605 }
4606
4607
4615 @Override
4616 public int filterCountByC_P(long companyId, long parentOrganizationId)
4617 throws SystemException {
4618 if (!InlineSQLHelperUtil.isEnabled()) {
4619 return countByC_P(companyId, parentOrganizationId);
4620 }
4621
4622 StringBundler query = new StringBundler(3);
4623
4624 query.append(_FILTER_SQL_COUNT_ORGANIZATION_WHERE);
4625
4626 query.append(_FINDER_COLUMN_C_P_COMPANYID_2);
4627
4628 query.append(_FINDER_COLUMN_C_P_PARENTORGANIZATIONID_2);
4629
4630 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4631 Organization.class.getName(),
4632 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
4633
4634 Session session = null;
4635
4636 try {
4637 session = openSession();
4638
4639 SQLQuery q = session.createSQLQuery(sql);
4640
4641 q.addScalar(COUNT_COLUMN_NAME,
4642 com.liferay.portal.kernel.dao.orm.Type.LONG);
4643
4644 QueryPos qPos = QueryPos.getInstance(q);
4645
4646 qPos.add(companyId);
4647
4648 qPos.add(parentOrganizationId);
4649
4650 Long count = (Long)q.uniqueResult();
4651
4652 return count.intValue();
4653 }
4654 catch (Exception e) {
4655 throw processException(e);
4656 }
4657 finally {
4658 closeSession(session);
4659 }
4660 }
4661
4662 private static final String _FINDER_COLUMN_C_P_COMPANYID_2 = "organization.companyId = ? AND ";
4663 private static final String _FINDER_COLUMN_C_P_PARENTORGANIZATIONID_2 = "organization.parentOrganizationId = ?";
4664 public static final FinderPath FINDER_PATH_FETCH_BY_C_N = new FinderPath(OrganizationModelImpl.ENTITY_CACHE_ENABLED,
4665 OrganizationModelImpl.FINDER_CACHE_ENABLED, OrganizationImpl.class,
4666 FINDER_CLASS_NAME_ENTITY, "fetchByC_N",
4667 new String[] { Long.class.getName(), String.class.getName() },
4668 OrganizationModelImpl.COMPANYID_COLUMN_BITMASK |
4669 OrganizationModelImpl.NAME_COLUMN_BITMASK);
4670 public static final FinderPath FINDER_PATH_COUNT_BY_C_N = new FinderPath(OrganizationModelImpl.ENTITY_CACHE_ENABLED,
4671 OrganizationModelImpl.FINDER_CACHE_ENABLED, Long.class,
4672 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_N",
4673 new String[] { Long.class.getName(), String.class.getName() });
4674
4675
4684 @Override
4685 public Organization findByC_N(long companyId, String name)
4686 throws NoSuchOrganizationException, SystemException {
4687 Organization organization = fetchByC_N(companyId, name);
4688
4689 if (organization == null) {
4690 StringBundler msg = new StringBundler(6);
4691
4692 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4693
4694 msg.append("companyId=");
4695 msg.append(companyId);
4696
4697 msg.append(", name=");
4698 msg.append(name);
4699
4700 msg.append(StringPool.CLOSE_CURLY_BRACE);
4701
4702 if (_log.isWarnEnabled()) {
4703 _log.warn(msg.toString());
4704 }
4705
4706 throw new NoSuchOrganizationException(msg.toString());
4707 }
4708
4709 return organization;
4710 }
4711
4712
4720 @Override
4721 public Organization fetchByC_N(long companyId, String name)
4722 throws SystemException {
4723 return fetchByC_N(companyId, name, true);
4724 }
4725
4726
4735 @Override
4736 public Organization fetchByC_N(long companyId, String name,
4737 boolean retrieveFromCache) throws SystemException {
4738 Object[] finderArgs = new Object[] { companyId, name };
4739
4740 Object result = null;
4741
4742 if (retrieveFromCache) {
4743 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_N,
4744 finderArgs, this);
4745 }
4746
4747 if (result instanceof Organization) {
4748 Organization organization = (Organization)result;
4749
4750 if ((companyId != organization.getCompanyId()) ||
4751 !Validator.equals(name, organization.getName())) {
4752 result = null;
4753 }
4754 }
4755
4756 if (result == null) {
4757 StringBundler query = new StringBundler(4);
4758
4759 query.append(_SQL_SELECT_ORGANIZATION_WHERE);
4760
4761 query.append(_FINDER_COLUMN_C_N_COMPANYID_2);
4762
4763 boolean bindName = false;
4764
4765 if (name == null) {
4766 query.append(_FINDER_COLUMN_C_N_NAME_1);
4767 }
4768 else if (name.equals(StringPool.BLANK)) {
4769 query.append(_FINDER_COLUMN_C_N_NAME_3);
4770 }
4771 else {
4772 bindName = true;
4773
4774 query.append(_FINDER_COLUMN_C_N_NAME_2);
4775 }
4776
4777 String sql = query.toString();
4778
4779 Session session = null;
4780
4781 try {
4782 session = openSession();
4783
4784 Query q = session.createQuery(sql);
4785
4786 QueryPos qPos = QueryPos.getInstance(q);
4787
4788 qPos.add(companyId);
4789
4790 if (bindName) {
4791 qPos.add(name);
4792 }
4793
4794 List<Organization> list = q.list();
4795
4796 if (list.isEmpty()) {
4797 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N,
4798 finderArgs, list);
4799 }
4800 else {
4801 Organization organization = list.get(0);
4802
4803 result = organization;
4804
4805 cacheResult(organization);
4806
4807 if ((organization.getCompanyId() != companyId) ||
4808 (organization.getName() == null) ||
4809 !organization.getName().equals(name)) {
4810 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N,
4811 finderArgs, organization);
4812 }
4813 }
4814 }
4815 catch (Exception e) {
4816 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_N,
4817 finderArgs);
4818
4819 throw processException(e);
4820 }
4821 finally {
4822 closeSession(session);
4823 }
4824 }
4825
4826 if (result instanceof List<?>) {
4827 return null;
4828 }
4829 else {
4830 return (Organization)result;
4831 }
4832 }
4833
4834
4842 @Override
4843 public Organization removeByC_N(long companyId, String name)
4844 throws NoSuchOrganizationException, SystemException {
4845 Organization organization = findByC_N(companyId, name);
4846
4847 return remove(organization);
4848 }
4849
4850
4858 @Override
4859 public int countByC_N(long companyId, String name)
4860 throws SystemException {
4861 FinderPath finderPath = FINDER_PATH_COUNT_BY_C_N;
4862
4863 Object[] finderArgs = new Object[] { companyId, name };
4864
4865 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
4866 this);
4867
4868 if (count == null) {
4869 StringBundler query = new StringBundler(3);
4870
4871 query.append(_SQL_COUNT_ORGANIZATION_WHERE);
4872
4873 query.append(_FINDER_COLUMN_C_N_COMPANYID_2);
4874
4875 boolean bindName = false;
4876
4877 if (name == null) {
4878 query.append(_FINDER_COLUMN_C_N_NAME_1);
4879 }
4880 else if (name.equals(StringPool.BLANK)) {
4881 query.append(_FINDER_COLUMN_C_N_NAME_3);
4882 }
4883 else {
4884 bindName = true;
4885
4886 query.append(_FINDER_COLUMN_C_N_NAME_2);
4887 }
4888
4889 String sql = query.toString();
4890
4891 Session session = null;
4892
4893 try {
4894 session = openSession();
4895
4896 Query q = session.createQuery(sql);
4897
4898 QueryPos qPos = QueryPos.getInstance(q);
4899
4900 qPos.add(companyId);
4901
4902 if (bindName) {
4903 qPos.add(name);
4904 }
4905
4906 count = (Long)q.uniqueResult();
4907
4908 FinderCacheUtil.putResult(finderPath, finderArgs, count);
4909 }
4910 catch (Exception e) {
4911 FinderCacheUtil.removeResult(finderPath, finderArgs);
4912
4913 throw processException(e);
4914 }
4915 finally {
4916 closeSession(session);
4917 }
4918 }
4919
4920 return count.intValue();
4921 }
4922
4923 private static final String _FINDER_COLUMN_C_N_COMPANYID_2 = "organization.companyId = ? AND ";
4924 private static final String _FINDER_COLUMN_C_N_NAME_1 = "organization.name IS NULL";
4925 private static final String _FINDER_COLUMN_C_N_NAME_2 = "organization.name = ?";
4926 private static final String _FINDER_COLUMN_C_N_NAME_3 = "(organization.name IS NULL OR organization.name = '')";
4927
4928 public OrganizationPersistenceImpl() {
4929 setModelClass(Organization.class);
4930 }
4931
4932
4937 @Override
4938 public void cacheResult(Organization organization) {
4939 EntityCacheUtil.putResult(OrganizationModelImpl.ENTITY_CACHE_ENABLED,
4940 OrganizationImpl.class, organization.getPrimaryKey(), organization);
4941
4942 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N,
4943 new Object[] { organization.getCompanyId(), organization.getName() },
4944 organization);
4945
4946 organization.resetOriginalValues();
4947 }
4948
4949
4954 @Override
4955 public void cacheResult(List<Organization> organizations) {
4956 for (Organization organization : organizations) {
4957 if (EntityCacheUtil.getResult(
4958 OrganizationModelImpl.ENTITY_CACHE_ENABLED,
4959 OrganizationImpl.class, organization.getPrimaryKey()) == null) {
4960 cacheResult(organization);
4961 }
4962 else {
4963 organization.resetOriginalValues();
4964 }
4965 }
4966 }
4967
4968
4975 @Override
4976 public void clearCache() {
4977 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
4978 CacheRegistryUtil.clear(OrganizationImpl.class.getName());
4979 }
4980
4981 EntityCacheUtil.clearCache(OrganizationImpl.class.getName());
4982
4983 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
4984 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
4985 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
4986 }
4987
4988
4995 @Override
4996 public void clearCache(Organization organization) {
4997 EntityCacheUtil.removeResult(OrganizationModelImpl.ENTITY_CACHE_ENABLED,
4998 OrganizationImpl.class, organization.getPrimaryKey());
4999
5000 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
5001 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
5002
5003 clearUniqueFindersCache(organization);
5004 }
5005
5006 @Override
5007 public void clearCache(List<Organization> organizations) {
5008 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
5009 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
5010
5011 for (Organization organization : organizations) {
5012 EntityCacheUtil.removeResult(OrganizationModelImpl.ENTITY_CACHE_ENABLED,
5013 OrganizationImpl.class, organization.getPrimaryKey());
5014
5015 clearUniqueFindersCache(organization);
5016 }
5017 }
5018
5019 protected void cacheUniqueFindersCache(Organization organization) {
5020 if (organization.isNew()) {
5021 Object[] args = new Object[] {
5022 organization.getCompanyId(), organization.getName()
5023 };
5024
5025 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_N, args,
5026 Long.valueOf(1));
5027 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N, args,
5028 organization);
5029 }
5030 else {
5031 OrganizationModelImpl organizationModelImpl = (OrganizationModelImpl)organization;
5032
5033 if ((organizationModelImpl.getColumnBitmask() &
5034 FINDER_PATH_FETCH_BY_C_N.getColumnBitmask()) != 0) {
5035 Object[] args = new Object[] {
5036 organization.getCompanyId(), organization.getName()
5037 };
5038
5039 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_N, args,
5040 Long.valueOf(1));
5041 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N, args,
5042 organization);
5043 }
5044 }
5045 }
5046
5047 protected void clearUniqueFindersCache(Organization organization) {
5048 OrganizationModelImpl organizationModelImpl = (OrganizationModelImpl)organization;
5049
5050 Object[] args = new Object[] {
5051 organization.getCompanyId(), organization.getName()
5052 };
5053
5054 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_N, args);
5055 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_N, args);
5056
5057 if ((organizationModelImpl.getColumnBitmask() &
5058 FINDER_PATH_FETCH_BY_C_N.getColumnBitmask()) != 0) {
5059 args = new Object[] {
5060 organizationModelImpl.getOriginalCompanyId(),
5061 organizationModelImpl.getOriginalName()
5062 };
5063
5064 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_N, args);
5065 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_N, args);
5066 }
5067 }
5068
5069
5075 @Override
5076 public Organization create(long organizationId) {
5077 Organization organization = new OrganizationImpl();
5078
5079 organization.setNew(true);
5080 organization.setPrimaryKey(organizationId);
5081
5082 String uuid = PortalUUIDUtil.generate();
5083
5084 organization.setUuid(uuid);
5085
5086 return organization;
5087 }
5088
5089
5097 @Override
5098 public Organization remove(long organizationId)
5099 throws NoSuchOrganizationException, SystemException {
5100 return remove((Serializable)organizationId);
5101 }
5102
5103
5111 @Override
5112 public Organization remove(Serializable primaryKey)
5113 throws NoSuchOrganizationException, SystemException {
5114 Session session = null;
5115
5116 try {
5117 session = openSession();
5118
5119 Organization organization = (Organization)session.get(OrganizationImpl.class,
5120 primaryKey);
5121
5122 if (organization == null) {
5123 if (_log.isWarnEnabled()) {
5124 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
5125 }
5126
5127 throw new NoSuchOrganizationException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
5128 primaryKey);
5129 }
5130
5131 return remove(organization);
5132 }
5133 catch (NoSuchOrganizationException nsee) {
5134 throw nsee;
5135 }
5136 catch (Exception e) {
5137 throw processException(e);
5138 }
5139 finally {
5140 closeSession(session);
5141 }
5142 }
5143
5144 @Override
5145 protected Organization removeImpl(Organization organization)
5146 throws SystemException {
5147 organization = toUnwrappedModel(organization);
5148
5149 organizationToGroupTableMapper.deleteLeftPrimaryKeyTableMappings(organization.getPrimaryKey());
5150
5151 organizationToUserTableMapper.deleteLeftPrimaryKeyTableMappings(organization.getPrimaryKey());
5152
5153 Session session = null;
5154
5155 try {
5156 session = openSession();
5157
5158 if (!session.contains(organization)) {
5159 organization = (Organization)session.get(OrganizationImpl.class,
5160 organization.getPrimaryKeyObj());
5161 }
5162
5163 if (organization != null) {
5164 session.delete(organization);
5165 }
5166 }
5167 catch (Exception e) {
5168 throw processException(e);
5169 }
5170 finally {
5171 closeSession(session);
5172 }
5173
5174 if (organization != null) {
5175 clearCache(organization);
5176 }
5177
5178 return organization;
5179 }
5180
5181 @Override
5182 public Organization updateImpl(
5183 com.liferay.portal.model.Organization organization)
5184 throws SystemException {
5185 organization = toUnwrappedModel(organization);
5186
5187 boolean isNew = organization.isNew();
5188
5189 OrganizationModelImpl organizationModelImpl = (OrganizationModelImpl)organization;
5190
5191 if (Validator.isNull(organization.getUuid())) {
5192 String uuid = PortalUUIDUtil.generate();
5193
5194 organization.setUuid(uuid);
5195 }
5196
5197 Session session = null;
5198
5199 try {
5200 session = openSession();
5201
5202 if (organization.isNew()) {
5203 session.save(organization);
5204
5205 organization.setNew(false);
5206 }
5207 else {
5208 session.merge(organization);
5209 }
5210 }
5211 catch (Exception e) {
5212 throw processException(e);
5213 }
5214 finally {
5215 closeSession(session);
5216 }
5217
5218 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
5219
5220 if (isNew || !OrganizationModelImpl.COLUMN_BITMASK_ENABLED) {
5221 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
5222 }
5223
5224 else {
5225 if ((organizationModelImpl.getColumnBitmask() &
5226 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
5227 Object[] args = new Object[] {
5228 organizationModelImpl.getOriginalUuid()
5229 };
5230
5231 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
5232 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
5233 args);
5234
5235 args = new Object[] { organizationModelImpl.getUuid() };
5236
5237 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
5238 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
5239 args);
5240 }
5241
5242 if ((organizationModelImpl.getColumnBitmask() &
5243 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C.getColumnBitmask()) != 0) {
5244 Object[] args = new Object[] {
5245 organizationModelImpl.getOriginalUuid(),
5246 organizationModelImpl.getOriginalCompanyId()
5247 };
5248
5249 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
5250 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
5251 args);
5252
5253 args = new Object[] {
5254 organizationModelImpl.getUuid(),
5255 organizationModelImpl.getCompanyId()
5256 };
5257
5258 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
5259 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
5260 args);
5261 }
5262
5263 if ((organizationModelImpl.getColumnBitmask() &
5264 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
5265 Object[] args = new Object[] {
5266 organizationModelImpl.getOriginalCompanyId()
5267 };
5268
5269 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
5270 args);
5271 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
5272 args);
5273
5274 args = new Object[] { organizationModelImpl.getCompanyId() };
5275
5276 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
5277 args);
5278 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
5279 args);
5280 }
5281
5282 if ((organizationModelImpl.getColumnBitmask() &
5283 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LOCATIONS.getColumnBitmask()) != 0) {
5284 Object[] args = new Object[] {
5285 organizationModelImpl.getOriginalCompanyId()
5286 };
5287
5288 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_LOCATIONS,
5289 args);
5290 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LOCATIONS,
5291 args);
5292
5293 args = new Object[] { organizationModelImpl.getCompanyId() };
5294
5295 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_LOCATIONS,
5296 args);
5297 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_LOCATIONS,
5298 args);
5299 }
5300
5301 if ((organizationModelImpl.getColumnBitmask() &
5302 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_P.getColumnBitmask()) != 0) {
5303 Object[] args = new Object[] {
5304 organizationModelImpl.getOriginalCompanyId(),
5305 organizationModelImpl.getOriginalParentOrganizationId()
5306 };
5307
5308 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_P, args);
5309 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_P,
5310 args);
5311
5312 args = new Object[] {
5313 organizationModelImpl.getCompanyId(),
5314 organizationModelImpl.getParentOrganizationId()
5315 };
5316
5317 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_P, args);
5318 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_P,
5319 args);
5320 }
5321 }
5322
5323 EntityCacheUtil.putResult(OrganizationModelImpl.ENTITY_CACHE_ENABLED,
5324 OrganizationImpl.class, organization.getPrimaryKey(), organization);
5325
5326 clearUniqueFindersCache(organization);
5327 cacheUniqueFindersCache(organization);
5328
5329 return organization;
5330 }
5331
5332 protected Organization toUnwrappedModel(Organization organization) {
5333 if (organization instanceof OrganizationImpl) {
5334 return organization;
5335 }
5336
5337 OrganizationImpl organizationImpl = new OrganizationImpl();
5338
5339 organizationImpl.setNew(organization.isNew());
5340 organizationImpl.setPrimaryKey(organization.getPrimaryKey());
5341
5342 organizationImpl.setUuid(organization.getUuid());
5343 organizationImpl.setOrganizationId(organization.getOrganizationId());
5344 organizationImpl.setCompanyId(organization.getCompanyId());
5345 organizationImpl.setUserId(organization.getUserId());
5346 organizationImpl.setUserName(organization.getUserName());
5347 organizationImpl.setCreateDate(organization.getCreateDate());
5348 organizationImpl.setModifiedDate(organization.getModifiedDate());
5349 organizationImpl.setParentOrganizationId(organization.getParentOrganizationId());
5350 organizationImpl.setTreePath(organization.getTreePath());
5351 organizationImpl.setName(organization.getName());
5352 organizationImpl.setType(organization.getType());
5353 organizationImpl.setRecursable(organization.isRecursable());
5354 organizationImpl.setRegionId(organization.getRegionId());
5355 organizationImpl.setCountryId(organization.getCountryId());
5356 organizationImpl.setStatusId(organization.getStatusId());
5357 organizationImpl.setComments(organization.getComments());
5358
5359 return organizationImpl;
5360 }
5361
5362
5370 @Override
5371 public Organization findByPrimaryKey(Serializable primaryKey)
5372 throws NoSuchOrganizationException, SystemException {
5373 Organization organization = fetchByPrimaryKey(primaryKey);
5374
5375 if (organization == null) {
5376 if (_log.isWarnEnabled()) {
5377 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
5378 }
5379
5380 throw new NoSuchOrganizationException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
5381 primaryKey);
5382 }
5383
5384 return organization;
5385 }
5386
5387
5395 @Override
5396 public Organization findByPrimaryKey(long organizationId)
5397 throws NoSuchOrganizationException, SystemException {
5398 return findByPrimaryKey((Serializable)organizationId);
5399 }
5400
5401
5408 @Override
5409 public Organization fetchByPrimaryKey(Serializable primaryKey)
5410 throws SystemException {
5411 Organization organization = (Organization)EntityCacheUtil.getResult(OrganizationModelImpl.ENTITY_CACHE_ENABLED,
5412 OrganizationImpl.class, primaryKey);
5413
5414 if (organization == _nullOrganization) {
5415 return null;
5416 }
5417
5418 if (organization == null) {
5419 Session session = null;
5420
5421 try {
5422 session = openSession();
5423
5424 organization = (Organization)session.get(OrganizationImpl.class,
5425 primaryKey);
5426
5427 if (organization != null) {
5428 cacheResult(organization);
5429 }
5430 else {
5431 EntityCacheUtil.putResult(OrganizationModelImpl.ENTITY_CACHE_ENABLED,
5432 OrganizationImpl.class, primaryKey, _nullOrganization);
5433 }
5434 }
5435 catch (Exception e) {
5436 EntityCacheUtil.removeResult(OrganizationModelImpl.ENTITY_CACHE_ENABLED,
5437 OrganizationImpl.class, primaryKey);
5438
5439 throw processException(e);
5440 }
5441 finally {
5442 closeSession(session);
5443 }
5444 }
5445
5446 return organization;
5447 }
5448
5449
5456 @Override
5457 public Organization fetchByPrimaryKey(long organizationId)
5458 throws SystemException {
5459 return fetchByPrimaryKey((Serializable)organizationId);
5460 }
5461
5462
5468 @Override
5469 public List<Organization> findAll() throws SystemException {
5470 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
5471 }
5472
5473
5485 @Override
5486 public List<Organization> findAll(int start, int end)
5487 throws SystemException {
5488 return findAll(start, end, null);
5489 }
5490
5491
5504 @Override
5505 public List<Organization> findAll(int start, int end,
5506 OrderByComparator orderByComparator) throws SystemException {
5507 boolean pagination = true;
5508 FinderPath finderPath = null;
5509 Object[] finderArgs = null;
5510
5511 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
5512 (orderByComparator == null)) {
5513 pagination = false;
5514 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
5515 finderArgs = FINDER_ARGS_EMPTY;
5516 }
5517 else {
5518 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
5519 finderArgs = new Object[] { start, end, orderByComparator };
5520 }
5521
5522 List<Organization> list = (List<Organization>)FinderCacheUtil.getResult(finderPath,
5523 finderArgs, this);
5524
5525 if (list == null) {
5526 StringBundler query = null;
5527 String sql = null;
5528
5529 if (orderByComparator != null) {
5530 query = new StringBundler(2 +
5531 (orderByComparator.getOrderByFields().length * 3));
5532
5533 query.append(_SQL_SELECT_ORGANIZATION);
5534
5535 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5536 orderByComparator);
5537
5538 sql = query.toString();
5539 }
5540 else {
5541 sql = _SQL_SELECT_ORGANIZATION;
5542
5543 if (pagination) {
5544 sql = sql.concat(OrganizationModelImpl.ORDER_BY_JPQL);
5545 }
5546 }
5547
5548 Session session = null;
5549
5550 try {
5551 session = openSession();
5552
5553 Query q = session.createQuery(sql);
5554
5555 if (!pagination) {
5556 list = (List<Organization>)QueryUtil.list(q, getDialect(),
5557 start, end, false);
5558
5559 Collections.sort(list);
5560
5561 list = new UnmodifiableList<Organization>(list);
5562 }
5563 else {
5564 list = (List<Organization>)QueryUtil.list(q, getDialect(),
5565 start, end);
5566 }
5567
5568 cacheResult(list);
5569
5570 FinderCacheUtil.putResult(finderPath, finderArgs, list);
5571 }
5572 catch (Exception e) {
5573 FinderCacheUtil.removeResult(finderPath, finderArgs);
5574
5575 throw processException(e);
5576 }
5577 finally {
5578 closeSession(session);
5579 }
5580 }
5581
5582 return list;
5583 }
5584
5585
5590 @Override
5591 public void removeAll() throws SystemException {
5592 for (Organization organization : findAll()) {
5593 remove(organization);
5594 }
5595 }
5596
5597
5603 @Override
5604 public int countAll() throws SystemException {
5605 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
5606 FINDER_ARGS_EMPTY, this);
5607
5608 if (count == null) {
5609 Session session = null;
5610
5611 try {
5612 session = openSession();
5613
5614 Query q = session.createQuery(_SQL_COUNT_ORGANIZATION);
5615
5616 count = (Long)q.uniqueResult();
5617
5618 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
5619 FINDER_ARGS_EMPTY, count);
5620 }
5621 catch (Exception e) {
5622 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
5623 FINDER_ARGS_EMPTY);
5624
5625 throw processException(e);
5626 }
5627 finally {
5628 closeSession(session);
5629 }
5630 }
5631
5632 return count.intValue();
5633 }
5634
5635
5642 @Override
5643 public List<com.liferay.portal.model.Group> getGroups(long pk)
5644 throws SystemException {
5645 return getGroups(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
5646 }
5647
5648
5661 @Override
5662 public List<com.liferay.portal.model.Group> getGroups(long pk, int start,
5663 int end) throws SystemException {
5664 return getGroups(pk, start, end, null);
5665 }
5666
5667
5681 @Override
5682 public List<com.liferay.portal.model.Group> getGroups(long pk, int start,
5683 int end, OrderByComparator orderByComparator) throws SystemException {
5684 return organizationToGroupTableMapper.getRightBaseModels(pk, start,
5685 end, orderByComparator);
5686 }
5687
5688
5695 @Override
5696 public int getGroupsSize(long pk) throws SystemException {
5697 long[] pks = organizationToGroupTableMapper.getRightPrimaryKeys(pk);
5698
5699 return pks.length;
5700 }
5701
5702
5710 @Override
5711 public boolean containsGroup(long pk, long groupPK)
5712 throws SystemException {
5713 return organizationToGroupTableMapper.containsTableMapping(pk, groupPK);
5714 }
5715
5716
5723 @Override
5724 public boolean containsGroups(long pk) throws SystemException {
5725 if (getGroupsSize(pk) > 0) {
5726 return true;
5727 }
5728 else {
5729 return false;
5730 }
5731 }
5732
5733
5740 @Override
5741 public void addGroup(long pk, long groupPK) throws SystemException {
5742 organizationToGroupTableMapper.addTableMapping(pk, groupPK);
5743 }
5744
5745
5752 @Override
5753 public void addGroup(long pk, com.liferay.portal.model.Group group)
5754 throws SystemException {
5755 organizationToGroupTableMapper.addTableMapping(pk, group.getPrimaryKey());
5756 }
5757
5758
5765 @Override
5766 public void addGroups(long pk, long[] groupPKs) throws SystemException {
5767 for (long groupPK : groupPKs) {
5768 organizationToGroupTableMapper.addTableMapping(pk, groupPK);
5769 }
5770 }
5771
5772
5779 @Override
5780 public void addGroups(long pk, List<com.liferay.portal.model.Group> groups)
5781 throws SystemException {
5782 for (com.liferay.portal.model.Group group : groups) {
5783 organizationToGroupTableMapper.addTableMapping(pk,
5784 group.getPrimaryKey());
5785 }
5786 }
5787
5788
5794 @Override
5795 public void clearGroups(long pk) throws SystemException {
5796 organizationToGroupTableMapper.deleteLeftPrimaryKeyTableMappings(pk);
5797 }
5798
5799
5806 @Override
5807 public void removeGroup(long pk, long groupPK) throws SystemException {
5808 organizationToGroupTableMapper.deleteTableMapping(pk, groupPK);
5809 }
5810
5811
5818 @Override
5819 public void removeGroup(long pk, com.liferay.portal.model.Group group)
5820 throws SystemException {
5821 organizationToGroupTableMapper.deleteTableMapping(pk,
5822 group.getPrimaryKey());
5823 }
5824
5825
5832 @Override
5833 public void removeGroups(long pk, long[] groupPKs)
5834 throws SystemException {
5835 for (long groupPK : groupPKs) {
5836 organizationToGroupTableMapper.deleteTableMapping(pk, groupPK);
5837 }
5838 }
5839
5840
5847 @Override
5848 public void removeGroups(long pk,
5849 List<com.liferay.portal.model.Group> groups) throws SystemException {
5850 for (com.liferay.portal.model.Group group : groups) {
5851 organizationToGroupTableMapper.deleteTableMapping(pk,
5852 group.getPrimaryKey());
5853 }
5854 }
5855
5856
5863 @Override
5864 public void setGroups(long pk, long[] groupPKs) throws SystemException {
5865 organizationToGroupTableMapper.deleteLeftPrimaryKeyTableMappings(pk);
5866
5867 for (Long groupPK : groupPKs) {
5868 organizationToGroupTableMapper.addTableMapping(pk, groupPK);
5869 }
5870 }
5871
5872
5879 @Override
5880 public void setGroups(long pk, List<com.liferay.portal.model.Group> groups)
5881 throws SystemException {
5882 try {
5883 long[] groupPKs = new long[groups.size()];
5884
5885 for (int i = 0; i < groups.size(); i++) {
5886 com.liferay.portal.model.Group group = groups.get(i);
5887
5888 groupPKs[i] = group.getPrimaryKey();
5889 }
5890
5891 setGroups(pk, groupPKs);
5892 }
5893 catch (Exception e) {
5894 throw processException(e);
5895 }
5896 finally {
5897 FinderCacheUtil.clearCache(OrganizationModelImpl.MAPPING_TABLE_GROUPS_ORGS_NAME);
5898 }
5899 }
5900
5901
5908 @Override
5909 public List<com.liferay.portal.model.User> getUsers(long pk)
5910 throws SystemException {
5911 return getUsers(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
5912 }
5913
5914
5927 @Override
5928 public List<com.liferay.portal.model.User> getUsers(long pk, int start,
5929 int end) throws SystemException {
5930 return getUsers(pk, start, end, null);
5931 }
5932
5933
5947 @Override
5948 public List<com.liferay.portal.model.User> getUsers(long pk, int start,
5949 int end, OrderByComparator orderByComparator) throws SystemException {
5950 return organizationToUserTableMapper.getRightBaseModels(pk, start, end,
5951 orderByComparator);
5952 }
5953
5954
5961 @Override
5962 public int getUsersSize(long pk) throws SystemException {
5963 long[] pks = organizationToUserTableMapper.getRightPrimaryKeys(pk);
5964
5965 return pks.length;
5966 }
5967
5968
5976 @Override
5977 public boolean containsUser(long pk, long userPK) throws SystemException {
5978 return organizationToUserTableMapper.containsTableMapping(pk, userPK);
5979 }
5980
5981
5988 @Override
5989 public boolean containsUsers(long pk) throws SystemException {
5990 if (getUsersSize(pk) > 0) {
5991 return true;
5992 }
5993 else {
5994 return false;
5995 }
5996 }
5997
5998
6005 @Override
6006 public void addUser(long pk, long userPK) throws SystemException {
6007 organizationToUserTableMapper.addTableMapping(pk, userPK);
6008 }
6009
6010
6017 @Override
6018 public void addUser(long pk, com.liferay.portal.model.User user)
6019 throws SystemException {
6020 organizationToUserTableMapper.addTableMapping(pk, user.getPrimaryKey());
6021 }
6022
6023
6030 @Override
6031 public void addUsers(long pk, long[] userPKs) throws SystemException {
6032 for (long userPK : userPKs) {
6033 organizationToUserTableMapper.addTableMapping(pk, userPK);
6034 }
6035 }
6036
6037
6044 @Override
6045 public void addUsers(long pk, List<com.liferay.portal.model.User> users)
6046 throws SystemException {
6047 for (com.liferay.portal.model.User user : users) {
6048 organizationToUserTableMapper.addTableMapping(pk,
6049 user.getPrimaryKey());
6050 }
6051 }
6052
6053
6059 @Override
6060 public void clearUsers(long pk) throws SystemException {
6061 organizationToUserTableMapper.deleteLeftPrimaryKeyTableMappings(pk);
6062 }
6063
6064
6071 @Override
6072 public void removeUser(long pk, long userPK) throws SystemException {
6073 organizationToUserTableMapper.deleteTableMapping(pk, userPK);
6074 }
6075
6076
6083 @Override
6084 public void removeUser(long pk, com.liferay.portal.model.User user)
6085 throws SystemException {
6086 organizationToUserTableMapper.deleteTableMapping(pk,
6087 user.getPrimaryKey());
6088 }
6089
6090
6097 @Override
6098 public void removeUsers(long pk, long[] userPKs) throws SystemException {
6099 for (long userPK : userPKs) {
6100 organizationToUserTableMapper.deleteTableMapping(pk, userPK);
6101 }
6102 }
6103
6104
6111 @Override
6112 public void removeUsers(long pk, List<com.liferay.portal.model.User> users)
6113 throws SystemException {
6114 for (com.liferay.portal.model.User user : users) {
6115 organizationToUserTableMapper.deleteTableMapping(pk,
6116 user.getPrimaryKey());
6117 }
6118 }
6119
6120
6127 @Override
6128 public void setUsers(long pk, long[] userPKs) throws SystemException {
6129 organizationToUserTableMapper.deleteLeftPrimaryKeyTableMappings(pk);
6130
6131 for (Long userPK : userPKs) {
6132 organizationToUserTableMapper.addTableMapping(pk, userPK);
6133 }
6134 }
6135
6136
6143 @Override
6144 public void setUsers(long pk, List<com.liferay.portal.model.User> users)
6145 throws SystemException {
6146 try {
6147 long[] userPKs = new long[users.size()];
6148
6149 for (int i = 0; i < users.size(); i++) {
6150 com.liferay.portal.model.User user = users.get(i);
6151
6152 userPKs[i] = user.getPrimaryKey();
6153 }
6154
6155 setUsers(pk, userPKs);
6156 }
6157 catch (Exception e) {
6158 throw processException(e);
6159 }
6160 finally {
6161 FinderCacheUtil.clearCache(OrganizationModelImpl.MAPPING_TABLE_USERS_ORGS_NAME);
6162 }
6163 }
6164
6165 @Override
6166 protected Set<String> getBadColumnNames() {
6167 return _badColumnNames;
6168 }
6169
6170
6173 public void afterPropertiesSet() {
6174 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
6175 com.liferay.portal.util.PropsUtil.get(
6176 "value.object.listener.com.liferay.portal.model.Organization")));
6177
6178 if (listenerClassNames.length > 0) {
6179 try {
6180 List<ModelListener<Organization>> listenersList = new ArrayList<ModelListener<Organization>>();
6181
6182 for (String listenerClassName : listenerClassNames) {
6183 listenersList.add((ModelListener<Organization>)InstanceFactory.newInstance(
6184 getClassLoader(), listenerClassName));
6185 }
6186
6187 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
6188 }
6189 catch (Exception e) {
6190 _log.error(e);
6191 }
6192 }
6193
6194 organizationToGroupTableMapper = TableMapperFactory.getTableMapper("Groups_Orgs",
6195 "organizationId", "groupId", this, groupPersistence);
6196
6197 organizationToUserTableMapper = TableMapperFactory.getTableMapper("Users_Orgs",
6198 "organizationId", "userId", this, userPersistence);
6199 }
6200
6201 public void destroy() {
6202 EntityCacheUtil.removeCache(OrganizationImpl.class.getName());
6203 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
6204 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
6205 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
6206 }
6207
6208 @BeanReference(type = GroupPersistence.class)
6209 protected GroupPersistence groupPersistence;
6210 protected TableMapper<Organization, com.liferay.portal.model.Group> organizationToGroupTableMapper;
6211 @BeanReference(type = UserPersistence.class)
6212 protected UserPersistence userPersistence;
6213 protected TableMapper<Organization, com.liferay.portal.model.User> organizationToUserTableMapper;
6214 private static final String _SQL_SELECT_ORGANIZATION = "SELECT organization FROM Organization organization";
6215 private static final String _SQL_SELECT_ORGANIZATION_WHERE = "SELECT organization FROM Organization organization WHERE ";
6216 private static final String _SQL_COUNT_ORGANIZATION = "SELECT COUNT(organization) FROM Organization organization";
6217 private static final String _SQL_COUNT_ORGANIZATION_WHERE = "SELECT COUNT(organization) FROM Organization organization WHERE ";
6218 private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "organization.organizationId";
6219 private static final String _FILTER_SQL_SELECT_ORGANIZATION_WHERE = "SELECT DISTINCT {organization.*} FROM Organization_ organization WHERE ";
6220 private static final String _FILTER_SQL_SELECT_ORGANIZATION_NO_INLINE_DISTINCT_WHERE_1 =
6221 "SELECT {Organization_.*} FROM (SELECT DISTINCT organization.organizationId FROM Organization_ organization WHERE ";
6222 private static final String _FILTER_SQL_SELECT_ORGANIZATION_NO_INLINE_DISTINCT_WHERE_2 =
6223 ") TEMP_TABLE INNER JOIN Organization_ ON TEMP_TABLE.organizationId = Organization_.organizationId";
6224 private static final String _FILTER_SQL_COUNT_ORGANIZATION_WHERE = "SELECT COUNT(DISTINCT organization.organizationId) AS COUNT_VALUE FROM Organization_ organization WHERE ";
6225 private static final String _FILTER_ENTITY_ALIAS = "organization";
6226 private static final String _FILTER_ENTITY_TABLE = "Organization_";
6227 private static final String _ORDER_BY_ENTITY_ALIAS = "organization.";
6228 private static final String _ORDER_BY_ENTITY_TABLE = "Organization_.";
6229 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No Organization exists with the primary key ";
6230 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No Organization exists with the key {";
6231 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
6232 private static Log _log = LogFactoryUtil.getLog(OrganizationPersistenceImpl.class);
6233 private static Set<String> _badColumnNames = SetUtil.fromArray(new String[] {
6234 "uuid", "type"
6235 });
6236 private static Organization _nullOrganization = new OrganizationImpl() {
6237 @Override
6238 public Object clone() {
6239 return this;
6240 }
6241
6242 @Override
6243 public CacheModel<Organization> toCacheModel() {
6244 return _nullOrganizationCacheModel;
6245 }
6246 };
6247
6248 private static CacheModel<Organization> _nullOrganizationCacheModel = new CacheModel<Organization>() {
6249 @Override
6250 public Organization toEntityModel() {
6251 return _nullOrganization;
6252 }
6253 };
6254 }