1
14
15 package com.liferay.portlet.softwarecatalog.service.persistence;
16
17 import com.liferay.portal.NoSuchModelException;
18 import com.liferay.portal.SystemException;
19 import com.liferay.portal.kernel.annotation.BeanReference;
20 import com.liferay.portal.kernel.cache.CacheRegistry;
21 import com.liferay.portal.kernel.dao.jdbc.MappingSqlQuery;
22 import com.liferay.portal.kernel.dao.jdbc.MappingSqlQueryFactoryUtil;
23 import com.liferay.portal.kernel.dao.jdbc.RowMapper;
24 import com.liferay.portal.kernel.dao.jdbc.SqlUpdate;
25 import com.liferay.portal.kernel.dao.jdbc.SqlUpdateFactoryUtil;
26 import com.liferay.portal.kernel.dao.orm.DynamicQuery;
27 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
28 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
29 import com.liferay.portal.kernel.dao.orm.FinderPath;
30 import com.liferay.portal.kernel.dao.orm.Query;
31 import com.liferay.portal.kernel.dao.orm.QueryPos;
32 import com.liferay.portal.kernel.dao.orm.QueryUtil;
33 import com.liferay.portal.kernel.dao.orm.SQLQuery;
34 import com.liferay.portal.kernel.dao.orm.Session;
35 import com.liferay.portal.kernel.dao.orm.Type;
36 import com.liferay.portal.kernel.log.Log;
37 import com.liferay.portal.kernel.log.LogFactoryUtil;
38 import com.liferay.portal.kernel.util.GetterUtil;
39 import com.liferay.portal.kernel.util.OrderByComparator;
40 import com.liferay.portal.kernel.util.SetUtil;
41 import com.liferay.portal.kernel.util.StringBundler;
42 import com.liferay.portal.kernel.util.StringPool;
43 import com.liferay.portal.kernel.util.StringUtil;
44 import com.liferay.portal.kernel.util.Validator;
45 import com.liferay.portal.model.ModelListener;
46 import com.liferay.portal.service.persistence.BatchSessionUtil;
47 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
48
49 import com.liferay.portlet.softwarecatalog.NoSuchProductEntryException;
50 import com.liferay.portlet.softwarecatalog.model.SCProductEntry;
51 import com.liferay.portlet.softwarecatalog.model.impl.SCProductEntryImpl;
52 import com.liferay.portlet.softwarecatalog.model.impl.SCProductEntryModelImpl;
53
54 import java.io.Serializable;
55
56 import java.sql.Types;
57
58 import java.util.ArrayList;
59 import java.util.Collections;
60 import java.util.List;
61 import java.util.Set;
62
63
76 public class SCProductEntryPersistenceImpl extends BasePersistenceImpl<SCProductEntry>
77 implements SCProductEntryPersistence {
78 public static final String FINDER_CLASS_NAME_ENTITY = SCProductEntryImpl.class.getName();
79 public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
80 ".List";
81 public static final FinderPath FINDER_PATH_FIND_BY_GROUPID = new FinderPath(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
82 SCProductEntryModelImpl.FINDER_CACHE_ENABLED,
83 FINDER_CLASS_NAME_LIST, "findByGroupId",
84 new String[] { Long.class.getName() });
85 public static final FinderPath FINDER_PATH_FIND_BY_OBC_GROUPID = new FinderPath(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
86 SCProductEntryModelImpl.FINDER_CACHE_ENABLED,
87 FINDER_CLASS_NAME_LIST, "findByGroupId",
88 new String[] {
89 Long.class.getName(),
90
91 "java.lang.Integer", "java.lang.Integer",
92 "com.liferay.portal.kernel.util.OrderByComparator"
93 });
94 public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
95 SCProductEntryModelImpl.FINDER_CACHE_ENABLED,
96 FINDER_CLASS_NAME_LIST, "countByGroupId",
97 new String[] { Long.class.getName() });
98 public static final FinderPath FINDER_PATH_FIND_BY_COMPANYID = new FinderPath(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
99 SCProductEntryModelImpl.FINDER_CACHE_ENABLED,
100 FINDER_CLASS_NAME_LIST, "findByCompanyId",
101 new String[] { Long.class.getName() });
102 public static final FinderPath FINDER_PATH_FIND_BY_OBC_COMPANYID = new FinderPath(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
103 SCProductEntryModelImpl.FINDER_CACHE_ENABLED,
104 FINDER_CLASS_NAME_LIST, "findByCompanyId",
105 new String[] {
106 Long.class.getName(),
107
108 "java.lang.Integer", "java.lang.Integer",
109 "com.liferay.portal.kernel.util.OrderByComparator"
110 });
111 public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
112 SCProductEntryModelImpl.FINDER_CACHE_ENABLED,
113 FINDER_CLASS_NAME_LIST, "countByCompanyId",
114 new String[] { Long.class.getName() });
115 public static final FinderPath FINDER_PATH_FIND_BY_G_U = new FinderPath(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
116 SCProductEntryModelImpl.FINDER_CACHE_ENABLED,
117 FINDER_CLASS_NAME_LIST, "findByG_U",
118 new String[] { Long.class.getName(), Long.class.getName() });
119 public static final FinderPath FINDER_PATH_FIND_BY_OBC_G_U = new FinderPath(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
120 SCProductEntryModelImpl.FINDER_CACHE_ENABLED,
121 FINDER_CLASS_NAME_LIST, "findByG_U",
122 new String[] {
123 Long.class.getName(), Long.class.getName(),
124
125 "java.lang.Integer", "java.lang.Integer",
126 "com.liferay.portal.kernel.util.OrderByComparator"
127 });
128 public static final FinderPath FINDER_PATH_COUNT_BY_G_U = new FinderPath(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
129 SCProductEntryModelImpl.FINDER_CACHE_ENABLED,
130 FINDER_CLASS_NAME_LIST, "countByG_U",
131 new String[] { Long.class.getName(), Long.class.getName() });
132 public static final FinderPath FINDER_PATH_FETCH_BY_RG_RA = new FinderPath(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
133 SCProductEntryModelImpl.FINDER_CACHE_ENABLED,
134 FINDER_CLASS_NAME_ENTITY, "fetchByRG_RA",
135 new String[] { String.class.getName(), String.class.getName() });
136 public static final FinderPath FINDER_PATH_COUNT_BY_RG_RA = new FinderPath(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
137 SCProductEntryModelImpl.FINDER_CACHE_ENABLED,
138 FINDER_CLASS_NAME_LIST, "countByRG_RA",
139 new String[] { String.class.getName(), String.class.getName() });
140 public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
141 SCProductEntryModelImpl.FINDER_CACHE_ENABLED,
142 FINDER_CLASS_NAME_LIST, "findAll", new String[0]);
143 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
144 SCProductEntryModelImpl.FINDER_CACHE_ENABLED,
145 FINDER_CLASS_NAME_LIST, "countAll", new String[0]);
146
147 public void cacheResult(SCProductEntry scProductEntry) {
148 EntityCacheUtil.putResult(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
149 SCProductEntryImpl.class, scProductEntry.getPrimaryKey(),
150 scProductEntry);
151
152 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_RG_RA,
153 new Object[] {
154 scProductEntry.getRepoGroupId(),
155
156 scProductEntry.getRepoArtifactId()
157 }, scProductEntry);
158 }
159
160 public void cacheResult(List<SCProductEntry> scProductEntries) {
161 for (SCProductEntry scProductEntry : scProductEntries) {
162 if (EntityCacheUtil.getResult(
163 SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
164 SCProductEntryImpl.class,
165 scProductEntry.getPrimaryKey(), this) == null) {
166 cacheResult(scProductEntry);
167 }
168 }
169 }
170
171 public void clearCache() {
172 CacheRegistry.clear(SCProductEntryImpl.class.getName());
173 EntityCacheUtil.clearCache(SCProductEntryImpl.class.getName());
174 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
175 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
176 }
177
178 public SCProductEntry create(long productEntryId) {
179 SCProductEntry scProductEntry = new SCProductEntryImpl();
180
181 scProductEntry.setNew(true);
182 scProductEntry.setPrimaryKey(productEntryId);
183
184 return scProductEntry;
185 }
186
187 public SCProductEntry remove(Serializable primaryKey)
188 throws NoSuchModelException, SystemException {
189 return remove(((Long)primaryKey).longValue());
190 }
191
192 public SCProductEntry remove(long productEntryId)
193 throws NoSuchProductEntryException, SystemException {
194 Session session = null;
195
196 try {
197 session = openSession();
198
199 SCProductEntry scProductEntry = (SCProductEntry)session.get(SCProductEntryImpl.class,
200 new Long(productEntryId));
201
202 if (scProductEntry == null) {
203 if (_log.isWarnEnabled()) {
204 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
205 productEntryId);
206 }
207
208 throw new NoSuchProductEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
209 productEntryId);
210 }
211
212 return remove(scProductEntry);
213 }
214 catch (NoSuchProductEntryException nsee) {
215 throw nsee;
216 }
217 catch (Exception e) {
218 throw processException(e);
219 }
220 finally {
221 closeSession(session);
222 }
223 }
224
225 public SCProductEntry remove(SCProductEntry scProductEntry)
226 throws SystemException {
227 for (ModelListener<SCProductEntry> listener : listeners) {
228 listener.onBeforeRemove(scProductEntry);
229 }
230
231 scProductEntry = removeImpl(scProductEntry);
232
233 for (ModelListener<SCProductEntry> listener : listeners) {
234 listener.onAfterRemove(scProductEntry);
235 }
236
237 return scProductEntry;
238 }
239
240 protected SCProductEntry removeImpl(SCProductEntry scProductEntry)
241 throws SystemException {
242 scProductEntry = toUnwrappedModel(scProductEntry);
243
244 try {
245 clearSCLicenses.clear(scProductEntry.getPrimaryKey());
246 }
247 catch (Exception e) {
248 throw processException(e);
249 }
250 finally {
251 FinderCacheUtil.clearCache(SCProductEntryModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
252 }
253
254 Session session = null;
255
256 try {
257 session = openSession();
258
259 if (scProductEntry.isCachedModel() || BatchSessionUtil.isEnabled()) {
260 Object staleObject = session.get(SCProductEntryImpl.class,
261 scProductEntry.getPrimaryKeyObj());
262
263 if (staleObject != null) {
264 session.evict(staleObject);
265 }
266 }
267
268 session.delete(scProductEntry);
269
270 session.flush();
271 }
272 catch (Exception e) {
273 throw processException(e);
274 }
275 finally {
276 closeSession(session);
277 }
278
279 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
280
281 SCProductEntryModelImpl scProductEntryModelImpl = (SCProductEntryModelImpl)scProductEntry;
282
283 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_RG_RA,
284 new Object[] {
285 scProductEntryModelImpl.getOriginalRepoGroupId(),
286
287 scProductEntryModelImpl.getOriginalRepoArtifactId()
288 });
289
290 EntityCacheUtil.removeResult(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
291 SCProductEntryImpl.class, scProductEntry.getPrimaryKey());
292
293 return scProductEntry;
294 }
295
296
299 public SCProductEntry update(SCProductEntry scProductEntry)
300 throws SystemException {
301 if (_log.isWarnEnabled()) {
302 _log.warn(
303 "Using the deprecated update(SCProductEntry scProductEntry) method. Use update(SCProductEntry scProductEntry, boolean merge) instead.");
304 }
305
306 return update(scProductEntry, false);
307 }
308
309 public SCProductEntry updateImpl(
310 com.liferay.portlet.softwarecatalog.model.SCProductEntry scProductEntry,
311 boolean merge) throws SystemException {
312 scProductEntry = toUnwrappedModel(scProductEntry);
313
314 boolean isNew = scProductEntry.isNew();
315
316 SCProductEntryModelImpl scProductEntryModelImpl = (SCProductEntryModelImpl)scProductEntry;
317
318 Session session = null;
319
320 try {
321 session = openSession();
322
323 BatchSessionUtil.update(session, scProductEntry, merge);
324
325 scProductEntry.setNew(false);
326 }
327 catch (Exception e) {
328 throw processException(e);
329 }
330 finally {
331 closeSession(session);
332 }
333
334 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
335
336 EntityCacheUtil.putResult(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
337 SCProductEntryImpl.class, scProductEntry.getPrimaryKey(),
338 scProductEntry);
339
340 if (!isNew &&
341 (!Validator.equals(scProductEntry.getRepoGroupId(),
342 scProductEntryModelImpl.getOriginalRepoGroupId()) ||
343 !Validator.equals(scProductEntry.getRepoArtifactId(),
344 scProductEntryModelImpl.getOriginalRepoArtifactId()))) {
345 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_RG_RA,
346 new Object[] {
347 scProductEntryModelImpl.getOriginalRepoGroupId(),
348
349 scProductEntryModelImpl.getOriginalRepoArtifactId()
350 });
351 }
352
353 if (isNew ||
354 (!Validator.equals(scProductEntry.getRepoGroupId(),
355 scProductEntryModelImpl.getOriginalRepoGroupId()) ||
356 !Validator.equals(scProductEntry.getRepoArtifactId(),
357 scProductEntryModelImpl.getOriginalRepoArtifactId()))) {
358 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_RG_RA,
359 new Object[] {
360 scProductEntry.getRepoGroupId(),
361
362 scProductEntry.getRepoArtifactId()
363 }, scProductEntry);
364 }
365
366 return scProductEntry;
367 }
368
369 protected SCProductEntry toUnwrappedModel(SCProductEntry scProductEntry) {
370 if (scProductEntry instanceof SCProductEntryImpl) {
371 return scProductEntry;
372 }
373
374 SCProductEntryImpl scProductEntryImpl = new SCProductEntryImpl();
375
376 scProductEntryImpl.setNew(scProductEntry.isNew());
377 scProductEntryImpl.setPrimaryKey(scProductEntry.getPrimaryKey());
378
379 scProductEntryImpl.setProductEntryId(scProductEntry.getProductEntryId());
380 scProductEntryImpl.setGroupId(scProductEntry.getGroupId());
381 scProductEntryImpl.setCompanyId(scProductEntry.getCompanyId());
382 scProductEntryImpl.setUserId(scProductEntry.getUserId());
383 scProductEntryImpl.setUserName(scProductEntry.getUserName());
384 scProductEntryImpl.setCreateDate(scProductEntry.getCreateDate());
385 scProductEntryImpl.setModifiedDate(scProductEntry.getModifiedDate());
386 scProductEntryImpl.setName(scProductEntry.getName());
387 scProductEntryImpl.setType(scProductEntry.getType());
388 scProductEntryImpl.setTags(scProductEntry.getTags());
389 scProductEntryImpl.setShortDescription(scProductEntry.getShortDescription());
390 scProductEntryImpl.setLongDescription(scProductEntry.getLongDescription());
391 scProductEntryImpl.setPageURL(scProductEntry.getPageURL());
392 scProductEntryImpl.setAuthor(scProductEntry.getAuthor());
393 scProductEntryImpl.setRepoGroupId(scProductEntry.getRepoGroupId());
394 scProductEntryImpl.setRepoArtifactId(scProductEntry.getRepoArtifactId());
395
396 return scProductEntryImpl;
397 }
398
399 public SCProductEntry findByPrimaryKey(Serializable primaryKey)
400 throws NoSuchModelException, SystemException {
401 return findByPrimaryKey(((Long)primaryKey).longValue());
402 }
403
404 public SCProductEntry findByPrimaryKey(long productEntryId)
405 throws NoSuchProductEntryException, SystemException {
406 SCProductEntry scProductEntry = fetchByPrimaryKey(productEntryId);
407
408 if (scProductEntry == null) {
409 if (_log.isWarnEnabled()) {
410 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + productEntryId);
411 }
412
413 throw new NoSuchProductEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
414 productEntryId);
415 }
416
417 return scProductEntry;
418 }
419
420 public SCProductEntry fetchByPrimaryKey(Serializable primaryKey)
421 throws SystemException {
422 return fetchByPrimaryKey(((Long)primaryKey).longValue());
423 }
424
425 public SCProductEntry fetchByPrimaryKey(long productEntryId)
426 throws SystemException {
427 SCProductEntry scProductEntry = (SCProductEntry)EntityCacheUtil.getResult(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
428 SCProductEntryImpl.class, productEntryId, this);
429
430 if (scProductEntry == null) {
431 Session session = null;
432
433 try {
434 session = openSession();
435
436 scProductEntry = (SCProductEntry)session.get(SCProductEntryImpl.class,
437 new Long(productEntryId));
438 }
439 catch (Exception e) {
440 throw processException(e);
441 }
442 finally {
443 if (scProductEntry != null) {
444 cacheResult(scProductEntry);
445 }
446
447 closeSession(session);
448 }
449 }
450
451 return scProductEntry;
452 }
453
454 public List<SCProductEntry> findByGroupId(long groupId)
455 throws SystemException {
456 Object[] finderArgs = new Object[] { new Long(groupId) };
457
458 List<SCProductEntry> list = (List<SCProductEntry>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_GROUPID,
459 finderArgs, this);
460
461 if (list == null) {
462 Session session = null;
463
464 try {
465 session = openSession();
466
467 StringBundler query = new StringBundler(3);
468
469 query.append(_SQL_SELECT_SCPRODUCTENTRY_WHERE);
470
471 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
472
473 query.append(SCProductEntryModelImpl.ORDER_BY_JPQL);
474
475 String sql = query.toString();
476
477 Query q = session.createQuery(sql);
478
479 QueryPos qPos = QueryPos.getInstance(q);
480
481 qPos.add(groupId);
482
483 list = q.list();
484 }
485 catch (Exception e) {
486 throw processException(e);
487 }
488 finally {
489 if (list == null) {
490 list = new ArrayList<SCProductEntry>();
491 }
492
493 cacheResult(list);
494
495 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_GROUPID,
496 finderArgs, list);
497
498 closeSession(session);
499 }
500 }
501
502 return list;
503 }
504
505 public List<SCProductEntry> findByGroupId(long groupId, int start, int end)
506 throws SystemException {
507 return findByGroupId(groupId, start, end, null);
508 }
509
510 public List<SCProductEntry> findByGroupId(long groupId, int start, int end,
511 OrderByComparator obc) throws SystemException {
512 Object[] finderArgs = new Object[] {
513 new Long(groupId),
514
515 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
516 };
517
518 List<SCProductEntry> list = (List<SCProductEntry>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_GROUPID,
519 finderArgs, this);
520
521 if (list == null) {
522 Session session = null;
523
524 try {
525 session = openSession();
526
527 StringBundler query = null;
528
529 if (obc != null) {
530 query = new StringBundler(3 +
531 (obc.getOrderByFields().length * 3));
532 }
533 else {
534 query = new StringBundler(3);
535 }
536
537 query.append(_SQL_SELECT_SCPRODUCTENTRY_WHERE);
538
539 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
540
541 if (obc != null) {
542 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
543 }
544
545 else {
546 query.append(SCProductEntryModelImpl.ORDER_BY_JPQL);
547 }
548
549 String sql = query.toString();
550
551 Query q = session.createQuery(sql);
552
553 QueryPos qPos = QueryPos.getInstance(q);
554
555 qPos.add(groupId);
556
557 list = (List<SCProductEntry>)QueryUtil.list(q, getDialect(),
558 start, end);
559 }
560 catch (Exception e) {
561 throw processException(e);
562 }
563 finally {
564 if (list == null) {
565 list = new ArrayList<SCProductEntry>();
566 }
567
568 cacheResult(list);
569
570 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_GROUPID,
571 finderArgs, list);
572
573 closeSession(session);
574 }
575 }
576
577 return list;
578 }
579
580 public SCProductEntry findByGroupId_First(long groupId,
581 OrderByComparator obc)
582 throws NoSuchProductEntryException, SystemException {
583 List<SCProductEntry> list = findByGroupId(groupId, 0, 1, obc);
584
585 if (list.isEmpty()) {
586 StringBundler msg = new StringBundler(4);
587
588 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
589
590 msg.append("groupId=");
591 msg.append(groupId);
592
593 msg.append(StringPool.CLOSE_CURLY_BRACE);
594
595 throw new NoSuchProductEntryException(msg.toString());
596 }
597 else {
598 return list.get(0);
599 }
600 }
601
602 public SCProductEntry findByGroupId_Last(long groupId, OrderByComparator obc)
603 throws NoSuchProductEntryException, SystemException {
604 int count = countByGroupId(groupId);
605
606 List<SCProductEntry> list = findByGroupId(groupId, count - 1, count, obc);
607
608 if (list.isEmpty()) {
609 StringBundler msg = new StringBundler(4);
610
611 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
612
613 msg.append("groupId=");
614 msg.append(groupId);
615
616 msg.append(StringPool.CLOSE_CURLY_BRACE);
617
618 throw new NoSuchProductEntryException(msg.toString());
619 }
620 else {
621 return list.get(0);
622 }
623 }
624
625 public SCProductEntry[] findByGroupId_PrevAndNext(long productEntryId,
626 long groupId, OrderByComparator obc)
627 throws NoSuchProductEntryException, SystemException {
628 SCProductEntry scProductEntry = findByPrimaryKey(productEntryId);
629
630 int count = countByGroupId(groupId);
631
632 Session session = null;
633
634 try {
635 session = openSession();
636
637 StringBundler query = null;
638
639 if (obc != null) {
640 query = new StringBundler(3 +
641 (obc.getOrderByFields().length * 3));
642 }
643 else {
644 query = new StringBundler(3);
645 }
646
647 query.append(_SQL_SELECT_SCPRODUCTENTRY_WHERE);
648
649 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
650
651 if (obc != null) {
652 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
653 }
654
655 else {
656 query.append(SCProductEntryModelImpl.ORDER_BY_JPQL);
657 }
658
659 String sql = query.toString();
660
661 Query q = session.createQuery(sql);
662
663 QueryPos qPos = QueryPos.getInstance(q);
664
665 qPos.add(groupId);
666
667 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
668 scProductEntry);
669
670 SCProductEntry[] array = new SCProductEntryImpl[3];
671
672 array[0] = (SCProductEntry)objArray[0];
673 array[1] = (SCProductEntry)objArray[1];
674 array[2] = (SCProductEntry)objArray[2];
675
676 return array;
677 }
678 catch (Exception e) {
679 throw processException(e);
680 }
681 finally {
682 closeSession(session);
683 }
684 }
685
686 public List<SCProductEntry> findByCompanyId(long companyId)
687 throws SystemException {
688 Object[] finderArgs = new Object[] { new Long(companyId) };
689
690 List<SCProductEntry> list = (List<SCProductEntry>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_COMPANYID,
691 finderArgs, this);
692
693 if (list == null) {
694 Session session = null;
695
696 try {
697 session = openSession();
698
699 StringBundler query = new StringBundler(3);
700
701 query.append(_SQL_SELECT_SCPRODUCTENTRY_WHERE);
702
703 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
704
705 query.append(SCProductEntryModelImpl.ORDER_BY_JPQL);
706
707 String sql = query.toString();
708
709 Query q = session.createQuery(sql);
710
711 QueryPos qPos = QueryPos.getInstance(q);
712
713 qPos.add(companyId);
714
715 list = q.list();
716 }
717 catch (Exception e) {
718 throw processException(e);
719 }
720 finally {
721 if (list == null) {
722 list = new ArrayList<SCProductEntry>();
723 }
724
725 cacheResult(list);
726
727 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_COMPANYID,
728 finderArgs, list);
729
730 closeSession(session);
731 }
732 }
733
734 return list;
735 }
736
737 public List<SCProductEntry> findByCompanyId(long companyId, int start,
738 int end) throws SystemException {
739 return findByCompanyId(companyId, start, end, null);
740 }
741
742 public List<SCProductEntry> findByCompanyId(long companyId, int start,
743 int end, OrderByComparator obc) throws SystemException {
744 Object[] finderArgs = new Object[] {
745 new Long(companyId),
746
747 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
748 };
749
750 List<SCProductEntry> list = (List<SCProductEntry>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_COMPANYID,
751 finderArgs, this);
752
753 if (list == null) {
754 Session session = null;
755
756 try {
757 session = openSession();
758
759 StringBundler query = null;
760
761 if (obc != null) {
762 query = new StringBundler(3 +
763 (obc.getOrderByFields().length * 3));
764 }
765 else {
766 query = new StringBundler(3);
767 }
768
769 query.append(_SQL_SELECT_SCPRODUCTENTRY_WHERE);
770
771 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
772
773 if (obc != null) {
774 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
775 }
776
777 else {
778 query.append(SCProductEntryModelImpl.ORDER_BY_JPQL);
779 }
780
781 String sql = query.toString();
782
783 Query q = session.createQuery(sql);
784
785 QueryPos qPos = QueryPos.getInstance(q);
786
787 qPos.add(companyId);
788
789 list = (List<SCProductEntry>)QueryUtil.list(q, getDialect(),
790 start, end);
791 }
792 catch (Exception e) {
793 throw processException(e);
794 }
795 finally {
796 if (list == null) {
797 list = new ArrayList<SCProductEntry>();
798 }
799
800 cacheResult(list);
801
802 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_COMPANYID,
803 finderArgs, list);
804
805 closeSession(session);
806 }
807 }
808
809 return list;
810 }
811
812 public SCProductEntry findByCompanyId_First(long companyId,
813 OrderByComparator obc)
814 throws NoSuchProductEntryException, SystemException {
815 List<SCProductEntry> list = findByCompanyId(companyId, 0, 1, obc);
816
817 if (list.isEmpty()) {
818 StringBundler msg = new StringBundler(4);
819
820 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
821
822 msg.append("companyId=");
823 msg.append(companyId);
824
825 msg.append(StringPool.CLOSE_CURLY_BRACE);
826
827 throw new NoSuchProductEntryException(msg.toString());
828 }
829 else {
830 return list.get(0);
831 }
832 }
833
834 public SCProductEntry findByCompanyId_Last(long companyId,
835 OrderByComparator obc)
836 throws NoSuchProductEntryException, SystemException {
837 int count = countByCompanyId(companyId);
838
839 List<SCProductEntry> list = findByCompanyId(companyId, count - 1,
840 count, obc);
841
842 if (list.isEmpty()) {
843 StringBundler msg = new StringBundler(4);
844
845 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
846
847 msg.append("companyId=");
848 msg.append(companyId);
849
850 msg.append(StringPool.CLOSE_CURLY_BRACE);
851
852 throw new NoSuchProductEntryException(msg.toString());
853 }
854 else {
855 return list.get(0);
856 }
857 }
858
859 public SCProductEntry[] findByCompanyId_PrevAndNext(long productEntryId,
860 long companyId, OrderByComparator obc)
861 throws NoSuchProductEntryException, SystemException {
862 SCProductEntry scProductEntry = findByPrimaryKey(productEntryId);
863
864 int count = countByCompanyId(companyId);
865
866 Session session = null;
867
868 try {
869 session = openSession();
870
871 StringBundler query = null;
872
873 if (obc != null) {
874 query = new StringBundler(3 +
875 (obc.getOrderByFields().length * 3));
876 }
877 else {
878 query = new StringBundler(3);
879 }
880
881 query.append(_SQL_SELECT_SCPRODUCTENTRY_WHERE);
882
883 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
884
885 if (obc != null) {
886 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
887 }
888
889 else {
890 query.append(SCProductEntryModelImpl.ORDER_BY_JPQL);
891 }
892
893 String sql = query.toString();
894
895 Query q = session.createQuery(sql);
896
897 QueryPos qPos = QueryPos.getInstance(q);
898
899 qPos.add(companyId);
900
901 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
902 scProductEntry);
903
904 SCProductEntry[] array = new SCProductEntryImpl[3];
905
906 array[0] = (SCProductEntry)objArray[0];
907 array[1] = (SCProductEntry)objArray[1];
908 array[2] = (SCProductEntry)objArray[2];
909
910 return array;
911 }
912 catch (Exception e) {
913 throw processException(e);
914 }
915 finally {
916 closeSession(session);
917 }
918 }
919
920 public List<SCProductEntry> findByG_U(long groupId, long userId)
921 throws SystemException {
922 Object[] finderArgs = new Object[] { new Long(groupId), new Long(userId) };
923
924 List<SCProductEntry> list = (List<SCProductEntry>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_G_U,
925 finderArgs, this);
926
927 if (list == null) {
928 Session session = null;
929
930 try {
931 session = openSession();
932
933 StringBundler query = new StringBundler(4);
934
935 query.append(_SQL_SELECT_SCPRODUCTENTRY_WHERE);
936
937 query.append(_FINDER_COLUMN_G_U_GROUPID_2);
938
939 query.append(_FINDER_COLUMN_G_U_USERID_2);
940
941 query.append(SCProductEntryModelImpl.ORDER_BY_JPQL);
942
943 String sql = query.toString();
944
945 Query q = session.createQuery(sql);
946
947 QueryPos qPos = QueryPos.getInstance(q);
948
949 qPos.add(groupId);
950
951 qPos.add(userId);
952
953 list = q.list();
954 }
955 catch (Exception e) {
956 throw processException(e);
957 }
958 finally {
959 if (list == null) {
960 list = new ArrayList<SCProductEntry>();
961 }
962
963 cacheResult(list);
964
965 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_G_U, finderArgs,
966 list);
967
968 closeSession(session);
969 }
970 }
971
972 return list;
973 }
974
975 public List<SCProductEntry> findByG_U(long groupId, long userId, int start,
976 int end) throws SystemException {
977 return findByG_U(groupId, userId, start, end, null);
978 }
979
980 public List<SCProductEntry> findByG_U(long groupId, long userId, int start,
981 int end, OrderByComparator obc) throws SystemException {
982 Object[] finderArgs = new Object[] {
983 new Long(groupId), new Long(userId),
984
985 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
986 };
987
988 List<SCProductEntry> list = (List<SCProductEntry>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_G_U,
989 finderArgs, this);
990
991 if (list == null) {
992 Session session = null;
993
994 try {
995 session = openSession();
996
997 StringBundler query = null;
998
999 if (obc != null) {
1000 query = new StringBundler(4 +
1001 (obc.getOrderByFields().length * 3));
1002 }
1003 else {
1004 query = new StringBundler(4);
1005 }
1006
1007 query.append(_SQL_SELECT_SCPRODUCTENTRY_WHERE);
1008
1009 query.append(_FINDER_COLUMN_G_U_GROUPID_2);
1010
1011 query.append(_FINDER_COLUMN_G_U_USERID_2);
1012
1013 if (obc != null) {
1014 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
1015 }
1016
1017 else {
1018 query.append(SCProductEntryModelImpl.ORDER_BY_JPQL);
1019 }
1020
1021 String sql = query.toString();
1022
1023 Query q = session.createQuery(sql);
1024
1025 QueryPos qPos = QueryPos.getInstance(q);
1026
1027 qPos.add(groupId);
1028
1029 qPos.add(userId);
1030
1031 list = (List<SCProductEntry>)QueryUtil.list(q, getDialect(),
1032 start, end);
1033 }
1034 catch (Exception e) {
1035 throw processException(e);
1036 }
1037 finally {
1038 if (list == null) {
1039 list = new ArrayList<SCProductEntry>();
1040 }
1041
1042 cacheResult(list);
1043
1044 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_G_U,
1045 finderArgs, list);
1046
1047 closeSession(session);
1048 }
1049 }
1050
1051 return list;
1052 }
1053
1054 public SCProductEntry findByG_U_First(long groupId, long userId,
1055 OrderByComparator obc)
1056 throws NoSuchProductEntryException, SystemException {
1057 List<SCProductEntry> list = findByG_U(groupId, userId, 0, 1, obc);
1058
1059 if (list.isEmpty()) {
1060 StringBundler msg = new StringBundler(6);
1061
1062 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1063
1064 msg.append("groupId=");
1065 msg.append(groupId);
1066
1067 msg.append(", userId=");
1068 msg.append(userId);
1069
1070 msg.append(StringPool.CLOSE_CURLY_BRACE);
1071
1072 throw new NoSuchProductEntryException(msg.toString());
1073 }
1074 else {
1075 return list.get(0);
1076 }
1077 }
1078
1079 public SCProductEntry findByG_U_Last(long groupId, long userId,
1080 OrderByComparator obc)
1081 throws NoSuchProductEntryException, SystemException {
1082 int count = countByG_U(groupId, userId);
1083
1084 List<SCProductEntry> list = findByG_U(groupId, userId, count - 1,
1085 count, obc);
1086
1087 if (list.isEmpty()) {
1088 StringBundler msg = new StringBundler(6);
1089
1090 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1091
1092 msg.append("groupId=");
1093 msg.append(groupId);
1094
1095 msg.append(", userId=");
1096 msg.append(userId);
1097
1098 msg.append(StringPool.CLOSE_CURLY_BRACE);
1099
1100 throw new NoSuchProductEntryException(msg.toString());
1101 }
1102 else {
1103 return list.get(0);
1104 }
1105 }
1106
1107 public SCProductEntry[] findByG_U_PrevAndNext(long productEntryId,
1108 long groupId, long userId, OrderByComparator obc)
1109 throws NoSuchProductEntryException, SystemException {
1110 SCProductEntry scProductEntry = findByPrimaryKey(productEntryId);
1111
1112 int count = countByG_U(groupId, userId);
1113
1114 Session session = null;
1115
1116 try {
1117 session = openSession();
1118
1119 StringBundler query = null;
1120
1121 if (obc != null) {
1122 query = new StringBundler(4 +
1123 (obc.getOrderByFields().length * 3));
1124 }
1125 else {
1126 query = new StringBundler(4);
1127 }
1128
1129 query.append(_SQL_SELECT_SCPRODUCTENTRY_WHERE);
1130
1131 query.append(_FINDER_COLUMN_G_U_GROUPID_2);
1132
1133 query.append(_FINDER_COLUMN_G_U_USERID_2);
1134
1135 if (obc != null) {
1136 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
1137 }
1138
1139 else {
1140 query.append(SCProductEntryModelImpl.ORDER_BY_JPQL);
1141 }
1142
1143 String sql = query.toString();
1144
1145 Query q = session.createQuery(sql);
1146
1147 QueryPos qPos = QueryPos.getInstance(q);
1148
1149 qPos.add(groupId);
1150
1151 qPos.add(userId);
1152
1153 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
1154 scProductEntry);
1155
1156 SCProductEntry[] array = new SCProductEntryImpl[3];
1157
1158 array[0] = (SCProductEntry)objArray[0];
1159 array[1] = (SCProductEntry)objArray[1];
1160 array[2] = (SCProductEntry)objArray[2];
1161
1162 return array;
1163 }
1164 catch (Exception e) {
1165 throw processException(e);
1166 }
1167 finally {
1168 closeSession(session);
1169 }
1170 }
1171
1172 public SCProductEntry findByRG_RA(String repoGroupId, String repoArtifactId)
1173 throws NoSuchProductEntryException, SystemException {
1174 SCProductEntry scProductEntry = fetchByRG_RA(repoGroupId, repoArtifactId);
1175
1176 if (scProductEntry == null) {
1177 StringBundler msg = new StringBundler(6);
1178
1179 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1180
1181 msg.append("repoGroupId=");
1182 msg.append(repoGroupId);
1183
1184 msg.append(", repoArtifactId=");
1185 msg.append(repoArtifactId);
1186
1187 msg.append(StringPool.CLOSE_CURLY_BRACE);
1188
1189 if (_log.isWarnEnabled()) {
1190 _log.warn(msg.toString());
1191 }
1192
1193 throw new NoSuchProductEntryException(msg.toString());
1194 }
1195
1196 return scProductEntry;
1197 }
1198
1199 public SCProductEntry fetchByRG_RA(String repoGroupId, String repoArtifactId)
1200 throws SystemException {
1201 return fetchByRG_RA(repoGroupId, repoArtifactId, true);
1202 }
1203
1204 public SCProductEntry fetchByRG_RA(String repoGroupId,
1205 String repoArtifactId, boolean retrieveFromCache)
1206 throws SystemException {
1207 Object[] finderArgs = new Object[] { repoGroupId, repoArtifactId };
1208
1209 Object result = null;
1210
1211 if (retrieveFromCache) {
1212 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_RG_RA,
1213 finderArgs, this);
1214 }
1215
1216 if (result == null) {
1217 Session session = null;
1218
1219 try {
1220 session = openSession();
1221
1222 StringBundler query = new StringBundler(4);
1223
1224 query.append(_SQL_SELECT_SCPRODUCTENTRY_WHERE);
1225
1226 if (repoGroupId == null) {
1227 query.append(_FINDER_COLUMN_RG_RA_REPOGROUPID_1);
1228 }
1229 else {
1230 if (repoGroupId.equals(StringPool.BLANK)) {
1231 query.append(_FINDER_COLUMN_RG_RA_REPOGROUPID_3);
1232 }
1233 else {
1234 query.append(_FINDER_COLUMN_RG_RA_REPOGROUPID_2);
1235 }
1236 }
1237
1238 if (repoArtifactId == null) {
1239 query.append(_FINDER_COLUMN_RG_RA_REPOARTIFACTID_1);
1240 }
1241 else {
1242 if (repoArtifactId.equals(StringPool.BLANK)) {
1243 query.append(_FINDER_COLUMN_RG_RA_REPOARTIFACTID_3);
1244 }
1245 else {
1246 query.append(_FINDER_COLUMN_RG_RA_REPOARTIFACTID_2);
1247 }
1248 }
1249
1250 query.append(SCProductEntryModelImpl.ORDER_BY_JPQL);
1251
1252 String sql = query.toString();
1253
1254 Query q = session.createQuery(sql);
1255
1256 QueryPos qPos = QueryPos.getInstance(q);
1257
1258 if (repoGroupId != null) {
1259 qPos.add(repoGroupId);
1260 }
1261
1262 if (repoArtifactId != null) {
1263 qPos.add(repoArtifactId);
1264 }
1265
1266 List<SCProductEntry> list = q.list();
1267
1268 result = list;
1269
1270 SCProductEntry scProductEntry = null;
1271
1272 if (list.isEmpty()) {
1273 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_RG_RA,
1274 finderArgs, list);
1275 }
1276 else {
1277 scProductEntry = list.get(0);
1278
1279 cacheResult(scProductEntry);
1280
1281 if ((scProductEntry.getRepoGroupId() == null) ||
1282 !scProductEntry.getRepoGroupId().equals(repoGroupId) ||
1283 (scProductEntry.getRepoArtifactId() == null) ||
1284 !scProductEntry.getRepoArtifactId()
1285 .equals(repoArtifactId)) {
1286 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_RG_RA,
1287 finderArgs, scProductEntry);
1288 }
1289 }
1290
1291 return scProductEntry;
1292 }
1293 catch (Exception e) {
1294 throw processException(e);
1295 }
1296 finally {
1297 if (result == null) {
1298 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_RG_RA,
1299 finderArgs, new ArrayList<SCProductEntry>());
1300 }
1301
1302 closeSession(session);
1303 }
1304 }
1305 else {
1306 if (result instanceof List<?>) {
1307 return null;
1308 }
1309 else {
1310 return (SCProductEntry)result;
1311 }
1312 }
1313 }
1314
1315 public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery)
1316 throws SystemException {
1317 Session session = null;
1318
1319 try {
1320 session = openSession();
1321
1322 dynamicQuery.compile(session);
1323
1324 return dynamicQuery.list();
1325 }
1326 catch (Exception e) {
1327 throw processException(e);
1328 }
1329 finally {
1330 closeSession(session);
1331 }
1332 }
1333
1334 public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery,
1335 int start, int end) throws SystemException {
1336 Session session = null;
1337
1338 try {
1339 session = openSession();
1340
1341 dynamicQuery.setLimit(start, end);
1342
1343 dynamicQuery.compile(session);
1344
1345 return dynamicQuery.list();
1346 }
1347 catch (Exception e) {
1348 throw processException(e);
1349 }
1350 finally {
1351 closeSession(session);
1352 }
1353 }
1354
1355 public List<SCProductEntry> findAll() throws SystemException {
1356 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1357 }
1358
1359 public List<SCProductEntry> findAll(int start, int end)
1360 throws SystemException {
1361 return findAll(start, end, null);
1362 }
1363
1364 public List<SCProductEntry> findAll(int start, int end,
1365 OrderByComparator obc) throws SystemException {
1366 Object[] finderArgs = new Object[] {
1367 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
1368 };
1369
1370 List<SCProductEntry> list = (List<SCProductEntry>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
1371 finderArgs, this);
1372
1373 if (list == null) {
1374 Session session = null;
1375
1376 try {
1377 session = openSession();
1378
1379 StringBundler query = null;
1380 String sql = null;
1381
1382 if (obc != null) {
1383 query = new StringBundler(2 +
1384 (obc.getOrderByFields().length * 3));
1385
1386 query.append(_SQL_SELECT_SCPRODUCTENTRY);
1387
1388 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
1389
1390 sql = query.toString();
1391 }
1392
1393 else {
1394 sql = _SQL_SELECT_SCPRODUCTENTRY.concat(SCProductEntryModelImpl.ORDER_BY_JPQL);
1395 }
1396
1397 Query q = session.createQuery(sql);
1398
1399 if (obc == null) {
1400 list = (List<SCProductEntry>)QueryUtil.list(q,
1401 getDialect(), start, end, false);
1402
1403 Collections.sort(list);
1404 }
1405 else {
1406 list = (List<SCProductEntry>)QueryUtil.list(q,
1407 getDialect(), start, end);
1408 }
1409 }
1410 catch (Exception e) {
1411 throw processException(e);
1412 }
1413 finally {
1414 if (list == null) {
1415 list = new ArrayList<SCProductEntry>();
1416 }
1417
1418 cacheResult(list);
1419
1420 FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
1421
1422 closeSession(session);
1423 }
1424 }
1425
1426 return list;
1427 }
1428
1429 public void removeByGroupId(long groupId) throws SystemException {
1430 for (SCProductEntry scProductEntry : findByGroupId(groupId)) {
1431 remove(scProductEntry);
1432 }
1433 }
1434
1435 public void removeByCompanyId(long companyId) throws SystemException {
1436 for (SCProductEntry scProductEntry : findByCompanyId(companyId)) {
1437 remove(scProductEntry);
1438 }
1439 }
1440
1441 public void removeByG_U(long groupId, long userId)
1442 throws SystemException {
1443 for (SCProductEntry scProductEntry : findByG_U(groupId, userId)) {
1444 remove(scProductEntry);
1445 }
1446 }
1447
1448 public void removeByRG_RA(String repoGroupId, String repoArtifactId)
1449 throws NoSuchProductEntryException, SystemException {
1450 SCProductEntry scProductEntry = findByRG_RA(repoGroupId, repoArtifactId);
1451
1452 remove(scProductEntry);
1453 }
1454
1455 public void removeAll() throws SystemException {
1456 for (SCProductEntry scProductEntry : findAll()) {
1457 remove(scProductEntry);
1458 }
1459 }
1460
1461 public int countByGroupId(long groupId) throws SystemException {
1462 Object[] finderArgs = new Object[] { new Long(groupId) };
1463
1464 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
1465 finderArgs, this);
1466
1467 if (count == null) {
1468 Session session = null;
1469
1470 try {
1471 session = openSession();
1472
1473 StringBundler query = new StringBundler(2);
1474
1475 query.append(_SQL_COUNT_SCPRODUCTENTRY_WHERE);
1476
1477 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1478
1479 String sql = query.toString();
1480
1481 Query q = session.createQuery(sql);
1482
1483 QueryPos qPos = QueryPos.getInstance(q);
1484
1485 qPos.add(groupId);
1486
1487 count = (Long)q.uniqueResult();
1488 }
1489 catch (Exception e) {
1490 throw processException(e);
1491 }
1492 finally {
1493 if (count == null) {
1494 count = Long.valueOf(0);
1495 }
1496
1497 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
1498 finderArgs, count);
1499
1500 closeSession(session);
1501 }
1502 }
1503
1504 return count.intValue();
1505 }
1506
1507 public int countByCompanyId(long companyId) throws SystemException {
1508 Object[] finderArgs = new Object[] { new Long(companyId) };
1509
1510 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
1511 finderArgs, this);
1512
1513 if (count == null) {
1514 Session session = null;
1515
1516 try {
1517 session = openSession();
1518
1519 StringBundler query = new StringBundler(2);
1520
1521 query.append(_SQL_COUNT_SCPRODUCTENTRY_WHERE);
1522
1523 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1524
1525 String sql = query.toString();
1526
1527 Query q = session.createQuery(sql);
1528
1529 QueryPos qPos = QueryPos.getInstance(q);
1530
1531 qPos.add(companyId);
1532
1533 count = (Long)q.uniqueResult();
1534 }
1535 catch (Exception e) {
1536 throw processException(e);
1537 }
1538 finally {
1539 if (count == null) {
1540 count = Long.valueOf(0);
1541 }
1542
1543 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
1544 finderArgs, count);
1545
1546 closeSession(session);
1547 }
1548 }
1549
1550 return count.intValue();
1551 }
1552
1553 public int countByG_U(long groupId, long userId) throws SystemException {
1554 Object[] finderArgs = new Object[] { new Long(groupId), new Long(userId) };
1555
1556 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_U,
1557 finderArgs, this);
1558
1559 if (count == null) {
1560 Session session = null;
1561
1562 try {
1563 session = openSession();
1564
1565 StringBundler query = new StringBundler(3);
1566
1567 query.append(_SQL_COUNT_SCPRODUCTENTRY_WHERE);
1568
1569 query.append(_FINDER_COLUMN_G_U_GROUPID_2);
1570
1571 query.append(_FINDER_COLUMN_G_U_USERID_2);
1572
1573 String sql = query.toString();
1574
1575 Query q = session.createQuery(sql);
1576
1577 QueryPos qPos = QueryPos.getInstance(q);
1578
1579 qPos.add(groupId);
1580
1581 qPos.add(userId);
1582
1583 count = (Long)q.uniqueResult();
1584 }
1585 catch (Exception e) {
1586 throw processException(e);
1587 }
1588 finally {
1589 if (count == null) {
1590 count = Long.valueOf(0);
1591 }
1592
1593 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_U, finderArgs,
1594 count);
1595
1596 closeSession(session);
1597 }
1598 }
1599
1600 return count.intValue();
1601 }
1602
1603 public int countByRG_RA(String repoGroupId, String repoArtifactId)
1604 throws SystemException {
1605 Object[] finderArgs = new Object[] { repoGroupId, repoArtifactId };
1606
1607 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_RG_RA,
1608 finderArgs, this);
1609
1610 if (count == null) {
1611 Session session = null;
1612
1613 try {
1614 session = openSession();
1615
1616 StringBundler query = new StringBundler(3);
1617
1618 query.append(_SQL_COUNT_SCPRODUCTENTRY_WHERE);
1619
1620 if (repoGroupId == null) {
1621 query.append(_FINDER_COLUMN_RG_RA_REPOGROUPID_1);
1622 }
1623 else {
1624 if (repoGroupId.equals(StringPool.BLANK)) {
1625 query.append(_FINDER_COLUMN_RG_RA_REPOGROUPID_3);
1626 }
1627 else {
1628 query.append(_FINDER_COLUMN_RG_RA_REPOGROUPID_2);
1629 }
1630 }
1631
1632 if (repoArtifactId == null) {
1633 query.append(_FINDER_COLUMN_RG_RA_REPOARTIFACTID_1);
1634 }
1635 else {
1636 if (repoArtifactId.equals(StringPool.BLANK)) {
1637 query.append(_FINDER_COLUMN_RG_RA_REPOARTIFACTID_3);
1638 }
1639 else {
1640 query.append(_FINDER_COLUMN_RG_RA_REPOARTIFACTID_2);
1641 }
1642 }
1643
1644 String sql = query.toString();
1645
1646 Query q = session.createQuery(sql);
1647
1648 QueryPos qPos = QueryPos.getInstance(q);
1649
1650 if (repoGroupId != null) {
1651 qPos.add(repoGroupId);
1652 }
1653
1654 if (repoArtifactId != null) {
1655 qPos.add(repoArtifactId);
1656 }
1657
1658 count = (Long)q.uniqueResult();
1659 }
1660 catch (Exception e) {
1661 throw processException(e);
1662 }
1663 finally {
1664 if (count == null) {
1665 count = Long.valueOf(0);
1666 }
1667
1668 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_RG_RA,
1669 finderArgs, count);
1670
1671 closeSession(session);
1672 }
1673 }
1674
1675 return count.intValue();
1676 }
1677
1678 public int countAll() throws SystemException {
1679 Object[] finderArgs = new Object[0];
1680
1681 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1682 finderArgs, this);
1683
1684 if (count == null) {
1685 Session session = null;
1686
1687 try {
1688 session = openSession();
1689
1690 Query q = session.createQuery(_SQL_COUNT_SCPRODUCTENTRY);
1691
1692 count = (Long)q.uniqueResult();
1693 }
1694 catch (Exception e) {
1695 throw processException(e);
1696 }
1697 finally {
1698 if (count == null) {
1699 count = Long.valueOf(0);
1700 }
1701
1702 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
1703 count);
1704
1705 closeSession(session);
1706 }
1707 }
1708
1709 return count.intValue();
1710 }
1711
1712 public List<com.liferay.portlet.softwarecatalog.model.SCLicense> getSCLicenses(
1713 long pk) throws SystemException {
1714 return getSCLicenses(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
1715 }
1716
1717 public List<com.liferay.portlet.softwarecatalog.model.SCLicense> getSCLicenses(
1718 long pk, int start, int end) throws SystemException {
1719 return getSCLicenses(pk, start, end, null);
1720 }
1721
1722 public static final FinderPath FINDER_PATH_GET_SCLICENSES = new FinderPath(com.liferay.portlet.softwarecatalog.model.impl.SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
1723 SCProductEntryModelImpl.FINDER_CACHE_ENABLED_SCLICENSES_SCPRODUCTENTRIES,
1724 SCProductEntryModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME,
1725 "getSCLicenses",
1726 new String[] {
1727 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
1728 "com.liferay.portal.kernel.util.OrderByComparator"
1729 });
1730
1731 public List<com.liferay.portlet.softwarecatalog.model.SCLicense> getSCLicenses(
1732 long pk, int start, int end, OrderByComparator obc)
1733 throws SystemException {
1734 Object[] finderArgs = new Object[] {
1735 new Long(pk), String.valueOf(start), String.valueOf(end),
1736 String.valueOf(obc)
1737 };
1738
1739 List<com.liferay.portlet.softwarecatalog.model.SCLicense> list = (List<com.liferay.portlet.softwarecatalog.model.SCLicense>)FinderCacheUtil.getResult(FINDER_PATH_GET_SCLICENSES,
1740 finderArgs, this);
1741
1742 if (list == null) {
1743 Session session = null;
1744
1745 try {
1746 session = openSession();
1747
1748 String sql = null;
1749
1750 if (obc != null) {
1751 sql = _SQL_GETSCLICENSES.concat(ORDER_BY_CLAUSE)
1752 .concat(obc.getOrderBy());
1753 }
1754
1755 else {
1756 sql = _SQL_GETSCLICENSES.concat(com.liferay.portlet.softwarecatalog.model.impl.SCLicenseModelImpl.ORDER_BY_SQL);
1757 }
1758
1759 SQLQuery q = session.createSQLQuery(sql);
1760
1761 q.addEntity("SCLicense",
1762 com.liferay.portlet.softwarecatalog.model.impl.SCLicenseImpl.class);
1763
1764 QueryPos qPos = QueryPos.getInstance(q);
1765
1766 qPos.add(pk);
1767
1768 list = (List<com.liferay.portlet.softwarecatalog.model.SCLicense>)QueryUtil.list(q,
1769 getDialect(), start, end);
1770 }
1771 catch (Exception e) {
1772 throw processException(e);
1773 }
1774 finally {
1775 if (list == null) {
1776 list = new ArrayList<com.liferay.portlet.softwarecatalog.model.SCLicense>();
1777 }
1778
1779 scLicensePersistence.cacheResult(list);
1780
1781 FinderCacheUtil.putResult(FINDER_PATH_GET_SCLICENSES,
1782 finderArgs, list);
1783
1784 closeSession(session);
1785 }
1786 }
1787
1788 return list;
1789 }
1790
1791 public static final FinderPath FINDER_PATH_GET_SCLICENSES_SIZE = new FinderPath(com.liferay.portlet.softwarecatalog.model.impl.SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
1792 SCProductEntryModelImpl.FINDER_CACHE_ENABLED_SCLICENSES_SCPRODUCTENTRIES,
1793 SCProductEntryModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME,
1794 "getSCLicensesSize", new String[] { Long.class.getName() });
1795
1796 public int getSCLicensesSize(long pk) throws SystemException {
1797 Object[] finderArgs = new Object[] { new Long(pk) };
1798
1799 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_SCLICENSES_SIZE,
1800 finderArgs, this);
1801
1802 if (count == null) {
1803 Session session = null;
1804
1805 try {
1806 session = openSession();
1807
1808 SQLQuery q = session.createSQLQuery(_SQL_GETSCLICENSESSIZE);
1809
1810 q.addScalar(COUNT_COLUMN_NAME, Type.LONG);
1811
1812 QueryPos qPos = QueryPos.getInstance(q);
1813
1814 qPos.add(pk);
1815
1816 count = (Long)q.uniqueResult();
1817 }
1818 catch (Exception e) {
1819 throw processException(e);
1820 }
1821 finally {
1822 if (count == null) {
1823 count = Long.valueOf(0);
1824 }
1825
1826 FinderCacheUtil.putResult(FINDER_PATH_GET_SCLICENSES_SIZE,
1827 finderArgs, count);
1828
1829 closeSession(session);
1830 }
1831 }
1832
1833 return count.intValue();
1834 }
1835
1836 public static final FinderPath FINDER_PATH_CONTAINS_SCLICENSE = new FinderPath(com.liferay.portlet.softwarecatalog.model.impl.SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
1837 SCProductEntryModelImpl.FINDER_CACHE_ENABLED_SCLICENSES_SCPRODUCTENTRIES,
1838 SCProductEntryModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME,
1839 "containsSCLicense",
1840 new String[] { Long.class.getName(), Long.class.getName() });
1841
1842 public boolean containsSCLicense(long pk, long scLicensePK)
1843 throws SystemException {
1844 Object[] finderArgs = new Object[] { new Long(pk), new Long(scLicensePK) };
1845
1846 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_SCLICENSE,
1847 finderArgs, this);
1848
1849 if (value == null) {
1850 try {
1851 value = Boolean.valueOf(containsSCLicense.contains(pk,
1852 scLicensePK));
1853 }
1854 catch (Exception e) {
1855 throw processException(e);
1856 }
1857 finally {
1858 if (value == null) {
1859 value = Boolean.FALSE;
1860 }
1861
1862 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_SCLICENSE,
1863 finderArgs, value);
1864 }
1865 }
1866
1867 return value.booleanValue();
1868 }
1869
1870 public boolean containsSCLicenses(long pk) throws SystemException {
1871 if (getSCLicensesSize(pk) > 0) {
1872 return true;
1873 }
1874 else {
1875 return false;
1876 }
1877 }
1878
1879 public void addSCLicense(long pk, long scLicensePK)
1880 throws SystemException {
1881 try {
1882 addSCLicense.add(pk, scLicensePK);
1883 }
1884 catch (Exception e) {
1885 throw processException(e);
1886 }
1887 finally {
1888 FinderCacheUtil.clearCache(SCProductEntryModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
1889 }
1890 }
1891
1892 public void addSCLicense(long pk,
1893 com.liferay.portlet.softwarecatalog.model.SCLicense scLicense)
1894 throws SystemException {
1895 try {
1896 addSCLicense.add(pk, scLicense.getPrimaryKey());
1897 }
1898 catch (Exception e) {
1899 throw processException(e);
1900 }
1901 finally {
1902 FinderCacheUtil.clearCache(SCProductEntryModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
1903 }
1904 }
1905
1906 public void addSCLicenses(long pk, long[] scLicensePKs)
1907 throws SystemException {
1908 try {
1909 for (long scLicensePK : scLicensePKs) {
1910 addSCLicense.add(pk, scLicensePK);
1911 }
1912 }
1913 catch (Exception e) {
1914 throw processException(e);
1915 }
1916 finally {
1917 FinderCacheUtil.clearCache(SCProductEntryModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
1918 }
1919 }
1920
1921 public void addSCLicenses(long pk,
1922 List<com.liferay.portlet.softwarecatalog.model.SCLicense> scLicenses)
1923 throws SystemException {
1924 try {
1925 for (com.liferay.portlet.softwarecatalog.model.SCLicense scLicense : scLicenses) {
1926 addSCLicense.add(pk, scLicense.getPrimaryKey());
1927 }
1928 }
1929 catch (Exception e) {
1930 throw processException(e);
1931 }
1932 finally {
1933 FinderCacheUtil.clearCache(SCProductEntryModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
1934 }
1935 }
1936
1937 public void clearSCLicenses(long pk) throws SystemException {
1938 try {
1939 clearSCLicenses.clear(pk);
1940 }
1941 catch (Exception e) {
1942 throw processException(e);
1943 }
1944 finally {
1945 FinderCacheUtil.clearCache(SCProductEntryModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
1946 }
1947 }
1948
1949 public void removeSCLicense(long pk, long scLicensePK)
1950 throws SystemException {
1951 try {
1952 removeSCLicense.remove(pk, scLicensePK);
1953 }
1954 catch (Exception e) {
1955 throw processException(e);
1956 }
1957 finally {
1958 FinderCacheUtil.clearCache(SCProductEntryModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
1959 }
1960 }
1961
1962 public void removeSCLicense(long pk,
1963 com.liferay.portlet.softwarecatalog.model.SCLicense scLicense)
1964 throws SystemException {
1965 try {
1966 removeSCLicense.remove(pk, scLicense.getPrimaryKey());
1967 }
1968 catch (Exception e) {
1969 throw processException(e);
1970 }
1971 finally {
1972 FinderCacheUtil.clearCache(SCProductEntryModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
1973 }
1974 }
1975
1976 public void removeSCLicenses(long pk, long[] scLicensePKs)
1977 throws SystemException {
1978 try {
1979 for (long scLicensePK : scLicensePKs) {
1980 removeSCLicense.remove(pk, scLicensePK);
1981 }
1982 }
1983 catch (Exception e) {
1984 throw processException(e);
1985 }
1986 finally {
1987 FinderCacheUtil.clearCache(SCProductEntryModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
1988 }
1989 }
1990
1991 public void removeSCLicenses(long pk,
1992 List<com.liferay.portlet.softwarecatalog.model.SCLicense> scLicenses)
1993 throws SystemException {
1994 try {
1995 for (com.liferay.portlet.softwarecatalog.model.SCLicense scLicense : scLicenses) {
1996 removeSCLicense.remove(pk, scLicense.getPrimaryKey());
1997 }
1998 }
1999 catch (Exception e) {
2000 throw processException(e);
2001 }
2002 finally {
2003 FinderCacheUtil.clearCache(SCProductEntryModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
2004 }
2005 }
2006
2007 public void setSCLicenses(long pk, long[] scLicensePKs)
2008 throws SystemException {
2009 try {
2010 Set<Long> scLicensePKSet = SetUtil.fromArray(scLicensePKs);
2011
2012 List<com.liferay.portlet.softwarecatalog.model.SCLicense> scLicenses =
2013 getSCLicenses(pk);
2014
2015 for (com.liferay.portlet.softwarecatalog.model.SCLicense scLicense : scLicenses) {
2016 if (!scLicensePKSet.contains(scLicense.getPrimaryKey())) {
2017 removeSCLicense.remove(pk, scLicense.getPrimaryKey());
2018 }
2019 else {
2020 scLicensePKSet.remove(scLicense.getPrimaryKey());
2021 }
2022 }
2023
2024 for (Long scLicensePK : scLicensePKSet) {
2025 addSCLicense.add(pk, scLicensePK);
2026 }
2027 }
2028 catch (Exception e) {
2029 throw processException(e);
2030 }
2031 finally {
2032 FinderCacheUtil.clearCache(SCProductEntryModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
2033 }
2034 }
2035
2036 public void setSCLicenses(long pk,
2037 List<com.liferay.portlet.softwarecatalog.model.SCLicense> scLicenses)
2038 throws SystemException {
2039 try {
2040 long[] scLicensePKs = new long[scLicenses.size()];
2041
2042 for (int i = 0; i < scLicenses.size(); i++) {
2043 com.liferay.portlet.softwarecatalog.model.SCLicense scLicense = scLicenses.get(i);
2044
2045 scLicensePKs[i] = scLicense.getPrimaryKey();
2046 }
2047
2048 setSCLicenses(pk, scLicensePKs);
2049 }
2050 catch (Exception e) {
2051 throw processException(e);
2052 }
2053 finally {
2054 FinderCacheUtil.clearCache(SCProductEntryModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
2055 }
2056 }
2057
2058 public void afterPropertiesSet() {
2059 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
2060 com.liferay.portal.util.PropsUtil.get(
2061 "value.object.listener.com.liferay.portlet.softwarecatalog.model.SCProductEntry")));
2062
2063 if (listenerClassNames.length > 0) {
2064 try {
2065 List<ModelListener<SCProductEntry>> listenersList = new ArrayList<ModelListener<SCProductEntry>>();
2066
2067 for (String listenerClassName : listenerClassNames) {
2068 listenersList.add((ModelListener<SCProductEntry>)Class.forName(
2069 listenerClassName).newInstance());
2070 }
2071
2072 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
2073 }
2074 catch (Exception e) {
2075 _log.error(e);
2076 }
2077 }
2078
2079 containsSCLicense = new ContainsSCLicense(this);
2080
2081 addSCLicense = new AddSCLicense(this);
2082 clearSCLicenses = new ClearSCLicenses(this);
2083 removeSCLicense = new RemoveSCLicense(this);
2084 }
2085
2086 @BeanReference(name = "com.liferay.portlet.softwarecatalog.service.persistence.SCLicensePersistence")
2087 protected com.liferay.portlet.softwarecatalog.service.persistence.SCLicensePersistence scLicensePersistence;
2088 @BeanReference(name = "com.liferay.portlet.softwarecatalog.service.persistence.SCFrameworkVersionPersistence")
2089 protected com.liferay.portlet.softwarecatalog.service.persistence.SCFrameworkVersionPersistence scFrameworkVersionPersistence;
2090 @BeanReference(name = "com.liferay.portlet.softwarecatalog.service.persistence.SCProductEntryPersistence")
2091 protected com.liferay.portlet.softwarecatalog.service.persistence.SCProductEntryPersistence scProductEntryPersistence;
2092 @BeanReference(name = "com.liferay.portlet.softwarecatalog.service.persistence.SCProductScreenshotPersistence")
2093 protected com.liferay.portlet.softwarecatalog.service.persistence.SCProductScreenshotPersistence scProductScreenshotPersistence;
2094 @BeanReference(name = "com.liferay.portlet.softwarecatalog.service.persistence.SCProductVersionPersistence")
2095 protected com.liferay.portlet.softwarecatalog.service.persistence.SCProductVersionPersistence scProductVersionPersistence;
2096 @BeanReference(name = "com.liferay.portal.service.persistence.ImagePersistence")
2097 protected com.liferay.portal.service.persistence.ImagePersistence imagePersistence;
2098 @BeanReference(name = "com.liferay.portal.service.persistence.ResourcePersistence")
2099 protected com.liferay.portal.service.persistence.ResourcePersistence resourcePersistence;
2100 @BeanReference(name = "com.liferay.portal.service.persistence.UserPersistence")
2101 protected com.liferay.portal.service.persistence.UserPersistence userPersistence;
2102 @BeanReference(name = "com.liferay.portlet.messageboards.service.persistence.MBMessagePersistence")
2103 protected com.liferay.portlet.messageboards.service.persistence.MBMessagePersistence mbMessagePersistence;
2104 @BeanReference(name = "com.liferay.portlet.ratings.service.persistence.RatingsStatsPersistence")
2105 protected com.liferay.portlet.ratings.service.persistence.RatingsStatsPersistence ratingsStatsPersistence;
2106 protected ContainsSCLicense containsSCLicense;
2107 protected AddSCLicense addSCLicense;
2108 protected ClearSCLicenses clearSCLicenses;
2109 protected RemoveSCLicense removeSCLicense;
2110
2111 protected class ContainsSCLicense {
2112 protected ContainsSCLicense(
2113 SCProductEntryPersistenceImpl persistenceImpl) {
2114 super();
2115
2116 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
2117 _SQL_CONTAINSSCLICENSE,
2118 new int[] { Types.BIGINT, Types.BIGINT }, RowMapper.COUNT);
2119 }
2120
2121 protected boolean contains(long productEntryId, long licenseId) {
2122 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
2123 new Long(productEntryId), new Long(licenseId)
2124 });
2125
2126 if (results.size() > 0) {
2127 Integer count = results.get(0);
2128
2129 if (count.intValue() > 0) {
2130 return true;
2131 }
2132 }
2133
2134 return false;
2135 }
2136
2137 private MappingSqlQuery _mappingSqlQuery;
2138 }
2139
2140 protected class AddSCLicense {
2141 protected AddSCLicense(SCProductEntryPersistenceImpl persistenceImpl) {
2142 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
2143 "INSERT INTO SCLicenses_SCProductEntries (productEntryId, licenseId) VALUES (?, ?)",
2144 new int[] { Types.BIGINT, Types.BIGINT });
2145 _persistenceImpl = persistenceImpl;
2146 }
2147
2148 protected void add(long productEntryId, long licenseId) {
2149 if (!_persistenceImpl.containsSCLicense.contains(productEntryId,
2150 licenseId)) {
2151 _sqlUpdate.update(new Object[] {
2152 new Long(productEntryId), new Long(licenseId)
2153 });
2154 }
2155 }
2156
2157 private SqlUpdate _sqlUpdate;
2158 private SCProductEntryPersistenceImpl _persistenceImpl;
2159 }
2160
2161 protected class ClearSCLicenses {
2162 protected ClearSCLicenses(SCProductEntryPersistenceImpl persistenceImpl) {
2163 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
2164 "DELETE FROM SCLicenses_SCProductEntries WHERE productEntryId = ?",
2165 new int[] { Types.BIGINT });
2166 }
2167
2168 protected void clear(long productEntryId) {
2169 _sqlUpdate.update(new Object[] { new Long(productEntryId) });
2170 }
2171
2172 private SqlUpdate _sqlUpdate;
2173 }
2174
2175 protected class RemoveSCLicense {
2176 protected RemoveSCLicense(SCProductEntryPersistenceImpl persistenceImpl) {
2177 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
2178 "DELETE FROM SCLicenses_SCProductEntries WHERE productEntryId = ? AND licenseId = ?",
2179 new int[] { Types.BIGINT, Types.BIGINT });
2180 }
2181
2182 protected void remove(long productEntryId, long licenseId) {
2183 _sqlUpdate.update(new Object[] {
2184 new Long(productEntryId), new Long(licenseId)
2185 });
2186 }
2187
2188 private SqlUpdate _sqlUpdate;
2189 }
2190
2191 private static final String _SQL_SELECT_SCPRODUCTENTRY = "SELECT scProductEntry FROM SCProductEntry scProductEntry";
2192 private static final String _SQL_SELECT_SCPRODUCTENTRY_WHERE = "SELECT scProductEntry FROM SCProductEntry scProductEntry WHERE ";
2193 private static final String _SQL_COUNT_SCPRODUCTENTRY = "SELECT COUNT(scProductEntry) FROM SCProductEntry scProductEntry";
2194 private static final String _SQL_COUNT_SCPRODUCTENTRY_WHERE = "SELECT COUNT(scProductEntry) FROM SCProductEntry scProductEntry WHERE ";
2195 private static final String _SQL_GETSCLICENSES = "SELECT {SCLicense.*} FROM SCLicense INNER JOIN SCLicenses_SCProductEntries ON (SCLicenses_SCProductEntries.licenseId = SCLicense.licenseId) WHERE (SCLicenses_SCProductEntries.productEntryId = ?)";
2196 private static final String _SQL_GETSCLICENSESSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM SCLicenses_SCProductEntries WHERE productEntryId = ?";
2197 private static final String _SQL_CONTAINSSCLICENSE = "SELECT COUNT(*) AS COUNT_VALUE FROM SCLicenses_SCProductEntries WHERE productEntryId = ? AND licenseId = ?";
2198 private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "scProductEntry.groupId = ?";
2199 private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "scProductEntry.companyId = ?";
2200 private static final String _FINDER_COLUMN_G_U_GROUPID_2 = "scProductEntry.groupId = ? AND ";
2201 private static final String _FINDER_COLUMN_G_U_USERID_2 = "scProductEntry.userId = ?";
2202 private static final String _FINDER_COLUMN_RG_RA_REPOGROUPID_1 = "scProductEntry.repoGroupId IS NULL AND ";
2203 private static final String _FINDER_COLUMN_RG_RA_REPOGROUPID_2 = "scProductEntry.lower(repoGroupId) = ? AND ";
2204 private static final String _FINDER_COLUMN_RG_RA_REPOGROUPID_3 = "(scProductEntry.repoGroupId IS NULL OR scProductEntry.lower(repoGroupId) = ?) AND ";
2205 private static final String _FINDER_COLUMN_RG_RA_REPOARTIFACTID_1 = "scProductEntry.repoArtifactId IS NULL";
2206 private static final String _FINDER_COLUMN_RG_RA_REPOARTIFACTID_2 = "scProductEntry.lower(repoArtifactId) = ?";
2207 private static final String _FINDER_COLUMN_RG_RA_REPOARTIFACTID_3 = "(scProductEntry.repoArtifactId IS NULL OR scProductEntry.lower(repoArtifactId) = ?)";
2208 private static final String _ORDER_BY_ENTITY_ALIAS = "scProductEntry.";
2209 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No SCProductEntry exists with the primary key ";
2210 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No SCProductEntry exists with the key {";
2211 private static Log _log = LogFactoryUtil.getLog(SCProductEntryPersistenceImpl.class);
2212}