001
014
015 package com.liferay.portlet.exportimport.service.persistence.impl;
016
017 import aQute.bnd.annotation.ProviderType;
018
019 import com.liferay.portal.kernel.bean.BeanReference;
020 import com.liferay.portal.kernel.dao.orm.EntityCache;
021 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
022 import com.liferay.portal.kernel.dao.orm.FinderCache;
023 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
024 import com.liferay.portal.kernel.dao.orm.FinderPath;
025 import com.liferay.portal.kernel.dao.orm.Query;
026 import com.liferay.portal.kernel.dao.orm.QueryPos;
027 import com.liferay.portal.kernel.dao.orm.QueryUtil;
028 import com.liferay.portal.kernel.dao.orm.Session;
029 import com.liferay.portal.kernel.log.Log;
030 import com.liferay.portal.kernel.log.LogFactoryUtil;
031 import com.liferay.portal.kernel.util.OrderByComparator;
032 import com.liferay.portal.kernel.util.SetUtil;
033 import com.liferay.portal.kernel.util.StringBundler;
034 import com.liferay.portal.kernel.util.StringPool;
035 import com.liferay.portal.model.CacheModel;
036 import com.liferay.portal.model.MVCCModel;
037 import com.liferay.portal.service.ServiceContext;
038 import com.liferay.portal.service.ServiceContextThreadLocal;
039 import com.liferay.portal.service.persistence.CompanyProvider;
040 import com.liferay.portal.service.persistence.CompanyProviderWrapper;
041 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
042
043 import com.liferay.portlet.exportimport.exception.NoSuchConfigurationException;
044 import com.liferay.portlet.exportimport.model.ExportImportConfiguration;
045 import com.liferay.portlet.exportimport.model.impl.ExportImportConfigurationImpl;
046 import com.liferay.portlet.exportimport.model.impl.ExportImportConfigurationModelImpl;
047 import com.liferay.portlet.exportimport.service.persistence.ExportImportConfigurationPersistence;
048
049 import java.io.Serializable;
050
051 import java.util.Collections;
052 import java.util.Date;
053 import java.util.HashMap;
054 import java.util.HashSet;
055 import java.util.Iterator;
056 import java.util.List;
057 import java.util.Map;
058 import java.util.Set;
059
060
072 @ProviderType
073 public class ExportImportConfigurationPersistenceImpl
074 extends BasePersistenceImpl<ExportImportConfiguration>
075 implements ExportImportConfigurationPersistence {
076
081 public static final String FINDER_CLASS_NAME_ENTITY = ExportImportConfigurationImpl.class.getName();
082 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
083 ".List1";
084 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
085 ".List2";
086 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(ExportImportConfigurationModelImpl.ENTITY_CACHE_ENABLED,
087 ExportImportConfigurationModelImpl.FINDER_CACHE_ENABLED,
088 ExportImportConfigurationImpl.class,
089 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
090 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(ExportImportConfigurationModelImpl.ENTITY_CACHE_ENABLED,
091 ExportImportConfigurationModelImpl.FINDER_CACHE_ENABLED,
092 ExportImportConfigurationImpl.class,
093 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
094 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(ExportImportConfigurationModelImpl.ENTITY_CACHE_ENABLED,
095 ExportImportConfigurationModelImpl.FINDER_CACHE_ENABLED,
096 Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll",
097 new String[0]);
098 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(ExportImportConfigurationModelImpl.ENTITY_CACHE_ENABLED,
099 ExportImportConfigurationModelImpl.FINDER_CACHE_ENABLED,
100 ExportImportConfigurationImpl.class,
101 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByGroupId",
102 new String[] {
103 Long.class.getName(),
104
105 Integer.class.getName(), Integer.class.getName(),
106 OrderByComparator.class.getName()
107 });
108 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID =
109 new FinderPath(ExportImportConfigurationModelImpl.ENTITY_CACHE_ENABLED,
110 ExportImportConfigurationModelImpl.FINDER_CACHE_ENABLED,
111 ExportImportConfigurationImpl.class,
112 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByGroupId",
113 new String[] { Long.class.getName() },
114 ExportImportConfigurationModelImpl.GROUPID_COLUMN_BITMASK |
115 ExportImportConfigurationModelImpl.CREATEDATE_COLUMN_BITMASK);
116 public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(ExportImportConfigurationModelImpl.ENTITY_CACHE_ENABLED,
117 ExportImportConfigurationModelImpl.FINDER_CACHE_ENABLED,
118 Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
119 "countByGroupId", new String[] { Long.class.getName() });
120
121
127 @Override
128 public List<ExportImportConfiguration> findByGroupId(long groupId) {
129 return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
130 }
131
132
144 @Override
145 public List<ExportImportConfiguration> findByGroupId(long groupId,
146 int start, int end) {
147 return findByGroupId(groupId, start, end, null);
148 }
149
150
163 @Override
164 public List<ExportImportConfiguration> findByGroupId(long groupId,
165 int start, int end,
166 OrderByComparator<ExportImportConfiguration> orderByComparator) {
167 return findByGroupId(groupId, start, end, orderByComparator, true);
168 }
169
170
184 @Override
185 public List<ExportImportConfiguration> findByGroupId(long groupId,
186 int start, int end,
187 OrderByComparator<ExportImportConfiguration> orderByComparator,
188 boolean retrieveFromCache) {
189 boolean pagination = true;
190 FinderPath finderPath = null;
191 Object[] finderArgs = null;
192
193 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
194 (orderByComparator == null)) {
195 pagination = false;
196 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
197 finderArgs = new Object[] { groupId };
198 }
199 else {
200 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
201 finderArgs = new Object[] { groupId, start, end, orderByComparator };
202 }
203
204 List<ExportImportConfiguration> list = null;
205
206 if (retrieveFromCache) {
207 list = (List<ExportImportConfiguration>)finderCache.getResult(finderPath,
208 finderArgs, this);
209
210 if ((list != null) && !list.isEmpty()) {
211 for (ExportImportConfiguration exportImportConfiguration : list) {
212 if ((groupId != exportImportConfiguration.getGroupId())) {
213 list = null;
214
215 break;
216 }
217 }
218 }
219 }
220
221 if (list == null) {
222 StringBundler query = null;
223
224 if (orderByComparator != null) {
225 query = new StringBundler(3 +
226 (orderByComparator.getOrderByFields().length * 2));
227 }
228 else {
229 query = new StringBundler(3);
230 }
231
232 query.append(_SQL_SELECT_EXPORTIMPORTCONFIGURATION_WHERE);
233
234 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
235
236 if (orderByComparator != null) {
237 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
238 orderByComparator);
239 }
240 else
241 if (pagination) {
242 query.append(ExportImportConfigurationModelImpl.ORDER_BY_JPQL);
243 }
244
245 String sql = query.toString();
246
247 Session session = null;
248
249 try {
250 session = openSession();
251
252 Query q = session.createQuery(sql);
253
254 QueryPos qPos = QueryPos.getInstance(q);
255
256 qPos.add(groupId);
257
258 if (!pagination) {
259 list = (List<ExportImportConfiguration>)QueryUtil.list(q,
260 getDialect(), start, end, false);
261
262 Collections.sort(list);
263
264 list = Collections.unmodifiableList(list);
265 }
266 else {
267 list = (List<ExportImportConfiguration>)QueryUtil.list(q,
268 getDialect(), start, end);
269 }
270
271 cacheResult(list);
272
273 finderCache.putResult(finderPath, finderArgs, list);
274 }
275 catch (Exception e) {
276 finderCache.removeResult(finderPath, finderArgs);
277
278 throw processException(e);
279 }
280 finally {
281 closeSession(session);
282 }
283 }
284
285 return list;
286 }
287
288
296 @Override
297 public ExportImportConfiguration findByGroupId_First(long groupId,
298 OrderByComparator<ExportImportConfiguration> orderByComparator)
299 throws NoSuchConfigurationException {
300 ExportImportConfiguration exportImportConfiguration = fetchByGroupId_First(groupId,
301 orderByComparator);
302
303 if (exportImportConfiguration != null) {
304 return exportImportConfiguration;
305 }
306
307 StringBundler msg = new StringBundler(4);
308
309 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
310
311 msg.append("groupId=");
312 msg.append(groupId);
313
314 msg.append(StringPool.CLOSE_CURLY_BRACE);
315
316 throw new NoSuchConfigurationException(msg.toString());
317 }
318
319
326 @Override
327 public ExportImportConfiguration fetchByGroupId_First(long groupId,
328 OrderByComparator<ExportImportConfiguration> orderByComparator) {
329 List<ExportImportConfiguration> list = findByGroupId(groupId, 0, 1,
330 orderByComparator);
331
332 if (!list.isEmpty()) {
333 return list.get(0);
334 }
335
336 return null;
337 }
338
339
347 @Override
348 public ExportImportConfiguration findByGroupId_Last(long groupId,
349 OrderByComparator<ExportImportConfiguration> orderByComparator)
350 throws NoSuchConfigurationException {
351 ExportImportConfiguration exportImportConfiguration = fetchByGroupId_Last(groupId,
352 orderByComparator);
353
354 if (exportImportConfiguration != null) {
355 return exportImportConfiguration;
356 }
357
358 StringBundler msg = new StringBundler(4);
359
360 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
361
362 msg.append("groupId=");
363 msg.append(groupId);
364
365 msg.append(StringPool.CLOSE_CURLY_BRACE);
366
367 throw new NoSuchConfigurationException(msg.toString());
368 }
369
370
377 @Override
378 public ExportImportConfiguration fetchByGroupId_Last(long groupId,
379 OrderByComparator<ExportImportConfiguration> orderByComparator) {
380 int count = countByGroupId(groupId);
381
382 if (count == 0) {
383 return null;
384 }
385
386 List<ExportImportConfiguration> list = findByGroupId(groupId,
387 count - 1, count, orderByComparator);
388
389 if (!list.isEmpty()) {
390 return list.get(0);
391 }
392
393 return null;
394 }
395
396
405 @Override
406 public ExportImportConfiguration[] findByGroupId_PrevAndNext(
407 long exportImportConfigurationId, long groupId,
408 OrderByComparator<ExportImportConfiguration> orderByComparator)
409 throws NoSuchConfigurationException {
410 ExportImportConfiguration exportImportConfiguration = findByPrimaryKey(exportImportConfigurationId);
411
412 Session session = null;
413
414 try {
415 session = openSession();
416
417 ExportImportConfiguration[] array = new ExportImportConfigurationImpl[3];
418
419 array[0] = getByGroupId_PrevAndNext(session,
420 exportImportConfiguration, groupId, orderByComparator, true);
421
422 array[1] = exportImportConfiguration;
423
424 array[2] = getByGroupId_PrevAndNext(session,
425 exportImportConfiguration, groupId, orderByComparator, false);
426
427 return array;
428 }
429 catch (Exception e) {
430 throw processException(e);
431 }
432 finally {
433 closeSession(session);
434 }
435 }
436
437 protected ExportImportConfiguration getByGroupId_PrevAndNext(
438 Session session, ExportImportConfiguration exportImportConfiguration,
439 long groupId,
440 OrderByComparator<ExportImportConfiguration> orderByComparator,
441 boolean previous) {
442 StringBundler query = null;
443
444 if (orderByComparator != null) {
445 query = new StringBundler(4 +
446 (orderByComparator.getOrderByConditionFields().length * 3) +
447 (orderByComparator.getOrderByFields().length * 3));
448 }
449 else {
450 query = new StringBundler(3);
451 }
452
453 query.append(_SQL_SELECT_EXPORTIMPORTCONFIGURATION_WHERE);
454
455 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
456
457 if (orderByComparator != null) {
458 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
459
460 if (orderByConditionFields.length > 0) {
461 query.append(WHERE_AND);
462 }
463
464 for (int i = 0; i < orderByConditionFields.length; i++) {
465 query.append(_ORDER_BY_ENTITY_ALIAS);
466 query.append(orderByConditionFields[i]);
467
468 if ((i + 1) < orderByConditionFields.length) {
469 if (orderByComparator.isAscending() ^ previous) {
470 query.append(WHERE_GREATER_THAN_HAS_NEXT);
471 }
472 else {
473 query.append(WHERE_LESSER_THAN_HAS_NEXT);
474 }
475 }
476 else {
477 if (orderByComparator.isAscending() ^ previous) {
478 query.append(WHERE_GREATER_THAN);
479 }
480 else {
481 query.append(WHERE_LESSER_THAN);
482 }
483 }
484 }
485
486 query.append(ORDER_BY_CLAUSE);
487
488 String[] orderByFields = orderByComparator.getOrderByFields();
489
490 for (int i = 0; i < orderByFields.length; i++) {
491 query.append(_ORDER_BY_ENTITY_ALIAS);
492 query.append(orderByFields[i]);
493
494 if ((i + 1) < orderByFields.length) {
495 if (orderByComparator.isAscending() ^ previous) {
496 query.append(ORDER_BY_ASC_HAS_NEXT);
497 }
498 else {
499 query.append(ORDER_BY_DESC_HAS_NEXT);
500 }
501 }
502 else {
503 if (orderByComparator.isAscending() ^ previous) {
504 query.append(ORDER_BY_ASC);
505 }
506 else {
507 query.append(ORDER_BY_DESC);
508 }
509 }
510 }
511 }
512 else {
513 query.append(ExportImportConfigurationModelImpl.ORDER_BY_JPQL);
514 }
515
516 String sql = query.toString();
517
518 Query q = session.createQuery(sql);
519
520 q.setFirstResult(0);
521 q.setMaxResults(2);
522
523 QueryPos qPos = QueryPos.getInstance(q);
524
525 qPos.add(groupId);
526
527 if (orderByComparator != null) {
528 Object[] values = orderByComparator.getOrderByConditionValues(exportImportConfiguration);
529
530 for (Object value : values) {
531 qPos.add(value);
532 }
533 }
534
535 List<ExportImportConfiguration> list = q.list();
536
537 if (list.size() == 2) {
538 return list.get(1);
539 }
540 else {
541 return null;
542 }
543 }
544
545
550 @Override
551 public void removeByGroupId(long groupId) {
552 for (ExportImportConfiguration exportImportConfiguration : findByGroupId(
553 groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
554 remove(exportImportConfiguration);
555 }
556 }
557
558
564 @Override
565 public int countByGroupId(long groupId) {
566 FinderPath finderPath = FINDER_PATH_COUNT_BY_GROUPID;
567
568 Object[] finderArgs = new Object[] { groupId };
569
570 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
571
572 if (count == null) {
573 StringBundler query = new StringBundler(2);
574
575 query.append(_SQL_COUNT_EXPORTIMPORTCONFIGURATION_WHERE);
576
577 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
578
579 String sql = query.toString();
580
581 Session session = null;
582
583 try {
584 session = openSession();
585
586 Query q = session.createQuery(sql);
587
588 QueryPos qPos = QueryPos.getInstance(q);
589
590 qPos.add(groupId);
591
592 count = (Long)q.uniqueResult();
593
594 finderCache.putResult(finderPath, finderArgs, count);
595 }
596 catch (Exception e) {
597 finderCache.removeResult(finderPath, finderArgs);
598
599 throw processException(e);
600 }
601 finally {
602 closeSession(session);
603 }
604 }
605
606 return count.intValue();
607 }
608
609 private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "exportImportConfiguration.groupId = ?";
610 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID =
611 new FinderPath(ExportImportConfigurationModelImpl.ENTITY_CACHE_ENABLED,
612 ExportImportConfigurationModelImpl.FINDER_CACHE_ENABLED,
613 ExportImportConfigurationImpl.class,
614 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByCompanyId",
615 new String[] {
616 Long.class.getName(),
617
618 Integer.class.getName(), Integer.class.getName(),
619 OrderByComparator.class.getName()
620 });
621 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID =
622 new FinderPath(ExportImportConfigurationModelImpl.ENTITY_CACHE_ENABLED,
623 ExportImportConfigurationModelImpl.FINDER_CACHE_ENABLED,
624 ExportImportConfigurationImpl.class,
625 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCompanyId",
626 new String[] { Long.class.getName() },
627 ExportImportConfigurationModelImpl.COMPANYID_COLUMN_BITMASK |
628 ExportImportConfigurationModelImpl.CREATEDATE_COLUMN_BITMASK);
629 public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(ExportImportConfigurationModelImpl.ENTITY_CACHE_ENABLED,
630 ExportImportConfigurationModelImpl.FINDER_CACHE_ENABLED,
631 Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
632 "countByCompanyId", new String[] { Long.class.getName() });
633
634
640 @Override
641 public List<ExportImportConfiguration> findByCompanyId(long companyId) {
642 return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
643 null);
644 }
645
646
658 @Override
659 public List<ExportImportConfiguration> findByCompanyId(long companyId,
660 int start, int end) {
661 return findByCompanyId(companyId, start, end, null);
662 }
663
664
677 @Override
678 public List<ExportImportConfiguration> findByCompanyId(long companyId,
679 int start, int end,
680 OrderByComparator<ExportImportConfiguration> orderByComparator) {
681 return findByCompanyId(companyId, start, end, orderByComparator, true);
682 }
683
684
698 @Override
699 public List<ExportImportConfiguration> findByCompanyId(long companyId,
700 int start, int end,
701 OrderByComparator<ExportImportConfiguration> orderByComparator,
702 boolean retrieveFromCache) {
703 boolean pagination = true;
704 FinderPath finderPath = null;
705 Object[] finderArgs = null;
706
707 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
708 (orderByComparator == null)) {
709 pagination = false;
710 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID;
711 finderArgs = new Object[] { companyId };
712 }
713 else {
714 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID;
715 finderArgs = new Object[] { companyId, start, end, orderByComparator };
716 }
717
718 List<ExportImportConfiguration> list = null;
719
720 if (retrieveFromCache) {
721 list = (List<ExportImportConfiguration>)finderCache.getResult(finderPath,
722 finderArgs, this);
723
724 if ((list != null) && !list.isEmpty()) {
725 for (ExportImportConfiguration exportImportConfiguration : list) {
726 if ((companyId != exportImportConfiguration.getCompanyId())) {
727 list = null;
728
729 break;
730 }
731 }
732 }
733 }
734
735 if (list == null) {
736 StringBundler query = null;
737
738 if (orderByComparator != null) {
739 query = new StringBundler(3 +
740 (orderByComparator.getOrderByFields().length * 2));
741 }
742 else {
743 query = new StringBundler(3);
744 }
745
746 query.append(_SQL_SELECT_EXPORTIMPORTCONFIGURATION_WHERE);
747
748 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
749
750 if (orderByComparator != null) {
751 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
752 orderByComparator);
753 }
754 else
755 if (pagination) {
756 query.append(ExportImportConfigurationModelImpl.ORDER_BY_JPQL);
757 }
758
759 String sql = query.toString();
760
761 Session session = null;
762
763 try {
764 session = openSession();
765
766 Query q = session.createQuery(sql);
767
768 QueryPos qPos = QueryPos.getInstance(q);
769
770 qPos.add(companyId);
771
772 if (!pagination) {
773 list = (List<ExportImportConfiguration>)QueryUtil.list(q,
774 getDialect(), start, end, false);
775
776 Collections.sort(list);
777
778 list = Collections.unmodifiableList(list);
779 }
780 else {
781 list = (List<ExportImportConfiguration>)QueryUtil.list(q,
782 getDialect(), start, end);
783 }
784
785 cacheResult(list);
786
787 finderCache.putResult(finderPath, finderArgs, list);
788 }
789 catch (Exception e) {
790 finderCache.removeResult(finderPath, finderArgs);
791
792 throw processException(e);
793 }
794 finally {
795 closeSession(session);
796 }
797 }
798
799 return list;
800 }
801
802
810 @Override
811 public ExportImportConfiguration findByCompanyId_First(long companyId,
812 OrderByComparator<ExportImportConfiguration> orderByComparator)
813 throws NoSuchConfigurationException {
814 ExportImportConfiguration exportImportConfiguration = fetchByCompanyId_First(companyId,
815 orderByComparator);
816
817 if (exportImportConfiguration != null) {
818 return exportImportConfiguration;
819 }
820
821 StringBundler msg = new StringBundler(4);
822
823 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
824
825 msg.append("companyId=");
826 msg.append(companyId);
827
828 msg.append(StringPool.CLOSE_CURLY_BRACE);
829
830 throw new NoSuchConfigurationException(msg.toString());
831 }
832
833
840 @Override
841 public ExportImportConfiguration fetchByCompanyId_First(long companyId,
842 OrderByComparator<ExportImportConfiguration> orderByComparator) {
843 List<ExportImportConfiguration> list = findByCompanyId(companyId, 0, 1,
844 orderByComparator);
845
846 if (!list.isEmpty()) {
847 return list.get(0);
848 }
849
850 return null;
851 }
852
853
861 @Override
862 public ExportImportConfiguration findByCompanyId_Last(long companyId,
863 OrderByComparator<ExportImportConfiguration> orderByComparator)
864 throws NoSuchConfigurationException {
865 ExportImportConfiguration exportImportConfiguration = fetchByCompanyId_Last(companyId,
866 orderByComparator);
867
868 if (exportImportConfiguration != null) {
869 return exportImportConfiguration;
870 }
871
872 StringBundler msg = new StringBundler(4);
873
874 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
875
876 msg.append("companyId=");
877 msg.append(companyId);
878
879 msg.append(StringPool.CLOSE_CURLY_BRACE);
880
881 throw new NoSuchConfigurationException(msg.toString());
882 }
883
884
891 @Override
892 public ExportImportConfiguration fetchByCompanyId_Last(long companyId,
893 OrderByComparator<ExportImportConfiguration> orderByComparator) {
894 int count = countByCompanyId(companyId);
895
896 if (count == 0) {
897 return null;
898 }
899
900 List<ExportImportConfiguration> list = findByCompanyId(companyId,
901 count - 1, count, orderByComparator);
902
903 if (!list.isEmpty()) {
904 return list.get(0);
905 }
906
907 return null;
908 }
909
910
919 @Override
920 public ExportImportConfiguration[] findByCompanyId_PrevAndNext(
921 long exportImportConfigurationId, long companyId,
922 OrderByComparator<ExportImportConfiguration> orderByComparator)
923 throws NoSuchConfigurationException {
924 ExportImportConfiguration exportImportConfiguration = findByPrimaryKey(exportImportConfigurationId);
925
926 Session session = null;
927
928 try {
929 session = openSession();
930
931 ExportImportConfiguration[] array = new ExportImportConfigurationImpl[3];
932
933 array[0] = getByCompanyId_PrevAndNext(session,
934 exportImportConfiguration, companyId, orderByComparator,
935 true);
936
937 array[1] = exportImportConfiguration;
938
939 array[2] = getByCompanyId_PrevAndNext(session,
940 exportImportConfiguration, companyId, orderByComparator,
941 false);
942
943 return array;
944 }
945 catch (Exception e) {
946 throw processException(e);
947 }
948 finally {
949 closeSession(session);
950 }
951 }
952
953 protected ExportImportConfiguration getByCompanyId_PrevAndNext(
954 Session session, ExportImportConfiguration exportImportConfiguration,
955 long companyId,
956 OrderByComparator<ExportImportConfiguration> orderByComparator,
957 boolean previous) {
958 StringBundler query = null;
959
960 if (orderByComparator != null) {
961 query = new StringBundler(4 +
962 (orderByComparator.getOrderByConditionFields().length * 3) +
963 (orderByComparator.getOrderByFields().length * 3));
964 }
965 else {
966 query = new StringBundler(3);
967 }
968
969 query.append(_SQL_SELECT_EXPORTIMPORTCONFIGURATION_WHERE);
970
971 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
972
973 if (orderByComparator != null) {
974 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
975
976 if (orderByConditionFields.length > 0) {
977 query.append(WHERE_AND);
978 }
979
980 for (int i = 0; i < orderByConditionFields.length; i++) {
981 query.append(_ORDER_BY_ENTITY_ALIAS);
982 query.append(orderByConditionFields[i]);
983
984 if ((i + 1) < orderByConditionFields.length) {
985 if (orderByComparator.isAscending() ^ previous) {
986 query.append(WHERE_GREATER_THAN_HAS_NEXT);
987 }
988 else {
989 query.append(WHERE_LESSER_THAN_HAS_NEXT);
990 }
991 }
992 else {
993 if (orderByComparator.isAscending() ^ previous) {
994 query.append(WHERE_GREATER_THAN);
995 }
996 else {
997 query.append(WHERE_LESSER_THAN);
998 }
999 }
1000 }
1001
1002 query.append(ORDER_BY_CLAUSE);
1003
1004 String[] orderByFields = orderByComparator.getOrderByFields();
1005
1006 for (int i = 0; i < orderByFields.length; i++) {
1007 query.append(_ORDER_BY_ENTITY_ALIAS);
1008 query.append(orderByFields[i]);
1009
1010 if ((i + 1) < orderByFields.length) {
1011 if (orderByComparator.isAscending() ^ previous) {
1012 query.append(ORDER_BY_ASC_HAS_NEXT);
1013 }
1014 else {
1015 query.append(ORDER_BY_DESC_HAS_NEXT);
1016 }
1017 }
1018 else {
1019 if (orderByComparator.isAscending() ^ previous) {
1020 query.append(ORDER_BY_ASC);
1021 }
1022 else {
1023 query.append(ORDER_BY_DESC);
1024 }
1025 }
1026 }
1027 }
1028 else {
1029 query.append(ExportImportConfigurationModelImpl.ORDER_BY_JPQL);
1030 }
1031
1032 String sql = query.toString();
1033
1034 Query q = session.createQuery(sql);
1035
1036 q.setFirstResult(0);
1037 q.setMaxResults(2);
1038
1039 QueryPos qPos = QueryPos.getInstance(q);
1040
1041 qPos.add(companyId);
1042
1043 if (orderByComparator != null) {
1044 Object[] values = orderByComparator.getOrderByConditionValues(exportImportConfiguration);
1045
1046 for (Object value : values) {
1047 qPos.add(value);
1048 }
1049 }
1050
1051 List<ExportImportConfiguration> list = q.list();
1052
1053 if (list.size() == 2) {
1054 return list.get(1);
1055 }
1056 else {
1057 return null;
1058 }
1059 }
1060
1061
1066 @Override
1067 public void removeByCompanyId(long companyId) {
1068 for (ExportImportConfiguration exportImportConfiguration : findByCompanyId(
1069 companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1070 remove(exportImportConfiguration);
1071 }
1072 }
1073
1074
1080 @Override
1081 public int countByCompanyId(long companyId) {
1082 FinderPath finderPath = FINDER_PATH_COUNT_BY_COMPANYID;
1083
1084 Object[] finderArgs = new Object[] { companyId };
1085
1086 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
1087
1088 if (count == null) {
1089 StringBundler query = new StringBundler(2);
1090
1091 query.append(_SQL_COUNT_EXPORTIMPORTCONFIGURATION_WHERE);
1092
1093 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1094
1095 String sql = query.toString();
1096
1097 Session session = null;
1098
1099 try {
1100 session = openSession();
1101
1102 Query q = session.createQuery(sql);
1103
1104 QueryPos qPos = QueryPos.getInstance(q);
1105
1106 qPos.add(companyId);
1107
1108 count = (Long)q.uniqueResult();
1109
1110 finderCache.putResult(finderPath, finderArgs, count);
1111 }
1112 catch (Exception e) {
1113 finderCache.removeResult(finderPath, finderArgs);
1114
1115 throw processException(e);
1116 }
1117 finally {
1118 closeSession(session);
1119 }
1120 }
1121
1122 return count.intValue();
1123 }
1124
1125 private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "exportImportConfiguration.companyId = ?";
1126 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_T = new FinderPath(ExportImportConfigurationModelImpl.ENTITY_CACHE_ENABLED,
1127 ExportImportConfigurationModelImpl.FINDER_CACHE_ENABLED,
1128 ExportImportConfigurationImpl.class,
1129 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_T",
1130 new String[] {
1131 Long.class.getName(), Integer.class.getName(),
1132
1133 Integer.class.getName(), Integer.class.getName(),
1134 OrderByComparator.class.getName()
1135 });
1136 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_T = new FinderPath(ExportImportConfigurationModelImpl.ENTITY_CACHE_ENABLED,
1137 ExportImportConfigurationModelImpl.FINDER_CACHE_ENABLED,
1138 ExportImportConfigurationImpl.class,
1139 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_T",
1140 new String[] { Long.class.getName(), Integer.class.getName() },
1141 ExportImportConfigurationModelImpl.GROUPID_COLUMN_BITMASK |
1142 ExportImportConfigurationModelImpl.TYPE_COLUMN_BITMASK |
1143 ExportImportConfigurationModelImpl.CREATEDATE_COLUMN_BITMASK);
1144 public static final FinderPath FINDER_PATH_COUNT_BY_G_T = new FinderPath(ExportImportConfigurationModelImpl.ENTITY_CACHE_ENABLED,
1145 ExportImportConfigurationModelImpl.FINDER_CACHE_ENABLED,
1146 Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
1147 "countByG_T",
1148 new String[] { Long.class.getName(), Integer.class.getName() });
1149
1150
1157 @Override
1158 public List<ExportImportConfiguration> findByG_T(long groupId, int type) {
1159 return findByG_T(groupId, type, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
1160 null);
1161 }
1162
1163
1176 @Override
1177 public List<ExportImportConfiguration> findByG_T(long groupId, int type,
1178 int start, int end) {
1179 return findByG_T(groupId, type, start, end, null);
1180 }
1181
1182
1196 @Override
1197 public List<ExportImportConfiguration> findByG_T(long groupId, int type,
1198 int start, int end,
1199 OrderByComparator<ExportImportConfiguration> orderByComparator) {
1200 return findByG_T(groupId, type, start, end, orderByComparator, true);
1201 }
1202
1203
1218 @Override
1219 public List<ExportImportConfiguration> findByG_T(long groupId, int type,
1220 int start, int end,
1221 OrderByComparator<ExportImportConfiguration> orderByComparator,
1222 boolean retrieveFromCache) {
1223 boolean pagination = true;
1224 FinderPath finderPath = null;
1225 Object[] finderArgs = null;
1226
1227 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1228 (orderByComparator == null)) {
1229 pagination = false;
1230 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_T;
1231 finderArgs = new Object[] { groupId, type };
1232 }
1233 else {
1234 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_T;
1235 finderArgs = new Object[] {
1236 groupId, type,
1237
1238 start, end, orderByComparator
1239 };
1240 }
1241
1242 List<ExportImportConfiguration> list = null;
1243
1244 if (retrieveFromCache) {
1245 list = (List<ExportImportConfiguration>)finderCache.getResult(finderPath,
1246 finderArgs, this);
1247
1248 if ((list != null) && !list.isEmpty()) {
1249 for (ExportImportConfiguration exportImportConfiguration : list) {
1250 if ((groupId != exportImportConfiguration.getGroupId()) ||
1251 (type != exportImportConfiguration.getType())) {
1252 list = null;
1253
1254 break;
1255 }
1256 }
1257 }
1258 }
1259
1260 if (list == null) {
1261 StringBundler query = null;
1262
1263 if (orderByComparator != null) {
1264 query = new StringBundler(4 +
1265 (orderByComparator.getOrderByFields().length * 2));
1266 }
1267 else {
1268 query = new StringBundler(4);
1269 }
1270
1271 query.append(_SQL_SELECT_EXPORTIMPORTCONFIGURATION_WHERE);
1272
1273 query.append(_FINDER_COLUMN_G_T_GROUPID_2);
1274
1275 query.append(_FINDER_COLUMN_G_T_TYPE_2);
1276
1277 if (orderByComparator != null) {
1278 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1279 orderByComparator);
1280 }
1281 else
1282 if (pagination) {
1283 query.append(ExportImportConfigurationModelImpl.ORDER_BY_JPQL);
1284 }
1285
1286 String sql = query.toString();
1287
1288 Session session = null;
1289
1290 try {
1291 session = openSession();
1292
1293 Query q = session.createQuery(sql);
1294
1295 QueryPos qPos = QueryPos.getInstance(q);
1296
1297 qPos.add(groupId);
1298
1299 qPos.add(type);
1300
1301 if (!pagination) {
1302 list = (List<ExportImportConfiguration>)QueryUtil.list(q,
1303 getDialect(), start, end, false);
1304
1305 Collections.sort(list);
1306
1307 list = Collections.unmodifiableList(list);
1308 }
1309 else {
1310 list = (List<ExportImportConfiguration>)QueryUtil.list(q,
1311 getDialect(), start, end);
1312 }
1313
1314 cacheResult(list);
1315
1316 finderCache.putResult(finderPath, finderArgs, list);
1317 }
1318 catch (Exception e) {
1319 finderCache.removeResult(finderPath, finderArgs);
1320
1321 throw processException(e);
1322 }
1323 finally {
1324 closeSession(session);
1325 }
1326 }
1327
1328 return list;
1329 }
1330
1331
1340 @Override
1341 public ExportImportConfiguration findByG_T_First(long groupId, int type,
1342 OrderByComparator<ExportImportConfiguration> orderByComparator)
1343 throws NoSuchConfigurationException {
1344 ExportImportConfiguration exportImportConfiguration = fetchByG_T_First(groupId,
1345 type, orderByComparator);
1346
1347 if (exportImportConfiguration != null) {
1348 return exportImportConfiguration;
1349 }
1350
1351 StringBundler msg = new StringBundler(6);
1352
1353 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1354
1355 msg.append("groupId=");
1356 msg.append(groupId);
1357
1358 msg.append(", type=");
1359 msg.append(type);
1360
1361 msg.append(StringPool.CLOSE_CURLY_BRACE);
1362
1363 throw new NoSuchConfigurationException(msg.toString());
1364 }
1365
1366
1374 @Override
1375 public ExportImportConfiguration fetchByG_T_First(long groupId, int type,
1376 OrderByComparator<ExportImportConfiguration> orderByComparator) {
1377 List<ExportImportConfiguration> list = findByG_T(groupId, type, 0, 1,
1378 orderByComparator);
1379
1380 if (!list.isEmpty()) {
1381 return list.get(0);
1382 }
1383
1384 return null;
1385 }
1386
1387
1396 @Override
1397 public ExportImportConfiguration findByG_T_Last(long groupId, int type,
1398 OrderByComparator<ExportImportConfiguration> orderByComparator)
1399 throws NoSuchConfigurationException {
1400 ExportImportConfiguration exportImportConfiguration = fetchByG_T_Last(groupId,
1401 type, orderByComparator);
1402
1403 if (exportImportConfiguration != null) {
1404 return exportImportConfiguration;
1405 }
1406
1407 StringBundler msg = new StringBundler(6);
1408
1409 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1410
1411 msg.append("groupId=");
1412 msg.append(groupId);
1413
1414 msg.append(", type=");
1415 msg.append(type);
1416
1417 msg.append(StringPool.CLOSE_CURLY_BRACE);
1418
1419 throw new NoSuchConfigurationException(msg.toString());
1420 }
1421
1422
1430 @Override
1431 public ExportImportConfiguration fetchByG_T_Last(long groupId, int type,
1432 OrderByComparator<ExportImportConfiguration> orderByComparator) {
1433 int count = countByG_T(groupId, type);
1434
1435 if (count == 0) {
1436 return null;
1437 }
1438
1439 List<ExportImportConfiguration> list = findByG_T(groupId, type,
1440 count - 1, count, orderByComparator);
1441
1442 if (!list.isEmpty()) {
1443 return list.get(0);
1444 }
1445
1446 return null;
1447 }
1448
1449
1459 @Override
1460 public ExportImportConfiguration[] findByG_T_PrevAndNext(
1461 long exportImportConfigurationId, long groupId, int type,
1462 OrderByComparator<ExportImportConfiguration> orderByComparator)
1463 throws NoSuchConfigurationException {
1464 ExportImportConfiguration exportImportConfiguration = findByPrimaryKey(exportImportConfigurationId);
1465
1466 Session session = null;
1467
1468 try {
1469 session = openSession();
1470
1471 ExportImportConfiguration[] array = new ExportImportConfigurationImpl[3];
1472
1473 array[0] = getByG_T_PrevAndNext(session, exportImportConfiguration,
1474 groupId, type, orderByComparator, true);
1475
1476 array[1] = exportImportConfiguration;
1477
1478 array[2] = getByG_T_PrevAndNext(session, exportImportConfiguration,
1479 groupId, type, orderByComparator, false);
1480
1481 return array;
1482 }
1483 catch (Exception e) {
1484 throw processException(e);
1485 }
1486 finally {
1487 closeSession(session);
1488 }
1489 }
1490
1491 protected ExportImportConfiguration getByG_T_PrevAndNext(Session session,
1492 ExportImportConfiguration exportImportConfiguration, long groupId,
1493 int type,
1494 OrderByComparator<ExportImportConfiguration> orderByComparator,
1495 boolean previous) {
1496 StringBundler query = null;
1497
1498 if (orderByComparator != null) {
1499 query = new StringBundler(5 +
1500 (orderByComparator.getOrderByConditionFields().length * 3) +
1501 (orderByComparator.getOrderByFields().length * 3));
1502 }
1503 else {
1504 query = new StringBundler(4);
1505 }
1506
1507 query.append(_SQL_SELECT_EXPORTIMPORTCONFIGURATION_WHERE);
1508
1509 query.append(_FINDER_COLUMN_G_T_GROUPID_2);
1510
1511 query.append(_FINDER_COLUMN_G_T_TYPE_2);
1512
1513 if (orderByComparator != null) {
1514 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1515
1516 if (orderByConditionFields.length > 0) {
1517 query.append(WHERE_AND);
1518 }
1519
1520 for (int i = 0; i < orderByConditionFields.length; i++) {
1521 query.append(_ORDER_BY_ENTITY_ALIAS);
1522 query.append(orderByConditionFields[i]);
1523
1524 if ((i + 1) < orderByConditionFields.length) {
1525 if (orderByComparator.isAscending() ^ previous) {
1526 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1527 }
1528 else {
1529 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1530 }
1531 }
1532 else {
1533 if (orderByComparator.isAscending() ^ previous) {
1534 query.append(WHERE_GREATER_THAN);
1535 }
1536 else {
1537 query.append(WHERE_LESSER_THAN);
1538 }
1539 }
1540 }
1541
1542 query.append(ORDER_BY_CLAUSE);
1543
1544 String[] orderByFields = orderByComparator.getOrderByFields();
1545
1546 for (int i = 0; i < orderByFields.length; i++) {
1547 query.append(_ORDER_BY_ENTITY_ALIAS);
1548 query.append(orderByFields[i]);
1549
1550 if ((i + 1) < orderByFields.length) {
1551 if (orderByComparator.isAscending() ^ previous) {
1552 query.append(ORDER_BY_ASC_HAS_NEXT);
1553 }
1554 else {
1555 query.append(ORDER_BY_DESC_HAS_NEXT);
1556 }
1557 }
1558 else {
1559 if (orderByComparator.isAscending() ^ previous) {
1560 query.append(ORDER_BY_ASC);
1561 }
1562 else {
1563 query.append(ORDER_BY_DESC);
1564 }
1565 }
1566 }
1567 }
1568 else {
1569 query.append(ExportImportConfigurationModelImpl.ORDER_BY_JPQL);
1570 }
1571
1572 String sql = query.toString();
1573
1574 Query q = session.createQuery(sql);
1575
1576 q.setFirstResult(0);
1577 q.setMaxResults(2);
1578
1579 QueryPos qPos = QueryPos.getInstance(q);
1580
1581 qPos.add(groupId);
1582
1583 qPos.add(type);
1584
1585 if (orderByComparator != null) {
1586 Object[] values = orderByComparator.getOrderByConditionValues(exportImportConfiguration);
1587
1588 for (Object value : values) {
1589 qPos.add(value);
1590 }
1591 }
1592
1593 List<ExportImportConfiguration> list = q.list();
1594
1595 if (list.size() == 2) {
1596 return list.get(1);
1597 }
1598 else {
1599 return null;
1600 }
1601 }
1602
1603
1609 @Override
1610 public void removeByG_T(long groupId, int type) {
1611 for (ExportImportConfiguration exportImportConfiguration : findByG_T(
1612 groupId, type, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1613 remove(exportImportConfiguration);
1614 }
1615 }
1616
1617
1624 @Override
1625 public int countByG_T(long groupId, int type) {
1626 FinderPath finderPath = FINDER_PATH_COUNT_BY_G_T;
1627
1628 Object[] finderArgs = new Object[] { groupId, type };
1629
1630 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
1631
1632 if (count == null) {
1633 StringBundler query = new StringBundler(3);
1634
1635 query.append(_SQL_COUNT_EXPORTIMPORTCONFIGURATION_WHERE);
1636
1637 query.append(_FINDER_COLUMN_G_T_GROUPID_2);
1638
1639 query.append(_FINDER_COLUMN_G_T_TYPE_2);
1640
1641 String sql = query.toString();
1642
1643 Session session = null;
1644
1645 try {
1646 session = openSession();
1647
1648 Query q = session.createQuery(sql);
1649
1650 QueryPos qPos = QueryPos.getInstance(q);
1651
1652 qPos.add(groupId);
1653
1654 qPos.add(type);
1655
1656 count = (Long)q.uniqueResult();
1657
1658 finderCache.putResult(finderPath, finderArgs, count);
1659 }
1660 catch (Exception e) {
1661 finderCache.removeResult(finderPath, finderArgs);
1662
1663 throw processException(e);
1664 }
1665 finally {
1666 closeSession(session);
1667 }
1668 }
1669
1670 return count.intValue();
1671 }
1672
1673 private static final String _FINDER_COLUMN_G_T_GROUPID_2 = "exportImportConfiguration.groupId = ? AND ";
1674 private static final String _FINDER_COLUMN_G_T_TYPE_2 = "exportImportConfiguration.type = ?";
1675 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_S = new FinderPath(ExportImportConfigurationModelImpl.ENTITY_CACHE_ENABLED,
1676 ExportImportConfigurationModelImpl.FINDER_CACHE_ENABLED,
1677 ExportImportConfigurationImpl.class,
1678 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_S",
1679 new String[] {
1680 Long.class.getName(), Integer.class.getName(),
1681
1682 Integer.class.getName(), Integer.class.getName(),
1683 OrderByComparator.class.getName()
1684 });
1685 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S = new FinderPath(ExportImportConfigurationModelImpl.ENTITY_CACHE_ENABLED,
1686 ExportImportConfigurationModelImpl.FINDER_CACHE_ENABLED,
1687 ExportImportConfigurationImpl.class,
1688 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_S",
1689 new String[] { Long.class.getName(), Integer.class.getName() },
1690 ExportImportConfigurationModelImpl.GROUPID_COLUMN_BITMASK |
1691 ExportImportConfigurationModelImpl.STATUS_COLUMN_BITMASK |
1692 ExportImportConfigurationModelImpl.CREATEDATE_COLUMN_BITMASK);
1693 public static final FinderPath FINDER_PATH_COUNT_BY_G_S = new FinderPath(ExportImportConfigurationModelImpl.ENTITY_CACHE_ENABLED,
1694 ExportImportConfigurationModelImpl.FINDER_CACHE_ENABLED,
1695 Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
1696 "countByG_S",
1697 new String[] { Long.class.getName(), Integer.class.getName() });
1698
1699
1706 @Override
1707 public List<ExportImportConfiguration> findByG_S(long groupId, int status) {
1708 return findByG_S(groupId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
1709 null);
1710 }
1711
1712
1725 @Override
1726 public List<ExportImportConfiguration> findByG_S(long groupId, int status,
1727 int start, int end) {
1728 return findByG_S(groupId, status, start, end, null);
1729 }
1730
1731
1745 @Override
1746 public List<ExportImportConfiguration> findByG_S(long groupId, int status,
1747 int start, int end,
1748 OrderByComparator<ExportImportConfiguration> orderByComparator) {
1749 return findByG_S(groupId, status, start, end, orderByComparator, true);
1750 }
1751
1752
1767 @Override
1768 public List<ExportImportConfiguration> findByG_S(long groupId, int status,
1769 int start, int end,
1770 OrderByComparator<ExportImportConfiguration> orderByComparator,
1771 boolean retrieveFromCache) {
1772 boolean pagination = true;
1773 FinderPath finderPath = null;
1774 Object[] finderArgs = null;
1775
1776 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1777 (orderByComparator == null)) {
1778 pagination = false;
1779 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S;
1780 finderArgs = new Object[] { groupId, status };
1781 }
1782 else {
1783 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_S;
1784 finderArgs = new Object[] {
1785 groupId, status,
1786
1787 start, end, orderByComparator
1788 };
1789 }
1790
1791 List<ExportImportConfiguration> list = null;
1792
1793 if (retrieveFromCache) {
1794 list = (List<ExportImportConfiguration>)finderCache.getResult(finderPath,
1795 finderArgs, this);
1796
1797 if ((list != null) && !list.isEmpty()) {
1798 for (ExportImportConfiguration exportImportConfiguration : list) {
1799 if ((groupId != exportImportConfiguration.getGroupId()) ||
1800 (status != exportImportConfiguration.getStatus())) {
1801 list = null;
1802
1803 break;
1804 }
1805 }
1806 }
1807 }
1808
1809 if (list == null) {
1810 StringBundler query = null;
1811
1812 if (orderByComparator != null) {
1813 query = new StringBundler(4 +
1814 (orderByComparator.getOrderByFields().length * 2));
1815 }
1816 else {
1817 query = new StringBundler(4);
1818 }
1819
1820 query.append(_SQL_SELECT_EXPORTIMPORTCONFIGURATION_WHERE);
1821
1822 query.append(_FINDER_COLUMN_G_S_GROUPID_2);
1823
1824 query.append(_FINDER_COLUMN_G_S_STATUS_2);
1825
1826 if (orderByComparator != null) {
1827 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1828 orderByComparator);
1829 }
1830 else
1831 if (pagination) {
1832 query.append(ExportImportConfigurationModelImpl.ORDER_BY_JPQL);
1833 }
1834
1835 String sql = query.toString();
1836
1837 Session session = null;
1838
1839 try {
1840 session = openSession();
1841
1842 Query q = session.createQuery(sql);
1843
1844 QueryPos qPos = QueryPos.getInstance(q);
1845
1846 qPos.add(groupId);
1847
1848 qPos.add(status);
1849
1850 if (!pagination) {
1851 list = (List<ExportImportConfiguration>)QueryUtil.list(q,
1852 getDialect(), start, end, false);
1853
1854 Collections.sort(list);
1855
1856 list = Collections.unmodifiableList(list);
1857 }
1858 else {
1859 list = (List<ExportImportConfiguration>)QueryUtil.list(q,
1860 getDialect(), start, end);
1861 }
1862
1863 cacheResult(list);
1864
1865 finderCache.putResult(finderPath, finderArgs, list);
1866 }
1867 catch (Exception e) {
1868 finderCache.removeResult(finderPath, finderArgs);
1869
1870 throw processException(e);
1871 }
1872 finally {
1873 closeSession(session);
1874 }
1875 }
1876
1877 return list;
1878 }
1879
1880
1889 @Override
1890 public ExportImportConfiguration findByG_S_First(long groupId, int status,
1891 OrderByComparator<ExportImportConfiguration> orderByComparator)
1892 throws NoSuchConfigurationException {
1893 ExportImportConfiguration exportImportConfiguration = fetchByG_S_First(groupId,
1894 status, orderByComparator);
1895
1896 if (exportImportConfiguration != null) {
1897 return exportImportConfiguration;
1898 }
1899
1900 StringBundler msg = new StringBundler(6);
1901
1902 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1903
1904 msg.append("groupId=");
1905 msg.append(groupId);
1906
1907 msg.append(", status=");
1908 msg.append(status);
1909
1910 msg.append(StringPool.CLOSE_CURLY_BRACE);
1911
1912 throw new NoSuchConfigurationException(msg.toString());
1913 }
1914
1915
1923 @Override
1924 public ExportImportConfiguration fetchByG_S_First(long groupId, int status,
1925 OrderByComparator<ExportImportConfiguration> orderByComparator) {
1926 List<ExportImportConfiguration> list = findByG_S(groupId, status, 0, 1,
1927 orderByComparator);
1928
1929 if (!list.isEmpty()) {
1930 return list.get(0);
1931 }
1932
1933 return null;
1934 }
1935
1936
1945 @Override
1946 public ExportImportConfiguration findByG_S_Last(long groupId, int status,
1947 OrderByComparator<ExportImportConfiguration> orderByComparator)
1948 throws NoSuchConfigurationException {
1949 ExportImportConfiguration exportImportConfiguration = fetchByG_S_Last(groupId,
1950 status, orderByComparator);
1951
1952 if (exportImportConfiguration != null) {
1953 return exportImportConfiguration;
1954 }
1955
1956 StringBundler msg = new StringBundler(6);
1957
1958 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1959
1960 msg.append("groupId=");
1961 msg.append(groupId);
1962
1963 msg.append(", status=");
1964 msg.append(status);
1965
1966 msg.append(StringPool.CLOSE_CURLY_BRACE);
1967
1968 throw new NoSuchConfigurationException(msg.toString());
1969 }
1970
1971
1979 @Override
1980 public ExportImportConfiguration fetchByG_S_Last(long groupId, int status,
1981 OrderByComparator<ExportImportConfiguration> orderByComparator) {
1982 int count = countByG_S(groupId, status);
1983
1984 if (count == 0) {
1985 return null;
1986 }
1987
1988 List<ExportImportConfiguration> list = findByG_S(groupId, status,
1989 count - 1, count, orderByComparator);
1990
1991 if (!list.isEmpty()) {
1992 return list.get(0);
1993 }
1994
1995 return null;
1996 }
1997
1998
2008 @Override
2009 public ExportImportConfiguration[] findByG_S_PrevAndNext(
2010 long exportImportConfigurationId, long groupId, int status,
2011 OrderByComparator<ExportImportConfiguration> orderByComparator)
2012 throws NoSuchConfigurationException {
2013 ExportImportConfiguration exportImportConfiguration = findByPrimaryKey(exportImportConfigurationId);
2014
2015 Session session = null;
2016
2017 try {
2018 session = openSession();
2019
2020 ExportImportConfiguration[] array = new ExportImportConfigurationImpl[3];
2021
2022 array[0] = getByG_S_PrevAndNext(session, exportImportConfiguration,
2023 groupId, status, orderByComparator, true);
2024
2025 array[1] = exportImportConfiguration;
2026
2027 array[2] = getByG_S_PrevAndNext(session, exportImportConfiguration,
2028 groupId, status, orderByComparator, false);
2029
2030 return array;
2031 }
2032 catch (Exception e) {
2033 throw processException(e);
2034 }
2035 finally {
2036 closeSession(session);
2037 }
2038 }
2039
2040 protected ExportImportConfiguration getByG_S_PrevAndNext(Session session,
2041 ExportImportConfiguration exportImportConfiguration, long groupId,
2042 int status,
2043 OrderByComparator<ExportImportConfiguration> orderByComparator,
2044 boolean previous) {
2045 StringBundler query = null;
2046
2047 if (orderByComparator != null) {
2048 query = new StringBundler(5 +
2049 (orderByComparator.getOrderByConditionFields().length * 3) +
2050 (orderByComparator.getOrderByFields().length * 3));
2051 }
2052 else {
2053 query = new StringBundler(4);
2054 }
2055
2056 query.append(_SQL_SELECT_EXPORTIMPORTCONFIGURATION_WHERE);
2057
2058 query.append(_FINDER_COLUMN_G_S_GROUPID_2);
2059
2060 query.append(_FINDER_COLUMN_G_S_STATUS_2);
2061
2062 if (orderByComparator != null) {
2063 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2064
2065 if (orderByConditionFields.length > 0) {
2066 query.append(WHERE_AND);
2067 }
2068
2069 for (int i = 0; i < orderByConditionFields.length; i++) {
2070 query.append(_ORDER_BY_ENTITY_ALIAS);
2071 query.append(orderByConditionFields[i]);
2072
2073 if ((i + 1) < orderByConditionFields.length) {
2074 if (orderByComparator.isAscending() ^ previous) {
2075 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2076 }
2077 else {
2078 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2079 }
2080 }
2081 else {
2082 if (orderByComparator.isAscending() ^ previous) {
2083 query.append(WHERE_GREATER_THAN);
2084 }
2085 else {
2086 query.append(WHERE_LESSER_THAN);
2087 }
2088 }
2089 }
2090
2091 query.append(ORDER_BY_CLAUSE);
2092
2093 String[] orderByFields = orderByComparator.getOrderByFields();
2094
2095 for (int i = 0; i < orderByFields.length; i++) {
2096 query.append(_ORDER_BY_ENTITY_ALIAS);
2097 query.append(orderByFields[i]);
2098
2099 if ((i + 1) < orderByFields.length) {
2100 if (orderByComparator.isAscending() ^ previous) {
2101 query.append(ORDER_BY_ASC_HAS_NEXT);
2102 }
2103 else {
2104 query.append(ORDER_BY_DESC_HAS_NEXT);
2105 }
2106 }
2107 else {
2108 if (orderByComparator.isAscending() ^ previous) {
2109 query.append(ORDER_BY_ASC);
2110 }
2111 else {
2112 query.append(ORDER_BY_DESC);
2113 }
2114 }
2115 }
2116 }
2117 else {
2118 query.append(ExportImportConfigurationModelImpl.ORDER_BY_JPQL);
2119 }
2120
2121 String sql = query.toString();
2122
2123 Query q = session.createQuery(sql);
2124
2125 q.setFirstResult(0);
2126 q.setMaxResults(2);
2127
2128 QueryPos qPos = QueryPos.getInstance(q);
2129
2130 qPos.add(groupId);
2131
2132 qPos.add(status);
2133
2134 if (orderByComparator != null) {
2135 Object[] values = orderByComparator.getOrderByConditionValues(exportImportConfiguration);
2136
2137 for (Object value : values) {
2138 qPos.add(value);
2139 }
2140 }
2141
2142 List<ExportImportConfiguration> list = q.list();
2143
2144 if (list.size() == 2) {
2145 return list.get(1);
2146 }
2147 else {
2148 return null;
2149 }
2150 }
2151
2152
2158 @Override
2159 public void removeByG_S(long groupId, int status) {
2160 for (ExportImportConfiguration exportImportConfiguration : findByG_S(
2161 groupId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
2162 remove(exportImportConfiguration);
2163 }
2164 }
2165
2166
2173 @Override
2174 public int countByG_S(long groupId, int status) {
2175 FinderPath finderPath = FINDER_PATH_COUNT_BY_G_S;
2176
2177 Object[] finderArgs = new Object[] { groupId, status };
2178
2179 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
2180
2181 if (count == null) {
2182 StringBundler query = new StringBundler(3);
2183
2184 query.append(_SQL_COUNT_EXPORTIMPORTCONFIGURATION_WHERE);
2185
2186 query.append(_FINDER_COLUMN_G_S_GROUPID_2);
2187
2188 query.append(_FINDER_COLUMN_G_S_STATUS_2);
2189
2190 String sql = query.toString();
2191
2192 Session session = null;
2193
2194 try {
2195 session = openSession();
2196
2197 Query q = session.createQuery(sql);
2198
2199 QueryPos qPos = QueryPos.getInstance(q);
2200
2201 qPos.add(groupId);
2202
2203 qPos.add(status);
2204
2205 count = (Long)q.uniqueResult();
2206
2207 finderCache.putResult(finderPath, finderArgs, count);
2208 }
2209 catch (Exception e) {
2210 finderCache.removeResult(finderPath, finderArgs);
2211
2212 throw processException(e);
2213 }
2214 finally {
2215 closeSession(session);
2216 }
2217 }
2218
2219 return count.intValue();
2220 }
2221
2222 private static final String _FINDER_COLUMN_G_S_GROUPID_2 = "exportImportConfiguration.groupId = ? AND ";
2223 private static final String _FINDER_COLUMN_G_S_STATUS_2 = "exportImportConfiguration.status = ?";
2224 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_T_S = new FinderPath(ExportImportConfigurationModelImpl.ENTITY_CACHE_ENABLED,
2225 ExportImportConfigurationModelImpl.FINDER_CACHE_ENABLED,
2226 ExportImportConfigurationImpl.class,
2227 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_T_S",
2228 new String[] {
2229 Long.class.getName(), Integer.class.getName(),
2230 Integer.class.getName(),
2231
2232 Integer.class.getName(), Integer.class.getName(),
2233 OrderByComparator.class.getName()
2234 });
2235 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_T_S = new FinderPath(ExportImportConfigurationModelImpl.ENTITY_CACHE_ENABLED,
2236 ExportImportConfigurationModelImpl.FINDER_CACHE_ENABLED,
2237 ExportImportConfigurationImpl.class,
2238 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_T_S",
2239 new String[] {
2240 Long.class.getName(), Integer.class.getName(),
2241 Integer.class.getName()
2242 },
2243 ExportImportConfigurationModelImpl.GROUPID_COLUMN_BITMASK |
2244 ExportImportConfigurationModelImpl.TYPE_COLUMN_BITMASK |
2245 ExportImportConfigurationModelImpl.STATUS_COLUMN_BITMASK |
2246 ExportImportConfigurationModelImpl.CREATEDATE_COLUMN_BITMASK);
2247 public static final FinderPath FINDER_PATH_COUNT_BY_G_T_S = new FinderPath(ExportImportConfigurationModelImpl.ENTITY_CACHE_ENABLED,
2248 ExportImportConfigurationModelImpl.FINDER_CACHE_ENABLED,
2249 Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
2250 "countByG_T_S",
2251 new String[] {
2252 Long.class.getName(), Integer.class.getName(),
2253 Integer.class.getName()
2254 });
2255
2256
2264 @Override
2265 public List<ExportImportConfiguration> findByG_T_S(long groupId, int type,
2266 int status) {
2267 return findByG_T_S(groupId, type, status, QueryUtil.ALL_POS,
2268 QueryUtil.ALL_POS, null);
2269 }
2270
2271
2285 @Override
2286 public List<ExportImportConfiguration> findByG_T_S(long groupId, int type,
2287 int status, int start, int end) {
2288 return findByG_T_S(groupId, type, status, start, end, null);
2289 }
2290
2291
2306 @Override
2307 public List<ExportImportConfiguration> findByG_T_S(long groupId, int type,
2308 int status, int start, int end,
2309 OrderByComparator<ExportImportConfiguration> orderByComparator) {
2310 return findByG_T_S(groupId, type, status, start, end,
2311 orderByComparator, true);
2312 }
2313
2314
2330 @Override
2331 public List<ExportImportConfiguration> findByG_T_S(long groupId, int type,
2332 int status, int start, int end,
2333 OrderByComparator<ExportImportConfiguration> orderByComparator,
2334 boolean retrieveFromCache) {
2335 boolean pagination = true;
2336 FinderPath finderPath = null;
2337 Object[] finderArgs = null;
2338
2339 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2340 (orderByComparator == null)) {
2341 pagination = false;
2342 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_T_S;
2343 finderArgs = new Object[] { groupId, type, status };
2344 }
2345 else {
2346 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_T_S;
2347 finderArgs = new Object[] {
2348 groupId, type, status,
2349
2350 start, end, orderByComparator
2351 };
2352 }
2353
2354 List<ExportImportConfiguration> list = null;
2355
2356 if (retrieveFromCache) {
2357 list = (List<ExportImportConfiguration>)finderCache.getResult(finderPath,
2358 finderArgs, this);
2359
2360 if ((list != null) && !list.isEmpty()) {
2361 for (ExportImportConfiguration exportImportConfiguration : list) {
2362 if ((groupId != exportImportConfiguration.getGroupId()) ||
2363 (type != exportImportConfiguration.getType()) ||
2364 (status != exportImportConfiguration.getStatus())) {
2365 list = null;
2366
2367 break;
2368 }
2369 }
2370 }
2371 }
2372
2373 if (list == null) {
2374 StringBundler query = null;
2375
2376 if (orderByComparator != null) {
2377 query = new StringBundler(5 +
2378 (orderByComparator.getOrderByFields().length * 2));
2379 }
2380 else {
2381 query = new StringBundler(5);
2382 }
2383
2384 query.append(_SQL_SELECT_EXPORTIMPORTCONFIGURATION_WHERE);
2385
2386 query.append(_FINDER_COLUMN_G_T_S_GROUPID_2);
2387
2388 query.append(_FINDER_COLUMN_G_T_S_TYPE_2);
2389
2390 query.append(_FINDER_COLUMN_G_T_S_STATUS_2);
2391
2392 if (orderByComparator != null) {
2393 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2394 orderByComparator);
2395 }
2396 else
2397 if (pagination) {
2398 query.append(ExportImportConfigurationModelImpl.ORDER_BY_JPQL);
2399 }
2400
2401 String sql = query.toString();
2402
2403 Session session = null;
2404
2405 try {
2406 session = openSession();
2407
2408 Query q = session.createQuery(sql);
2409
2410 QueryPos qPos = QueryPos.getInstance(q);
2411
2412 qPos.add(groupId);
2413
2414 qPos.add(type);
2415
2416 qPos.add(status);
2417
2418 if (!pagination) {
2419 list = (List<ExportImportConfiguration>)QueryUtil.list(q,
2420 getDialect(), start, end, false);
2421
2422 Collections.sort(list);
2423
2424 list = Collections.unmodifiableList(list);
2425 }
2426 else {
2427 list = (List<ExportImportConfiguration>)QueryUtil.list(q,
2428 getDialect(), start, end);
2429 }
2430
2431 cacheResult(list);
2432
2433 finderCache.putResult(finderPath, finderArgs, list);
2434 }
2435 catch (Exception e) {
2436 finderCache.removeResult(finderPath, finderArgs);
2437
2438 throw processException(e);
2439 }
2440 finally {
2441 closeSession(session);
2442 }
2443 }
2444
2445 return list;
2446 }
2447
2448
2458 @Override
2459 public ExportImportConfiguration findByG_T_S_First(long groupId, int type,
2460 int status,
2461 OrderByComparator<ExportImportConfiguration> orderByComparator)
2462 throws NoSuchConfigurationException {
2463 ExportImportConfiguration exportImportConfiguration = fetchByG_T_S_First(groupId,
2464 type, status, orderByComparator);
2465
2466 if (exportImportConfiguration != null) {
2467 return exportImportConfiguration;
2468 }
2469
2470 StringBundler msg = new StringBundler(8);
2471
2472 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2473
2474 msg.append("groupId=");
2475 msg.append(groupId);
2476
2477 msg.append(", type=");
2478 msg.append(type);
2479
2480 msg.append(", status=");
2481 msg.append(status);
2482
2483 msg.append(StringPool.CLOSE_CURLY_BRACE);
2484
2485 throw new NoSuchConfigurationException(msg.toString());
2486 }
2487
2488
2497 @Override
2498 public ExportImportConfiguration fetchByG_T_S_First(long groupId, int type,
2499 int status,
2500 OrderByComparator<ExportImportConfiguration> orderByComparator) {
2501 List<ExportImportConfiguration> list = findByG_T_S(groupId, type,
2502 status, 0, 1, orderByComparator);
2503
2504 if (!list.isEmpty()) {
2505 return list.get(0);
2506 }
2507
2508 return null;
2509 }
2510
2511
2521 @Override
2522 public ExportImportConfiguration findByG_T_S_Last(long groupId, int type,
2523 int status,
2524 OrderByComparator<ExportImportConfiguration> orderByComparator)
2525 throws NoSuchConfigurationException {
2526 ExportImportConfiguration exportImportConfiguration = fetchByG_T_S_Last(groupId,
2527 type, status, orderByComparator);
2528
2529 if (exportImportConfiguration != null) {
2530 return exportImportConfiguration;
2531 }
2532
2533 StringBundler msg = new StringBundler(8);
2534
2535 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2536
2537 msg.append("groupId=");
2538 msg.append(groupId);
2539
2540 msg.append(", type=");
2541 msg.append(type);
2542
2543 msg.append(", status=");
2544 msg.append(status);
2545
2546 msg.append(StringPool.CLOSE_CURLY_BRACE);
2547
2548 throw new NoSuchConfigurationException(msg.toString());
2549 }
2550
2551
2560 @Override
2561 public ExportImportConfiguration fetchByG_T_S_Last(long groupId, int type,
2562 int status,
2563 OrderByComparator<ExportImportConfiguration> orderByComparator) {
2564 int count = countByG_T_S(groupId, type, status);
2565
2566 if (count == 0) {
2567 return null;
2568 }
2569
2570 List<ExportImportConfiguration> list = findByG_T_S(groupId, type,
2571 status, count - 1, count, orderByComparator);
2572
2573 if (!list.isEmpty()) {
2574 return list.get(0);
2575 }
2576
2577 return null;
2578 }
2579
2580
2591 @Override
2592 public ExportImportConfiguration[] findByG_T_S_PrevAndNext(
2593 long exportImportConfigurationId, long groupId, int type, int status,
2594 OrderByComparator<ExportImportConfiguration> orderByComparator)
2595 throws NoSuchConfigurationException {
2596 ExportImportConfiguration exportImportConfiguration = findByPrimaryKey(exportImportConfigurationId);
2597
2598 Session session = null;
2599
2600 try {
2601 session = openSession();
2602
2603 ExportImportConfiguration[] array = new ExportImportConfigurationImpl[3];
2604
2605 array[0] = getByG_T_S_PrevAndNext(session,
2606 exportImportConfiguration, groupId, type, status,
2607 orderByComparator, true);
2608
2609 array[1] = exportImportConfiguration;
2610
2611 array[2] = getByG_T_S_PrevAndNext(session,
2612 exportImportConfiguration, groupId, type, status,
2613 orderByComparator, false);
2614
2615 return array;
2616 }
2617 catch (Exception e) {
2618 throw processException(e);
2619 }
2620 finally {
2621 closeSession(session);
2622 }
2623 }
2624
2625 protected ExportImportConfiguration getByG_T_S_PrevAndNext(
2626 Session session, ExportImportConfiguration exportImportConfiguration,
2627 long groupId, int type, int status,
2628 OrderByComparator<ExportImportConfiguration> orderByComparator,
2629 boolean previous) {
2630 StringBundler query = null;
2631
2632 if (orderByComparator != null) {
2633 query = new StringBundler(6 +
2634 (orderByComparator.getOrderByConditionFields().length * 3) +
2635 (orderByComparator.getOrderByFields().length * 3));
2636 }
2637 else {
2638 query = new StringBundler(5);
2639 }
2640
2641 query.append(_SQL_SELECT_EXPORTIMPORTCONFIGURATION_WHERE);
2642
2643 query.append(_FINDER_COLUMN_G_T_S_GROUPID_2);
2644
2645 query.append(_FINDER_COLUMN_G_T_S_TYPE_2);
2646
2647 query.append(_FINDER_COLUMN_G_T_S_STATUS_2);
2648
2649 if (orderByComparator != null) {
2650 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2651
2652 if (orderByConditionFields.length > 0) {
2653 query.append(WHERE_AND);
2654 }
2655
2656 for (int i = 0; i < orderByConditionFields.length; i++) {
2657 query.append(_ORDER_BY_ENTITY_ALIAS);
2658 query.append(orderByConditionFields[i]);
2659
2660 if ((i + 1) < orderByConditionFields.length) {
2661 if (orderByComparator.isAscending() ^ previous) {
2662 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2663 }
2664 else {
2665 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2666 }
2667 }
2668 else {
2669 if (orderByComparator.isAscending() ^ previous) {
2670 query.append(WHERE_GREATER_THAN);
2671 }
2672 else {
2673 query.append(WHERE_LESSER_THAN);
2674 }
2675 }
2676 }
2677
2678 query.append(ORDER_BY_CLAUSE);
2679
2680 String[] orderByFields = orderByComparator.getOrderByFields();
2681
2682 for (int i = 0; i < orderByFields.length; i++) {
2683 query.append(_ORDER_BY_ENTITY_ALIAS);
2684 query.append(orderByFields[i]);
2685
2686 if ((i + 1) < orderByFields.length) {
2687 if (orderByComparator.isAscending() ^ previous) {
2688 query.append(ORDER_BY_ASC_HAS_NEXT);
2689 }
2690 else {
2691 query.append(ORDER_BY_DESC_HAS_NEXT);
2692 }
2693 }
2694 else {
2695 if (orderByComparator.isAscending() ^ previous) {
2696 query.append(ORDER_BY_ASC);
2697 }
2698 else {
2699 query.append(ORDER_BY_DESC);
2700 }
2701 }
2702 }
2703 }
2704 else {
2705 query.append(ExportImportConfigurationModelImpl.ORDER_BY_JPQL);
2706 }
2707
2708 String sql = query.toString();
2709
2710 Query q = session.createQuery(sql);
2711
2712 q.setFirstResult(0);
2713 q.setMaxResults(2);
2714
2715 QueryPos qPos = QueryPos.getInstance(q);
2716
2717 qPos.add(groupId);
2718
2719 qPos.add(type);
2720
2721 qPos.add(status);
2722
2723 if (orderByComparator != null) {
2724 Object[] values = orderByComparator.getOrderByConditionValues(exportImportConfiguration);
2725
2726 for (Object value : values) {
2727 qPos.add(value);
2728 }
2729 }
2730
2731 List<ExportImportConfiguration> list = q.list();
2732
2733 if (list.size() == 2) {
2734 return list.get(1);
2735 }
2736 else {
2737 return null;
2738 }
2739 }
2740
2741
2748 @Override
2749 public void removeByG_T_S(long groupId, int type, int status) {
2750 for (ExportImportConfiguration exportImportConfiguration : findByG_T_S(
2751 groupId, type, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
2752 null)) {
2753 remove(exportImportConfiguration);
2754 }
2755 }
2756
2757
2765 @Override
2766 public int countByG_T_S(long groupId, int type, int status) {
2767 FinderPath finderPath = FINDER_PATH_COUNT_BY_G_T_S;
2768
2769 Object[] finderArgs = new Object[] { groupId, type, status };
2770
2771 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
2772
2773 if (count == null) {
2774 StringBundler query = new StringBundler(4);
2775
2776 query.append(_SQL_COUNT_EXPORTIMPORTCONFIGURATION_WHERE);
2777
2778 query.append(_FINDER_COLUMN_G_T_S_GROUPID_2);
2779
2780 query.append(_FINDER_COLUMN_G_T_S_TYPE_2);
2781
2782 query.append(_FINDER_COLUMN_G_T_S_STATUS_2);
2783
2784 String sql = query.toString();
2785
2786 Session session = null;
2787
2788 try {
2789 session = openSession();
2790
2791 Query q = session.createQuery(sql);
2792
2793 QueryPos qPos = QueryPos.getInstance(q);
2794
2795 qPos.add(groupId);
2796
2797 qPos.add(type);
2798
2799 qPos.add(status);
2800
2801 count = (Long)q.uniqueResult();
2802
2803 finderCache.putResult(finderPath, finderArgs, count);
2804 }
2805 catch (Exception e) {
2806 finderCache.removeResult(finderPath, finderArgs);
2807
2808 throw processException(e);
2809 }
2810 finally {
2811 closeSession(session);
2812 }
2813 }
2814
2815 return count.intValue();
2816 }
2817
2818 private static final String _FINDER_COLUMN_G_T_S_GROUPID_2 = "exportImportConfiguration.groupId = ? AND ";
2819 private static final String _FINDER_COLUMN_G_T_S_TYPE_2 = "exportImportConfiguration.type = ? AND ";
2820 private static final String _FINDER_COLUMN_G_T_S_STATUS_2 = "exportImportConfiguration.status = ?";
2821
2822 public ExportImportConfigurationPersistenceImpl() {
2823 setModelClass(ExportImportConfiguration.class);
2824 }
2825
2826
2831 @Override
2832 public void cacheResult(ExportImportConfiguration exportImportConfiguration) {
2833 entityCache.putResult(ExportImportConfigurationModelImpl.ENTITY_CACHE_ENABLED,
2834 ExportImportConfigurationImpl.class,
2835 exportImportConfiguration.getPrimaryKey(), exportImportConfiguration);
2836
2837 exportImportConfiguration.resetOriginalValues();
2838 }
2839
2840
2845 @Override
2846 public void cacheResult(
2847 List<ExportImportConfiguration> exportImportConfigurations) {
2848 for (ExportImportConfiguration exportImportConfiguration : exportImportConfigurations) {
2849 if (entityCache.getResult(
2850 ExportImportConfigurationModelImpl.ENTITY_CACHE_ENABLED,
2851 ExportImportConfigurationImpl.class,
2852 exportImportConfiguration.getPrimaryKey()) == null) {
2853 cacheResult(exportImportConfiguration);
2854 }
2855 else {
2856 exportImportConfiguration.resetOriginalValues();
2857 }
2858 }
2859 }
2860
2861
2868 @Override
2869 public void clearCache() {
2870 entityCache.clearCache(ExportImportConfigurationImpl.class);
2871
2872 finderCache.clearCache(FINDER_CLASS_NAME_ENTITY);
2873 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2874 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2875 }
2876
2877
2884 @Override
2885 public void clearCache(ExportImportConfiguration exportImportConfiguration) {
2886 entityCache.removeResult(ExportImportConfigurationModelImpl.ENTITY_CACHE_ENABLED,
2887 ExportImportConfigurationImpl.class,
2888 exportImportConfiguration.getPrimaryKey());
2889
2890 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2891 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2892 }
2893
2894 @Override
2895 public void clearCache(
2896 List<ExportImportConfiguration> exportImportConfigurations) {
2897 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2898 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2899
2900 for (ExportImportConfiguration exportImportConfiguration : exportImportConfigurations) {
2901 entityCache.removeResult(ExportImportConfigurationModelImpl.ENTITY_CACHE_ENABLED,
2902 ExportImportConfigurationImpl.class,
2903 exportImportConfiguration.getPrimaryKey());
2904 }
2905 }
2906
2907
2913 @Override
2914 public ExportImportConfiguration create(long exportImportConfigurationId) {
2915 ExportImportConfiguration exportImportConfiguration = new ExportImportConfigurationImpl();
2916
2917 exportImportConfiguration.setNew(true);
2918 exportImportConfiguration.setPrimaryKey(exportImportConfigurationId);
2919
2920 exportImportConfiguration.setCompanyId(companyProvider.getCompanyId());
2921
2922 return exportImportConfiguration;
2923 }
2924
2925
2932 @Override
2933 public ExportImportConfiguration remove(long exportImportConfigurationId)
2934 throws NoSuchConfigurationException {
2935 return remove((Serializable)exportImportConfigurationId);
2936 }
2937
2938
2945 @Override
2946 public ExportImportConfiguration remove(Serializable primaryKey)
2947 throws NoSuchConfigurationException {
2948 Session session = null;
2949
2950 try {
2951 session = openSession();
2952
2953 ExportImportConfiguration exportImportConfiguration = (ExportImportConfiguration)session.get(ExportImportConfigurationImpl.class,
2954 primaryKey);
2955
2956 if (exportImportConfiguration == null) {
2957 if (_log.isWarnEnabled()) {
2958 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
2959 }
2960
2961 throw new NoSuchConfigurationException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
2962 primaryKey);
2963 }
2964
2965 return remove(exportImportConfiguration);
2966 }
2967 catch (NoSuchConfigurationException nsee) {
2968 throw nsee;
2969 }
2970 catch (Exception e) {
2971 throw processException(e);
2972 }
2973 finally {
2974 closeSession(session);
2975 }
2976 }
2977
2978 @Override
2979 protected ExportImportConfiguration removeImpl(
2980 ExportImportConfiguration exportImportConfiguration) {
2981 exportImportConfiguration = toUnwrappedModel(exportImportConfiguration);
2982
2983 Session session = null;
2984
2985 try {
2986 session = openSession();
2987
2988 if (!session.contains(exportImportConfiguration)) {
2989 exportImportConfiguration = (ExportImportConfiguration)session.get(ExportImportConfigurationImpl.class,
2990 exportImportConfiguration.getPrimaryKeyObj());
2991 }
2992
2993 if (exportImportConfiguration != null) {
2994 session.delete(exportImportConfiguration);
2995 }
2996 }
2997 catch (Exception e) {
2998 throw processException(e);
2999 }
3000 finally {
3001 closeSession(session);
3002 }
3003
3004 if (exportImportConfiguration != null) {
3005 clearCache(exportImportConfiguration);
3006 }
3007
3008 return exportImportConfiguration;
3009 }
3010
3011 @Override
3012 public ExportImportConfiguration updateImpl(
3013 ExportImportConfiguration exportImportConfiguration) {
3014 exportImportConfiguration = toUnwrappedModel(exportImportConfiguration);
3015
3016 boolean isNew = exportImportConfiguration.isNew();
3017
3018 ExportImportConfigurationModelImpl exportImportConfigurationModelImpl = (ExportImportConfigurationModelImpl)exportImportConfiguration;
3019
3020 ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext();
3021
3022 Date now = new Date();
3023
3024 if (isNew && (exportImportConfiguration.getCreateDate() == null)) {
3025 if (serviceContext == null) {
3026 exportImportConfiguration.setCreateDate(now);
3027 }
3028 else {
3029 exportImportConfiguration.setCreateDate(serviceContext.getCreateDate(
3030 now));
3031 }
3032 }
3033
3034 if (!exportImportConfigurationModelImpl.hasSetModifiedDate()) {
3035 if (serviceContext == null) {
3036 exportImportConfiguration.setModifiedDate(now);
3037 }
3038 else {
3039 exportImportConfiguration.setModifiedDate(serviceContext.getModifiedDate(
3040 now));
3041 }
3042 }
3043
3044 Session session = null;
3045
3046 try {
3047 session = openSession();
3048
3049 if (exportImportConfiguration.isNew()) {
3050 session.save(exportImportConfiguration);
3051
3052 exportImportConfiguration.setNew(false);
3053 }
3054 else {
3055 exportImportConfiguration = (ExportImportConfiguration)session.merge(exportImportConfiguration);
3056 }
3057 }
3058 catch (Exception e) {
3059 throw processException(e);
3060 }
3061 finally {
3062 closeSession(session);
3063 }
3064
3065 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
3066
3067 if (isNew ||
3068 !ExportImportConfigurationModelImpl.COLUMN_BITMASK_ENABLED) {
3069 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
3070 }
3071
3072 else {
3073 if ((exportImportConfigurationModelImpl.getColumnBitmask() &
3074 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
3075 Object[] args = new Object[] {
3076 exportImportConfigurationModelImpl.getOriginalGroupId()
3077 };
3078
3079 finderCache.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
3080 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
3081 args);
3082
3083 args = new Object[] {
3084 exportImportConfigurationModelImpl.getGroupId()
3085 };
3086
3087 finderCache.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
3088 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
3089 args);
3090 }
3091
3092 if ((exportImportConfigurationModelImpl.getColumnBitmask() &
3093 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
3094 Object[] args = new Object[] {
3095 exportImportConfigurationModelImpl.getOriginalCompanyId()
3096 };
3097
3098 finderCache.removeResult(FINDER_PATH_COUNT_BY_COMPANYID, args);
3099 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
3100 args);
3101
3102 args = new Object[] {
3103 exportImportConfigurationModelImpl.getCompanyId()
3104 };
3105
3106 finderCache.removeResult(FINDER_PATH_COUNT_BY_COMPANYID, args);
3107 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
3108 args);
3109 }
3110
3111 if ((exportImportConfigurationModelImpl.getColumnBitmask() &
3112 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_T.getColumnBitmask()) != 0) {
3113 Object[] args = new Object[] {
3114 exportImportConfigurationModelImpl.getOriginalGroupId(),
3115 exportImportConfigurationModelImpl.getOriginalType()
3116 };
3117
3118 finderCache.removeResult(FINDER_PATH_COUNT_BY_G_T, args);
3119 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_T,
3120 args);
3121
3122 args = new Object[] {
3123 exportImportConfigurationModelImpl.getGroupId(),
3124 exportImportConfigurationModelImpl.getType()
3125 };
3126
3127 finderCache.removeResult(FINDER_PATH_COUNT_BY_G_T, args);
3128 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_T,
3129 args);
3130 }
3131
3132 if ((exportImportConfigurationModelImpl.getColumnBitmask() &
3133 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S.getColumnBitmask()) != 0) {
3134 Object[] args = new Object[] {
3135 exportImportConfigurationModelImpl.getOriginalGroupId(),
3136 exportImportConfigurationModelImpl.getOriginalStatus()
3137 };
3138
3139 finderCache.removeResult(FINDER_PATH_COUNT_BY_G_S, args);
3140 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S,
3141 args);
3142
3143 args = new Object[] {
3144 exportImportConfigurationModelImpl.getGroupId(),
3145 exportImportConfigurationModelImpl.getStatus()
3146 };
3147
3148 finderCache.removeResult(FINDER_PATH_COUNT_BY_G_S, args);
3149 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S,
3150 args);
3151 }
3152
3153 if ((exportImportConfigurationModelImpl.getColumnBitmask() &
3154 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_T_S.getColumnBitmask()) != 0) {
3155 Object[] args = new Object[] {
3156 exportImportConfigurationModelImpl.getOriginalGroupId(),
3157 exportImportConfigurationModelImpl.getOriginalType(),
3158 exportImportConfigurationModelImpl.getOriginalStatus()
3159 };
3160
3161 finderCache.removeResult(FINDER_PATH_COUNT_BY_G_T_S, args);
3162 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_T_S,
3163 args);
3164
3165 args = new Object[] {
3166 exportImportConfigurationModelImpl.getGroupId(),
3167 exportImportConfigurationModelImpl.getType(),
3168 exportImportConfigurationModelImpl.getStatus()
3169 };
3170
3171 finderCache.removeResult(FINDER_PATH_COUNT_BY_G_T_S, args);
3172 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_T_S,
3173 args);
3174 }
3175 }
3176
3177 entityCache.putResult(ExportImportConfigurationModelImpl.ENTITY_CACHE_ENABLED,
3178 ExportImportConfigurationImpl.class,
3179 exportImportConfiguration.getPrimaryKey(),
3180 exportImportConfiguration, false);
3181
3182 exportImportConfiguration.resetOriginalValues();
3183
3184 return exportImportConfiguration;
3185 }
3186
3187 protected ExportImportConfiguration toUnwrappedModel(
3188 ExportImportConfiguration exportImportConfiguration) {
3189 if (exportImportConfiguration instanceof ExportImportConfigurationImpl) {
3190 return exportImportConfiguration;
3191 }
3192
3193 ExportImportConfigurationImpl exportImportConfigurationImpl = new ExportImportConfigurationImpl();
3194
3195 exportImportConfigurationImpl.setNew(exportImportConfiguration.isNew());
3196 exportImportConfigurationImpl.setPrimaryKey(exportImportConfiguration.getPrimaryKey());
3197
3198 exportImportConfigurationImpl.setMvccVersion(exportImportConfiguration.getMvccVersion());
3199 exportImportConfigurationImpl.setExportImportConfigurationId(exportImportConfiguration.getExportImportConfigurationId());
3200 exportImportConfigurationImpl.setGroupId(exportImportConfiguration.getGroupId());
3201 exportImportConfigurationImpl.setCompanyId(exportImportConfiguration.getCompanyId());
3202 exportImportConfigurationImpl.setUserId(exportImportConfiguration.getUserId());
3203 exportImportConfigurationImpl.setUserName(exportImportConfiguration.getUserName());
3204 exportImportConfigurationImpl.setCreateDate(exportImportConfiguration.getCreateDate());
3205 exportImportConfigurationImpl.setModifiedDate(exportImportConfiguration.getModifiedDate());
3206 exportImportConfigurationImpl.setName(exportImportConfiguration.getName());
3207 exportImportConfigurationImpl.setDescription(exportImportConfiguration.getDescription());
3208 exportImportConfigurationImpl.setType(exportImportConfiguration.getType());
3209 exportImportConfigurationImpl.setSettings(exportImportConfiguration.getSettings());
3210 exportImportConfigurationImpl.setStatus(exportImportConfiguration.getStatus());
3211 exportImportConfigurationImpl.setStatusByUserId(exportImportConfiguration.getStatusByUserId());
3212 exportImportConfigurationImpl.setStatusByUserName(exportImportConfiguration.getStatusByUserName());
3213 exportImportConfigurationImpl.setStatusDate(exportImportConfiguration.getStatusDate());
3214
3215 return exportImportConfigurationImpl;
3216 }
3217
3218
3225 @Override
3226 public ExportImportConfiguration findByPrimaryKey(Serializable primaryKey)
3227 throws NoSuchConfigurationException {
3228 ExportImportConfiguration exportImportConfiguration = fetchByPrimaryKey(primaryKey);
3229
3230 if (exportImportConfiguration == null) {
3231 if (_log.isWarnEnabled()) {
3232 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
3233 }
3234
3235 throw new NoSuchConfigurationException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
3236 primaryKey);
3237 }
3238
3239 return exportImportConfiguration;
3240 }
3241
3242
3249 @Override
3250 public ExportImportConfiguration findByPrimaryKey(
3251 long exportImportConfigurationId) throws NoSuchConfigurationException {
3252 return findByPrimaryKey((Serializable)exportImportConfigurationId);
3253 }
3254
3255
3261 @Override
3262 public ExportImportConfiguration fetchByPrimaryKey(Serializable primaryKey) {
3263 ExportImportConfiguration exportImportConfiguration = (ExportImportConfiguration)entityCache.getResult(ExportImportConfigurationModelImpl.ENTITY_CACHE_ENABLED,
3264 ExportImportConfigurationImpl.class, primaryKey);
3265
3266 if (exportImportConfiguration == _nullExportImportConfiguration) {
3267 return null;
3268 }
3269
3270 if (exportImportConfiguration == null) {
3271 Session session = null;
3272
3273 try {
3274 session = openSession();
3275
3276 exportImportConfiguration = (ExportImportConfiguration)session.get(ExportImportConfigurationImpl.class,
3277 primaryKey);
3278
3279 if (exportImportConfiguration != null) {
3280 cacheResult(exportImportConfiguration);
3281 }
3282 else {
3283 entityCache.putResult(ExportImportConfigurationModelImpl.ENTITY_CACHE_ENABLED,
3284 ExportImportConfigurationImpl.class, primaryKey,
3285 _nullExportImportConfiguration);
3286 }
3287 }
3288 catch (Exception e) {
3289 entityCache.removeResult(ExportImportConfigurationModelImpl.ENTITY_CACHE_ENABLED,
3290 ExportImportConfigurationImpl.class, primaryKey);
3291
3292 throw processException(e);
3293 }
3294 finally {
3295 closeSession(session);
3296 }
3297 }
3298
3299 return exportImportConfiguration;
3300 }
3301
3302
3308 @Override
3309 public ExportImportConfiguration fetchByPrimaryKey(
3310 long exportImportConfigurationId) {
3311 return fetchByPrimaryKey((Serializable)exportImportConfigurationId);
3312 }
3313
3314 @Override
3315 public Map<Serializable, ExportImportConfiguration> fetchByPrimaryKeys(
3316 Set<Serializable> primaryKeys) {
3317 if (primaryKeys.isEmpty()) {
3318 return Collections.emptyMap();
3319 }
3320
3321 Map<Serializable, ExportImportConfiguration> map = new HashMap<Serializable, ExportImportConfiguration>();
3322
3323 if (primaryKeys.size() == 1) {
3324 Iterator<Serializable> iterator = primaryKeys.iterator();
3325
3326 Serializable primaryKey = iterator.next();
3327
3328 ExportImportConfiguration exportImportConfiguration = fetchByPrimaryKey(primaryKey);
3329
3330 if (exportImportConfiguration != null) {
3331 map.put(primaryKey, exportImportConfiguration);
3332 }
3333
3334 return map;
3335 }
3336
3337 Set<Serializable> uncachedPrimaryKeys = null;
3338
3339 for (Serializable primaryKey : primaryKeys) {
3340 ExportImportConfiguration exportImportConfiguration = (ExportImportConfiguration)entityCache.getResult(ExportImportConfigurationModelImpl.ENTITY_CACHE_ENABLED,
3341 ExportImportConfigurationImpl.class, primaryKey);
3342
3343 if (exportImportConfiguration == null) {
3344 if (uncachedPrimaryKeys == null) {
3345 uncachedPrimaryKeys = new HashSet<Serializable>();
3346 }
3347
3348 uncachedPrimaryKeys.add(primaryKey);
3349 }
3350 else {
3351 map.put(primaryKey, exportImportConfiguration);
3352 }
3353 }
3354
3355 if (uncachedPrimaryKeys == null) {
3356 return map;
3357 }
3358
3359 StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) +
3360 1);
3361
3362 query.append(_SQL_SELECT_EXPORTIMPORTCONFIGURATION_WHERE_PKS_IN);
3363
3364 for (Serializable primaryKey : uncachedPrimaryKeys) {
3365 query.append(String.valueOf(primaryKey));
3366
3367 query.append(StringPool.COMMA);
3368 }
3369
3370 query.setIndex(query.index() - 1);
3371
3372 query.append(StringPool.CLOSE_PARENTHESIS);
3373
3374 String sql = query.toString();
3375
3376 Session session = null;
3377
3378 try {
3379 session = openSession();
3380
3381 Query q = session.createQuery(sql);
3382
3383 for (ExportImportConfiguration exportImportConfiguration : (List<ExportImportConfiguration>)q.list()) {
3384 map.put(exportImportConfiguration.getPrimaryKeyObj(),
3385 exportImportConfiguration);
3386
3387 cacheResult(exportImportConfiguration);
3388
3389 uncachedPrimaryKeys.remove(exportImportConfiguration.getPrimaryKeyObj());
3390 }
3391
3392 for (Serializable primaryKey : uncachedPrimaryKeys) {
3393 entityCache.putResult(ExportImportConfigurationModelImpl.ENTITY_CACHE_ENABLED,
3394 ExportImportConfigurationImpl.class, primaryKey,
3395 _nullExportImportConfiguration);
3396 }
3397 }
3398 catch (Exception e) {
3399 throw processException(e);
3400 }
3401 finally {
3402 closeSession(session);
3403 }
3404
3405 return map;
3406 }
3407
3408
3413 @Override
3414 public List<ExportImportConfiguration> findAll() {
3415 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
3416 }
3417
3418
3429 @Override
3430 public List<ExportImportConfiguration> findAll(int start, int end) {
3431 return findAll(start, end, null);
3432 }
3433
3434
3446 @Override
3447 public List<ExportImportConfiguration> findAll(int start, int end,
3448 OrderByComparator<ExportImportConfiguration> orderByComparator) {
3449 return findAll(start, end, orderByComparator, true);
3450 }
3451
3452
3465 @Override
3466 public List<ExportImportConfiguration> findAll(int start, int end,
3467 OrderByComparator<ExportImportConfiguration> orderByComparator,
3468 boolean retrieveFromCache) {
3469 boolean pagination = true;
3470 FinderPath finderPath = null;
3471 Object[] finderArgs = null;
3472
3473 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3474 (orderByComparator == null)) {
3475 pagination = false;
3476 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
3477 finderArgs = FINDER_ARGS_EMPTY;
3478 }
3479 else {
3480 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
3481 finderArgs = new Object[] { start, end, orderByComparator };
3482 }
3483
3484 List<ExportImportConfiguration> list = null;
3485
3486 if (retrieveFromCache) {
3487 list = (List<ExportImportConfiguration>)finderCache.getResult(finderPath,
3488 finderArgs, this);
3489 }
3490
3491 if (list == null) {
3492 StringBundler query = null;
3493 String sql = null;
3494
3495 if (orderByComparator != null) {
3496 query = new StringBundler(2 +
3497 (orderByComparator.getOrderByFields().length * 2));
3498
3499 query.append(_SQL_SELECT_EXPORTIMPORTCONFIGURATION);
3500
3501 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3502 orderByComparator);
3503
3504 sql = query.toString();
3505 }
3506 else {
3507 sql = _SQL_SELECT_EXPORTIMPORTCONFIGURATION;
3508
3509 if (pagination) {
3510 sql = sql.concat(ExportImportConfigurationModelImpl.ORDER_BY_JPQL);
3511 }
3512 }
3513
3514 Session session = null;
3515
3516 try {
3517 session = openSession();
3518
3519 Query q = session.createQuery(sql);
3520
3521 if (!pagination) {
3522 list = (List<ExportImportConfiguration>)QueryUtil.list(q,
3523 getDialect(), start, end, false);
3524
3525 Collections.sort(list);
3526
3527 list = Collections.unmodifiableList(list);
3528 }
3529 else {
3530 list = (List<ExportImportConfiguration>)QueryUtil.list(q,
3531 getDialect(), start, end);
3532 }
3533
3534 cacheResult(list);
3535
3536 finderCache.putResult(finderPath, finderArgs, list);
3537 }
3538 catch (Exception e) {
3539 finderCache.removeResult(finderPath, finderArgs);
3540
3541 throw processException(e);
3542 }
3543 finally {
3544 closeSession(session);
3545 }
3546 }
3547
3548 return list;
3549 }
3550
3551
3555 @Override
3556 public void removeAll() {
3557 for (ExportImportConfiguration exportImportConfiguration : findAll()) {
3558 remove(exportImportConfiguration);
3559 }
3560 }
3561
3562
3567 @Override
3568 public int countAll() {
3569 Long count = (Long)finderCache.getResult(FINDER_PATH_COUNT_ALL,
3570 FINDER_ARGS_EMPTY, this);
3571
3572 if (count == null) {
3573 Session session = null;
3574
3575 try {
3576 session = openSession();
3577
3578 Query q = session.createQuery(_SQL_COUNT_EXPORTIMPORTCONFIGURATION);
3579
3580 count = (Long)q.uniqueResult();
3581
3582 finderCache.putResult(FINDER_PATH_COUNT_ALL, FINDER_ARGS_EMPTY,
3583 count);
3584 }
3585 catch (Exception e) {
3586 finderCache.removeResult(FINDER_PATH_COUNT_ALL,
3587 FINDER_ARGS_EMPTY);
3588
3589 throw processException(e);
3590 }
3591 finally {
3592 closeSession(session);
3593 }
3594 }
3595
3596 return count.intValue();
3597 }
3598
3599 @Override
3600 public Set<String> getBadColumnNames() {
3601 return _badColumnNames;
3602 }
3603
3604 @Override
3605 protected Map<String, Integer> getTableColumnsMap() {
3606 return ExportImportConfigurationModelImpl.TABLE_COLUMNS_MAP;
3607 }
3608
3609
3612 public void afterPropertiesSet() {
3613 }
3614
3615 public void destroy() {
3616 entityCache.removeCache(ExportImportConfigurationImpl.class.getName());
3617 finderCache.removeCache(FINDER_CLASS_NAME_ENTITY);
3618 finderCache.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
3619 finderCache.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
3620 }
3621
3622 @BeanReference(type = CompanyProviderWrapper.class)
3623 protected CompanyProvider companyProvider;
3624 protected EntityCache entityCache = EntityCacheUtil.getEntityCache();
3625 protected FinderCache finderCache = FinderCacheUtil.getFinderCache();
3626 private static final String _SQL_SELECT_EXPORTIMPORTCONFIGURATION = "SELECT exportImportConfiguration FROM ExportImportConfiguration exportImportConfiguration";
3627 private static final String _SQL_SELECT_EXPORTIMPORTCONFIGURATION_WHERE_PKS_IN =
3628 "SELECT exportImportConfiguration FROM ExportImportConfiguration exportImportConfiguration WHERE exportImportConfigurationId IN (";
3629 private static final String _SQL_SELECT_EXPORTIMPORTCONFIGURATION_WHERE = "SELECT exportImportConfiguration FROM ExportImportConfiguration exportImportConfiguration WHERE ";
3630 private static final String _SQL_COUNT_EXPORTIMPORTCONFIGURATION = "SELECT COUNT(exportImportConfiguration) FROM ExportImportConfiguration exportImportConfiguration";
3631 private static final String _SQL_COUNT_EXPORTIMPORTCONFIGURATION_WHERE = "SELECT COUNT(exportImportConfiguration) FROM ExportImportConfiguration exportImportConfiguration WHERE ";
3632 private static final String _ORDER_BY_ENTITY_ALIAS = "exportImportConfiguration.";
3633 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No ExportImportConfiguration exists with the primary key ";
3634 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No ExportImportConfiguration exists with the key {";
3635 private static final Log _log = LogFactoryUtil.getLog(ExportImportConfigurationPersistenceImpl.class);
3636 private static final Set<String> _badColumnNames = SetUtil.fromArray(new String[] {
3637 "type", "settings"
3638 });
3639 private static final ExportImportConfiguration _nullExportImportConfiguration =
3640 new ExportImportConfigurationImpl() {
3641 @Override
3642 public Object clone() {
3643 return this;
3644 }
3645
3646 @Override
3647 public CacheModel<ExportImportConfiguration> toCacheModel() {
3648 return _nullExportImportConfigurationCacheModel;
3649 }
3650 };
3651
3652 private static final CacheModel<ExportImportConfiguration> _nullExportImportConfigurationCacheModel =
3653 new NullCacheModel();
3654
3655 private static class NullCacheModel implements CacheModel<ExportImportConfiguration>,
3656 MVCCModel {
3657 @Override
3658 public long getMvccVersion() {
3659 return -1;
3660 }
3661
3662 @Override
3663 public void setMvccVersion(long mvccVersion) {
3664 }
3665
3666 @Override
3667 public ExportImportConfiguration toEntityModel() {
3668 return _nullExportImportConfiguration;
3669 }
3670 }
3671 }