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