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 clearUniqueFindersCache(scProductEntry);
251 }
252
253 @Override
254 public void clearCache(List<SCProductEntry> scProductEntries) {
255 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
256 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
257
258 for (SCProductEntry scProductEntry : scProductEntries) {
259 EntityCacheUtil.removeResult(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
260 SCProductEntryImpl.class, scProductEntry.getPrimaryKey());
261
262 clearUniqueFindersCache(scProductEntry);
263 }
264 }
265
266 protected void clearUniqueFindersCache(SCProductEntry scProductEntry) {
267 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_RG_RA,
268 new Object[] {
269 scProductEntry.getRepoGroupId(),
270
271 scProductEntry.getRepoArtifactId()
272 });
273 }
274
275
281 public SCProductEntry create(long productEntryId) {
282 SCProductEntry scProductEntry = new SCProductEntryImpl();
283
284 scProductEntry.setNew(true);
285 scProductEntry.setPrimaryKey(productEntryId);
286
287 return scProductEntry;
288 }
289
290
298 public SCProductEntry remove(long productEntryId)
299 throws NoSuchProductEntryException, SystemException {
300 return remove(Long.valueOf(productEntryId));
301 }
302
303
311 @Override
312 public SCProductEntry remove(Serializable primaryKey)
313 throws NoSuchProductEntryException, SystemException {
314 Session session = null;
315
316 try {
317 session = openSession();
318
319 SCProductEntry scProductEntry = (SCProductEntry)session.get(SCProductEntryImpl.class,
320 primaryKey);
321
322 if (scProductEntry == null) {
323 if (_log.isWarnEnabled()) {
324 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
325 }
326
327 throw new NoSuchProductEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
328 primaryKey);
329 }
330
331 return remove(scProductEntry);
332 }
333 catch (NoSuchProductEntryException nsee) {
334 throw nsee;
335 }
336 catch (Exception e) {
337 throw processException(e);
338 }
339 finally {
340 closeSession(session);
341 }
342 }
343
344 @Override
345 protected SCProductEntry removeImpl(SCProductEntry scProductEntry)
346 throws SystemException {
347 scProductEntry = toUnwrappedModel(scProductEntry);
348
349 try {
350 clearSCLicenses.clear(scProductEntry.getPrimaryKey());
351 }
352 catch (Exception e) {
353 throw processException(e);
354 }
355 finally {
356 FinderCacheUtil.clearCache(SCProductEntryModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
357 }
358
359 Session session = null;
360
361 try {
362 session = openSession();
363
364 BatchSessionUtil.delete(session, scProductEntry);
365 }
366 catch (Exception e) {
367 throw processException(e);
368 }
369 finally {
370 closeSession(session);
371 }
372
373 clearCache(scProductEntry);
374
375 return scProductEntry;
376 }
377
378 @Override
379 public SCProductEntry updateImpl(
380 com.liferay.portlet.softwarecatalog.model.SCProductEntry scProductEntry,
381 boolean merge) throws SystemException {
382 scProductEntry = toUnwrappedModel(scProductEntry);
383
384 boolean isNew = scProductEntry.isNew();
385
386 SCProductEntryModelImpl scProductEntryModelImpl = (SCProductEntryModelImpl)scProductEntry;
387
388 Session session = null;
389
390 try {
391 session = openSession();
392
393 BatchSessionUtil.update(session, scProductEntry, merge);
394
395 scProductEntry.setNew(false);
396 }
397 catch (Exception e) {
398 throw processException(e);
399 }
400 finally {
401 closeSession(session);
402 }
403
404 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
405
406 if (isNew || !SCProductEntryModelImpl.COLUMN_BITMASK_ENABLED) {
407 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
408 }
409
410 else {
411 if ((scProductEntryModelImpl.getColumnBitmask() &
412 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
413 Object[] args = new Object[] {
414 Long.valueOf(scProductEntryModelImpl.getOriginalGroupId())
415 };
416
417 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
418 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
419 args);
420
421 args = new Object[] {
422 Long.valueOf(scProductEntryModelImpl.getGroupId())
423 };
424
425 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
426 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
427 args);
428 }
429
430 if ((scProductEntryModelImpl.getColumnBitmask() &
431 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
432 Object[] args = new Object[] {
433 Long.valueOf(scProductEntryModelImpl.getOriginalCompanyId())
434 };
435
436 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
437 args);
438 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
439 args);
440
441 args = new Object[] {
442 Long.valueOf(scProductEntryModelImpl.getCompanyId())
443 };
444
445 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
446 args);
447 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
448 args);
449 }
450
451 if ((scProductEntryModelImpl.getColumnBitmask() &
452 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U.getColumnBitmask()) != 0) {
453 Object[] args = new Object[] {
454 Long.valueOf(scProductEntryModelImpl.getOriginalGroupId()),
455 Long.valueOf(scProductEntryModelImpl.getOriginalUserId())
456 };
457
458 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U, args);
459 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U,
460 args);
461
462 args = new Object[] {
463 Long.valueOf(scProductEntryModelImpl.getGroupId()),
464 Long.valueOf(scProductEntryModelImpl.getUserId())
465 };
466
467 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U, args);
468 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U,
469 args);
470 }
471 }
472
473 EntityCacheUtil.putResult(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
474 SCProductEntryImpl.class, scProductEntry.getPrimaryKey(),
475 scProductEntry);
476
477 if (isNew) {
478 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_RG_RA,
479 new Object[] {
480 scProductEntry.getRepoGroupId(),
481
482 scProductEntry.getRepoArtifactId()
483 }, scProductEntry);
484 }
485 else {
486 if ((scProductEntryModelImpl.getColumnBitmask() &
487 FINDER_PATH_FETCH_BY_RG_RA.getColumnBitmask()) != 0) {
488 Object[] args = new Object[] {
489 scProductEntryModelImpl.getOriginalRepoGroupId(),
490
491 scProductEntryModelImpl.getOriginalRepoArtifactId()
492 };
493
494 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_RG_RA, args);
495 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_RG_RA, args);
496
497 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_RG_RA,
498 new Object[] {
499 scProductEntry.getRepoGroupId(),
500
501 scProductEntry.getRepoArtifactId()
502 }, scProductEntry);
503 }
504 }
505
506 return scProductEntry;
507 }
508
509 protected SCProductEntry toUnwrappedModel(SCProductEntry scProductEntry) {
510 if (scProductEntry instanceof SCProductEntryImpl) {
511 return scProductEntry;
512 }
513
514 SCProductEntryImpl scProductEntryImpl = new SCProductEntryImpl();
515
516 scProductEntryImpl.setNew(scProductEntry.isNew());
517 scProductEntryImpl.setPrimaryKey(scProductEntry.getPrimaryKey());
518
519 scProductEntryImpl.setProductEntryId(scProductEntry.getProductEntryId());
520 scProductEntryImpl.setGroupId(scProductEntry.getGroupId());
521 scProductEntryImpl.setCompanyId(scProductEntry.getCompanyId());
522 scProductEntryImpl.setUserId(scProductEntry.getUserId());
523 scProductEntryImpl.setUserName(scProductEntry.getUserName());
524 scProductEntryImpl.setCreateDate(scProductEntry.getCreateDate());
525 scProductEntryImpl.setModifiedDate(scProductEntry.getModifiedDate());
526 scProductEntryImpl.setName(scProductEntry.getName());
527 scProductEntryImpl.setType(scProductEntry.getType());
528 scProductEntryImpl.setTags(scProductEntry.getTags());
529 scProductEntryImpl.setShortDescription(scProductEntry.getShortDescription());
530 scProductEntryImpl.setLongDescription(scProductEntry.getLongDescription());
531 scProductEntryImpl.setPageURL(scProductEntry.getPageURL());
532 scProductEntryImpl.setAuthor(scProductEntry.getAuthor());
533 scProductEntryImpl.setRepoGroupId(scProductEntry.getRepoGroupId());
534 scProductEntryImpl.setRepoArtifactId(scProductEntry.getRepoArtifactId());
535
536 return scProductEntryImpl;
537 }
538
539
547 @Override
548 public SCProductEntry findByPrimaryKey(Serializable primaryKey)
549 throws NoSuchModelException, SystemException {
550 return findByPrimaryKey(((Long)primaryKey).longValue());
551 }
552
553
561 public SCProductEntry findByPrimaryKey(long productEntryId)
562 throws NoSuchProductEntryException, SystemException {
563 SCProductEntry scProductEntry = fetchByPrimaryKey(productEntryId);
564
565 if (scProductEntry == null) {
566 if (_log.isWarnEnabled()) {
567 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + productEntryId);
568 }
569
570 throw new NoSuchProductEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
571 productEntryId);
572 }
573
574 return scProductEntry;
575 }
576
577
584 @Override
585 public SCProductEntry fetchByPrimaryKey(Serializable primaryKey)
586 throws SystemException {
587 return fetchByPrimaryKey(((Long)primaryKey).longValue());
588 }
589
590
597 public SCProductEntry fetchByPrimaryKey(long productEntryId)
598 throws SystemException {
599 SCProductEntry scProductEntry = (SCProductEntry)EntityCacheUtil.getResult(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
600 SCProductEntryImpl.class, productEntryId);
601
602 if (scProductEntry == _nullSCProductEntry) {
603 return null;
604 }
605
606 if (scProductEntry == null) {
607 Session session = null;
608
609 boolean hasException = false;
610
611 try {
612 session = openSession();
613
614 scProductEntry = (SCProductEntry)session.get(SCProductEntryImpl.class,
615 Long.valueOf(productEntryId));
616 }
617 catch (Exception e) {
618 hasException = true;
619
620 throw processException(e);
621 }
622 finally {
623 if (scProductEntry != null) {
624 cacheResult(scProductEntry);
625 }
626 else if (!hasException) {
627 EntityCacheUtil.putResult(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
628 SCProductEntryImpl.class, productEntryId,
629 _nullSCProductEntry);
630 }
631
632 closeSession(session);
633 }
634 }
635
636 return scProductEntry;
637 }
638
639
646 public List<SCProductEntry> findByGroupId(long groupId)
647 throws SystemException {
648 return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
649 }
650
651
664 public List<SCProductEntry> findByGroupId(long groupId, int start, int end)
665 throws SystemException {
666 return findByGroupId(groupId, start, end, null);
667 }
668
669
683 public List<SCProductEntry> findByGroupId(long groupId, int start, int end,
684 OrderByComparator orderByComparator) throws SystemException {
685 FinderPath finderPath = null;
686 Object[] finderArgs = null;
687
688 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
689 (orderByComparator == null)) {
690 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
691 finderArgs = new Object[] { groupId };
692 }
693 else {
694 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
695 finderArgs = new Object[] { groupId, start, end, orderByComparator };
696 }
697
698 List<SCProductEntry> list = (List<SCProductEntry>)FinderCacheUtil.getResult(finderPath,
699 finderArgs, this);
700
701 if (list == null) {
702 StringBundler query = null;
703
704 if (orderByComparator != null) {
705 query = new StringBundler(3 +
706 (orderByComparator.getOrderByFields().length * 3));
707 }
708 else {
709 query = new StringBundler(3);
710 }
711
712 query.append(_SQL_SELECT_SCPRODUCTENTRY_WHERE);
713
714 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
715
716 if (orderByComparator != null) {
717 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
718 orderByComparator);
719 }
720
721 else {
722 query.append(SCProductEntryModelImpl.ORDER_BY_JPQL);
723 }
724
725 String sql = query.toString();
726
727 Session session = null;
728
729 try {
730 session = openSession();
731
732 Query q = session.createQuery(sql);
733
734 QueryPos qPos = QueryPos.getInstance(q);
735
736 qPos.add(groupId);
737
738 list = (List<SCProductEntry>)QueryUtil.list(q, getDialect(),
739 start, end);
740 }
741 catch (Exception e) {
742 throw processException(e);
743 }
744 finally {
745 if (list == null) {
746 FinderCacheUtil.removeResult(finderPath, finderArgs);
747 }
748 else {
749 cacheResult(list);
750
751 FinderCacheUtil.putResult(finderPath, finderArgs, list);
752 }
753
754 closeSession(session);
755 }
756 }
757
758 return list;
759 }
760
761
774 public SCProductEntry findByGroupId_First(long groupId,
775 OrderByComparator orderByComparator)
776 throws NoSuchProductEntryException, SystemException {
777 List<SCProductEntry> list = findByGroupId(groupId, 0, 1,
778 orderByComparator);
779
780 if (list.isEmpty()) {
781 StringBundler msg = new StringBundler(4);
782
783 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
784
785 msg.append("groupId=");
786 msg.append(groupId);
787
788 msg.append(StringPool.CLOSE_CURLY_BRACE);
789
790 throw new NoSuchProductEntryException(msg.toString());
791 }
792 else {
793 return list.get(0);
794 }
795 }
796
797
810 public SCProductEntry findByGroupId_Last(long groupId,
811 OrderByComparator orderByComparator)
812 throws NoSuchProductEntryException, SystemException {
813 int count = countByGroupId(groupId);
814
815 List<SCProductEntry> list = findByGroupId(groupId, count - 1, count,
816 orderByComparator);
817
818 if (list.isEmpty()) {
819 StringBundler msg = new StringBundler(4);
820
821 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
822
823 msg.append("groupId=");
824 msg.append(groupId);
825
826 msg.append(StringPool.CLOSE_CURLY_BRACE);
827
828 throw new NoSuchProductEntryException(msg.toString());
829 }
830 else {
831 return list.get(0);
832 }
833 }
834
835
849 public SCProductEntry[] findByGroupId_PrevAndNext(long productEntryId,
850 long groupId, OrderByComparator orderByComparator)
851 throws NoSuchProductEntryException, SystemException {
852 SCProductEntry scProductEntry = findByPrimaryKey(productEntryId);
853
854 Session session = null;
855
856 try {
857 session = openSession();
858
859 SCProductEntry[] array = new SCProductEntryImpl[3];
860
861 array[0] = getByGroupId_PrevAndNext(session, scProductEntry,
862 groupId, orderByComparator, true);
863
864 array[1] = scProductEntry;
865
866 array[2] = getByGroupId_PrevAndNext(session, scProductEntry,
867 groupId, orderByComparator, false);
868
869 return array;
870 }
871 catch (Exception e) {
872 throw processException(e);
873 }
874 finally {
875 closeSession(session);
876 }
877 }
878
879 protected SCProductEntry getByGroupId_PrevAndNext(Session session,
880 SCProductEntry scProductEntry, long groupId,
881 OrderByComparator orderByComparator, boolean previous) {
882 StringBundler query = null;
883
884 if (orderByComparator != null) {
885 query = new StringBundler(6 +
886 (orderByComparator.getOrderByFields().length * 6));
887 }
888 else {
889 query = new StringBundler(3);
890 }
891
892 query.append(_SQL_SELECT_SCPRODUCTENTRY_WHERE);
893
894 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
895
896 if (orderByComparator != null) {
897 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
898
899 if (orderByConditionFields.length > 0) {
900 query.append(WHERE_AND);
901 }
902
903 for (int i = 0; i < orderByConditionFields.length; i++) {
904 query.append(_ORDER_BY_ENTITY_ALIAS);
905 query.append(orderByConditionFields[i]);
906
907 if ((i + 1) < orderByConditionFields.length) {
908 if (orderByComparator.isAscending() ^ previous) {
909 query.append(WHERE_GREATER_THAN_HAS_NEXT);
910 }
911 else {
912 query.append(WHERE_LESSER_THAN_HAS_NEXT);
913 }
914 }
915 else {
916 if (orderByComparator.isAscending() ^ previous) {
917 query.append(WHERE_GREATER_THAN);
918 }
919 else {
920 query.append(WHERE_LESSER_THAN);
921 }
922 }
923 }
924
925 query.append(ORDER_BY_CLAUSE);
926
927 String[] orderByFields = orderByComparator.getOrderByFields();
928
929 for (int i = 0; i < orderByFields.length; i++) {
930 query.append(_ORDER_BY_ENTITY_ALIAS);
931 query.append(orderByFields[i]);
932
933 if ((i + 1) < orderByFields.length) {
934 if (orderByComparator.isAscending() ^ previous) {
935 query.append(ORDER_BY_ASC_HAS_NEXT);
936 }
937 else {
938 query.append(ORDER_BY_DESC_HAS_NEXT);
939 }
940 }
941 else {
942 if (orderByComparator.isAscending() ^ previous) {
943 query.append(ORDER_BY_ASC);
944 }
945 else {
946 query.append(ORDER_BY_DESC);
947 }
948 }
949 }
950 }
951
952 else {
953 query.append(SCProductEntryModelImpl.ORDER_BY_JPQL);
954 }
955
956 String sql = query.toString();
957
958 Query q = session.createQuery(sql);
959
960 q.setFirstResult(0);
961 q.setMaxResults(2);
962
963 QueryPos qPos = QueryPos.getInstance(q);
964
965 qPos.add(groupId);
966
967 if (orderByComparator != null) {
968 Object[] values = orderByComparator.getOrderByConditionValues(scProductEntry);
969
970 for (Object value : values) {
971 qPos.add(value);
972 }
973 }
974
975 List<SCProductEntry> list = q.list();
976
977 if (list.size() == 2) {
978 return list.get(1);
979 }
980 else {
981 return null;
982 }
983 }
984
985
992 public List<SCProductEntry> filterFindByGroupId(long groupId)
993 throws SystemException {
994 return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
995 QueryUtil.ALL_POS, null);
996 }
997
998
1011 public List<SCProductEntry> filterFindByGroupId(long groupId, int start,
1012 int end) throws SystemException {
1013 return filterFindByGroupId(groupId, start, end, null);
1014 }
1015
1016
1030 public List<SCProductEntry> filterFindByGroupId(long groupId, int start,
1031 int end, OrderByComparator orderByComparator) throws SystemException {
1032 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1033 return findByGroupId(groupId, start, end, orderByComparator);
1034 }
1035
1036 StringBundler query = null;
1037
1038 if (orderByComparator != null) {
1039 query = new StringBundler(3 +
1040 (orderByComparator.getOrderByFields().length * 3));
1041 }
1042 else {
1043 query = new StringBundler(3);
1044 }
1045
1046 if (getDB().isSupportsInlineDistinct()) {
1047 query.append(_FILTER_SQL_SELECT_SCPRODUCTENTRY_WHERE);
1048 }
1049 else {
1050 query.append(_FILTER_SQL_SELECT_SCPRODUCTENTRY_NO_INLINE_DISTINCT_WHERE_1);
1051 }
1052
1053 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1054
1055 if (!getDB().isSupportsInlineDistinct()) {
1056 query.append(_FILTER_SQL_SELECT_SCPRODUCTENTRY_NO_INLINE_DISTINCT_WHERE_2);
1057 }
1058
1059 if (orderByComparator != null) {
1060 if (getDB().isSupportsInlineDistinct()) {
1061 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1062 orderByComparator);
1063 }
1064 else {
1065 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
1066 orderByComparator);
1067 }
1068 }
1069
1070 else {
1071 if (getDB().isSupportsInlineDistinct()) {
1072 query.append(SCProductEntryModelImpl.ORDER_BY_JPQL);
1073 }
1074 else {
1075 query.append(SCProductEntryModelImpl.ORDER_BY_SQL);
1076 }
1077 }
1078
1079 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1080 SCProductEntry.class.getName(),
1081 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
1082
1083 Session session = null;
1084
1085 try {
1086 session = openSession();
1087
1088 SQLQuery q = session.createSQLQuery(sql);
1089
1090 if (getDB().isSupportsInlineDistinct()) {
1091 q.addEntity(_FILTER_ENTITY_ALIAS, SCProductEntryImpl.class);
1092 }
1093 else {
1094 q.addEntity(_FILTER_ENTITY_TABLE, SCProductEntryImpl.class);
1095 }
1096
1097 QueryPos qPos = QueryPos.getInstance(q);
1098
1099 qPos.add(groupId);
1100
1101 return (List<SCProductEntry>)QueryUtil.list(q, getDialect(), start,
1102 end);
1103 }
1104 catch (Exception e) {
1105 throw processException(e);
1106 }
1107 finally {
1108 closeSession(session);
1109 }
1110 }
1111
1112
1122 public SCProductEntry[] filterFindByGroupId_PrevAndNext(
1123 long productEntryId, long groupId, OrderByComparator orderByComparator)
1124 throws NoSuchProductEntryException, SystemException {
1125 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1126 return findByGroupId_PrevAndNext(productEntryId, groupId,
1127 orderByComparator);
1128 }
1129
1130 SCProductEntry scProductEntry = findByPrimaryKey(productEntryId);
1131
1132 Session session = null;
1133
1134 try {
1135 session = openSession();
1136
1137 SCProductEntry[] array = new SCProductEntryImpl[3];
1138
1139 array[0] = filterGetByGroupId_PrevAndNext(session, scProductEntry,
1140 groupId, orderByComparator, true);
1141
1142 array[1] = scProductEntry;
1143
1144 array[2] = filterGetByGroupId_PrevAndNext(session, scProductEntry,
1145 groupId, orderByComparator, false);
1146
1147 return array;
1148 }
1149 catch (Exception e) {
1150 throw processException(e);
1151 }
1152 finally {
1153 closeSession(session);
1154 }
1155 }
1156
1157 protected SCProductEntry filterGetByGroupId_PrevAndNext(Session session,
1158 SCProductEntry scProductEntry, long groupId,
1159 OrderByComparator orderByComparator, boolean previous) {
1160 StringBundler query = null;
1161
1162 if (orderByComparator != null) {
1163 query = new StringBundler(6 +
1164 (orderByComparator.getOrderByFields().length * 6));
1165 }
1166 else {
1167 query = new StringBundler(3);
1168 }
1169
1170 if (getDB().isSupportsInlineDistinct()) {
1171 query.append(_FILTER_SQL_SELECT_SCPRODUCTENTRY_WHERE);
1172 }
1173 else {
1174 query.append(_FILTER_SQL_SELECT_SCPRODUCTENTRY_NO_INLINE_DISTINCT_WHERE_1);
1175 }
1176
1177 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1178
1179 if (!getDB().isSupportsInlineDistinct()) {
1180 query.append(_FILTER_SQL_SELECT_SCPRODUCTENTRY_NO_INLINE_DISTINCT_WHERE_2);
1181 }
1182
1183 if (orderByComparator != null) {
1184 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1185
1186 if (orderByConditionFields.length > 0) {
1187 query.append(WHERE_AND);
1188 }
1189
1190 for (int i = 0; i < orderByConditionFields.length; i++) {
1191 if (getDB().isSupportsInlineDistinct()) {
1192 query.append(_ORDER_BY_ENTITY_ALIAS);
1193 }
1194 else {
1195 query.append(_ORDER_BY_ENTITY_TABLE);
1196 }
1197
1198 query.append(orderByConditionFields[i]);
1199
1200 if ((i + 1) < orderByConditionFields.length) {
1201 if (orderByComparator.isAscending() ^ previous) {
1202 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1203 }
1204 else {
1205 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1206 }
1207 }
1208 else {
1209 if (orderByComparator.isAscending() ^ previous) {
1210 query.append(WHERE_GREATER_THAN);
1211 }
1212 else {
1213 query.append(WHERE_LESSER_THAN);
1214 }
1215 }
1216 }
1217
1218 query.append(ORDER_BY_CLAUSE);
1219
1220 String[] orderByFields = orderByComparator.getOrderByFields();
1221
1222 for (int i = 0; i < orderByFields.length; i++) {
1223 if (getDB().isSupportsInlineDistinct()) {
1224 query.append(_ORDER_BY_ENTITY_ALIAS);
1225 }
1226 else {
1227 query.append(_ORDER_BY_ENTITY_TABLE);
1228 }
1229
1230 query.append(orderByFields[i]);
1231
1232 if ((i + 1) < orderByFields.length) {
1233 if (orderByComparator.isAscending() ^ previous) {
1234 query.append(ORDER_BY_ASC_HAS_NEXT);
1235 }
1236 else {
1237 query.append(ORDER_BY_DESC_HAS_NEXT);
1238 }
1239 }
1240 else {
1241 if (orderByComparator.isAscending() ^ previous) {
1242 query.append(ORDER_BY_ASC);
1243 }
1244 else {
1245 query.append(ORDER_BY_DESC);
1246 }
1247 }
1248 }
1249 }
1250
1251 else {
1252 if (getDB().isSupportsInlineDistinct()) {
1253 query.append(SCProductEntryModelImpl.ORDER_BY_JPQL);
1254 }
1255 else {
1256 query.append(SCProductEntryModelImpl.ORDER_BY_SQL);
1257 }
1258 }
1259
1260 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1261 SCProductEntry.class.getName(),
1262 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
1263
1264 SQLQuery q = session.createSQLQuery(sql);
1265
1266 q.setFirstResult(0);
1267 q.setMaxResults(2);
1268
1269 if (getDB().isSupportsInlineDistinct()) {
1270 q.addEntity(_FILTER_ENTITY_ALIAS, SCProductEntryImpl.class);
1271 }
1272 else {
1273 q.addEntity(_FILTER_ENTITY_TABLE, SCProductEntryImpl.class);
1274 }
1275
1276 QueryPos qPos = QueryPos.getInstance(q);
1277
1278 qPos.add(groupId);
1279
1280 if (orderByComparator != null) {
1281 Object[] values = orderByComparator.getOrderByConditionValues(scProductEntry);
1282
1283 for (Object value : values) {
1284 qPos.add(value);
1285 }
1286 }
1287
1288 List<SCProductEntry> list = q.list();
1289
1290 if (list.size() == 2) {
1291 return list.get(1);
1292 }
1293 else {
1294 return null;
1295 }
1296 }
1297
1298
1305 public List<SCProductEntry> findByCompanyId(long companyId)
1306 throws SystemException {
1307 return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
1308 null);
1309 }
1310
1311
1324 public List<SCProductEntry> findByCompanyId(long companyId, int start,
1325 int end) throws SystemException {
1326 return findByCompanyId(companyId, start, end, null);
1327 }
1328
1329
1343 public List<SCProductEntry> findByCompanyId(long companyId, int start,
1344 int end, OrderByComparator orderByComparator) throws SystemException {
1345 FinderPath finderPath = null;
1346 Object[] finderArgs = null;
1347
1348 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1349 (orderByComparator == null)) {
1350 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID;
1351 finderArgs = new Object[] { companyId };
1352 }
1353 else {
1354 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID;
1355 finderArgs = new Object[] { companyId, start, end, orderByComparator };
1356 }
1357
1358 List<SCProductEntry> list = (List<SCProductEntry>)FinderCacheUtil.getResult(finderPath,
1359 finderArgs, this);
1360
1361 if (list == null) {
1362 StringBundler query = null;
1363
1364 if (orderByComparator != null) {
1365 query = new StringBundler(3 +
1366 (orderByComparator.getOrderByFields().length * 3));
1367 }
1368 else {
1369 query = new StringBundler(3);
1370 }
1371
1372 query.append(_SQL_SELECT_SCPRODUCTENTRY_WHERE);
1373
1374 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1375
1376 if (orderByComparator != null) {
1377 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1378 orderByComparator);
1379 }
1380
1381 else {
1382 query.append(SCProductEntryModelImpl.ORDER_BY_JPQL);
1383 }
1384
1385 String sql = query.toString();
1386
1387 Session session = null;
1388
1389 try {
1390 session = openSession();
1391
1392 Query q = session.createQuery(sql);
1393
1394 QueryPos qPos = QueryPos.getInstance(q);
1395
1396 qPos.add(companyId);
1397
1398 list = (List<SCProductEntry>)QueryUtil.list(q, getDialect(),
1399 start, end);
1400 }
1401 catch (Exception e) {
1402 throw processException(e);
1403 }
1404 finally {
1405 if (list == null) {
1406 FinderCacheUtil.removeResult(finderPath, finderArgs);
1407 }
1408 else {
1409 cacheResult(list);
1410
1411 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1412 }
1413
1414 closeSession(session);
1415 }
1416 }
1417
1418 return list;
1419 }
1420
1421
1434 public SCProductEntry findByCompanyId_First(long companyId,
1435 OrderByComparator orderByComparator)
1436 throws NoSuchProductEntryException, SystemException {
1437 List<SCProductEntry> list = findByCompanyId(companyId, 0, 1,
1438 orderByComparator);
1439
1440 if (list.isEmpty()) {
1441 StringBundler msg = new StringBundler(4);
1442
1443 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1444
1445 msg.append("companyId=");
1446 msg.append(companyId);
1447
1448 msg.append(StringPool.CLOSE_CURLY_BRACE);
1449
1450 throw new NoSuchProductEntryException(msg.toString());
1451 }
1452 else {
1453 return list.get(0);
1454 }
1455 }
1456
1457
1470 public SCProductEntry findByCompanyId_Last(long companyId,
1471 OrderByComparator orderByComparator)
1472 throws NoSuchProductEntryException, SystemException {
1473 int count = countByCompanyId(companyId);
1474
1475 List<SCProductEntry> list = findByCompanyId(companyId, count - 1,
1476 count, orderByComparator);
1477
1478 if (list.isEmpty()) {
1479 StringBundler msg = new StringBundler(4);
1480
1481 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1482
1483 msg.append("companyId=");
1484 msg.append(companyId);
1485
1486 msg.append(StringPool.CLOSE_CURLY_BRACE);
1487
1488 throw new NoSuchProductEntryException(msg.toString());
1489 }
1490 else {
1491 return list.get(0);
1492 }
1493 }
1494
1495
1509 public SCProductEntry[] findByCompanyId_PrevAndNext(long productEntryId,
1510 long companyId, OrderByComparator orderByComparator)
1511 throws NoSuchProductEntryException, SystemException {
1512 SCProductEntry scProductEntry = findByPrimaryKey(productEntryId);
1513
1514 Session session = null;
1515
1516 try {
1517 session = openSession();
1518
1519 SCProductEntry[] array = new SCProductEntryImpl[3];
1520
1521 array[0] = getByCompanyId_PrevAndNext(session, scProductEntry,
1522 companyId, orderByComparator, true);
1523
1524 array[1] = scProductEntry;
1525
1526 array[2] = getByCompanyId_PrevAndNext(session, scProductEntry,
1527 companyId, orderByComparator, false);
1528
1529 return array;
1530 }
1531 catch (Exception e) {
1532 throw processException(e);
1533 }
1534 finally {
1535 closeSession(session);
1536 }
1537 }
1538
1539 protected SCProductEntry getByCompanyId_PrevAndNext(Session session,
1540 SCProductEntry scProductEntry, long companyId,
1541 OrderByComparator orderByComparator, boolean previous) {
1542 StringBundler query = null;
1543
1544 if (orderByComparator != null) {
1545 query = new StringBundler(6 +
1546 (orderByComparator.getOrderByFields().length * 6));
1547 }
1548 else {
1549 query = new StringBundler(3);
1550 }
1551
1552 query.append(_SQL_SELECT_SCPRODUCTENTRY_WHERE);
1553
1554 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1555
1556 if (orderByComparator != null) {
1557 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1558
1559 if (orderByConditionFields.length > 0) {
1560 query.append(WHERE_AND);
1561 }
1562
1563 for (int i = 0; i < orderByConditionFields.length; i++) {
1564 query.append(_ORDER_BY_ENTITY_ALIAS);
1565 query.append(orderByConditionFields[i]);
1566
1567 if ((i + 1) < orderByConditionFields.length) {
1568 if (orderByComparator.isAscending() ^ previous) {
1569 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1570 }
1571 else {
1572 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1573 }
1574 }
1575 else {
1576 if (orderByComparator.isAscending() ^ previous) {
1577 query.append(WHERE_GREATER_THAN);
1578 }
1579 else {
1580 query.append(WHERE_LESSER_THAN);
1581 }
1582 }
1583 }
1584
1585 query.append(ORDER_BY_CLAUSE);
1586
1587 String[] orderByFields = orderByComparator.getOrderByFields();
1588
1589 for (int i = 0; i < orderByFields.length; i++) {
1590 query.append(_ORDER_BY_ENTITY_ALIAS);
1591 query.append(orderByFields[i]);
1592
1593 if ((i + 1) < orderByFields.length) {
1594 if (orderByComparator.isAscending() ^ previous) {
1595 query.append(ORDER_BY_ASC_HAS_NEXT);
1596 }
1597 else {
1598 query.append(ORDER_BY_DESC_HAS_NEXT);
1599 }
1600 }
1601 else {
1602 if (orderByComparator.isAscending() ^ previous) {
1603 query.append(ORDER_BY_ASC);
1604 }
1605 else {
1606 query.append(ORDER_BY_DESC);
1607 }
1608 }
1609 }
1610 }
1611
1612 else {
1613 query.append(SCProductEntryModelImpl.ORDER_BY_JPQL);
1614 }
1615
1616 String sql = query.toString();
1617
1618 Query q = session.createQuery(sql);
1619
1620 q.setFirstResult(0);
1621 q.setMaxResults(2);
1622
1623 QueryPos qPos = QueryPos.getInstance(q);
1624
1625 qPos.add(companyId);
1626
1627 if (orderByComparator != null) {
1628 Object[] values = orderByComparator.getOrderByConditionValues(scProductEntry);
1629
1630 for (Object value : values) {
1631 qPos.add(value);
1632 }
1633 }
1634
1635 List<SCProductEntry> list = q.list();
1636
1637 if (list.size() == 2) {
1638 return list.get(1);
1639 }
1640 else {
1641 return null;
1642 }
1643 }
1644
1645
1653 public List<SCProductEntry> findByG_U(long groupId, long userId)
1654 throws SystemException {
1655 return findByG_U(groupId, userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
1656 null);
1657 }
1658
1659
1673 public List<SCProductEntry> findByG_U(long groupId, long userId, int start,
1674 int end) throws SystemException {
1675 return findByG_U(groupId, userId, start, end, null);
1676 }
1677
1678
1693 public List<SCProductEntry> findByG_U(long groupId, long userId, int start,
1694 int end, OrderByComparator orderByComparator) throws SystemException {
1695 FinderPath finderPath = null;
1696 Object[] finderArgs = null;
1697
1698 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1699 (orderByComparator == null)) {
1700 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U;
1701 finderArgs = new Object[] { groupId, userId };
1702 }
1703 else {
1704 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U;
1705 finderArgs = new Object[] {
1706 groupId, userId,
1707
1708 start, end, orderByComparator
1709 };
1710 }
1711
1712 List<SCProductEntry> list = (List<SCProductEntry>)FinderCacheUtil.getResult(finderPath,
1713 finderArgs, this);
1714
1715 if (list == null) {
1716 StringBundler query = null;
1717
1718 if (orderByComparator != null) {
1719 query = new StringBundler(4 +
1720 (orderByComparator.getOrderByFields().length * 3));
1721 }
1722 else {
1723 query = new StringBundler(4);
1724 }
1725
1726 query.append(_SQL_SELECT_SCPRODUCTENTRY_WHERE);
1727
1728 query.append(_FINDER_COLUMN_G_U_GROUPID_2);
1729
1730 query.append(_FINDER_COLUMN_G_U_USERID_2);
1731
1732 if (orderByComparator != null) {
1733 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1734 orderByComparator);
1735 }
1736
1737 else {
1738 query.append(SCProductEntryModelImpl.ORDER_BY_JPQL);
1739 }
1740
1741 String sql = query.toString();
1742
1743 Session session = null;
1744
1745 try {
1746 session = openSession();
1747
1748 Query q = session.createQuery(sql);
1749
1750 QueryPos qPos = QueryPos.getInstance(q);
1751
1752 qPos.add(groupId);
1753
1754 qPos.add(userId);
1755
1756 list = (List<SCProductEntry>)QueryUtil.list(q, getDialect(),
1757 start, end);
1758 }
1759 catch (Exception e) {
1760 throw processException(e);
1761 }
1762 finally {
1763 if (list == null) {
1764 FinderCacheUtil.removeResult(finderPath, finderArgs);
1765 }
1766 else {
1767 cacheResult(list);
1768
1769 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1770 }
1771
1772 closeSession(session);
1773 }
1774 }
1775
1776 return list;
1777 }
1778
1779
1793 public SCProductEntry findByG_U_First(long groupId, long userId,
1794 OrderByComparator orderByComparator)
1795 throws NoSuchProductEntryException, SystemException {
1796 List<SCProductEntry> list = findByG_U(groupId, userId, 0, 1,
1797 orderByComparator);
1798
1799 if (list.isEmpty()) {
1800 StringBundler msg = new StringBundler(6);
1801
1802 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1803
1804 msg.append("groupId=");
1805 msg.append(groupId);
1806
1807 msg.append(", userId=");
1808 msg.append(userId);
1809
1810 msg.append(StringPool.CLOSE_CURLY_BRACE);
1811
1812 throw new NoSuchProductEntryException(msg.toString());
1813 }
1814 else {
1815 return list.get(0);
1816 }
1817 }
1818
1819
1833 public SCProductEntry findByG_U_Last(long groupId, long userId,
1834 OrderByComparator orderByComparator)
1835 throws NoSuchProductEntryException, SystemException {
1836 int count = countByG_U(groupId, userId);
1837
1838 List<SCProductEntry> list = findByG_U(groupId, userId, count - 1,
1839 count, orderByComparator);
1840
1841 if (list.isEmpty()) {
1842 StringBundler msg = new StringBundler(6);
1843
1844 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1845
1846 msg.append("groupId=");
1847 msg.append(groupId);
1848
1849 msg.append(", userId=");
1850 msg.append(userId);
1851
1852 msg.append(StringPool.CLOSE_CURLY_BRACE);
1853
1854 throw new NoSuchProductEntryException(msg.toString());
1855 }
1856 else {
1857 return list.get(0);
1858 }
1859 }
1860
1861
1876 public SCProductEntry[] findByG_U_PrevAndNext(long productEntryId,
1877 long groupId, long userId, OrderByComparator orderByComparator)
1878 throws NoSuchProductEntryException, SystemException {
1879 SCProductEntry scProductEntry = findByPrimaryKey(productEntryId);
1880
1881 Session session = null;
1882
1883 try {
1884 session = openSession();
1885
1886 SCProductEntry[] array = new SCProductEntryImpl[3];
1887
1888 array[0] = getByG_U_PrevAndNext(session, scProductEntry, groupId,
1889 userId, orderByComparator, true);
1890
1891 array[1] = scProductEntry;
1892
1893 array[2] = getByG_U_PrevAndNext(session, scProductEntry, groupId,
1894 userId, orderByComparator, false);
1895
1896 return array;
1897 }
1898 catch (Exception e) {
1899 throw processException(e);
1900 }
1901 finally {
1902 closeSession(session);
1903 }
1904 }
1905
1906 protected SCProductEntry getByG_U_PrevAndNext(Session session,
1907 SCProductEntry scProductEntry, long groupId, long userId,
1908 OrderByComparator orderByComparator, boolean previous) {
1909 StringBundler query = null;
1910
1911 if (orderByComparator != null) {
1912 query = new StringBundler(6 +
1913 (orderByComparator.getOrderByFields().length * 6));
1914 }
1915 else {
1916 query = new StringBundler(3);
1917 }
1918
1919 query.append(_SQL_SELECT_SCPRODUCTENTRY_WHERE);
1920
1921 query.append(_FINDER_COLUMN_G_U_GROUPID_2);
1922
1923 query.append(_FINDER_COLUMN_G_U_USERID_2);
1924
1925 if (orderByComparator != null) {
1926 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1927
1928 if (orderByConditionFields.length > 0) {
1929 query.append(WHERE_AND);
1930 }
1931
1932 for (int i = 0; i < orderByConditionFields.length; i++) {
1933 query.append(_ORDER_BY_ENTITY_ALIAS);
1934 query.append(orderByConditionFields[i]);
1935
1936 if ((i + 1) < orderByConditionFields.length) {
1937 if (orderByComparator.isAscending() ^ previous) {
1938 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1939 }
1940 else {
1941 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1942 }
1943 }
1944 else {
1945 if (orderByComparator.isAscending() ^ previous) {
1946 query.append(WHERE_GREATER_THAN);
1947 }
1948 else {
1949 query.append(WHERE_LESSER_THAN);
1950 }
1951 }
1952 }
1953
1954 query.append(ORDER_BY_CLAUSE);
1955
1956 String[] orderByFields = orderByComparator.getOrderByFields();
1957
1958 for (int i = 0; i < orderByFields.length; i++) {
1959 query.append(_ORDER_BY_ENTITY_ALIAS);
1960 query.append(orderByFields[i]);
1961
1962 if ((i + 1) < orderByFields.length) {
1963 if (orderByComparator.isAscending() ^ previous) {
1964 query.append(ORDER_BY_ASC_HAS_NEXT);
1965 }
1966 else {
1967 query.append(ORDER_BY_DESC_HAS_NEXT);
1968 }
1969 }
1970 else {
1971 if (orderByComparator.isAscending() ^ previous) {
1972 query.append(ORDER_BY_ASC);
1973 }
1974 else {
1975 query.append(ORDER_BY_DESC);
1976 }
1977 }
1978 }
1979 }
1980
1981 else {
1982 query.append(SCProductEntryModelImpl.ORDER_BY_JPQL);
1983 }
1984
1985 String sql = query.toString();
1986
1987 Query q = session.createQuery(sql);
1988
1989 q.setFirstResult(0);
1990 q.setMaxResults(2);
1991
1992 QueryPos qPos = QueryPos.getInstance(q);
1993
1994 qPos.add(groupId);
1995
1996 qPos.add(userId);
1997
1998 if (orderByComparator != null) {
1999 Object[] values = orderByComparator.getOrderByConditionValues(scProductEntry);
2000
2001 for (Object value : values) {
2002 qPos.add(value);
2003 }
2004 }
2005
2006 List<SCProductEntry> list = q.list();
2007
2008 if (list.size() == 2) {
2009 return list.get(1);
2010 }
2011 else {
2012 return null;
2013 }
2014 }
2015
2016
2024 public List<SCProductEntry> filterFindByG_U(long groupId, long userId)
2025 throws SystemException {
2026 return filterFindByG_U(groupId, userId, QueryUtil.ALL_POS,
2027 QueryUtil.ALL_POS, null);
2028 }
2029
2030
2044 public List<SCProductEntry> filterFindByG_U(long groupId, long userId,
2045 int start, int end) throws SystemException {
2046 return filterFindByG_U(groupId, userId, start, end, null);
2047 }
2048
2049
2064 public List<SCProductEntry> filterFindByG_U(long groupId, long userId,
2065 int start, int end, OrderByComparator orderByComparator)
2066 throws SystemException {
2067 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2068 return findByG_U(groupId, userId, start, end, orderByComparator);
2069 }
2070
2071 StringBundler query = null;
2072
2073 if (orderByComparator != null) {
2074 query = new StringBundler(4 +
2075 (orderByComparator.getOrderByFields().length * 3));
2076 }
2077 else {
2078 query = new StringBundler(4);
2079 }
2080
2081 if (getDB().isSupportsInlineDistinct()) {
2082 query.append(_FILTER_SQL_SELECT_SCPRODUCTENTRY_WHERE);
2083 }
2084 else {
2085 query.append(_FILTER_SQL_SELECT_SCPRODUCTENTRY_NO_INLINE_DISTINCT_WHERE_1);
2086 }
2087
2088 query.append(_FINDER_COLUMN_G_U_GROUPID_2);
2089
2090 query.append(_FINDER_COLUMN_G_U_USERID_2);
2091
2092 if (!getDB().isSupportsInlineDistinct()) {
2093 query.append(_FILTER_SQL_SELECT_SCPRODUCTENTRY_NO_INLINE_DISTINCT_WHERE_2);
2094 }
2095
2096 if (orderByComparator != null) {
2097 if (getDB().isSupportsInlineDistinct()) {
2098 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2099 orderByComparator);
2100 }
2101 else {
2102 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
2103 orderByComparator);
2104 }
2105 }
2106
2107 else {
2108 if (getDB().isSupportsInlineDistinct()) {
2109 query.append(SCProductEntryModelImpl.ORDER_BY_JPQL);
2110 }
2111 else {
2112 query.append(SCProductEntryModelImpl.ORDER_BY_SQL);
2113 }
2114 }
2115
2116 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2117 SCProductEntry.class.getName(),
2118 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2119
2120 Session session = null;
2121
2122 try {
2123 session = openSession();
2124
2125 SQLQuery q = session.createSQLQuery(sql);
2126
2127 if (getDB().isSupportsInlineDistinct()) {
2128 q.addEntity(_FILTER_ENTITY_ALIAS, SCProductEntryImpl.class);
2129 }
2130 else {
2131 q.addEntity(_FILTER_ENTITY_TABLE, SCProductEntryImpl.class);
2132 }
2133
2134 QueryPos qPos = QueryPos.getInstance(q);
2135
2136 qPos.add(groupId);
2137
2138 qPos.add(userId);
2139
2140 return (List<SCProductEntry>)QueryUtil.list(q, getDialect(), start,
2141 end);
2142 }
2143 catch (Exception e) {
2144 throw processException(e);
2145 }
2146 finally {
2147 closeSession(session);
2148 }
2149 }
2150
2151
2162 public SCProductEntry[] filterFindByG_U_PrevAndNext(long productEntryId,
2163 long groupId, long userId, OrderByComparator orderByComparator)
2164 throws NoSuchProductEntryException, SystemException {
2165 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2166 return findByG_U_PrevAndNext(productEntryId, groupId, userId,
2167 orderByComparator);
2168 }
2169
2170 SCProductEntry scProductEntry = findByPrimaryKey(productEntryId);
2171
2172 Session session = null;
2173
2174 try {
2175 session = openSession();
2176
2177 SCProductEntry[] array = new SCProductEntryImpl[3];
2178
2179 array[0] = filterGetByG_U_PrevAndNext(session, scProductEntry,
2180 groupId, userId, orderByComparator, true);
2181
2182 array[1] = scProductEntry;
2183
2184 array[2] = filterGetByG_U_PrevAndNext(session, scProductEntry,
2185 groupId, userId, orderByComparator, false);
2186
2187 return array;
2188 }
2189 catch (Exception e) {
2190 throw processException(e);
2191 }
2192 finally {
2193 closeSession(session);
2194 }
2195 }
2196
2197 protected SCProductEntry filterGetByG_U_PrevAndNext(Session session,
2198 SCProductEntry scProductEntry, long groupId, long userId,
2199 OrderByComparator orderByComparator, boolean previous) {
2200 StringBundler query = null;
2201
2202 if (orderByComparator != null) {
2203 query = new StringBundler(6 +
2204 (orderByComparator.getOrderByFields().length * 6));
2205 }
2206 else {
2207 query = new StringBundler(3);
2208 }
2209
2210 if (getDB().isSupportsInlineDistinct()) {
2211 query.append(_FILTER_SQL_SELECT_SCPRODUCTENTRY_WHERE);
2212 }
2213 else {
2214 query.append(_FILTER_SQL_SELECT_SCPRODUCTENTRY_NO_INLINE_DISTINCT_WHERE_1);
2215 }
2216
2217 query.append(_FINDER_COLUMN_G_U_GROUPID_2);
2218
2219 query.append(_FINDER_COLUMN_G_U_USERID_2);
2220
2221 if (!getDB().isSupportsInlineDistinct()) {
2222 query.append(_FILTER_SQL_SELECT_SCPRODUCTENTRY_NO_INLINE_DISTINCT_WHERE_2);
2223 }
2224
2225 if (orderByComparator != null) {
2226 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2227
2228 if (orderByConditionFields.length > 0) {
2229 query.append(WHERE_AND);
2230 }
2231
2232 for (int i = 0; i < orderByConditionFields.length; i++) {
2233 if (getDB().isSupportsInlineDistinct()) {
2234 query.append(_ORDER_BY_ENTITY_ALIAS);
2235 }
2236 else {
2237 query.append(_ORDER_BY_ENTITY_TABLE);
2238 }
2239
2240 query.append(orderByConditionFields[i]);
2241
2242 if ((i + 1) < orderByConditionFields.length) {
2243 if (orderByComparator.isAscending() ^ previous) {
2244 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2245 }
2246 else {
2247 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2248 }
2249 }
2250 else {
2251 if (orderByComparator.isAscending() ^ previous) {
2252 query.append(WHERE_GREATER_THAN);
2253 }
2254 else {
2255 query.append(WHERE_LESSER_THAN);
2256 }
2257 }
2258 }
2259
2260 query.append(ORDER_BY_CLAUSE);
2261
2262 String[] orderByFields = orderByComparator.getOrderByFields();
2263
2264 for (int i = 0; i < orderByFields.length; i++) {
2265 if (getDB().isSupportsInlineDistinct()) {
2266 query.append(_ORDER_BY_ENTITY_ALIAS);
2267 }
2268 else {
2269 query.append(_ORDER_BY_ENTITY_TABLE);
2270 }
2271
2272 query.append(orderByFields[i]);
2273
2274 if ((i + 1) < orderByFields.length) {
2275 if (orderByComparator.isAscending() ^ previous) {
2276 query.append(ORDER_BY_ASC_HAS_NEXT);
2277 }
2278 else {
2279 query.append(ORDER_BY_DESC_HAS_NEXT);
2280 }
2281 }
2282 else {
2283 if (orderByComparator.isAscending() ^ previous) {
2284 query.append(ORDER_BY_ASC);
2285 }
2286 else {
2287 query.append(ORDER_BY_DESC);
2288 }
2289 }
2290 }
2291 }
2292
2293 else {
2294 if (getDB().isSupportsInlineDistinct()) {
2295 query.append(SCProductEntryModelImpl.ORDER_BY_JPQL);
2296 }
2297 else {
2298 query.append(SCProductEntryModelImpl.ORDER_BY_SQL);
2299 }
2300 }
2301
2302 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2303 SCProductEntry.class.getName(),
2304 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2305
2306 SQLQuery q = session.createSQLQuery(sql);
2307
2308 q.setFirstResult(0);
2309 q.setMaxResults(2);
2310
2311 if (getDB().isSupportsInlineDistinct()) {
2312 q.addEntity(_FILTER_ENTITY_ALIAS, SCProductEntryImpl.class);
2313 }
2314 else {
2315 q.addEntity(_FILTER_ENTITY_TABLE, SCProductEntryImpl.class);
2316 }
2317
2318 QueryPos qPos = QueryPos.getInstance(q);
2319
2320 qPos.add(groupId);
2321
2322 qPos.add(userId);
2323
2324 if (orderByComparator != null) {
2325 Object[] values = orderByComparator.getOrderByConditionValues(scProductEntry);
2326
2327 for (Object value : values) {
2328 qPos.add(value);
2329 }
2330 }
2331
2332 List<SCProductEntry> list = q.list();
2333
2334 if (list.size() == 2) {
2335 return list.get(1);
2336 }
2337 else {
2338 return null;
2339 }
2340 }
2341
2342
2351 public SCProductEntry findByRG_RA(String repoGroupId, String repoArtifactId)
2352 throws NoSuchProductEntryException, SystemException {
2353 SCProductEntry scProductEntry = fetchByRG_RA(repoGroupId, repoArtifactId);
2354
2355 if (scProductEntry == null) {
2356 StringBundler msg = new StringBundler(6);
2357
2358 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2359
2360 msg.append("repoGroupId=");
2361 msg.append(repoGroupId);
2362
2363 msg.append(", repoArtifactId=");
2364 msg.append(repoArtifactId);
2365
2366 msg.append(StringPool.CLOSE_CURLY_BRACE);
2367
2368 if (_log.isWarnEnabled()) {
2369 _log.warn(msg.toString());
2370 }
2371
2372 throw new NoSuchProductEntryException(msg.toString());
2373 }
2374
2375 return scProductEntry;
2376 }
2377
2378
2386 public SCProductEntry fetchByRG_RA(String repoGroupId, String repoArtifactId)
2387 throws SystemException {
2388 return fetchByRG_RA(repoGroupId, repoArtifactId, true);
2389 }
2390
2391
2400 public SCProductEntry fetchByRG_RA(String repoGroupId,
2401 String repoArtifactId, boolean retrieveFromCache)
2402 throws SystemException {
2403 Object[] finderArgs = new Object[] { repoGroupId, repoArtifactId };
2404
2405 Object result = null;
2406
2407 if (retrieveFromCache) {
2408 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_RG_RA,
2409 finderArgs, this);
2410 }
2411
2412 if (result == null) {
2413 StringBundler query = new StringBundler(4);
2414
2415 query.append(_SQL_SELECT_SCPRODUCTENTRY_WHERE);
2416
2417 if (repoGroupId == null) {
2418 query.append(_FINDER_COLUMN_RG_RA_REPOGROUPID_1);
2419 }
2420 else {
2421 if (repoGroupId.equals(StringPool.BLANK)) {
2422 query.append(_FINDER_COLUMN_RG_RA_REPOGROUPID_3);
2423 }
2424 else {
2425 query.append(_FINDER_COLUMN_RG_RA_REPOGROUPID_2);
2426 }
2427 }
2428
2429 if (repoArtifactId == null) {
2430 query.append(_FINDER_COLUMN_RG_RA_REPOARTIFACTID_1);
2431 }
2432 else {
2433 if (repoArtifactId.equals(StringPool.BLANK)) {
2434 query.append(_FINDER_COLUMN_RG_RA_REPOARTIFACTID_3);
2435 }
2436 else {
2437 query.append(_FINDER_COLUMN_RG_RA_REPOARTIFACTID_2);
2438 }
2439 }
2440
2441 query.append(SCProductEntryModelImpl.ORDER_BY_JPQL);
2442
2443 String sql = query.toString();
2444
2445 Session session = null;
2446
2447 try {
2448 session = openSession();
2449
2450 Query q = session.createQuery(sql);
2451
2452 QueryPos qPos = QueryPos.getInstance(q);
2453
2454 if (repoGroupId != null) {
2455 qPos.add(repoGroupId);
2456 }
2457
2458 if (repoArtifactId != null) {
2459 qPos.add(repoArtifactId);
2460 }
2461
2462 List<SCProductEntry> list = q.list();
2463
2464 result = list;
2465
2466 SCProductEntry scProductEntry = null;
2467
2468 if (list.isEmpty()) {
2469 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_RG_RA,
2470 finderArgs, list);
2471 }
2472 else {
2473 scProductEntry = list.get(0);
2474
2475 cacheResult(scProductEntry);
2476
2477 if ((scProductEntry.getRepoGroupId() == null) ||
2478 !scProductEntry.getRepoGroupId().equals(repoGroupId) ||
2479 (scProductEntry.getRepoArtifactId() == null) ||
2480 !scProductEntry.getRepoArtifactId()
2481 .equals(repoArtifactId)) {
2482 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_RG_RA,
2483 finderArgs, scProductEntry);
2484 }
2485 }
2486
2487 return scProductEntry;
2488 }
2489 catch (Exception e) {
2490 throw processException(e);
2491 }
2492 finally {
2493 if (result == null) {
2494 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_RG_RA,
2495 finderArgs);
2496 }
2497
2498 closeSession(session);
2499 }
2500 }
2501 else {
2502 if (result instanceof List<?>) {
2503 return null;
2504 }
2505 else {
2506 return (SCProductEntry)result;
2507 }
2508 }
2509 }
2510
2511
2517 public List<SCProductEntry> findAll() throws SystemException {
2518 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2519 }
2520
2521
2533 public List<SCProductEntry> findAll(int start, int end)
2534 throws SystemException {
2535 return findAll(start, end, null);
2536 }
2537
2538
2551 public List<SCProductEntry> findAll(int start, int end,
2552 OrderByComparator orderByComparator) throws SystemException {
2553 FinderPath finderPath = null;
2554 Object[] finderArgs = new Object[] { start, end, orderByComparator };
2555
2556 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2557 (orderByComparator == null)) {
2558 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
2559 finderArgs = FINDER_ARGS_EMPTY;
2560 }
2561 else {
2562 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
2563 finderArgs = new Object[] { start, end, orderByComparator };
2564 }
2565
2566 List<SCProductEntry> list = (List<SCProductEntry>)FinderCacheUtil.getResult(finderPath,
2567 finderArgs, this);
2568
2569 if (list == null) {
2570 StringBundler query = null;
2571 String sql = null;
2572
2573 if (orderByComparator != null) {
2574 query = new StringBundler(2 +
2575 (orderByComparator.getOrderByFields().length * 3));
2576
2577 query.append(_SQL_SELECT_SCPRODUCTENTRY);
2578
2579 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2580 orderByComparator);
2581
2582 sql = query.toString();
2583 }
2584 else {
2585 sql = _SQL_SELECT_SCPRODUCTENTRY.concat(SCProductEntryModelImpl.ORDER_BY_JPQL);
2586 }
2587
2588 Session session = null;
2589
2590 try {
2591 session = openSession();
2592
2593 Query q = session.createQuery(sql);
2594
2595 if (orderByComparator == null) {
2596 list = (List<SCProductEntry>)QueryUtil.list(q,
2597 getDialect(), start, end, false);
2598
2599 Collections.sort(list);
2600 }
2601 else {
2602 list = (List<SCProductEntry>)QueryUtil.list(q,
2603 getDialect(), start, end);
2604 }
2605 }
2606 catch (Exception e) {
2607 throw processException(e);
2608 }
2609 finally {
2610 if (list == null) {
2611 FinderCacheUtil.removeResult(finderPath, finderArgs);
2612 }
2613 else {
2614 cacheResult(list);
2615
2616 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2617 }
2618
2619 closeSession(session);
2620 }
2621 }
2622
2623 return list;
2624 }
2625
2626
2632 public void removeByGroupId(long groupId) throws SystemException {
2633 for (SCProductEntry scProductEntry : findByGroupId(groupId)) {
2634 remove(scProductEntry);
2635 }
2636 }
2637
2638
2644 public void removeByCompanyId(long companyId) throws SystemException {
2645 for (SCProductEntry scProductEntry : findByCompanyId(companyId)) {
2646 remove(scProductEntry);
2647 }
2648 }
2649
2650
2657 public void removeByG_U(long groupId, long userId)
2658 throws SystemException {
2659 for (SCProductEntry scProductEntry : findByG_U(groupId, userId)) {
2660 remove(scProductEntry);
2661 }
2662 }
2663
2664
2671 public void removeByRG_RA(String repoGroupId, String repoArtifactId)
2672 throws NoSuchProductEntryException, SystemException {
2673 SCProductEntry scProductEntry = findByRG_RA(repoGroupId, repoArtifactId);
2674
2675 remove(scProductEntry);
2676 }
2677
2678
2683 public void removeAll() throws SystemException {
2684 for (SCProductEntry scProductEntry : findAll()) {
2685 remove(scProductEntry);
2686 }
2687 }
2688
2689
2696 public int countByGroupId(long groupId) throws SystemException {
2697 Object[] finderArgs = new Object[] { groupId };
2698
2699 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
2700 finderArgs, this);
2701
2702 if (count == null) {
2703 StringBundler query = new StringBundler(2);
2704
2705 query.append(_SQL_COUNT_SCPRODUCTENTRY_WHERE);
2706
2707 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2708
2709 String sql = query.toString();
2710
2711 Session session = null;
2712
2713 try {
2714 session = openSession();
2715
2716 Query q = session.createQuery(sql);
2717
2718 QueryPos qPos = QueryPos.getInstance(q);
2719
2720 qPos.add(groupId);
2721
2722 count = (Long)q.uniqueResult();
2723 }
2724 catch (Exception e) {
2725 throw processException(e);
2726 }
2727 finally {
2728 if (count == null) {
2729 count = Long.valueOf(0);
2730 }
2731
2732 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
2733 finderArgs, count);
2734
2735 closeSession(session);
2736 }
2737 }
2738
2739 return count.intValue();
2740 }
2741
2742
2749 public int filterCountByGroupId(long groupId) throws SystemException {
2750 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2751 return countByGroupId(groupId);
2752 }
2753
2754 StringBundler query = new StringBundler(2);
2755
2756 query.append(_FILTER_SQL_COUNT_SCPRODUCTENTRY_WHERE);
2757
2758 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2759
2760 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2761 SCProductEntry.class.getName(),
2762 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2763
2764 Session session = null;
2765
2766 try {
2767 session = openSession();
2768
2769 SQLQuery q = session.createSQLQuery(sql);
2770
2771 q.addScalar(COUNT_COLUMN_NAME,
2772 com.liferay.portal.kernel.dao.orm.Type.LONG);
2773
2774 QueryPos qPos = QueryPos.getInstance(q);
2775
2776 qPos.add(groupId);
2777
2778 Long count = (Long)q.uniqueResult();
2779
2780 return count.intValue();
2781 }
2782 catch (Exception e) {
2783 throw processException(e);
2784 }
2785 finally {
2786 closeSession(session);
2787 }
2788 }
2789
2790
2797 public int countByCompanyId(long companyId) throws SystemException {
2798 Object[] finderArgs = new Object[] { companyId };
2799
2800 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
2801 finderArgs, this);
2802
2803 if (count == null) {
2804 StringBundler query = new StringBundler(2);
2805
2806 query.append(_SQL_COUNT_SCPRODUCTENTRY_WHERE);
2807
2808 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2809
2810 String sql = query.toString();
2811
2812 Session session = null;
2813
2814 try {
2815 session = openSession();
2816
2817 Query q = session.createQuery(sql);
2818
2819 QueryPos qPos = QueryPos.getInstance(q);
2820
2821 qPos.add(companyId);
2822
2823 count = (Long)q.uniqueResult();
2824 }
2825 catch (Exception e) {
2826 throw processException(e);
2827 }
2828 finally {
2829 if (count == null) {
2830 count = Long.valueOf(0);
2831 }
2832
2833 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
2834 finderArgs, count);
2835
2836 closeSession(session);
2837 }
2838 }
2839
2840 return count.intValue();
2841 }
2842
2843
2851 public int countByG_U(long groupId, long userId) throws SystemException {
2852 Object[] finderArgs = new Object[] { groupId, userId };
2853
2854 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_U,
2855 finderArgs, this);
2856
2857 if (count == null) {
2858 StringBundler query = new StringBundler(3);
2859
2860 query.append(_SQL_COUNT_SCPRODUCTENTRY_WHERE);
2861
2862 query.append(_FINDER_COLUMN_G_U_GROUPID_2);
2863
2864 query.append(_FINDER_COLUMN_G_U_USERID_2);
2865
2866 String sql = query.toString();
2867
2868 Session session = null;
2869
2870 try {
2871 session = openSession();
2872
2873 Query q = session.createQuery(sql);
2874
2875 QueryPos qPos = QueryPos.getInstance(q);
2876
2877 qPos.add(groupId);
2878
2879 qPos.add(userId);
2880
2881 count = (Long)q.uniqueResult();
2882 }
2883 catch (Exception e) {
2884 throw processException(e);
2885 }
2886 finally {
2887 if (count == null) {
2888 count = Long.valueOf(0);
2889 }
2890
2891 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_U, finderArgs,
2892 count);
2893
2894 closeSession(session);
2895 }
2896 }
2897
2898 return count.intValue();
2899 }
2900
2901
2909 public int filterCountByG_U(long groupId, long userId)
2910 throws SystemException {
2911 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2912 return countByG_U(groupId, userId);
2913 }
2914
2915 StringBundler query = new StringBundler(3);
2916
2917 query.append(_FILTER_SQL_COUNT_SCPRODUCTENTRY_WHERE);
2918
2919 query.append(_FINDER_COLUMN_G_U_GROUPID_2);
2920
2921 query.append(_FINDER_COLUMN_G_U_USERID_2);
2922
2923 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2924 SCProductEntry.class.getName(),
2925 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2926
2927 Session session = null;
2928
2929 try {
2930 session = openSession();
2931
2932 SQLQuery q = session.createSQLQuery(sql);
2933
2934 q.addScalar(COUNT_COLUMN_NAME,
2935 com.liferay.portal.kernel.dao.orm.Type.LONG);
2936
2937 QueryPos qPos = QueryPos.getInstance(q);
2938
2939 qPos.add(groupId);
2940
2941 qPos.add(userId);
2942
2943 Long count = (Long)q.uniqueResult();
2944
2945 return count.intValue();
2946 }
2947 catch (Exception e) {
2948 throw processException(e);
2949 }
2950 finally {
2951 closeSession(session);
2952 }
2953 }
2954
2955
2963 public int countByRG_RA(String repoGroupId, String repoArtifactId)
2964 throws SystemException {
2965 Object[] finderArgs = new Object[] { repoGroupId, repoArtifactId };
2966
2967 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_RG_RA,
2968 finderArgs, this);
2969
2970 if (count == null) {
2971 StringBundler query = new StringBundler(3);
2972
2973 query.append(_SQL_COUNT_SCPRODUCTENTRY_WHERE);
2974
2975 if (repoGroupId == null) {
2976 query.append(_FINDER_COLUMN_RG_RA_REPOGROUPID_1);
2977 }
2978 else {
2979 if (repoGroupId.equals(StringPool.BLANK)) {
2980 query.append(_FINDER_COLUMN_RG_RA_REPOGROUPID_3);
2981 }
2982 else {
2983 query.append(_FINDER_COLUMN_RG_RA_REPOGROUPID_2);
2984 }
2985 }
2986
2987 if (repoArtifactId == null) {
2988 query.append(_FINDER_COLUMN_RG_RA_REPOARTIFACTID_1);
2989 }
2990 else {
2991 if (repoArtifactId.equals(StringPool.BLANK)) {
2992 query.append(_FINDER_COLUMN_RG_RA_REPOARTIFACTID_3);
2993 }
2994 else {
2995 query.append(_FINDER_COLUMN_RG_RA_REPOARTIFACTID_2);
2996 }
2997 }
2998
2999 String sql = query.toString();
3000
3001 Session session = null;
3002
3003 try {
3004 session = openSession();
3005
3006 Query q = session.createQuery(sql);
3007
3008 QueryPos qPos = QueryPos.getInstance(q);
3009
3010 if (repoGroupId != null) {
3011 qPos.add(repoGroupId);
3012 }
3013
3014 if (repoArtifactId != null) {
3015 qPos.add(repoArtifactId);
3016 }
3017
3018 count = (Long)q.uniqueResult();
3019 }
3020 catch (Exception e) {
3021 throw processException(e);
3022 }
3023 finally {
3024 if (count == null) {
3025 count = Long.valueOf(0);
3026 }
3027
3028 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_RG_RA,
3029 finderArgs, count);
3030
3031 closeSession(session);
3032 }
3033 }
3034
3035 return count.intValue();
3036 }
3037
3038
3044 public int countAll() throws SystemException {
3045 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
3046 FINDER_ARGS_EMPTY, this);
3047
3048 if (count == null) {
3049 Session session = null;
3050
3051 try {
3052 session = openSession();
3053
3054 Query q = session.createQuery(_SQL_COUNT_SCPRODUCTENTRY);
3055
3056 count = (Long)q.uniqueResult();
3057 }
3058 catch (Exception e) {
3059 throw processException(e);
3060 }
3061 finally {
3062 if (count == null) {
3063 count = Long.valueOf(0);
3064 }
3065
3066 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
3067 FINDER_ARGS_EMPTY, count);
3068
3069 closeSession(session);
3070 }
3071 }
3072
3073 return count.intValue();
3074 }
3075
3076
3083 public List<com.liferay.portlet.softwarecatalog.model.SCLicense> getSCLicenses(
3084 long pk) throws SystemException {
3085 return getSCLicenses(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
3086 }
3087
3088
3101 public List<com.liferay.portlet.softwarecatalog.model.SCLicense> getSCLicenses(
3102 long pk, int start, int end) throws SystemException {
3103 return getSCLicenses(pk, start, end, null);
3104 }
3105
3106 public static final FinderPath FINDER_PATH_GET_SCLICENSES = new FinderPath(com.liferay.portlet.softwarecatalog.model.impl.SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
3107 SCProductEntryModelImpl.FINDER_CACHE_ENABLED_SCLICENSES_SCPRODUCTENTRIES,
3108 com.liferay.portlet.softwarecatalog.model.impl.SCLicenseImpl.class,
3109 SCProductEntryModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME,
3110 "getSCLicenses",
3111 new String[] {
3112 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
3113 "com.liferay.portal.kernel.util.OrderByComparator"
3114 });
3115
3116
3130 public List<com.liferay.portlet.softwarecatalog.model.SCLicense> getSCLicenses(
3131 long pk, int start, int end, OrderByComparator orderByComparator)
3132 throws SystemException {
3133 Object[] finderArgs = new Object[] { pk, start, end, orderByComparator };
3134
3135 List<com.liferay.portlet.softwarecatalog.model.SCLicense> list = (List<com.liferay.portlet.softwarecatalog.model.SCLicense>)FinderCacheUtil.getResult(FINDER_PATH_GET_SCLICENSES,
3136 finderArgs, this);
3137
3138 if (list == null) {
3139 Session session = null;
3140
3141 try {
3142 session = openSession();
3143
3144 String sql = null;
3145
3146 if (orderByComparator != null) {
3147 sql = _SQL_GETSCLICENSES.concat(ORDER_BY_CLAUSE)
3148 .concat(orderByComparator.getOrderBy());
3149 }
3150 else {
3151 sql = _SQL_GETSCLICENSES.concat(com.liferay.portlet.softwarecatalog.model.impl.SCLicenseModelImpl.ORDER_BY_SQL);
3152 }
3153
3154 SQLQuery q = session.createSQLQuery(sql);
3155
3156 q.addEntity("SCLicense",
3157 com.liferay.portlet.softwarecatalog.model.impl.SCLicenseImpl.class);
3158
3159 QueryPos qPos = QueryPos.getInstance(q);
3160
3161 qPos.add(pk);
3162
3163 list = (List<com.liferay.portlet.softwarecatalog.model.SCLicense>)QueryUtil.list(q,
3164 getDialect(), start, end);
3165 }
3166 catch (Exception e) {
3167 throw processException(e);
3168 }
3169 finally {
3170 if (list == null) {
3171 FinderCacheUtil.removeResult(FINDER_PATH_GET_SCLICENSES,
3172 finderArgs);
3173 }
3174 else {
3175 scLicensePersistence.cacheResult(list);
3176
3177 FinderCacheUtil.putResult(FINDER_PATH_GET_SCLICENSES,
3178 finderArgs, list);
3179 }
3180
3181 closeSession(session);
3182 }
3183 }
3184
3185 return list;
3186 }
3187
3188 public static final FinderPath FINDER_PATH_GET_SCLICENSES_SIZE = new FinderPath(com.liferay.portlet.softwarecatalog.model.impl.SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
3189 SCProductEntryModelImpl.FINDER_CACHE_ENABLED_SCLICENSES_SCPRODUCTENTRIES,
3190 Long.class,
3191 SCProductEntryModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME,
3192 "getSCLicensesSize", new String[] { Long.class.getName() });
3193
3194
3201 public int getSCLicensesSize(long pk) throws SystemException {
3202 Object[] finderArgs = new Object[] { pk };
3203
3204 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_SCLICENSES_SIZE,
3205 finderArgs, this);
3206
3207 if (count == null) {
3208 Session session = null;
3209
3210 try {
3211 session = openSession();
3212
3213 SQLQuery q = session.createSQLQuery(_SQL_GETSCLICENSESSIZE);
3214
3215 q.addScalar(COUNT_COLUMN_NAME,
3216 com.liferay.portal.kernel.dao.orm.Type.LONG);
3217
3218 QueryPos qPos = QueryPos.getInstance(q);
3219
3220 qPos.add(pk);
3221
3222 count = (Long)q.uniqueResult();
3223 }
3224 catch (Exception e) {
3225 throw processException(e);
3226 }
3227 finally {
3228 if (count == null) {
3229 count = Long.valueOf(0);
3230 }
3231
3232 FinderCacheUtil.putResult(FINDER_PATH_GET_SCLICENSES_SIZE,
3233 finderArgs, count);
3234
3235 closeSession(session);
3236 }
3237 }
3238
3239 return count.intValue();
3240 }
3241
3242 public static final FinderPath FINDER_PATH_CONTAINS_SCLICENSE = new FinderPath(com.liferay.portlet.softwarecatalog.model.impl.SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
3243 SCProductEntryModelImpl.FINDER_CACHE_ENABLED_SCLICENSES_SCPRODUCTENTRIES,
3244 Boolean.class,
3245 SCProductEntryModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME,
3246 "containsSCLicense",
3247 new String[] { Long.class.getName(), Long.class.getName() });
3248
3249
3257 public boolean containsSCLicense(long pk, long scLicensePK)
3258 throws SystemException {
3259 Object[] finderArgs = new Object[] { pk, scLicensePK };
3260
3261 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_SCLICENSE,
3262 finderArgs, this);
3263
3264 if (value == null) {
3265 try {
3266 value = Boolean.valueOf(containsSCLicense.contains(pk,
3267 scLicensePK));
3268 }
3269 catch (Exception e) {
3270 throw processException(e);
3271 }
3272 finally {
3273 if (value == null) {
3274 value = Boolean.FALSE;
3275 }
3276
3277 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_SCLICENSE,
3278 finderArgs, value);
3279 }
3280 }
3281
3282 return value.booleanValue();
3283 }
3284
3285
3292 public boolean containsSCLicenses(long pk) throws SystemException {
3293 if (getSCLicensesSize(pk) > 0) {
3294 return true;
3295 }
3296 else {
3297 return false;
3298 }
3299 }
3300
3301
3308 public void addSCLicense(long pk, long scLicensePK)
3309 throws SystemException {
3310 try {
3311 addSCLicense.add(pk, scLicensePK);
3312 }
3313 catch (Exception e) {
3314 throw processException(e);
3315 }
3316 finally {
3317 FinderCacheUtil.clearCache(SCProductEntryModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
3318 }
3319 }
3320
3321
3328 public void addSCLicense(long pk,
3329 com.liferay.portlet.softwarecatalog.model.SCLicense scLicense)
3330 throws SystemException {
3331 try {
3332 addSCLicense.add(pk, scLicense.getPrimaryKey());
3333 }
3334 catch (Exception e) {
3335 throw processException(e);
3336 }
3337 finally {
3338 FinderCacheUtil.clearCache(SCProductEntryModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
3339 }
3340 }
3341
3342
3349 public void addSCLicenses(long pk, long[] scLicensePKs)
3350 throws SystemException {
3351 try {
3352 for (long scLicensePK : scLicensePKs) {
3353 addSCLicense.add(pk, scLicensePK);
3354 }
3355 }
3356 catch (Exception e) {
3357 throw processException(e);
3358 }
3359 finally {
3360 FinderCacheUtil.clearCache(SCProductEntryModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
3361 }
3362 }
3363
3364
3371 public void addSCLicenses(long pk,
3372 List<com.liferay.portlet.softwarecatalog.model.SCLicense> scLicenses)
3373 throws SystemException {
3374 try {
3375 for (com.liferay.portlet.softwarecatalog.model.SCLicense scLicense : scLicenses) {
3376 addSCLicense.add(pk, scLicense.getPrimaryKey());
3377 }
3378 }
3379 catch (Exception e) {
3380 throw processException(e);
3381 }
3382 finally {
3383 FinderCacheUtil.clearCache(SCProductEntryModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
3384 }
3385 }
3386
3387
3393 public void clearSCLicenses(long pk) throws SystemException {
3394 try {
3395 clearSCLicenses.clear(pk);
3396 }
3397 catch (Exception e) {
3398 throw processException(e);
3399 }
3400 finally {
3401 FinderCacheUtil.clearCache(SCProductEntryModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
3402 }
3403 }
3404
3405
3412 public void removeSCLicense(long pk, long scLicensePK)
3413 throws SystemException {
3414 try {
3415 removeSCLicense.remove(pk, scLicensePK);
3416 }
3417 catch (Exception e) {
3418 throw processException(e);
3419 }
3420 finally {
3421 FinderCacheUtil.clearCache(SCProductEntryModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
3422 }
3423 }
3424
3425
3432 public void removeSCLicense(long pk,
3433 com.liferay.portlet.softwarecatalog.model.SCLicense scLicense)
3434 throws SystemException {
3435 try {
3436 removeSCLicense.remove(pk, scLicense.getPrimaryKey());
3437 }
3438 catch (Exception e) {
3439 throw processException(e);
3440 }
3441 finally {
3442 FinderCacheUtil.clearCache(SCProductEntryModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
3443 }
3444 }
3445
3446
3453 public void removeSCLicenses(long pk, long[] scLicensePKs)
3454 throws SystemException {
3455 try {
3456 for (long scLicensePK : scLicensePKs) {
3457 removeSCLicense.remove(pk, scLicensePK);
3458 }
3459 }
3460 catch (Exception e) {
3461 throw processException(e);
3462 }
3463 finally {
3464 FinderCacheUtil.clearCache(SCProductEntryModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
3465 }
3466 }
3467
3468
3475 public void removeSCLicenses(long pk,
3476 List<com.liferay.portlet.softwarecatalog.model.SCLicense> scLicenses)
3477 throws SystemException {
3478 try {
3479 for (com.liferay.portlet.softwarecatalog.model.SCLicense scLicense : scLicenses) {
3480 removeSCLicense.remove(pk, scLicense.getPrimaryKey());
3481 }
3482 }
3483 catch (Exception e) {
3484 throw processException(e);
3485 }
3486 finally {
3487 FinderCacheUtil.clearCache(SCProductEntryModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
3488 }
3489 }
3490
3491
3498 public void setSCLicenses(long pk, long[] scLicensePKs)
3499 throws SystemException {
3500 try {
3501 Set<Long> scLicensePKSet = SetUtil.fromArray(scLicensePKs);
3502
3503 List<com.liferay.portlet.softwarecatalog.model.SCLicense> scLicenses =
3504 getSCLicenses(pk);
3505
3506 for (com.liferay.portlet.softwarecatalog.model.SCLicense scLicense : scLicenses) {
3507 if (!scLicensePKSet.remove(scLicense.getPrimaryKey())) {
3508 removeSCLicense.remove(pk, scLicense.getPrimaryKey());
3509 }
3510 }
3511
3512 for (Long scLicensePK : scLicensePKSet) {
3513 addSCLicense.add(pk, scLicensePK);
3514 }
3515 }
3516 catch (Exception e) {
3517 throw processException(e);
3518 }
3519 finally {
3520 FinderCacheUtil.clearCache(SCProductEntryModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
3521 }
3522 }
3523
3524
3531 public void setSCLicenses(long pk,
3532 List<com.liferay.portlet.softwarecatalog.model.SCLicense> scLicenses)
3533 throws SystemException {
3534 try {
3535 long[] scLicensePKs = new long[scLicenses.size()];
3536
3537 for (int i = 0; i < scLicenses.size(); i++) {
3538 com.liferay.portlet.softwarecatalog.model.SCLicense scLicense = scLicenses.get(i);
3539
3540 scLicensePKs[i] = scLicense.getPrimaryKey();
3541 }
3542
3543 setSCLicenses(pk, scLicensePKs);
3544 }
3545 catch (Exception e) {
3546 throw processException(e);
3547 }
3548 finally {
3549 FinderCacheUtil.clearCache(SCProductEntryModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
3550 }
3551 }
3552
3553
3556 public void afterPropertiesSet() {
3557 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
3558 com.liferay.portal.util.PropsUtil.get(
3559 "value.object.listener.com.liferay.portlet.softwarecatalog.model.SCProductEntry")));
3560
3561 if (listenerClassNames.length > 0) {
3562 try {
3563 List<ModelListener<SCProductEntry>> listenersList = new ArrayList<ModelListener<SCProductEntry>>();
3564
3565 for (String listenerClassName : listenerClassNames) {
3566 listenersList.add((ModelListener<SCProductEntry>)InstanceFactory.newInstance(
3567 listenerClassName));
3568 }
3569
3570 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
3571 }
3572 catch (Exception e) {
3573 _log.error(e);
3574 }
3575 }
3576
3577 containsSCLicense = new ContainsSCLicense();
3578
3579 addSCLicense = new AddSCLicense();
3580 clearSCLicenses = new ClearSCLicenses();
3581 removeSCLicense = new RemoveSCLicense();
3582 }
3583
3584 public void destroy() {
3585 EntityCacheUtil.removeCache(SCProductEntryImpl.class.getName());
3586 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
3587 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
3588 }
3589
3590 @BeanReference(type = SCFrameworkVersionPersistence.class)
3591 protected SCFrameworkVersionPersistence scFrameworkVersionPersistence;
3592 @BeanReference(type = SCLicensePersistence.class)
3593 protected SCLicensePersistence scLicensePersistence;
3594 @BeanReference(type = SCProductEntryPersistence.class)
3595 protected SCProductEntryPersistence scProductEntryPersistence;
3596 @BeanReference(type = SCProductScreenshotPersistence.class)
3597 protected SCProductScreenshotPersistence scProductScreenshotPersistence;
3598 @BeanReference(type = SCProductVersionPersistence.class)
3599 protected SCProductVersionPersistence scProductVersionPersistence;
3600 @BeanReference(type = GroupPersistence.class)
3601 protected GroupPersistence groupPersistence;
3602 @BeanReference(type = ImagePersistence.class)
3603 protected ImagePersistence imagePersistence;
3604 @BeanReference(type = ResourcePersistence.class)
3605 protected ResourcePersistence resourcePersistence;
3606 @BeanReference(type = UserPersistence.class)
3607 protected UserPersistence userPersistence;
3608 @BeanReference(type = MBMessagePersistence.class)
3609 protected MBMessagePersistence mbMessagePersistence;
3610 @BeanReference(type = RatingsStatsPersistence.class)
3611 protected RatingsStatsPersistence ratingsStatsPersistence;
3612 protected ContainsSCLicense containsSCLicense;
3613 protected AddSCLicense addSCLicense;
3614 protected ClearSCLicenses clearSCLicenses;
3615 protected RemoveSCLicense removeSCLicense;
3616
3617 protected class ContainsSCLicense {
3618 protected ContainsSCLicense() {
3619 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
3620 _SQL_CONTAINSSCLICENSE,
3621 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
3622 RowMapper.COUNT);
3623 }
3624
3625 protected boolean contains(long productEntryId, long licenseId) {
3626 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
3627 new Long(productEntryId), new Long(licenseId)
3628 });
3629
3630 if (results.size() > 0) {
3631 Integer count = results.get(0);
3632
3633 if (count.intValue() > 0) {
3634 return true;
3635 }
3636 }
3637
3638 return false;
3639 }
3640
3641 private MappingSqlQuery<Integer> _mappingSqlQuery;
3642 }
3643
3644 protected class AddSCLicense {
3645 protected AddSCLicense() {
3646 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
3647 "INSERT INTO SCLicenses_SCProductEntries (productEntryId, licenseId) VALUES (?, ?)",
3648 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
3649 }
3650
3651 protected void add(long productEntryId, long licenseId)
3652 throws SystemException {
3653 if (!containsSCLicense.contains(productEntryId, licenseId)) {
3654 ModelListener<com.liferay.portlet.softwarecatalog.model.SCLicense>[] scLicenseListeners =
3655 scLicensePersistence.getListeners();
3656
3657 for (ModelListener<SCProductEntry> listener : listeners) {
3658 listener.onBeforeAddAssociation(productEntryId,
3659 com.liferay.portlet.softwarecatalog.model.SCLicense.class.getName(),
3660 licenseId);
3661 }
3662
3663 for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCLicense> listener : scLicenseListeners) {
3664 listener.onBeforeAddAssociation(licenseId,
3665 SCProductEntry.class.getName(), productEntryId);
3666 }
3667
3668 _sqlUpdate.update(new Object[] {
3669 new Long(productEntryId), new Long(licenseId)
3670 });
3671
3672 for (ModelListener<SCProductEntry> listener : listeners) {
3673 listener.onAfterAddAssociation(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.onAfterAddAssociation(licenseId,
3680 SCProductEntry.class.getName(), productEntryId);
3681 }
3682 }
3683 }
3684
3685 private SqlUpdate _sqlUpdate;
3686 }
3687
3688 protected class ClearSCLicenses {
3689 protected ClearSCLicenses() {
3690 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
3691 "DELETE FROM SCLicenses_SCProductEntries WHERE productEntryId = ?",
3692 new int[] { java.sql.Types.BIGINT });
3693 }
3694
3695 protected void clear(long productEntryId) throws SystemException {
3696 ModelListener<com.liferay.portlet.softwarecatalog.model.SCLicense>[] scLicenseListeners =
3697 scLicensePersistence.getListeners();
3698
3699 List<com.liferay.portlet.softwarecatalog.model.SCLicense> scLicenses =
3700 null;
3701
3702 if ((listeners.length > 0) || (scLicenseListeners.length > 0)) {
3703 scLicenses = getSCLicenses(productEntryId);
3704
3705 for (com.liferay.portlet.softwarecatalog.model.SCLicense scLicense : scLicenses) {
3706 for (ModelListener<SCProductEntry> listener : listeners) {
3707 listener.onBeforeRemoveAssociation(productEntryId,
3708 com.liferay.portlet.softwarecatalog.model.SCLicense.class.getName(),
3709 scLicense.getPrimaryKey());
3710 }
3711
3712 for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCLicense> listener : scLicenseListeners) {
3713 listener.onBeforeRemoveAssociation(scLicense.getPrimaryKey(),
3714 SCProductEntry.class.getName(), productEntryId);
3715 }
3716 }
3717 }
3718
3719 _sqlUpdate.update(new Object[] { new Long(productEntryId) });
3720
3721 if ((listeners.length > 0) || (scLicenseListeners.length > 0)) {
3722 for (com.liferay.portlet.softwarecatalog.model.SCLicense scLicense : scLicenses) {
3723 for (ModelListener<SCProductEntry> listener : listeners) {
3724 listener.onAfterRemoveAssociation(productEntryId,
3725 com.liferay.portlet.softwarecatalog.model.SCLicense.class.getName(),
3726 scLicense.getPrimaryKey());
3727 }
3728
3729 for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCLicense> listener : scLicenseListeners) {
3730 listener.onAfterRemoveAssociation(scLicense.getPrimaryKey(),
3731 SCProductEntry.class.getName(), productEntryId);
3732 }
3733 }
3734 }
3735 }
3736
3737 private SqlUpdate _sqlUpdate;
3738 }
3739
3740 protected class RemoveSCLicense {
3741 protected RemoveSCLicense() {
3742 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
3743 "DELETE FROM SCLicenses_SCProductEntries WHERE productEntryId = ? AND licenseId = ?",
3744 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
3745 }
3746
3747 protected void remove(long productEntryId, long licenseId)
3748 throws SystemException {
3749 if (containsSCLicense.contains(productEntryId, licenseId)) {
3750 ModelListener<com.liferay.portlet.softwarecatalog.model.SCLicense>[] scLicenseListeners =
3751 scLicensePersistence.getListeners();
3752
3753 for (ModelListener<SCProductEntry> listener : listeners) {
3754 listener.onBeforeRemoveAssociation(productEntryId,
3755 com.liferay.portlet.softwarecatalog.model.SCLicense.class.getName(),
3756 licenseId);
3757 }
3758
3759 for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCLicense> listener : scLicenseListeners) {
3760 listener.onBeforeRemoveAssociation(licenseId,
3761 SCProductEntry.class.getName(), productEntryId);
3762 }
3763
3764 _sqlUpdate.update(new Object[] {
3765 new Long(productEntryId), new Long(licenseId)
3766 });
3767
3768 for (ModelListener<SCProductEntry> listener : listeners) {
3769 listener.onAfterRemoveAssociation(productEntryId,
3770 com.liferay.portlet.softwarecatalog.model.SCLicense.class.getName(),
3771 licenseId);
3772 }
3773
3774 for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCLicense> listener : scLicenseListeners) {
3775 listener.onAfterRemoveAssociation(licenseId,
3776 SCProductEntry.class.getName(), productEntryId);
3777 }
3778 }
3779 }
3780
3781 private SqlUpdate _sqlUpdate;
3782 }
3783
3784 private static final String _SQL_SELECT_SCPRODUCTENTRY = "SELECT scProductEntry FROM SCProductEntry scProductEntry";
3785 private static final String _SQL_SELECT_SCPRODUCTENTRY_WHERE = "SELECT scProductEntry FROM SCProductEntry scProductEntry WHERE ";
3786 private static final String _SQL_COUNT_SCPRODUCTENTRY = "SELECT COUNT(scProductEntry) FROM SCProductEntry scProductEntry";
3787 private static final String _SQL_COUNT_SCPRODUCTENTRY_WHERE = "SELECT COUNT(scProductEntry) FROM SCProductEntry scProductEntry WHERE ";
3788 private static final String _SQL_GETSCLICENSES = "SELECT {SCLicense.*} FROM SCLicense INNER JOIN SCLicenses_SCProductEntries ON (SCLicenses_SCProductEntries.licenseId = SCLicense.licenseId) WHERE (SCLicenses_SCProductEntries.productEntryId = ?)";
3789 private static final String _SQL_GETSCLICENSESSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM SCLicenses_SCProductEntries WHERE productEntryId = ?";
3790 private static final String _SQL_CONTAINSSCLICENSE = "SELECT COUNT(*) AS COUNT_VALUE FROM SCLicenses_SCProductEntries WHERE productEntryId = ? AND licenseId = ?";
3791 private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "scProductEntry.groupId = ?";
3792 private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "scProductEntry.companyId = ?";
3793 private static final String _FINDER_COLUMN_G_U_GROUPID_2 = "scProductEntry.groupId = ? AND ";
3794 private static final String _FINDER_COLUMN_G_U_USERID_2 = "scProductEntry.userId = ?";
3795 private static final String _FINDER_COLUMN_RG_RA_REPOGROUPID_1 = "scProductEntry.repoGroupId IS NULL AND ";
3796 private static final String _FINDER_COLUMN_RG_RA_REPOGROUPID_2 = "lower(scProductEntry.repoGroupId) = lower(CAST_TEXT(?)) AND ";
3797 private static final String _FINDER_COLUMN_RG_RA_REPOGROUPID_3 = "(scProductEntry.repoGroupId IS NULL OR lower(scProductEntry.repoGroupId) = lower(CAST_TEXT(?))) AND ";
3798 private static final String _FINDER_COLUMN_RG_RA_REPOARTIFACTID_1 = "scProductEntry.repoArtifactId IS NULL";
3799 private static final String _FINDER_COLUMN_RG_RA_REPOARTIFACTID_2 = "lower(scProductEntry.repoArtifactId) = lower(CAST_TEXT(?))";
3800 private static final String _FINDER_COLUMN_RG_RA_REPOARTIFACTID_3 = "(scProductEntry.repoArtifactId IS NULL OR lower(scProductEntry.repoArtifactId) = lower(CAST_TEXT(?)))";
3801 private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "scProductEntry.productEntryId";
3802 private static final String _FILTER_SQL_SELECT_SCPRODUCTENTRY_WHERE = "SELECT DISTINCT {scProductEntry.*} FROM SCProductEntry scProductEntry WHERE ";
3803 private static final String _FILTER_SQL_SELECT_SCPRODUCTENTRY_NO_INLINE_DISTINCT_WHERE_1 =
3804 "SELECT {SCProductEntry.*} FROM (SELECT DISTINCT scProductEntry.productEntryId FROM SCProductEntry scProductEntry WHERE ";
3805 private static final String _FILTER_SQL_SELECT_SCPRODUCTENTRY_NO_INLINE_DISTINCT_WHERE_2 =
3806 ") TEMP_TABLE INNER JOIN SCProductEntry ON TEMP_TABLE.productEntryId = SCProductEntry.productEntryId";
3807 private static final String _FILTER_SQL_COUNT_SCPRODUCTENTRY_WHERE = "SELECT COUNT(DISTINCT scProductEntry.productEntryId) AS COUNT_VALUE FROM SCProductEntry scProductEntry WHERE ";
3808 private static final String _FILTER_ENTITY_ALIAS = "scProductEntry";
3809 private static final String _FILTER_ENTITY_TABLE = "SCProductEntry";
3810 private static final String _ORDER_BY_ENTITY_ALIAS = "scProductEntry.";
3811 private static final String _ORDER_BY_ENTITY_TABLE = "SCProductEntry.";
3812 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No SCProductEntry exists with the primary key ";
3813 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No SCProductEntry exists with the key {";
3814 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
3815 private static Log _log = LogFactoryUtil.getLog(SCProductEntryPersistenceImpl.class);
3816 private static SCProductEntry _nullSCProductEntry = new SCProductEntryImpl() {
3817 @Override
3818 public Object clone() {
3819 return this;
3820 }
3821
3822 @Override
3823 public CacheModel<SCProductEntry> toCacheModel() {
3824 return _nullSCProductEntryCacheModel;
3825 }
3826 };
3827
3828 private static CacheModel<SCProductEntry> _nullSCProductEntryCacheModel = new CacheModel<SCProductEntry>() {
3829 public SCProductEntry toEntityModel() {
3830 return _nullSCProductEntry;
3831 }
3832 };
3833 }