001
014
015 package com.liferay.portlet.softwarecatalog.service.persistence;
016
017 import com.liferay.portal.NoSuchModelException;
018 import com.liferay.portal.kernel.bean.BeanReference;
019 import com.liferay.portal.kernel.cache.CacheRegistryUtil;
020 import com.liferay.portal.kernel.dao.jdbc.MappingSqlQuery;
021 import com.liferay.portal.kernel.dao.jdbc.MappingSqlQueryFactoryUtil;
022 import com.liferay.portal.kernel.dao.jdbc.RowMapper;
023 import com.liferay.portal.kernel.dao.jdbc.SqlUpdate;
024 import com.liferay.portal.kernel.dao.jdbc.SqlUpdateFactoryUtil;
025 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
026 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
027 import com.liferay.portal.kernel.dao.orm.FinderPath;
028 import com.liferay.portal.kernel.dao.orm.Query;
029 import com.liferay.portal.kernel.dao.orm.QueryPos;
030 import com.liferay.portal.kernel.dao.orm.QueryUtil;
031 import com.liferay.portal.kernel.dao.orm.SQLQuery;
032 import com.liferay.portal.kernel.dao.orm.Session;
033 import com.liferay.portal.kernel.exception.SystemException;
034 import com.liferay.portal.kernel.log.Log;
035 import com.liferay.portal.kernel.log.LogFactoryUtil;
036 import com.liferay.portal.kernel.util.GetterUtil;
037 import com.liferay.portal.kernel.util.InstanceFactory;
038 import com.liferay.portal.kernel.util.OrderByComparator;
039 import com.liferay.portal.kernel.util.SetUtil;
040 import com.liferay.portal.kernel.util.StringBundler;
041 import com.liferay.portal.kernel.util.StringPool;
042 import com.liferay.portal.kernel.util.StringUtil;
043 import com.liferay.portal.model.CacheModel;
044 import com.liferay.portal.model.ModelListener;
045 import com.liferay.portal.security.permission.InlineSQLHelperUtil;
046 import com.liferay.portal.service.persistence.BatchSessionUtil;
047 import com.liferay.portal.service.persistence.GroupPersistence;
048 import com.liferay.portal.service.persistence.ImagePersistence;
049 import com.liferay.portal.service.persistence.ResourcePersistence;
050 import com.liferay.portal.service.persistence.UserPersistence;
051 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
052
053 import com.liferay.portlet.messageboards.service.persistence.MBMessagePersistence;
054 import com.liferay.portlet.ratings.service.persistence.RatingsStatsPersistence;
055 import com.liferay.portlet.softwarecatalog.NoSuchProductEntryException;
056 import com.liferay.portlet.softwarecatalog.model.SCProductEntry;
057 import com.liferay.portlet.softwarecatalog.model.impl.SCProductEntryImpl;
058 import com.liferay.portlet.softwarecatalog.model.impl.SCProductEntryModelImpl;
059
060 import java.io.Serializable;
061
062 import java.util.ArrayList;
063 import java.util.Collections;
064 import java.util.List;
065 import java.util.Set;
066
067
079 public class SCProductEntryPersistenceImpl extends BasePersistenceImpl<SCProductEntry>
080 implements SCProductEntryPersistence {
081
086 public static final String FINDER_CLASS_NAME_ENTITY = SCProductEntryImpl.class.getName();
087 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
088 ".List1";
089 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
090 ".List2";
091 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
092 SCProductEntryModelImpl.FINDER_CACHE_ENABLED,
093 SCProductEntryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
094 "findByGroupId",
095 new String[] {
096 Long.class.getName(),
097
098 "java.lang.Integer", "java.lang.Integer",
099 "com.liferay.portal.kernel.util.OrderByComparator"
100 });
101 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID =
102 new FinderPath(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
103 SCProductEntryModelImpl.FINDER_CACHE_ENABLED,
104 SCProductEntryImpl.class,
105 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByGroupId",
106 new String[] { Long.class.getName() },
107 SCProductEntryModelImpl.GROUPID_COLUMN_BITMASK);
108 public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
109 SCProductEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
110 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId",
111 new String[] { Long.class.getName() });
112 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID =
113 new FinderPath(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
114 SCProductEntryModelImpl.FINDER_CACHE_ENABLED,
115 SCProductEntryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
116 "findByCompanyId",
117 new String[] {
118 Long.class.getName(),
119
120 "java.lang.Integer", "java.lang.Integer",
121 "com.liferay.portal.kernel.util.OrderByComparator"
122 });
123 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID =
124 new FinderPath(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
125 SCProductEntryModelImpl.FINDER_CACHE_ENABLED,
126 SCProductEntryImpl.class,
127 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCompanyId",
128 new String[] { Long.class.getName() },
129 SCProductEntryModelImpl.COMPANYID_COLUMN_BITMASK);
130 public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
131 SCProductEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
132 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCompanyId",
133 new String[] { Long.class.getName() });
134 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U = new FinderPath(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
135 SCProductEntryModelImpl.FINDER_CACHE_ENABLED,
136 SCProductEntryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
137 "findByG_U",
138 new String[] {
139 Long.class.getName(), Long.class.getName(),
140
141 "java.lang.Integer", "java.lang.Integer",
142 "com.liferay.portal.kernel.util.OrderByComparator"
143 });
144 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U = new FinderPath(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
145 SCProductEntryModelImpl.FINDER_CACHE_ENABLED,
146 SCProductEntryImpl.class,
147 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_U",
148 new String[] { Long.class.getName(), Long.class.getName() },
149 SCProductEntryModelImpl.GROUPID_COLUMN_BITMASK |
150 SCProductEntryModelImpl.USERID_COLUMN_BITMASK);
151 public static final FinderPath FINDER_PATH_COUNT_BY_G_U = new FinderPath(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
152 SCProductEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
153 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_U",
154 new String[] { Long.class.getName(), Long.class.getName() });
155 public static final FinderPath FINDER_PATH_FETCH_BY_RG_RA = new FinderPath(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
156 SCProductEntryModelImpl.FINDER_CACHE_ENABLED,
157 SCProductEntryImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByRG_RA",
158 new String[] { String.class.getName(), String.class.getName() },
159 SCProductEntryModelImpl.REPOGROUPID_COLUMN_BITMASK |
160 SCProductEntryModelImpl.REPOARTIFACTID_COLUMN_BITMASK);
161 public static final FinderPath FINDER_PATH_COUNT_BY_RG_RA = new FinderPath(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
162 SCProductEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
163 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByRG_RA",
164 new String[] { String.class.getName(), String.class.getName() });
165 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
166 SCProductEntryModelImpl.FINDER_CACHE_ENABLED,
167 SCProductEntryImpl.class,
168 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
169 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
170 SCProductEntryModelImpl.FINDER_CACHE_ENABLED,
171 SCProductEntryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
172 "findAll", new String[0]);
173 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
174 SCProductEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
175 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
176
177
182 public void cacheResult(SCProductEntry scProductEntry) {
183 EntityCacheUtil.putResult(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
184 SCProductEntryImpl.class, scProductEntry.getPrimaryKey(),
185 scProductEntry);
186
187 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_RG_RA,
188 new Object[] {
189 scProductEntry.getRepoGroupId(),
190
191 scProductEntry.getRepoArtifactId()
192 }, scProductEntry);
193
194 scProductEntry.resetOriginalValues();
195 }
196
197
202 public void cacheResult(List<SCProductEntry> scProductEntries) {
203 for (SCProductEntry scProductEntry : scProductEntries) {
204 if (EntityCacheUtil.getResult(
205 SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
206 SCProductEntryImpl.class, scProductEntry.getPrimaryKey()) == null) {
207 cacheResult(scProductEntry);
208 }
209 else {
210 scProductEntry.resetOriginalValues();
211 }
212 }
213 }
214
215
222 @Override
223 public void clearCache() {
224 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
225 CacheRegistryUtil.clear(SCProductEntryImpl.class.getName());
226 }
227
228 EntityCacheUtil.clearCache(SCProductEntryImpl.class.getName());
229
230 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
231 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
232 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
233 }
234
235
242 @Override
243 public void clearCache(SCProductEntry scProductEntry) {
244 EntityCacheUtil.removeResult(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
245 SCProductEntryImpl.class, scProductEntry.getPrimaryKey());
246
247 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
248 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
249
250 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_RG_RA,
251 new Object[] {
252 scProductEntry.getRepoGroupId(),
253
254 scProductEntry.getRepoArtifactId()
255 });
256 }
257
258
264 public SCProductEntry create(long productEntryId) {
265 SCProductEntry scProductEntry = new SCProductEntryImpl();
266
267 scProductEntry.setNew(true);
268 scProductEntry.setPrimaryKey(productEntryId);
269
270 return scProductEntry;
271 }
272
273
281 @Override
282 public SCProductEntry remove(Serializable primaryKey)
283 throws NoSuchModelException, SystemException {
284 return remove(((Long)primaryKey).longValue());
285 }
286
287
295 public SCProductEntry remove(long productEntryId)
296 throws NoSuchProductEntryException, SystemException {
297 Session session = null;
298
299 try {
300 session = openSession();
301
302 SCProductEntry scProductEntry = (SCProductEntry)session.get(SCProductEntryImpl.class,
303 Long.valueOf(productEntryId));
304
305 if (scProductEntry == null) {
306 if (_log.isWarnEnabled()) {
307 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
308 productEntryId);
309 }
310
311 throw new NoSuchProductEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
312 productEntryId);
313 }
314
315 return scProductEntryPersistence.remove(scProductEntry);
316 }
317 catch (NoSuchProductEntryException nsee) {
318 throw nsee;
319 }
320 catch (Exception e) {
321 throw processException(e);
322 }
323 finally {
324 closeSession(session);
325 }
326 }
327
328
335 @Override
336 public SCProductEntry remove(SCProductEntry scProductEntry)
337 throws SystemException {
338 return super.remove(scProductEntry);
339 }
340
341 @Override
342 protected SCProductEntry removeImpl(SCProductEntry scProductEntry)
343 throws SystemException {
344 scProductEntry = toUnwrappedModel(scProductEntry);
345
346 try {
347 clearSCLicenses.clear(scProductEntry.getPrimaryKey());
348 }
349 catch (Exception e) {
350 throw processException(e);
351 }
352 finally {
353 FinderCacheUtil.clearCache(SCProductEntryModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
354 }
355
356 Session session = null;
357
358 try {
359 session = openSession();
360
361 BatchSessionUtil.delete(session, scProductEntry);
362 }
363 catch (Exception e) {
364 throw processException(e);
365 }
366 finally {
367 closeSession(session);
368 }
369
370 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
371 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
372
373 SCProductEntryModelImpl scProductEntryModelImpl = (SCProductEntryModelImpl)scProductEntry;
374
375 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_RG_RA,
376 new Object[] {
377 scProductEntryModelImpl.getRepoGroupId(),
378
379 scProductEntryModelImpl.getRepoArtifactId()
380 });
381
382 EntityCacheUtil.removeResult(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
383 SCProductEntryImpl.class, scProductEntry.getPrimaryKey());
384
385 return scProductEntry;
386 }
387
388 @Override
389 public SCProductEntry updateImpl(
390 com.liferay.portlet.softwarecatalog.model.SCProductEntry scProductEntry,
391 boolean merge) throws SystemException {
392 scProductEntry = toUnwrappedModel(scProductEntry);
393
394 boolean isNew = scProductEntry.isNew();
395
396 SCProductEntryModelImpl scProductEntryModelImpl = (SCProductEntryModelImpl)scProductEntry;
397
398 Session session = null;
399
400 try {
401 session = openSession();
402
403 BatchSessionUtil.update(session, scProductEntry, merge);
404
405 scProductEntry.setNew(false);
406 }
407 catch (Exception e) {
408 throw processException(e);
409 }
410 finally {
411 closeSession(session);
412 }
413
414 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
415
416 if (isNew || !SCProductEntryModelImpl.COLUMN_BITMASK_ENABLED) {
417 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
418 }
419
420 else {
421 if ((scProductEntryModelImpl.getColumnBitmask() &
422 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
423 Object[] args = new Object[] {
424 Long.valueOf(scProductEntryModelImpl.getOriginalGroupId())
425 };
426
427 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
428 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
429 args);
430
431 args = new Object[] {
432 Long.valueOf(scProductEntryModelImpl.getGroupId())
433 };
434
435 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
436 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
437 args);
438 }
439
440 if ((scProductEntryModelImpl.getColumnBitmask() &
441 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
442 Object[] args = new Object[] {
443 Long.valueOf(scProductEntryModelImpl.getOriginalCompanyId())
444 };
445
446 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
447 args);
448 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
449 args);
450
451 args = new Object[] {
452 Long.valueOf(scProductEntryModelImpl.getCompanyId())
453 };
454
455 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
456 args);
457 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
458 args);
459 }
460
461 if ((scProductEntryModelImpl.getColumnBitmask() &
462 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U.getColumnBitmask()) != 0) {
463 Object[] args = new Object[] {
464 Long.valueOf(scProductEntryModelImpl.getOriginalGroupId()),
465 Long.valueOf(scProductEntryModelImpl.getOriginalUserId())
466 };
467
468 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U, args);
469 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U,
470 args);
471
472 args = new Object[] {
473 Long.valueOf(scProductEntryModelImpl.getGroupId()),
474 Long.valueOf(scProductEntryModelImpl.getUserId())
475 };
476
477 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U, args);
478 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U,
479 args);
480 }
481 }
482
483 EntityCacheUtil.putResult(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
484 SCProductEntryImpl.class, scProductEntry.getPrimaryKey(),
485 scProductEntry);
486
487 if (isNew) {
488 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_RG_RA,
489 new Object[] {
490 scProductEntry.getRepoGroupId(),
491
492 scProductEntry.getRepoArtifactId()
493 }, scProductEntry);
494 }
495 else {
496 if ((scProductEntryModelImpl.getColumnBitmask() &
497 FINDER_PATH_FETCH_BY_RG_RA.getColumnBitmask()) != 0) {
498 Object[] args = new Object[] {
499 scProductEntryModelImpl.getOriginalRepoGroupId(),
500
501 scProductEntryModelImpl.getOriginalRepoArtifactId()
502 };
503
504 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_RG_RA, args);
505 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_RG_RA, args);
506
507 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_RG_RA,
508 new Object[] {
509 scProductEntry.getRepoGroupId(),
510
511 scProductEntry.getRepoArtifactId()
512 }, scProductEntry);
513 }
514 }
515
516 return scProductEntry;
517 }
518
519 protected SCProductEntry toUnwrappedModel(SCProductEntry scProductEntry) {
520 if (scProductEntry instanceof SCProductEntryImpl) {
521 return scProductEntry;
522 }
523
524 SCProductEntryImpl scProductEntryImpl = new SCProductEntryImpl();
525
526 scProductEntryImpl.setNew(scProductEntry.isNew());
527 scProductEntryImpl.setPrimaryKey(scProductEntry.getPrimaryKey());
528
529 scProductEntryImpl.setProductEntryId(scProductEntry.getProductEntryId());
530 scProductEntryImpl.setGroupId(scProductEntry.getGroupId());
531 scProductEntryImpl.setCompanyId(scProductEntry.getCompanyId());
532 scProductEntryImpl.setUserId(scProductEntry.getUserId());
533 scProductEntryImpl.setUserName(scProductEntry.getUserName());
534 scProductEntryImpl.setCreateDate(scProductEntry.getCreateDate());
535 scProductEntryImpl.setModifiedDate(scProductEntry.getModifiedDate());
536 scProductEntryImpl.setName(scProductEntry.getName());
537 scProductEntryImpl.setType(scProductEntry.getType());
538 scProductEntryImpl.setTags(scProductEntry.getTags());
539 scProductEntryImpl.setShortDescription(scProductEntry.getShortDescription());
540 scProductEntryImpl.setLongDescription(scProductEntry.getLongDescription());
541 scProductEntryImpl.setPageURL(scProductEntry.getPageURL());
542 scProductEntryImpl.setAuthor(scProductEntry.getAuthor());
543 scProductEntryImpl.setRepoGroupId(scProductEntry.getRepoGroupId());
544 scProductEntryImpl.setRepoArtifactId(scProductEntry.getRepoArtifactId());
545
546 return scProductEntryImpl;
547 }
548
549
557 @Override
558 public SCProductEntry findByPrimaryKey(Serializable primaryKey)
559 throws NoSuchModelException, SystemException {
560 return findByPrimaryKey(((Long)primaryKey).longValue());
561 }
562
563
571 public SCProductEntry findByPrimaryKey(long productEntryId)
572 throws NoSuchProductEntryException, SystemException {
573 SCProductEntry scProductEntry = fetchByPrimaryKey(productEntryId);
574
575 if (scProductEntry == null) {
576 if (_log.isWarnEnabled()) {
577 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + productEntryId);
578 }
579
580 throw new NoSuchProductEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
581 productEntryId);
582 }
583
584 return scProductEntry;
585 }
586
587
594 @Override
595 public SCProductEntry fetchByPrimaryKey(Serializable primaryKey)
596 throws SystemException {
597 return fetchByPrimaryKey(((Long)primaryKey).longValue());
598 }
599
600
607 public SCProductEntry fetchByPrimaryKey(long productEntryId)
608 throws SystemException {
609 SCProductEntry scProductEntry = (SCProductEntry)EntityCacheUtil.getResult(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
610 SCProductEntryImpl.class, productEntryId);
611
612 if (scProductEntry == _nullSCProductEntry) {
613 return null;
614 }
615
616 if (scProductEntry == null) {
617 Session session = null;
618
619 boolean hasException = false;
620
621 try {
622 session = openSession();
623
624 scProductEntry = (SCProductEntry)session.get(SCProductEntryImpl.class,
625 Long.valueOf(productEntryId));
626 }
627 catch (Exception e) {
628 hasException = true;
629
630 throw processException(e);
631 }
632 finally {
633 if (scProductEntry != null) {
634 cacheResult(scProductEntry);
635 }
636 else if (!hasException) {
637 EntityCacheUtil.putResult(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
638 SCProductEntryImpl.class, productEntryId,
639 _nullSCProductEntry);
640 }
641
642 closeSession(session);
643 }
644 }
645
646 return scProductEntry;
647 }
648
649
656 public List<SCProductEntry> findByGroupId(long groupId)
657 throws SystemException {
658 return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
659 }
660
661
674 public List<SCProductEntry> findByGroupId(long groupId, int start, int end)
675 throws SystemException {
676 return findByGroupId(groupId, start, end, null);
677 }
678
679
693 public List<SCProductEntry> findByGroupId(long groupId, int start, int end,
694 OrderByComparator orderByComparator) throws SystemException {
695 FinderPath finderPath = null;
696 Object[] finderArgs = null;
697
698 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
699 (orderByComparator == null)) {
700 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
701 finderArgs = new Object[] { groupId };
702 }
703 else {
704 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
705 finderArgs = new Object[] { groupId, start, end, orderByComparator };
706 }
707
708 List<SCProductEntry> list = (List<SCProductEntry>)FinderCacheUtil.getResult(finderPath,
709 finderArgs, this);
710
711 if (list == null) {
712 StringBundler query = null;
713
714 if (orderByComparator != null) {
715 query = new StringBundler(3 +
716 (orderByComparator.getOrderByFields().length * 3));
717 }
718 else {
719 query = new StringBundler(3);
720 }
721
722 query.append(_SQL_SELECT_SCPRODUCTENTRY_WHERE);
723
724 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
725
726 if (orderByComparator != null) {
727 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
728 orderByComparator);
729 }
730
731 else {
732 query.append(SCProductEntryModelImpl.ORDER_BY_JPQL);
733 }
734
735 String sql = query.toString();
736
737 Session session = null;
738
739 try {
740 session = openSession();
741
742 Query q = session.createQuery(sql);
743
744 QueryPos qPos = QueryPos.getInstance(q);
745
746 qPos.add(groupId);
747
748 list = (List<SCProductEntry>)QueryUtil.list(q, getDialect(),
749 start, end);
750 }
751 catch (Exception e) {
752 throw processException(e);
753 }
754 finally {
755 if (list == null) {
756 FinderCacheUtil.removeResult(finderPath, finderArgs);
757 }
758 else {
759 cacheResult(list);
760
761 FinderCacheUtil.putResult(finderPath, finderArgs, list);
762 }
763
764 closeSession(session);
765 }
766 }
767
768 return list;
769 }
770
771
784 public SCProductEntry findByGroupId_First(long groupId,
785 OrderByComparator orderByComparator)
786 throws NoSuchProductEntryException, SystemException {
787 List<SCProductEntry> list = findByGroupId(groupId, 0, 1,
788 orderByComparator);
789
790 if (list.isEmpty()) {
791 StringBundler msg = new StringBundler(4);
792
793 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
794
795 msg.append("groupId=");
796 msg.append(groupId);
797
798 msg.append(StringPool.CLOSE_CURLY_BRACE);
799
800 throw new NoSuchProductEntryException(msg.toString());
801 }
802 else {
803 return list.get(0);
804 }
805 }
806
807
820 public SCProductEntry findByGroupId_Last(long groupId,
821 OrderByComparator orderByComparator)
822 throws NoSuchProductEntryException, SystemException {
823 int count = countByGroupId(groupId);
824
825 List<SCProductEntry> list = findByGroupId(groupId, count - 1, count,
826 orderByComparator);
827
828 if (list.isEmpty()) {
829 StringBundler msg = new StringBundler(4);
830
831 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
832
833 msg.append("groupId=");
834 msg.append(groupId);
835
836 msg.append(StringPool.CLOSE_CURLY_BRACE);
837
838 throw new NoSuchProductEntryException(msg.toString());
839 }
840 else {
841 return list.get(0);
842 }
843 }
844
845
859 public SCProductEntry[] findByGroupId_PrevAndNext(long productEntryId,
860 long groupId, OrderByComparator orderByComparator)
861 throws NoSuchProductEntryException, SystemException {
862 SCProductEntry scProductEntry = findByPrimaryKey(productEntryId);
863
864 Session session = null;
865
866 try {
867 session = openSession();
868
869 SCProductEntry[] array = new SCProductEntryImpl[3];
870
871 array[0] = getByGroupId_PrevAndNext(session, scProductEntry,
872 groupId, orderByComparator, true);
873
874 array[1] = scProductEntry;
875
876 array[2] = getByGroupId_PrevAndNext(session, scProductEntry,
877 groupId, orderByComparator, false);
878
879 return array;
880 }
881 catch (Exception e) {
882 throw processException(e);
883 }
884 finally {
885 closeSession(session);
886 }
887 }
888
889 protected SCProductEntry getByGroupId_PrevAndNext(Session session,
890 SCProductEntry scProductEntry, long groupId,
891 OrderByComparator orderByComparator, boolean previous) {
892 StringBundler query = null;
893
894 if (orderByComparator != null) {
895 query = new StringBundler(6 +
896 (orderByComparator.getOrderByFields().length * 6));
897 }
898 else {
899 query = new StringBundler(3);
900 }
901
902 query.append(_SQL_SELECT_SCPRODUCTENTRY_WHERE);
903
904 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
905
906 if (orderByComparator != null) {
907 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
908
909 if (orderByConditionFields.length > 0) {
910 query.append(WHERE_AND);
911 }
912
913 for (int i = 0; i < orderByConditionFields.length; i++) {
914 query.append(_ORDER_BY_ENTITY_ALIAS);
915 query.append(orderByConditionFields[i]);
916
917 if ((i + 1) < orderByConditionFields.length) {
918 if (orderByComparator.isAscending() ^ previous) {
919 query.append(WHERE_GREATER_THAN_HAS_NEXT);
920 }
921 else {
922 query.append(WHERE_LESSER_THAN_HAS_NEXT);
923 }
924 }
925 else {
926 if (orderByComparator.isAscending() ^ previous) {
927 query.append(WHERE_GREATER_THAN);
928 }
929 else {
930 query.append(WHERE_LESSER_THAN);
931 }
932 }
933 }
934
935 query.append(ORDER_BY_CLAUSE);
936
937 String[] orderByFields = orderByComparator.getOrderByFields();
938
939 for (int i = 0; i < orderByFields.length; i++) {
940 query.append(_ORDER_BY_ENTITY_ALIAS);
941 query.append(orderByFields[i]);
942
943 if ((i + 1) < orderByFields.length) {
944 if (orderByComparator.isAscending() ^ previous) {
945 query.append(ORDER_BY_ASC_HAS_NEXT);
946 }
947 else {
948 query.append(ORDER_BY_DESC_HAS_NEXT);
949 }
950 }
951 else {
952 if (orderByComparator.isAscending() ^ previous) {
953 query.append(ORDER_BY_ASC);
954 }
955 else {
956 query.append(ORDER_BY_DESC);
957 }
958 }
959 }
960 }
961
962 else {
963 query.append(SCProductEntryModelImpl.ORDER_BY_JPQL);
964 }
965
966 String sql = query.toString();
967
968 Query q = session.createQuery(sql);
969
970 q.setFirstResult(0);
971 q.setMaxResults(2);
972
973 QueryPos qPos = QueryPos.getInstance(q);
974
975 qPos.add(groupId);
976
977 if (orderByComparator != null) {
978 Object[] values = orderByComparator.getOrderByConditionValues(scProductEntry);
979
980 for (Object value : values) {
981 qPos.add(value);
982 }
983 }
984
985 List<SCProductEntry> list = q.list();
986
987 if (list.size() == 2) {
988 return list.get(1);
989 }
990 else {
991 return null;
992 }
993 }
994
995
1002 public List<SCProductEntry> filterFindByGroupId(long groupId)
1003 throws SystemException {
1004 return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
1005 QueryUtil.ALL_POS, null);
1006 }
1007
1008
1021 public List<SCProductEntry> filterFindByGroupId(long groupId, int start,
1022 int end) throws SystemException {
1023 return filterFindByGroupId(groupId, start, end, null);
1024 }
1025
1026
1040 public List<SCProductEntry> filterFindByGroupId(long groupId, int start,
1041 int end, OrderByComparator orderByComparator) throws SystemException {
1042 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1043 return findByGroupId(groupId, start, end, orderByComparator);
1044 }
1045
1046 StringBundler query = null;
1047
1048 if (orderByComparator != null) {
1049 query = new StringBundler(3 +
1050 (orderByComparator.getOrderByFields().length * 3));
1051 }
1052 else {
1053 query = new StringBundler(3);
1054 }
1055
1056 if (getDB().isSupportsInlineDistinct()) {
1057 query.append(_FILTER_SQL_SELECT_SCPRODUCTENTRY_WHERE);
1058 }
1059 else {
1060 query.append(_FILTER_SQL_SELECT_SCPRODUCTENTRY_NO_INLINE_DISTINCT_WHERE_1);
1061 }
1062
1063 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1064
1065 if (!getDB().isSupportsInlineDistinct()) {
1066 query.append(_FILTER_SQL_SELECT_SCPRODUCTENTRY_NO_INLINE_DISTINCT_WHERE_2);
1067 }
1068
1069 if (orderByComparator != null) {
1070 if (getDB().isSupportsInlineDistinct()) {
1071 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1072 orderByComparator);
1073 }
1074 else {
1075 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
1076 orderByComparator);
1077 }
1078 }
1079
1080 else {
1081 if (getDB().isSupportsInlineDistinct()) {
1082 query.append(SCProductEntryModelImpl.ORDER_BY_JPQL);
1083 }
1084 else {
1085 query.append(SCProductEntryModelImpl.ORDER_BY_SQL);
1086 }
1087 }
1088
1089 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1090 SCProductEntry.class.getName(),
1091 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
1092
1093 Session session = null;
1094
1095 try {
1096 session = openSession();
1097
1098 SQLQuery q = session.createSQLQuery(sql);
1099
1100 if (getDB().isSupportsInlineDistinct()) {
1101 q.addEntity(_FILTER_ENTITY_ALIAS, SCProductEntryImpl.class);
1102 }
1103 else {
1104 q.addEntity(_FILTER_ENTITY_TABLE, SCProductEntryImpl.class);
1105 }
1106
1107 QueryPos qPos = QueryPos.getInstance(q);
1108
1109 qPos.add(groupId);
1110
1111 return (List<SCProductEntry>)QueryUtil.list(q, getDialect(), start,
1112 end);
1113 }
1114 catch (Exception e) {
1115 throw processException(e);
1116 }
1117 finally {
1118 closeSession(session);
1119 }
1120 }
1121
1122
1132 public SCProductEntry[] filterFindByGroupId_PrevAndNext(
1133 long productEntryId, long groupId, OrderByComparator orderByComparator)
1134 throws NoSuchProductEntryException, SystemException {
1135 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1136 return findByGroupId_PrevAndNext(productEntryId, groupId,
1137 orderByComparator);
1138 }
1139
1140 SCProductEntry scProductEntry = findByPrimaryKey(productEntryId);
1141
1142 Session session = null;
1143
1144 try {
1145 session = openSession();
1146
1147 SCProductEntry[] array = new SCProductEntryImpl[3];
1148
1149 array[0] = filterGetByGroupId_PrevAndNext(session, scProductEntry,
1150 groupId, orderByComparator, true);
1151
1152 array[1] = scProductEntry;
1153
1154 array[2] = filterGetByGroupId_PrevAndNext(session, scProductEntry,
1155 groupId, orderByComparator, false);
1156
1157 return array;
1158 }
1159 catch (Exception e) {
1160 throw processException(e);
1161 }
1162 finally {
1163 closeSession(session);
1164 }
1165 }
1166
1167 protected SCProductEntry filterGetByGroupId_PrevAndNext(Session session,
1168 SCProductEntry scProductEntry, long groupId,
1169 OrderByComparator orderByComparator, boolean previous) {
1170 StringBundler query = null;
1171
1172 if (orderByComparator != null) {
1173 query = new StringBundler(6 +
1174 (orderByComparator.getOrderByFields().length * 6));
1175 }
1176 else {
1177 query = new StringBundler(3);
1178 }
1179
1180 if (getDB().isSupportsInlineDistinct()) {
1181 query.append(_FILTER_SQL_SELECT_SCPRODUCTENTRY_WHERE);
1182 }
1183 else {
1184 query.append(_FILTER_SQL_SELECT_SCPRODUCTENTRY_NO_INLINE_DISTINCT_WHERE_1);
1185 }
1186
1187 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1188
1189 if (!getDB().isSupportsInlineDistinct()) {
1190 query.append(_FILTER_SQL_SELECT_SCPRODUCTENTRY_NO_INLINE_DISTINCT_WHERE_2);
1191 }
1192
1193 if (orderByComparator != null) {
1194 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1195
1196 if (orderByConditionFields.length > 0) {
1197 query.append(WHERE_AND);
1198 }
1199
1200 for (int i = 0; i < orderByConditionFields.length; i++) {
1201 if (getDB().isSupportsInlineDistinct()) {
1202 query.append(_ORDER_BY_ENTITY_ALIAS);
1203 }
1204 else {
1205 query.append(_ORDER_BY_ENTITY_TABLE);
1206 }
1207
1208 query.append(orderByConditionFields[i]);
1209
1210 if ((i + 1) < orderByConditionFields.length) {
1211 if (orderByComparator.isAscending() ^ previous) {
1212 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1213 }
1214 else {
1215 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1216 }
1217 }
1218 else {
1219 if (orderByComparator.isAscending() ^ previous) {
1220 query.append(WHERE_GREATER_THAN);
1221 }
1222 else {
1223 query.append(WHERE_LESSER_THAN);
1224 }
1225 }
1226 }
1227
1228 query.append(ORDER_BY_CLAUSE);
1229
1230 String[] orderByFields = orderByComparator.getOrderByFields();
1231
1232 for (int i = 0; i < orderByFields.length; i++) {
1233 if (getDB().isSupportsInlineDistinct()) {
1234 query.append(_ORDER_BY_ENTITY_ALIAS);
1235 }
1236 else {
1237 query.append(_ORDER_BY_ENTITY_TABLE);
1238 }
1239
1240 query.append(orderByFields[i]);
1241
1242 if ((i + 1) < orderByFields.length) {
1243 if (orderByComparator.isAscending() ^ previous) {
1244 query.append(ORDER_BY_ASC_HAS_NEXT);
1245 }
1246 else {
1247 query.append(ORDER_BY_DESC_HAS_NEXT);
1248 }
1249 }
1250 else {
1251 if (orderByComparator.isAscending() ^ previous) {
1252 query.append(ORDER_BY_ASC);
1253 }
1254 else {
1255 query.append(ORDER_BY_DESC);
1256 }
1257 }
1258 }
1259 }
1260
1261 else {
1262 if (getDB().isSupportsInlineDistinct()) {
1263 query.append(SCProductEntryModelImpl.ORDER_BY_JPQL);
1264 }
1265 else {
1266 query.append(SCProductEntryModelImpl.ORDER_BY_SQL);
1267 }
1268 }
1269
1270 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1271 SCProductEntry.class.getName(),
1272 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
1273
1274 SQLQuery q = session.createSQLQuery(sql);
1275
1276 q.setFirstResult(0);
1277 q.setMaxResults(2);
1278
1279 if (getDB().isSupportsInlineDistinct()) {
1280 q.addEntity(_FILTER_ENTITY_ALIAS, SCProductEntryImpl.class);
1281 }
1282 else {
1283 q.addEntity(_FILTER_ENTITY_TABLE, SCProductEntryImpl.class);
1284 }
1285
1286 QueryPos qPos = QueryPos.getInstance(q);
1287
1288 qPos.add(groupId);
1289
1290 if (orderByComparator != null) {
1291 Object[] values = orderByComparator.getOrderByConditionValues(scProductEntry);
1292
1293 for (Object value : values) {
1294 qPos.add(value);
1295 }
1296 }
1297
1298 List<SCProductEntry> list = q.list();
1299
1300 if (list.size() == 2) {
1301 return list.get(1);
1302 }
1303 else {
1304 return null;
1305 }
1306 }
1307
1308
1315 public List<SCProductEntry> findByCompanyId(long companyId)
1316 throws SystemException {
1317 return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
1318 null);
1319 }
1320
1321
1334 public List<SCProductEntry> findByCompanyId(long companyId, int start,
1335 int end) throws SystemException {
1336 return findByCompanyId(companyId, start, end, null);
1337 }
1338
1339
1353 public List<SCProductEntry> findByCompanyId(long companyId, int start,
1354 int end, OrderByComparator orderByComparator) throws SystemException {
1355 FinderPath finderPath = null;
1356 Object[] finderArgs = null;
1357
1358 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1359 (orderByComparator == null)) {
1360 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID;
1361 finderArgs = new Object[] { companyId };
1362 }
1363 else {
1364 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID;
1365 finderArgs = new Object[] { companyId, start, end, orderByComparator };
1366 }
1367
1368 List<SCProductEntry> list = (List<SCProductEntry>)FinderCacheUtil.getResult(finderPath,
1369 finderArgs, this);
1370
1371 if (list == null) {
1372 StringBundler query = null;
1373
1374 if (orderByComparator != null) {
1375 query = new StringBundler(3 +
1376 (orderByComparator.getOrderByFields().length * 3));
1377 }
1378 else {
1379 query = new StringBundler(3);
1380 }
1381
1382 query.append(_SQL_SELECT_SCPRODUCTENTRY_WHERE);
1383
1384 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1385
1386 if (orderByComparator != null) {
1387 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1388 orderByComparator);
1389 }
1390
1391 else {
1392 query.append(SCProductEntryModelImpl.ORDER_BY_JPQL);
1393 }
1394
1395 String sql = query.toString();
1396
1397 Session session = null;
1398
1399 try {
1400 session = openSession();
1401
1402 Query q = session.createQuery(sql);
1403
1404 QueryPos qPos = QueryPos.getInstance(q);
1405
1406 qPos.add(companyId);
1407
1408 list = (List<SCProductEntry>)QueryUtil.list(q, getDialect(),
1409 start, end);
1410 }
1411 catch (Exception e) {
1412 throw processException(e);
1413 }
1414 finally {
1415 if (list == null) {
1416 FinderCacheUtil.removeResult(finderPath, finderArgs);
1417 }
1418 else {
1419 cacheResult(list);
1420
1421 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1422 }
1423
1424 closeSession(session);
1425 }
1426 }
1427
1428 return list;
1429 }
1430
1431
1444 public SCProductEntry findByCompanyId_First(long companyId,
1445 OrderByComparator orderByComparator)
1446 throws NoSuchProductEntryException, SystemException {
1447 List<SCProductEntry> list = findByCompanyId(companyId, 0, 1,
1448 orderByComparator);
1449
1450 if (list.isEmpty()) {
1451 StringBundler msg = new StringBundler(4);
1452
1453 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1454
1455 msg.append("companyId=");
1456 msg.append(companyId);
1457
1458 msg.append(StringPool.CLOSE_CURLY_BRACE);
1459
1460 throw new NoSuchProductEntryException(msg.toString());
1461 }
1462 else {
1463 return list.get(0);
1464 }
1465 }
1466
1467
1480 public SCProductEntry findByCompanyId_Last(long companyId,
1481 OrderByComparator orderByComparator)
1482 throws NoSuchProductEntryException, SystemException {
1483 int count = countByCompanyId(companyId);
1484
1485 List<SCProductEntry> list = findByCompanyId(companyId, count - 1,
1486 count, orderByComparator);
1487
1488 if (list.isEmpty()) {
1489 StringBundler msg = new StringBundler(4);
1490
1491 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1492
1493 msg.append("companyId=");
1494 msg.append(companyId);
1495
1496 msg.append(StringPool.CLOSE_CURLY_BRACE);
1497
1498 throw new NoSuchProductEntryException(msg.toString());
1499 }
1500 else {
1501 return list.get(0);
1502 }
1503 }
1504
1505
1519 public SCProductEntry[] findByCompanyId_PrevAndNext(long productEntryId,
1520 long companyId, OrderByComparator orderByComparator)
1521 throws NoSuchProductEntryException, SystemException {
1522 SCProductEntry scProductEntry = findByPrimaryKey(productEntryId);
1523
1524 Session session = null;
1525
1526 try {
1527 session = openSession();
1528
1529 SCProductEntry[] array = new SCProductEntryImpl[3];
1530
1531 array[0] = getByCompanyId_PrevAndNext(session, scProductEntry,
1532 companyId, orderByComparator, true);
1533
1534 array[1] = scProductEntry;
1535
1536 array[2] = getByCompanyId_PrevAndNext(session, scProductEntry,
1537 companyId, orderByComparator, false);
1538
1539 return array;
1540 }
1541 catch (Exception e) {
1542 throw processException(e);
1543 }
1544 finally {
1545 closeSession(session);
1546 }
1547 }
1548
1549 protected SCProductEntry getByCompanyId_PrevAndNext(Session session,
1550 SCProductEntry scProductEntry, long companyId,
1551 OrderByComparator orderByComparator, boolean previous) {
1552 StringBundler query = null;
1553
1554 if (orderByComparator != null) {
1555 query = new StringBundler(6 +
1556 (orderByComparator.getOrderByFields().length * 6));
1557 }
1558 else {
1559 query = new StringBundler(3);
1560 }
1561
1562 query.append(_SQL_SELECT_SCPRODUCTENTRY_WHERE);
1563
1564 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1565
1566 if (orderByComparator != null) {
1567 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1568
1569 if (orderByConditionFields.length > 0) {
1570 query.append(WHERE_AND);
1571 }
1572
1573 for (int i = 0; i < orderByConditionFields.length; i++) {
1574 query.append(_ORDER_BY_ENTITY_ALIAS);
1575 query.append(orderByConditionFields[i]);
1576
1577 if ((i + 1) < orderByConditionFields.length) {
1578 if (orderByComparator.isAscending() ^ previous) {
1579 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1580 }
1581 else {
1582 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1583 }
1584 }
1585 else {
1586 if (orderByComparator.isAscending() ^ previous) {
1587 query.append(WHERE_GREATER_THAN);
1588 }
1589 else {
1590 query.append(WHERE_LESSER_THAN);
1591 }
1592 }
1593 }
1594
1595 query.append(ORDER_BY_CLAUSE);
1596
1597 String[] orderByFields = orderByComparator.getOrderByFields();
1598
1599 for (int i = 0; i < orderByFields.length; i++) {
1600 query.append(_ORDER_BY_ENTITY_ALIAS);
1601 query.append(orderByFields[i]);
1602
1603 if ((i + 1) < orderByFields.length) {
1604 if (orderByComparator.isAscending() ^ previous) {
1605 query.append(ORDER_BY_ASC_HAS_NEXT);
1606 }
1607 else {
1608 query.append(ORDER_BY_DESC_HAS_NEXT);
1609 }
1610 }
1611 else {
1612 if (orderByComparator.isAscending() ^ previous) {
1613 query.append(ORDER_BY_ASC);
1614 }
1615 else {
1616 query.append(ORDER_BY_DESC);
1617 }
1618 }
1619 }
1620 }
1621
1622 else {
1623 query.append(SCProductEntryModelImpl.ORDER_BY_JPQL);
1624 }
1625
1626 String sql = query.toString();
1627
1628 Query q = session.createQuery(sql);
1629
1630 q.setFirstResult(0);
1631 q.setMaxResults(2);
1632
1633 QueryPos qPos = QueryPos.getInstance(q);
1634
1635 qPos.add(companyId);
1636
1637 if (orderByComparator != null) {
1638 Object[] values = orderByComparator.getOrderByConditionValues(scProductEntry);
1639
1640 for (Object value : values) {
1641 qPos.add(value);
1642 }
1643 }
1644
1645 List<SCProductEntry> list = q.list();
1646
1647 if (list.size() == 2) {
1648 return list.get(1);
1649 }
1650 else {
1651 return null;
1652 }
1653 }
1654
1655
1663 public List<SCProductEntry> findByG_U(long groupId, long userId)
1664 throws SystemException {
1665 return findByG_U(groupId, userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
1666 null);
1667 }
1668
1669
1683 public List<SCProductEntry> findByG_U(long groupId, long userId, int start,
1684 int end) throws SystemException {
1685 return findByG_U(groupId, userId, start, end, null);
1686 }
1687
1688
1703 public List<SCProductEntry> findByG_U(long groupId, long userId, int start,
1704 int end, OrderByComparator orderByComparator) throws SystemException {
1705 FinderPath finderPath = null;
1706 Object[] finderArgs = null;
1707
1708 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1709 (orderByComparator == null)) {
1710 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U;
1711 finderArgs = new Object[] { groupId, userId };
1712 }
1713 else {
1714 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U;
1715 finderArgs = new Object[] {
1716 groupId, userId,
1717
1718 start, end, orderByComparator
1719 };
1720 }
1721
1722 List<SCProductEntry> list = (List<SCProductEntry>)FinderCacheUtil.getResult(finderPath,
1723 finderArgs, this);
1724
1725 if (list == null) {
1726 StringBundler query = null;
1727
1728 if (orderByComparator != null) {
1729 query = new StringBundler(4 +
1730 (orderByComparator.getOrderByFields().length * 3));
1731 }
1732 else {
1733 query = new StringBundler(4);
1734 }
1735
1736 query.append(_SQL_SELECT_SCPRODUCTENTRY_WHERE);
1737
1738 query.append(_FINDER_COLUMN_G_U_GROUPID_2);
1739
1740 query.append(_FINDER_COLUMN_G_U_USERID_2);
1741
1742 if (orderByComparator != null) {
1743 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1744 orderByComparator);
1745 }
1746
1747 else {
1748 query.append(SCProductEntryModelImpl.ORDER_BY_JPQL);
1749 }
1750
1751 String sql = query.toString();
1752
1753 Session session = null;
1754
1755 try {
1756 session = openSession();
1757
1758 Query q = session.createQuery(sql);
1759
1760 QueryPos qPos = QueryPos.getInstance(q);
1761
1762 qPos.add(groupId);
1763
1764 qPos.add(userId);
1765
1766 list = (List<SCProductEntry>)QueryUtil.list(q, getDialect(),
1767 start, end);
1768 }
1769 catch (Exception e) {
1770 throw processException(e);
1771 }
1772 finally {
1773 if (list == null) {
1774 FinderCacheUtil.removeResult(finderPath, finderArgs);
1775 }
1776 else {
1777 cacheResult(list);
1778
1779 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1780 }
1781
1782 closeSession(session);
1783 }
1784 }
1785
1786 return list;
1787 }
1788
1789
1803 public SCProductEntry findByG_U_First(long groupId, long userId,
1804 OrderByComparator orderByComparator)
1805 throws NoSuchProductEntryException, SystemException {
1806 List<SCProductEntry> list = findByG_U(groupId, userId, 0, 1,
1807 orderByComparator);
1808
1809 if (list.isEmpty()) {
1810 StringBundler msg = new StringBundler(6);
1811
1812 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1813
1814 msg.append("groupId=");
1815 msg.append(groupId);
1816
1817 msg.append(", userId=");
1818 msg.append(userId);
1819
1820 msg.append(StringPool.CLOSE_CURLY_BRACE);
1821
1822 throw new NoSuchProductEntryException(msg.toString());
1823 }
1824 else {
1825 return list.get(0);
1826 }
1827 }
1828
1829
1843 public SCProductEntry findByG_U_Last(long groupId, long userId,
1844 OrderByComparator orderByComparator)
1845 throws NoSuchProductEntryException, SystemException {
1846 int count = countByG_U(groupId, userId);
1847
1848 List<SCProductEntry> list = findByG_U(groupId, userId, count - 1,
1849 count, orderByComparator);
1850
1851 if (list.isEmpty()) {
1852 StringBundler msg = new StringBundler(6);
1853
1854 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1855
1856 msg.append("groupId=");
1857 msg.append(groupId);
1858
1859 msg.append(", userId=");
1860 msg.append(userId);
1861
1862 msg.append(StringPool.CLOSE_CURLY_BRACE);
1863
1864 throw new NoSuchProductEntryException(msg.toString());
1865 }
1866 else {
1867 return list.get(0);
1868 }
1869 }
1870
1871
1886 public SCProductEntry[] findByG_U_PrevAndNext(long productEntryId,
1887 long groupId, long userId, OrderByComparator orderByComparator)
1888 throws NoSuchProductEntryException, SystemException {
1889 SCProductEntry scProductEntry = findByPrimaryKey(productEntryId);
1890
1891 Session session = null;
1892
1893 try {
1894 session = openSession();
1895
1896 SCProductEntry[] array = new SCProductEntryImpl[3];
1897
1898 array[0] = getByG_U_PrevAndNext(session, scProductEntry, groupId,
1899 userId, orderByComparator, true);
1900
1901 array[1] = scProductEntry;
1902
1903 array[2] = getByG_U_PrevAndNext(session, scProductEntry, groupId,
1904 userId, orderByComparator, false);
1905
1906 return array;
1907 }
1908 catch (Exception e) {
1909 throw processException(e);
1910 }
1911 finally {
1912 closeSession(session);
1913 }
1914 }
1915
1916 protected SCProductEntry getByG_U_PrevAndNext(Session session,
1917 SCProductEntry scProductEntry, long groupId, long userId,
1918 OrderByComparator orderByComparator, boolean previous) {
1919 StringBundler query = null;
1920
1921 if (orderByComparator != null) {
1922 query = new StringBundler(6 +
1923 (orderByComparator.getOrderByFields().length * 6));
1924 }
1925 else {
1926 query = new StringBundler(3);
1927 }
1928
1929 query.append(_SQL_SELECT_SCPRODUCTENTRY_WHERE);
1930
1931 query.append(_FINDER_COLUMN_G_U_GROUPID_2);
1932
1933 query.append(_FINDER_COLUMN_G_U_USERID_2);
1934
1935 if (orderByComparator != null) {
1936 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1937
1938 if (orderByConditionFields.length > 0) {
1939 query.append(WHERE_AND);
1940 }
1941
1942 for (int i = 0; i < orderByConditionFields.length; i++) {
1943 query.append(_ORDER_BY_ENTITY_ALIAS);
1944 query.append(orderByConditionFields[i]);
1945
1946 if ((i + 1) < orderByConditionFields.length) {
1947 if (orderByComparator.isAscending() ^ previous) {
1948 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1949 }
1950 else {
1951 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1952 }
1953 }
1954 else {
1955 if (orderByComparator.isAscending() ^ previous) {
1956 query.append(WHERE_GREATER_THAN);
1957 }
1958 else {
1959 query.append(WHERE_LESSER_THAN);
1960 }
1961 }
1962 }
1963
1964 query.append(ORDER_BY_CLAUSE);
1965
1966 String[] orderByFields = orderByComparator.getOrderByFields();
1967
1968 for (int i = 0; i < orderByFields.length; i++) {
1969 query.append(_ORDER_BY_ENTITY_ALIAS);
1970 query.append(orderByFields[i]);
1971
1972 if ((i + 1) < orderByFields.length) {
1973 if (orderByComparator.isAscending() ^ previous) {
1974 query.append(ORDER_BY_ASC_HAS_NEXT);
1975 }
1976 else {
1977 query.append(ORDER_BY_DESC_HAS_NEXT);
1978 }
1979 }
1980 else {
1981 if (orderByComparator.isAscending() ^ previous) {
1982 query.append(ORDER_BY_ASC);
1983 }
1984 else {
1985 query.append(ORDER_BY_DESC);
1986 }
1987 }
1988 }
1989 }
1990
1991 else {
1992 query.append(SCProductEntryModelImpl.ORDER_BY_JPQL);
1993 }
1994
1995 String sql = query.toString();
1996
1997 Query q = session.createQuery(sql);
1998
1999 q.setFirstResult(0);
2000 q.setMaxResults(2);
2001
2002 QueryPos qPos = QueryPos.getInstance(q);
2003
2004 qPos.add(groupId);
2005
2006 qPos.add(userId);
2007
2008 if (orderByComparator != null) {
2009 Object[] values = orderByComparator.getOrderByConditionValues(scProductEntry);
2010
2011 for (Object value : values) {
2012 qPos.add(value);
2013 }
2014 }
2015
2016 List<SCProductEntry> list = q.list();
2017
2018 if (list.size() == 2) {
2019 return list.get(1);
2020 }
2021 else {
2022 return null;
2023 }
2024 }
2025
2026
2034 public List<SCProductEntry> filterFindByG_U(long groupId, long userId)
2035 throws SystemException {
2036 return filterFindByG_U(groupId, userId, QueryUtil.ALL_POS,
2037 QueryUtil.ALL_POS, null);
2038 }
2039
2040
2054 public List<SCProductEntry> filterFindByG_U(long groupId, long userId,
2055 int start, int end) throws SystemException {
2056 return filterFindByG_U(groupId, userId, start, end, null);
2057 }
2058
2059
2074 public List<SCProductEntry> filterFindByG_U(long groupId, long userId,
2075 int start, int end, OrderByComparator orderByComparator)
2076 throws SystemException {
2077 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2078 return findByG_U(groupId, userId, start, end, orderByComparator);
2079 }
2080
2081 StringBundler query = null;
2082
2083 if (orderByComparator != null) {
2084 query = new StringBundler(4 +
2085 (orderByComparator.getOrderByFields().length * 3));
2086 }
2087 else {
2088 query = new StringBundler(4);
2089 }
2090
2091 if (getDB().isSupportsInlineDistinct()) {
2092 query.append(_FILTER_SQL_SELECT_SCPRODUCTENTRY_WHERE);
2093 }
2094 else {
2095 query.append(_FILTER_SQL_SELECT_SCPRODUCTENTRY_NO_INLINE_DISTINCT_WHERE_1);
2096 }
2097
2098 query.append(_FINDER_COLUMN_G_U_GROUPID_2);
2099
2100 query.append(_FINDER_COLUMN_G_U_USERID_2);
2101
2102 if (!getDB().isSupportsInlineDistinct()) {
2103 query.append(_FILTER_SQL_SELECT_SCPRODUCTENTRY_NO_INLINE_DISTINCT_WHERE_2);
2104 }
2105
2106 if (orderByComparator != null) {
2107 if (getDB().isSupportsInlineDistinct()) {
2108 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2109 orderByComparator);
2110 }
2111 else {
2112 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
2113 orderByComparator);
2114 }
2115 }
2116
2117 else {
2118 if (getDB().isSupportsInlineDistinct()) {
2119 query.append(SCProductEntryModelImpl.ORDER_BY_JPQL);
2120 }
2121 else {
2122 query.append(SCProductEntryModelImpl.ORDER_BY_SQL);
2123 }
2124 }
2125
2126 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2127 SCProductEntry.class.getName(),
2128 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2129
2130 Session session = null;
2131
2132 try {
2133 session = openSession();
2134
2135 SQLQuery q = session.createSQLQuery(sql);
2136
2137 if (getDB().isSupportsInlineDistinct()) {
2138 q.addEntity(_FILTER_ENTITY_ALIAS, SCProductEntryImpl.class);
2139 }
2140 else {
2141 q.addEntity(_FILTER_ENTITY_TABLE, SCProductEntryImpl.class);
2142 }
2143
2144 QueryPos qPos = QueryPos.getInstance(q);
2145
2146 qPos.add(groupId);
2147
2148 qPos.add(userId);
2149
2150 return (List<SCProductEntry>)QueryUtil.list(q, getDialect(), start,
2151 end);
2152 }
2153 catch (Exception e) {
2154 throw processException(e);
2155 }
2156 finally {
2157 closeSession(session);
2158 }
2159 }
2160
2161
2172 public SCProductEntry[] filterFindByG_U_PrevAndNext(long productEntryId,
2173 long groupId, long userId, OrderByComparator orderByComparator)
2174 throws NoSuchProductEntryException, SystemException {
2175 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2176 return findByG_U_PrevAndNext(productEntryId, groupId, userId,
2177 orderByComparator);
2178 }
2179
2180 SCProductEntry scProductEntry = findByPrimaryKey(productEntryId);
2181
2182 Session session = null;
2183
2184 try {
2185 session = openSession();
2186
2187 SCProductEntry[] array = new SCProductEntryImpl[3];
2188
2189 array[0] = filterGetByG_U_PrevAndNext(session, scProductEntry,
2190 groupId, userId, orderByComparator, true);
2191
2192 array[1] = scProductEntry;
2193
2194 array[2] = filterGetByG_U_PrevAndNext(session, scProductEntry,
2195 groupId, userId, orderByComparator, false);
2196
2197 return array;
2198 }
2199 catch (Exception e) {
2200 throw processException(e);
2201 }
2202 finally {
2203 closeSession(session);
2204 }
2205 }
2206
2207 protected SCProductEntry filterGetByG_U_PrevAndNext(Session session,
2208 SCProductEntry scProductEntry, long groupId, long userId,
2209 OrderByComparator orderByComparator, boolean previous) {
2210 StringBundler query = null;
2211
2212 if (orderByComparator != null) {
2213 query = new StringBundler(6 +
2214 (orderByComparator.getOrderByFields().length * 6));
2215 }
2216 else {
2217 query = new StringBundler(3);
2218 }
2219
2220 if (getDB().isSupportsInlineDistinct()) {
2221 query.append(_FILTER_SQL_SELECT_SCPRODUCTENTRY_WHERE);
2222 }
2223 else {
2224 query.append(_FILTER_SQL_SELECT_SCPRODUCTENTRY_NO_INLINE_DISTINCT_WHERE_1);
2225 }
2226
2227 query.append(_FINDER_COLUMN_G_U_GROUPID_2);
2228
2229 query.append(_FINDER_COLUMN_G_U_USERID_2);
2230
2231 if (!getDB().isSupportsInlineDistinct()) {
2232 query.append(_FILTER_SQL_SELECT_SCPRODUCTENTRY_NO_INLINE_DISTINCT_WHERE_2);
2233 }
2234
2235 if (orderByComparator != null) {
2236 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2237
2238 if (orderByConditionFields.length > 0) {
2239 query.append(WHERE_AND);
2240 }
2241
2242 for (int i = 0; i < orderByConditionFields.length; i++) {
2243 if (getDB().isSupportsInlineDistinct()) {
2244 query.append(_ORDER_BY_ENTITY_ALIAS);
2245 }
2246 else {
2247 query.append(_ORDER_BY_ENTITY_TABLE);
2248 }
2249
2250 query.append(orderByConditionFields[i]);
2251
2252 if ((i + 1) < orderByConditionFields.length) {
2253 if (orderByComparator.isAscending() ^ previous) {
2254 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2255 }
2256 else {
2257 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2258 }
2259 }
2260 else {
2261 if (orderByComparator.isAscending() ^ previous) {
2262 query.append(WHERE_GREATER_THAN);
2263 }
2264 else {
2265 query.append(WHERE_LESSER_THAN);
2266 }
2267 }
2268 }
2269
2270 query.append(ORDER_BY_CLAUSE);
2271
2272 String[] orderByFields = orderByComparator.getOrderByFields();
2273
2274 for (int i = 0; i < orderByFields.length; i++) {
2275 if (getDB().isSupportsInlineDistinct()) {
2276 query.append(_ORDER_BY_ENTITY_ALIAS);
2277 }
2278 else {
2279 query.append(_ORDER_BY_ENTITY_TABLE);
2280 }
2281
2282 query.append(orderByFields[i]);
2283
2284 if ((i + 1) < orderByFields.length) {
2285 if (orderByComparator.isAscending() ^ previous) {
2286 query.append(ORDER_BY_ASC_HAS_NEXT);
2287 }
2288 else {
2289 query.append(ORDER_BY_DESC_HAS_NEXT);
2290 }
2291 }
2292 else {
2293 if (orderByComparator.isAscending() ^ previous) {
2294 query.append(ORDER_BY_ASC);
2295 }
2296 else {
2297 query.append(ORDER_BY_DESC);
2298 }
2299 }
2300 }
2301 }
2302
2303 else {
2304 if (getDB().isSupportsInlineDistinct()) {
2305 query.append(SCProductEntryModelImpl.ORDER_BY_JPQL);
2306 }
2307 else {
2308 query.append(SCProductEntryModelImpl.ORDER_BY_SQL);
2309 }
2310 }
2311
2312 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2313 SCProductEntry.class.getName(),
2314 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2315
2316 SQLQuery q = session.createSQLQuery(sql);
2317
2318 q.setFirstResult(0);
2319 q.setMaxResults(2);
2320
2321 if (getDB().isSupportsInlineDistinct()) {
2322 q.addEntity(_FILTER_ENTITY_ALIAS, SCProductEntryImpl.class);
2323 }
2324 else {
2325 q.addEntity(_FILTER_ENTITY_TABLE, SCProductEntryImpl.class);
2326 }
2327
2328 QueryPos qPos = QueryPos.getInstance(q);
2329
2330 qPos.add(groupId);
2331
2332 qPos.add(userId);
2333
2334 if (orderByComparator != null) {
2335 Object[] values = orderByComparator.getOrderByConditionValues(scProductEntry);
2336
2337 for (Object value : values) {
2338 qPos.add(value);
2339 }
2340 }
2341
2342 List<SCProductEntry> list = q.list();
2343
2344 if (list.size() == 2) {
2345 return list.get(1);
2346 }
2347 else {
2348 return null;
2349 }
2350 }
2351
2352
2361 public SCProductEntry findByRG_RA(String repoGroupId, String repoArtifactId)
2362 throws NoSuchProductEntryException, SystemException {
2363 SCProductEntry scProductEntry = fetchByRG_RA(repoGroupId, repoArtifactId);
2364
2365 if (scProductEntry == null) {
2366 StringBundler msg = new StringBundler(6);
2367
2368 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2369
2370 msg.append("repoGroupId=");
2371 msg.append(repoGroupId);
2372
2373 msg.append(", repoArtifactId=");
2374 msg.append(repoArtifactId);
2375
2376 msg.append(StringPool.CLOSE_CURLY_BRACE);
2377
2378 if (_log.isWarnEnabled()) {
2379 _log.warn(msg.toString());
2380 }
2381
2382 throw new NoSuchProductEntryException(msg.toString());
2383 }
2384
2385 return scProductEntry;
2386 }
2387
2388
2396 public SCProductEntry fetchByRG_RA(String repoGroupId, String repoArtifactId)
2397 throws SystemException {
2398 return fetchByRG_RA(repoGroupId, repoArtifactId, true);
2399 }
2400
2401
2410 public SCProductEntry fetchByRG_RA(String repoGroupId,
2411 String repoArtifactId, boolean retrieveFromCache)
2412 throws SystemException {
2413 Object[] finderArgs = new Object[] { repoGroupId, repoArtifactId };
2414
2415 Object result = null;
2416
2417 if (retrieveFromCache) {
2418 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_RG_RA,
2419 finderArgs, this);
2420 }
2421
2422 if (result == null) {
2423 StringBundler query = new StringBundler(4);
2424
2425 query.append(_SQL_SELECT_SCPRODUCTENTRY_WHERE);
2426
2427 if (repoGroupId == null) {
2428 query.append(_FINDER_COLUMN_RG_RA_REPOGROUPID_1);
2429 }
2430 else {
2431 if (repoGroupId.equals(StringPool.BLANK)) {
2432 query.append(_FINDER_COLUMN_RG_RA_REPOGROUPID_3);
2433 }
2434 else {
2435 query.append(_FINDER_COLUMN_RG_RA_REPOGROUPID_2);
2436 }
2437 }
2438
2439 if (repoArtifactId == null) {
2440 query.append(_FINDER_COLUMN_RG_RA_REPOARTIFACTID_1);
2441 }
2442 else {
2443 if (repoArtifactId.equals(StringPool.BLANK)) {
2444 query.append(_FINDER_COLUMN_RG_RA_REPOARTIFACTID_3);
2445 }
2446 else {
2447 query.append(_FINDER_COLUMN_RG_RA_REPOARTIFACTID_2);
2448 }
2449 }
2450
2451 query.append(SCProductEntryModelImpl.ORDER_BY_JPQL);
2452
2453 String sql = query.toString();
2454
2455 Session session = null;
2456
2457 try {
2458 session = openSession();
2459
2460 Query q = session.createQuery(sql);
2461
2462 QueryPos qPos = QueryPos.getInstance(q);
2463
2464 if (repoGroupId != null) {
2465 qPos.add(repoGroupId);
2466 }
2467
2468 if (repoArtifactId != null) {
2469 qPos.add(repoArtifactId);
2470 }
2471
2472 List<SCProductEntry> list = q.list();
2473
2474 result = list;
2475
2476 SCProductEntry scProductEntry = null;
2477
2478 if (list.isEmpty()) {
2479 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_RG_RA,
2480 finderArgs, list);
2481 }
2482 else {
2483 scProductEntry = list.get(0);
2484
2485 cacheResult(scProductEntry);
2486
2487 if ((scProductEntry.getRepoGroupId() == null) ||
2488 !scProductEntry.getRepoGroupId().equals(repoGroupId) ||
2489 (scProductEntry.getRepoArtifactId() == null) ||
2490 !scProductEntry.getRepoArtifactId()
2491 .equals(repoArtifactId)) {
2492 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_RG_RA,
2493 finderArgs, scProductEntry);
2494 }
2495 }
2496
2497 return scProductEntry;
2498 }
2499 catch (Exception e) {
2500 throw processException(e);
2501 }
2502 finally {
2503 if (result == null) {
2504 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_RG_RA,
2505 finderArgs);
2506 }
2507
2508 closeSession(session);
2509 }
2510 }
2511 else {
2512 if (result instanceof List<?>) {
2513 return null;
2514 }
2515 else {
2516 return (SCProductEntry)result;
2517 }
2518 }
2519 }
2520
2521
2527 public List<SCProductEntry> findAll() throws SystemException {
2528 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2529 }
2530
2531
2543 public List<SCProductEntry> findAll(int start, int end)
2544 throws SystemException {
2545 return findAll(start, end, null);
2546 }
2547
2548
2561 public List<SCProductEntry> findAll(int start, int end,
2562 OrderByComparator orderByComparator) throws SystemException {
2563 FinderPath finderPath = null;
2564 Object[] finderArgs = new Object[] { start, end, orderByComparator };
2565
2566 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2567 (orderByComparator == null)) {
2568 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
2569 finderArgs = FINDER_ARGS_EMPTY;
2570 }
2571 else {
2572 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
2573 finderArgs = new Object[] { start, end, orderByComparator };
2574 }
2575
2576 List<SCProductEntry> list = (List<SCProductEntry>)FinderCacheUtil.getResult(finderPath,
2577 finderArgs, this);
2578
2579 if (list == null) {
2580 StringBundler query = null;
2581 String sql = null;
2582
2583 if (orderByComparator != null) {
2584 query = new StringBundler(2 +
2585 (orderByComparator.getOrderByFields().length * 3));
2586
2587 query.append(_SQL_SELECT_SCPRODUCTENTRY);
2588
2589 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2590 orderByComparator);
2591
2592 sql = query.toString();
2593 }
2594 else {
2595 sql = _SQL_SELECT_SCPRODUCTENTRY.concat(SCProductEntryModelImpl.ORDER_BY_JPQL);
2596 }
2597
2598 Session session = null;
2599
2600 try {
2601 session = openSession();
2602
2603 Query q = session.createQuery(sql);
2604
2605 if (orderByComparator == null) {
2606 list = (List<SCProductEntry>)QueryUtil.list(q,
2607 getDialect(), start, end, false);
2608
2609 Collections.sort(list);
2610 }
2611 else {
2612 list = (List<SCProductEntry>)QueryUtil.list(q,
2613 getDialect(), start, end);
2614 }
2615 }
2616 catch (Exception e) {
2617 throw processException(e);
2618 }
2619 finally {
2620 if (list == null) {
2621 FinderCacheUtil.removeResult(finderPath, finderArgs);
2622 }
2623 else {
2624 cacheResult(list);
2625
2626 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2627 }
2628
2629 closeSession(session);
2630 }
2631 }
2632
2633 return list;
2634 }
2635
2636
2642 public void removeByGroupId(long groupId) throws SystemException {
2643 for (SCProductEntry scProductEntry : findByGroupId(groupId)) {
2644 scProductEntryPersistence.remove(scProductEntry);
2645 }
2646 }
2647
2648
2654 public void removeByCompanyId(long companyId) throws SystemException {
2655 for (SCProductEntry scProductEntry : findByCompanyId(companyId)) {
2656 scProductEntryPersistence.remove(scProductEntry);
2657 }
2658 }
2659
2660
2667 public void removeByG_U(long groupId, long userId)
2668 throws SystemException {
2669 for (SCProductEntry scProductEntry : findByG_U(groupId, userId)) {
2670 scProductEntryPersistence.remove(scProductEntry);
2671 }
2672 }
2673
2674
2681 public void removeByRG_RA(String repoGroupId, String repoArtifactId)
2682 throws NoSuchProductEntryException, SystemException {
2683 SCProductEntry scProductEntry = findByRG_RA(repoGroupId, repoArtifactId);
2684
2685 scProductEntryPersistence.remove(scProductEntry);
2686 }
2687
2688
2693 public void removeAll() throws SystemException {
2694 for (SCProductEntry scProductEntry : findAll()) {
2695 scProductEntryPersistence.remove(scProductEntry);
2696 }
2697 }
2698
2699
2706 public int countByGroupId(long groupId) throws SystemException {
2707 Object[] finderArgs = new Object[] { groupId };
2708
2709 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
2710 finderArgs, this);
2711
2712 if (count == null) {
2713 StringBundler query = new StringBundler(2);
2714
2715 query.append(_SQL_COUNT_SCPRODUCTENTRY_WHERE);
2716
2717 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2718
2719 String sql = query.toString();
2720
2721 Session session = null;
2722
2723 try {
2724 session = openSession();
2725
2726 Query q = session.createQuery(sql);
2727
2728 QueryPos qPos = QueryPos.getInstance(q);
2729
2730 qPos.add(groupId);
2731
2732 count = (Long)q.uniqueResult();
2733 }
2734 catch (Exception e) {
2735 throw processException(e);
2736 }
2737 finally {
2738 if (count == null) {
2739 count = Long.valueOf(0);
2740 }
2741
2742 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
2743 finderArgs, count);
2744
2745 closeSession(session);
2746 }
2747 }
2748
2749 return count.intValue();
2750 }
2751
2752
2759 public int filterCountByGroupId(long groupId) throws SystemException {
2760 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2761 return countByGroupId(groupId);
2762 }
2763
2764 StringBundler query = new StringBundler(2);
2765
2766 query.append(_FILTER_SQL_COUNT_SCPRODUCTENTRY_WHERE);
2767
2768 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2769
2770 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2771 SCProductEntry.class.getName(),
2772 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2773
2774 Session session = null;
2775
2776 try {
2777 session = openSession();
2778
2779 SQLQuery q = session.createSQLQuery(sql);
2780
2781 q.addScalar(COUNT_COLUMN_NAME,
2782 com.liferay.portal.kernel.dao.orm.Type.LONG);
2783
2784 QueryPos qPos = QueryPos.getInstance(q);
2785
2786 qPos.add(groupId);
2787
2788 Long count = (Long)q.uniqueResult();
2789
2790 return count.intValue();
2791 }
2792 catch (Exception e) {
2793 throw processException(e);
2794 }
2795 finally {
2796 closeSession(session);
2797 }
2798 }
2799
2800
2807 public int countByCompanyId(long companyId) throws SystemException {
2808 Object[] finderArgs = new Object[] { companyId };
2809
2810 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
2811 finderArgs, this);
2812
2813 if (count == null) {
2814 StringBundler query = new StringBundler(2);
2815
2816 query.append(_SQL_COUNT_SCPRODUCTENTRY_WHERE);
2817
2818 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2819
2820 String sql = query.toString();
2821
2822 Session session = null;
2823
2824 try {
2825 session = openSession();
2826
2827 Query q = session.createQuery(sql);
2828
2829 QueryPos qPos = QueryPos.getInstance(q);
2830
2831 qPos.add(companyId);
2832
2833 count = (Long)q.uniqueResult();
2834 }
2835 catch (Exception e) {
2836 throw processException(e);
2837 }
2838 finally {
2839 if (count == null) {
2840 count = Long.valueOf(0);
2841 }
2842
2843 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
2844 finderArgs, count);
2845
2846 closeSession(session);
2847 }
2848 }
2849
2850 return count.intValue();
2851 }
2852
2853
2861 public int countByG_U(long groupId, long userId) throws SystemException {
2862 Object[] finderArgs = new Object[] { groupId, userId };
2863
2864 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_U,
2865 finderArgs, this);
2866
2867 if (count == null) {
2868 StringBundler query = new StringBundler(3);
2869
2870 query.append(_SQL_COUNT_SCPRODUCTENTRY_WHERE);
2871
2872 query.append(_FINDER_COLUMN_G_U_GROUPID_2);
2873
2874 query.append(_FINDER_COLUMN_G_U_USERID_2);
2875
2876 String sql = query.toString();
2877
2878 Session session = null;
2879
2880 try {
2881 session = openSession();
2882
2883 Query q = session.createQuery(sql);
2884
2885 QueryPos qPos = QueryPos.getInstance(q);
2886
2887 qPos.add(groupId);
2888
2889 qPos.add(userId);
2890
2891 count = (Long)q.uniqueResult();
2892 }
2893 catch (Exception e) {
2894 throw processException(e);
2895 }
2896 finally {
2897 if (count == null) {
2898 count = Long.valueOf(0);
2899 }
2900
2901 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_U, finderArgs,
2902 count);
2903
2904 closeSession(session);
2905 }
2906 }
2907
2908 return count.intValue();
2909 }
2910
2911
2919 public int filterCountByG_U(long groupId, long userId)
2920 throws SystemException {
2921 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2922 return countByG_U(groupId, userId);
2923 }
2924
2925 StringBundler query = new StringBundler(3);
2926
2927 query.append(_FILTER_SQL_COUNT_SCPRODUCTENTRY_WHERE);
2928
2929 query.append(_FINDER_COLUMN_G_U_GROUPID_2);
2930
2931 query.append(_FINDER_COLUMN_G_U_USERID_2);
2932
2933 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2934 SCProductEntry.class.getName(),
2935 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2936
2937 Session session = null;
2938
2939 try {
2940 session = openSession();
2941
2942 SQLQuery q = session.createSQLQuery(sql);
2943
2944 q.addScalar(COUNT_COLUMN_NAME,
2945 com.liferay.portal.kernel.dao.orm.Type.LONG);
2946
2947 QueryPos qPos = QueryPos.getInstance(q);
2948
2949 qPos.add(groupId);
2950
2951 qPos.add(userId);
2952
2953 Long count = (Long)q.uniqueResult();
2954
2955 return count.intValue();
2956 }
2957 catch (Exception e) {
2958 throw processException(e);
2959 }
2960 finally {
2961 closeSession(session);
2962 }
2963 }
2964
2965
2973 public int countByRG_RA(String repoGroupId, String repoArtifactId)
2974 throws SystemException {
2975 Object[] finderArgs = new Object[] { repoGroupId, repoArtifactId };
2976
2977 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_RG_RA,
2978 finderArgs, this);
2979
2980 if (count == null) {
2981 StringBundler query = new StringBundler(3);
2982
2983 query.append(_SQL_COUNT_SCPRODUCTENTRY_WHERE);
2984
2985 if (repoGroupId == null) {
2986 query.append(_FINDER_COLUMN_RG_RA_REPOGROUPID_1);
2987 }
2988 else {
2989 if (repoGroupId.equals(StringPool.BLANK)) {
2990 query.append(_FINDER_COLUMN_RG_RA_REPOGROUPID_3);
2991 }
2992 else {
2993 query.append(_FINDER_COLUMN_RG_RA_REPOGROUPID_2);
2994 }
2995 }
2996
2997 if (repoArtifactId == null) {
2998 query.append(_FINDER_COLUMN_RG_RA_REPOARTIFACTID_1);
2999 }
3000 else {
3001 if (repoArtifactId.equals(StringPool.BLANK)) {
3002 query.append(_FINDER_COLUMN_RG_RA_REPOARTIFACTID_3);
3003 }
3004 else {
3005 query.append(_FINDER_COLUMN_RG_RA_REPOARTIFACTID_2);
3006 }
3007 }
3008
3009 String sql = query.toString();
3010
3011 Session session = null;
3012
3013 try {
3014 session = openSession();
3015
3016 Query q = session.createQuery(sql);
3017
3018 QueryPos qPos = QueryPos.getInstance(q);
3019
3020 if (repoGroupId != null) {
3021 qPos.add(repoGroupId);
3022 }
3023
3024 if (repoArtifactId != null) {
3025 qPos.add(repoArtifactId);
3026 }
3027
3028 count = (Long)q.uniqueResult();
3029 }
3030 catch (Exception e) {
3031 throw processException(e);
3032 }
3033 finally {
3034 if (count == null) {
3035 count = Long.valueOf(0);
3036 }
3037
3038 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_RG_RA,
3039 finderArgs, count);
3040
3041 closeSession(session);
3042 }
3043 }
3044
3045 return count.intValue();
3046 }
3047
3048
3054 public int countAll() throws SystemException {
3055 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
3056 FINDER_ARGS_EMPTY, this);
3057
3058 if (count == null) {
3059 Session session = null;
3060
3061 try {
3062 session = openSession();
3063
3064 Query q = session.createQuery(_SQL_COUNT_SCPRODUCTENTRY);
3065
3066 count = (Long)q.uniqueResult();
3067 }
3068 catch (Exception e) {
3069 throw processException(e);
3070 }
3071 finally {
3072 if (count == null) {
3073 count = Long.valueOf(0);
3074 }
3075
3076 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
3077 FINDER_ARGS_EMPTY, count);
3078
3079 closeSession(session);
3080 }
3081 }
3082
3083 return count.intValue();
3084 }
3085
3086
3093 public List<com.liferay.portlet.softwarecatalog.model.SCLicense> getSCLicenses(
3094 long pk) throws SystemException {
3095 return getSCLicenses(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
3096 }
3097
3098
3111 public List<com.liferay.portlet.softwarecatalog.model.SCLicense> getSCLicenses(
3112 long pk, int start, int end) throws SystemException {
3113 return getSCLicenses(pk, start, end, null);
3114 }
3115
3116 public static final FinderPath FINDER_PATH_GET_SCLICENSES = new FinderPath(com.liferay.portlet.softwarecatalog.model.impl.SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
3117 SCProductEntryModelImpl.FINDER_CACHE_ENABLED_SCLICENSES_SCPRODUCTENTRIES,
3118 com.liferay.portlet.softwarecatalog.model.impl.SCLicenseImpl.class,
3119 SCProductEntryModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME,
3120 "getSCLicenses",
3121 new String[] {
3122 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
3123 "com.liferay.portal.kernel.util.OrderByComparator"
3124 });
3125
3126
3140 public List<com.liferay.portlet.softwarecatalog.model.SCLicense> getSCLicenses(
3141 long pk, int start, int end, OrderByComparator orderByComparator)
3142 throws SystemException {
3143 Object[] finderArgs = new Object[] { pk, start, end, orderByComparator };
3144
3145 List<com.liferay.portlet.softwarecatalog.model.SCLicense> list = (List<com.liferay.portlet.softwarecatalog.model.SCLicense>)FinderCacheUtil.getResult(FINDER_PATH_GET_SCLICENSES,
3146 finderArgs, this);
3147
3148 if (list == null) {
3149 Session session = null;
3150
3151 try {
3152 session = openSession();
3153
3154 String sql = null;
3155
3156 if (orderByComparator != null) {
3157 sql = _SQL_GETSCLICENSES.concat(ORDER_BY_CLAUSE)
3158 .concat(orderByComparator.getOrderBy());
3159 }
3160 else {
3161 sql = _SQL_GETSCLICENSES.concat(com.liferay.portlet.softwarecatalog.model.impl.SCLicenseModelImpl.ORDER_BY_SQL);
3162 }
3163
3164 SQLQuery q = session.createSQLQuery(sql);
3165
3166 q.addEntity("SCLicense",
3167 com.liferay.portlet.softwarecatalog.model.impl.SCLicenseImpl.class);
3168
3169 QueryPos qPos = QueryPos.getInstance(q);
3170
3171 qPos.add(pk);
3172
3173 list = (List<com.liferay.portlet.softwarecatalog.model.SCLicense>)QueryUtil.list(q,
3174 getDialect(), start, end);
3175 }
3176 catch (Exception e) {
3177 throw processException(e);
3178 }
3179 finally {
3180 if (list == null) {
3181 FinderCacheUtil.removeResult(FINDER_PATH_GET_SCLICENSES,
3182 finderArgs);
3183 }
3184 else {
3185 scLicensePersistence.cacheResult(list);
3186
3187 FinderCacheUtil.putResult(FINDER_PATH_GET_SCLICENSES,
3188 finderArgs, list);
3189 }
3190
3191 closeSession(session);
3192 }
3193 }
3194
3195 return list;
3196 }
3197
3198 public static final FinderPath FINDER_PATH_GET_SCLICENSES_SIZE = new FinderPath(com.liferay.portlet.softwarecatalog.model.impl.SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
3199 SCProductEntryModelImpl.FINDER_CACHE_ENABLED_SCLICENSES_SCPRODUCTENTRIES,
3200 Long.class,
3201 SCProductEntryModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME,
3202 "getSCLicensesSize", new String[] { Long.class.getName() });
3203
3204
3211 public int getSCLicensesSize(long pk) throws SystemException {
3212 Object[] finderArgs = new Object[] { pk };
3213
3214 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_SCLICENSES_SIZE,
3215 finderArgs, this);
3216
3217 if (count == null) {
3218 Session session = null;
3219
3220 try {
3221 session = openSession();
3222
3223 SQLQuery q = session.createSQLQuery(_SQL_GETSCLICENSESSIZE);
3224
3225 q.addScalar(COUNT_COLUMN_NAME,
3226 com.liferay.portal.kernel.dao.orm.Type.LONG);
3227
3228 QueryPos qPos = QueryPos.getInstance(q);
3229
3230 qPos.add(pk);
3231
3232 count = (Long)q.uniqueResult();
3233 }
3234 catch (Exception e) {
3235 throw processException(e);
3236 }
3237 finally {
3238 if (count == null) {
3239 count = Long.valueOf(0);
3240 }
3241
3242 FinderCacheUtil.putResult(FINDER_PATH_GET_SCLICENSES_SIZE,
3243 finderArgs, count);
3244
3245 closeSession(session);
3246 }
3247 }
3248
3249 return count.intValue();
3250 }
3251
3252 public static final FinderPath FINDER_PATH_CONTAINS_SCLICENSE = new FinderPath(com.liferay.portlet.softwarecatalog.model.impl.SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
3253 SCProductEntryModelImpl.FINDER_CACHE_ENABLED_SCLICENSES_SCPRODUCTENTRIES,
3254 Boolean.class,
3255 SCProductEntryModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME,
3256 "containsSCLicense",
3257 new String[] { Long.class.getName(), Long.class.getName() });
3258
3259
3267 public boolean containsSCLicense(long pk, long scLicensePK)
3268 throws SystemException {
3269 Object[] finderArgs = new Object[] { pk, scLicensePK };
3270
3271 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_SCLICENSE,
3272 finderArgs, this);
3273
3274 if (value == null) {
3275 try {
3276 value = Boolean.valueOf(containsSCLicense.contains(pk,
3277 scLicensePK));
3278 }
3279 catch (Exception e) {
3280 throw processException(e);
3281 }
3282 finally {
3283 if (value == null) {
3284 value = Boolean.FALSE;
3285 }
3286
3287 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_SCLICENSE,
3288 finderArgs, value);
3289 }
3290 }
3291
3292 return value.booleanValue();
3293 }
3294
3295
3302 public boolean containsSCLicenses(long pk) throws SystemException {
3303 if (getSCLicensesSize(pk) > 0) {
3304 return true;
3305 }
3306 else {
3307 return false;
3308 }
3309 }
3310
3311
3318 public void addSCLicense(long pk, long scLicensePK)
3319 throws SystemException {
3320 try {
3321 addSCLicense.add(pk, scLicensePK);
3322 }
3323 catch (Exception e) {
3324 throw processException(e);
3325 }
3326 finally {
3327 FinderCacheUtil.clearCache(SCProductEntryModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
3328 }
3329 }
3330
3331
3338 public void addSCLicense(long pk,
3339 com.liferay.portlet.softwarecatalog.model.SCLicense scLicense)
3340 throws SystemException {
3341 try {
3342 addSCLicense.add(pk, scLicense.getPrimaryKey());
3343 }
3344 catch (Exception e) {
3345 throw processException(e);
3346 }
3347 finally {
3348 FinderCacheUtil.clearCache(SCProductEntryModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
3349 }
3350 }
3351
3352
3359 public void addSCLicenses(long pk, long[] scLicensePKs)
3360 throws SystemException {
3361 try {
3362 for (long scLicensePK : scLicensePKs) {
3363 addSCLicense.add(pk, scLicensePK);
3364 }
3365 }
3366 catch (Exception e) {
3367 throw processException(e);
3368 }
3369 finally {
3370 FinderCacheUtil.clearCache(SCProductEntryModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
3371 }
3372 }
3373
3374
3381 public void addSCLicenses(long pk,
3382 List<com.liferay.portlet.softwarecatalog.model.SCLicense> scLicenses)
3383 throws SystemException {
3384 try {
3385 for (com.liferay.portlet.softwarecatalog.model.SCLicense scLicense : scLicenses) {
3386 addSCLicense.add(pk, scLicense.getPrimaryKey());
3387 }
3388 }
3389 catch (Exception e) {
3390 throw processException(e);
3391 }
3392 finally {
3393 FinderCacheUtil.clearCache(SCProductEntryModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
3394 }
3395 }
3396
3397
3403 public void clearSCLicenses(long pk) throws SystemException {
3404 try {
3405 clearSCLicenses.clear(pk);
3406 }
3407 catch (Exception e) {
3408 throw processException(e);
3409 }
3410 finally {
3411 FinderCacheUtil.clearCache(SCProductEntryModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
3412 }
3413 }
3414
3415
3422 public void removeSCLicense(long pk, long scLicensePK)
3423 throws SystemException {
3424 try {
3425 removeSCLicense.remove(pk, scLicensePK);
3426 }
3427 catch (Exception e) {
3428 throw processException(e);
3429 }
3430 finally {
3431 FinderCacheUtil.clearCache(SCProductEntryModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
3432 }
3433 }
3434
3435
3442 public void removeSCLicense(long pk,
3443 com.liferay.portlet.softwarecatalog.model.SCLicense scLicense)
3444 throws SystemException {
3445 try {
3446 removeSCLicense.remove(pk, scLicense.getPrimaryKey());
3447 }
3448 catch (Exception e) {
3449 throw processException(e);
3450 }
3451 finally {
3452 FinderCacheUtil.clearCache(SCProductEntryModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
3453 }
3454 }
3455
3456
3463 public void removeSCLicenses(long pk, long[] scLicensePKs)
3464 throws SystemException {
3465 try {
3466 for (long scLicensePK : scLicensePKs) {
3467 removeSCLicense.remove(pk, scLicensePK);
3468 }
3469 }
3470 catch (Exception e) {
3471 throw processException(e);
3472 }
3473 finally {
3474 FinderCacheUtil.clearCache(SCProductEntryModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
3475 }
3476 }
3477
3478
3485 public void removeSCLicenses(long pk,
3486 List<com.liferay.portlet.softwarecatalog.model.SCLicense> scLicenses)
3487 throws SystemException {
3488 try {
3489 for (com.liferay.portlet.softwarecatalog.model.SCLicense scLicense : scLicenses) {
3490 removeSCLicense.remove(pk, scLicense.getPrimaryKey());
3491 }
3492 }
3493 catch (Exception e) {
3494 throw processException(e);
3495 }
3496 finally {
3497 FinderCacheUtil.clearCache(SCProductEntryModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
3498 }
3499 }
3500
3501
3508 public void setSCLicenses(long pk, long[] scLicensePKs)
3509 throws SystemException {
3510 try {
3511 Set<Long> scLicensePKSet = SetUtil.fromArray(scLicensePKs);
3512
3513 List<com.liferay.portlet.softwarecatalog.model.SCLicense> scLicenses =
3514 getSCLicenses(pk);
3515
3516 for (com.liferay.portlet.softwarecatalog.model.SCLicense scLicense : scLicenses) {
3517 if (!scLicensePKSet.remove(scLicense.getPrimaryKey())) {
3518 removeSCLicense.remove(pk, scLicense.getPrimaryKey());
3519 }
3520 }
3521
3522 for (Long scLicensePK : scLicensePKSet) {
3523 addSCLicense.add(pk, scLicensePK);
3524 }
3525 }
3526 catch (Exception e) {
3527 throw processException(e);
3528 }
3529 finally {
3530 FinderCacheUtil.clearCache(SCProductEntryModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
3531 }
3532 }
3533
3534
3541 public void setSCLicenses(long pk,
3542 List<com.liferay.portlet.softwarecatalog.model.SCLicense> scLicenses)
3543 throws SystemException {
3544 try {
3545 long[] scLicensePKs = new long[scLicenses.size()];
3546
3547 for (int i = 0; i < scLicenses.size(); i++) {
3548 com.liferay.portlet.softwarecatalog.model.SCLicense scLicense = scLicenses.get(i);
3549
3550 scLicensePKs[i] = scLicense.getPrimaryKey();
3551 }
3552
3553 setSCLicenses(pk, scLicensePKs);
3554 }
3555 catch (Exception e) {
3556 throw processException(e);
3557 }
3558 finally {
3559 FinderCacheUtil.clearCache(SCProductEntryModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
3560 }
3561 }
3562
3563
3566 public void afterPropertiesSet() {
3567 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
3568 com.liferay.portal.util.PropsUtil.get(
3569 "value.object.listener.com.liferay.portlet.softwarecatalog.model.SCProductEntry")));
3570
3571 if (listenerClassNames.length > 0) {
3572 try {
3573 List<ModelListener<SCProductEntry>> listenersList = new ArrayList<ModelListener<SCProductEntry>>();
3574
3575 for (String listenerClassName : listenerClassNames) {
3576 listenersList.add((ModelListener<SCProductEntry>)InstanceFactory.newInstance(
3577 listenerClassName));
3578 }
3579
3580 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
3581 }
3582 catch (Exception e) {
3583 _log.error(e);
3584 }
3585 }
3586
3587 containsSCLicense = new ContainsSCLicense(this);
3588
3589 addSCLicense = new AddSCLicense(this);
3590 clearSCLicenses = new ClearSCLicenses(this);
3591 removeSCLicense = new RemoveSCLicense(this);
3592 }
3593
3594 public void destroy() {
3595 EntityCacheUtil.removeCache(SCProductEntryImpl.class.getName());
3596 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
3597 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
3598 }
3599
3600 @BeanReference(type = SCFrameworkVersionPersistence.class)
3601 protected SCFrameworkVersionPersistence scFrameworkVersionPersistence;
3602 @BeanReference(type = SCLicensePersistence.class)
3603 protected SCLicensePersistence scLicensePersistence;
3604 @BeanReference(type = SCProductEntryPersistence.class)
3605 protected SCProductEntryPersistence scProductEntryPersistence;
3606 @BeanReference(type = SCProductScreenshotPersistence.class)
3607 protected SCProductScreenshotPersistence scProductScreenshotPersistence;
3608 @BeanReference(type = SCProductVersionPersistence.class)
3609 protected SCProductVersionPersistence scProductVersionPersistence;
3610 @BeanReference(type = GroupPersistence.class)
3611 protected GroupPersistence groupPersistence;
3612 @BeanReference(type = ImagePersistence.class)
3613 protected ImagePersistence imagePersistence;
3614 @BeanReference(type = ResourcePersistence.class)
3615 protected ResourcePersistence resourcePersistence;
3616 @BeanReference(type = UserPersistence.class)
3617 protected UserPersistence userPersistence;
3618 @BeanReference(type = MBMessagePersistence.class)
3619 protected MBMessagePersistence mbMessagePersistence;
3620 @BeanReference(type = RatingsStatsPersistence.class)
3621 protected RatingsStatsPersistence ratingsStatsPersistence;
3622 protected ContainsSCLicense containsSCLicense;
3623 protected AddSCLicense addSCLicense;
3624 protected ClearSCLicenses clearSCLicenses;
3625 protected RemoveSCLicense removeSCLicense;
3626
3627 protected class ContainsSCLicense {
3628 protected ContainsSCLicense(
3629 SCProductEntryPersistenceImpl persistenceImpl) {
3630 super();
3631
3632 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
3633 _SQL_CONTAINSSCLICENSE,
3634 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
3635 RowMapper.COUNT);
3636 }
3637
3638 protected boolean contains(long productEntryId, long licenseId) {
3639 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
3640 new Long(productEntryId), new Long(licenseId)
3641 });
3642
3643 if (results.size() > 0) {
3644 Integer count = results.get(0);
3645
3646 if (count.intValue() > 0) {
3647 return true;
3648 }
3649 }
3650
3651 return false;
3652 }
3653
3654 private MappingSqlQuery<Integer> _mappingSqlQuery;
3655 }
3656
3657 protected class AddSCLicense {
3658 protected AddSCLicense(SCProductEntryPersistenceImpl persistenceImpl) {
3659 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
3660 "INSERT INTO SCLicenses_SCProductEntries (productEntryId, licenseId) VALUES (?, ?)",
3661 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
3662 _persistenceImpl = persistenceImpl;
3663 }
3664
3665 protected void add(long productEntryId, long licenseId)
3666 throws SystemException {
3667 if (!_persistenceImpl.containsSCLicense.contains(productEntryId,
3668 licenseId)) {
3669 ModelListener<com.liferay.portlet.softwarecatalog.model.SCLicense>[] scLicenseListeners =
3670 scLicensePersistence.getListeners();
3671
3672 for (ModelListener<SCProductEntry> listener : listeners) {
3673 listener.onBeforeAddAssociation(productEntryId,
3674 com.liferay.portlet.softwarecatalog.model.SCLicense.class.getName(),
3675 licenseId);
3676 }
3677
3678 for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCLicense> listener : scLicenseListeners) {
3679 listener.onBeforeAddAssociation(licenseId,
3680 SCProductEntry.class.getName(), productEntryId);
3681 }
3682
3683 _sqlUpdate.update(new Object[] {
3684 new Long(productEntryId), new Long(licenseId)
3685 });
3686
3687 for (ModelListener<SCProductEntry> listener : listeners) {
3688 listener.onAfterAddAssociation(productEntryId,
3689 com.liferay.portlet.softwarecatalog.model.SCLicense.class.getName(),
3690 licenseId);
3691 }
3692
3693 for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCLicense> listener : scLicenseListeners) {
3694 listener.onAfterAddAssociation(licenseId,
3695 SCProductEntry.class.getName(), productEntryId);
3696 }
3697 }
3698 }
3699
3700 private SqlUpdate _sqlUpdate;
3701 private SCProductEntryPersistenceImpl _persistenceImpl;
3702 }
3703
3704 protected class ClearSCLicenses {
3705 protected ClearSCLicenses(SCProductEntryPersistenceImpl persistenceImpl) {
3706 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
3707 "DELETE FROM SCLicenses_SCProductEntries WHERE productEntryId = ?",
3708 new int[] { java.sql.Types.BIGINT });
3709 }
3710
3711 protected void clear(long productEntryId) throws SystemException {
3712 ModelListener<com.liferay.portlet.softwarecatalog.model.SCLicense>[] scLicenseListeners =
3713 scLicensePersistence.getListeners();
3714
3715 List<com.liferay.portlet.softwarecatalog.model.SCLicense> scLicenses =
3716 null;
3717
3718 if ((listeners.length > 0) || (scLicenseListeners.length > 0)) {
3719 scLicenses = getSCLicenses(productEntryId);
3720
3721 for (com.liferay.portlet.softwarecatalog.model.SCLicense scLicense : scLicenses) {
3722 for (ModelListener<SCProductEntry> listener : listeners) {
3723 listener.onBeforeRemoveAssociation(productEntryId,
3724 com.liferay.portlet.softwarecatalog.model.SCLicense.class.getName(),
3725 scLicense.getPrimaryKey());
3726 }
3727
3728 for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCLicense> listener : scLicenseListeners) {
3729 listener.onBeforeRemoveAssociation(scLicense.getPrimaryKey(),
3730 SCProductEntry.class.getName(), productEntryId);
3731 }
3732 }
3733 }
3734
3735 _sqlUpdate.update(new Object[] { new Long(productEntryId) });
3736
3737 if ((listeners.length > 0) || (scLicenseListeners.length > 0)) {
3738 for (com.liferay.portlet.softwarecatalog.model.SCLicense scLicense : scLicenses) {
3739 for (ModelListener<SCProductEntry> listener : listeners) {
3740 listener.onAfterRemoveAssociation(productEntryId,
3741 com.liferay.portlet.softwarecatalog.model.SCLicense.class.getName(),
3742 scLicense.getPrimaryKey());
3743 }
3744
3745 for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCLicense> listener : scLicenseListeners) {
3746 listener.onAfterRemoveAssociation(scLicense.getPrimaryKey(),
3747 SCProductEntry.class.getName(), productEntryId);
3748 }
3749 }
3750 }
3751 }
3752
3753 private SqlUpdate _sqlUpdate;
3754 }
3755
3756 protected class RemoveSCLicense {
3757 protected RemoveSCLicense(SCProductEntryPersistenceImpl persistenceImpl) {
3758 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
3759 "DELETE FROM SCLicenses_SCProductEntries WHERE productEntryId = ? AND licenseId = ?",
3760 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
3761 _persistenceImpl = persistenceImpl;
3762 }
3763
3764 protected void remove(long productEntryId, long licenseId)
3765 throws SystemException {
3766 if (_persistenceImpl.containsSCLicense.contains(productEntryId,
3767 licenseId)) {
3768 ModelListener<com.liferay.portlet.softwarecatalog.model.SCLicense>[] scLicenseListeners =
3769 scLicensePersistence.getListeners();
3770
3771 for (ModelListener<SCProductEntry> listener : listeners) {
3772 listener.onBeforeRemoveAssociation(productEntryId,
3773 com.liferay.portlet.softwarecatalog.model.SCLicense.class.getName(),
3774 licenseId);
3775 }
3776
3777 for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCLicense> listener : scLicenseListeners) {
3778 listener.onBeforeRemoveAssociation(licenseId,
3779 SCProductEntry.class.getName(), productEntryId);
3780 }
3781
3782 _sqlUpdate.update(new Object[] {
3783 new Long(productEntryId), new Long(licenseId)
3784 });
3785
3786 for (ModelListener<SCProductEntry> listener : listeners) {
3787 listener.onAfterRemoveAssociation(productEntryId,
3788 com.liferay.portlet.softwarecatalog.model.SCLicense.class.getName(),
3789 licenseId);
3790 }
3791
3792 for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCLicense> listener : scLicenseListeners) {
3793 listener.onAfterRemoveAssociation(licenseId,
3794 SCProductEntry.class.getName(), productEntryId);
3795 }
3796 }
3797 }
3798
3799 private SqlUpdate _sqlUpdate;
3800 private SCProductEntryPersistenceImpl _persistenceImpl;
3801 }
3802
3803 private static final String _SQL_SELECT_SCPRODUCTENTRY = "SELECT scProductEntry FROM SCProductEntry scProductEntry";
3804 private static final String _SQL_SELECT_SCPRODUCTENTRY_WHERE = "SELECT scProductEntry FROM SCProductEntry scProductEntry WHERE ";
3805 private static final String _SQL_COUNT_SCPRODUCTENTRY = "SELECT COUNT(scProductEntry) FROM SCProductEntry scProductEntry";
3806 private static final String _SQL_COUNT_SCPRODUCTENTRY_WHERE = "SELECT COUNT(scProductEntry) FROM SCProductEntry scProductEntry WHERE ";
3807 private static final String _SQL_GETSCLICENSES = "SELECT {SCLicense.*} FROM SCLicense INNER JOIN SCLicenses_SCProductEntries ON (SCLicenses_SCProductEntries.licenseId = SCLicense.licenseId) WHERE (SCLicenses_SCProductEntries.productEntryId = ?)";
3808 private static final String _SQL_GETSCLICENSESSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM SCLicenses_SCProductEntries WHERE productEntryId = ?";
3809 private static final String _SQL_CONTAINSSCLICENSE = "SELECT COUNT(*) AS COUNT_VALUE FROM SCLicenses_SCProductEntries WHERE productEntryId = ? AND licenseId = ?";
3810 private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "scProductEntry.groupId = ?";
3811 private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "scProductEntry.companyId = ?";
3812 private static final String _FINDER_COLUMN_G_U_GROUPID_2 = "scProductEntry.groupId = ? AND ";
3813 private static final String _FINDER_COLUMN_G_U_USERID_2 = "scProductEntry.userId = ?";
3814 private static final String _FINDER_COLUMN_RG_RA_REPOGROUPID_1 = "scProductEntry.repoGroupId IS NULL AND ";
3815 private static final String _FINDER_COLUMN_RG_RA_REPOGROUPID_2 = "lower(scProductEntry.repoGroupId) = lower(CAST_TEXT(?)) AND ";
3816 private static final String _FINDER_COLUMN_RG_RA_REPOGROUPID_3 = "(scProductEntry.repoGroupId IS NULL OR lower(scProductEntry.repoGroupId) = lower(CAST_TEXT(?))) AND ";
3817 private static final String _FINDER_COLUMN_RG_RA_REPOARTIFACTID_1 = "scProductEntry.repoArtifactId IS NULL";
3818 private static final String _FINDER_COLUMN_RG_RA_REPOARTIFACTID_2 = "lower(scProductEntry.repoArtifactId) = lower(CAST_TEXT(?))";
3819 private static final String _FINDER_COLUMN_RG_RA_REPOARTIFACTID_3 = "(scProductEntry.repoArtifactId IS NULL OR lower(scProductEntry.repoArtifactId) = lower(CAST_TEXT(?)))";
3820 private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "scProductEntry.productEntryId";
3821 private static final String _FILTER_SQL_SELECT_SCPRODUCTENTRY_WHERE = "SELECT DISTINCT {scProductEntry.*} FROM SCProductEntry scProductEntry WHERE ";
3822 private static final String _FILTER_SQL_SELECT_SCPRODUCTENTRY_NO_INLINE_DISTINCT_WHERE_1 =
3823 "SELECT {SCProductEntry.*} FROM (SELECT DISTINCT scProductEntry.productEntryId FROM SCProductEntry scProductEntry WHERE ";
3824 private static final String _FILTER_SQL_SELECT_SCPRODUCTENTRY_NO_INLINE_DISTINCT_WHERE_2 =
3825 ") TEMP_TABLE INNER JOIN SCProductEntry ON TEMP_TABLE.productEntryId = SCProductEntry.productEntryId";
3826 private static final String _FILTER_SQL_COUNT_SCPRODUCTENTRY_WHERE = "SELECT COUNT(DISTINCT scProductEntry.productEntryId) AS COUNT_VALUE FROM SCProductEntry scProductEntry WHERE ";
3827 private static final String _FILTER_ENTITY_ALIAS = "scProductEntry";
3828 private static final String _FILTER_ENTITY_TABLE = "SCProductEntry";
3829 private static final String _ORDER_BY_ENTITY_ALIAS = "scProductEntry.";
3830 private static final String _ORDER_BY_ENTITY_TABLE = "SCProductEntry.";
3831 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No SCProductEntry exists with the primary key ";
3832 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No SCProductEntry exists with the key {";
3833 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
3834 private static Log _log = LogFactoryUtil.getLog(SCProductEntryPersistenceImpl.class);
3835 private static SCProductEntry _nullSCProductEntry = new SCProductEntryImpl() {
3836 @Override
3837 public Object clone() {
3838 return this;
3839 }
3840
3841 @Override
3842 public CacheModel<SCProductEntry> toCacheModel() {
3843 return _nullSCProductEntryCacheModel;
3844 }
3845 };
3846
3847 private static CacheModel<SCProductEntry> _nullSCProductEntryCacheModel = new CacheModel<SCProductEntry>() {
3848 public SCProductEntry toEntityModel() {
3849 return _nullSCProductEntry;
3850 }
3851 };
3852 }