001    /**
002     * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portlet.softwarecatalog.service.persistence;
016    
017    import com.liferay.portal.NoSuchModelException;
018    import com.liferay.portal.kernel.annotation.BeanReference;
019    import com.liferay.portal.kernel.cache.CacheRegistryUtil;
020    import com.liferay.portal.kernel.dao.jdbc.MappingSqlQuery;
021    import com.liferay.portal.kernel.dao.jdbc.MappingSqlQueryFactoryUtil;
022    import com.liferay.portal.kernel.dao.jdbc.RowMapper;
023    import com.liferay.portal.kernel.dao.jdbc.SqlUpdate;
024    import com.liferay.portal.kernel.dao.jdbc.SqlUpdateFactoryUtil;
025    import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
026    import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
027    import com.liferay.portal.kernel.dao.orm.FinderPath;
028    import com.liferay.portal.kernel.dao.orm.Query;
029    import com.liferay.portal.kernel.dao.orm.QueryPos;
030    import com.liferay.portal.kernel.dao.orm.QueryUtil;
031    import com.liferay.portal.kernel.dao.orm.SQLQuery;
032    import com.liferay.portal.kernel.dao.orm.Session;
033    import com.liferay.portal.kernel.exception.SystemException;
034    import com.liferay.portal.kernel.log.Log;
035    import com.liferay.portal.kernel.log.LogFactoryUtil;
036    import com.liferay.portal.kernel.util.GetterUtil;
037    import com.liferay.portal.kernel.util.InstanceFactory;
038    import com.liferay.portal.kernel.util.OrderByComparator;
039    import com.liferay.portal.kernel.util.SetUtil;
040    import com.liferay.portal.kernel.util.StringBundler;
041    import com.liferay.portal.kernel.util.StringPool;
042    import com.liferay.portal.kernel.util.StringUtil;
043    import com.liferay.portal.kernel.util.Validator;
044    import com.liferay.portal.model.ModelListener;
045    import com.liferay.portal.security.permission.InlineSQLHelperUtil;
046    import com.liferay.portal.service.persistence.BatchSessionUtil;
047    import com.liferay.portal.service.persistence.GroupPersistence;
048    import com.liferay.portal.service.persistence.ImagePersistence;
049    import com.liferay.portal.service.persistence.ResourcePersistence;
050    import com.liferay.portal.service.persistence.UserPersistence;
051    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
052    
053    import com.liferay.portlet.messageboards.service.persistence.MBMessagePersistence;
054    import com.liferay.portlet.ratings.service.persistence.RatingsStatsPersistence;
055    import com.liferay.portlet.softwarecatalog.NoSuchProductEntryException;
056    import com.liferay.portlet.softwarecatalog.model.SCProductEntry;
057    import com.liferay.portlet.softwarecatalog.model.impl.SCProductEntryImpl;
058    import com.liferay.portlet.softwarecatalog.model.impl.SCProductEntryModelImpl;
059    
060    import java.io.Serializable;
061    
062    import java.util.ArrayList;
063    import java.util.Collections;
064    import java.util.List;
065    import java.util.Set;
066    
067    /**
068     * The persistence implementation for the s c product entry service.
069     *
070     * <p>
071     * Never modify or reference this class directly. Always use {@link SCProductEntryUtil} to access the s c product entry persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
072     * </p>
073     *
074     * <p>
075     * Caching information and settings can be found in <code>portal.properties</code>
076     * </p>
077     *
078     * @author Brian Wing Shun Chan
079     * @see SCProductEntryPersistence
080     * @see SCProductEntryUtil
081     * @generated
082     */
083    public class SCProductEntryPersistenceImpl extends BasePersistenceImpl<SCProductEntry>
084            implements SCProductEntryPersistence {
085            public static final String FINDER_CLASS_NAME_ENTITY = SCProductEntryImpl.class.getName();
086            public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
087                    ".List";
088            public static final FinderPath FINDER_PATH_FIND_BY_GROUPID = new FinderPath(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
089                            SCProductEntryModelImpl.FINDER_CACHE_ENABLED,
090                            FINDER_CLASS_NAME_LIST, "findByGroupId",
091                            new String[] {
092                                    Long.class.getName(),
093                                    
094                            "java.lang.Integer", "java.lang.Integer",
095                                    "com.liferay.portal.kernel.util.OrderByComparator"
096                            });
097            public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
098                            SCProductEntryModelImpl.FINDER_CACHE_ENABLED,
099                            FINDER_CLASS_NAME_LIST, "countByGroupId",
100                            new String[] { Long.class.getName() });
101            public static final FinderPath FINDER_PATH_FIND_BY_COMPANYID = new FinderPath(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
102                            SCProductEntryModelImpl.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(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
111                            SCProductEntryModelImpl.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_U = new FinderPath(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
115                            SCProductEntryModelImpl.FINDER_CACHE_ENABLED,
116                            FINDER_CLASS_NAME_LIST, "findByG_U",
117                            new String[] {
118                                    Long.class.getName(), Long.class.getName(),
119                                    
120                            "java.lang.Integer", "java.lang.Integer",
121                                    "com.liferay.portal.kernel.util.OrderByComparator"
122                            });
123            public static final FinderPath FINDER_PATH_COUNT_BY_G_U = new FinderPath(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
124                            SCProductEntryModelImpl.FINDER_CACHE_ENABLED,
125                            FINDER_CLASS_NAME_LIST, "countByG_U",
126                            new String[] { Long.class.getName(), Long.class.getName() });
127            public static final FinderPath FINDER_PATH_FETCH_BY_RG_RA = new FinderPath(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
128                            SCProductEntryModelImpl.FINDER_CACHE_ENABLED,
129                            FINDER_CLASS_NAME_ENTITY, "fetchByRG_RA",
130                            new String[] { String.class.getName(), String.class.getName() });
131            public static final FinderPath FINDER_PATH_COUNT_BY_RG_RA = new FinderPath(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
132                            SCProductEntryModelImpl.FINDER_CACHE_ENABLED,
133                            FINDER_CLASS_NAME_LIST, "countByRG_RA",
134                            new String[] { String.class.getName(), String.class.getName() });
135            public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
136                            SCProductEntryModelImpl.FINDER_CACHE_ENABLED,
137                            FINDER_CLASS_NAME_LIST, "findAll", new String[0]);
138            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
139                            SCProductEntryModelImpl.FINDER_CACHE_ENABLED,
140                            FINDER_CLASS_NAME_LIST, "countAll", new String[0]);
141    
142            /**
143             * Caches the s c product entry in the entity cache if it is enabled.
144             *
145             * @param scProductEntry the s c product entry to cache
146             */
147            public void cacheResult(SCProductEntry scProductEntry) {
148                    EntityCacheUtil.putResult(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
149                            SCProductEntryImpl.class, scProductEntry.getPrimaryKey(),
150                            scProductEntry);
151    
152                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_RG_RA,
153                            new Object[] {
154                                    scProductEntry.getRepoGroupId(),
155                                    
156                            scProductEntry.getRepoArtifactId()
157                            }, scProductEntry);
158            }
159    
160            /**
161             * Caches the s c product entries in the entity cache if it is enabled.
162             *
163             * @param scProductEntries the s c product entries to cache
164             */
165            public void cacheResult(List<SCProductEntry> scProductEntries) {
166                    for (SCProductEntry scProductEntry : scProductEntries) {
167                            if (EntityCacheUtil.getResult(
168                                                    SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
169                                                    SCProductEntryImpl.class,
170                                                    scProductEntry.getPrimaryKey(), this) == null) {
171                                    cacheResult(scProductEntry);
172                            }
173                    }
174            }
175    
176            /**
177             * Clears the cache for all s c product entries.
178             *
179             * <p>
180             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
181             * </p>
182             */
183            public void clearCache() {
184                    CacheRegistryUtil.clear(SCProductEntryImpl.class.getName());
185                    EntityCacheUtil.clearCache(SCProductEntryImpl.class.getName());
186                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
187                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
188            }
189    
190            /**
191             * Clears the cache for the s c product entry.
192             *
193             * <p>
194             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
195             * </p>
196             */
197            public void clearCache(SCProductEntry scProductEntry) {
198                    EntityCacheUtil.removeResult(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
199                            SCProductEntryImpl.class, scProductEntry.getPrimaryKey());
200    
201                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_RG_RA,
202                            new Object[] {
203                                    scProductEntry.getRepoGroupId(),
204                                    
205                            scProductEntry.getRepoArtifactId()
206                            });
207            }
208    
209            /**
210             * Creates a new s c product entry with the primary key. Does not add the s c product entry to the database.
211             *
212             * @param productEntryId the primary key for the new s c product entry
213             * @return the new s c product entry
214             */
215            public SCProductEntry create(long productEntryId) {
216                    SCProductEntry scProductEntry = new SCProductEntryImpl();
217    
218                    scProductEntry.setNew(true);
219                    scProductEntry.setPrimaryKey(productEntryId);
220    
221                    return scProductEntry;
222            }
223    
224            /**
225             * Removes the s c product entry with the primary key from the database. Also notifies the appropriate model listeners.
226             *
227             * @param primaryKey the primary key of the s c product entry to remove
228             * @return the s c product entry that was removed
229             * @throws com.liferay.portal.NoSuchModelException if a s c product entry with the primary key could not be found
230             * @throws SystemException if a system exception occurred
231             */
232            public SCProductEntry remove(Serializable primaryKey)
233                    throws NoSuchModelException, SystemException {
234                    return remove(((Long)primaryKey).longValue());
235            }
236    
237            /**
238             * Removes the s c product entry with the primary key from the database. Also notifies the appropriate model listeners.
239             *
240             * @param productEntryId the primary key of the s c product entry to remove
241             * @return the s c product entry that was removed
242             * @throws com.liferay.portlet.softwarecatalog.NoSuchProductEntryException if a s c product entry with the primary key could not be found
243             * @throws SystemException if a system exception occurred
244             */
245            public SCProductEntry remove(long productEntryId)
246                    throws NoSuchProductEntryException, SystemException {
247                    Session session = null;
248    
249                    try {
250                            session = openSession();
251    
252                            SCProductEntry scProductEntry = (SCProductEntry)session.get(SCProductEntryImpl.class,
253                                            new Long(productEntryId));
254    
255                            if (scProductEntry == null) {
256                                    if (_log.isWarnEnabled()) {
257                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
258                                                    productEntryId);
259                                    }
260    
261                                    throw new NoSuchProductEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
262                                            productEntryId);
263                            }
264    
265                            return remove(scProductEntry);
266                    }
267                    catch (NoSuchProductEntryException nsee) {
268                            throw nsee;
269                    }
270                    catch (Exception e) {
271                            throw processException(e);
272                    }
273                    finally {
274                            closeSession(session);
275                    }
276            }
277    
278            protected SCProductEntry removeImpl(SCProductEntry scProductEntry)
279                    throws SystemException {
280                    scProductEntry = toUnwrappedModel(scProductEntry);
281    
282                    try {
283                            clearSCLicenses.clear(scProductEntry.getPrimaryKey());
284                    }
285                    catch (Exception e) {
286                            throw processException(e);
287                    }
288                    finally {
289                            FinderCacheUtil.clearCache(SCProductEntryModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
290                    }
291    
292                    Session session = null;
293    
294                    try {
295                            session = openSession();
296    
297                            BatchSessionUtil.delete(session, scProductEntry);
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                    SCProductEntryModelImpl scProductEntryModelImpl = (SCProductEntryModelImpl)scProductEntry;
309    
310                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_RG_RA,
311                            new Object[] {
312                                    scProductEntryModelImpl.getRepoGroupId(),
313                                    
314                            scProductEntryModelImpl.getRepoArtifactId()
315                            });
316    
317                    EntityCacheUtil.removeResult(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
318                            SCProductEntryImpl.class, scProductEntry.getPrimaryKey());
319    
320                    return scProductEntry;
321            }
322    
323            public SCProductEntry updateImpl(
324                    com.liferay.portlet.softwarecatalog.model.SCProductEntry scProductEntry,
325                    boolean merge) throws SystemException {
326                    scProductEntry = toUnwrappedModel(scProductEntry);
327    
328                    boolean isNew = scProductEntry.isNew();
329    
330                    SCProductEntryModelImpl scProductEntryModelImpl = (SCProductEntryModelImpl)scProductEntry;
331    
332                    Session session = null;
333    
334                    try {
335                            session = openSession();
336    
337                            BatchSessionUtil.update(session, scProductEntry, merge);
338    
339                            scProductEntry.setNew(false);
340                    }
341                    catch (Exception e) {
342                            throw processException(e);
343                    }
344                    finally {
345                            closeSession(session);
346                    }
347    
348                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
349    
350                    EntityCacheUtil.putResult(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
351                            SCProductEntryImpl.class, scProductEntry.getPrimaryKey(),
352                            scProductEntry);
353    
354                    if (!isNew &&
355                                    (!Validator.equals(scProductEntry.getRepoGroupId(),
356                                            scProductEntryModelImpl.getOriginalRepoGroupId()) ||
357                                    !Validator.equals(scProductEntry.getRepoArtifactId(),
358                                            scProductEntryModelImpl.getOriginalRepoArtifactId()))) {
359                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_RG_RA,
360                                    new Object[] {
361                                            scProductEntryModelImpl.getOriginalRepoGroupId(),
362                                            
363                                    scProductEntryModelImpl.getOriginalRepoArtifactId()
364                                    });
365                    }
366    
367                    if (isNew ||
368                                    (!Validator.equals(scProductEntry.getRepoGroupId(),
369                                            scProductEntryModelImpl.getOriginalRepoGroupId()) ||
370                                    !Validator.equals(scProductEntry.getRepoArtifactId(),
371                                            scProductEntryModelImpl.getOriginalRepoArtifactId()))) {
372                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_RG_RA,
373                                    new Object[] {
374                                            scProductEntry.getRepoGroupId(),
375                                            
376                                    scProductEntry.getRepoArtifactId()
377                                    }, scProductEntry);
378                    }
379    
380                    return scProductEntry;
381            }
382    
383            protected SCProductEntry toUnwrappedModel(SCProductEntry scProductEntry) {
384                    if (scProductEntry instanceof SCProductEntryImpl) {
385                            return scProductEntry;
386                    }
387    
388                    SCProductEntryImpl scProductEntryImpl = new SCProductEntryImpl();
389    
390                    scProductEntryImpl.setNew(scProductEntry.isNew());
391                    scProductEntryImpl.setPrimaryKey(scProductEntry.getPrimaryKey());
392    
393                    scProductEntryImpl.setProductEntryId(scProductEntry.getProductEntryId());
394                    scProductEntryImpl.setGroupId(scProductEntry.getGroupId());
395                    scProductEntryImpl.setCompanyId(scProductEntry.getCompanyId());
396                    scProductEntryImpl.setUserId(scProductEntry.getUserId());
397                    scProductEntryImpl.setUserName(scProductEntry.getUserName());
398                    scProductEntryImpl.setCreateDate(scProductEntry.getCreateDate());
399                    scProductEntryImpl.setModifiedDate(scProductEntry.getModifiedDate());
400                    scProductEntryImpl.setName(scProductEntry.getName());
401                    scProductEntryImpl.setType(scProductEntry.getType());
402                    scProductEntryImpl.setTags(scProductEntry.getTags());
403                    scProductEntryImpl.setShortDescription(scProductEntry.getShortDescription());
404                    scProductEntryImpl.setLongDescription(scProductEntry.getLongDescription());
405                    scProductEntryImpl.setPageURL(scProductEntry.getPageURL());
406                    scProductEntryImpl.setAuthor(scProductEntry.getAuthor());
407                    scProductEntryImpl.setRepoGroupId(scProductEntry.getRepoGroupId());
408                    scProductEntryImpl.setRepoArtifactId(scProductEntry.getRepoArtifactId());
409    
410                    return scProductEntryImpl;
411            }
412    
413            /**
414             * Finds the s c product entry with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
415             *
416             * @param primaryKey the primary key of the s c product entry to find
417             * @return the s c product entry
418             * @throws com.liferay.portal.NoSuchModelException if a s c product entry with the primary key could not be found
419             * @throws SystemException if a system exception occurred
420             */
421            public SCProductEntry findByPrimaryKey(Serializable primaryKey)
422                    throws NoSuchModelException, SystemException {
423                    return findByPrimaryKey(((Long)primaryKey).longValue());
424            }
425    
426            /**
427             * Finds the s c product entry with the primary key or throws a {@link com.liferay.portlet.softwarecatalog.NoSuchProductEntryException} if it could not be found.
428             *
429             * @param productEntryId the primary key of the s c product entry to find
430             * @return the s c product entry
431             * @throws com.liferay.portlet.softwarecatalog.NoSuchProductEntryException if a s c product entry with the primary key could not be found
432             * @throws SystemException if a system exception occurred
433             */
434            public SCProductEntry findByPrimaryKey(long productEntryId)
435                    throws NoSuchProductEntryException, SystemException {
436                    SCProductEntry scProductEntry = fetchByPrimaryKey(productEntryId);
437    
438                    if (scProductEntry == null) {
439                            if (_log.isWarnEnabled()) {
440                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + productEntryId);
441                            }
442    
443                            throw new NoSuchProductEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
444                                    productEntryId);
445                    }
446    
447                    return scProductEntry;
448            }
449    
450            /**
451             * Finds the s c product entry with the primary key or returns <code>null</code> if it could not be found.
452             *
453             * @param primaryKey the primary key of the s c product entry to find
454             * @return the s c product entry, or <code>null</code> if a s c product entry with the primary key could not be found
455             * @throws SystemException if a system exception occurred
456             */
457            public SCProductEntry fetchByPrimaryKey(Serializable primaryKey)
458                    throws SystemException {
459                    return fetchByPrimaryKey(((Long)primaryKey).longValue());
460            }
461    
462            /**
463             * Finds the s c product entry with the primary key or returns <code>null</code> if it could not be found.
464             *
465             * @param productEntryId the primary key of the s c product entry to find
466             * @return the s c product entry, or <code>null</code> if a s c product entry with the primary key could not be found
467             * @throws SystemException if a system exception occurred
468             */
469            public SCProductEntry fetchByPrimaryKey(long productEntryId)
470                    throws SystemException {
471                    SCProductEntry scProductEntry = (SCProductEntry)EntityCacheUtil.getResult(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
472                                    SCProductEntryImpl.class, productEntryId, this);
473    
474                    if (scProductEntry == null) {
475                            Session session = null;
476    
477                            try {
478                                    session = openSession();
479    
480                                    scProductEntry = (SCProductEntry)session.get(SCProductEntryImpl.class,
481                                                    new Long(productEntryId));
482                            }
483                            catch (Exception e) {
484                                    throw processException(e);
485                            }
486                            finally {
487                                    if (scProductEntry != null) {
488                                            cacheResult(scProductEntry);
489                                    }
490    
491                                    closeSession(session);
492                            }
493                    }
494    
495                    return scProductEntry;
496            }
497    
498            /**
499             * Finds all the s c product entries where groupId = &#63;.
500             *
501             * @param groupId the group id to search with
502             * @return the matching s c product entries
503             * @throws SystemException if a system exception occurred
504             */
505            public List<SCProductEntry> findByGroupId(long groupId)
506                    throws SystemException {
507                    return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
508            }
509    
510            /**
511             * Finds a range of all the s c product entries where groupId = &#63;.
512             *
513             * <p>
514             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
515             * </p>
516             *
517             * @param groupId the group id to search with
518             * @param start the lower bound of the range of s c product entries to return
519             * @param end the upper bound of the range of s c product entries to return (not inclusive)
520             * @return the range of matching s c product entries
521             * @throws SystemException if a system exception occurred
522             */
523            public List<SCProductEntry> findByGroupId(long groupId, int start, int end)
524                    throws SystemException {
525                    return findByGroupId(groupId, start, end, null);
526            }
527    
528            /**
529             * Finds an ordered range of all the s c product entries where groupId = &#63;.
530             *
531             * <p>
532             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
533             * </p>
534             *
535             * @param groupId the group id to search with
536             * @param start the lower bound of the range of s c product entries to return
537             * @param end the upper bound of the range of s c product entries to return (not inclusive)
538             * @param orderByComparator the comparator to order the results by
539             * @return the ordered range of matching s c product entries
540             * @throws SystemException if a system exception occurred
541             */
542            public List<SCProductEntry> findByGroupId(long groupId, int start, int end,
543                    OrderByComparator orderByComparator) throws SystemException {
544                    Object[] finderArgs = new Object[] {
545                                    groupId,
546                                    
547                                    String.valueOf(start), String.valueOf(end),
548                                    String.valueOf(orderByComparator)
549                            };
550    
551                    List<SCProductEntry> list = (List<SCProductEntry>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_GROUPID,
552                                    finderArgs, this);
553    
554                    if (list == null) {
555                            StringBundler query = null;
556    
557                            if (orderByComparator != null) {
558                                    query = new StringBundler(3 +
559                                                    (orderByComparator.getOrderByFields().length * 3));
560                            }
561                            else {
562                                    query = new StringBundler(3);
563                            }
564    
565                            query.append(_SQL_SELECT_SCPRODUCTENTRY_WHERE);
566    
567                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
568    
569                            if (orderByComparator != null) {
570                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
571                                            orderByComparator);
572                            }
573    
574                            else {
575                                    query.append(SCProductEntryModelImpl.ORDER_BY_JPQL);
576                            }
577    
578                            String sql = query.toString();
579    
580                            Session session = null;
581    
582                            try {
583                                    session = openSession();
584    
585                                    Query q = session.createQuery(sql);
586    
587                                    QueryPos qPos = QueryPos.getInstance(q);
588    
589                                    qPos.add(groupId);
590    
591                                    list = (List<SCProductEntry>)QueryUtil.list(q, getDialect(),
592                                                    start, end);
593                            }
594                            catch (Exception e) {
595                                    throw processException(e);
596                            }
597                            finally {
598                                    if (list == null) {
599                                            FinderCacheUtil.removeResult(FINDER_PATH_FIND_BY_GROUPID,
600                                                    finderArgs);
601                                    }
602                                    else {
603                                            cacheResult(list);
604    
605                                            FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_GROUPID,
606                                                    finderArgs, list);
607                                    }
608    
609                                    closeSession(session);
610                            }
611                    }
612    
613                    return list;
614            }
615    
616            /**
617             * Finds the first s c product entry in the ordered set where groupId = &#63;.
618             *
619             * <p>
620             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
621             * </p>
622             *
623             * @param groupId the group id to search with
624             * @param orderByComparator the comparator to order the set by
625             * @return the first matching s c product entry
626             * @throws com.liferay.portlet.softwarecatalog.NoSuchProductEntryException if a matching s c product entry could not be found
627             * @throws SystemException if a system exception occurred
628             */
629            public SCProductEntry findByGroupId_First(long groupId,
630                    OrderByComparator orderByComparator)
631                    throws NoSuchProductEntryException, SystemException {
632                    List<SCProductEntry> list = findByGroupId(groupId, 0, 1,
633                                    orderByComparator);
634    
635                    if (list.isEmpty()) {
636                            StringBundler msg = new StringBundler(4);
637    
638                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
639    
640                            msg.append("groupId=");
641                            msg.append(groupId);
642    
643                            msg.append(StringPool.CLOSE_CURLY_BRACE);
644    
645                            throw new NoSuchProductEntryException(msg.toString());
646                    }
647                    else {
648                            return list.get(0);
649                    }
650            }
651    
652            /**
653             * Finds the last s c product entry in the ordered set where groupId = &#63;.
654             *
655             * <p>
656             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
657             * </p>
658             *
659             * @param groupId the group id to search with
660             * @param orderByComparator the comparator to order the set by
661             * @return the last matching s c product entry
662             * @throws com.liferay.portlet.softwarecatalog.NoSuchProductEntryException if a matching s c product entry could not be found
663             * @throws SystemException if a system exception occurred
664             */
665            public SCProductEntry findByGroupId_Last(long groupId,
666                    OrderByComparator orderByComparator)
667                    throws NoSuchProductEntryException, SystemException {
668                    int count = countByGroupId(groupId);
669    
670                    List<SCProductEntry> list = findByGroupId(groupId, count - 1, count,
671                                    orderByComparator);
672    
673                    if (list.isEmpty()) {
674                            StringBundler msg = new StringBundler(4);
675    
676                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
677    
678                            msg.append("groupId=");
679                            msg.append(groupId);
680    
681                            msg.append(StringPool.CLOSE_CURLY_BRACE);
682    
683                            throw new NoSuchProductEntryException(msg.toString());
684                    }
685                    else {
686                            return list.get(0);
687                    }
688            }
689    
690            /**
691             * Finds the s c product entries before and after the current s c product entry in the ordered set where groupId = &#63;.
692             *
693             * <p>
694             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
695             * </p>
696             *
697             * @param productEntryId the primary key of the current s c product entry
698             * @param groupId the group id to search with
699             * @param orderByComparator the comparator to order the set by
700             * @return the previous, current, and next s c product entry
701             * @throws com.liferay.portlet.softwarecatalog.NoSuchProductEntryException if a s c product entry with the primary key could not be found
702             * @throws SystemException if a system exception occurred
703             */
704            public SCProductEntry[] findByGroupId_PrevAndNext(long productEntryId,
705                    long groupId, OrderByComparator orderByComparator)
706                    throws NoSuchProductEntryException, SystemException {
707                    SCProductEntry scProductEntry = findByPrimaryKey(productEntryId);
708    
709                    Session session = null;
710    
711                    try {
712                            session = openSession();
713    
714                            SCProductEntry[] array = new SCProductEntryImpl[3];
715    
716                            array[0] = getByGroupId_PrevAndNext(session, scProductEntry,
717                                            groupId, orderByComparator, true);
718    
719                            array[1] = scProductEntry;
720    
721                            array[2] = getByGroupId_PrevAndNext(session, scProductEntry,
722                                            groupId, orderByComparator, false);
723    
724                            return array;
725                    }
726                    catch (Exception e) {
727                            throw processException(e);
728                    }
729                    finally {
730                            closeSession(session);
731                    }
732            }
733    
734            protected SCProductEntry getByGroupId_PrevAndNext(Session session,
735                    SCProductEntry scProductEntry, long groupId,
736                    OrderByComparator orderByComparator, boolean previous) {
737                    StringBundler query = null;
738    
739                    if (orderByComparator != null) {
740                            query = new StringBundler(6 +
741                                            (orderByComparator.getOrderByFields().length * 6));
742                    }
743                    else {
744                            query = new StringBundler(3);
745                    }
746    
747                    query.append(_SQL_SELECT_SCPRODUCTENTRY_WHERE);
748    
749                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
750    
751                    if (orderByComparator != null) {
752                            String[] orderByFields = orderByComparator.getOrderByFields();
753    
754                            if (orderByFields.length > 0) {
755                                    query.append(WHERE_AND);
756                            }
757    
758                            for (int i = 0; i < orderByFields.length; i++) {
759                                    query.append(_ORDER_BY_ENTITY_ALIAS);
760                                    query.append(orderByFields[i]);
761    
762                                    if ((i + 1) < orderByFields.length) {
763                                            if (orderByComparator.isAscending() ^ previous) {
764                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
765                                            }
766                                            else {
767                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
768                                            }
769                                    }
770                                    else {
771                                            if (orderByComparator.isAscending() ^ previous) {
772                                                    query.append(WHERE_GREATER_THAN);
773                                            }
774                                            else {
775                                                    query.append(WHERE_LESSER_THAN);
776                                            }
777                                    }
778                            }
779    
780                            query.append(ORDER_BY_CLAUSE);
781    
782                            for (int i = 0; i < orderByFields.length; i++) {
783                                    query.append(_ORDER_BY_ENTITY_ALIAS);
784                                    query.append(orderByFields[i]);
785    
786                                    if ((i + 1) < orderByFields.length) {
787                                            if (orderByComparator.isAscending() ^ previous) {
788                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
789                                            }
790                                            else {
791                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
792                                            }
793                                    }
794                                    else {
795                                            if (orderByComparator.isAscending() ^ previous) {
796                                                    query.append(ORDER_BY_ASC);
797                                            }
798                                            else {
799                                                    query.append(ORDER_BY_DESC);
800                                            }
801                                    }
802                            }
803                    }
804    
805                    else {
806                            query.append(SCProductEntryModelImpl.ORDER_BY_JPQL);
807                    }
808    
809                    String sql = query.toString();
810    
811                    Query q = session.createQuery(sql);
812    
813                    q.setFirstResult(0);
814                    q.setMaxResults(2);
815    
816                    QueryPos qPos = QueryPos.getInstance(q);
817    
818                    qPos.add(groupId);
819    
820                    if (orderByComparator != null) {
821                            Object[] values = orderByComparator.getOrderByValues(scProductEntry);
822    
823                            for (Object value : values) {
824                                    qPos.add(value);
825                            }
826                    }
827    
828                    List<SCProductEntry> list = q.list();
829    
830                    if (list.size() == 2) {
831                            return list.get(1);
832                    }
833                    else {
834                            return null;
835                    }
836            }
837    
838            /**
839             * Filters by the user's permissions and finds all the s c product entries where groupId = &#63;.
840             *
841             * @param groupId the group id to search with
842             * @return the matching s c product entries that the user has permission to view
843             * @throws SystemException if a system exception occurred
844             */
845            public List<SCProductEntry> filterFindByGroupId(long groupId)
846                    throws SystemException {
847                    return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
848                            QueryUtil.ALL_POS, null);
849            }
850    
851            /**
852             * Filters by the user's permissions and finds a range of all the s c product entries where groupId = &#63;.
853             *
854             * <p>
855             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
856             * </p>
857             *
858             * @param groupId the group id to search with
859             * @param start the lower bound of the range of s c product entries to return
860             * @param end the upper bound of the range of s c product entries to return (not inclusive)
861             * @return the range of matching s c product entries that the user has permission to view
862             * @throws SystemException if a system exception occurred
863             */
864            public List<SCProductEntry> filterFindByGroupId(long groupId, int start,
865                    int end) throws SystemException {
866                    return filterFindByGroupId(groupId, start, end, null);
867            }
868    
869            /**
870             * Filters by the user's permissions and finds an ordered range of all the s c product entries where groupId = &#63;.
871             *
872             * <p>
873             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
874             * </p>
875             *
876             * @param groupId the group id to search with
877             * @param start the lower bound of the range of s c product entries to return
878             * @param end the upper bound of the range of s c product entries to return (not inclusive)
879             * @param orderByComparator the comparator to order the results by
880             * @return the ordered range of matching s c product entries that the user has permission to view
881             * @throws SystemException if a system exception occurred
882             */
883            public List<SCProductEntry> filterFindByGroupId(long groupId, int start,
884                    int end, OrderByComparator orderByComparator) throws SystemException {
885                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
886                            return findByGroupId(groupId, start, end, orderByComparator);
887                    }
888    
889                    StringBundler query = null;
890    
891                    if (orderByComparator != null) {
892                            query = new StringBundler(3 +
893                                            (orderByComparator.getOrderByFields().length * 3));
894                    }
895                    else {
896                            query = new StringBundler(3);
897                    }
898    
899                    if (getDB().isSupportsInlineDistinct()) {
900                            query.append(_FILTER_SQL_SELECT_SCPRODUCTENTRY_WHERE);
901                    }
902                    else {
903                            query.append(_FILTER_SQL_SELECT_SCPRODUCTENTRY_NO_INLINE_DISTINCT_WHERE_1);
904                    }
905    
906                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
907    
908                    if (!getDB().isSupportsInlineDistinct()) {
909                            query.append(_FILTER_SQL_SELECT_SCPRODUCTENTRY_NO_INLINE_DISTINCT_WHERE_2);
910                    }
911    
912                    if (orderByComparator != null) {
913                            if (getDB().isSupportsInlineDistinct()) {
914                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
915                                            orderByComparator);
916                            }
917                            else {
918                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
919                                            orderByComparator);
920                            }
921                    }
922    
923                    else {
924                            if (getDB().isSupportsInlineDistinct()) {
925                                    query.append(SCProductEntryModelImpl.ORDER_BY_JPQL);
926                            }
927                            else {
928                                    query.append(SCProductEntryModelImpl.ORDER_BY_SQL);
929                            }
930                    }
931    
932                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
933                                    SCProductEntry.class.getName(), _FILTER_COLUMN_PK,
934                                    _FILTER_COLUMN_USERID, groupId);
935    
936                    Session session = null;
937    
938                    try {
939                            session = openSession();
940    
941                            SQLQuery q = session.createSQLQuery(sql);
942    
943                            if (getDB().isSupportsInlineDistinct()) {
944                                    q.addEntity(_FILTER_ENTITY_ALIAS, SCProductEntryImpl.class);
945                            }
946                            else {
947                                    q.addEntity(_FILTER_ENTITY_TABLE, SCProductEntryImpl.class);
948                            }
949    
950                            QueryPos qPos = QueryPos.getInstance(q);
951    
952                            qPos.add(groupId);
953    
954                            return (List<SCProductEntry>)QueryUtil.list(q, getDialect(), start,
955                                    end);
956                    }
957                    catch (Exception e) {
958                            throw processException(e);
959                    }
960                    finally {
961                            closeSession(session);
962                    }
963            }
964    
965            /**
966             * Finds all the s c product entries where companyId = &#63;.
967             *
968             * @param companyId the company id to search with
969             * @return the matching s c product entries
970             * @throws SystemException if a system exception occurred
971             */
972            public List<SCProductEntry> findByCompanyId(long companyId)
973                    throws SystemException {
974                    return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
975                            null);
976            }
977    
978            /**
979             * Finds a range of all the s c product entries where companyId = &#63;.
980             *
981             * <p>
982             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
983             * </p>
984             *
985             * @param companyId the company id to search with
986             * @param start the lower bound of the range of s c product entries to return
987             * @param end the upper bound of the range of s c product entries to return (not inclusive)
988             * @return the range of matching s c product entries
989             * @throws SystemException if a system exception occurred
990             */
991            public List<SCProductEntry> findByCompanyId(long companyId, int start,
992                    int end) throws SystemException {
993                    return findByCompanyId(companyId, start, end, null);
994            }
995    
996            /**
997             * Finds an ordered range of all the s c product entries where companyId = &#63;.
998             *
999             * <p>
1000             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1001             * </p>
1002             *
1003             * @param companyId the company id to search with
1004             * @param start the lower bound of the range of s c product entries to return
1005             * @param end the upper bound of the range of s c product entries to return (not inclusive)
1006             * @param orderByComparator the comparator to order the results by
1007             * @return the ordered range of matching s c product entries
1008             * @throws SystemException if a system exception occurred
1009             */
1010            public List<SCProductEntry> findByCompanyId(long companyId, int start,
1011                    int end, OrderByComparator orderByComparator) throws SystemException {
1012                    Object[] finderArgs = new Object[] {
1013                                    companyId,
1014                                    
1015                                    String.valueOf(start), String.valueOf(end),
1016                                    String.valueOf(orderByComparator)
1017                            };
1018    
1019                    List<SCProductEntry> list = (List<SCProductEntry>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_COMPANYID,
1020                                    finderArgs, this);
1021    
1022                    if (list == null) {
1023                            StringBundler query = null;
1024    
1025                            if (orderByComparator != null) {
1026                                    query = new StringBundler(3 +
1027                                                    (orderByComparator.getOrderByFields().length * 3));
1028                            }
1029                            else {
1030                                    query = new StringBundler(3);
1031                            }
1032    
1033                            query.append(_SQL_SELECT_SCPRODUCTENTRY_WHERE);
1034    
1035                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1036    
1037                            if (orderByComparator != null) {
1038                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1039                                            orderByComparator);
1040                            }
1041    
1042                            else {
1043                                    query.append(SCProductEntryModelImpl.ORDER_BY_JPQL);
1044                            }
1045    
1046                            String sql = query.toString();
1047    
1048                            Session session = null;
1049    
1050                            try {
1051                                    session = openSession();
1052    
1053                                    Query q = session.createQuery(sql);
1054    
1055                                    QueryPos qPos = QueryPos.getInstance(q);
1056    
1057                                    qPos.add(companyId);
1058    
1059                                    list = (List<SCProductEntry>)QueryUtil.list(q, getDialect(),
1060                                                    start, end);
1061                            }
1062                            catch (Exception e) {
1063                                    throw processException(e);
1064                            }
1065                            finally {
1066                                    if (list == null) {
1067                                            FinderCacheUtil.removeResult(FINDER_PATH_FIND_BY_COMPANYID,
1068                                                    finderArgs);
1069                                    }
1070                                    else {
1071                                            cacheResult(list);
1072    
1073                                            FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_COMPANYID,
1074                                                    finderArgs, list);
1075                                    }
1076    
1077                                    closeSession(session);
1078                            }
1079                    }
1080    
1081                    return list;
1082            }
1083    
1084            /**
1085             * Finds the first s c product entry in the ordered set where companyId = &#63;.
1086             *
1087             * <p>
1088             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1089             * </p>
1090             *
1091             * @param companyId the company id to search with
1092             * @param orderByComparator the comparator to order the set by
1093             * @return the first matching s c product entry
1094             * @throws com.liferay.portlet.softwarecatalog.NoSuchProductEntryException if a matching s c product entry could not be found
1095             * @throws SystemException if a system exception occurred
1096             */
1097            public SCProductEntry findByCompanyId_First(long companyId,
1098                    OrderByComparator orderByComparator)
1099                    throws NoSuchProductEntryException, SystemException {
1100                    List<SCProductEntry> list = findByCompanyId(companyId, 0, 1,
1101                                    orderByComparator);
1102    
1103                    if (list.isEmpty()) {
1104                            StringBundler msg = new StringBundler(4);
1105    
1106                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1107    
1108                            msg.append("companyId=");
1109                            msg.append(companyId);
1110    
1111                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1112    
1113                            throw new NoSuchProductEntryException(msg.toString());
1114                    }
1115                    else {
1116                            return list.get(0);
1117                    }
1118            }
1119    
1120            /**
1121             * Finds the last s c product entry in the ordered set where companyId = &#63;.
1122             *
1123             * <p>
1124             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1125             * </p>
1126             *
1127             * @param companyId the company id to search with
1128             * @param orderByComparator the comparator to order the set by
1129             * @return the last matching s c product entry
1130             * @throws com.liferay.portlet.softwarecatalog.NoSuchProductEntryException if a matching s c product entry could not be found
1131             * @throws SystemException if a system exception occurred
1132             */
1133            public SCProductEntry findByCompanyId_Last(long companyId,
1134                    OrderByComparator orderByComparator)
1135                    throws NoSuchProductEntryException, SystemException {
1136                    int count = countByCompanyId(companyId);
1137    
1138                    List<SCProductEntry> list = findByCompanyId(companyId, count - 1,
1139                                    count, orderByComparator);
1140    
1141                    if (list.isEmpty()) {
1142                            StringBundler msg = new StringBundler(4);
1143    
1144                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1145    
1146                            msg.append("companyId=");
1147                            msg.append(companyId);
1148    
1149                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1150    
1151                            throw new NoSuchProductEntryException(msg.toString());
1152                    }
1153                    else {
1154                            return list.get(0);
1155                    }
1156            }
1157    
1158            /**
1159             * Finds the s c product entries before and after the current s c product entry in the ordered set where companyId = &#63;.
1160             *
1161             * <p>
1162             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1163             * </p>
1164             *
1165             * @param productEntryId the primary key of the current s c product entry
1166             * @param companyId the company id to search with
1167             * @param orderByComparator the comparator to order the set by
1168             * @return the previous, current, and next s c product entry
1169             * @throws com.liferay.portlet.softwarecatalog.NoSuchProductEntryException if a s c product entry with the primary key could not be found
1170             * @throws SystemException if a system exception occurred
1171             */
1172            public SCProductEntry[] findByCompanyId_PrevAndNext(long productEntryId,
1173                    long companyId, OrderByComparator orderByComparator)
1174                    throws NoSuchProductEntryException, SystemException {
1175                    SCProductEntry scProductEntry = findByPrimaryKey(productEntryId);
1176    
1177                    Session session = null;
1178    
1179                    try {
1180                            session = openSession();
1181    
1182                            SCProductEntry[] array = new SCProductEntryImpl[3];
1183    
1184                            array[0] = getByCompanyId_PrevAndNext(session, scProductEntry,
1185                                            companyId, orderByComparator, true);
1186    
1187                            array[1] = scProductEntry;
1188    
1189                            array[2] = getByCompanyId_PrevAndNext(session, scProductEntry,
1190                                            companyId, orderByComparator, false);
1191    
1192                            return array;
1193                    }
1194                    catch (Exception e) {
1195                            throw processException(e);
1196                    }
1197                    finally {
1198                            closeSession(session);
1199                    }
1200            }
1201    
1202            protected SCProductEntry getByCompanyId_PrevAndNext(Session session,
1203                    SCProductEntry scProductEntry, long companyId,
1204                    OrderByComparator orderByComparator, boolean previous) {
1205                    StringBundler query = null;
1206    
1207                    if (orderByComparator != null) {
1208                            query = new StringBundler(6 +
1209                                            (orderByComparator.getOrderByFields().length * 6));
1210                    }
1211                    else {
1212                            query = new StringBundler(3);
1213                    }
1214    
1215                    query.append(_SQL_SELECT_SCPRODUCTENTRY_WHERE);
1216    
1217                    query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1218    
1219                    if (orderByComparator != null) {
1220                            String[] orderByFields = orderByComparator.getOrderByFields();
1221    
1222                            if (orderByFields.length > 0) {
1223                                    query.append(WHERE_AND);
1224                            }
1225    
1226                            for (int i = 0; i < orderByFields.length; i++) {
1227                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1228                                    query.append(orderByFields[i]);
1229    
1230                                    if ((i + 1) < orderByFields.length) {
1231                                            if (orderByComparator.isAscending() ^ previous) {
1232                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1233                                            }
1234                                            else {
1235                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1236                                            }
1237                                    }
1238                                    else {
1239                                            if (orderByComparator.isAscending() ^ previous) {
1240                                                    query.append(WHERE_GREATER_THAN);
1241                                            }
1242                                            else {
1243                                                    query.append(WHERE_LESSER_THAN);
1244                                            }
1245                                    }
1246                            }
1247    
1248                            query.append(ORDER_BY_CLAUSE);
1249    
1250                            for (int i = 0; i < orderByFields.length; i++) {
1251                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1252                                    query.append(orderByFields[i]);
1253    
1254                                    if ((i + 1) < orderByFields.length) {
1255                                            if (orderByComparator.isAscending() ^ previous) {
1256                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1257                                            }
1258                                            else {
1259                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1260                                            }
1261                                    }
1262                                    else {
1263                                            if (orderByComparator.isAscending() ^ previous) {
1264                                                    query.append(ORDER_BY_ASC);
1265                                            }
1266                                            else {
1267                                                    query.append(ORDER_BY_DESC);
1268                                            }
1269                                    }
1270                            }
1271                    }
1272    
1273                    else {
1274                            query.append(SCProductEntryModelImpl.ORDER_BY_JPQL);
1275                    }
1276    
1277                    String sql = query.toString();
1278    
1279                    Query q = session.createQuery(sql);
1280    
1281                    q.setFirstResult(0);
1282                    q.setMaxResults(2);
1283    
1284                    QueryPos qPos = QueryPos.getInstance(q);
1285    
1286                    qPos.add(companyId);
1287    
1288                    if (orderByComparator != null) {
1289                            Object[] values = orderByComparator.getOrderByValues(scProductEntry);
1290    
1291                            for (Object value : values) {
1292                                    qPos.add(value);
1293                            }
1294                    }
1295    
1296                    List<SCProductEntry> list = q.list();
1297    
1298                    if (list.size() == 2) {
1299                            return list.get(1);
1300                    }
1301                    else {
1302                            return null;
1303                    }
1304            }
1305    
1306            /**
1307             * Finds all the s c product entries where groupId = &#63; and userId = &#63;.
1308             *
1309             * @param groupId the group id to search with
1310             * @param userId the user id to search with
1311             * @return the matching s c product entries
1312             * @throws SystemException if a system exception occurred
1313             */
1314            public List<SCProductEntry> findByG_U(long groupId, long userId)
1315                    throws SystemException {
1316                    return findByG_U(groupId, userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
1317                            null);
1318            }
1319    
1320            /**
1321             * Finds a range of all the s c product entries where groupId = &#63; and userId = &#63;.
1322             *
1323             * <p>
1324             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1325             * </p>
1326             *
1327             * @param groupId the group id to search with
1328             * @param userId the user id to search with
1329             * @param start the lower bound of the range of s c product entries to return
1330             * @param end the upper bound of the range of s c product entries to return (not inclusive)
1331             * @return the range of matching s c product entries
1332             * @throws SystemException if a system exception occurred
1333             */
1334            public List<SCProductEntry> findByG_U(long groupId, long userId, int start,
1335                    int end) throws SystemException {
1336                    return findByG_U(groupId, userId, start, end, null);
1337            }
1338    
1339            /**
1340             * Finds an ordered range of all the s c product entries where groupId = &#63; and userId = &#63;.
1341             *
1342             * <p>
1343             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1344             * </p>
1345             *
1346             * @param groupId the group id to search with
1347             * @param userId the user id to search with
1348             * @param start the lower bound of the range of s c product entries to return
1349             * @param end the upper bound of the range of s c product entries to return (not inclusive)
1350             * @param orderByComparator the comparator to order the results by
1351             * @return the ordered range of matching s c product entries
1352             * @throws SystemException if a system exception occurred
1353             */
1354            public List<SCProductEntry> findByG_U(long groupId, long userId, int start,
1355                    int end, OrderByComparator orderByComparator) throws SystemException {
1356                    Object[] finderArgs = new Object[] {
1357                                    groupId, userId,
1358                                    
1359                                    String.valueOf(start), String.valueOf(end),
1360                                    String.valueOf(orderByComparator)
1361                            };
1362    
1363                    List<SCProductEntry> list = (List<SCProductEntry>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_G_U,
1364                                    finderArgs, this);
1365    
1366                    if (list == null) {
1367                            StringBundler query = null;
1368    
1369                            if (orderByComparator != null) {
1370                                    query = new StringBundler(4 +
1371                                                    (orderByComparator.getOrderByFields().length * 3));
1372                            }
1373                            else {
1374                                    query = new StringBundler(4);
1375                            }
1376    
1377                            query.append(_SQL_SELECT_SCPRODUCTENTRY_WHERE);
1378    
1379                            query.append(_FINDER_COLUMN_G_U_GROUPID_2);
1380    
1381                            query.append(_FINDER_COLUMN_G_U_USERID_2);
1382    
1383                            if (orderByComparator != null) {
1384                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1385                                            orderByComparator);
1386                            }
1387    
1388                            else {
1389                                    query.append(SCProductEntryModelImpl.ORDER_BY_JPQL);
1390                            }
1391    
1392                            String sql = query.toString();
1393    
1394                            Session session = null;
1395    
1396                            try {
1397                                    session = openSession();
1398    
1399                                    Query q = session.createQuery(sql);
1400    
1401                                    QueryPos qPos = QueryPos.getInstance(q);
1402    
1403                                    qPos.add(groupId);
1404    
1405                                    qPos.add(userId);
1406    
1407                                    list = (List<SCProductEntry>)QueryUtil.list(q, getDialect(),
1408                                                    start, end);
1409                            }
1410                            catch (Exception e) {
1411                                    throw processException(e);
1412                            }
1413                            finally {
1414                                    if (list == null) {
1415                                            FinderCacheUtil.removeResult(FINDER_PATH_FIND_BY_G_U,
1416                                                    finderArgs);
1417                                    }
1418                                    else {
1419                                            cacheResult(list);
1420    
1421                                            FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_G_U,
1422                                                    finderArgs, list);
1423                                    }
1424    
1425                                    closeSession(session);
1426                            }
1427                    }
1428    
1429                    return list;
1430            }
1431    
1432            /**
1433             * Finds the first s c product entry in the ordered set where groupId = &#63; and userId = &#63;.
1434             *
1435             * <p>
1436             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1437             * </p>
1438             *
1439             * @param groupId the group id to search with
1440             * @param userId the user id to search with
1441             * @param orderByComparator the comparator to order the set by
1442             * @return the first matching s c product entry
1443             * @throws com.liferay.portlet.softwarecatalog.NoSuchProductEntryException if a matching s c product entry could not be found
1444             * @throws SystemException if a system exception occurred
1445             */
1446            public SCProductEntry findByG_U_First(long groupId, long userId,
1447                    OrderByComparator orderByComparator)
1448                    throws NoSuchProductEntryException, SystemException {
1449                    List<SCProductEntry> list = findByG_U(groupId, userId, 0, 1,
1450                                    orderByComparator);
1451    
1452                    if (list.isEmpty()) {
1453                            StringBundler msg = new StringBundler(6);
1454    
1455                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1456    
1457                            msg.append("groupId=");
1458                            msg.append(groupId);
1459    
1460                            msg.append(", userId=");
1461                            msg.append(userId);
1462    
1463                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1464    
1465                            throw new NoSuchProductEntryException(msg.toString());
1466                    }
1467                    else {
1468                            return list.get(0);
1469                    }
1470            }
1471    
1472            /**
1473             * Finds the last s c product entry in the ordered set where groupId = &#63; and userId = &#63;.
1474             *
1475             * <p>
1476             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1477             * </p>
1478             *
1479             * @param groupId the group id to search with
1480             * @param userId the user id to search with
1481             * @param orderByComparator the comparator to order the set by
1482             * @return the last matching s c product entry
1483             * @throws com.liferay.portlet.softwarecatalog.NoSuchProductEntryException if a matching s c product entry could not be found
1484             * @throws SystemException if a system exception occurred
1485             */
1486            public SCProductEntry findByG_U_Last(long groupId, long userId,
1487                    OrderByComparator orderByComparator)
1488                    throws NoSuchProductEntryException, SystemException {
1489                    int count = countByG_U(groupId, userId);
1490    
1491                    List<SCProductEntry> list = findByG_U(groupId, userId, count - 1,
1492                                    count, orderByComparator);
1493    
1494                    if (list.isEmpty()) {
1495                            StringBundler msg = new StringBundler(6);
1496    
1497                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1498    
1499                            msg.append("groupId=");
1500                            msg.append(groupId);
1501    
1502                            msg.append(", userId=");
1503                            msg.append(userId);
1504    
1505                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1506    
1507                            throw new NoSuchProductEntryException(msg.toString());
1508                    }
1509                    else {
1510                            return list.get(0);
1511                    }
1512            }
1513    
1514            /**
1515             * Finds the s c product entries before and after the current s c product entry in the ordered set where groupId = &#63; and userId = &#63;.
1516             *
1517             * <p>
1518             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1519             * </p>
1520             *
1521             * @param productEntryId the primary key of the current s c product entry
1522             * @param groupId the group id to search with
1523             * @param userId the user id to search with
1524             * @param orderByComparator the comparator to order the set by
1525             * @return the previous, current, and next s c product entry
1526             * @throws com.liferay.portlet.softwarecatalog.NoSuchProductEntryException if a s c product entry with the primary key could not be found
1527             * @throws SystemException if a system exception occurred
1528             */
1529            public SCProductEntry[] findByG_U_PrevAndNext(long productEntryId,
1530                    long groupId, long userId, OrderByComparator orderByComparator)
1531                    throws NoSuchProductEntryException, SystemException {
1532                    SCProductEntry scProductEntry = findByPrimaryKey(productEntryId);
1533    
1534                    Session session = null;
1535    
1536                    try {
1537                            session = openSession();
1538    
1539                            SCProductEntry[] array = new SCProductEntryImpl[3];
1540    
1541                            array[0] = getByG_U_PrevAndNext(session, scProductEntry, groupId,
1542                                            userId, orderByComparator, true);
1543    
1544                            array[1] = scProductEntry;
1545    
1546                            array[2] = getByG_U_PrevAndNext(session, scProductEntry, groupId,
1547                                            userId, orderByComparator, false);
1548    
1549                            return array;
1550                    }
1551                    catch (Exception e) {
1552                            throw processException(e);
1553                    }
1554                    finally {
1555                            closeSession(session);
1556                    }
1557            }
1558    
1559            protected SCProductEntry getByG_U_PrevAndNext(Session session,
1560                    SCProductEntry scProductEntry, long groupId, long userId,
1561                    OrderByComparator orderByComparator, boolean previous) {
1562                    StringBundler query = null;
1563    
1564                    if (orderByComparator != null) {
1565                            query = new StringBundler(6 +
1566                                            (orderByComparator.getOrderByFields().length * 6));
1567                    }
1568                    else {
1569                            query = new StringBundler(3);
1570                    }
1571    
1572                    query.append(_SQL_SELECT_SCPRODUCTENTRY_WHERE);
1573    
1574                    query.append(_FINDER_COLUMN_G_U_GROUPID_2);
1575    
1576                    query.append(_FINDER_COLUMN_G_U_USERID_2);
1577    
1578                    if (orderByComparator != null) {
1579                            String[] orderByFields = orderByComparator.getOrderByFields();
1580    
1581                            if (orderByFields.length > 0) {
1582                                    query.append(WHERE_AND);
1583                            }
1584    
1585                            for (int i = 0; i < orderByFields.length; i++) {
1586                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1587                                    query.append(orderByFields[i]);
1588    
1589                                    if ((i + 1) < orderByFields.length) {
1590                                            if (orderByComparator.isAscending() ^ previous) {
1591                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1592                                            }
1593                                            else {
1594                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1595                                            }
1596                                    }
1597                                    else {
1598                                            if (orderByComparator.isAscending() ^ previous) {
1599                                                    query.append(WHERE_GREATER_THAN);
1600                                            }
1601                                            else {
1602                                                    query.append(WHERE_LESSER_THAN);
1603                                            }
1604                                    }
1605                            }
1606    
1607                            query.append(ORDER_BY_CLAUSE);
1608    
1609                            for (int i = 0; i < orderByFields.length; i++) {
1610                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1611                                    query.append(orderByFields[i]);
1612    
1613                                    if ((i + 1) < orderByFields.length) {
1614                                            if (orderByComparator.isAscending() ^ previous) {
1615                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1616                                            }
1617                                            else {
1618                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1619                                            }
1620                                    }
1621                                    else {
1622                                            if (orderByComparator.isAscending() ^ previous) {
1623                                                    query.append(ORDER_BY_ASC);
1624                                            }
1625                                            else {
1626                                                    query.append(ORDER_BY_DESC);
1627                                            }
1628                                    }
1629                            }
1630                    }
1631    
1632                    else {
1633                            query.append(SCProductEntryModelImpl.ORDER_BY_JPQL);
1634                    }
1635    
1636                    String sql = query.toString();
1637    
1638                    Query q = session.createQuery(sql);
1639    
1640                    q.setFirstResult(0);
1641                    q.setMaxResults(2);
1642    
1643                    QueryPos qPos = QueryPos.getInstance(q);
1644    
1645                    qPos.add(groupId);
1646    
1647                    qPos.add(userId);
1648    
1649                    if (orderByComparator != null) {
1650                            Object[] values = orderByComparator.getOrderByValues(scProductEntry);
1651    
1652                            for (Object value : values) {
1653                                    qPos.add(value);
1654                            }
1655                    }
1656    
1657                    List<SCProductEntry> list = q.list();
1658    
1659                    if (list.size() == 2) {
1660                            return list.get(1);
1661                    }
1662                    else {
1663                            return null;
1664                    }
1665            }
1666    
1667            /**
1668             * Filters by the user's permissions and finds all the s c product entries where groupId = &#63; and userId = &#63;.
1669             *
1670             * @param groupId the group id to search with
1671             * @param userId the user id to search with
1672             * @return the matching s c product entries that the user has permission to view
1673             * @throws SystemException if a system exception occurred
1674             */
1675            public List<SCProductEntry> filterFindByG_U(long groupId, long userId)
1676                    throws SystemException {
1677                    return filterFindByG_U(groupId, userId, QueryUtil.ALL_POS,
1678                            QueryUtil.ALL_POS, null);
1679            }
1680    
1681            /**
1682             * Filters by the user's permissions and finds a range of all the s c product entries where groupId = &#63; and userId = &#63;.
1683             *
1684             * <p>
1685             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1686             * </p>
1687             *
1688             * @param groupId the group id to search with
1689             * @param userId the user id to search with
1690             * @param start the lower bound of the range of s c product entries to return
1691             * @param end the upper bound of the range of s c product entries to return (not inclusive)
1692             * @return the range of matching s c product entries that the user has permission to view
1693             * @throws SystemException if a system exception occurred
1694             */
1695            public List<SCProductEntry> filterFindByG_U(long groupId, long userId,
1696                    int start, int end) throws SystemException {
1697                    return filterFindByG_U(groupId, userId, start, end, null);
1698            }
1699    
1700            /**
1701             * Filters by the user's permissions and finds an ordered range of all the s c product entries where groupId = &#63; and userId = &#63;.
1702             *
1703             * <p>
1704             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1705             * </p>
1706             *
1707             * @param groupId the group id to search with
1708             * @param userId the user id to search with
1709             * @param start the lower bound of the range of s c product entries to return
1710             * @param end the upper bound of the range of s c product entries to return (not inclusive)
1711             * @param orderByComparator the comparator to order the results by
1712             * @return the ordered range of matching s c product entries that the user has permission to view
1713             * @throws SystemException if a system exception occurred
1714             */
1715            public List<SCProductEntry> filterFindByG_U(long groupId, long userId,
1716                    int start, int end, OrderByComparator orderByComparator)
1717                    throws SystemException {
1718                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1719                            return findByG_U(groupId, userId, start, end, orderByComparator);
1720                    }
1721    
1722                    StringBundler query = null;
1723    
1724                    if (orderByComparator != null) {
1725                            query = new StringBundler(4 +
1726                                            (orderByComparator.getOrderByFields().length * 3));
1727                    }
1728                    else {
1729                            query = new StringBundler(4);
1730                    }
1731    
1732                    if (getDB().isSupportsInlineDistinct()) {
1733                            query.append(_FILTER_SQL_SELECT_SCPRODUCTENTRY_WHERE);
1734                    }
1735                    else {
1736                            query.append(_FILTER_SQL_SELECT_SCPRODUCTENTRY_NO_INLINE_DISTINCT_WHERE_1);
1737                    }
1738    
1739                    query.append(_FINDER_COLUMN_G_U_GROUPID_2);
1740    
1741                    query.append(_FINDER_COLUMN_G_U_USERID_2);
1742    
1743                    if (!getDB().isSupportsInlineDistinct()) {
1744                            query.append(_FILTER_SQL_SELECT_SCPRODUCTENTRY_NO_INLINE_DISTINCT_WHERE_2);
1745                    }
1746    
1747                    if (orderByComparator != null) {
1748                            if (getDB().isSupportsInlineDistinct()) {
1749                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1750                                            orderByComparator);
1751                            }
1752                            else {
1753                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
1754                                            orderByComparator);
1755                            }
1756                    }
1757    
1758                    else {
1759                            if (getDB().isSupportsInlineDistinct()) {
1760                                    query.append(SCProductEntryModelImpl.ORDER_BY_JPQL);
1761                            }
1762                            else {
1763                                    query.append(SCProductEntryModelImpl.ORDER_BY_SQL);
1764                            }
1765                    }
1766    
1767                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1768                                    SCProductEntry.class.getName(), _FILTER_COLUMN_PK,
1769                                    _FILTER_COLUMN_USERID, groupId);
1770    
1771                    Session session = null;
1772    
1773                    try {
1774                            session = openSession();
1775    
1776                            SQLQuery q = session.createSQLQuery(sql);
1777    
1778                            if (getDB().isSupportsInlineDistinct()) {
1779                                    q.addEntity(_FILTER_ENTITY_ALIAS, SCProductEntryImpl.class);
1780                            }
1781                            else {
1782                                    q.addEntity(_FILTER_ENTITY_TABLE, SCProductEntryImpl.class);
1783                            }
1784    
1785                            QueryPos qPos = QueryPos.getInstance(q);
1786    
1787                            qPos.add(groupId);
1788    
1789                            qPos.add(userId);
1790    
1791                            return (List<SCProductEntry>)QueryUtil.list(q, getDialect(), start,
1792                                    end);
1793                    }
1794                    catch (Exception e) {
1795                            throw processException(e);
1796                    }
1797                    finally {
1798                            closeSession(session);
1799                    }
1800            }
1801    
1802            /**
1803             * Finds the s c product entry where repoGroupId = &#63; and repoArtifactId = &#63; or throws a {@link com.liferay.portlet.softwarecatalog.NoSuchProductEntryException} if it could not be found.
1804             *
1805             * @param repoGroupId the repo group id to search with
1806             * @param repoArtifactId the repo artifact id to search with
1807             * @return the matching s c product entry
1808             * @throws com.liferay.portlet.softwarecatalog.NoSuchProductEntryException if a matching s c product entry could not be found
1809             * @throws SystemException if a system exception occurred
1810             */
1811            public SCProductEntry findByRG_RA(String repoGroupId, String repoArtifactId)
1812                    throws NoSuchProductEntryException, SystemException {
1813                    SCProductEntry scProductEntry = fetchByRG_RA(repoGroupId, repoArtifactId);
1814    
1815                    if (scProductEntry == null) {
1816                            StringBundler msg = new StringBundler(6);
1817    
1818                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1819    
1820                            msg.append("repoGroupId=");
1821                            msg.append(repoGroupId);
1822    
1823                            msg.append(", repoArtifactId=");
1824                            msg.append(repoArtifactId);
1825    
1826                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1827    
1828                            if (_log.isWarnEnabled()) {
1829                                    _log.warn(msg.toString());
1830                            }
1831    
1832                            throw new NoSuchProductEntryException(msg.toString());
1833                    }
1834    
1835                    return scProductEntry;
1836            }
1837    
1838            /**
1839             * Finds the s c product entry where repoGroupId = &#63; and repoArtifactId = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
1840             *
1841             * @param repoGroupId the repo group id to search with
1842             * @param repoArtifactId the repo artifact id to search with
1843             * @return the matching s c product entry, or <code>null</code> if a matching s c product entry could not be found
1844             * @throws SystemException if a system exception occurred
1845             */
1846            public SCProductEntry fetchByRG_RA(String repoGroupId, String repoArtifactId)
1847                    throws SystemException {
1848                    return fetchByRG_RA(repoGroupId, repoArtifactId, true);
1849            }
1850    
1851            /**
1852             * Finds the s c product entry where repoGroupId = &#63; and repoArtifactId = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
1853             *
1854             * @param repoGroupId the repo group id to search with
1855             * @param repoArtifactId the repo artifact id to search with
1856             * @return the matching s c product entry, or <code>null</code> if a matching s c product entry could not be found
1857             * @throws SystemException if a system exception occurred
1858             */
1859            public SCProductEntry fetchByRG_RA(String repoGroupId,
1860                    String repoArtifactId, boolean retrieveFromCache)
1861                    throws SystemException {
1862                    Object[] finderArgs = new Object[] { repoGroupId, repoArtifactId };
1863    
1864                    Object result = null;
1865    
1866                    if (retrieveFromCache) {
1867                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_RG_RA,
1868                                            finderArgs, this);
1869                    }
1870    
1871                    if (result == null) {
1872                            StringBundler query = new StringBundler(4);
1873    
1874                            query.append(_SQL_SELECT_SCPRODUCTENTRY_WHERE);
1875    
1876                            if (repoGroupId == null) {
1877                                    query.append(_FINDER_COLUMN_RG_RA_REPOGROUPID_1);
1878                            }
1879                            else {
1880                                    if (repoGroupId.equals(StringPool.BLANK)) {
1881                                            query.append(_FINDER_COLUMN_RG_RA_REPOGROUPID_3);
1882                                    }
1883                                    else {
1884                                            query.append(_FINDER_COLUMN_RG_RA_REPOGROUPID_2);
1885                                    }
1886                            }
1887    
1888                            if (repoArtifactId == null) {
1889                                    query.append(_FINDER_COLUMN_RG_RA_REPOARTIFACTID_1);
1890                            }
1891                            else {
1892                                    if (repoArtifactId.equals(StringPool.BLANK)) {
1893                                            query.append(_FINDER_COLUMN_RG_RA_REPOARTIFACTID_3);
1894                                    }
1895                                    else {
1896                                            query.append(_FINDER_COLUMN_RG_RA_REPOARTIFACTID_2);
1897                                    }
1898                            }
1899    
1900                            query.append(SCProductEntryModelImpl.ORDER_BY_JPQL);
1901    
1902                            String sql = query.toString();
1903    
1904                            Session session = null;
1905    
1906                            try {
1907                                    session = openSession();
1908    
1909                                    Query q = session.createQuery(sql);
1910    
1911                                    QueryPos qPos = QueryPos.getInstance(q);
1912    
1913                                    if (repoGroupId != null) {
1914                                            qPos.add(repoGroupId);
1915                                    }
1916    
1917                                    if (repoArtifactId != null) {
1918                                            qPos.add(repoArtifactId);
1919                                    }
1920    
1921                                    List<SCProductEntry> list = q.list();
1922    
1923                                    result = list;
1924    
1925                                    SCProductEntry scProductEntry = null;
1926    
1927                                    if (list.isEmpty()) {
1928                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_RG_RA,
1929                                                    finderArgs, list);
1930                                    }
1931                                    else {
1932                                            scProductEntry = list.get(0);
1933    
1934                                            cacheResult(scProductEntry);
1935    
1936                                            if ((scProductEntry.getRepoGroupId() == null) ||
1937                                                            !scProductEntry.getRepoGroupId().equals(repoGroupId) ||
1938                                                            (scProductEntry.getRepoArtifactId() == null) ||
1939                                                            !scProductEntry.getRepoArtifactId()
1940                                                                                               .equals(repoArtifactId)) {
1941                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_RG_RA,
1942                                                            finderArgs, scProductEntry);
1943                                            }
1944                                    }
1945    
1946                                    return scProductEntry;
1947                            }
1948                            catch (Exception e) {
1949                                    throw processException(e);
1950                            }
1951                            finally {
1952                                    if (result == null) {
1953                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_RG_RA,
1954                                                    finderArgs);
1955                                    }
1956    
1957                                    closeSession(session);
1958                            }
1959                    }
1960                    else {
1961                            if (result instanceof List<?>) {
1962                                    return null;
1963                            }
1964                            else {
1965                                    return (SCProductEntry)result;
1966                            }
1967                    }
1968            }
1969    
1970            /**
1971             * Finds all the s c product entries.
1972             *
1973             * @return the s c product entries
1974             * @throws SystemException if a system exception occurred
1975             */
1976            public List<SCProductEntry> findAll() throws SystemException {
1977                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1978            }
1979    
1980            /**
1981             * Finds a range of all the s c product entries.
1982             *
1983             * <p>
1984             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1985             * </p>
1986             *
1987             * @param start the lower bound of the range of s c product entries to return
1988             * @param end the upper bound of the range of s c product entries to return (not inclusive)
1989             * @return the range of s c product entries
1990             * @throws SystemException if a system exception occurred
1991             */
1992            public List<SCProductEntry> findAll(int start, int end)
1993                    throws SystemException {
1994                    return findAll(start, end, null);
1995            }
1996    
1997            /**
1998             * Finds an ordered range of all the s c product entries.
1999             *
2000             * <p>
2001             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2002             * </p>
2003             *
2004             * @param start the lower bound of the range of s c product entries to return
2005             * @param end the upper bound of the range of s c product entries to return (not inclusive)
2006             * @param orderByComparator the comparator to order the results by
2007             * @return the ordered range of s c product entries
2008             * @throws SystemException if a system exception occurred
2009             */
2010            public List<SCProductEntry> findAll(int start, int end,
2011                    OrderByComparator orderByComparator) throws SystemException {
2012                    Object[] finderArgs = new Object[] {
2013                                    String.valueOf(start), String.valueOf(end),
2014                                    String.valueOf(orderByComparator)
2015                            };
2016    
2017                    List<SCProductEntry> list = (List<SCProductEntry>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
2018                                    finderArgs, this);
2019    
2020                    if (list == null) {
2021                            StringBundler query = null;
2022                            String sql = null;
2023    
2024                            if (orderByComparator != null) {
2025                                    query = new StringBundler(2 +
2026                                                    (orderByComparator.getOrderByFields().length * 3));
2027    
2028                                    query.append(_SQL_SELECT_SCPRODUCTENTRY);
2029    
2030                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2031                                            orderByComparator);
2032    
2033                                    sql = query.toString();
2034                            }
2035                            else {
2036                                    sql = _SQL_SELECT_SCPRODUCTENTRY.concat(SCProductEntryModelImpl.ORDER_BY_JPQL);
2037                            }
2038    
2039                            Session session = null;
2040    
2041                            try {
2042                                    session = openSession();
2043    
2044                                    Query q = session.createQuery(sql);
2045    
2046                                    if (orderByComparator == null) {
2047                                            list = (List<SCProductEntry>)QueryUtil.list(q,
2048                                                            getDialect(), start, end, false);
2049    
2050                                            Collections.sort(list);
2051                                    }
2052                                    else {
2053                                            list = (List<SCProductEntry>)QueryUtil.list(q,
2054                                                            getDialect(), start, end);
2055                                    }
2056                            }
2057                            catch (Exception e) {
2058                                    throw processException(e);
2059                            }
2060                            finally {
2061                                    if (list == null) {
2062                                            FinderCacheUtil.removeResult(FINDER_PATH_FIND_ALL,
2063                                                    finderArgs);
2064                                    }
2065                                    else {
2066                                            cacheResult(list);
2067    
2068                                            FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs,
2069                                                    list);
2070                                    }
2071    
2072                                    closeSession(session);
2073                            }
2074                    }
2075    
2076                    return list;
2077            }
2078    
2079            /**
2080             * Removes all the s c product entries where groupId = &#63; from the database.
2081             *
2082             * @param groupId the group id to search with
2083             * @throws SystemException if a system exception occurred
2084             */
2085            public void removeByGroupId(long groupId) throws SystemException {
2086                    for (SCProductEntry scProductEntry : findByGroupId(groupId)) {
2087                            remove(scProductEntry);
2088                    }
2089            }
2090    
2091            /**
2092             * Removes all the s c product entries where companyId = &#63; from the database.
2093             *
2094             * @param companyId the company id to search with
2095             * @throws SystemException if a system exception occurred
2096             */
2097            public void removeByCompanyId(long companyId) throws SystemException {
2098                    for (SCProductEntry scProductEntry : findByCompanyId(companyId)) {
2099                            remove(scProductEntry);
2100                    }
2101            }
2102    
2103            /**
2104             * Removes all the s c product entries where groupId = &#63; and userId = &#63; from the database.
2105             *
2106             * @param groupId the group id to search with
2107             * @param userId the user id to search with
2108             * @throws SystemException if a system exception occurred
2109             */
2110            public void removeByG_U(long groupId, long userId)
2111                    throws SystemException {
2112                    for (SCProductEntry scProductEntry : findByG_U(groupId, userId)) {
2113                            remove(scProductEntry);
2114                    }
2115            }
2116    
2117            /**
2118             * Removes the s c product entry where repoGroupId = &#63; and repoArtifactId = &#63; from the database.
2119             *
2120             * @param repoGroupId the repo group id to search with
2121             * @param repoArtifactId the repo artifact id to search with
2122             * @throws SystemException if a system exception occurred
2123             */
2124            public void removeByRG_RA(String repoGroupId, String repoArtifactId)
2125                    throws NoSuchProductEntryException, SystemException {
2126                    SCProductEntry scProductEntry = findByRG_RA(repoGroupId, repoArtifactId);
2127    
2128                    remove(scProductEntry);
2129            }
2130    
2131            /**
2132             * Removes all the s c product entries from the database.
2133             *
2134             * @throws SystemException if a system exception occurred
2135             */
2136            public void removeAll() throws SystemException {
2137                    for (SCProductEntry scProductEntry : findAll()) {
2138                            remove(scProductEntry);
2139                    }
2140            }
2141    
2142            /**
2143             * Counts all the s c product entries where groupId = &#63;.
2144             *
2145             * @param groupId the group id to search with
2146             * @return the number of matching s c product entries
2147             * @throws SystemException if a system exception occurred
2148             */
2149            public int countByGroupId(long groupId) throws SystemException {
2150                    Object[] finderArgs = new Object[] { groupId };
2151    
2152                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
2153                                    finderArgs, this);
2154    
2155                    if (count == null) {
2156                            StringBundler query = new StringBundler(2);
2157    
2158                            query.append(_SQL_COUNT_SCPRODUCTENTRY_WHERE);
2159    
2160                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2161    
2162                            String sql = query.toString();
2163    
2164                            Session session = null;
2165    
2166                            try {
2167                                    session = openSession();
2168    
2169                                    Query q = session.createQuery(sql);
2170    
2171                                    QueryPos qPos = QueryPos.getInstance(q);
2172    
2173                                    qPos.add(groupId);
2174    
2175                                    count = (Long)q.uniqueResult();
2176                            }
2177                            catch (Exception e) {
2178                                    throw processException(e);
2179                            }
2180                            finally {
2181                                    if (count == null) {
2182                                            count = Long.valueOf(0);
2183                                    }
2184    
2185                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
2186                                            finderArgs, count);
2187    
2188                                    closeSession(session);
2189                            }
2190                    }
2191    
2192                    return count.intValue();
2193            }
2194    
2195            /**
2196             * Filters by the user's permissions and counts all the s c product entries where groupId = &#63;.
2197             *
2198             * @param groupId the group id to search with
2199             * @return the number of matching s c product entries that the user has permission to view
2200             * @throws SystemException if a system exception occurred
2201             */
2202            public int filterCountByGroupId(long groupId) throws SystemException {
2203                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2204                            return countByGroupId(groupId);
2205                    }
2206    
2207                    StringBundler query = new StringBundler(2);
2208    
2209                    query.append(_FILTER_SQL_COUNT_SCPRODUCTENTRY_WHERE);
2210    
2211                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2212    
2213                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2214                                    SCProductEntry.class.getName(), _FILTER_COLUMN_PK,
2215                                    _FILTER_COLUMN_USERID, groupId);
2216    
2217                    Session session = null;
2218    
2219                    try {
2220                            session = openSession();
2221    
2222                            SQLQuery q = session.createSQLQuery(sql);
2223    
2224                            q.addScalar(COUNT_COLUMN_NAME,
2225                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
2226    
2227                            QueryPos qPos = QueryPos.getInstance(q);
2228    
2229                            qPos.add(groupId);
2230    
2231                            Long count = (Long)q.uniqueResult();
2232    
2233                            return count.intValue();
2234                    }
2235                    catch (Exception e) {
2236                            throw processException(e);
2237                    }
2238                    finally {
2239                            closeSession(session);
2240                    }
2241            }
2242    
2243            /**
2244             * Counts all the s c product entries where companyId = &#63;.
2245             *
2246             * @param companyId the company id to search with
2247             * @return the number of matching s c product entries
2248             * @throws SystemException if a system exception occurred
2249             */
2250            public int countByCompanyId(long companyId) throws SystemException {
2251                    Object[] finderArgs = new Object[] { companyId };
2252    
2253                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
2254                                    finderArgs, this);
2255    
2256                    if (count == null) {
2257                            StringBundler query = new StringBundler(2);
2258    
2259                            query.append(_SQL_COUNT_SCPRODUCTENTRY_WHERE);
2260    
2261                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2262    
2263                            String sql = query.toString();
2264    
2265                            Session session = null;
2266    
2267                            try {
2268                                    session = openSession();
2269    
2270                                    Query q = session.createQuery(sql);
2271    
2272                                    QueryPos qPos = QueryPos.getInstance(q);
2273    
2274                                    qPos.add(companyId);
2275    
2276                                    count = (Long)q.uniqueResult();
2277                            }
2278                            catch (Exception e) {
2279                                    throw processException(e);
2280                            }
2281                            finally {
2282                                    if (count == null) {
2283                                            count = Long.valueOf(0);
2284                                    }
2285    
2286                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
2287                                            finderArgs, count);
2288    
2289                                    closeSession(session);
2290                            }
2291                    }
2292    
2293                    return count.intValue();
2294            }
2295    
2296            /**
2297             * Counts all the s c product entries where groupId = &#63; and userId = &#63;.
2298             *
2299             * @param groupId the group id to search with
2300             * @param userId the user id to search with
2301             * @return the number of matching s c product entries
2302             * @throws SystemException if a system exception occurred
2303             */
2304            public int countByG_U(long groupId, long userId) throws SystemException {
2305                    Object[] finderArgs = new Object[] { groupId, userId };
2306    
2307                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_U,
2308                                    finderArgs, this);
2309    
2310                    if (count == null) {
2311                            StringBundler query = new StringBundler(3);
2312    
2313                            query.append(_SQL_COUNT_SCPRODUCTENTRY_WHERE);
2314    
2315                            query.append(_FINDER_COLUMN_G_U_GROUPID_2);
2316    
2317                            query.append(_FINDER_COLUMN_G_U_USERID_2);
2318    
2319                            String sql = query.toString();
2320    
2321                            Session session = null;
2322    
2323                            try {
2324                                    session = openSession();
2325    
2326                                    Query q = session.createQuery(sql);
2327    
2328                                    QueryPos qPos = QueryPos.getInstance(q);
2329    
2330                                    qPos.add(groupId);
2331    
2332                                    qPos.add(userId);
2333    
2334                                    count = (Long)q.uniqueResult();
2335                            }
2336                            catch (Exception e) {
2337                                    throw processException(e);
2338                            }
2339                            finally {
2340                                    if (count == null) {
2341                                            count = Long.valueOf(0);
2342                                    }
2343    
2344                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_U, finderArgs,
2345                                            count);
2346    
2347                                    closeSession(session);
2348                            }
2349                    }
2350    
2351                    return count.intValue();
2352            }
2353    
2354            /**
2355             * Filters by the user's permissions and counts all the s c product entries where groupId = &#63; and userId = &#63;.
2356             *
2357             * @param groupId the group id to search with
2358             * @param userId the user id to search with
2359             * @return the number of matching s c product entries that the user has permission to view
2360             * @throws SystemException if a system exception occurred
2361             */
2362            public int filterCountByG_U(long groupId, long userId)
2363                    throws SystemException {
2364                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2365                            return countByG_U(groupId, userId);
2366                    }
2367    
2368                    StringBundler query = new StringBundler(3);
2369    
2370                    query.append(_FILTER_SQL_COUNT_SCPRODUCTENTRY_WHERE);
2371    
2372                    query.append(_FINDER_COLUMN_G_U_GROUPID_2);
2373    
2374                    query.append(_FINDER_COLUMN_G_U_USERID_2);
2375    
2376                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2377                                    SCProductEntry.class.getName(), _FILTER_COLUMN_PK,
2378                                    _FILTER_COLUMN_USERID, groupId);
2379    
2380                    Session session = null;
2381    
2382                    try {
2383                            session = openSession();
2384    
2385                            SQLQuery q = session.createSQLQuery(sql);
2386    
2387                            q.addScalar(COUNT_COLUMN_NAME,
2388                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
2389    
2390                            QueryPos qPos = QueryPos.getInstance(q);
2391    
2392                            qPos.add(groupId);
2393    
2394                            qPos.add(userId);
2395    
2396                            Long count = (Long)q.uniqueResult();
2397    
2398                            return count.intValue();
2399                    }
2400                    catch (Exception e) {
2401                            throw processException(e);
2402                    }
2403                    finally {
2404                            closeSession(session);
2405                    }
2406            }
2407    
2408            /**
2409             * Counts all the s c product entries where repoGroupId = &#63; and repoArtifactId = &#63;.
2410             *
2411             * @param repoGroupId the repo group id to search with
2412             * @param repoArtifactId the repo artifact id to search with
2413             * @return the number of matching s c product entries
2414             * @throws SystemException if a system exception occurred
2415             */
2416            public int countByRG_RA(String repoGroupId, String repoArtifactId)
2417                    throws SystemException {
2418                    Object[] finderArgs = new Object[] { repoGroupId, repoArtifactId };
2419    
2420                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_RG_RA,
2421                                    finderArgs, this);
2422    
2423                    if (count == null) {
2424                            StringBundler query = new StringBundler(3);
2425    
2426                            query.append(_SQL_COUNT_SCPRODUCTENTRY_WHERE);
2427    
2428                            if (repoGroupId == null) {
2429                                    query.append(_FINDER_COLUMN_RG_RA_REPOGROUPID_1);
2430                            }
2431                            else {
2432                                    if (repoGroupId.equals(StringPool.BLANK)) {
2433                                            query.append(_FINDER_COLUMN_RG_RA_REPOGROUPID_3);
2434                                    }
2435                                    else {
2436                                            query.append(_FINDER_COLUMN_RG_RA_REPOGROUPID_2);
2437                                    }
2438                            }
2439    
2440                            if (repoArtifactId == null) {
2441                                    query.append(_FINDER_COLUMN_RG_RA_REPOARTIFACTID_1);
2442                            }
2443                            else {
2444                                    if (repoArtifactId.equals(StringPool.BLANK)) {
2445                                            query.append(_FINDER_COLUMN_RG_RA_REPOARTIFACTID_3);
2446                                    }
2447                                    else {
2448                                            query.append(_FINDER_COLUMN_RG_RA_REPOARTIFACTID_2);
2449                                    }
2450                            }
2451    
2452                            String sql = query.toString();
2453    
2454                            Session session = null;
2455    
2456                            try {
2457                                    session = openSession();
2458    
2459                                    Query q = session.createQuery(sql);
2460    
2461                                    QueryPos qPos = QueryPos.getInstance(q);
2462    
2463                                    if (repoGroupId != null) {
2464                                            qPos.add(repoGroupId);
2465                                    }
2466    
2467                                    if (repoArtifactId != null) {
2468                                            qPos.add(repoArtifactId);
2469                                    }
2470    
2471                                    count = (Long)q.uniqueResult();
2472                            }
2473                            catch (Exception e) {
2474                                    throw processException(e);
2475                            }
2476                            finally {
2477                                    if (count == null) {
2478                                            count = Long.valueOf(0);
2479                                    }
2480    
2481                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_RG_RA,
2482                                            finderArgs, count);
2483    
2484                                    closeSession(session);
2485                            }
2486                    }
2487    
2488                    return count.intValue();
2489            }
2490    
2491            /**
2492             * Counts all the s c product entries.
2493             *
2494             * @return the number of s c product entries
2495             * @throws SystemException if a system exception occurred
2496             */
2497            public int countAll() throws SystemException {
2498                    Object[] finderArgs = new Object[0];
2499    
2500                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
2501                                    finderArgs, this);
2502    
2503                    if (count == null) {
2504                            Session session = null;
2505    
2506                            try {
2507                                    session = openSession();
2508    
2509                                    Query q = session.createQuery(_SQL_COUNT_SCPRODUCTENTRY);
2510    
2511                                    count = (Long)q.uniqueResult();
2512                            }
2513                            catch (Exception e) {
2514                                    throw processException(e);
2515                            }
2516                            finally {
2517                                    if (count == null) {
2518                                            count = Long.valueOf(0);
2519                                    }
2520    
2521                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
2522                                            count);
2523    
2524                                    closeSession(session);
2525                            }
2526                    }
2527    
2528                    return count.intValue();
2529            }
2530    
2531            /**
2532             * Gets all the s c licenses associated with the s c product entry.
2533             *
2534             * @param pk the primary key of the s c product entry to get the associated s c licenses for
2535             * @return the s c licenses associated with the s c product entry
2536             * @throws SystemException if a system exception occurred
2537             */
2538            public List<com.liferay.portlet.softwarecatalog.model.SCLicense> getSCLicenses(
2539                    long pk) throws SystemException {
2540                    return getSCLicenses(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
2541            }
2542    
2543            /**
2544             * Gets a range of all the s c licenses associated with the s c product entry.
2545             *
2546             * <p>
2547             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2548             * </p>
2549             *
2550             * @param pk the primary key of the s c product entry to get the associated s c licenses for
2551             * @param start the lower bound of the range of s c product entries to return
2552             * @param end the upper bound of the range of s c product entries to return (not inclusive)
2553             * @return the range of s c licenses associated with the s c product entry
2554             * @throws SystemException if a system exception occurred
2555             */
2556            public List<com.liferay.portlet.softwarecatalog.model.SCLicense> getSCLicenses(
2557                    long pk, int start, int end) throws SystemException {
2558                    return getSCLicenses(pk, start, end, null);
2559            }
2560    
2561            public static final FinderPath FINDER_PATH_GET_SCLICENSES = new FinderPath(com.liferay.portlet.softwarecatalog.model.impl.SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
2562                            SCProductEntryModelImpl.FINDER_CACHE_ENABLED_SCLICENSES_SCPRODUCTENTRIES,
2563                            SCProductEntryModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME,
2564                            "getSCLicenses",
2565                            new String[] {
2566                                    Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
2567                                    "com.liferay.portal.kernel.util.OrderByComparator"
2568                            });
2569    
2570            /**
2571             * Gets an ordered range of all the s c licenses associated with the s c product entry.
2572             *
2573             * <p>
2574             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2575             * </p>
2576             *
2577             * @param pk the primary key of the s c product entry to get the associated s c licenses for
2578             * @param start the lower bound of the range of s c product entries to return
2579             * @param end the upper bound of the range of s c product entries to return (not inclusive)
2580             * @param orderByComparator the comparator to order the results by
2581             * @return the ordered range of s c licenses associated with the s c product entry
2582             * @throws SystemException if a system exception occurred
2583             */
2584            public List<com.liferay.portlet.softwarecatalog.model.SCLicense> getSCLicenses(
2585                    long pk, int start, int end, OrderByComparator orderByComparator)
2586                    throws SystemException {
2587                    Object[] finderArgs = new Object[] {
2588                                    pk, String.valueOf(start), String.valueOf(end),
2589                                    String.valueOf(orderByComparator)
2590                            };
2591    
2592                    List<com.liferay.portlet.softwarecatalog.model.SCLicense> list = (List<com.liferay.portlet.softwarecatalog.model.SCLicense>)FinderCacheUtil.getResult(FINDER_PATH_GET_SCLICENSES,
2593                                    finderArgs, this);
2594    
2595                    if (list == null) {
2596                            Session session = null;
2597    
2598                            try {
2599                                    session = openSession();
2600    
2601                                    String sql = null;
2602    
2603                                    if (orderByComparator != null) {
2604                                            sql = _SQL_GETSCLICENSES.concat(ORDER_BY_CLAUSE)
2605                                                                                            .concat(orderByComparator.getOrderBy());
2606                                    }
2607                                    else {
2608                                            sql = _SQL_GETSCLICENSES.concat(com.liferay.portlet.softwarecatalog.model.impl.SCLicenseModelImpl.ORDER_BY_SQL);
2609                                    }
2610    
2611                                    SQLQuery q = session.createSQLQuery(sql);
2612    
2613                                    q.addEntity("SCLicense",
2614                                            com.liferay.portlet.softwarecatalog.model.impl.SCLicenseImpl.class);
2615    
2616                                    QueryPos qPos = QueryPos.getInstance(q);
2617    
2618                                    qPos.add(pk);
2619    
2620                                    list = (List<com.liferay.portlet.softwarecatalog.model.SCLicense>)QueryUtil.list(q,
2621                                                    getDialect(), start, end);
2622                            }
2623                            catch (Exception e) {
2624                                    throw processException(e);
2625                            }
2626                            finally {
2627                                    if (list == null) {
2628                                            FinderCacheUtil.removeResult(FINDER_PATH_GET_SCLICENSES,
2629                                                    finderArgs);
2630                                    }
2631                                    else {
2632                                            scLicensePersistence.cacheResult(list);
2633    
2634                                            FinderCacheUtil.putResult(FINDER_PATH_GET_SCLICENSES,
2635                                                    finderArgs, list);
2636                                    }
2637    
2638                                    closeSession(session);
2639                            }
2640                    }
2641    
2642                    return list;
2643            }
2644    
2645            public static final FinderPath FINDER_PATH_GET_SCLICENSES_SIZE = new FinderPath(com.liferay.portlet.softwarecatalog.model.impl.SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
2646                            SCProductEntryModelImpl.FINDER_CACHE_ENABLED_SCLICENSES_SCPRODUCTENTRIES,
2647                            SCProductEntryModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME,
2648                            "getSCLicensesSize", new String[] { Long.class.getName() });
2649    
2650            /**
2651             * Gets the number of s c licenses associated with the s c product entry.
2652             *
2653             * @param pk the primary key of the s c product entry to get the number of associated s c licenses for
2654             * @return the number of s c licenses associated with the s c product entry
2655             * @throws SystemException if a system exception occurred
2656             */
2657            public int getSCLicensesSize(long pk) throws SystemException {
2658                    Object[] finderArgs = new Object[] { pk };
2659    
2660                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_SCLICENSES_SIZE,
2661                                    finderArgs, this);
2662    
2663                    if (count == null) {
2664                            Session session = null;
2665    
2666                            try {
2667                                    session = openSession();
2668    
2669                                    SQLQuery q = session.createSQLQuery(_SQL_GETSCLICENSESSIZE);
2670    
2671                                    q.addScalar(COUNT_COLUMN_NAME,
2672                                            com.liferay.portal.kernel.dao.orm.Type.LONG);
2673    
2674                                    QueryPos qPos = QueryPos.getInstance(q);
2675    
2676                                    qPos.add(pk);
2677    
2678                                    count = (Long)q.uniqueResult();
2679                            }
2680                            catch (Exception e) {
2681                                    throw processException(e);
2682                            }
2683                            finally {
2684                                    if (count == null) {
2685                                            count = Long.valueOf(0);
2686                                    }
2687    
2688                                    FinderCacheUtil.putResult(FINDER_PATH_GET_SCLICENSES_SIZE,
2689                                            finderArgs, count);
2690    
2691                                    closeSession(session);
2692                            }
2693                    }
2694    
2695                    return count.intValue();
2696            }
2697    
2698            public static final FinderPath FINDER_PATH_CONTAINS_SCLICENSE = new FinderPath(com.liferay.portlet.softwarecatalog.model.impl.SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
2699                            SCProductEntryModelImpl.FINDER_CACHE_ENABLED_SCLICENSES_SCPRODUCTENTRIES,
2700                            SCProductEntryModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME,
2701                            "containsSCLicense",
2702                            new String[] { Long.class.getName(), Long.class.getName() });
2703    
2704            /**
2705             * Determines if the s c license is associated with the s c product entry.
2706             *
2707             * @param pk the primary key of the s c product entry
2708             * @param scLicensePK the primary key of the s c license
2709             * @return <code>true</code> if the s c license is associated with the s c product entry; <code>false</code> otherwise
2710             * @throws SystemException if a system exception occurred
2711             */
2712            public boolean containsSCLicense(long pk, long scLicensePK)
2713                    throws SystemException {
2714                    Object[] finderArgs = new Object[] { pk, scLicensePK };
2715    
2716                    Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_SCLICENSE,
2717                                    finderArgs, this);
2718    
2719                    if (value == null) {
2720                            try {
2721                                    value = Boolean.valueOf(containsSCLicense.contains(pk,
2722                                                            scLicensePK));
2723                            }
2724                            catch (Exception e) {
2725                                    throw processException(e);
2726                            }
2727                            finally {
2728                                    if (value == null) {
2729                                            value = Boolean.FALSE;
2730                                    }
2731    
2732                                    FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_SCLICENSE,
2733                                            finderArgs, value);
2734                            }
2735                    }
2736    
2737                    return value.booleanValue();
2738            }
2739    
2740            /**
2741             * Determines if the s c product entry has any s c licenses associated with it.
2742             *
2743             * @param pk the primary key of the s c product entry to check for associations with s c licenses
2744             * @return <code>true</code> if the s c product entry has any s c licenses associated with it; <code>false</code> otherwise
2745             * @throws SystemException if a system exception occurred
2746             */
2747            public boolean containsSCLicenses(long pk) throws SystemException {
2748                    if (getSCLicensesSize(pk) > 0) {
2749                            return true;
2750                    }
2751                    else {
2752                            return false;
2753                    }
2754            }
2755    
2756            /**
2757             * Adds an association between the s c product entry and the s c license. Also notifies the appropriate model listeners and clears the mapping table finder cache.
2758             *
2759             * @param pk the primary key of the s c product entry
2760             * @param scLicensePK the primary key of the s c license
2761             * @throws SystemException if a system exception occurred
2762             */
2763            public void addSCLicense(long pk, long scLicensePK)
2764                    throws SystemException {
2765                    try {
2766                            addSCLicense.add(pk, scLicensePK);
2767                    }
2768                    catch (Exception e) {
2769                            throw processException(e);
2770                    }
2771                    finally {
2772                            FinderCacheUtil.clearCache(SCProductEntryModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
2773                    }
2774            }
2775    
2776            /**
2777             * Adds an association between the s c product entry and the s c license. Also notifies the appropriate model listeners and clears the mapping table finder cache.
2778             *
2779             * @param pk the primary key of the s c product entry
2780             * @param scLicense the s c license
2781             * @throws SystemException if a system exception occurred
2782             */
2783            public void addSCLicense(long pk,
2784                    com.liferay.portlet.softwarecatalog.model.SCLicense scLicense)
2785                    throws SystemException {
2786                    try {
2787                            addSCLicense.add(pk, scLicense.getPrimaryKey());
2788                    }
2789                    catch (Exception e) {
2790                            throw processException(e);
2791                    }
2792                    finally {
2793                            FinderCacheUtil.clearCache(SCProductEntryModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
2794                    }
2795            }
2796    
2797            /**
2798             * Adds an association between the s c product entry and the s c licenses. Also notifies the appropriate model listeners and clears the mapping table finder cache.
2799             *
2800             * @param pk the primary key of the s c product entry
2801             * @param scLicensePKs the primary keys of the s c licenses
2802             * @throws SystemException if a system exception occurred
2803             */
2804            public void addSCLicenses(long pk, long[] scLicensePKs)
2805                    throws SystemException {
2806                    try {
2807                            for (long scLicensePK : scLicensePKs) {
2808                                    addSCLicense.add(pk, scLicensePK);
2809                            }
2810                    }
2811                    catch (Exception e) {
2812                            throw processException(e);
2813                    }
2814                    finally {
2815                            FinderCacheUtil.clearCache(SCProductEntryModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
2816                    }
2817            }
2818    
2819            /**
2820             * Adds an association between the s c product entry and the s c licenses. Also notifies the appropriate model listeners and clears the mapping table finder cache.
2821             *
2822             * @param pk the primary key of the s c product entry
2823             * @param scLicenses the s c licenses
2824             * @throws SystemException if a system exception occurred
2825             */
2826            public void addSCLicenses(long pk,
2827                    List<com.liferay.portlet.softwarecatalog.model.SCLicense> scLicenses)
2828                    throws SystemException {
2829                    try {
2830                            for (com.liferay.portlet.softwarecatalog.model.SCLicense scLicense : scLicenses) {
2831                                    addSCLicense.add(pk, scLicense.getPrimaryKey());
2832                            }
2833                    }
2834                    catch (Exception e) {
2835                            throw processException(e);
2836                    }
2837                    finally {
2838                            FinderCacheUtil.clearCache(SCProductEntryModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
2839                    }
2840            }
2841    
2842            /**
2843             * Clears all associations between the s c product entry and its s c licenses. Also notifies the appropriate model listeners and clears the mapping table finder cache.
2844             *
2845             * @param pk the primary key of the s c product entry to clear the associated s c licenses from
2846             * @throws SystemException if a system exception occurred
2847             */
2848            public void clearSCLicenses(long pk) throws SystemException {
2849                    try {
2850                            clearSCLicenses.clear(pk);
2851                    }
2852                    catch (Exception e) {
2853                            throw processException(e);
2854                    }
2855                    finally {
2856                            FinderCacheUtil.clearCache(SCProductEntryModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
2857                    }
2858            }
2859    
2860            /**
2861             * Removes the association between the s c product entry and the s c license. Also notifies the appropriate model listeners and clears the mapping table finder cache.
2862             *
2863             * @param pk the primary key of the s c product entry
2864             * @param scLicensePK the primary key of the s c license
2865             * @throws SystemException if a system exception occurred
2866             */
2867            public void removeSCLicense(long pk, long scLicensePK)
2868                    throws SystemException {
2869                    try {
2870                            removeSCLicense.remove(pk, scLicensePK);
2871                    }
2872                    catch (Exception e) {
2873                            throw processException(e);
2874                    }
2875                    finally {
2876                            FinderCacheUtil.clearCache(SCProductEntryModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
2877                    }
2878            }
2879    
2880            /**
2881             * Removes the association between the s c product entry and the s c license. Also notifies the appropriate model listeners and clears the mapping table finder cache.
2882             *
2883             * @param pk the primary key of the s c product entry
2884             * @param scLicense the s c license
2885             * @throws SystemException if a system exception occurred
2886             */
2887            public void removeSCLicense(long pk,
2888                    com.liferay.portlet.softwarecatalog.model.SCLicense scLicense)
2889                    throws SystemException {
2890                    try {
2891                            removeSCLicense.remove(pk, scLicense.getPrimaryKey());
2892                    }
2893                    catch (Exception e) {
2894                            throw processException(e);
2895                    }
2896                    finally {
2897                            FinderCacheUtil.clearCache(SCProductEntryModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
2898                    }
2899            }
2900    
2901            /**
2902             * Removes the association between the s c product entry and the s c licenses. Also notifies the appropriate model listeners and clears the mapping table finder cache.
2903             *
2904             * @param pk the primary key of the s c product entry
2905             * @param scLicensePKs the primary keys of the s c licenses
2906             * @throws SystemException if a system exception occurred
2907             */
2908            public void removeSCLicenses(long pk, long[] scLicensePKs)
2909                    throws SystemException {
2910                    try {
2911                            for (long scLicensePK : scLicensePKs) {
2912                                    removeSCLicense.remove(pk, scLicensePK);
2913                            }
2914                    }
2915                    catch (Exception e) {
2916                            throw processException(e);
2917                    }
2918                    finally {
2919                            FinderCacheUtil.clearCache(SCProductEntryModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
2920                    }
2921            }
2922    
2923            /**
2924             * Removes the association between the s c product entry and the s c licenses. Also notifies the appropriate model listeners and clears the mapping table finder cache.
2925             *
2926             * @param pk the primary key of the s c product entry
2927             * @param scLicenses the s c licenses
2928             * @throws SystemException if a system exception occurred
2929             */
2930            public void removeSCLicenses(long pk,
2931                    List<com.liferay.portlet.softwarecatalog.model.SCLicense> scLicenses)
2932                    throws SystemException {
2933                    try {
2934                            for (com.liferay.portlet.softwarecatalog.model.SCLicense scLicense : scLicenses) {
2935                                    removeSCLicense.remove(pk, scLicense.getPrimaryKey());
2936                            }
2937                    }
2938                    catch (Exception e) {
2939                            throw processException(e);
2940                    }
2941                    finally {
2942                            FinderCacheUtil.clearCache(SCProductEntryModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
2943                    }
2944            }
2945    
2946            /**
2947             * Sets the s c licenses associated with the s c product entry, removing and adding associations as necessary. Also notifies the appropriate model listeners and clears the mapping table finder cache.
2948             *
2949             * @param pk the primary key of the s c product entry to set the associations for
2950             * @param scLicensePKs the primary keys of the s c licenses to be associated with the s c product entry
2951             * @throws SystemException if a system exception occurred
2952             */
2953            public void setSCLicenses(long pk, long[] scLicensePKs)
2954                    throws SystemException {
2955                    try {
2956                            Set<Long> scLicensePKSet = SetUtil.fromArray(scLicensePKs);
2957    
2958                            List<com.liferay.portlet.softwarecatalog.model.SCLicense> scLicenses =
2959                                    getSCLicenses(pk);
2960    
2961                            for (com.liferay.portlet.softwarecatalog.model.SCLicense scLicense : scLicenses) {
2962                                    if (!scLicensePKSet.remove(scLicense.getPrimaryKey())) {
2963                                            removeSCLicense.remove(pk, scLicense.getPrimaryKey());
2964                                    }
2965                            }
2966    
2967                            for (Long scLicensePK : scLicensePKSet) {
2968                                    addSCLicense.add(pk, scLicensePK);
2969                            }
2970                    }
2971                    catch (Exception e) {
2972                            throw processException(e);
2973                    }
2974                    finally {
2975                            FinderCacheUtil.clearCache(SCProductEntryModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
2976                    }
2977            }
2978    
2979            /**
2980             * Sets the s c licenses associated with the s c product entry, removing and adding associations as necessary. Also notifies the appropriate model listeners and clears the mapping table finder cache.
2981             *
2982             * @param pk the primary key of the s c product entry to set the associations for
2983             * @param scLicenses the s c licenses to be associated with the s c product entry
2984             * @throws SystemException if a system exception occurred
2985             */
2986            public void setSCLicenses(long pk,
2987                    List<com.liferay.portlet.softwarecatalog.model.SCLicense> scLicenses)
2988                    throws SystemException {
2989                    try {
2990                            long[] scLicensePKs = new long[scLicenses.size()];
2991    
2992                            for (int i = 0; i < scLicenses.size(); i++) {
2993                                    com.liferay.portlet.softwarecatalog.model.SCLicense scLicense = scLicenses.get(i);
2994    
2995                                    scLicensePKs[i] = scLicense.getPrimaryKey();
2996                            }
2997    
2998                            setSCLicenses(pk, scLicensePKs);
2999                    }
3000                    catch (Exception e) {
3001                            throw processException(e);
3002                    }
3003                    finally {
3004                            FinderCacheUtil.clearCache(SCProductEntryModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
3005                    }
3006            }
3007    
3008            /**
3009             * Initializes the s c product entry persistence.
3010             */
3011            public void afterPropertiesSet() {
3012                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
3013                                            com.liferay.portal.util.PropsUtil.get(
3014                                                    "value.object.listener.com.liferay.portlet.softwarecatalog.model.SCProductEntry")));
3015    
3016                    if (listenerClassNames.length > 0) {
3017                            try {
3018                                    List<ModelListener<SCProductEntry>> listenersList = new ArrayList<ModelListener<SCProductEntry>>();
3019    
3020                                    for (String listenerClassName : listenerClassNames) {
3021                                            listenersList.add((ModelListener<SCProductEntry>)InstanceFactory.newInstance(
3022                                                            listenerClassName));
3023                                    }
3024    
3025                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
3026                            }
3027                            catch (Exception e) {
3028                                    _log.error(e);
3029                            }
3030                    }
3031    
3032                    containsSCLicense = new ContainsSCLicense(this);
3033    
3034                    addSCLicense = new AddSCLicense(this);
3035                    clearSCLicenses = new ClearSCLicenses(this);
3036                    removeSCLicense = new RemoveSCLicense(this);
3037            }
3038    
3039            public void destroy() {
3040                    EntityCacheUtil.removeCache(SCProductEntryImpl.class.getName());
3041                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
3042                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST);
3043            }
3044    
3045            @BeanReference(type = SCLicensePersistence.class)
3046            protected SCLicensePersistence scLicensePersistence;
3047            @BeanReference(type = SCFrameworkVersionPersistence.class)
3048            protected SCFrameworkVersionPersistence scFrameworkVersionPersistence;
3049            @BeanReference(type = SCProductEntryPersistence.class)
3050            protected SCProductEntryPersistence scProductEntryPersistence;
3051            @BeanReference(type = SCProductScreenshotPersistence.class)
3052            protected SCProductScreenshotPersistence scProductScreenshotPersistence;
3053            @BeanReference(type = SCProductVersionPersistence.class)
3054            protected SCProductVersionPersistence scProductVersionPersistence;
3055            @BeanReference(type = GroupPersistence.class)
3056            protected GroupPersistence groupPersistence;
3057            @BeanReference(type = ImagePersistence.class)
3058            protected ImagePersistence imagePersistence;
3059            @BeanReference(type = ResourcePersistence.class)
3060            protected ResourcePersistence resourcePersistence;
3061            @BeanReference(type = UserPersistence.class)
3062            protected UserPersistence userPersistence;
3063            @BeanReference(type = MBMessagePersistence.class)
3064            protected MBMessagePersistence mbMessagePersistence;
3065            @BeanReference(type = RatingsStatsPersistence.class)
3066            protected RatingsStatsPersistence ratingsStatsPersistence;
3067            protected ContainsSCLicense containsSCLicense;
3068            protected AddSCLicense addSCLicense;
3069            protected ClearSCLicenses clearSCLicenses;
3070            protected RemoveSCLicense removeSCLicense;
3071    
3072            protected class ContainsSCLicense {
3073                    protected ContainsSCLicense(
3074                            SCProductEntryPersistenceImpl persistenceImpl) {
3075                            super();
3076    
3077                            _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
3078                                            _SQL_CONTAINSSCLICENSE,
3079                                            new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
3080                                            RowMapper.COUNT);
3081                    }
3082    
3083                    protected boolean contains(long productEntryId, long licenseId) {
3084                            List<Integer> results = _mappingSqlQuery.execute(new Object[] {
3085                                                    new Long(productEntryId), new Long(licenseId)
3086                                            });
3087    
3088                            if (results.size() > 0) {
3089                                    Integer count = results.get(0);
3090    
3091                                    if (count.intValue() > 0) {
3092                                            return true;
3093                                    }
3094                            }
3095    
3096                            return false;
3097                    }
3098    
3099                    private MappingSqlQuery<Integer> _mappingSqlQuery;
3100            }
3101    
3102            protected class AddSCLicense {
3103                    protected AddSCLicense(SCProductEntryPersistenceImpl persistenceImpl) {
3104                            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
3105                                            "INSERT INTO SCLicenses_SCProductEntries (productEntryId, licenseId) VALUES (?, ?)",
3106                                            new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
3107                            _persistenceImpl = persistenceImpl;
3108                    }
3109    
3110                    protected void add(long productEntryId, long licenseId)
3111                            throws SystemException {
3112                            if (!_persistenceImpl.containsSCLicense.contains(productEntryId,
3113                                                    licenseId)) {
3114                                    ModelListener<com.liferay.portlet.softwarecatalog.model.SCLicense>[] scLicenseListeners =
3115                                            scLicensePersistence.getListeners();
3116    
3117                                    for (ModelListener<SCProductEntry> listener : listeners) {
3118                                            listener.onBeforeAddAssociation(productEntryId,
3119                                                    com.liferay.portlet.softwarecatalog.model.SCLicense.class.getName(),
3120                                                    licenseId);
3121                                    }
3122    
3123                                    for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCLicense> listener : scLicenseListeners) {
3124                                            listener.onBeforeAddAssociation(licenseId,
3125                                                    SCProductEntry.class.getName(), productEntryId);
3126                                    }
3127    
3128                                    _sqlUpdate.update(new Object[] {
3129                                                    new Long(productEntryId), new Long(licenseId)
3130                                            });
3131    
3132                                    for (ModelListener<SCProductEntry> listener : listeners) {
3133                                            listener.onAfterAddAssociation(productEntryId,
3134                                                    com.liferay.portlet.softwarecatalog.model.SCLicense.class.getName(),
3135                                                    licenseId);
3136                                    }
3137    
3138                                    for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCLicense> listener : scLicenseListeners) {
3139                                            listener.onAfterAddAssociation(licenseId,
3140                                                    SCProductEntry.class.getName(), productEntryId);
3141                                    }
3142                            }
3143                    }
3144    
3145                    private SqlUpdate _sqlUpdate;
3146                    private SCProductEntryPersistenceImpl _persistenceImpl;
3147            }
3148    
3149            protected class ClearSCLicenses {
3150                    protected ClearSCLicenses(SCProductEntryPersistenceImpl persistenceImpl) {
3151                            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
3152                                            "DELETE FROM SCLicenses_SCProductEntries WHERE productEntryId = ?",
3153                                            new int[] { java.sql.Types.BIGINT });
3154                    }
3155    
3156                    protected void clear(long productEntryId) throws SystemException {
3157                            ModelListener<com.liferay.portlet.softwarecatalog.model.SCLicense>[] scLicenseListeners =
3158                                    scLicensePersistence.getListeners();
3159    
3160                            List<com.liferay.portlet.softwarecatalog.model.SCLicense> scLicenses =
3161                                    null;
3162    
3163                            if ((listeners.length > 0) || (scLicenseListeners.length > 0)) {
3164                                    scLicenses = getSCLicenses(productEntryId);
3165    
3166                                    for (com.liferay.portlet.softwarecatalog.model.SCLicense scLicense : scLicenses) {
3167                                            for (ModelListener<SCProductEntry> listener : listeners) {
3168                                                    listener.onBeforeRemoveAssociation(productEntryId,
3169                                                            com.liferay.portlet.softwarecatalog.model.SCLicense.class.getName(),
3170                                                            scLicense.getPrimaryKey());
3171                                            }
3172    
3173                                            for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCLicense> listener : scLicenseListeners) {
3174                                                    listener.onBeforeRemoveAssociation(scLicense.getPrimaryKey(),
3175                                                            SCProductEntry.class.getName(), productEntryId);
3176                                            }
3177                                    }
3178                            }
3179    
3180                            _sqlUpdate.update(new Object[] { new Long(productEntryId) });
3181    
3182                            if ((listeners.length > 0) || (scLicenseListeners.length > 0)) {
3183                                    for (com.liferay.portlet.softwarecatalog.model.SCLicense scLicense : scLicenses) {
3184                                            for (ModelListener<SCProductEntry> listener : listeners) {
3185                                                    listener.onAfterRemoveAssociation(productEntryId,
3186                                                            com.liferay.portlet.softwarecatalog.model.SCLicense.class.getName(),
3187                                                            scLicense.getPrimaryKey());
3188                                            }
3189    
3190                                            for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCLicense> listener : scLicenseListeners) {
3191                                                    listener.onAfterRemoveAssociation(scLicense.getPrimaryKey(),
3192                                                            SCProductEntry.class.getName(), productEntryId);
3193                                            }
3194                                    }
3195                            }
3196                    }
3197    
3198                    private SqlUpdate _sqlUpdate;
3199            }
3200    
3201            protected class RemoveSCLicense {
3202                    protected RemoveSCLicense(SCProductEntryPersistenceImpl persistenceImpl) {
3203                            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
3204                                            "DELETE FROM SCLicenses_SCProductEntries WHERE productEntryId = ? AND licenseId = ?",
3205                                            new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
3206                            _persistenceImpl = persistenceImpl;
3207                    }
3208    
3209                    protected void remove(long productEntryId, long licenseId)
3210                            throws SystemException {
3211                            if (_persistenceImpl.containsSCLicense.contains(productEntryId,
3212                                                    licenseId)) {
3213                                    ModelListener<com.liferay.portlet.softwarecatalog.model.SCLicense>[] scLicenseListeners =
3214                                            scLicensePersistence.getListeners();
3215    
3216                                    for (ModelListener<SCProductEntry> listener : listeners) {
3217                                            listener.onBeforeRemoveAssociation(productEntryId,
3218                                                    com.liferay.portlet.softwarecatalog.model.SCLicense.class.getName(),
3219                                                    licenseId);
3220                                    }
3221    
3222                                    for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCLicense> listener : scLicenseListeners) {
3223                                            listener.onBeforeRemoveAssociation(licenseId,
3224                                                    SCProductEntry.class.getName(), productEntryId);
3225                                    }
3226    
3227                                    _sqlUpdate.update(new Object[] {
3228                                                    new Long(productEntryId), new Long(licenseId)
3229                                            });
3230    
3231                                    for (ModelListener<SCProductEntry> listener : listeners) {
3232                                            listener.onAfterRemoveAssociation(productEntryId,
3233                                                    com.liferay.portlet.softwarecatalog.model.SCLicense.class.getName(),
3234                                                    licenseId);
3235                                    }
3236    
3237                                    for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCLicense> listener : scLicenseListeners) {
3238                                            listener.onAfterRemoveAssociation(licenseId,
3239                                                    SCProductEntry.class.getName(), productEntryId);
3240                                    }
3241                            }
3242                    }
3243    
3244                    private SqlUpdate _sqlUpdate;
3245                    private SCProductEntryPersistenceImpl _persistenceImpl;
3246            }
3247    
3248            private static final String _SQL_SELECT_SCPRODUCTENTRY = "SELECT scProductEntry FROM SCProductEntry scProductEntry";
3249            private static final String _SQL_SELECT_SCPRODUCTENTRY_WHERE = "SELECT scProductEntry FROM SCProductEntry scProductEntry WHERE ";
3250            private static final String _SQL_COUNT_SCPRODUCTENTRY = "SELECT COUNT(scProductEntry) FROM SCProductEntry scProductEntry";
3251            private static final String _SQL_COUNT_SCPRODUCTENTRY_WHERE = "SELECT COUNT(scProductEntry) FROM SCProductEntry scProductEntry WHERE ";
3252            private static final String _SQL_GETSCLICENSES = "SELECT {SCLicense.*} FROM SCLicense INNER JOIN SCLicenses_SCProductEntries ON (SCLicenses_SCProductEntries.licenseId = SCLicense.licenseId) WHERE (SCLicenses_SCProductEntries.productEntryId = ?)";
3253            private static final String _SQL_GETSCLICENSESSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM SCLicenses_SCProductEntries WHERE productEntryId = ?";
3254            private static final String _SQL_CONTAINSSCLICENSE = "SELECT COUNT(*) AS COUNT_VALUE FROM SCLicenses_SCProductEntries WHERE productEntryId = ? AND licenseId = ?";
3255            private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "scProductEntry.groupId = ?";
3256            private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "scProductEntry.companyId = ?";
3257            private static final String _FINDER_COLUMN_G_U_GROUPID_2 = "scProductEntry.groupId = ? AND ";
3258            private static final String _FINDER_COLUMN_G_U_USERID_2 = "scProductEntry.userId = ?";
3259            private static final String _FINDER_COLUMN_RG_RA_REPOGROUPID_1 = "scProductEntry.repoGroupId IS NULL AND ";
3260            private static final String _FINDER_COLUMN_RG_RA_REPOGROUPID_2 = "lower(scProductEntry.repoGroupId) = lower(CAST_TEXT(?)) AND ";
3261            private static final String _FINDER_COLUMN_RG_RA_REPOGROUPID_3 = "(scProductEntry.repoGroupId IS NULL OR lower(scProductEntry.repoGroupId) = lower(CAST_TEXT(?))) AND ";
3262            private static final String _FINDER_COLUMN_RG_RA_REPOARTIFACTID_1 = "scProductEntry.repoArtifactId IS NULL";
3263            private static final String _FINDER_COLUMN_RG_RA_REPOARTIFACTID_2 = "lower(scProductEntry.repoArtifactId) = lower(CAST_TEXT(?))";
3264            private static final String _FINDER_COLUMN_RG_RA_REPOARTIFACTID_3 = "(scProductEntry.repoArtifactId IS NULL OR lower(scProductEntry.repoArtifactId) = lower(CAST_TEXT(?)))";
3265            private static final String _FILTER_SQL_SELECT_SCPRODUCTENTRY_WHERE = "SELECT DISTINCT {scProductEntry.*} FROM SCProductEntry scProductEntry WHERE ";
3266            private static final String _FILTER_SQL_SELECT_SCPRODUCTENTRY_NO_INLINE_DISTINCT_WHERE_1 =
3267                    "SELECT {SCProductEntry.*} FROM (SELECT DISTINCT scProductEntry.productEntryId FROM SCProductEntry scProductEntry WHERE ";
3268            private static final String _FILTER_SQL_SELECT_SCPRODUCTENTRY_NO_INLINE_DISTINCT_WHERE_2 =
3269                    ") TEMP_TABLE INNER JOIN SCProductEntry ON TEMP_TABLE.productEntryId = SCProductEntry.productEntryId";
3270            private static final String _FILTER_SQL_COUNT_SCPRODUCTENTRY_WHERE = "SELECT COUNT(DISTINCT scProductEntry.productEntryId) AS COUNT_VALUE FROM SCProductEntry scProductEntry WHERE ";
3271            private static final String _FILTER_COLUMN_PK = "scProductEntry.productEntryId";
3272            private static final String _FILTER_COLUMN_USERID = "scProductEntry.userId";
3273            private static final String _FILTER_ENTITY_ALIAS = "scProductEntry";
3274            private static final String _FILTER_ENTITY_TABLE = "SCProductEntry";
3275            private static final String _ORDER_BY_ENTITY_ALIAS = "scProductEntry.";
3276            private static final String _ORDER_BY_ENTITY_TABLE = "SCProductEntry.";
3277            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No SCProductEntry exists with the primary key ";
3278            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No SCProductEntry exists with the key {";
3279            private static Log _log = LogFactoryUtil.getLog(SCProductEntryPersistenceImpl.class);
3280    }