001
014
015 package com.liferay.portlet.softwarecatalog.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.SQLQuery;
029 import com.liferay.portal.kernel.dao.orm.Session;
030 import com.liferay.portal.kernel.log.Log;
031 import com.liferay.portal.kernel.log.LogFactoryUtil;
032 import com.liferay.portal.kernel.util.OrderByComparator;
033 import com.liferay.portal.kernel.util.SetUtil;
034 import com.liferay.portal.kernel.util.StringBundler;
035 import com.liferay.portal.kernel.util.StringPool;
036 import com.liferay.portal.kernel.util.StringUtil;
037 import com.liferay.portal.kernel.util.Validator;
038 import com.liferay.portal.model.CacheModel;
039 import com.liferay.portal.security.permission.InlineSQLHelperUtil;
040 import com.liferay.portal.service.ServiceContext;
041 import com.liferay.portal.service.ServiceContextThreadLocal;
042 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
043 import com.liferay.portal.service.persistence.impl.TableMapper;
044 import com.liferay.portal.service.persistence.impl.TableMapperFactory;
045
046 import com.liferay.portlet.softwarecatalog.NoSuchProductEntryException;
047 import com.liferay.portlet.softwarecatalog.model.SCProductEntry;
048 import com.liferay.portlet.softwarecatalog.model.impl.SCProductEntryImpl;
049 import com.liferay.portlet.softwarecatalog.model.impl.SCProductEntryModelImpl;
050 import com.liferay.portlet.softwarecatalog.service.persistence.SCLicensePersistence;
051 import com.liferay.portlet.softwarecatalog.service.persistence.SCProductEntryPersistence;
052
053 import java.io.Serializable;
054
055 import java.util.Collections;
056 import java.util.Date;
057 import java.util.HashMap;
058 import java.util.HashSet;
059 import java.util.Iterator;
060 import java.util.List;
061 import java.util.Map;
062 import java.util.Set;
063
064
076 @ProviderType
077 public class SCProductEntryPersistenceImpl extends BasePersistenceImpl<SCProductEntry>
078 implements SCProductEntryPersistence {
079
084 public static final String FINDER_CLASS_NAME_ENTITY = SCProductEntryImpl.class.getName();
085 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
086 ".List1";
087 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
088 ".List2";
089 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
090 SCProductEntryModelImpl.FINDER_CACHE_ENABLED,
091 SCProductEntryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
092 "findAll", new String[0]);
093 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
094 SCProductEntryModelImpl.FINDER_CACHE_ENABLED,
095 SCProductEntryImpl.class,
096 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
097 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
098 SCProductEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
099 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
100 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
101 SCProductEntryModelImpl.FINDER_CACHE_ENABLED,
102 SCProductEntryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
103 "findByGroupId",
104 new String[] {
105 Long.class.getName(),
106
107 Integer.class.getName(), Integer.class.getName(),
108 OrderByComparator.class.getName()
109 });
110 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID =
111 new FinderPath(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
112 SCProductEntryModelImpl.FINDER_CACHE_ENABLED,
113 SCProductEntryImpl.class,
114 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByGroupId",
115 new String[] { Long.class.getName() },
116 SCProductEntryModelImpl.GROUPID_COLUMN_BITMASK |
117 SCProductEntryModelImpl.MODIFIEDDATE_COLUMN_BITMASK |
118 SCProductEntryModelImpl.NAME_COLUMN_BITMASK);
119 public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
120 SCProductEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
121 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId",
122 new String[] { Long.class.getName() });
123
124
130 @Override
131 public List<SCProductEntry> findByGroupId(long groupId) {
132 return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
133 }
134
135
147 @Override
148 public List<SCProductEntry> findByGroupId(long groupId, int start, int end) {
149 return findByGroupId(groupId, start, end, null);
150 }
151
152
165 @Override
166 public List<SCProductEntry> findByGroupId(long groupId, int start, int end,
167 OrderByComparator<SCProductEntry> orderByComparator) {
168 return findByGroupId(groupId, start, end, orderByComparator, true);
169 }
170
171
185 @Override
186 public List<SCProductEntry> findByGroupId(long groupId, int start, int end,
187 OrderByComparator<SCProductEntry> 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<SCProductEntry> list = null;
205
206 if (retrieveFromCache) {
207 list = (List<SCProductEntry>)finderCache.getResult(finderPath,
208 finderArgs, this);
209
210 if ((list != null) && !list.isEmpty()) {
211 for (SCProductEntry scProductEntry : list) {
212 if ((groupId != scProductEntry.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 * 3));
227 }
228 else {
229 query = new StringBundler(3);
230 }
231
232 query.append(_SQL_SELECT_SCPRODUCTENTRY_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(SCProductEntryModelImpl.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<SCProductEntry>)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<SCProductEntry>)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 SCProductEntry findByGroupId_First(long groupId,
298 OrderByComparator<SCProductEntry> orderByComparator)
299 throws NoSuchProductEntryException {
300 SCProductEntry scProductEntry = fetchByGroupId_First(groupId,
301 orderByComparator);
302
303 if (scProductEntry != null) {
304 return scProductEntry;
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 NoSuchProductEntryException(msg.toString());
317 }
318
319
326 @Override
327 public SCProductEntry fetchByGroupId_First(long groupId,
328 OrderByComparator<SCProductEntry> orderByComparator) {
329 List<SCProductEntry> 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 SCProductEntry findByGroupId_Last(long groupId,
349 OrderByComparator<SCProductEntry> orderByComparator)
350 throws NoSuchProductEntryException {
351 SCProductEntry scProductEntry = fetchByGroupId_Last(groupId,
352 orderByComparator);
353
354 if (scProductEntry != null) {
355 return scProductEntry;
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 NoSuchProductEntryException(msg.toString());
368 }
369
370
377 @Override
378 public SCProductEntry fetchByGroupId_Last(long groupId,
379 OrderByComparator<SCProductEntry> orderByComparator) {
380 int count = countByGroupId(groupId);
381
382 if (count == 0) {
383 return null;
384 }
385
386 List<SCProductEntry> list = findByGroupId(groupId, count - 1, count,
387 orderByComparator);
388
389 if (!list.isEmpty()) {
390 return list.get(0);
391 }
392
393 return null;
394 }
395
396
405 @Override
406 public SCProductEntry[] findByGroupId_PrevAndNext(long productEntryId,
407 long groupId, OrderByComparator<SCProductEntry> orderByComparator)
408 throws NoSuchProductEntryException {
409 SCProductEntry scProductEntry = findByPrimaryKey(productEntryId);
410
411 Session session = null;
412
413 try {
414 session = openSession();
415
416 SCProductEntry[] array = new SCProductEntryImpl[3];
417
418 array[0] = getByGroupId_PrevAndNext(session, scProductEntry,
419 groupId, orderByComparator, true);
420
421 array[1] = scProductEntry;
422
423 array[2] = getByGroupId_PrevAndNext(session, scProductEntry,
424 groupId, orderByComparator, false);
425
426 return array;
427 }
428 catch (Exception e) {
429 throw processException(e);
430 }
431 finally {
432 closeSession(session);
433 }
434 }
435
436 protected SCProductEntry getByGroupId_PrevAndNext(Session session,
437 SCProductEntry scProductEntry, long groupId,
438 OrderByComparator<SCProductEntry> orderByComparator, boolean previous) {
439 StringBundler query = null;
440
441 if (orderByComparator != null) {
442 query = new StringBundler(6 +
443 (orderByComparator.getOrderByFields().length * 6));
444 }
445 else {
446 query = new StringBundler(3);
447 }
448
449 query.append(_SQL_SELECT_SCPRODUCTENTRY_WHERE);
450
451 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
452
453 if (orderByComparator != null) {
454 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
455
456 if (orderByConditionFields.length > 0) {
457 query.append(WHERE_AND);
458 }
459
460 for (int i = 0; i < orderByConditionFields.length; i++) {
461 query.append(_ORDER_BY_ENTITY_ALIAS);
462 query.append(orderByConditionFields[i]);
463
464 if ((i + 1) < orderByConditionFields.length) {
465 if (orderByComparator.isAscending() ^ previous) {
466 query.append(WHERE_GREATER_THAN_HAS_NEXT);
467 }
468 else {
469 query.append(WHERE_LESSER_THAN_HAS_NEXT);
470 }
471 }
472 else {
473 if (orderByComparator.isAscending() ^ previous) {
474 query.append(WHERE_GREATER_THAN);
475 }
476 else {
477 query.append(WHERE_LESSER_THAN);
478 }
479 }
480 }
481
482 query.append(ORDER_BY_CLAUSE);
483
484 String[] orderByFields = orderByComparator.getOrderByFields();
485
486 for (int i = 0; i < orderByFields.length; i++) {
487 query.append(_ORDER_BY_ENTITY_ALIAS);
488 query.append(orderByFields[i]);
489
490 if ((i + 1) < orderByFields.length) {
491 if (orderByComparator.isAscending() ^ previous) {
492 query.append(ORDER_BY_ASC_HAS_NEXT);
493 }
494 else {
495 query.append(ORDER_BY_DESC_HAS_NEXT);
496 }
497 }
498 else {
499 if (orderByComparator.isAscending() ^ previous) {
500 query.append(ORDER_BY_ASC);
501 }
502 else {
503 query.append(ORDER_BY_DESC);
504 }
505 }
506 }
507 }
508 else {
509 query.append(SCProductEntryModelImpl.ORDER_BY_JPQL);
510 }
511
512 String sql = query.toString();
513
514 Query q = session.createQuery(sql);
515
516 q.setFirstResult(0);
517 q.setMaxResults(2);
518
519 QueryPos qPos = QueryPos.getInstance(q);
520
521 qPos.add(groupId);
522
523 if (orderByComparator != null) {
524 Object[] values = orderByComparator.getOrderByConditionValues(scProductEntry);
525
526 for (Object value : values) {
527 qPos.add(value);
528 }
529 }
530
531 List<SCProductEntry> list = q.list();
532
533 if (list.size() == 2) {
534 return list.get(1);
535 }
536 else {
537 return null;
538 }
539 }
540
541
547 @Override
548 public List<SCProductEntry> filterFindByGroupId(long groupId) {
549 return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
550 QueryUtil.ALL_POS, null);
551 }
552
553
565 @Override
566 public List<SCProductEntry> filterFindByGroupId(long groupId, int start,
567 int end) {
568 return filterFindByGroupId(groupId, start, end, null);
569 }
570
571
584 @Override
585 public List<SCProductEntry> filterFindByGroupId(long groupId, int start,
586 int end, OrderByComparator<SCProductEntry> orderByComparator) {
587 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
588 return findByGroupId(groupId, start, end, orderByComparator);
589 }
590
591 StringBundler query = null;
592
593 if (orderByComparator != null) {
594 query = new StringBundler(3 +
595 (orderByComparator.getOrderByFields().length * 3));
596 }
597 else {
598 query = new StringBundler(3);
599 }
600
601 if (getDB().isSupportsInlineDistinct()) {
602 query.append(_FILTER_SQL_SELECT_SCPRODUCTENTRY_WHERE);
603 }
604 else {
605 query.append(_FILTER_SQL_SELECT_SCPRODUCTENTRY_NO_INLINE_DISTINCT_WHERE_1);
606 }
607
608 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
609
610 if (!getDB().isSupportsInlineDistinct()) {
611 query.append(_FILTER_SQL_SELECT_SCPRODUCTENTRY_NO_INLINE_DISTINCT_WHERE_2);
612 }
613
614 if (orderByComparator != null) {
615 if (getDB().isSupportsInlineDistinct()) {
616 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
617 orderByComparator, true);
618 }
619 else {
620 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
621 orderByComparator, true);
622 }
623 }
624 else {
625 if (getDB().isSupportsInlineDistinct()) {
626 query.append(SCProductEntryModelImpl.ORDER_BY_JPQL);
627 }
628 else {
629 query.append(SCProductEntryModelImpl.ORDER_BY_SQL);
630 }
631 }
632
633 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
634 SCProductEntry.class.getName(),
635 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
636
637 Session session = null;
638
639 try {
640 session = openSession();
641
642 SQLQuery q = session.createSynchronizedSQLQuery(sql);
643
644 if (getDB().isSupportsInlineDistinct()) {
645 q.addEntity(_FILTER_ENTITY_ALIAS, SCProductEntryImpl.class);
646 }
647 else {
648 q.addEntity(_FILTER_ENTITY_TABLE, SCProductEntryImpl.class);
649 }
650
651 QueryPos qPos = QueryPos.getInstance(q);
652
653 qPos.add(groupId);
654
655 return (List<SCProductEntry>)QueryUtil.list(q, getDialect(), start,
656 end);
657 }
658 catch (Exception e) {
659 throw processException(e);
660 }
661 finally {
662 closeSession(session);
663 }
664 }
665
666
675 @Override
676 public SCProductEntry[] filterFindByGroupId_PrevAndNext(
677 long productEntryId, long groupId,
678 OrderByComparator<SCProductEntry> orderByComparator)
679 throws NoSuchProductEntryException {
680 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
681 return findByGroupId_PrevAndNext(productEntryId, groupId,
682 orderByComparator);
683 }
684
685 SCProductEntry scProductEntry = findByPrimaryKey(productEntryId);
686
687 Session session = null;
688
689 try {
690 session = openSession();
691
692 SCProductEntry[] array = new SCProductEntryImpl[3];
693
694 array[0] = filterGetByGroupId_PrevAndNext(session, scProductEntry,
695 groupId, orderByComparator, true);
696
697 array[1] = scProductEntry;
698
699 array[2] = filterGetByGroupId_PrevAndNext(session, scProductEntry,
700 groupId, orderByComparator, false);
701
702 return array;
703 }
704 catch (Exception e) {
705 throw processException(e);
706 }
707 finally {
708 closeSession(session);
709 }
710 }
711
712 protected SCProductEntry filterGetByGroupId_PrevAndNext(Session session,
713 SCProductEntry scProductEntry, long groupId,
714 OrderByComparator<SCProductEntry> orderByComparator, boolean previous) {
715 StringBundler query = null;
716
717 if (orderByComparator != null) {
718 query = new StringBundler(6 +
719 (orderByComparator.getOrderByFields().length * 6));
720 }
721 else {
722 query = new StringBundler(3);
723 }
724
725 if (getDB().isSupportsInlineDistinct()) {
726 query.append(_FILTER_SQL_SELECT_SCPRODUCTENTRY_WHERE);
727 }
728 else {
729 query.append(_FILTER_SQL_SELECT_SCPRODUCTENTRY_NO_INLINE_DISTINCT_WHERE_1);
730 }
731
732 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
733
734 if (!getDB().isSupportsInlineDistinct()) {
735 query.append(_FILTER_SQL_SELECT_SCPRODUCTENTRY_NO_INLINE_DISTINCT_WHERE_2);
736 }
737
738 if (orderByComparator != null) {
739 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
740
741 if (orderByConditionFields.length > 0) {
742 query.append(WHERE_AND);
743 }
744
745 for (int i = 0; i < orderByConditionFields.length; i++) {
746 if (getDB().isSupportsInlineDistinct()) {
747 query.append(_ORDER_BY_ENTITY_ALIAS);
748 }
749 else {
750 query.append(_ORDER_BY_ENTITY_TABLE);
751 }
752
753 query.append(orderByConditionFields[i]);
754
755 if ((i + 1) < orderByConditionFields.length) {
756 if (orderByComparator.isAscending() ^ previous) {
757 query.append(WHERE_GREATER_THAN_HAS_NEXT);
758 }
759 else {
760 query.append(WHERE_LESSER_THAN_HAS_NEXT);
761 }
762 }
763 else {
764 if (orderByComparator.isAscending() ^ previous) {
765 query.append(WHERE_GREATER_THAN);
766 }
767 else {
768 query.append(WHERE_LESSER_THAN);
769 }
770 }
771 }
772
773 query.append(ORDER_BY_CLAUSE);
774
775 String[] orderByFields = orderByComparator.getOrderByFields();
776
777 for (int i = 0; i < orderByFields.length; i++) {
778 if (getDB().isSupportsInlineDistinct()) {
779 query.append(_ORDER_BY_ENTITY_ALIAS);
780 }
781 else {
782 query.append(_ORDER_BY_ENTITY_TABLE);
783 }
784
785 query.append(orderByFields[i]);
786
787 if ((i + 1) < orderByFields.length) {
788 if (orderByComparator.isAscending() ^ previous) {
789 query.append(ORDER_BY_ASC_HAS_NEXT);
790 }
791 else {
792 query.append(ORDER_BY_DESC_HAS_NEXT);
793 }
794 }
795 else {
796 if (orderByComparator.isAscending() ^ previous) {
797 query.append(ORDER_BY_ASC);
798 }
799 else {
800 query.append(ORDER_BY_DESC);
801 }
802 }
803 }
804 }
805 else {
806 if (getDB().isSupportsInlineDistinct()) {
807 query.append(SCProductEntryModelImpl.ORDER_BY_JPQL);
808 }
809 else {
810 query.append(SCProductEntryModelImpl.ORDER_BY_SQL);
811 }
812 }
813
814 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
815 SCProductEntry.class.getName(),
816 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
817
818 SQLQuery q = session.createSynchronizedSQLQuery(sql);
819
820 q.setFirstResult(0);
821 q.setMaxResults(2);
822
823 if (getDB().isSupportsInlineDistinct()) {
824 q.addEntity(_FILTER_ENTITY_ALIAS, SCProductEntryImpl.class);
825 }
826 else {
827 q.addEntity(_FILTER_ENTITY_TABLE, SCProductEntryImpl.class);
828 }
829
830 QueryPos qPos = QueryPos.getInstance(q);
831
832 qPos.add(groupId);
833
834 if (orderByComparator != null) {
835 Object[] values = orderByComparator.getOrderByConditionValues(scProductEntry);
836
837 for (Object value : values) {
838 qPos.add(value);
839 }
840 }
841
842 List<SCProductEntry> list = q.list();
843
844 if (list.size() == 2) {
845 return list.get(1);
846 }
847 else {
848 return null;
849 }
850 }
851
852
857 @Override
858 public void removeByGroupId(long groupId) {
859 for (SCProductEntry scProductEntry : findByGroupId(groupId,
860 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
861 remove(scProductEntry);
862 }
863 }
864
865
871 @Override
872 public int countByGroupId(long groupId) {
873 FinderPath finderPath = FINDER_PATH_COUNT_BY_GROUPID;
874
875 Object[] finderArgs = new Object[] { groupId };
876
877 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
878
879 if (count == null) {
880 StringBundler query = new StringBundler(2);
881
882 query.append(_SQL_COUNT_SCPRODUCTENTRY_WHERE);
883
884 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
885
886 String sql = query.toString();
887
888 Session session = null;
889
890 try {
891 session = openSession();
892
893 Query q = session.createQuery(sql);
894
895 QueryPos qPos = QueryPos.getInstance(q);
896
897 qPos.add(groupId);
898
899 count = (Long)q.uniqueResult();
900
901 finderCache.putResult(finderPath, finderArgs, count);
902 }
903 catch (Exception e) {
904 finderCache.removeResult(finderPath, finderArgs);
905
906 throw processException(e);
907 }
908 finally {
909 closeSession(session);
910 }
911 }
912
913 return count.intValue();
914 }
915
916
922 @Override
923 public int filterCountByGroupId(long groupId) {
924 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
925 return countByGroupId(groupId);
926 }
927
928 StringBundler query = new StringBundler(2);
929
930 query.append(_FILTER_SQL_COUNT_SCPRODUCTENTRY_WHERE);
931
932 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
933
934 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
935 SCProductEntry.class.getName(),
936 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
937
938 Session session = null;
939
940 try {
941 session = openSession();
942
943 SQLQuery q = session.createSynchronizedSQLQuery(sql);
944
945 q.addScalar(COUNT_COLUMN_NAME,
946 com.liferay.portal.kernel.dao.orm.Type.LONG);
947
948 QueryPos qPos = QueryPos.getInstance(q);
949
950 qPos.add(groupId);
951
952 Long count = (Long)q.uniqueResult();
953
954 return count.intValue();
955 }
956 catch (Exception e) {
957 throw processException(e);
958 }
959 finally {
960 closeSession(session);
961 }
962 }
963
964 private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "scProductEntry.groupId = ?";
965 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID =
966 new FinderPath(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
967 SCProductEntryModelImpl.FINDER_CACHE_ENABLED,
968 SCProductEntryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
969 "findByCompanyId",
970 new String[] {
971 Long.class.getName(),
972
973 Integer.class.getName(), Integer.class.getName(),
974 OrderByComparator.class.getName()
975 });
976 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID =
977 new FinderPath(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
978 SCProductEntryModelImpl.FINDER_CACHE_ENABLED,
979 SCProductEntryImpl.class,
980 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCompanyId",
981 new String[] { Long.class.getName() },
982 SCProductEntryModelImpl.COMPANYID_COLUMN_BITMASK |
983 SCProductEntryModelImpl.MODIFIEDDATE_COLUMN_BITMASK |
984 SCProductEntryModelImpl.NAME_COLUMN_BITMASK);
985 public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
986 SCProductEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
987 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCompanyId",
988 new String[] { Long.class.getName() });
989
990
996 @Override
997 public List<SCProductEntry> findByCompanyId(long companyId) {
998 return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
999 null);
1000 }
1001
1002
1014 @Override
1015 public List<SCProductEntry> findByCompanyId(long companyId, int start,
1016 int end) {
1017 return findByCompanyId(companyId, start, end, null);
1018 }
1019
1020
1033 @Override
1034 public List<SCProductEntry> findByCompanyId(long companyId, int start,
1035 int end, OrderByComparator<SCProductEntry> orderByComparator) {
1036 return findByCompanyId(companyId, start, end, orderByComparator, true);
1037 }
1038
1039
1053 @Override
1054 public List<SCProductEntry> findByCompanyId(long companyId, int start,
1055 int end, OrderByComparator<SCProductEntry> orderByComparator,
1056 boolean retrieveFromCache) {
1057 boolean pagination = true;
1058 FinderPath finderPath = null;
1059 Object[] finderArgs = null;
1060
1061 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1062 (orderByComparator == null)) {
1063 pagination = false;
1064 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID;
1065 finderArgs = new Object[] { companyId };
1066 }
1067 else {
1068 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID;
1069 finderArgs = new Object[] { companyId, start, end, orderByComparator };
1070 }
1071
1072 List<SCProductEntry> list = null;
1073
1074 if (retrieveFromCache) {
1075 list = (List<SCProductEntry>)finderCache.getResult(finderPath,
1076 finderArgs, this);
1077
1078 if ((list != null) && !list.isEmpty()) {
1079 for (SCProductEntry scProductEntry : list) {
1080 if ((companyId != scProductEntry.getCompanyId())) {
1081 list = null;
1082
1083 break;
1084 }
1085 }
1086 }
1087 }
1088
1089 if (list == null) {
1090 StringBundler query = null;
1091
1092 if (orderByComparator != null) {
1093 query = new StringBundler(3 +
1094 (orderByComparator.getOrderByFields().length * 3));
1095 }
1096 else {
1097 query = new StringBundler(3);
1098 }
1099
1100 query.append(_SQL_SELECT_SCPRODUCTENTRY_WHERE);
1101
1102 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1103
1104 if (orderByComparator != null) {
1105 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1106 orderByComparator);
1107 }
1108 else
1109 if (pagination) {
1110 query.append(SCProductEntryModelImpl.ORDER_BY_JPQL);
1111 }
1112
1113 String sql = query.toString();
1114
1115 Session session = null;
1116
1117 try {
1118 session = openSession();
1119
1120 Query q = session.createQuery(sql);
1121
1122 QueryPos qPos = QueryPos.getInstance(q);
1123
1124 qPos.add(companyId);
1125
1126 if (!pagination) {
1127 list = (List<SCProductEntry>)QueryUtil.list(q,
1128 getDialect(), start, end, false);
1129
1130 Collections.sort(list);
1131
1132 list = Collections.unmodifiableList(list);
1133 }
1134 else {
1135 list = (List<SCProductEntry>)QueryUtil.list(q,
1136 getDialect(), start, end);
1137 }
1138
1139 cacheResult(list);
1140
1141 finderCache.putResult(finderPath, finderArgs, list);
1142 }
1143 catch (Exception e) {
1144 finderCache.removeResult(finderPath, finderArgs);
1145
1146 throw processException(e);
1147 }
1148 finally {
1149 closeSession(session);
1150 }
1151 }
1152
1153 return list;
1154 }
1155
1156
1164 @Override
1165 public SCProductEntry findByCompanyId_First(long companyId,
1166 OrderByComparator<SCProductEntry> orderByComparator)
1167 throws NoSuchProductEntryException {
1168 SCProductEntry scProductEntry = fetchByCompanyId_First(companyId,
1169 orderByComparator);
1170
1171 if (scProductEntry != null) {
1172 return scProductEntry;
1173 }
1174
1175 StringBundler msg = new StringBundler(4);
1176
1177 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1178
1179 msg.append("companyId=");
1180 msg.append(companyId);
1181
1182 msg.append(StringPool.CLOSE_CURLY_BRACE);
1183
1184 throw new NoSuchProductEntryException(msg.toString());
1185 }
1186
1187
1194 @Override
1195 public SCProductEntry fetchByCompanyId_First(long companyId,
1196 OrderByComparator<SCProductEntry> orderByComparator) {
1197 List<SCProductEntry> list = findByCompanyId(companyId, 0, 1,
1198 orderByComparator);
1199
1200 if (!list.isEmpty()) {
1201 return list.get(0);
1202 }
1203
1204 return null;
1205 }
1206
1207
1215 @Override
1216 public SCProductEntry findByCompanyId_Last(long companyId,
1217 OrderByComparator<SCProductEntry> orderByComparator)
1218 throws NoSuchProductEntryException {
1219 SCProductEntry scProductEntry = fetchByCompanyId_Last(companyId,
1220 orderByComparator);
1221
1222 if (scProductEntry != null) {
1223 return scProductEntry;
1224 }
1225
1226 StringBundler msg = new StringBundler(4);
1227
1228 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1229
1230 msg.append("companyId=");
1231 msg.append(companyId);
1232
1233 msg.append(StringPool.CLOSE_CURLY_BRACE);
1234
1235 throw new NoSuchProductEntryException(msg.toString());
1236 }
1237
1238
1245 @Override
1246 public SCProductEntry fetchByCompanyId_Last(long companyId,
1247 OrderByComparator<SCProductEntry> orderByComparator) {
1248 int count = countByCompanyId(companyId);
1249
1250 if (count == 0) {
1251 return null;
1252 }
1253
1254 List<SCProductEntry> list = findByCompanyId(companyId, count - 1,
1255 count, orderByComparator);
1256
1257 if (!list.isEmpty()) {
1258 return list.get(0);
1259 }
1260
1261 return null;
1262 }
1263
1264
1273 @Override
1274 public SCProductEntry[] findByCompanyId_PrevAndNext(long productEntryId,
1275 long companyId, OrderByComparator<SCProductEntry> orderByComparator)
1276 throws NoSuchProductEntryException {
1277 SCProductEntry scProductEntry = findByPrimaryKey(productEntryId);
1278
1279 Session session = null;
1280
1281 try {
1282 session = openSession();
1283
1284 SCProductEntry[] array = new SCProductEntryImpl[3];
1285
1286 array[0] = getByCompanyId_PrevAndNext(session, scProductEntry,
1287 companyId, orderByComparator, true);
1288
1289 array[1] = scProductEntry;
1290
1291 array[2] = getByCompanyId_PrevAndNext(session, scProductEntry,
1292 companyId, orderByComparator, false);
1293
1294 return array;
1295 }
1296 catch (Exception e) {
1297 throw processException(e);
1298 }
1299 finally {
1300 closeSession(session);
1301 }
1302 }
1303
1304 protected SCProductEntry getByCompanyId_PrevAndNext(Session session,
1305 SCProductEntry scProductEntry, long companyId,
1306 OrderByComparator<SCProductEntry> orderByComparator, boolean previous) {
1307 StringBundler query = null;
1308
1309 if (orderByComparator != null) {
1310 query = new StringBundler(6 +
1311 (orderByComparator.getOrderByFields().length * 6));
1312 }
1313 else {
1314 query = new StringBundler(3);
1315 }
1316
1317 query.append(_SQL_SELECT_SCPRODUCTENTRY_WHERE);
1318
1319 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1320
1321 if (orderByComparator != null) {
1322 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1323
1324 if (orderByConditionFields.length > 0) {
1325 query.append(WHERE_AND);
1326 }
1327
1328 for (int i = 0; i < orderByConditionFields.length; i++) {
1329 query.append(_ORDER_BY_ENTITY_ALIAS);
1330 query.append(orderByConditionFields[i]);
1331
1332 if ((i + 1) < orderByConditionFields.length) {
1333 if (orderByComparator.isAscending() ^ previous) {
1334 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1335 }
1336 else {
1337 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1338 }
1339 }
1340 else {
1341 if (orderByComparator.isAscending() ^ previous) {
1342 query.append(WHERE_GREATER_THAN);
1343 }
1344 else {
1345 query.append(WHERE_LESSER_THAN);
1346 }
1347 }
1348 }
1349
1350 query.append(ORDER_BY_CLAUSE);
1351
1352 String[] orderByFields = orderByComparator.getOrderByFields();
1353
1354 for (int i = 0; i < orderByFields.length; i++) {
1355 query.append(_ORDER_BY_ENTITY_ALIAS);
1356 query.append(orderByFields[i]);
1357
1358 if ((i + 1) < orderByFields.length) {
1359 if (orderByComparator.isAscending() ^ previous) {
1360 query.append(ORDER_BY_ASC_HAS_NEXT);
1361 }
1362 else {
1363 query.append(ORDER_BY_DESC_HAS_NEXT);
1364 }
1365 }
1366 else {
1367 if (orderByComparator.isAscending() ^ previous) {
1368 query.append(ORDER_BY_ASC);
1369 }
1370 else {
1371 query.append(ORDER_BY_DESC);
1372 }
1373 }
1374 }
1375 }
1376 else {
1377 query.append(SCProductEntryModelImpl.ORDER_BY_JPQL);
1378 }
1379
1380 String sql = query.toString();
1381
1382 Query q = session.createQuery(sql);
1383
1384 q.setFirstResult(0);
1385 q.setMaxResults(2);
1386
1387 QueryPos qPos = QueryPos.getInstance(q);
1388
1389 qPos.add(companyId);
1390
1391 if (orderByComparator != null) {
1392 Object[] values = orderByComparator.getOrderByConditionValues(scProductEntry);
1393
1394 for (Object value : values) {
1395 qPos.add(value);
1396 }
1397 }
1398
1399 List<SCProductEntry> list = q.list();
1400
1401 if (list.size() == 2) {
1402 return list.get(1);
1403 }
1404 else {
1405 return null;
1406 }
1407 }
1408
1409
1414 @Override
1415 public void removeByCompanyId(long companyId) {
1416 for (SCProductEntry scProductEntry : findByCompanyId(companyId,
1417 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1418 remove(scProductEntry);
1419 }
1420 }
1421
1422
1428 @Override
1429 public int countByCompanyId(long companyId) {
1430 FinderPath finderPath = FINDER_PATH_COUNT_BY_COMPANYID;
1431
1432 Object[] finderArgs = new Object[] { companyId };
1433
1434 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
1435
1436 if (count == null) {
1437 StringBundler query = new StringBundler(2);
1438
1439 query.append(_SQL_COUNT_SCPRODUCTENTRY_WHERE);
1440
1441 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1442
1443 String sql = query.toString();
1444
1445 Session session = null;
1446
1447 try {
1448 session = openSession();
1449
1450 Query q = session.createQuery(sql);
1451
1452 QueryPos qPos = QueryPos.getInstance(q);
1453
1454 qPos.add(companyId);
1455
1456 count = (Long)q.uniqueResult();
1457
1458 finderCache.putResult(finderPath, finderArgs, count);
1459 }
1460 catch (Exception e) {
1461 finderCache.removeResult(finderPath, finderArgs);
1462
1463 throw processException(e);
1464 }
1465 finally {
1466 closeSession(session);
1467 }
1468 }
1469
1470 return count.intValue();
1471 }
1472
1473 private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "scProductEntry.companyId = ?";
1474 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U = new FinderPath(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
1475 SCProductEntryModelImpl.FINDER_CACHE_ENABLED,
1476 SCProductEntryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
1477 "findByG_U",
1478 new String[] {
1479 Long.class.getName(), Long.class.getName(),
1480
1481 Integer.class.getName(), Integer.class.getName(),
1482 OrderByComparator.class.getName()
1483 });
1484 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U = new FinderPath(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
1485 SCProductEntryModelImpl.FINDER_CACHE_ENABLED,
1486 SCProductEntryImpl.class,
1487 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_U",
1488 new String[] { Long.class.getName(), Long.class.getName() },
1489 SCProductEntryModelImpl.GROUPID_COLUMN_BITMASK |
1490 SCProductEntryModelImpl.USERID_COLUMN_BITMASK |
1491 SCProductEntryModelImpl.MODIFIEDDATE_COLUMN_BITMASK |
1492 SCProductEntryModelImpl.NAME_COLUMN_BITMASK);
1493 public static final FinderPath FINDER_PATH_COUNT_BY_G_U = new FinderPath(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
1494 SCProductEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
1495 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_U",
1496 new String[] { Long.class.getName(), Long.class.getName() });
1497
1498
1505 @Override
1506 public List<SCProductEntry> findByG_U(long groupId, long userId) {
1507 return findByG_U(groupId, userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
1508 null);
1509 }
1510
1511
1524 @Override
1525 public List<SCProductEntry> findByG_U(long groupId, long userId, int start,
1526 int end) {
1527 return findByG_U(groupId, userId, start, end, null);
1528 }
1529
1530
1544 @Override
1545 public List<SCProductEntry> findByG_U(long groupId, long userId, int start,
1546 int end, OrderByComparator<SCProductEntry> orderByComparator) {
1547 return findByG_U(groupId, userId, start, end, orderByComparator, true);
1548 }
1549
1550
1565 @Override
1566 public List<SCProductEntry> findByG_U(long groupId, long userId, int start,
1567 int end, OrderByComparator<SCProductEntry> orderByComparator,
1568 boolean retrieveFromCache) {
1569 boolean pagination = true;
1570 FinderPath finderPath = null;
1571 Object[] finderArgs = null;
1572
1573 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1574 (orderByComparator == null)) {
1575 pagination = false;
1576 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U;
1577 finderArgs = new Object[] { groupId, userId };
1578 }
1579 else {
1580 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U;
1581 finderArgs = new Object[] {
1582 groupId, userId,
1583
1584 start, end, orderByComparator
1585 };
1586 }
1587
1588 List<SCProductEntry> list = null;
1589
1590 if (retrieveFromCache) {
1591 list = (List<SCProductEntry>)finderCache.getResult(finderPath,
1592 finderArgs, this);
1593
1594 if ((list != null) && !list.isEmpty()) {
1595 for (SCProductEntry scProductEntry : list) {
1596 if ((groupId != scProductEntry.getGroupId()) ||
1597 (userId != scProductEntry.getUserId())) {
1598 list = null;
1599
1600 break;
1601 }
1602 }
1603 }
1604 }
1605
1606 if (list == null) {
1607 StringBundler query = null;
1608
1609 if (orderByComparator != null) {
1610 query = new StringBundler(4 +
1611 (orderByComparator.getOrderByFields().length * 3));
1612 }
1613 else {
1614 query = new StringBundler(4);
1615 }
1616
1617 query.append(_SQL_SELECT_SCPRODUCTENTRY_WHERE);
1618
1619 query.append(_FINDER_COLUMN_G_U_GROUPID_2);
1620
1621 query.append(_FINDER_COLUMN_G_U_USERID_2);
1622
1623 if (orderByComparator != null) {
1624 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1625 orderByComparator);
1626 }
1627 else
1628 if (pagination) {
1629 query.append(SCProductEntryModelImpl.ORDER_BY_JPQL);
1630 }
1631
1632 String sql = query.toString();
1633
1634 Session session = null;
1635
1636 try {
1637 session = openSession();
1638
1639 Query q = session.createQuery(sql);
1640
1641 QueryPos qPos = QueryPos.getInstance(q);
1642
1643 qPos.add(groupId);
1644
1645 qPos.add(userId);
1646
1647 if (!pagination) {
1648 list = (List<SCProductEntry>)QueryUtil.list(q,
1649 getDialect(), start, end, false);
1650
1651 Collections.sort(list);
1652
1653 list = Collections.unmodifiableList(list);
1654 }
1655 else {
1656 list = (List<SCProductEntry>)QueryUtil.list(q,
1657 getDialect(), start, end);
1658 }
1659
1660 cacheResult(list);
1661
1662 finderCache.putResult(finderPath, finderArgs, list);
1663 }
1664 catch (Exception e) {
1665 finderCache.removeResult(finderPath, finderArgs);
1666
1667 throw processException(e);
1668 }
1669 finally {
1670 closeSession(session);
1671 }
1672 }
1673
1674 return list;
1675 }
1676
1677
1686 @Override
1687 public SCProductEntry findByG_U_First(long groupId, long userId,
1688 OrderByComparator<SCProductEntry> orderByComparator)
1689 throws NoSuchProductEntryException {
1690 SCProductEntry scProductEntry = fetchByG_U_First(groupId, userId,
1691 orderByComparator);
1692
1693 if (scProductEntry != null) {
1694 return scProductEntry;
1695 }
1696
1697 StringBundler msg = new StringBundler(6);
1698
1699 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1700
1701 msg.append("groupId=");
1702 msg.append(groupId);
1703
1704 msg.append(", userId=");
1705 msg.append(userId);
1706
1707 msg.append(StringPool.CLOSE_CURLY_BRACE);
1708
1709 throw new NoSuchProductEntryException(msg.toString());
1710 }
1711
1712
1720 @Override
1721 public SCProductEntry fetchByG_U_First(long groupId, long userId,
1722 OrderByComparator<SCProductEntry> orderByComparator) {
1723 List<SCProductEntry> list = findByG_U(groupId, userId, 0, 1,
1724 orderByComparator);
1725
1726 if (!list.isEmpty()) {
1727 return list.get(0);
1728 }
1729
1730 return null;
1731 }
1732
1733
1742 @Override
1743 public SCProductEntry findByG_U_Last(long groupId, long userId,
1744 OrderByComparator<SCProductEntry> orderByComparator)
1745 throws NoSuchProductEntryException {
1746 SCProductEntry scProductEntry = fetchByG_U_Last(groupId, userId,
1747 orderByComparator);
1748
1749 if (scProductEntry != null) {
1750 return scProductEntry;
1751 }
1752
1753 StringBundler msg = new StringBundler(6);
1754
1755 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1756
1757 msg.append("groupId=");
1758 msg.append(groupId);
1759
1760 msg.append(", userId=");
1761 msg.append(userId);
1762
1763 msg.append(StringPool.CLOSE_CURLY_BRACE);
1764
1765 throw new NoSuchProductEntryException(msg.toString());
1766 }
1767
1768
1776 @Override
1777 public SCProductEntry fetchByG_U_Last(long groupId, long userId,
1778 OrderByComparator<SCProductEntry> orderByComparator) {
1779 int count = countByG_U(groupId, userId);
1780
1781 if (count == 0) {
1782 return null;
1783 }
1784
1785 List<SCProductEntry> list = findByG_U(groupId, userId, count - 1,
1786 count, orderByComparator);
1787
1788 if (!list.isEmpty()) {
1789 return list.get(0);
1790 }
1791
1792 return null;
1793 }
1794
1795
1805 @Override
1806 public SCProductEntry[] findByG_U_PrevAndNext(long productEntryId,
1807 long groupId, long userId,
1808 OrderByComparator<SCProductEntry> orderByComparator)
1809 throws NoSuchProductEntryException {
1810 SCProductEntry scProductEntry = findByPrimaryKey(productEntryId);
1811
1812 Session session = null;
1813
1814 try {
1815 session = openSession();
1816
1817 SCProductEntry[] array = new SCProductEntryImpl[3];
1818
1819 array[0] = getByG_U_PrevAndNext(session, scProductEntry, groupId,
1820 userId, orderByComparator, true);
1821
1822 array[1] = scProductEntry;
1823
1824 array[2] = getByG_U_PrevAndNext(session, scProductEntry, groupId,
1825 userId, orderByComparator, false);
1826
1827 return array;
1828 }
1829 catch (Exception e) {
1830 throw processException(e);
1831 }
1832 finally {
1833 closeSession(session);
1834 }
1835 }
1836
1837 protected SCProductEntry getByG_U_PrevAndNext(Session session,
1838 SCProductEntry scProductEntry, long groupId, long userId,
1839 OrderByComparator<SCProductEntry> orderByComparator, boolean previous) {
1840 StringBundler query = null;
1841
1842 if (orderByComparator != null) {
1843 query = new StringBundler(6 +
1844 (orderByComparator.getOrderByFields().length * 6));
1845 }
1846 else {
1847 query = new StringBundler(3);
1848 }
1849
1850 query.append(_SQL_SELECT_SCPRODUCTENTRY_WHERE);
1851
1852 query.append(_FINDER_COLUMN_G_U_GROUPID_2);
1853
1854 query.append(_FINDER_COLUMN_G_U_USERID_2);
1855
1856 if (orderByComparator != null) {
1857 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1858
1859 if (orderByConditionFields.length > 0) {
1860 query.append(WHERE_AND);
1861 }
1862
1863 for (int i = 0; i < orderByConditionFields.length; i++) {
1864 query.append(_ORDER_BY_ENTITY_ALIAS);
1865 query.append(orderByConditionFields[i]);
1866
1867 if ((i + 1) < orderByConditionFields.length) {
1868 if (orderByComparator.isAscending() ^ previous) {
1869 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1870 }
1871 else {
1872 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1873 }
1874 }
1875 else {
1876 if (orderByComparator.isAscending() ^ previous) {
1877 query.append(WHERE_GREATER_THAN);
1878 }
1879 else {
1880 query.append(WHERE_LESSER_THAN);
1881 }
1882 }
1883 }
1884
1885 query.append(ORDER_BY_CLAUSE);
1886
1887 String[] orderByFields = orderByComparator.getOrderByFields();
1888
1889 for (int i = 0; i < orderByFields.length; i++) {
1890 query.append(_ORDER_BY_ENTITY_ALIAS);
1891 query.append(orderByFields[i]);
1892
1893 if ((i + 1) < orderByFields.length) {
1894 if (orderByComparator.isAscending() ^ previous) {
1895 query.append(ORDER_BY_ASC_HAS_NEXT);
1896 }
1897 else {
1898 query.append(ORDER_BY_DESC_HAS_NEXT);
1899 }
1900 }
1901 else {
1902 if (orderByComparator.isAscending() ^ previous) {
1903 query.append(ORDER_BY_ASC);
1904 }
1905 else {
1906 query.append(ORDER_BY_DESC);
1907 }
1908 }
1909 }
1910 }
1911 else {
1912 query.append(SCProductEntryModelImpl.ORDER_BY_JPQL);
1913 }
1914
1915 String sql = query.toString();
1916
1917 Query q = session.createQuery(sql);
1918
1919 q.setFirstResult(0);
1920 q.setMaxResults(2);
1921
1922 QueryPos qPos = QueryPos.getInstance(q);
1923
1924 qPos.add(groupId);
1925
1926 qPos.add(userId);
1927
1928 if (orderByComparator != null) {
1929 Object[] values = orderByComparator.getOrderByConditionValues(scProductEntry);
1930
1931 for (Object value : values) {
1932 qPos.add(value);
1933 }
1934 }
1935
1936 List<SCProductEntry> list = q.list();
1937
1938 if (list.size() == 2) {
1939 return list.get(1);
1940 }
1941 else {
1942 return null;
1943 }
1944 }
1945
1946
1953 @Override
1954 public List<SCProductEntry> filterFindByG_U(long groupId, long userId) {
1955 return filterFindByG_U(groupId, userId, QueryUtil.ALL_POS,
1956 QueryUtil.ALL_POS, null);
1957 }
1958
1959
1972 @Override
1973 public List<SCProductEntry> filterFindByG_U(long groupId, long userId,
1974 int start, int end) {
1975 return filterFindByG_U(groupId, userId, start, end, null);
1976 }
1977
1978
1992 @Override
1993 public List<SCProductEntry> filterFindByG_U(long groupId, long userId,
1994 int start, int end, OrderByComparator<SCProductEntry> orderByComparator) {
1995 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1996 return findByG_U(groupId, userId, start, end, orderByComparator);
1997 }
1998
1999 StringBundler query = null;
2000
2001 if (orderByComparator != null) {
2002 query = new StringBundler(4 +
2003 (orderByComparator.getOrderByFields().length * 3));
2004 }
2005 else {
2006 query = new StringBundler(4);
2007 }
2008
2009 if (getDB().isSupportsInlineDistinct()) {
2010 query.append(_FILTER_SQL_SELECT_SCPRODUCTENTRY_WHERE);
2011 }
2012 else {
2013 query.append(_FILTER_SQL_SELECT_SCPRODUCTENTRY_NO_INLINE_DISTINCT_WHERE_1);
2014 }
2015
2016 query.append(_FINDER_COLUMN_G_U_GROUPID_2);
2017
2018 query.append(_FINDER_COLUMN_G_U_USERID_2);
2019
2020 if (!getDB().isSupportsInlineDistinct()) {
2021 query.append(_FILTER_SQL_SELECT_SCPRODUCTENTRY_NO_INLINE_DISTINCT_WHERE_2);
2022 }
2023
2024 if (orderByComparator != null) {
2025 if (getDB().isSupportsInlineDistinct()) {
2026 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2027 orderByComparator, true);
2028 }
2029 else {
2030 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
2031 orderByComparator, true);
2032 }
2033 }
2034 else {
2035 if (getDB().isSupportsInlineDistinct()) {
2036 query.append(SCProductEntryModelImpl.ORDER_BY_JPQL);
2037 }
2038 else {
2039 query.append(SCProductEntryModelImpl.ORDER_BY_SQL);
2040 }
2041 }
2042
2043 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2044 SCProductEntry.class.getName(),
2045 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2046
2047 Session session = null;
2048
2049 try {
2050 session = openSession();
2051
2052 SQLQuery q = session.createSynchronizedSQLQuery(sql);
2053
2054 if (getDB().isSupportsInlineDistinct()) {
2055 q.addEntity(_FILTER_ENTITY_ALIAS, SCProductEntryImpl.class);
2056 }
2057 else {
2058 q.addEntity(_FILTER_ENTITY_TABLE, SCProductEntryImpl.class);
2059 }
2060
2061 QueryPos qPos = QueryPos.getInstance(q);
2062
2063 qPos.add(groupId);
2064
2065 qPos.add(userId);
2066
2067 return (List<SCProductEntry>)QueryUtil.list(q, getDialect(), start,
2068 end);
2069 }
2070 catch (Exception e) {
2071 throw processException(e);
2072 }
2073 finally {
2074 closeSession(session);
2075 }
2076 }
2077
2078
2088 @Override
2089 public SCProductEntry[] filterFindByG_U_PrevAndNext(long productEntryId,
2090 long groupId, long userId,
2091 OrderByComparator<SCProductEntry> orderByComparator)
2092 throws NoSuchProductEntryException {
2093 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2094 return findByG_U_PrevAndNext(productEntryId, groupId, userId,
2095 orderByComparator);
2096 }
2097
2098 SCProductEntry scProductEntry = findByPrimaryKey(productEntryId);
2099
2100 Session session = null;
2101
2102 try {
2103 session = openSession();
2104
2105 SCProductEntry[] array = new SCProductEntryImpl[3];
2106
2107 array[0] = filterGetByG_U_PrevAndNext(session, scProductEntry,
2108 groupId, userId, orderByComparator, true);
2109
2110 array[1] = scProductEntry;
2111
2112 array[2] = filterGetByG_U_PrevAndNext(session, scProductEntry,
2113 groupId, userId, orderByComparator, false);
2114
2115 return array;
2116 }
2117 catch (Exception e) {
2118 throw processException(e);
2119 }
2120 finally {
2121 closeSession(session);
2122 }
2123 }
2124
2125 protected SCProductEntry filterGetByG_U_PrevAndNext(Session session,
2126 SCProductEntry scProductEntry, long groupId, long userId,
2127 OrderByComparator<SCProductEntry> orderByComparator, boolean previous) {
2128 StringBundler query = null;
2129
2130 if (orderByComparator != null) {
2131 query = new StringBundler(6 +
2132 (orderByComparator.getOrderByFields().length * 6));
2133 }
2134 else {
2135 query = new StringBundler(3);
2136 }
2137
2138 if (getDB().isSupportsInlineDistinct()) {
2139 query.append(_FILTER_SQL_SELECT_SCPRODUCTENTRY_WHERE);
2140 }
2141 else {
2142 query.append(_FILTER_SQL_SELECT_SCPRODUCTENTRY_NO_INLINE_DISTINCT_WHERE_1);
2143 }
2144
2145 query.append(_FINDER_COLUMN_G_U_GROUPID_2);
2146
2147 query.append(_FINDER_COLUMN_G_U_USERID_2);
2148
2149 if (!getDB().isSupportsInlineDistinct()) {
2150 query.append(_FILTER_SQL_SELECT_SCPRODUCTENTRY_NO_INLINE_DISTINCT_WHERE_2);
2151 }
2152
2153 if (orderByComparator != null) {
2154 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2155
2156 if (orderByConditionFields.length > 0) {
2157 query.append(WHERE_AND);
2158 }
2159
2160 for (int i = 0; i < orderByConditionFields.length; i++) {
2161 if (getDB().isSupportsInlineDistinct()) {
2162 query.append(_ORDER_BY_ENTITY_ALIAS);
2163 }
2164 else {
2165 query.append(_ORDER_BY_ENTITY_TABLE);
2166 }
2167
2168 query.append(orderByConditionFields[i]);
2169
2170 if ((i + 1) < orderByConditionFields.length) {
2171 if (orderByComparator.isAscending() ^ previous) {
2172 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2173 }
2174 else {
2175 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2176 }
2177 }
2178 else {
2179 if (orderByComparator.isAscending() ^ previous) {
2180 query.append(WHERE_GREATER_THAN);
2181 }
2182 else {
2183 query.append(WHERE_LESSER_THAN);
2184 }
2185 }
2186 }
2187
2188 query.append(ORDER_BY_CLAUSE);
2189
2190 String[] orderByFields = orderByComparator.getOrderByFields();
2191
2192 for (int i = 0; i < orderByFields.length; i++) {
2193 if (getDB().isSupportsInlineDistinct()) {
2194 query.append(_ORDER_BY_ENTITY_ALIAS);
2195 }
2196 else {
2197 query.append(_ORDER_BY_ENTITY_TABLE);
2198 }
2199
2200 query.append(orderByFields[i]);
2201
2202 if ((i + 1) < orderByFields.length) {
2203 if (orderByComparator.isAscending() ^ previous) {
2204 query.append(ORDER_BY_ASC_HAS_NEXT);
2205 }
2206 else {
2207 query.append(ORDER_BY_DESC_HAS_NEXT);
2208 }
2209 }
2210 else {
2211 if (orderByComparator.isAscending() ^ previous) {
2212 query.append(ORDER_BY_ASC);
2213 }
2214 else {
2215 query.append(ORDER_BY_DESC);
2216 }
2217 }
2218 }
2219 }
2220 else {
2221 if (getDB().isSupportsInlineDistinct()) {
2222 query.append(SCProductEntryModelImpl.ORDER_BY_JPQL);
2223 }
2224 else {
2225 query.append(SCProductEntryModelImpl.ORDER_BY_SQL);
2226 }
2227 }
2228
2229 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2230 SCProductEntry.class.getName(),
2231 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2232
2233 SQLQuery q = session.createSynchronizedSQLQuery(sql);
2234
2235 q.setFirstResult(0);
2236 q.setMaxResults(2);
2237
2238 if (getDB().isSupportsInlineDistinct()) {
2239 q.addEntity(_FILTER_ENTITY_ALIAS, SCProductEntryImpl.class);
2240 }
2241 else {
2242 q.addEntity(_FILTER_ENTITY_TABLE, SCProductEntryImpl.class);
2243 }
2244
2245 QueryPos qPos = QueryPos.getInstance(q);
2246
2247 qPos.add(groupId);
2248
2249 qPos.add(userId);
2250
2251 if (orderByComparator != null) {
2252 Object[] values = orderByComparator.getOrderByConditionValues(scProductEntry);
2253
2254 for (Object value : values) {
2255 qPos.add(value);
2256 }
2257 }
2258
2259 List<SCProductEntry> list = q.list();
2260
2261 if (list.size() == 2) {
2262 return list.get(1);
2263 }
2264 else {
2265 return null;
2266 }
2267 }
2268
2269
2275 @Override
2276 public void removeByG_U(long groupId, long userId) {
2277 for (SCProductEntry scProductEntry : findByG_U(groupId, userId,
2278 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
2279 remove(scProductEntry);
2280 }
2281 }
2282
2283
2290 @Override
2291 public int countByG_U(long groupId, long userId) {
2292 FinderPath finderPath = FINDER_PATH_COUNT_BY_G_U;
2293
2294 Object[] finderArgs = new Object[] { groupId, userId };
2295
2296 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
2297
2298 if (count == null) {
2299 StringBundler query = new StringBundler(3);
2300
2301 query.append(_SQL_COUNT_SCPRODUCTENTRY_WHERE);
2302
2303 query.append(_FINDER_COLUMN_G_U_GROUPID_2);
2304
2305 query.append(_FINDER_COLUMN_G_U_USERID_2);
2306
2307 String sql = query.toString();
2308
2309 Session session = null;
2310
2311 try {
2312 session = openSession();
2313
2314 Query q = session.createQuery(sql);
2315
2316 QueryPos qPos = QueryPos.getInstance(q);
2317
2318 qPos.add(groupId);
2319
2320 qPos.add(userId);
2321
2322 count = (Long)q.uniqueResult();
2323
2324 finderCache.putResult(finderPath, finderArgs, count);
2325 }
2326 catch (Exception e) {
2327 finderCache.removeResult(finderPath, finderArgs);
2328
2329 throw processException(e);
2330 }
2331 finally {
2332 closeSession(session);
2333 }
2334 }
2335
2336 return count.intValue();
2337 }
2338
2339
2346 @Override
2347 public int filterCountByG_U(long groupId, long userId) {
2348 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2349 return countByG_U(groupId, userId);
2350 }
2351
2352 StringBundler query = new StringBundler(3);
2353
2354 query.append(_FILTER_SQL_COUNT_SCPRODUCTENTRY_WHERE);
2355
2356 query.append(_FINDER_COLUMN_G_U_GROUPID_2);
2357
2358 query.append(_FINDER_COLUMN_G_U_USERID_2);
2359
2360 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2361 SCProductEntry.class.getName(),
2362 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2363
2364 Session session = null;
2365
2366 try {
2367 session = openSession();
2368
2369 SQLQuery q = session.createSynchronizedSQLQuery(sql);
2370
2371 q.addScalar(COUNT_COLUMN_NAME,
2372 com.liferay.portal.kernel.dao.orm.Type.LONG);
2373
2374 QueryPos qPos = QueryPos.getInstance(q);
2375
2376 qPos.add(groupId);
2377
2378 qPos.add(userId);
2379
2380 Long count = (Long)q.uniqueResult();
2381
2382 return count.intValue();
2383 }
2384 catch (Exception e) {
2385 throw processException(e);
2386 }
2387 finally {
2388 closeSession(session);
2389 }
2390 }
2391
2392 private static final String _FINDER_COLUMN_G_U_GROUPID_2 = "scProductEntry.groupId = ? AND ";
2393 private static final String _FINDER_COLUMN_G_U_USERID_2 = "scProductEntry.userId = ?";
2394 public static final FinderPath FINDER_PATH_FETCH_BY_RG_RA = new FinderPath(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
2395 SCProductEntryModelImpl.FINDER_CACHE_ENABLED,
2396 SCProductEntryImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByRG_RA",
2397 new String[] { String.class.getName(), String.class.getName() },
2398 SCProductEntryModelImpl.REPOGROUPID_COLUMN_BITMASK |
2399 SCProductEntryModelImpl.REPOARTIFACTID_COLUMN_BITMASK);
2400 public static final FinderPath FINDER_PATH_COUNT_BY_RG_RA = new FinderPath(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
2401 SCProductEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
2402 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByRG_RA",
2403 new String[] { String.class.getName(), String.class.getName() });
2404
2405
2413 @Override
2414 public SCProductEntry findByRG_RA(String repoGroupId, String repoArtifactId)
2415 throws NoSuchProductEntryException {
2416 SCProductEntry scProductEntry = fetchByRG_RA(repoGroupId, repoArtifactId);
2417
2418 if (scProductEntry == null) {
2419 StringBundler msg = new StringBundler(6);
2420
2421 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2422
2423 msg.append("repoGroupId=");
2424 msg.append(repoGroupId);
2425
2426 msg.append(", repoArtifactId=");
2427 msg.append(repoArtifactId);
2428
2429 msg.append(StringPool.CLOSE_CURLY_BRACE);
2430
2431 if (_log.isWarnEnabled()) {
2432 _log.warn(msg.toString());
2433 }
2434
2435 throw new NoSuchProductEntryException(msg.toString());
2436 }
2437
2438 return scProductEntry;
2439 }
2440
2441
2448 @Override
2449 public SCProductEntry fetchByRG_RA(String repoGroupId, String repoArtifactId) {
2450 return fetchByRG_RA(repoGroupId, repoArtifactId, true);
2451 }
2452
2453
2461 @Override
2462 public SCProductEntry fetchByRG_RA(String repoGroupId,
2463 String repoArtifactId, boolean retrieveFromCache) {
2464 Object[] finderArgs = new Object[] { repoGroupId, repoArtifactId };
2465
2466 Object result = null;
2467
2468 if (retrieveFromCache) {
2469 result = finderCache.getResult(FINDER_PATH_FETCH_BY_RG_RA,
2470 finderArgs, this);
2471 }
2472
2473 if (result instanceof SCProductEntry) {
2474 SCProductEntry scProductEntry = (SCProductEntry)result;
2475
2476 if (!Validator.equals(repoGroupId, scProductEntry.getRepoGroupId()) ||
2477 !Validator.equals(repoArtifactId,
2478 scProductEntry.getRepoArtifactId())) {
2479 result = null;
2480 }
2481 }
2482
2483 if (result == null) {
2484 StringBundler query = new StringBundler(4);
2485
2486 query.append(_SQL_SELECT_SCPRODUCTENTRY_WHERE);
2487
2488 boolean bindRepoGroupId = false;
2489
2490 if (repoGroupId == null) {
2491 query.append(_FINDER_COLUMN_RG_RA_REPOGROUPID_1);
2492 }
2493 else if (repoGroupId.equals(StringPool.BLANK)) {
2494 query.append(_FINDER_COLUMN_RG_RA_REPOGROUPID_3);
2495 }
2496 else {
2497 bindRepoGroupId = true;
2498
2499 query.append(_FINDER_COLUMN_RG_RA_REPOGROUPID_2);
2500 }
2501
2502 boolean bindRepoArtifactId = false;
2503
2504 if (repoArtifactId == null) {
2505 query.append(_FINDER_COLUMN_RG_RA_REPOARTIFACTID_1);
2506 }
2507 else if (repoArtifactId.equals(StringPool.BLANK)) {
2508 query.append(_FINDER_COLUMN_RG_RA_REPOARTIFACTID_3);
2509 }
2510 else {
2511 bindRepoArtifactId = true;
2512
2513 query.append(_FINDER_COLUMN_RG_RA_REPOARTIFACTID_2);
2514 }
2515
2516 String sql = query.toString();
2517
2518 Session session = null;
2519
2520 try {
2521 session = openSession();
2522
2523 Query q = session.createQuery(sql);
2524
2525 QueryPos qPos = QueryPos.getInstance(q);
2526
2527 if (bindRepoGroupId) {
2528 qPos.add(StringUtil.toLowerCase(repoGroupId));
2529 }
2530
2531 if (bindRepoArtifactId) {
2532 qPos.add(StringUtil.toLowerCase(repoArtifactId));
2533 }
2534
2535 List<SCProductEntry> list = q.list();
2536
2537 if (list.isEmpty()) {
2538 finderCache.putResult(FINDER_PATH_FETCH_BY_RG_RA,
2539 finderArgs, list);
2540 }
2541 else {
2542 if ((list.size() > 1) && _log.isWarnEnabled()) {
2543 _log.warn(
2544 "SCProductEntryPersistenceImpl.fetchByRG_RA(String, String, boolean) with parameters (" +
2545 StringUtil.merge(finderArgs) +
2546 ") yields a result set with more than 1 result. This violates the logical unique restriction. There is no order guarantee on which result is returned by this finder.");
2547 }
2548
2549 SCProductEntry scProductEntry = list.get(0);
2550
2551 result = scProductEntry;
2552
2553 cacheResult(scProductEntry);
2554
2555 if ((scProductEntry.getRepoGroupId() == null) ||
2556 !scProductEntry.getRepoGroupId().equals(repoGroupId) ||
2557 (scProductEntry.getRepoArtifactId() == null) ||
2558 !scProductEntry.getRepoArtifactId()
2559 .equals(repoArtifactId)) {
2560 finderCache.putResult(FINDER_PATH_FETCH_BY_RG_RA,
2561 finderArgs, scProductEntry);
2562 }
2563 }
2564 }
2565 catch (Exception e) {
2566 finderCache.removeResult(FINDER_PATH_FETCH_BY_RG_RA, finderArgs);
2567
2568 throw processException(e);
2569 }
2570 finally {
2571 closeSession(session);
2572 }
2573 }
2574
2575 if (result instanceof List<?>) {
2576 return null;
2577 }
2578 else {
2579 return (SCProductEntry)result;
2580 }
2581 }
2582
2583
2590 @Override
2591 public SCProductEntry removeByRG_RA(String repoGroupId,
2592 String repoArtifactId) throws NoSuchProductEntryException {
2593 SCProductEntry scProductEntry = findByRG_RA(repoGroupId, repoArtifactId);
2594
2595 return remove(scProductEntry);
2596 }
2597
2598
2605 @Override
2606 public int countByRG_RA(String repoGroupId, String repoArtifactId) {
2607 FinderPath finderPath = FINDER_PATH_COUNT_BY_RG_RA;
2608
2609 Object[] finderArgs = new Object[] { repoGroupId, repoArtifactId };
2610
2611 Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
2612
2613 if (count == null) {
2614 StringBundler query = new StringBundler(3);
2615
2616 query.append(_SQL_COUNT_SCPRODUCTENTRY_WHERE);
2617
2618 boolean bindRepoGroupId = false;
2619
2620 if (repoGroupId == null) {
2621 query.append(_FINDER_COLUMN_RG_RA_REPOGROUPID_1);
2622 }
2623 else if (repoGroupId.equals(StringPool.BLANK)) {
2624 query.append(_FINDER_COLUMN_RG_RA_REPOGROUPID_3);
2625 }
2626 else {
2627 bindRepoGroupId = true;
2628
2629 query.append(_FINDER_COLUMN_RG_RA_REPOGROUPID_2);
2630 }
2631
2632 boolean bindRepoArtifactId = false;
2633
2634 if (repoArtifactId == null) {
2635 query.append(_FINDER_COLUMN_RG_RA_REPOARTIFACTID_1);
2636 }
2637 else if (repoArtifactId.equals(StringPool.BLANK)) {
2638 query.append(_FINDER_COLUMN_RG_RA_REPOARTIFACTID_3);
2639 }
2640 else {
2641 bindRepoArtifactId = true;
2642
2643 query.append(_FINDER_COLUMN_RG_RA_REPOARTIFACTID_2);
2644 }
2645
2646 String sql = query.toString();
2647
2648 Session session = null;
2649
2650 try {
2651 session = openSession();
2652
2653 Query q = session.createQuery(sql);
2654
2655 QueryPos qPos = QueryPos.getInstance(q);
2656
2657 if (bindRepoGroupId) {
2658 qPos.add(StringUtil.toLowerCase(repoGroupId));
2659 }
2660
2661 if (bindRepoArtifactId) {
2662 qPos.add(StringUtil.toLowerCase(repoArtifactId));
2663 }
2664
2665 count = (Long)q.uniqueResult();
2666
2667 finderCache.putResult(finderPath, finderArgs, count);
2668 }
2669 catch (Exception e) {
2670 finderCache.removeResult(finderPath, finderArgs);
2671
2672 throw processException(e);
2673 }
2674 finally {
2675 closeSession(session);
2676 }
2677 }
2678
2679 return count.intValue();
2680 }
2681
2682 private static final String _FINDER_COLUMN_RG_RA_REPOGROUPID_1 = "scProductEntry.repoGroupId IS NULL AND ";
2683 private static final String _FINDER_COLUMN_RG_RA_REPOGROUPID_2 = "lower(scProductEntry.repoGroupId) = ? AND ";
2684 private static final String _FINDER_COLUMN_RG_RA_REPOGROUPID_3 = "(scProductEntry.repoGroupId IS NULL OR scProductEntry.repoGroupId = '') AND ";
2685 private static final String _FINDER_COLUMN_RG_RA_REPOARTIFACTID_1 = "scProductEntry.repoArtifactId IS NULL";
2686 private static final String _FINDER_COLUMN_RG_RA_REPOARTIFACTID_2 = "lower(scProductEntry.repoArtifactId) = ?";
2687 private static final String _FINDER_COLUMN_RG_RA_REPOARTIFACTID_3 = "(scProductEntry.repoArtifactId IS NULL OR scProductEntry.repoArtifactId = '')";
2688
2689 public SCProductEntryPersistenceImpl() {
2690 setModelClass(SCProductEntry.class);
2691 }
2692
2693
2698 @Override
2699 public void cacheResult(SCProductEntry scProductEntry) {
2700 entityCache.putResult(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
2701 SCProductEntryImpl.class, scProductEntry.getPrimaryKey(),
2702 scProductEntry);
2703
2704 finderCache.putResult(FINDER_PATH_FETCH_BY_RG_RA,
2705 new Object[] {
2706 scProductEntry.getRepoGroupId(),
2707 scProductEntry.getRepoArtifactId()
2708 }, scProductEntry);
2709
2710 scProductEntry.resetOriginalValues();
2711 }
2712
2713
2718 @Override
2719 public void cacheResult(List<SCProductEntry> scProductEntries) {
2720 for (SCProductEntry scProductEntry : scProductEntries) {
2721 if (entityCache.getResult(
2722 SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
2723 SCProductEntryImpl.class, scProductEntry.getPrimaryKey()) == null) {
2724 cacheResult(scProductEntry);
2725 }
2726 else {
2727 scProductEntry.resetOriginalValues();
2728 }
2729 }
2730 }
2731
2732
2739 @Override
2740 public void clearCache() {
2741 entityCache.clearCache(SCProductEntryImpl.class);
2742
2743 finderCache.clearCache(FINDER_CLASS_NAME_ENTITY);
2744 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2745 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2746 }
2747
2748
2755 @Override
2756 public void clearCache(SCProductEntry scProductEntry) {
2757 entityCache.removeResult(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
2758 SCProductEntryImpl.class, scProductEntry.getPrimaryKey());
2759
2760 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2761 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2762
2763 clearUniqueFindersCache((SCProductEntryModelImpl)scProductEntry);
2764 }
2765
2766 @Override
2767 public void clearCache(List<SCProductEntry> scProductEntries) {
2768 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2769 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2770
2771 for (SCProductEntry scProductEntry : scProductEntries) {
2772 entityCache.removeResult(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
2773 SCProductEntryImpl.class, scProductEntry.getPrimaryKey());
2774
2775 clearUniqueFindersCache((SCProductEntryModelImpl)scProductEntry);
2776 }
2777 }
2778
2779 protected void cacheUniqueFindersCache(
2780 SCProductEntryModelImpl scProductEntryModelImpl, boolean isNew) {
2781 if (isNew) {
2782 Object[] args = new Object[] {
2783 scProductEntryModelImpl.getRepoGroupId(),
2784 scProductEntryModelImpl.getRepoArtifactId()
2785 };
2786
2787 finderCache.putResult(FINDER_PATH_COUNT_BY_RG_RA, args,
2788 Long.valueOf(1));
2789 finderCache.putResult(FINDER_PATH_FETCH_BY_RG_RA, args,
2790 scProductEntryModelImpl);
2791 }
2792 else {
2793 if ((scProductEntryModelImpl.getColumnBitmask() &
2794 FINDER_PATH_FETCH_BY_RG_RA.getColumnBitmask()) != 0) {
2795 Object[] args = new Object[] {
2796 scProductEntryModelImpl.getRepoGroupId(),
2797 scProductEntryModelImpl.getRepoArtifactId()
2798 };
2799
2800 finderCache.putResult(FINDER_PATH_COUNT_BY_RG_RA, args,
2801 Long.valueOf(1));
2802 finderCache.putResult(FINDER_PATH_FETCH_BY_RG_RA, args,
2803 scProductEntryModelImpl);
2804 }
2805 }
2806 }
2807
2808 protected void clearUniqueFindersCache(
2809 SCProductEntryModelImpl scProductEntryModelImpl) {
2810 Object[] args = new Object[] {
2811 scProductEntryModelImpl.getRepoGroupId(),
2812 scProductEntryModelImpl.getRepoArtifactId()
2813 };
2814
2815 finderCache.removeResult(FINDER_PATH_COUNT_BY_RG_RA, args);
2816 finderCache.removeResult(FINDER_PATH_FETCH_BY_RG_RA, args);
2817
2818 if ((scProductEntryModelImpl.getColumnBitmask() &
2819 FINDER_PATH_FETCH_BY_RG_RA.getColumnBitmask()) != 0) {
2820 args = new Object[] {
2821 scProductEntryModelImpl.getOriginalRepoGroupId(),
2822 scProductEntryModelImpl.getOriginalRepoArtifactId()
2823 };
2824
2825 finderCache.removeResult(FINDER_PATH_COUNT_BY_RG_RA, args);
2826 finderCache.removeResult(FINDER_PATH_FETCH_BY_RG_RA, args);
2827 }
2828 }
2829
2830
2836 @Override
2837 public SCProductEntry create(long productEntryId) {
2838 SCProductEntry scProductEntry = new SCProductEntryImpl();
2839
2840 scProductEntry.setNew(true);
2841 scProductEntry.setPrimaryKey(productEntryId);
2842
2843 return scProductEntry;
2844 }
2845
2846
2853 @Override
2854 public SCProductEntry remove(long productEntryId)
2855 throws NoSuchProductEntryException {
2856 return remove((Serializable)productEntryId);
2857 }
2858
2859
2866 @Override
2867 public SCProductEntry remove(Serializable primaryKey)
2868 throws NoSuchProductEntryException {
2869 Session session = null;
2870
2871 try {
2872 session = openSession();
2873
2874 SCProductEntry scProductEntry = (SCProductEntry)session.get(SCProductEntryImpl.class,
2875 primaryKey);
2876
2877 if (scProductEntry == null) {
2878 if (_log.isWarnEnabled()) {
2879 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
2880 }
2881
2882 throw new NoSuchProductEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
2883 primaryKey);
2884 }
2885
2886 return remove(scProductEntry);
2887 }
2888 catch (NoSuchProductEntryException nsee) {
2889 throw nsee;
2890 }
2891 catch (Exception e) {
2892 throw processException(e);
2893 }
2894 finally {
2895 closeSession(session);
2896 }
2897 }
2898
2899 @Override
2900 protected SCProductEntry removeImpl(SCProductEntry scProductEntry) {
2901 scProductEntry = toUnwrappedModel(scProductEntry);
2902
2903 scProductEntryToSCLicenseTableMapper.deleteLeftPrimaryKeyTableMappings(0,
2904 scProductEntry.getPrimaryKey());
2905
2906 Session session = null;
2907
2908 try {
2909 session = openSession();
2910
2911 if (!session.contains(scProductEntry)) {
2912 scProductEntry = (SCProductEntry)session.get(SCProductEntryImpl.class,
2913 scProductEntry.getPrimaryKeyObj());
2914 }
2915
2916 if (scProductEntry != null) {
2917 session.delete(scProductEntry);
2918 }
2919 }
2920 catch (Exception e) {
2921 throw processException(e);
2922 }
2923 finally {
2924 closeSession(session);
2925 }
2926
2927 if (scProductEntry != null) {
2928 clearCache(scProductEntry);
2929 }
2930
2931 return scProductEntry;
2932 }
2933
2934 @Override
2935 public SCProductEntry updateImpl(SCProductEntry scProductEntry) {
2936 scProductEntry = toUnwrappedModel(scProductEntry);
2937
2938 boolean isNew = scProductEntry.isNew();
2939
2940 SCProductEntryModelImpl scProductEntryModelImpl = (SCProductEntryModelImpl)scProductEntry;
2941
2942 ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext();
2943
2944 Date now = new Date();
2945
2946 if (isNew && (scProductEntry.getCreateDate() == null)) {
2947 if (serviceContext == null) {
2948 scProductEntry.setCreateDate(now);
2949 }
2950 else {
2951 scProductEntry.setCreateDate(serviceContext.getCreateDate(now));
2952 }
2953 }
2954
2955 if (!scProductEntryModelImpl.hasSetModifiedDate()) {
2956 if (serviceContext == null) {
2957 scProductEntry.setModifiedDate(now);
2958 }
2959 else {
2960 scProductEntry.setModifiedDate(serviceContext.getModifiedDate(
2961 now));
2962 }
2963 }
2964
2965 Session session = null;
2966
2967 try {
2968 session = openSession();
2969
2970 if (scProductEntry.isNew()) {
2971 session.save(scProductEntry);
2972
2973 scProductEntry.setNew(false);
2974 }
2975 else {
2976 scProductEntry = (SCProductEntry)session.merge(scProductEntry);
2977 }
2978 }
2979 catch (Exception e) {
2980 throw processException(e);
2981 }
2982 finally {
2983 closeSession(session);
2984 }
2985
2986 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2987
2988 if (isNew || !SCProductEntryModelImpl.COLUMN_BITMASK_ENABLED) {
2989 finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2990 }
2991
2992 else {
2993 if ((scProductEntryModelImpl.getColumnBitmask() &
2994 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
2995 Object[] args = new Object[] {
2996 scProductEntryModelImpl.getOriginalGroupId()
2997 };
2998
2999 finderCache.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
3000 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
3001 args);
3002
3003 args = new Object[] { scProductEntryModelImpl.getGroupId() };
3004
3005 finderCache.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
3006 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
3007 args);
3008 }
3009
3010 if ((scProductEntryModelImpl.getColumnBitmask() &
3011 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
3012 Object[] args = new Object[] {
3013 scProductEntryModelImpl.getOriginalCompanyId()
3014 };
3015
3016 finderCache.removeResult(FINDER_PATH_COUNT_BY_COMPANYID, args);
3017 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
3018 args);
3019
3020 args = new Object[] { scProductEntryModelImpl.getCompanyId() };
3021
3022 finderCache.removeResult(FINDER_PATH_COUNT_BY_COMPANYID, args);
3023 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
3024 args);
3025 }
3026
3027 if ((scProductEntryModelImpl.getColumnBitmask() &
3028 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U.getColumnBitmask()) != 0) {
3029 Object[] args = new Object[] {
3030 scProductEntryModelImpl.getOriginalGroupId(),
3031 scProductEntryModelImpl.getOriginalUserId()
3032 };
3033
3034 finderCache.removeResult(FINDER_PATH_COUNT_BY_G_U, args);
3035 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U,
3036 args);
3037
3038 args = new Object[] {
3039 scProductEntryModelImpl.getGroupId(),
3040 scProductEntryModelImpl.getUserId()
3041 };
3042
3043 finderCache.removeResult(FINDER_PATH_COUNT_BY_G_U, args);
3044 finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U,
3045 args);
3046 }
3047 }
3048
3049 entityCache.putResult(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
3050 SCProductEntryImpl.class, scProductEntry.getPrimaryKey(),
3051 scProductEntry, false);
3052
3053 clearUniqueFindersCache(scProductEntryModelImpl);
3054 cacheUniqueFindersCache(scProductEntryModelImpl, isNew);
3055
3056 scProductEntry.resetOriginalValues();
3057
3058 return scProductEntry;
3059 }
3060
3061 protected SCProductEntry toUnwrappedModel(SCProductEntry scProductEntry) {
3062 if (scProductEntry instanceof SCProductEntryImpl) {
3063 return scProductEntry;
3064 }
3065
3066 SCProductEntryImpl scProductEntryImpl = new SCProductEntryImpl();
3067
3068 scProductEntryImpl.setNew(scProductEntry.isNew());
3069 scProductEntryImpl.setPrimaryKey(scProductEntry.getPrimaryKey());
3070
3071 scProductEntryImpl.setProductEntryId(scProductEntry.getProductEntryId());
3072 scProductEntryImpl.setGroupId(scProductEntry.getGroupId());
3073 scProductEntryImpl.setCompanyId(scProductEntry.getCompanyId());
3074 scProductEntryImpl.setUserId(scProductEntry.getUserId());
3075 scProductEntryImpl.setUserName(scProductEntry.getUserName());
3076 scProductEntryImpl.setCreateDate(scProductEntry.getCreateDate());
3077 scProductEntryImpl.setModifiedDate(scProductEntry.getModifiedDate());
3078 scProductEntryImpl.setName(scProductEntry.getName());
3079 scProductEntryImpl.setType(scProductEntry.getType());
3080 scProductEntryImpl.setTags(scProductEntry.getTags());
3081 scProductEntryImpl.setShortDescription(scProductEntry.getShortDescription());
3082 scProductEntryImpl.setLongDescription(scProductEntry.getLongDescription());
3083 scProductEntryImpl.setPageURL(scProductEntry.getPageURL());
3084 scProductEntryImpl.setAuthor(scProductEntry.getAuthor());
3085 scProductEntryImpl.setRepoGroupId(scProductEntry.getRepoGroupId());
3086 scProductEntryImpl.setRepoArtifactId(scProductEntry.getRepoArtifactId());
3087
3088 return scProductEntryImpl;
3089 }
3090
3091
3098 @Override
3099 public SCProductEntry findByPrimaryKey(Serializable primaryKey)
3100 throws NoSuchProductEntryException {
3101 SCProductEntry scProductEntry = fetchByPrimaryKey(primaryKey);
3102
3103 if (scProductEntry == null) {
3104 if (_log.isWarnEnabled()) {
3105 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
3106 }
3107
3108 throw new NoSuchProductEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
3109 primaryKey);
3110 }
3111
3112 return scProductEntry;
3113 }
3114
3115
3122 @Override
3123 public SCProductEntry findByPrimaryKey(long productEntryId)
3124 throws NoSuchProductEntryException {
3125 return findByPrimaryKey((Serializable)productEntryId);
3126 }
3127
3128
3134 @Override
3135 public SCProductEntry fetchByPrimaryKey(Serializable primaryKey) {
3136 SCProductEntry scProductEntry = (SCProductEntry)entityCache.getResult(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
3137 SCProductEntryImpl.class, primaryKey);
3138
3139 if (scProductEntry == _nullSCProductEntry) {
3140 return null;
3141 }
3142
3143 if (scProductEntry == null) {
3144 Session session = null;
3145
3146 try {
3147 session = openSession();
3148
3149 scProductEntry = (SCProductEntry)session.get(SCProductEntryImpl.class,
3150 primaryKey);
3151
3152 if (scProductEntry != null) {
3153 cacheResult(scProductEntry);
3154 }
3155 else {
3156 entityCache.putResult(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
3157 SCProductEntryImpl.class, primaryKey,
3158 _nullSCProductEntry);
3159 }
3160 }
3161 catch (Exception e) {
3162 entityCache.removeResult(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
3163 SCProductEntryImpl.class, primaryKey);
3164
3165 throw processException(e);
3166 }
3167 finally {
3168 closeSession(session);
3169 }
3170 }
3171
3172 return scProductEntry;
3173 }
3174
3175
3181 @Override
3182 public SCProductEntry fetchByPrimaryKey(long productEntryId) {
3183 return fetchByPrimaryKey((Serializable)productEntryId);
3184 }
3185
3186 @Override
3187 public Map<Serializable, SCProductEntry> fetchByPrimaryKeys(
3188 Set<Serializable> primaryKeys) {
3189 if (primaryKeys.isEmpty()) {
3190 return Collections.emptyMap();
3191 }
3192
3193 Map<Serializable, SCProductEntry> map = new HashMap<Serializable, SCProductEntry>();
3194
3195 if (primaryKeys.size() == 1) {
3196 Iterator<Serializable> iterator = primaryKeys.iterator();
3197
3198 Serializable primaryKey = iterator.next();
3199
3200 SCProductEntry scProductEntry = fetchByPrimaryKey(primaryKey);
3201
3202 if (scProductEntry != null) {
3203 map.put(primaryKey, scProductEntry);
3204 }
3205
3206 return map;
3207 }
3208
3209 Set<Serializable> uncachedPrimaryKeys = null;
3210
3211 for (Serializable primaryKey : primaryKeys) {
3212 SCProductEntry scProductEntry = (SCProductEntry)entityCache.getResult(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
3213 SCProductEntryImpl.class, primaryKey);
3214
3215 if (scProductEntry == null) {
3216 if (uncachedPrimaryKeys == null) {
3217 uncachedPrimaryKeys = new HashSet<Serializable>();
3218 }
3219
3220 uncachedPrimaryKeys.add(primaryKey);
3221 }
3222 else {
3223 map.put(primaryKey, scProductEntry);
3224 }
3225 }
3226
3227 if (uncachedPrimaryKeys == null) {
3228 return map;
3229 }
3230
3231 StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) +
3232 1);
3233
3234 query.append(_SQL_SELECT_SCPRODUCTENTRY_WHERE_PKS_IN);
3235
3236 for (Serializable primaryKey : uncachedPrimaryKeys) {
3237 query.append(String.valueOf(primaryKey));
3238
3239 query.append(StringPool.COMMA);
3240 }
3241
3242 query.setIndex(query.index() - 1);
3243
3244 query.append(StringPool.CLOSE_PARENTHESIS);
3245
3246 String sql = query.toString();
3247
3248 Session session = null;
3249
3250 try {
3251 session = openSession();
3252
3253 Query q = session.createQuery(sql);
3254
3255 for (SCProductEntry scProductEntry : (List<SCProductEntry>)q.list()) {
3256 map.put(scProductEntry.getPrimaryKeyObj(), scProductEntry);
3257
3258 cacheResult(scProductEntry);
3259
3260 uncachedPrimaryKeys.remove(scProductEntry.getPrimaryKeyObj());
3261 }
3262
3263 for (Serializable primaryKey : uncachedPrimaryKeys) {
3264 entityCache.putResult(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
3265 SCProductEntryImpl.class, primaryKey, _nullSCProductEntry);
3266 }
3267 }
3268 catch (Exception e) {
3269 throw processException(e);
3270 }
3271 finally {
3272 closeSession(session);
3273 }
3274
3275 return map;
3276 }
3277
3278
3283 @Override
3284 public List<SCProductEntry> findAll() {
3285 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
3286 }
3287
3288
3299 @Override
3300 public List<SCProductEntry> findAll(int start, int end) {
3301 return findAll(start, end, null);
3302 }
3303
3304
3316 @Override
3317 public List<SCProductEntry> findAll(int start, int end,
3318 OrderByComparator<SCProductEntry> orderByComparator) {
3319 return findAll(start, end, orderByComparator, true);
3320 }
3321
3322
3335 @Override
3336 public List<SCProductEntry> findAll(int start, int end,
3337 OrderByComparator<SCProductEntry> orderByComparator,
3338 boolean retrieveFromCache) {
3339 boolean pagination = true;
3340 FinderPath finderPath = null;
3341 Object[] finderArgs = null;
3342
3343 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3344 (orderByComparator == null)) {
3345 pagination = false;
3346 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
3347 finderArgs = FINDER_ARGS_EMPTY;
3348 }
3349 else {
3350 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
3351 finderArgs = new Object[] { start, end, orderByComparator };
3352 }
3353
3354 List<SCProductEntry> list = null;
3355
3356 if (retrieveFromCache) {
3357 list = (List<SCProductEntry>)finderCache.getResult(finderPath,
3358 finderArgs, this);
3359 }
3360
3361 if (list == null) {
3362 StringBundler query = null;
3363 String sql = null;
3364
3365 if (orderByComparator != null) {
3366 query = new StringBundler(2 +
3367 (orderByComparator.getOrderByFields().length * 3));
3368
3369 query.append(_SQL_SELECT_SCPRODUCTENTRY);
3370
3371 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3372 orderByComparator);
3373
3374 sql = query.toString();
3375 }
3376 else {
3377 sql = _SQL_SELECT_SCPRODUCTENTRY;
3378
3379 if (pagination) {
3380 sql = sql.concat(SCProductEntryModelImpl.ORDER_BY_JPQL);
3381 }
3382 }
3383
3384 Session session = null;
3385
3386 try {
3387 session = openSession();
3388
3389 Query q = session.createQuery(sql);
3390
3391 if (!pagination) {
3392 list = (List<SCProductEntry>)QueryUtil.list(q,
3393 getDialect(), start, end, false);
3394
3395 Collections.sort(list);
3396
3397 list = Collections.unmodifiableList(list);
3398 }
3399 else {
3400 list = (List<SCProductEntry>)QueryUtil.list(q,
3401 getDialect(), start, end);
3402 }
3403
3404 cacheResult(list);
3405
3406 finderCache.putResult(finderPath, finderArgs, list);
3407 }
3408 catch (Exception e) {
3409 finderCache.removeResult(finderPath, finderArgs);
3410
3411 throw processException(e);
3412 }
3413 finally {
3414 closeSession(session);
3415 }
3416 }
3417
3418 return list;
3419 }
3420
3421
3425 @Override
3426 public void removeAll() {
3427 for (SCProductEntry scProductEntry : findAll()) {
3428 remove(scProductEntry);
3429 }
3430 }
3431
3432
3437 @Override
3438 public int countAll() {
3439 Long count = (Long)finderCache.getResult(FINDER_PATH_COUNT_ALL,
3440 FINDER_ARGS_EMPTY, this);
3441
3442 if (count == null) {
3443 Session session = null;
3444
3445 try {
3446 session = openSession();
3447
3448 Query q = session.createQuery(_SQL_COUNT_SCPRODUCTENTRY);
3449
3450 count = (Long)q.uniqueResult();
3451
3452 finderCache.putResult(FINDER_PATH_COUNT_ALL, FINDER_ARGS_EMPTY,
3453 count);
3454 }
3455 catch (Exception e) {
3456 finderCache.removeResult(FINDER_PATH_COUNT_ALL,
3457 FINDER_ARGS_EMPTY);
3458
3459 throw processException(e);
3460 }
3461 finally {
3462 closeSession(session);
3463 }
3464 }
3465
3466 return count.intValue();
3467 }
3468
3469
3475 @Override
3476 public long[] getSCLicensePrimaryKeys(long pk) {
3477 long[] pks = scProductEntryToSCLicenseTableMapper.getRightPrimaryKeys(0,
3478 pk);
3479
3480 return pks.clone();
3481 }
3482
3483
3489 @Override
3490 public List<com.liferay.portlet.softwarecatalog.model.SCLicense> getSCLicenses(
3491 long pk) {
3492 return getSCLicenses(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
3493 }
3494
3495
3507 @Override
3508 public List<com.liferay.portlet.softwarecatalog.model.SCLicense> getSCLicenses(
3509 long pk, int start, int end) {
3510 return getSCLicenses(pk, start, end, null);
3511 }
3512
3513
3526 @Override
3527 public List<com.liferay.portlet.softwarecatalog.model.SCLicense> getSCLicenses(
3528 long pk, int start, int end,
3529 OrderByComparator<com.liferay.portlet.softwarecatalog.model.SCLicense> orderByComparator) {
3530 return scProductEntryToSCLicenseTableMapper.getRightBaseModels(0, pk,
3531 start, end, orderByComparator);
3532 }
3533
3534
3540 @Override
3541 public int getSCLicensesSize(long pk) {
3542 long[] pks = scProductEntryToSCLicenseTableMapper.getRightPrimaryKeys(0,
3543 pk);
3544
3545 return pks.length;
3546 }
3547
3548
3555 @Override
3556 public boolean containsSCLicense(long pk, long scLicensePK) {
3557 return scProductEntryToSCLicenseTableMapper.containsTableMapping(0, pk,
3558 scLicensePK);
3559 }
3560
3561
3567 @Override
3568 public boolean containsSCLicenses(long pk) {
3569 if (getSCLicensesSize(pk) > 0) {
3570 return true;
3571 }
3572 else {
3573 return false;
3574 }
3575 }
3576
3577
3583 @Override
3584 public void addSCLicense(long pk, long scLicensePK) {
3585 scProductEntryToSCLicenseTableMapper.addTableMapping(0, pk, scLicensePK);
3586 }
3587
3588
3594 @Override
3595 public void addSCLicense(long pk,
3596 com.liferay.portlet.softwarecatalog.model.SCLicense scLicense) {
3597 scProductEntryToSCLicenseTableMapper.addTableMapping(0, pk,
3598 scLicense.getPrimaryKey());
3599 }
3600
3601
3607 @Override
3608 public void addSCLicenses(long pk, long[] scLicensePKs) {
3609 for (long scLicensePK : scLicensePKs) {
3610 scProductEntryToSCLicenseTableMapper.addTableMapping(0, pk,
3611 scLicensePK);
3612 }
3613 }
3614
3615
3621 @Override
3622 public void addSCLicenses(long pk,
3623 List<com.liferay.portlet.softwarecatalog.model.SCLicense> scLicenses) {
3624 for (com.liferay.portlet.softwarecatalog.model.SCLicense scLicense : scLicenses) {
3625 scProductEntryToSCLicenseTableMapper.addTableMapping(0, pk,
3626 scLicense.getPrimaryKey());
3627 }
3628 }
3629
3630
3635 @Override
3636 public void clearSCLicenses(long pk) {
3637 scProductEntryToSCLicenseTableMapper.deleteLeftPrimaryKeyTableMappings(0,
3638 pk);
3639 }
3640
3641
3647 @Override
3648 public void removeSCLicense(long pk, long scLicensePK) {
3649 scProductEntryToSCLicenseTableMapper.deleteTableMapping(0, pk,
3650 scLicensePK);
3651 }
3652
3653
3659 @Override
3660 public void removeSCLicense(long pk,
3661 com.liferay.portlet.softwarecatalog.model.SCLicense scLicense) {
3662 scProductEntryToSCLicenseTableMapper.deleteTableMapping(0, pk,
3663 scLicense.getPrimaryKey());
3664 }
3665
3666
3672 @Override
3673 public void removeSCLicenses(long pk, long[] scLicensePKs) {
3674 for (long scLicensePK : scLicensePKs) {
3675 scProductEntryToSCLicenseTableMapper.deleteTableMapping(0, pk,
3676 scLicensePK);
3677 }
3678 }
3679
3680
3686 @Override
3687 public void removeSCLicenses(long pk,
3688 List<com.liferay.portlet.softwarecatalog.model.SCLicense> scLicenses) {
3689 for (com.liferay.portlet.softwarecatalog.model.SCLicense scLicense : scLicenses) {
3690 scProductEntryToSCLicenseTableMapper.deleteTableMapping(0, pk,
3691 scLicense.getPrimaryKey());
3692 }
3693 }
3694
3695
3701 @Override
3702 public void setSCLicenses(long pk, long[] scLicensePKs) {
3703 Set<Long> newSCLicensePKsSet = SetUtil.fromArray(scLicensePKs);
3704 Set<Long> oldSCLicensePKsSet = SetUtil.fromArray(scProductEntryToSCLicenseTableMapper.getRightPrimaryKeys(
3705 0, pk));
3706
3707 Set<Long> removeSCLicensePKsSet = new HashSet<Long>(oldSCLicensePKsSet);
3708
3709 removeSCLicensePKsSet.removeAll(newSCLicensePKsSet);
3710
3711 for (long removeSCLicensePK : removeSCLicensePKsSet) {
3712 scProductEntryToSCLicenseTableMapper.deleteTableMapping(0, pk,
3713 removeSCLicensePK);
3714 }
3715
3716 newSCLicensePKsSet.removeAll(oldSCLicensePKsSet);
3717
3718 for (long newSCLicensePK : newSCLicensePKsSet) {
3719 scProductEntryToSCLicenseTableMapper.addTableMapping(0, pk,
3720 newSCLicensePK);
3721 }
3722 }
3723
3724
3730 @Override
3731 public void setSCLicenses(long pk,
3732 List<com.liferay.portlet.softwarecatalog.model.SCLicense> scLicenses) {
3733 try {
3734 long[] scLicensePKs = new long[scLicenses.size()];
3735
3736 for (int i = 0; i < scLicenses.size(); i++) {
3737 com.liferay.portlet.softwarecatalog.model.SCLicense scLicense = scLicenses.get(i);
3738
3739 scLicensePKs[i] = scLicense.getPrimaryKey();
3740 }
3741
3742 setSCLicenses(pk, scLicensePKs);
3743 }
3744 catch (Exception e) {
3745 throw processException(e);
3746 }
3747 }
3748
3749 @Override
3750 public Set<String> getBadColumnNames() {
3751 return _badColumnNames;
3752 }
3753
3754 @Override
3755 protected Map<String, Integer> getTableColumnsMap() {
3756 return SCProductEntryModelImpl.TABLE_COLUMNS_MAP;
3757 }
3758
3759
3762 public void afterPropertiesSet() {
3763 scProductEntryToSCLicenseTableMapper = TableMapperFactory.getTableMapper("SCLicenses_SCProductEntries",
3764 "companyId", "productEntryId", "licenseId", this,
3765 scLicensePersistence);
3766 }
3767
3768 public void destroy() {
3769 entityCache.removeCache(SCProductEntryImpl.class.getName());
3770 finderCache.removeCache(FINDER_CLASS_NAME_ENTITY);
3771 finderCache.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
3772 finderCache.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
3773
3774 TableMapperFactory.removeTableMapper("SCLicenses_SCProductEntries");
3775 }
3776
3777 protected EntityCache entityCache = EntityCacheUtil.getEntityCache();
3778 protected FinderCache finderCache = FinderCacheUtil.getFinderCache();
3779 @BeanReference(type = SCLicensePersistence.class)
3780 protected SCLicensePersistence scLicensePersistence;
3781 protected TableMapper<SCProductEntry, com.liferay.portlet.softwarecatalog.model.SCLicense> scProductEntryToSCLicenseTableMapper;
3782 private static final String _SQL_SELECT_SCPRODUCTENTRY = "SELECT scProductEntry FROM SCProductEntry scProductEntry";
3783 private static final String _SQL_SELECT_SCPRODUCTENTRY_WHERE_PKS_IN = "SELECT scProductEntry FROM SCProductEntry scProductEntry WHERE productEntryId IN (";
3784 private static final String _SQL_SELECT_SCPRODUCTENTRY_WHERE = "SELECT scProductEntry FROM SCProductEntry scProductEntry WHERE ";
3785 private static final String _SQL_COUNT_SCPRODUCTENTRY = "SELECT COUNT(scProductEntry) FROM SCProductEntry scProductEntry";
3786 private static final String _SQL_COUNT_SCPRODUCTENTRY_WHERE = "SELECT COUNT(scProductEntry) FROM SCProductEntry scProductEntry WHERE ";
3787 private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "scProductEntry.productEntryId";
3788 private static final String _FILTER_SQL_SELECT_SCPRODUCTENTRY_WHERE = "SELECT DISTINCT {scProductEntry.*} FROM SCProductEntry scProductEntry WHERE ";
3789 private static final String _FILTER_SQL_SELECT_SCPRODUCTENTRY_NO_INLINE_DISTINCT_WHERE_1 =
3790 "SELECT {SCProductEntry.*} FROM (SELECT DISTINCT scProductEntry.productEntryId FROM SCProductEntry scProductEntry WHERE ";
3791 private static final String _FILTER_SQL_SELECT_SCPRODUCTENTRY_NO_INLINE_DISTINCT_WHERE_2 =
3792 ") TEMP_TABLE INNER JOIN SCProductEntry ON TEMP_TABLE.productEntryId = SCProductEntry.productEntryId";
3793 private static final String _FILTER_SQL_COUNT_SCPRODUCTENTRY_WHERE = "SELECT COUNT(DISTINCT scProductEntry.productEntryId) AS COUNT_VALUE FROM SCProductEntry scProductEntry WHERE ";
3794 private static final String _FILTER_ENTITY_ALIAS = "scProductEntry";
3795 private static final String _FILTER_ENTITY_TABLE = "SCProductEntry";
3796 private static final String _ORDER_BY_ENTITY_ALIAS = "scProductEntry.";
3797 private static final String _ORDER_BY_ENTITY_TABLE = "SCProductEntry.";
3798 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No SCProductEntry exists with the primary key ";
3799 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No SCProductEntry exists with the key {";
3800 private static final Log _log = LogFactoryUtil.getLog(SCProductEntryPersistenceImpl.class);
3801 private static final Set<String> _badColumnNames = SetUtil.fromArray(new String[] {
3802 "type"
3803 });
3804 private static final SCProductEntry _nullSCProductEntry = new SCProductEntryImpl() {
3805 @Override
3806 public Object clone() {
3807 return this;
3808 }
3809
3810 @Override
3811 public CacheModel<SCProductEntry> toCacheModel() {
3812 return _nullSCProductEntryCacheModel;
3813 }
3814 };
3815
3816 private static final CacheModel<SCProductEntry> _nullSCProductEntryCacheModel =
3817 new CacheModel<SCProductEntry>() {
3818 @Override
3819 public SCProductEntry toEntityModel() {
3820 return _nullSCProductEntry;
3821 }
3822 };
3823 }