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