001
014
015 package com.liferay.portlet.softwarecatalog.service.persistence;
016
017 import com.liferay.portal.kernel.bean.BeanReference;
018 import com.liferay.portal.kernel.cache.CacheRegistryUtil;
019 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
020 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
021 import com.liferay.portal.kernel.dao.orm.FinderPath;
022 import com.liferay.portal.kernel.dao.orm.Query;
023 import com.liferay.portal.kernel.dao.orm.QueryPos;
024 import com.liferay.portal.kernel.dao.orm.QueryUtil;
025 import com.liferay.portal.kernel.dao.orm.SQLQuery;
026 import com.liferay.portal.kernel.dao.orm.Session;
027 import com.liferay.portal.kernel.exception.SystemException;
028 import com.liferay.portal.kernel.log.Log;
029 import com.liferay.portal.kernel.log.LogFactoryUtil;
030 import com.liferay.portal.kernel.util.GetterUtil;
031 import com.liferay.portal.kernel.util.InstanceFactory;
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.UnmodifiableList;
038 import com.liferay.portal.kernel.util.Validator;
039 import com.liferay.portal.model.CacheModel;
040 import com.liferay.portal.model.ModelListener;
041 import com.liferay.portal.security.permission.InlineSQLHelperUtil;
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
051 import java.io.Serializable;
052
053 import java.util.ArrayList;
054 import java.util.Collections;
055 import java.util.HashSet;
056 import java.util.List;
057 import java.util.Set;
058
059
071 public class SCProductEntryPersistenceImpl extends BasePersistenceImpl<SCProductEntry>
072 implements SCProductEntryPersistence {
073
078 public static final String FINDER_CLASS_NAME_ENTITY = SCProductEntryImpl.class.getName();
079 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
080 ".List1";
081 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
082 ".List2";
083 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
084 SCProductEntryModelImpl.FINDER_CACHE_ENABLED,
085 SCProductEntryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
086 "findAll", new String[0]);
087 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
088 SCProductEntryModelImpl.FINDER_CACHE_ENABLED,
089 SCProductEntryImpl.class,
090 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
091 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
092 SCProductEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
093 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
094 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
095 SCProductEntryModelImpl.FINDER_CACHE_ENABLED,
096 SCProductEntryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
097 "findByGroupId",
098 new String[] {
099 Long.class.getName(),
100
101 Integer.class.getName(), Integer.class.getName(),
102 OrderByComparator.class.getName()
103 });
104 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID =
105 new FinderPath(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
106 SCProductEntryModelImpl.FINDER_CACHE_ENABLED,
107 SCProductEntryImpl.class,
108 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByGroupId",
109 new String[] { Long.class.getName() },
110 SCProductEntryModelImpl.GROUPID_COLUMN_BITMASK |
111 SCProductEntryModelImpl.MODIFIEDDATE_COLUMN_BITMASK |
112 SCProductEntryModelImpl.NAME_COLUMN_BITMASK);
113 public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
114 SCProductEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
115 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId",
116 new String[] { Long.class.getName() });
117
118
125 @Override
126 public List<SCProductEntry> findByGroupId(long groupId)
127 throws SystemException {
128 return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
129 }
130
131
144 @Override
145 public List<SCProductEntry> findByGroupId(long groupId, int start, int end)
146 throws SystemException {
147 return findByGroupId(groupId, start, end, null);
148 }
149
150
164 @Override
165 public List<SCProductEntry> findByGroupId(long groupId, int start, int end,
166 OrderByComparator orderByComparator) throws SystemException {
167 boolean pagination = true;
168 FinderPath finderPath = null;
169 Object[] finderArgs = null;
170
171 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
172 (orderByComparator == null)) {
173 pagination = false;
174 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
175 finderArgs = new Object[] { groupId };
176 }
177 else {
178 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
179 finderArgs = new Object[] { groupId, start, end, orderByComparator };
180 }
181
182 List<SCProductEntry> list = (List<SCProductEntry>)FinderCacheUtil.getResult(finderPath,
183 finderArgs, this);
184
185 if ((list != null) && !list.isEmpty()) {
186 for (SCProductEntry scProductEntry : list) {
187 if ((groupId != scProductEntry.getGroupId())) {
188 list = null;
189
190 break;
191 }
192 }
193 }
194
195 if (list == null) {
196 StringBundler query = null;
197
198 if (orderByComparator != null) {
199 query = new StringBundler(3 +
200 (orderByComparator.getOrderByFields().length * 3));
201 }
202 else {
203 query = new StringBundler(3);
204 }
205
206 query.append(_SQL_SELECT_SCPRODUCTENTRY_WHERE);
207
208 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
209
210 if (orderByComparator != null) {
211 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
212 orderByComparator);
213 }
214 else
215 if (pagination) {
216 query.append(SCProductEntryModelImpl.ORDER_BY_JPQL);
217 }
218
219 String sql = query.toString();
220
221 Session session = null;
222
223 try {
224 session = openSession();
225
226 Query q = session.createQuery(sql);
227
228 QueryPos qPos = QueryPos.getInstance(q);
229
230 qPos.add(groupId);
231
232 if (!pagination) {
233 list = (List<SCProductEntry>)QueryUtil.list(q,
234 getDialect(), start, end, false);
235
236 Collections.sort(list);
237
238 list = new UnmodifiableList<SCProductEntry>(list);
239 }
240 else {
241 list = (List<SCProductEntry>)QueryUtil.list(q,
242 getDialect(), start, end);
243 }
244
245 cacheResult(list);
246
247 FinderCacheUtil.putResult(finderPath, finderArgs, list);
248 }
249 catch (Exception e) {
250 FinderCacheUtil.removeResult(finderPath, finderArgs);
251
252 throw processException(e);
253 }
254 finally {
255 closeSession(session);
256 }
257 }
258
259 return list;
260 }
261
262
271 @Override
272 public SCProductEntry findByGroupId_First(long groupId,
273 OrderByComparator orderByComparator)
274 throws NoSuchProductEntryException, SystemException {
275 SCProductEntry scProductEntry = fetchByGroupId_First(groupId,
276 orderByComparator);
277
278 if (scProductEntry != null) {
279 return scProductEntry;
280 }
281
282 StringBundler msg = new StringBundler(4);
283
284 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
285
286 msg.append("groupId=");
287 msg.append(groupId);
288
289 msg.append(StringPool.CLOSE_CURLY_BRACE);
290
291 throw new NoSuchProductEntryException(msg.toString());
292 }
293
294
302 @Override
303 public SCProductEntry fetchByGroupId_First(long groupId,
304 OrderByComparator orderByComparator) throws SystemException {
305 List<SCProductEntry> list = findByGroupId(groupId, 0, 1,
306 orderByComparator);
307
308 if (!list.isEmpty()) {
309 return list.get(0);
310 }
311
312 return null;
313 }
314
315
324 @Override
325 public SCProductEntry findByGroupId_Last(long groupId,
326 OrderByComparator orderByComparator)
327 throws NoSuchProductEntryException, SystemException {
328 SCProductEntry scProductEntry = fetchByGroupId_Last(groupId,
329 orderByComparator);
330
331 if (scProductEntry != null) {
332 return scProductEntry;
333 }
334
335 StringBundler msg = new StringBundler(4);
336
337 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
338
339 msg.append("groupId=");
340 msg.append(groupId);
341
342 msg.append(StringPool.CLOSE_CURLY_BRACE);
343
344 throw new NoSuchProductEntryException(msg.toString());
345 }
346
347
355 @Override
356 public SCProductEntry fetchByGroupId_Last(long groupId,
357 OrderByComparator orderByComparator) throws SystemException {
358 int count = countByGroupId(groupId);
359
360 if (count == 0) {
361 return null;
362 }
363
364 List<SCProductEntry> list = findByGroupId(groupId, count - 1, count,
365 orderByComparator);
366
367 if (!list.isEmpty()) {
368 return list.get(0);
369 }
370
371 return null;
372 }
373
374
384 @Override
385 public SCProductEntry[] findByGroupId_PrevAndNext(long productEntryId,
386 long groupId, OrderByComparator orderByComparator)
387 throws NoSuchProductEntryException, SystemException {
388 SCProductEntry scProductEntry = findByPrimaryKey(productEntryId);
389
390 Session session = null;
391
392 try {
393 session = openSession();
394
395 SCProductEntry[] array = new SCProductEntryImpl[3];
396
397 array[0] = getByGroupId_PrevAndNext(session, scProductEntry,
398 groupId, orderByComparator, true);
399
400 array[1] = scProductEntry;
401
402 array[2] = getByGroupId_PrevAndNext(session, scProductEntry,
403 groupId, orderByComparator, false);
404
405 return array;
406 }
407 catch (Exception e) {
408 throw processException(e);
409 }
410 finally {
411 closeSession(session);
412 }
413 }
414
415 protected SCProductEntry getByGroupId_PrevAndNext(Session session,
416 SCProductEntry scProductEntry, long groupId,
417 OrderByComparator orderByComparator, boolean previous) {
418 StringBundler query = null;
419
420 if (orderByComparator != null) {
421 query = new StringBundler(6 +
422 (orderByComparator.getOrderByFields().length * 6));
423 }
424 else {
425 query = new StringBundler(3);
426 }
427
428 query.append(_SQL_SELECT_SCPRODUCTENTRY_WHERE);
429
430 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
431
432 if (orderByComparator != null) {
433 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
434
435 if (orderByConditionFields.length > 0) {
436 query.append(WHERE_AND);
437 }
438
439 for (int i = 0; i < orderByConditionFields.length; i++) {
440 query.append(_ORDER_BY_ENTITY_ALIAS);
441 query.append(orderByConditionFields[i]);
442
443 if ((i + 1) < orderByConditionFields.length) {
444 if (orderByComparator.isAscending() ^ previous) {
445 query.append(WHERE_GREATER_THAN_HAS_NEXT);
446 }
447 else {
448 query.append(WHERE_LESSER_THAN_HAS_NEXT);
449 }
450 }
451 else {
452 if (orderByComparator.isAscending() ^ previous) {
453 query.append(WHERE_GREATER_THAN);
454 }
455 else {
456 query.append(WHERE_LESSER_THAN);
457 }
458 }
459 }
460
461 query.append(ORDER_BY_CLAUSE);
462
463 String[] orderByFields = orderByComparator.getOrderByFields();
464
465 for (int i = 0; i < orderByFields.length; i++) {
466 query.append(_ORDER_BY_ENTITY_ALIAS);
467 query.append(orderByFields[i]);
468
469 if ((i + 1) < orderByFields.length) {
470 if (orderByComparator.isAscending() ^ previous) {
471 query.append(ORDER_BY_ASC_HAS_NEXT);
472 }
473 else {
474 query.append(ORDER_BY_DESC_HAS_NEXT);
475 }
476 }
477 else {
478 if (orderByComparator.isAscending() ^ previous) {
479 query.append(ORDER_BY_ASC);
480 }
481 else {
482 query.append(ORDER_BY_DESC);
483 }
484 }
485 }
486 }
487 else {
488 query.append(SCProductEntryModelImpl.ORDER_BY_JPQL);
489 }
490
491 String sql = query.toString();
492
493 Query q = session.createQuery(sql);
494
495 q.setFirstResult(0);
496 q.setMaxResults(2);
497
498 QueryPos qPos = QueryPos.getInstance(q);
499
500 qPos.add(groupId);
501
502 if (orderByComparator != null) {
503 Object[] values = orderByComparator.getOrderByConditionValues(scProductEntry);
504
505 for (Object value : values) {
506 qPos.add(value);
507 }
508 }
509
510 List<SCProductEntry> list = q.list();
511
512 if (list.size() == 2) {
513 return list.get(1);
514 }
515 else {
516 return null;
517 }
518 }
519
520
527 @Override
528 public List<SCProductEntry> filterFindByGroupId(long groupId)
529 throws SystemException {
530 return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
531 QueryUtil.ALL_POS, null);
532 }
533
534
547 @Override
548 public List<SCProductEntry> filterFindByGroupId(long groupId, int start,
549 int end) throws SystemException {
550 return filterFindByGroupId(groupId, start, end, null);
551 }
552
553
567 @Override
568 public List<SCProductEntry> filterFindByGroupId(long groupId, int start,
569 int end, OrderByComparator orderByComparator) throws SystemException {
570 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
571 return findByGroupId(groupId, start, end, orderByComparator);
572 }
573
574 StringBundler query = null;
575
576 if (orderByComparator != null) {
577 query = new StringBundler(3 +
578 (orderByComparator.getOrderByFields().length * 3));
579 }
580 else {
581 query = new StringBundler(3);
582 }
583
584 if (getDB().isSupportsInlineDistinct()) {
585 query.append(_FILTER_SQL_SELECT_SCPRODUCTENTRY_WHERE);
586 }
587 else {
588 query.append(_FILTER_SQL_SELECT_SCPRODUCTENTRY_NO_INLINE_DISTINCT_WHERE_1);
589 }
590
591 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
592
593 if (!getDB().isSupportsInlineDistinct()) {
594 query.append(_FILTER_SQL_SELECT_SCPRODUCTENTRY_NO_INLINE_DISTINCT_WHERE_2);
595 }
596
597 if (orderByComparator != null) {
598 if (getDB().isSupportsInlineDistinct()) {
599 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
600 orderByComparator, true);
601 }
602 else {
603 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
604 orderByComparator, true);
605 }
606 }
607 else {
608 if (getDB().isSupportsInlineDistinct()) {
609 query.append(SCProductEntryModelImpl.ORDER_BY_JPQL);
610 }
611 else {
612 query.append(SCProductEntryModelImpl.ORDER_BY_SQL);
613 }
614 }
615
616 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
617 SCProductEntry.class.getName(),
618 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
619
620 Session session = null;
621
622 try {
623 session = openSession();
624
625 SQLQuery q = session.createSQLQuery(sql);
626
627 if (getDB().isSupportsInlineDistinct()) {
628 q.addEntity(_FILTER_ENTITY_ALIAS, SCProductEntryImpl.class);
629 }
630 else {
631 q.addEntity(_FILTER_ENTITY_TABLE, SCProductEntryImpl.class);
632 }
633
634 QueryPos qPos = QueryPos.getInstance(q);
635
636 qPos.add(groupId);
637
638 return (List<SCProductEntry>)QueryUtil.list(q, getDialect(), start,
639 end);
640 }
641 catch (Exception e) {
642 throw processException(e);
643 }
644 finally {
645 closeSession(session);
646 }
647 }
648
649
659 @Override
660 public SCProductEntry[] filterFindByGroupId_PrevAndNext(
661 long productEntryId, long groupId, OrderByComparator orderByComparator)
662 throws NoSuchProductEntryException, SystemException {
663 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
664 return findByGroupId_PrevAndNext(productEntryId, groupId,
665 orderByComparator);
666 }
667
668 SCProductEntry scProductEntry = findByPrimaryKey(productEntryId);
669
670 Session session = null;
671
672 try {
673 session = openSession();
674
675 SCProductEntry[] array = new SCProductEntryImpl[3];
676
677 array[0] = filterGetByGroupId_PrevAndNext(session, scProductEntry,
678 groupId, orderByComparator, true);
679
680 array[1] = scProductEntry;
681
682 array[2] = filterGetByGroupId_PrevAndNext(session, scProductEntry,
683 groupId, orderByComparator, false);
684
685 return array;
686 }
687 catch (Exception e) {
688 throw processException(e);
689 }
690 finally {
691 closeSession(session);
692 }
693 }
694
695 protected SCProductEntry filterGetByGroupId_PrevAndNext(Session session,
696 SCProductEntry scProductEntry, long groupId,
697 OrderByComparator orderByComparator, boolean previous) {
698 StringBundler query = null;
699
700 if (orderByComparator != null) {
701 query = new StringBundler(6 +
702 (orderByComparator.getOrderByFields().length * 6));
703 }
704 else {
705 query = new StringBundler(3);
706 }
707
708 if (getDB().isSupportsInlineDistinct()) {
709 query.append(_FILTER_SQL_SELECT_SCPRODUCTENTRY_WHERE);
710 }
711 else {
712 query.append(_FILTER_SQL_SELECT_SCPRODUCTENTRY_NO_INLINE_DISTINCT_WHERE_1);
713 }
714
715 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
716
717 if (!getDB().isSupportsInlineDistinct()) {
718 query.append(_FILTER_SQL_SELECT_SCPRODUCTENTRY_NO_INLINE_DISTINCT_WHERE_2);
719 }
720
721 if (orderByComparator != null) {
722 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
723
724 if (orderByConditionFields.length > 0) {
725 query.append(WHERE_AND);
726 }
727
728 for (int i = 0; i < orderByConditionFields.length; i++) {
729 if (getDB().isSupportsInlineDistinct()) {
730 query.append(_ORDER_BY_ENTITY_ALIAS);
731 }
732 else {
733 query.append(_ORDER_BY_ENTITY_TABLE);
734 }
735
736 query.append(orderByConditionFields[i]);
737
738 if ((i + 1) < orderByConditionFields.length) {
739 if (orderByComparator.isAscending() ^ previous) {
740 query.append(WHERE_GREATER_THAN_HAS_NEXT);
741 }
742 else {
743 query.append(WHERE_LESSER_THAN_HAS_NEXT);
744 }
745 }
746 else {
747 if (orderByComparator.isAscending() ^ previous) {
748 query.append(WHERE_GREATER_THAN);
749 }
750 else {
751 query.append(WHERE_LESSER_THAN);
752 }
753 }
754 }
755
756 query.append(ORDER_BY_CLAUSE);
757
758 String[] orderByFields = orderByComparator.getOrderByFields();
759
760 for (int i = 0; i < orderByFields.length; i++) {
761 if (getDB().isSupportsInlineDistinct()) {
762 query.append(_ORDER_BY_ENTITY_ALIAS);
763 }
764 else {
765 query.append(_ORDER_BY_ENTITY_TABLE);
766 }
767
768 query.append(orderByFields[i]);
769
770 if ((i + 1) < orderByFields.length) {
771 if (orderByComparator.isAscending() ^ previous) {
772 query.append(ORDER_BY_ASC_HAS_NEXT);
773 }
774 else {
775 query.append(ORDER_BY_DESC_HAS_NEXT);
776 }
777 }
778 else {
779 if (orderByComparator.isAscending() ^ previous) {
780 query.append(ORDER_BY_ASC);
781 }
782 else {
783 query.append(ORDER_BY_DESC);
784 }
785 }
786 }
787 }
788 else {
789 if (getDB().isSupportsInlineDistinct()) {
790 query.append(SCProductEntryModelImpl.ORDER_BY_JPQL);
791 }
792 else {
793 query.append(SCProductEntryModelImpl.ORDER_BY_SQL);
794 }
795 }
796
797 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
798 SCProductEntry.class.getName(),
799 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
800
801 SQLQuery q = session.createSQLQuery(sql);
802
803 q.setFirstResult(0);
804 q.setMaxResults(2);
805
806 if (getDB().isSupportsInlineDistinct()) {
807 q.addEntity(_FILTER_ENTITY_ALIAS, SCProductEntryImpl.class);
808 }
809 else {
810 q.addEntity(_FILTER_ENTITY_TABLE, SCProductEntryImpl.class);
811 }
812
813 QueryPos qPos = QueryPos.getInstance(q);
814
815 qPos.add(groupId);
816
817 if (orderByComparator != null) {
818 Object[] values = orderByComparator.getOrderByConditionValues(scProductEntry);
819
820 for (Object value : values) {
821 qPos.add(value);
822 }
823 }
824
825 List<SCProductEntry> list = q.list();
826
827 if (list.size() == 2) {
828 return list.get(1);
829 }
830 else {
831 return null;
832 }
833 }
834
835
841 @Override
842 public void removeByGroupId(long groupId) throws SystemException {
843 for (SCProductEntry scProductEntry : findByGroupId(groupId,
844 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
845 remove(scProductEntry);
846 }
847 }
848
849
856 @Override
857 public int countByGroupId(long groupId) throws SystemException {
858 FinderPath finderPath = FINDER_PATH_COUNT_BY_GROUPID;
859
860 Object[] finderArgs = new Object[] { groupId };
861
862 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
863 this);
864
865 if (count == null) {
866 StringBundler query = new StringBundler(2);
867
868 query.append(_SQL_COUNT_SCPRODUCTENTRY_WHERE);
869
870 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
871
872 String sql = query.toString();
873
874 Session session = null;
875
876 try {
877 session = openSession();
878
879 Query q = session.createQuery(sql);
880
881 QueryPos qPos = QueryPos.getInstance(q);
882
883 qPos.add(groupId);
884
885 count = (Long)q.uniqueResult();
886
887 FinderCacheUtil.putResult(finderPath, finderArgs, count);
888 }
889 catch (Exception e) {
890 FinderCacheUtil.removeResult(finderPath, finderArgs);
891
892 throw processException(e);
893 }
894 finally {
895 closeSession(session);
896 }
897 }
898
899 return count.intValue();
900 }
901
902
909 @Override
910 public int filterCountByGroupId(long groupId) throws SystemException {
911 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
912 return countByGroupId(groupId);
913 }
914
915 StringBundler query = new StringBundler(2);
916
917 query.append(_FILTER_SQL_COUNT_SCPRODUCTENTRY_WHERE);
918
919 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
920
921 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
922 SCProductEntry.class.getName(),
923 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
924
925 Session session = null;
926
927 try {
928 session = openSession();
929
930 SQLQuery q = session.createSQLQuery(sql);
931
932 q.addScalar(COUNT_COLUMN_NAME,
933 com.liferay.portal.kernel.dao.orm.Type.LONG);
934
935 QueryPos qPos = QueryPos.getInstance(q);
936
937 qPos.add(groupId);
938
939 Long count = (Long)q.uniqueResult();
940
941 return count.intValue();
942 }
943 catch (Exception e) {
944 throw processException(e);
945 }
946 finally {
947 closeSession(session);
948 }
949 }
950
951 private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "scProductEntry.groupId = ?";
952 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID =
953 new FinderPath(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
954 SCProductEntryModelImpl.FINDER_CACHE_ENABLED,
955 SCProductEntryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
956 "findByCompanyId",
957 new String[] {
958 Long.class.getName(),
959
960 Integer.class.getName(), Integer.class.getName(),
961 OrderByComparator.class.getName()
962 });
963 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID =
964 new FinderPath(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
965 SCProductEntryModelImpl.FINDER_CACHE_ENABLED,
966 SCProductEntryImpl.class,
967 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCompanyId",
968 new String[] { Long.class.getName() },
969 SCProductEntryModelImpl.COMPANYID_COLUMN_BITMASK |
970 SCProductEntryModelImpl.MODIFIEDDATE_COLUMN_BITMASK |
971 SCProductEntryModelImpl.NAME_COLUMN_BITMASK);
972 public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
973 SCProductEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
974 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCompanyId",
975 new String[] { Long.class.getName() });
976
977
984 @Override
985 public List<SCProductEntry> findByCompanyId(long companyId)
986 throws SystemException {
987 return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
988 null);
989 }
990
991
1004 @Override
1005 public List<SCProductEntry> findByCompanyId(long companyId, int start,
1006 int end) throws SystemException {
1007 return findByCompanyId(companyId, start, end, null);
1008 }
1009
1010
1024 @Override
1025 public List<SCProductEntry> findByCompanyId(long companyId, int start,
1026 int end, OrderByComparator orderByComparator) throws SystemException {
1027 boolean pagination = true;
1028 FinderPath finderPath = null;
1029 Object[] finderArgs = null;
1030
1031 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1032 (orderByComparator == null)) {
1033 pagination = false;
1034 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID;
1035 finderArgs = new Object[] { companyId };
1036 }
1037 else {
1038 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID;
1039 finderArgs = new Object[] { companyId, start, end, orderByComparator };
1040 }
1041
1042 List<SCProductEntry> list = (List<SCProductEntry>)FinderCacheUtil.getResult(finderPath,
1043 finderArgs, this);
1044
1045 if ((list != null) && !list.isEmpty()) {
1046 for (SCProductEntry scProductEntry : list) {
1047 if ((companyId != scProductEntry.getCompanyId())) {
1048 list = null;
1049
1050 break;
1051 }
1052 }
1053 }
1054
1055 if (list == null) {
1056 StringBundler query = null;
1057
1058 if (orderByComparator != null) {
1059 query = new StringBundler(3 +
1060 (orderByComparator.getOrderByFields().length * 3));
1061 }
1062 else {
1063 query = new StringBundler(3);
1064 }
1065
1066 query.append(_SQL_SELECT_SCPRODUCTENTRY_WHERE);
1067
1068 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1069
1070 if (orderByComparator != null) {
1071 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1072 orderByComparator);
1073 }
1074 else
1075 if (pagination) {
1076 query.append(SCProductEntryModelImpl.ORDER_BY_JPQL);
1077 }
1078
1079 String sql = query.toString();
1080
1081 Session session = null;
1082
1083 try {
1084 session = openSession();
1085
1086 Query q = session.createQuery(sql);
1087
1088 QueryPos qPos = QueryPos.getInstance(q);
1089
1090 qPos.add(companyId);
1091
1092 if (!pagination) {
1093 list = (List<SCProductEntry>)QueryUtil.list(q,
1094 getDialect(), start, end, false);
1095
1096 Collections.sort(list);
1097
1098 list = new UnmodifiableList<SCProductEntry>(list);
1099 }
1100 else {
1101 list = (List<SCProductEntry>)QueryUtil.list(q,
1102 getDialect(), start, end);
1103 }
1104
1105 cacheResult(list);
1106
1107 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1108 }
1109 catch (Exception e) {
1110 FinderCacheUtil.removeResult(finderPath, finderArgs);
1111
1112 throw processException(e);
1113 }
1114 finally {
1115 closeSession(session);
1116 }
1117 }
1118
1119 return list;
1120 }
1121
1122
1131 @Override
1132 public SCProductEntry findByCompanyId_First(long companyId,
1133 OrderByComparator orderByComparator)
1134 throws NoSuchProductEntryException, SystemException {
1135 SCProductEntry scProductEntry = fetchByCompanyId_First(companyId,
1136 orderByComparator);
1137
1138 if (scProductEntry != null) {
1139 return scProductEntry;
1140 }
1141
1142 StringBundler msg = new StringBundler(4);
1143
1144 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1145
1146 msg.append("companyId=");
1147 msg.append(companyId);
1148
1149 msg.append(StringPool.CLOSE_CURLY_BRACE);
1150
1151 throw new NoSuchProductEntryException(msg.toString());
1152 }
1153
1154
1162 @Override
1163 public SCProductEntry fetchByCompanyId_First(long companyId,
1164 OrderByComparator orderByComparator) throws SystemException {
1165 List<SCProductEntry> list = findByCompanyId(companyId, 0, 1,
1166 orderByComparator);
1167
1168 if (!list.isEmpty()) {
1169 return list.get(0);
1170 }
1171
1172 return null;
1173 }
1174
1175
1184 @Override
1185 public SCProductEntry findByCompanyId_Last(long companyId,
1186 OrderByComparator orderByComparator)
1187 throws NoSuchProductEntryException, SystemException {
1188 SCProductEntry scProductEntry = fetchByCompanyId_Last(companyId,
1189 orderByComparator);
1190
1191 if (scProductEntry != null) {
1192 return scProductEntry;
1193 }
1194
1195 StringBundler msg = new StringBundler(4);
1196
1197 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1198
1199 msg.append("companyId=");
1200 msg.append(companyId);
1201
1202 msg.append(StringPool.CLOSE_CURLY_BRACE);
1203
1204 throw new NoSuchProductEntryException(msg.toString());
1205 }
1206
1207
1215 @Override
1216 public SCProductEntry fetchByCompanyId_Last(long companyId,
1217 OrderByComparator orderByComparator) throws SystemException {
1218 int count = countByCompanyId(companyId);
1219
1220 if (count == 0) {
1221 return null;
1222 }
1223
1224 List<SCProductEntry> list = findByCompanyId(companyId, count - 1,
1225 count, orderByComparator);
1226
1227 if (!list.isEmpty()) {
1228 return list.get(0);
1229 }
1230
1231 return null;
1232 }
1233
1234
1244 @Override
1245 public SCProductEntry[] findByCompanyId_PrevAndNext(long productEntryId,
1246 long companyId, OrderByComparator orderByComparator)
1247 throws NoSuchProductEntryException, SystemException {
1248 SCProductEntry scProductEntry = findByPrimaryKey(productEntryId);
1249
1250 Session session = null;
1251
1252 try {
1253 session = openSession();
1254
1255 SCProductEntry[] array = new SCProductEntryImpl[3];
1256
1257 array[0] = getByCompanyId_PrevAndNext(session, scProductEntry,
1258 companyId, orderByComparator, true);
1259
1260 array[1] = scProductEntry;
1261
1262 array[2] = getByCompanyId_PrevAndNext(session, scProductEntry,
1263 companyId, orderByComparator, false);
1264
1265 return array;
1266 }
1267 catch (Exception e) {
1268 throw processException(e);
1269 }
1270 finally {
1271 closeSession(session);
1272 }
1273 }
1274
1275 protected SCProductEntry getByCompanyId_PrevAndNext(Session session,
1276 SCProductEntry scProductEntry, long companyId,
1277 OrderByComparator orderByComparator, boolean previous) {
1278 StringBundler query = null;
1279
1280 if (orderByComparator != null) {
1281 query = new StringBundler(6 +
1282 (orderByComparator.getOrderByFields().length * 6));
1283 }
1284 else {
1285 query = new StringBundler(3);
1286 }
1287
1288 query.append(_SQL_SELECT_SCPRODUCTENTRY_WHERE);
1289
1290 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1291
1292 if (orderByComparator != null) {
1293 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1294
1295 if (orderByConditionFields.length > 0) {
1296 query.append(WHERE_AND);
1297 }
1298
1299 for (int i = 0; i < orderByConditionFields.length; i++) {
1300 query.append(_ORDER_BY_ENTITY_ALIAS);
1301 query.append(orderByConditionFields[i]);
1302
1303 if ((i + 1) < orderByConditionFields.length) {
1304 if (orderByComparator.isAscending() ^ previous) {
1305 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1306 }
1307 else {
1308 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1309 }
1310 }
1311 else {
1312 if (orderByComparator.isAscending() ^ previous) {
1313 query.append(WHERE_GREATER_THAN);
1314 }
1315 else {
1316 query.append(WHERE_LESSER_THAN);
1317 }
1318 }
1319 }
1320
1321 query.append(ORDER_BY_CLAUSE);
1322
1323 String[] orderByFields = orderByComparator.getOrderByFields();
1324
1325 for (int i = 0; i < orderByFields.length; i++) {
1326 query.append(_ORDER_BY_ENTITY_ALIAS);
1327 query.append(orderByFields[i]);
1328
1329 if ((i + 1) < orderByFields.length) {
1330 if (orderByComparator.isAscending() ^ previous) {
1331 query.append(ORDER_BY_ASC_HAS_NEXT);
1332 }
1333 else {
1334 query.append(ORDER_BY_DESC_HAS_NEXT);
1335 }
1336 }
1337 else {
1338 if (orderByComparator.isAscending() ^ previous) {
1339 query.append(ORDER_BY_ASC);
1340 }
1341 else {
1342 query.append(ORDER_BY_DESC);
1343 }
1344 }
1345 }
1346 }
1347 else {
1348 query.append(SCProductEntryModelImpl.ORDER_BY_JPQL);
1349 }
1350
1351 String sql = query.toString();
1352
1353 Query q = session.createQuery(sql);
1354
1355 q.setFirstResult(0);
1356 q.setMaxResults(2);
1357
1358 QueryPos qPos = QueryPos.getInstance(q);
1359
1360 qPos.add(companyId);
1361
1362 if (orderByComparator != null) {
1363 Object[] values = orderByComparator.getOrderByConditionValues(scProductEntry);
1364
1365 for (Object value : values) {
1366 qPos.add(value);
1367 }
1368 }
1369
1370 List<SCProductEntry> list = q.list();
1371
1372 if (list.size() == 2) {
1373 return list.get(1);
1374 }
1375 else {
1376 return null;
1377 }
1378 }
1379
1380
1386 @Override
1387 public void removeByCompanyId(long companyId) throws SystemException {
1388 for (SCProductEntry scProductEntry : findByCompanyId(companyId,
1389 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1390 remove(scProductEntry);
1391 }
1392 }
1393
1394
1401 @Override
1402 public int countByCompanyId(long companyId) throws SystemException {
1403 FinderPath finderPath = FINDER_PATH_COUNT_BY_COMPANYID;
1404
1405 Object[] finderArgs = new Object[] { companyId };
1406
1407 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1408 this);
1409
1410 if (count == null) {
1411 StringBundler query = new StringBundler(2);
1412
1413 query.append(_SQL_COUNT_SCPRODUCTENTRY_WHERE);
1414
1415 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1416
1417 String sql = query.toString();
1418
1419 Session session = null;
1420
1421 try {
1422 session = openSession();
1423
1424 Query q = session.createQuery(sql);
1425
1426 QueryPos qPos = QueryPos.getInstance(q);
1427
1428 qPos.add(companyId);
1429
1430 count = (Long)q.uniqueResult();
1431
1432 FinderCacheUtil.putResult(finderPath, finderArgs, count);
1433 }
1434 catch (Exception e) {
1435 FinderCacheUtil.removeResult(finderPath, finderArgs);
1436
1437 throw processException(e);
1438 }
1439 finally {
1440 closeSession(session);
1441 }
1442 }
1443
1444 return count.intValue();
1445 }
1446
1447 private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "scProductEntry.companyId = ?";
1448 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U = new FinderPath(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
1449 SCProductEntryModelImpl.FINDER_CACHE_ENABLED,
1450 SCProductEntryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
1451 "findByG_U",
1452 new String[] {
1453 Long.class.getName(), Long.class.getName(),
1454
1455 Integer.class.getName(), Integer.class.getName(),
1456 OrderByComparator.class.getName()
1457 });
1458 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U = new FinderPath(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
1459 SCProductEntryModelImpl.FINDER_CACHE_ENABLED,
1460 SCProductEntryImpl.class,
1461 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_U",
1462 new String[] { Long.class.getName(), Long.class.getName() },
1463 SCProductEntryModelImpl.GROUPID_COLUMN_BITMASK |
1464 SCProductEntryModelImpl.USERID_COLUMN_BITMASK |
1465 SCProductEntryModelImpl.MODIFIEDDATE_COLUMN_BITMASK |
1466 SCProductEntryModelImpl.NAME_COLUMN_BITMASK);
1467 public static final FinderPath FINDER_PATH_COUNT_BY_G_U = new FinderPath(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
1468 SCProductEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
1469 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_U",
1470 new String[] { Long.class.getName(), Long.class.getName() });
1471
1472
1480 @Override
1481 public List<SCProductEntry> findByG_U(long groupId, long userId)
1482 throws SystemException {
1483 return findByG_U(groupId, userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
1484 null);
1485 }
1486
1487
1501 @Override
1502 public List<SCProductEntry> findByG_U(long groupId, long userId, int start,
1503 int end) throws SystemException {
1504 return findByG_U(groupId, userId, start, end, null);
1505 }
1506
1507
1522 @Override
1523 public List<SCProductEntry> findByG_U(long groupId, long userId, int start,
1524 int end, OrderByComparator orderByComparator) throws SystemException {
1525 boolean pagination = true;
1526 FinderPath finderPath = null;
1527 Object[] finderArgs = null;
1528
1529 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1530 (orderByComparator == null)) {
1531 pagination = false;
1532 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U;
1533 finderArgs = new Object[] { groupId, userId };
1534 }
1535 else {
1536 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U;
1537 finderArgs = new Object[] {
1538 groupId, userId,
1539
1540 start, end, orderByComparator
1541 };
1542 }
1543
1544 List<SCProductEntry> list = (List<SCProductEntry>)FinderCacheUtil.getResult(finderPath,
1545 finderArgs, this);
1546
1547 if ((list != null) && !list.isEmpty()) {
1548 for (SCProductEntry scProductEntry : list) {
1549 if ((groupId != scProductEntry.getGroupId()) ||
1550 (userId != scProductEntry.getUserId())) {
1551 list = null;
1552
1553 break;
1554 }
1555 }
1556 }
1557
1558 if (list == null) {
1559 StringBundler query = null;
1560
1561 if (orderByComparator != null) {
1562 query = new StringBundler(4 +
1563 (orderByComparator.getOrderByFields().length * 3));
1564 }
1565 else {
1566 query = new StringBundler(4);
1567 }
1568
1569 query.append(_SQL_SELECT_SCPRODUCTENTRY_WHERE);
1570
1571 query.append(_FINDER_COLUMN_G_U_GROUPID_2);
1572
1573 query.append(_FINDER_COLUMN_G_U_USERID_2);
1574
1575 if (orderByComparator != null) {
1576 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1577 orderByComparator);
1578 }
1579 else
1580 if (pagination) {
1581 query.append(SCProductEntryModelImpl.ORDER_BY_JPQL);
1582 }
1583
1584 String sql = query.toString();
1585
1586 Session session = null;
1587
1588 try {
1589 session = openSession();
1590
1591 Query q = session.createQuery(sql);
1592
1593 QueryPos qPos = QueryPos.getInstance(q);
1594
1595 qPos.add(groupId);
1596
1597 qPos.add(userId);
1598
1599 if (!pagination) {
1600 list = (List<SCProductEntry>)QueryUtil.list(q,
1601 getDialect(), start, end, false);
1602
1603 Collections.sort(list);
1604
1605 list = new UnmodifiableList<SCProductEntry>(list);
1606 }
1607 else {
1608 list = (List<SCProductEntry>)QueryUtil.list(q,
1609 getDialect(), start, end);
1610 }
1611
1612 cacheResult(list);
1613
1614 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1615 }
1616 catch (Exception e) {
1617 FinderCacheUtil.removeResult(finderPath, finderArgs);
1618
1619 throw processException(e);
1620 }
1621 finally {
1622 closeSession(session);
1623 }
1624 }
1625
1626 return list;
1627 }
1628
1629
1639 @Override
1640 public SCProductEntry findByG_U_First(long groupId, long userId,
1641 OrderByComparator orderByComparator)
1642 throws NoSuchProductEntryException, SystemException {
1643 SCProductEntry scProductEntry = fetchByG_U_First(groupId, userId,
1644 orderByComparator);
1645
1646 if (scProductEntry != null) {
1647 return scProductEntry;
1648 }
1649
1650 StringBundler msg = new StringBundler(6);
1651
1652 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1653
1654 msg.append("groupId=");
1655 msg.append(groupId);
1656
1657 msg.append(", userId=");
1658 msg.append(userId);
1659
1660 msg.append(StringPool.CLOSE_CURLY_BRACE);
1661
1662 throw new NoSuchProductEntryException(msg.toString());
1663 }
1664
1665
1674 @Override
1675 public SCProductEntry fetchByG_U_First(long groupId, long userId,
1676 OrderByComparator orderByComparator) throws SystemException {
1677 List<SCProductEntry> list = findByG_U(groupId, userId, 0, 1,
1678 orderByComparator);
1679
1680 if (!list.isEmpty()) {
1681 return list.get(0);
1682 }
1683
1684 return null;
1685 }
1686
1687
1697 @Override
1698 public SCProductEntry findByG_U_Last(long groupId, long userId,
1699 OrderByComparator orderByComparator)
1700 throws NoSuchProductEntryException, SystemException {
1701 SCProductEntry scProductEntry = fetchByG_U_Last(groupId, userId,
1702 orderByComparator);
1703
1704 if (scProductEntry != null) {
1705 return scProductEntry;
1706 }
1707
1708 StringBundler msg = new StringBundler(6);
1709
1710 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1711
1712 msg.append("groupId=");
1713 msg.append(groupId);
1714
1715 msg.append(", userId=");
1716 msg.append(userId);
1717
1718 msg.append(StringPool.CLOSE_CURLY_BRACE);
1719
1720 throw new NoSuchProductEntryException(msg.toString());
1721 }
1722
1723
1732 @Override
1733 public SCProductEntry fetchByG_U_Last(long groupId, long userId,
1734 OrderByComparator orderByComparator) throws SystemException {
1735 int count = countByG_U(groupId, userId);
1736
1737 if (count == 0) {
1738 return null;
1739 }
1740
1741 List<SCProductEntry> list = findByG_U(groupId, userId, count - 1,
1742 count, orderByComparator);
1743
1744 if (!list.isEmpty()) {
1745 return list.get(0);
1746 }
1747
1748 return null;
1749 }
1750
1751
1762 @Override
1763 public SCProductEntry[] findByG_U_PrevAndNext(long productEntryId,
1764 long groupId, long userId, OrderByComparator orderByComparator)
1765 throws NoSuchProductEntryException, SystemException {
1766 SCProductEntry scProductEntry = findByPrimaryKey(productEntryId);
1767
1768 Session session = null;
1769
1770 try {
1771 session = openSession();
1772
1773 SCProductEntry[] array = new SCProductEntryImpl[3];
1774
1775 array[0] = getByG_U_PrevAndNext(session, scProductEntry, groupId,
1776 userId, orderByComparator, true);
1777
1778 array[1] = scProductEntry;
1779
1780 array[2] = getByG_U_PrevAndNext(session, scProductEntry, groupId,
1781 userId, orderByComparator, false);
1782
1783 return array;
1784 }
1785 catch (Exception e) {
1786 throw processException(e);
1787 }
1788 finally {
1789 closeSession(session);
1790 }
1791 }
1792
1793 protected SCProductEntry getByG_U_PrevAndNext(Session session,
1794 SCProductEntry scProductEntry, long groupId, long userId,
1795 OrderByComparator orderByComparator, boolean previous) {
1796 StringBundler query = null;
1797
1798 if (orderByComparator != null) {
1799 query = new StringBundler(6 +
1800 (orderByComparator.getOrderByFields().length * 6));
1801 }
1802 else {
1803 query = new StringBundler(3);
1804 }
1805
1806 query.append(_SQL_SELECT_SCPRODUCTENTRY_WHERE);
1807
1808 query.append(_FINDER_COLUMN_G_U_GROUPID_2);
1809
1810 query.append(_FINDER_COLUMN_G_U_USERID_2);
1811
1812 if (orderByComparator != null) {
1813 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1814
1815 if (orderByConditionFields.length > 0) {
1816 query.append(WHERE_AND);
1817 }
1818
1819 for (int i = 0; i < orderByConditionFields.length; i++) {
1820 query.append(_ORDER_BY_ENTITY_ALIAS);
1821 query.append(orderByConditionFields[i]);
1822
1823 if ((i + 1) < orderByConditionFields.length) {
1824 if (orderByComparator.isAscending() ^ previous) {
1825 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1826 }
1827 else {
1828 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1829 }
1830 }
1831 else {
1832 if (orderByComparator.isAscending() ^ previous) {
1833 query.append(WHERE_GREATER_THAN);
1834 }
1835 else {
1836 query.append(WHERE_LESSER_THAN);
1837 }
1838 }
1839 }
1840
1841 query.append(ORDER_BY_CLAUSE);
1842
1843 String[] orderByFields = orderByComparator.getOrderByFields();
1844
1845 for (int i = 0; i < orderByFields.length; i++) {
1846 query.append(_ORDER_BY_ENTITY_ALIAS);
1847 query.append(orderByFields[i]);
1848
1849 if ((i + 1) < orderByFields.length) {
1850 if (orderByComparator.isAscending() ^ previous) {
1851 query.append(ORDER_BY_ASC_HAS_NEXT);
1852 }
1853 else {
1854 query.append(ORDER_BY_DESC_HAS_NEXT);
1855 }
1856 }
1857 else {
1858 if (orderByComparator.isAscending() ^ previous) {
1859 query.append(ORDER_BY_ASC);
1860 }
1861 else {
1862 query.append(ORDER_BY_DESC);
1863 }
1864 }
1865 }
1866 }
1867 else {
1868 query.append(SCProductEntryModelImpl.ORDER_BY_JPQL);
1869 }
1870
1871 String sql = query.toString();
1872
1873 Query q = session.createQuery(sql);
1874
1875 q.setFirstResult(0);
1876 q.setMaxResults(2);
1877
1878 QueryPos qPos = QueryPos.getInstance(q);
1879
1880 qPos.add(groupId);
1881
1882 qPos.add(userId);
1883
1884 if (orderByComparator != null) {
1885 Object[] values = orderByComparator.getOrderByConditionValues(scProductEntry);
1886
1887 for (Object value : values) {
1888 qPos.add(value);
1889 }
1890 }
1891
1892 List<SCProductEntry> list = q.list();
1893
1894 if (list.size() == 2) {
1895 return list.get(1);
1896 }
1897 else {
1898 return null;
1899 }
1900 }
1901
1902
1910 @Override
1911 public List<SCProductEntry> filterFindByG_U(long groupId, long userId)
1912 throws SystemException {
1913 return filterFindByG_U(groupId, userId, QueryUtil.ALL_POS,
1914 QueryUtil.ALL_POS, null);
1915 }
1916
1917
1931 @Override
1932 public List<SCProductEntry> filterFindByG_U(long groupId, long userId,
1933 int start, int end) throws SystemException {
1934 return filterFindByG_U(groupId, userId, start, end, null);
1935 }
1936
1937
1952 @Override
1953 public List<SCProductEntry> filterFindByG_U(long groupId, long userId,
1954 int start, int end, OrderByComparator orderByComparator)
1955 throws SystemException {
1956 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1957 return findByG_U(groupId, userId, start, end, orderByComparator);
1958 }
1959
1960 StringBundler query = null;
1961
1962 if (orderByComparator != null) {
1963 query = new StringBundler(4 +
1964 (orderByComparator.getOrderByFields().length * 3));
1965 }
1966 else {
1967 query = new StringBundler(4);
1968 }
1969
1970 if (getDB().isSupportsInlineDistinct()) {
1971 query.append(_FILTER_SQL_SELECT_SCPRODUCTENTRY_WHERE);
1972 }
1973 else {
1974 query.append(_FILTER_SQL_SELECT_SCPRODUCTENTRY_NO_INLINE_DISTINCT_WHERE_1);
1975 }
1976
1977 query.append(_FINDER_COLUMN_G_U_GROUPID_2);
1978
1979 query.append(_FINDER_COLUMN_G_U_USERID_2);
1980
1981 if (!getDB().isSupportsInlineDistinct()) {
1982 query.append(_FILTER_SQL_SELECT_SCPRODUCTENTRY_NO_INLINE_DISTINCT_WHERE_2);
1983 }
1984
1985 if (orderByComparator != null) {
1986 if (getDB().isSupportsInlineDistinct()) {
1987 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1988 orderByComparator, true);
1989 }
1990 else {
1991 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
1992 orderByComparator, true);
1993 }
1994 }
1995 else {
1996 if (getDB().isSupportsInlineDistinct()) {
1997 query.append(SCProductEntryModelImpl.ORDER_BY_JPQL);
1998 }
1999 else {
2000 query.append(SCProductEntryModelImpl.ORDER_BY_SQL);
2001 }
2002 }
2003
2004 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2005 SCProductEntry.class.getName(),
2006 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2007
2008 Session session = null;
2009
2010 try {
2011 session = openSession();
2012
2013 SQLQuery q = session.createSQLQuery(sql);
2014
2015 if (getDB().isSupportsInlineDistinct()) {
2016 q.addEntity(_FILTER_ENTITY_ALIAS, SCProductEntryImpl.class);
2017 }
2018 else {
2019 q.addEntity(_FILTER_ENTITY_TABLE, SCProductEntryImpl.class);
2020 }
2021
2022 QueryPos qPos = QueryPos.getInstance(q);
2023
2024 qPos.add(groupId);
2025
2026 qPos.add(userId);
2027
2028 return (List<SCProductEntry>)QueryUtil.list(q, getDialect(), start,
2029 end);
2030 }
2031 catch (Exception e) {
2032 throw processException(e);
2033 }
2034 finally {
2035 closeSession(session);
2036 }
2037 }
2038
2039
2050 @Override
2051 public SCProductEntry[] filterFindByG_U_PrevAndNext(long productEntryId,
2052 long groupId, long userId, OrderByComparator orderByComparator)
2053 throws NoSuchProductEntryException, SystemException {
2054 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2055 return findByG_U_PrevAndNext(productEntryId, groupId, userId,
2056 orderByComparator);
2057 }
2058
2059 SCProductEntry scProductEntry = findByPrimaryKey(productEntryId);
2060
2061 Session session = null;
2062
2063 try {
2064 session = openSession();
2065
2066 SCProductEntry[] array = new SCProductEntryImpl[3];
2067
2068 array[0] = filterGetByG_U_PrevAndNext(session, scProductEntry,
2069 groupId, userId, orderByComparator, true);
2070
2071 array[1] = scProductEntry;
2072
2073 array[2] = filterGetByG_U_PrevAndNext(session, scProductEntry,
2074 groupId, userId, orderByComparator, false);
2075
2076 return array;
2077 }
2078 catch (Exception e) {
2079 throw processException(e);
2080 }
2081 finally {
2082 closeSession(session);
2083 }
2084 }
2085
2086 protected SCProductEntry filterGetByG_U_PrevAndNext(Session session,
2087 SCProductEntry scProductEntry, long groupId, long userId,
2088 OrderByComparator orderByComparator, boolean previous) {
2089 StringBundler query = null;
2090
2091 if (orderByComparator != null) {
2092 query = new StringBundler(6 +
2093 (orderByComparator.getOrderByFields().length * 6));
2094 }
2095 else {
2096 query = new StringBundler(3);
2097 }
2098
2099 if (getDB().isSupportsInlineDistinct()) {
2100 query.append(_FILTER_SQL_SELECT_SCPRODUCTENTRY_WHERE);
2101 }
2102 else {
2103 query.append(_FILTER_SQL_SELECT_SCPRODUCTENTRY_NO_INLINE_DISTINCT_WHERE_1);
2104 }
2105
2106 query.append(_FINDER_COLUMN_G_U_GROUPID_2);
2107
2108 query.append(_FINDER_COLUMN_G_U_USERID_2);
2109
2110 if (!getDB().isSupportsInlineDistinct()) {
2111 query.append(_FILTER_SQL_SELECT_SCPRODUCTENTRY_NO_INLINE_DISTINCT_WHERE_2);
2112 }
2113
2114 if (orderByComparator != null) {
2115 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2116
2117 if (orderByConditionFields.length > 0) {
2118 query.append(WHERE_AND);
2119 }
2120
2121 for (int i = 0; i < orderByConditionFields.length; i++) {
2122 if (getDB().isSupportsInlineDistinct()) {
2123 query.append(_ORDER_BY_ENTITY_ALIAS);
2124 }
2125 else {
2126 query.append(_ORDER_BY_ENTITY_TABLE);
2127 }
2128
2129 query.append(orderByConditionFields[i]);
2130
2131 if ((i + 1) < orderByConditionFields.length) {
2132 if (orderByComparator.isAscending() ^ previous) {
2133 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2134 }
2135 else {
2136 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2137 }
2138 }
2139 else {
2140 if (orderByComparator.isAscending() ^ previous) {
2141 query.append(WHERE_GREATER_THAN);
2142 }
2143 else {
2144 query.append(WHERE_LESSER_THAN);
2145 }
2146 }
2147 }
2148
2149 query.append(ORDER_BY_CLAUSE);
2150
2151 String[] orderByFields = orderByComparator.getOrderByFields();
2152
2153 for (int i = 0; i < orderByFields.length; i++) {
2154 if (getDB().isSupportsInlineDistinct()) {
2155 query.append(_ORDER_BY_ENTITY_ALIAS);
2156 }
2157 else {
2158 query.append(_ORDER_BY_ENTITY_TABLE);
2159 }
2160
2161 query.append(orderByFields[i]);
2162
2163 if ((i + 1) < orderByFields.length) {
2164 if (orderByComparator.isAscending() ^ previous) {
2165 query.append(ORDER_BY_ASC_HAS_NEXT);
2166 }
2167 else {
2168 query.append(ORDER_BY_DESC_HAS_NEXT);
2169 }
2170 }
2171 else {
2172 if (orderByComparator.isAscending() ^ previous) {
2173 query.append(ORDER_BY_ASC);
2174 }
2175 else {
2176 query.append(ORDER_BY_DESC);
2177 }
2178 }
2179 }
2180 }
2181 else {
2182 if (getDB().isSupportsInlineDistinct()) {
2183 query.append(SCProductEntryModelImpl.ORDER_BY_JPQL);
2184 }
2185 else {
2186 query.append(SCProductEntryModelImpl.ORDER_BY_SQL);
2187 }
2188 }
2189
2190 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2191 SCProductEntry.class.getName(),
2192 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2193
2194 SQLQuery q = session.createSQLQuery(sql);
2195
2196 q.setFirstResult(0);
2197 q.setMaxResults(2);
2198
2199 if (getDB().isSupportsInlineDistinct()) {
2200 q.addEntity(_FILTER_ENTITY_ALIAS, SCProductEntryImpl.class);
2201 }
2202 else {
2203 q.addEntity(_FILTER_ENTITY_TABLE, SCProductEntryImpl.class);
2204 }
2205
2206 QueryPos qPos = QueryPos.getInstance(q);
2207
2208 qPos.add(groupId);
2209
2210 qPos.add(userId);
2211
2212 if (orderByComparator != null) {
2213 Object[] values = orderByComparator.getOrderByConditionValues(scProductEntry);
2214
2215 for (Object value : values) {
2216 qPos.add(value);
2217 }
2218 }
2219
2220 List<SCProductEntry> list = q.list();
2221
2222 if (list.size() == 2) {
2223 return list.get(1);
2224 }
2225 else {
2226 return null;
2227 }
2228 }
2229
2230
2237 @Override
2238 public void removeByG_U(long groupId, long userId)
2239 throws SystemException {
2240 for (SCProductEntry scProductEntry : findByG_U(groupId, userId,
2241 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
2242 remove(scProductEntry);
2243 }
2244 }
2245
2246
2254 @Override
2255 public int countByG_U(long groupId, long userId) throws SystemException {
2256 FinderPath finderPath = FINDER_PATH_COUNT_BY_G_U;
2257
2258 Object[] finderArgs = new Object[] { groupId, userId };
2259
2260 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
2261 this);
2262
2263 if (count == null) {
2264 StringBundler query = new StringBundler(3);
2265
2266 query.append(_SQL_COUNT_SCPRODUCTENTRY_WHERE);
2267
2268 query.append(_FINDER_COLUMN_G_U_GROUPID_2);
2269
2270 query.append(_FINDER_COLUMN_G_U_USERID_2);
2271
2272 String sql = query.toString();
2273
2274 Session session = null;
2275
2276 try {
2277 session = openSession();
2278
2279 Query q = session.createQuery(sql);
2280
2281 QueryPos qPos = QueryPos.getInstance(q);
2282
2283 qPos.add(groupId);
2284
2285 qPos.add(userId);
2286
2287 count = (Long)q.uniqueResult();
2288
2289 FinderCacheUtil.putResult(finderPath, finderArgs, count);
2290 }
2291 catch (Exception e) {
2292 FinderCacheUtil.removeResult(finderPath, finderArgs);
2293
2294 throw processException(e);
2295 }
2296 finally {
2297 closeSession(session);
2298 }
2299 }
2300
2301 return count.intValue();
2302 }
2303
2304
2312 @Override
2313 public int filterCountByG_U(long groupId, long userId)
2314 throws SystemException {
2315 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2316 return countByG_U(groupId, userId);
2317 }
2318
2319 StringBundler query = new StringBundler(3);
2320
2321 query.append(_FILTER_SQL_COUNT_SCPRODUCTENTRY_WHERE);
2322
2323 query.append(_FINDER_COLUMN_G_U_GROUPID_2);
2324
2325 query.append(_FINDER_COLUMN_G_U_USERID_2);
2326
2327 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2328 SCProductEntry.class.getName(),
2329 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2330
2331 Session session = null;
2332
2333 try {
2334 session = openSession();
2335
2336 SQLQuery q = session.createSQLQuery(sql);
2337
2338 q.addScalar(COUNT_COLUMN_NAME,
2339 com.liferay.portal.kernel.dao.orm.Type.LONG);
2340
2341 QueryPos qPos = QueryPos.getInstance(q);
2342
2343 qPos.add(groupId);
2344
2345 qPos.add(userId);
2346
2347 Long count = (Long)q.uniqueResult();
2348
2349 return count.intValue();
2350 }
2351 catch (Exception e) {
2352 throw processException(e);
2353 }
2354 finally {
2355 closeSession(session);
2356 }
2357 }
2358
2359 private static final String _FINDER_COLUMN_G_U_GROUPID_2 = "scProductEntry.groupId = ? AND ";
2360 private static final String _FINDER_COLUMN_G_U_USERID_2 = "scProductEntry.userId = ?";
2361 public static final FinderPath FINDER_PATH_FETCH_BY_RG_RA = new FinderPath(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
2362 SCProductEntryModelImpl.FINDER_CACHE_ENABLED,
2363 SCProductEntryImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByRG_RA",
2364 new String[] { String.class.getName(), String.class.getName() },
2365 SCProductEntryModelImpl.REPOGROUPID_COLUMN_BITMASK |
2366 SCProductEntryModelImpl.REPOARTIFACTID_COLUMN_BITMASK);
2367 public static final FinderPath FINDER_PATH_COUNT_BY_RG_RA = new FinderPath(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
2368 SCProductEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
2369 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByRG_RA",
2370 new String[] { String.class.getName(), String.class.getName() });
2371
2372
2381 @Override
2382 public SCProductEntry findByRG_RA(String repoGroupId, String repoArtifactId)
2383 throws NoSuchProductEntryException, SystemException {
2384 SCProductEntry scProductEntry = fetchByRG_RA(repoGroupId, repoArtifactId);
2385
2386 if (scProductEntry == null) {
2387 StringBundler msg = new StringBundler(6);
2388
2389 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2390
2391 msg.append("repoGroupId=");
2392 msg.append(repoGroupId);
2393
2394 msg.append(", repoArtifactId=");
2395 msg.append(repoArtifactId);
2396
2397 msg.append(StringPool.CLOSE_CURLY_BRACE);
2398
2399 if (_log.isWarnEnabled()) {
2400 _log.warn(msg.toString());
2401 }
2402
2403 throw new NoSuchProductEntryException(msg.toString());
2404 }
2405
2406 return scProductEntry;
2407 }
2408
2409
2417 @Override
2418 public SCProductEntry fetchByRG_RA(String repoGroupId, String repoArtifactId)
2419 throws SystemException {
2420 return fetchByRG_RA(repoGroupId, repoArtifactId, true);
2421 }
2422
2423
2432 @Override
2433 public SCProductEntry fetchByRG_RA(String repoGroupId,
2434 String repoArtifactId, boolean retrieveFromCache)
2435 throws SystemException {
2436 Object[] finderArgs = new Object[] { repoGroupId, repoArtifactId };
2437
2438 Object result = null;
2439
2440 if (retrieveFromCache) {
2441 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_RG_RA,
2442 finderArgs, this);
2443 }
2444
2445 if (result instanceof SCProductEntry) {
2446 SCProductEntry scProductEntry = (SCProductEntry)result;
2447
2448 if (!Validator.equals(repoGroupId, scProductEntry.getRepoGroupId()) ||
2449 !Validator.equals(repoArtifactId,
2450 scProductEntry.getRepoArtifactId())) {
2451 result = null;
2452 }
2453 }
2454
2455 if (result == null) {
2456 StringBundler query = new StringBundler(4);
2457
2458 query.append(_SQL_SELECT_SCPRODUCTENTRY_WHERE);
2459
2460 boolean bindRepoGroupId = false;
2461
2462 if (repoGroupId == null) {
2463 query.append(_FINDER_COLUMN_RG_RA_REPOGROUPID_1);
2464 }
2465 else if (repoGroupId.equals(StringPool.BLANK)) {
2466 query.append(_FINDER_COLUMN_RG_RA_REPOGROUPID_3);
2467 }
2468 else {
2469 bindRepoGroupId = true;
2470
2471 query.append(_FINDER_COLUMN_RG_RA_REPOGROUPID_2);
2472 }
2473
2474 boolean bindRepoArtifactId = false;
2475
2476 if (repoArtifactId == null) {
2477 query.append(_FINDER_COLUMN_RG_RA_REPOARTIFACTID_1);
2478 }
2479 else if (repoArtifactId.equals(StringPool.BLANK)) {
2480 query.append(_FINDER_COLUMN_RG_RA_REPOARTIFACTID_3);
2481 }
2482 else {
2483 bindRepoArtifactId = true;
2484
2485 query.append(_FINDER_COLUMN_RG_RA_REPOARTIFACTID_2);
2486 }
2487
2488 String sql = query.toString();
2489
2490 Session session = null;
2491
2492 try {
2493 session = openSession();
2494
2495 Query q = session.createQuery(sql);
2496
2497 QueryPos qPos = QueryPos.getInstance(q);
2498
2499 if (bindRepoGroupId) {
2500 qPos.add(repoGroupId.toLowerCase());
2501 }
2502
2503 if (bindRepoArtifactId) {
2504 qPos.add(repoArtifactId.toLowerCase());
2505 }
2506
2507 List<SCProductEntry> list = q.list();
2508
2509 if (list.isEmpty()) {
2510 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_RG_RA,
2511 finderArgs, list);
2512 }
2513 else {
2514 if ((list.size() > 1) && _log.isWarnEnabled()) {
2515 _log.warn(
2516 "SCProductEntryPersistenceImpl.fetchByRG_RA(String, String, boolean) with parameters (" +
2517 StringUtil.merge(finderArgs) +
2518 ") 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.");
2519 }
2520
2521 SCProductEntry scProductEntry = list.get(0);
2522
2523 result = scProductEntry;
2524
2525 cacheResult(scProductEntry);
2526
2527 if ((scProductEntry.getRepoGroupId() == null) ||
2528 !scProductEntry.getRepoGroupId().equals(repoGroupId) ||
2529 (scProductEntry.getRepoArtifactId() == null) ||
2530 !scProductEntry.getRepoArtifactId()
2531 .equals(repoArtifactId)) {
2532 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_RG_RA,
2533 finderArgs, scProductEntry);
2534 }
2535 }
2536 }
2537 catch (Exception e) {
2538 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_RG_RA,
2539 finderArgs);
2540
2541 throw processException(e);
2542 }
2543 finally {
2544 closeSession(session);
2545 }
2546 }
2547
2548 if (result instanceof List<?>) {
2549 return null;
2550 }
2551 else {
2552 return (SCProductEntry)result;
2553 }
2554 }
2555
2556
2564 @Override
2565 public SCProductEntry removeByRG_RA(String repoGroupId,
2566 String repoArtifactId)
2567 throws NoSuchProductEntryException, SystemException {
2568 SCProductEntry scProductEntry = findByRG_RA(repoGroupId, repoArtifactId);
2569
2570 return remove(scProductEntry);
2571 }
2572
2573
2581 @Override
2582 public int countByRG_RA(String repoGroupId, String repoArtifactId)
2583 throws SystemException {
2584 FinderPath finderPath = FINDER_PATH_COUNT_BY_RG_RA;
2585
2586 Object[] finderArgs = new Object[] { repoGroupId, repoArtifactId };
2587
2588 Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
2589 this);
2590
2591 if (count == null) {
2592 StringBundler query = new StringBundler(3);
2593
2594 query.append(_SQL_COUNT_SCPRODUCTENTRY_WHERE);
2595
2596 boolean bindRepoGroupId = false;
2597
2598 if (repoGroupId == null) {
2599 query.append(_FINDER_COLUMN_RG_RA_REPOGROUPID_1);
2600 }
2601 else if (repoGroupId.equals(StringPool.BLANK)) {
2602 query.append(_FINDER_COLUMN_RG_RA_REPOGROUPID_3);
2603 }
2604 else {
2605 bindRepoGroupId = true;
2606
2607 query.append(_FINDER_COLUMN_RG_RA_REPOGROUPID_2);
2608 }
2609
2610 boolean bindRepoArtifactId = false;
2611
2612 if (repoArtifactId == null) {
2613 query.append(_FINDER_COLUMN_RG_RA_REPOARTIFACTID_1);
2614 }
2615 else if (repoArtifactId.equals(StringPool.BLANK)) {
2616 query.append(_FINDER_COLUMN_RG_RA_REPOARTIFACTID_3);
2617 }
2618 else {
2619 bindRepoArtifactId = true;
2620
2621 query.append(_FINDER_COLUMN_RG_RA_REPOARTIFACTID_2);
2622 }
2623
2624 String sql = query.toString();
2625
2626 Session session = null;
2627
2628 try {
2629 session = openSession();
2630
2631 Query q = session.createQuery(sql);
2632
2633 QueryPos qPos = QueryPos.getInstance(q);
2634
2635 if (bindRepoGroupId) {
2636 qPos.add(repoGroupId.toLowerCase());
2637 }
2638
2639 if (bindRepoArtifactId) {
2640 qPos.add(repoArtifactId.toLowerCase());
2641 }
2642
2643 count = (Long)q.uniqueResult();
2644
2645 FinderCacheUtil.putResult(finderPath, finderArgs, count);
2646 }
2647 catch (Exception e) {
2648 FinderCacheUtil.removeResult(finderPath, finderArgs);
2649
2650 throw processException(e);
2651 }
2652 finally {
2653 closeSession(session);
2654 }
2655 }
2656
2657 return count.intValue();
2658 }
2659
2660 private static final String _FINDER_COLUMN_RG_RA_REPOGROUPID_1 = "scProductEntry.repoGroupId IS NULL AND ";
2661 private static final String _FINDER_COLUMN_RG_RA_REPOGROUPID_2 = "lower(scProductEntry.repoGroupId) = ? AND ";
2662 private static final String _FINDER_COLUMN_RG_RA_REPOGROUPID_3 = "(scProductEntry.repoGroupId IS NULL OR scProductEntry.repoGroupId = '') AND ";
2663 private static final String _FINDER_COLUMN_RG_RA_REPOARTIFACTID_1 = "scProductEntry.repoArtifactId IS NULL";
2664 private static final String _FINDER_COLUMN_RG_RA_REPOARTIFACTID_2 = "lower(scProductEntry.repoArtifactId) = ?";
2665 private static final String _FINDER_COLUMN_RG_RA_REPOARTIFACTID_3 = "(scProductEntry.repoArtifactId IS NULL OR scProductEntry.repoArtifactId = '')";
2666
2667 public SCProductEntryPersistenceImpl() {
2668 setModelClass(SCProductEntry.class);
2669 }
2670
2671
2676 @Override
2677 public void cacheResult(SCProductEntry scProductEntry) {
2678 EntityCacheUtil.putResult(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
2679 SCProductEntryImpl.class, scProductEntry.getPrimaryKey(),
2680 scProductEntry);
2681
2682 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_RG_RA,
2683 new Object[] {
2684 scProductEntry.getRepoGroupId(),
2685 scProductEntry.getRepoArtifactId()
2686 }, scProductEntry);
2687
2688 scProductEntry.resetOriginalValues();
2689 }
2690
2691
2696 @Override
2697 public void cacheResult(List<SCProductEntry> scProductEntries) {
2698 for (SCProductEntry scProductEntry : scProductEntries) {
2699 if (EntityCacheUtil.getResult(
2700 SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
2701 SCProductEntryImpl.class, scProductEntry.getPrimaryKey()) == null) {
2702 cacheResult(scProductEntry);
2703 }
2704 else {
2705 scProductEntry.resetOriginalValues();
2706 }
2707 }
2708 }
2709
2710
2717 @Override
2718 public void clearCache() {
2719 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
2720 CacheRegistryUtil.clear(SCProductEntryImpl.class.getName());
2721 }
2722
2723 EntityCacheUtil.clearCache(SCProductEntryImpl.class.getName());
2724
2725 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
2726 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2727 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2728 }
2729
2730
2737 @Override
2738 public void clearCache(SCProductEntry scProductEntry) {
2739 EntityCacheUtil.removeResult(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
2740 SCProductEntryImpl.class, scProductEntry.getPrimaryKey());
2741
2742 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2743 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2744
2745 clearUniqueFindersCache(scProductEntry);
2746 }
2747
2748 @Override
2749 public void clearCache(List<SCProductEntry> scProductEntries) {
2750 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2751 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2752
2753 for (SCProductEntry scProductEntry : scProductEntries) {
2754 EntityCacheUtil.removeResult(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
2755 SCProductEntryImpl.class, scProductEntry.getPrimaryKey());
2756
2757 clearUniqueFindersCache(scProductEntry);
2758 }
2759 }
2760
2761 protected void cacheUniqueFindersCache(SCProductEntry scProductEntry) {
2762 if (scProductEntry.isNew()) {
2763 Object[] args = new Object[] {
2764 scProductEntry.getRepoGroupId(),
2765 scProductEntry.getRepoArtifactId()
2766 };
2767
2768 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_RG_RA, args,
2769 Long.valueOf(1));
2770 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_RG_RA, args,
2771 scProductEntry);
2772 }
2773 else {
2774 SCProductEntryModelImpl scProductEntryModelImpl = (SCProductEntryModelImpl)scProductEntry;
2775
2776 if ((scProductEntryModelImpl.getColumnBitmask() &
2777 FINDER_PATH_FETCH_BY_RG_RA.getColumnBitmask()) != 0) {
2778 Object[] args = new Object[] {
2779 scProductEntry.getRepoGroupId(),
2780 scProductEntry.getRepoArtifactId()
2781 };
2782
2783 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_RG_RA, args,
2784 Long.valueOf(1));
2785 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_RG_RA, args,
2786 scProductEntry);
2787 }
2788 }
2789 }
2790
2791 protected void clearUniqueFindersCache(SCProductEntry scProductEntry) {
2792 SCProductEntryModelImpl scProductEntryModelImpl = (SCProductEntryModelImpl)scProductEntry;
2793
2794 Object[] args = new Object[] {
2795 scProductEntry.getRepoGroupId(),
2796 scProductEntry.getRepoArtifactId()
2797 };
2798
2799 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_RG_RA, args);
2800 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_RG_RA, args);
2801
2802 if ((scProductEntryModelImpl.getColumnBitmask() &
2803 FINDER_PATH_FETCH_BY_RG_RA.getColumnBitmask()) != 0) {
2804 args = new Object[] {
2805 scProductEntryModelImpl.getOriginalRepoGroupId(),
2806 scProductEntryModelImpl.getOriginalRepoArtifactId()
2807 };
2808
2809 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_RG_RA, args);
2810 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_RG_RA, args);
2811 }
2812 }
2813
2814
2820 @Override
2821 public SCProductEntry create(long productEntryId) {
2822 SCProductEntry scProductEntry = new SCProductEntryImpl();
2823
2824 scProductEntry.setNew(true);
2825 scProductEntry.setPrimaryKey(productEntryId);
2826
2827 return scProductEntry;
2828 }
2829
2830
2838 @Override
2839 public SCProductEntry remove(long productEntryId)
2840 throws NoSuchProductEntryException, SystemException {
2841 return remove((Serializable)productEntryId);
2842 }
2843
2844
2852 @Override
2853 public SCProductEntry remove(Serializable primaryKey)
2854 throws NoSuchProductEntryException, SystemException {
2855 Session session = null;
2856
2857 try {
2858 session = openSession();
2859
2860 SCProductEntry scProductEntry = (SCProductEntry)session.get(SCProductEntryImpl.class,
2861 primaryKey);
2862
2863 if (scProductEntry == null) {
2864 if (_log.isWarnEnabled()) {
2865 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
2866 }
2867
2868 throw new NoSuchProductEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
2869 primaryKey);
2870 }
2871
2872 return remove(scProductEntry);
2873 }
2874 catch (NoSuchProductEntryException nsee) {
2875 throw nsee;
2876 }
2877 catch (Exception e) {
2878 throw processException(e);
2879 }
2880 finally {
2881 closeSession(session);
2882 }
2883 }
2884
2885 @Override
2886 protected SCProductEntry removeImpl(SCProductEntry scProductEntry)
2887 throws SystemException {
2888 scProductEntry = toUnwrappedModel(scProductEntry);
2889
2890 scProductEntryToSCLicenseTableMapper.deleteLeftPrimaryKeyTableMappings(scProductEntry.getPrimaryKey());
2891
2892 Session session = null;
2893
2894 try {
2895 session = openSession();
2896
2897 if (!session.contains(scProductEntry)) {
2898 scProductEntry = (SCProductEntry)session.get(SCProductEntryImpl.class,
2899 scProductEntry.getPrimaryKeyObj());
2900 }
2901
2902 if (scProductEntry != null) {
2903 session.delete(scProductEntry);
2904 }
2905 }
2906 catch (Exception e) {
2907 throw processException(e);
2908 }
2909 finally {
2910 closeSession(session);
2911 }
2912
2913 if (scProductEntry != null) {
2914 clearCache(scProductEntry);
2915 }
2916
2917 return scProductEntry;
2918 }
2919
2920 @Override
2921 public SCProductEntry updateImpl(
2922 com.liferay.portlet.softwarecatalog.model.SCProductEntry scProductEntry)
2923 throws SystemException {
2924 scProductEntry = toUnwrappedModel(scProductEntry);
2925
2926 boolean isNew = scProductEntry.isNew();
2927
2928 SCProductEntryModelImpl scProductEntryModelImpl = (SCProductEntryModelImpl)scProductEntry;
2929
2930 Session session = null;
2931
2932 try {
2933 session = openSession();
2934
2935 if (scProductEntry.isNew()) {
2936 session.save(scProductEntry);
2937
2938 scProductEntry.setNew(false);
2939 }
2940 else {
2941 session.merge(scProductEntry);
2942 }
2943 }
2944 catch (Exception e) {
2945 throw processException(e);
2946 }
2947 finally {
2948 closeSession(session);
2949 }
2950
2951 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2952
2953 if (isNew || !SCProductEntryModelImpl.COLUMN_BITMASK_ENABLED) {
2954 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2955 }
2956
2957 else {
2958 if ((scProductEntryModelImpl.getColumnBitmask() &
2959 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
2960 Object[] args = new Object[] {
2961 scProductEntryModelImpl.getOriginalGroupId()
2962 };
2963
2964 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
2965 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
2966 args);
2967
2968 args = new Object[] { scProductEntryModelImpl.getGroupId() };
2969
2970 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
2971 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
2972 args);
2973 }
2974
2975 if ((scProductEntryModelImpl.getColumnBitmask() &
2976 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
2977 Object[] args = new Object[] {
2978 scProductEntryModelImpl.getOriginalCompanyId()
2979 };
2980
2981 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
2982 args);
2983 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
2984 args);
2985
2986 args = new Object[] { scProductEntryModelImpl.getCompanyId() };
2987
2988 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
2989 args);
2990 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
2991 args);
2992 }
2993
2994 if ((scProductEntryModelImpl.getColumnBitmask() &
2995 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U.getColumnBitmask()) != 0) {
2996 Object[] args = new Object[] {
2997 scProductEntryModelImpl.getOriginalGroupId(),
2998 scProductEntryModelImpl.getOriginalUserId()
2999 };
3000
3001 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U, args);
3002 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U,
3003 args);
3004
3005 args = new Object[] {
3006 scProductEntryModelImpl.getGroupId(),
3007 scProductEntryModelImpl.getUserId()
3008 };
3009
3010 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U, args);
3011 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U,
3012 args);
3013 }
3014 }
3015
3016 EntityCacheUtil.putResult(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
3017 SCProductEntryImpl.class, scProductEntry.getPrimaryKey(),
3018 scProductEntry);
3019
3020 clearUniqueFindersCache(scProductEntry);
3021 cacheUniqueFindersCache(scProductEntry);
3022
3023 return scProductEntry;
3024 }
3025
3026 protected SCProductEntry toUnwrappedModel(SCProductEntry scProductEntry) {
3027 if (scProductEntry instanceof SCProductEntryImpl) {
3028 return scProductEntry;
3029 }
3030
3031 SCProductEntryImpl scProductEntryImpl = new SCProductEntryImpl();
3032
3033 scProductEntryImpl.setNew(scProductEntry.isNew());
3034 scProductEntryImpl.setPrimaryKey(scProductEntry.getPrimaryKey());
3035
3036 scProductEntryImpl.setProductEntryId(scProductEntry.getProductEntryId());
3037 scProductEntryImpl.setGroupId(scProductEntry.getGroupId());
3038 scProductEntryImpl.setCompanyId(scProductEntry.getCompanyId());
3039 scProductEntryImpl.setUserId(scProductEntry.getUserId());
3040 scProductEntryImpl.setUserName(scProductEntry.getUserName());
3041 scProductEntryImpl.setCreateDate(scProductEntry.getCreateDate());
3042 scProductEntryImpl.setModifiedDate(scProductEntry.getModifiedDate());
3043 scProductEntryImpl.setName(scProductEntry.getName());
3044 scProductEntryImpl.setType(scProductEntry.getType());
3045 scProductEntryImpl.setTags(scProductEntry.getTags());
3046 scProductEntryImpl.setShortDescription(scProductEntry.getShortDescription());
3047 scProductEntryImpl.setLongDescription(scProductEntry.getLongDescription());
3048 scProductEntryImpl.setPageURL(scProductEntry.getPageURL());
3049 scProductEntryImpl.setAuthor(scProductEntry.getAuthor());
3050 scProductEntryImpl.setRepoGroupId(scProductEntry.getRepoGroupId());
3051 scProductEntryImpl.setRepoArtifactId(scProductEntry.getRepoArtifactId());
3052
3053 return scProductEntryImpl;
3054 }
3055
3056
3064 @Override
3065 public SCProductEntry findByPrimaryKey(Serializable primaryKey)
3066 throws NoSuchProductEntryException, SystemException {
3067 SCProductEntry scProductEntry = fetchByPrimaryKey(primaryKey);
3068
3069 if (scProductEntry == null) {
3070 if (_log.isWarnEnabled()) {
3071 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
3072 }
3073
3074 throw new NoSuchProductEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
3075 primaryKey);
3076 }
3077
3078 return scProductEntry;
3079 }
3080
3081
3089 @Override
3090 public SCProductEntry findByPrimaryKey(long productEntryId)
3091 throws NoSuchProductEntryException, SystemException {
3092 return findByPrimaryKey((Serializable)productEntryId);
3093 }
3094
3095
3102 @Override
3103 public SCProductEntry fetchByPrimaryKey(Serializable primaryKey)
3104 throws SystemException {
3105 SCProductEntry scProductEntry = (SCProductEntry)EntityCacheUtil.getResult(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
3106 SCProductEntryImpl.class, primaryKey);
3107
3108 if (scProductEntry == _nullSCProductEntry) {
3109 return null;
3110 }
3111
3112 if (scProductEntry == null) {
3113 Session session = null;
3114
3115 try {
3116 session = openSession();
3117
3118 scProductEntry = (SCProductEntry)session.get(SCProductEntryImpl.class,
3119 primaryKey);
3120
3121 if (scProductEntry != null) {
3122 cacheResult(scProductEntry);
3123 }
3124 else {
3125 EntityCacheUtil.putResult(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
3126 SCProductEntryImpl.class, primaryKey,
3127 _nullSCProductEntry);
3128 }
3129 }
3130 catch (Exception e) {
3131 EntityCacheUtil.removeResult(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
3132 SCProductEntryImpl.class, primaryKey);
3133
3134 throw processException(e);
3135 }
3136 finally {
3137 closeSession(session);
3138 }
3139 }
3140
3141 return scProductEntry;
3142 }
3143
3144
3151 @Override
3152 public SCProductEntry fetchByPrimaryKey(long productEntryId)
3153 throws SystemException {
3154 return fetchByPrimaryKey((Serializable)productEntryId);
3155 }
3156
3157
3163 @Override
3164 public List<SCProductEntry> findAll() throws SystemException {
3165 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
3166 }
3167
3168
3180 @Override
3181 public List<SCProductEntry> findAll(int start, int end)
3182 throws SystemException {
3183 return findAll(start, end, null);
3184 }
3185
3186
3199 @Override
3200 public List<SCProductEntry> findAll(int start, int end,
3201 OrderByComparator orderByComparator) throws SystemException {
3202 boolean pagination = true;
3203 FinderPath finderPath = null;
3204 Object[] finderArgs = null;
3205
3206 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3207 (orderByComparator == null)) {
3208 pagination = false;
3209 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
3210 finderArgs = FINDER_ARGS_EMPTY;
3211 }
3212 else {
3213 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
3214 finderArgs = new Object[] { start, end, orderByComparator };
3215 }
3216
3217 List<SCProductEntry> list = (List<SCProductEntry>)FinderCacheUtil.getResult(finderPath,
3218 finderArgs, this);
3219
3220 if (list == null) {
3221 StringBundler query = null;
3222 String sql = null;
3223
3224 if (orderByComparator != null) {
3225 query = new StringBundler(2 +
3226 (orderByComparator.getOrderByFields().length * 3));
3227
3228 query.append(_SQL_SELECT_SCPRODUCTENTRY);
3229
3230 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3231 orderByComparator);
3232
3233 sql = query.toString();
3234 }
3235 else {
3236 sql = _SQL_SELECT_SCPRODUCTENTRY;
3237
3238 if (pagination) {
3239 sql = sql.concat(SCProductEntryModelImpl.ORDER_BY_JPQL);
3240 }
3241 }
3242
3243 Session session = null;
3244
3245 try {
3246 session = openSession();
3247
3248 Query q = session.createQuery(sql);
3249
3250 if (!pagination) {
3251 list = (List<SCProductEntry>)QueryUtil.list(q,
3252 getDialect(), start, end, false);
3253
3254 Collections.sort(list);
3255
3256 list = new UnmodifiableList<SCProductEntry>(list);
3257 }
3258 else {
3259 list = (List<SCProductEntry>)QueryUtil.list(q,
3260 getDialect(), start, end);
3261 }
3262
3263 cacheResult(list);
3264
3265 FinderCacheUtil.putResult(finderPath, finderArgs, list);
3266 }
3267 catch (Exception e) {
3268 FinderCacheUtil.removeResult(finderPath, finderArgs);
3269
3270 throw processException(e);
3271 }
3272 finally {
3273 closeSession(session);
3274 }
3275 }
3276
3277 return list;
3278 }
3279
3280
3285 @Override
3286 public void removeAll() throws SystemException {
3287 for (SCProductEntry scProductEntry : findAll()) {
3288 remove(scProductEntry);
3289 }
3290 }
3291
3292
3298 @Override
3299 public int countAll() throws SystemException {
3300 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
3301 FINDER_ARGS_EMPTY, this);
3302
3303 if (count == null) {
3304 Session session = null;
3305
3306 try {
3307 session = openSession();
3308
3309 Query q = session.createQuery(_SQL_COUNT_SCPRODUCTENTRY);
3310
3311 count = (Long)q.uniqueResult();
3312
3313 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
3314 FINDER_ARGS_EMPTY, count);
3315 }
3316 catch (Exception e) {
3317 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
3318 FINDER_ARGS_EMPTY);
3319
3320 throw processException(e);
3321 }
3322 finally {
3323 closeSession(session);
3324 }
3325 }
3326
3327 return count.intValue();
3328 }
3329
3330
3337 @Override
3338 public List<com.liferay.portlet.softwarecatalog.model.SCLicense> getSCLicenses(
3339 long pk) throws SystemException {
3340 return getSCLicenses(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
3341 }
3342
3343
3356 @Override
3357 public List<com.liferay.portlet.softwarecatalog.model.SCLicense> getSCLicenses(
3358 long pk, int start, int end) throws SystemException {
3359 return getSCLicenses(pk, start, end, null);
3360 }
3361
3362
3376 @Override
3377 public List<com.liferay.portlet.softwarecatalog.model.SCLicense> getSCLicenses(
3378 long pk, int start, int end, OrderByComparator orderByComparator)
3379 throws SystemException {
3380 return scProductEntryToSCLicenseTableMapper.getRightBaseModels(pk,
3381 start, end, orderByComparator);
3382 }
3383
3384
3391 @Override
3392 public int getSCLicensesSize(long pk) throws SystemException {
3393 long[] pks = scProductEntryToSCLicenseTableMapper.getRightPrimaryKeys(pk);
3394
3395 return pks.length;
3396 }
3397
3398
3406 @Override
3407 public boolean containsSCLicense(long pk, long scLicensePK)
3408 throws SystemException {
3409 return scProductEntryToSCLicenseTableMapper.containsTableMapping(pk,
3410 scLicensePK);
3411 }
3412
3413
3420 @Override
3421 public boolean containsSCLicenses(long pk) throws SystemException {
3422 if (getSCLicensesSize(pk) > 0) {
3423 return true;
3424 }
3425 else {
3426 return false;
3427 }
3428 }
3429
3430
3437 @Override
3438 public void addSCLicense(long pk, long scLicensePK)
3439 throws SystemException {
3440 scProductEntryToSCLicenseTableMapper.addTableMapping(pk, scLicensePK);
3441 }
3442
3443
3450 @Override
3451 public void addSCLicense(long pk,
3452 com.liferay.portlet.softwarecatalog.model.SCLicense scLicense)
3453 throws SystemException {
3454 scProductEntryToSCLicenseTableMapper.addTableMapping(pk,
3455 scLicense.getPrimaryKey());
3456 }
3457
3458
3465 @Override
3466 public void addSCLicenses(long pk, long[] scLicensePKs)
3467 throws SystemException {
3468 for (long scLicensePK : scLicensePKs) {
3469 scProductEntryToSCLicenseTableMapper.addTableMapping(pk, scLicensePK);
3470 }
3471 }
3472
3473
3480 @Override
3481 public void addSCLicenses(long pk,
3482 List<com.liferay.portlet.softwarecatalog.model.SCLicense> scLicenses)
3483 throws SystemException {
3484 for (com.liferay.portlet.softwarecatalog.model.SCLicense scLicense : scLicenses) {
3485 scProductEntryToSCLicenseTableMapper.addTableMapping(pk,
3486 scLicense.getPrimaryKey());
3487 }
3488 }
3489
3490
3496 @Override
3497 public void clearSCLicenses(long pk) throws SystemException {
3498 scProductEntryToSCLicenseTableMapper.deleteLeftPrimaryKeyTableMappings(pk);
3499 }
3500
3501
3508 @Override
3509 public void removeSCLicense(long pk, long scLicensePK)
3510 throws SystemException {
3511 scProductEntryToSCLicenseTableMapper.deleteTableMapping(pk, scLicensePK);
3512 }
3513
3514
3521 @Override
3522 public void removeSCLicense(long pk,
3523 com.liferay.portlet.softwarecatalog.model.SCLicense scLicense)
3524 throws SystemException {
3525 scProductEntryToSCLicenseTableMapper.deleteTableMapping(pk,
3526 scLicense.getPrimaryKey());
3527 }
3528
3529
3536 @Override
3537 public void removeSCLicenses(long pk, long[] scLicensePKs)
3538 throws SystemException {
3539 for (long scLicensePK : scLicensePKs) {
3540 scProductEntryToSCLicenseTableMapper.deleteTableMapping(pk,
3541 scLicensePK);
3542 }
3543 }
3544
3545
3552 @Override
3553 public void removeSCLicenses(long pk,
3554 List<com.liferay.portlet.softwarecatalog.model.SCLicense> scLicenses)
3555 throws SystemException {
3556 for (com.liferay.portlet.softwarecatalog.model.SCLicense scLicense : scLicenses) {
3557 scProductEntryToSCLicenseTableMapper.deleteTableMapping(pk,
3558 scLicense.getPrimaryKey());
3559 }
3560 }
3561
3562
3569 @Override
3570 public void setSCLicenses(long pk, long[] scLicensePKs)
3571 throws SystemException {
3572 Set<Long> newSCLicensePKsSet = SetUtil.fromArray(scLicensePKs);
3573 Set<Long> oldSCLicensePKsSet = SetUtil.fromArray(scProductEntryToSCLicenseTableMapper.getRightPrimaryKeys(
3574 pk));
3575
3576 Set<Long> removeSCLicensePKsSet = new HashSet<Long>(oldSCLicensePKsSet);
3577
3578 removeSCLicensePKsSet.removeAll(newSCLicensePKsSet);
3579
3580 for (long removeSCLicensePK : removeSCLicensePKsSet) {
3581 scProductEntryToSCLicenseTableMapper.deleteTableMapping(pk,
3582 removeSCLicensePK);
3583 }
3584
3585 newSCLicensePKsSet.removeAll(oldSCLicensePKsSet);
3586
3587 for (long newSCLicensePK : newSCLicensePKsSet) {
3588 scProductEntryToSCLicenseTableMapper.addTableMapping(pk,
3589 newSCLicensePK);
3590 }
3591 }
3592
3593
3600 @Override
3601 public void setSCLicenses(long pk,
3602 List<com.liferay.portlet.softwarecatalog.model.SCLicense> scLicenses)
3603 throws SystemException {
3604 try {
3605 long[] scLicensePKs = new long[scLicenses.size()];
3606
3607 for (int i = 0; i < scLicenses.size(); i++) {
3608 com.liferay.portlet.softwarecatalog.model.SCLicense scLicense = scLicenses.get(i);
3609
3610 scLicensePKs[i] = scLicense.getPrimaryKey();
3611 }
3612
3613 setSCLicenses(pk, scLicensePKs);
3614 }
3615 catch (Exception e) {
3616 throw processException(e);
3617 }
3618 finally {
3619 FinderCacheUtil.clearCache(SCProductEntryModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
3620 }
3621 }
3622
3623 @Override
3624 protected Set<String> getBadColumnNames() {
3625 return _badColumnNames;
3626 }
3627
3628
3631 public void afterPropertiesSet() {
3632 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
3633 com.liferay.portal.util.PropsUtil.get(
3634 "value.object.listener.com.liferay.portlet.softwarecatalog.model.SCProductEntry")));
3635
3636 if (listenerClassNames.length > 0) {
3637 try {
3638 List<ModelListener<SCProductEntry>> listenersList = new ArrayList<ModelListener<SCProductEntry>>();
3639
3640 for (String listenerClassName : listenerClassNames) {
3641 listenersList.add((ModelListener<SCProductEntry>)InstanceFactory.newInstance(
3642 getClassLoader(), listenerClassName));
3643 }
3644
3645 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
3646 }
3647 catch (Exception e) {
3648 _log.error(e);
3649 }
3650 }
3651
3652 scProductEntryToSCLicenseTableMapper = TableMapperFactory.getTableMapper("SCLicenses_SCProductEntries",
3653 "productEntryId", "licenseId", this, scLicensePersistence);
3654 }
3655
3656 public void destroy() {
3657 EntityCacheUtil.removeCache(SCProductEntryImpl.class.getName());
3658 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
3659 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
3660 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
3661 }
3662
3663 @BeanReference(type = SCLicensePersistence.class)
3664 protected SCLicensePersistence scLicensePersistence;
3665 protected TableMapper<SCProductEntry, com.liferay.portlet.softwarecatalog.model.SCLicense> scProductEntryToSCLicenseTableMapper;
3666 private static final String _SQL_SELECT_SCPRODUCTENTRY = "SELECT scProductEntry FROM SCProductEntry scProductEntry";
3667 private static final String _SQL_SELECT_SCPRODUCTENTRY_WHERE = "SELECT scProductEntry FROM SCProductEntry scProductEntry WHERE ";
3668 private static final String _SQL_COUNT_SCPRODUCTENTRY = "SELECT COUNT(scProductEntry) FROM SCProductEntry scProductEntry";
3669 private static final String _SQL_COUNT_SCPRODUCTENTRY_WHERE = "SELECT COUNT(scProductEntry) FROM SCProductEntry scProductEntry WHERE ";
3670 private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "scProductEntry.productEntryId";
3671 private static final String _FILTER_SQL_SELECT_SCPRODUCTENTRY_WHERE = "SELECT DISTINCT {scProductEntry.*} FROM SCProductEntry scProductEntry WHERE ";
3672 private static final String _FILTER_SQL_SELECT_SCPRODUCTENTRY_NO_INLINE_DISTINCT_WHERE_1 =
3673 "SELECT {SCProductEntry.*} FROM (SELECT DISTINCT scProductEntry.productEntryId FROM SCProductEntry scProductEntry WHERE ";
3674 private static final String _FILTER_SQL_SELECT_SCPRODUCTENTRY_NO_INLINE_DISTINCT_WHERE_2 =
3675 ") TEMP_TABLE INNER JOIN SCProductEntry ON TEMP_TABLE.productEntryId = SCProductEntry.productEntryId";
3676 private static final String _FILTER_SQL_COUNT_SCPRODUCTENTRY_WHERE = "SELECT COUNT(DISTINCT scProductEntry.productEntryId) AS COUNT_VALUE FROM SCProductEntry scProductEntry WHERE ";
3677 private static final String _FILTER_ENTITY_ALIAS = "scProductEntry";
3678 private static final String _FILTER_ENTITY_TABLE = "SCProductEntry";
3679 private static final String _ORDER_BY_ENTITY_ALIAS = "scProductEntry.";
3680 private static final String _ORDER_BY_ENTITY_TABLE = "SCProductEntry.";
3681 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No SCProductEntry exists with the primary key ";
3682 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No SCProductEntry exists with the key {";
3683 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
3684 private static Log _log = LogFactoryUtil.getLog(SCProductEntryPersistenceImpl.class);
3685 private static Set<String> _badColumnNames = SetUtil.fromArray(new String[] {
3686 "type"
3687 });
3688 private static SCProductEntry _nullSCProductEntry = new SCProductEntryImpl() {
3689 @Override
3690 public Object clone() {
3691 return this;
3692 }
3693
3694 @Override
3695 public CacheModel<SCProductEntry> toCacheModel() {
3696 return _nullSCProductEntryCacheModel;
3697 }
3698 };
3699
3700 private static CacheModel<SCProductEntry> _nullSCProductEntryCacheModel = new CacheModel<SCProductEntry>() {
3701 @Override
3702 public SCProductEntry toEntityModel() {
3703 return _nullSCProductEntry;
3704 }
3705 };
3706 }