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