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