001    /**
002     * Copyright (c) 2000-2012 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.bean.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.CacheModel;
045    import com.liferay.portal.model.ModelListener;
046    import com.liferay.portal.security.permission.InlineSQLHelperUtil;
047    import com.liferay.portal.service.persistence.BatchSessionUtil;
048    import com.liferay.portal.service.persistence.GroupPersistence;
049    import com.liferay.portal.service.persistence.ImagePersistence;
050    import com.liferay.portal.service.persistence.ResourcePersistence;
051    import com.liferay.portal.service.persistence.UserPersistence;
052    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
053    
054    import com.liferay.portlet.messageboards.service.persistence.MBMessagePersistence;
055    import com.liferay.portlet.ratings.service.persistence.RatingsStatsPersistence;
056    import com.liferay.portlet.softwarecatalog.NoSuchProductEntryException;
057    import com.liferay.portlet.softwarecatalog.model.SCProductEntry;
058    import com.liferay.portlet.softwarecatalog.model.impl.SCProductEntryImpl;
059    import com.liferay.portlet.softwarecatalog.model.impl.SCProductEntryModelImpl;
060    
061    import java.io.Serializable;
062    
063    import java.util.ArrayList;
064    import java.util.Collections;
065    import java.util.List;
066    import java.util.Set;
067    
068    /**
069     * The persistence implementation for the s c product entry service.
070     *
071     * <p>
072     * Caching information and settings can be found in <code>portal.properties</code>
073     * </p>
074     *
075     * @author Brian Wing Shun Chan
076     * @see SCProductEntryPersistence
077     * @see SCProductEntryUtil
078     * @generated
079     */
080    public class SCProductEntryPersistenceImpl extends BasePersistenceImpl<SCProductEntry>
081            implements SCProductEntryPersistence {
082            /*
083             * NOTE FOR DEVELOPERS:
084             *
085             * 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.
086             */
087            public static final String FINDER_CLASS_NAME_ENTITY = SCProductEntryImpl.class.getName();
088            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
089                    ".List1";
090            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
091                    ".List2";
092            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
093                            SCProductEntryModelImpl.FINDER_CACHE_ENABLED,
094                            SCProductEntryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
095                            "findByGroupId",
096                            new String[] {
097                                    Long.class.getName(),
098                                    
099                            "java.lang.Integer", "java.lang.Integer",
100                                    "com.liferay.portal.kernel.util.OrderByComparator"
101                            });
102            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID =
103                    new FinderPath(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
104                            SCProductEntryModelImpl.FINDER_CACHE_ENABLED,
105                            SCProductEntryImpl.class,
106                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByGroupId",
107                            new String[] { Long.class.getName() },
108                            SCProductEntryModelImpl.GROUPID_COLUMN_BITMASK);
109            public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
110                            SCProductEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
111                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId",
112                            new String[] { Long.class.getName() });
113            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID =
114                    new FinderPath(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
115                            SCProductEntryModelImpl.FINDER_CACHE_ENABLED,
116                            SCProductEntryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
117                            "findByCompanyId",
118                            new String[] {
119                                    Long.class.getName(),
120                                    
121                            "java.lang.Integer", "java.lang.Integer",
122                                    "com.liferay.portal.kernel.util.OrderByComparator"
123                            });
124            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID =
125                    new FinderPath(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
126                            SCProductEntryModelImpl.FINDER_CACHE_ENABLED,
127                            SCProductEntryImpl.class,
128                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCompanyId",
129                            new String[] { Long.class.getName() },
130                            SCProductEntryModelImpl.COMPANYID_COLUMN_BITMASK);
131            public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
132                            SCProductEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
133                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCompanyId",
134                            new String[] { Long.class.getName() });
135            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U = new FinderPath(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
136                            SCProductEntryModelImpl.FINDER_CACHE_ENABLED,
137                            SCProductEntryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
138                            "findByG_U",
139                            new String[] {
140                                    Long.class.getName(), Long.class.getName(),
141                                    
142                            "java.lang.Integer", "java.lang.Integer",
143                                    "com.liferay.portal.kernel.util.OrderByComparator"
144                            });
145            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U = new FinderPath(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
146                            SCProductEntryModelImpl.FINDER_CACHE_ENABLED,
147                            SCProductEntryImpl.class,
148                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_U",
149                            new String[] { Long.class.getName(), Long.class.getName() },
150                            SCProductEntryModelImpl.GROUPID_COLUMN_BITMASK |
151                            SCProductEntryModelImpl.USERID_COLUMN_BITMASK);
152            public static final FinderPath FINDER_PATH_COUNT_BY_G_U = new FinderPath(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
153                            SCProductEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
154                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_U",
155                            new String[] { Long.class.getName(), Long.class.getName() });
156            public static final FinderPath FINDER_PATH_FETCH_BY_RG_RA = new FinderPath(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
157                            SCProductEntryModelImpl.FINDER_CACHE_ENABLED,
158                            SCProductEntryImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByRG_RA",
159                            new String[] { String.class.getName(), String.class.getName() },
160                            SCProductEntryModelImpl.REPOGROUPID_COLUMN_BITMASK |
161                            SCProductEntryModelImpl.REPOARTIFACTID_COLUMN_BITMASK);
162            public static final FinderPath FINDER_PATH_COUNT_BY_RG_RA = new FinderPath(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
163                            SCProductEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
164                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByRG_RA",
165                            new String[] { String.class.getName(), String.class.getName() });
166            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
167                            SCProductEntryModelImpl.FINDER_CACHE_ENABLED,
168                            SCProductEntryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
169                            "findAll", new String[0]);
170            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
171                            SCProductEntryModelImpl.FINDER_CACHE_ENABLED,
172                            SCProductEntryImpl.class,
173                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
174            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
175                            SCProductEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
176                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
177    
178            /**
179             * Caches the s c product entry in the entity cache if it is enabled.
180             *
181             * @param scProductEntry the s c product entry
182             */
183            public void cacheResult(SCProductEntry scProductEntry) {
184                    EntityCacheUtil.putResult(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
185                            SCProductEntryImpl.class, scProductEntry.getPrimaryKey(),
186                            scProductEntry);
187    
188                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_RG_RA,
189                            new Object[] {
190                                    scProductEntry.getRepoGroupId(),
191                                    
192                            scProductEntry.getRepoArtifactId()
193                            }, scProductEntry);
194    
195                    scProductEntry.resetOriginalValues();
196            }
197    
198            /**
199             * Caches the s c product entries in the entity cache if it is enabled.
200             *
201             * @param scProductEntries the s c product entries
202             */
203            public void cacheResult(List<SCProductEntry> scProductEntries) {
204                    for (SCProductEntry scProductEntry : scProductEntries) {
205                            if (EntityCacheUtil.getResult(
206                                                    SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
207                                                    SCProductEntryImpl.class, scProductEntry.getPrimaryKey()) == null) {
208                                    cacheResult(scProductEntry);
209                            }
210                            else {
211                                    scProductEntry.resetOriginalValues();
212                            }
213                    }
214            }
215    
216            /**
217             * Clears the cache for all s c product entries.
218             *
219             * <p>
220             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
221             * </p>
222             */
223            @Override
224            public void clearCache() {
225                    if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
226                            CacheRegistryUtil.clear(SCProductEntryImpl.class.getName());
227                    }
228    
229                    EntityCacheUtil.clearCache(SCProductEntryImpl.class.getName());
230    
231                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
232                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
233                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
234            }
235    
236            /**
237             * Clears the cache for the s c product entry.
238             *
239             * <p>
240             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
241             * </p>
242             */
243            @Override
244            public void clearCache(SCProductEntry scProductEntry) {
245                    EntityCacheUtil.removeResult(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
246                            SCProductEntryImpl.class, scProductEntry.getPrimaryKey());
247    
248                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
249                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
250    
251                    clearUniqueFindersCache(scProductEntry);
252            }
253    
254            @Override
255            public void clearCache(List<SCProductEntry> scProductEntries) {
256                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
257                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
258    
259                    for (SCProductEntry scProductEntry : scProductEntries) {
260                            EntityCacheUtil.removeResult(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
261                                    SCProductEntryImpl.class, scProductEntry.getPrimaryKey());
262    
263                            clearUniqueFindersCache(scProductEntry);
264                    }
265            }
266    
267            protected void clearUniqueFindersCache(SCProductEntry scProductEntry) {
268                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_RG_RA,
269                            new Object[] {
270                                    scProductEntry.getRepoGroupId(),
271                                    
272                            scProductEntry.getRepoArtifactId()
273                            });
274            }
275    
276            /**
277             * Creates a new s c product entry with the primary key. Does not add the s c product entry to the database.
278             *
279             * @param productEntryId the primary key for the new s c product entry
280             * @return the new s c product entry
281             */
282            public SCProductEntry create(long productEntryId) {
283                    SCProductEntry scProductEntry = new SCProductEntryImpl();
284    
285                    scProductEntry.setNew(true);
286                    scProductEntry.setPrimaryKey(productEntryId);
287    
288                    return scProductEntry;
289            }
290    
291            /**
292             * Removes the s c product entry with the primary key from the database. Also notifies the appropriate model listeners.
293             *
294             * @param productEntryId the primary key of the s c product entry
295             * @return the s c product entry that was removed
296             * @throws com.liferay.portlet.softwarecatalog.NoSuchProductEntryException if a s c product entry with the primary key could not be found
297             * @throws SystemException if a system exception occurred
298             */
299            public SCProductEntry remove(long productEntryId)
300                    throws NoSuchProductEntryException, SystemException {
301                    return remove(Long.valueOf(productEntryId));
302            }
303    
304            /**
305             * Removes the s c product entry with the primary key from the database. Also notifies the appropriate model listeners.
306             *
307             * @param primaryKey the primary key of the s c product entry
308             * @return the s c product entry that was removed
309             * @throws com.liferay.portlet.softwarecatalog.NoSuchProductEntryException if a s c product entry with the primary key could not be found
310             * @throws SystemException if a system exception occurred
311             */
312            @Override
313            public SCProductEntry remove(Serializable primaryKey)
314                    throws NoSuchProductEntryException, SystemException {
315                    Session session = null;
316    
317                    try {
318                            session = openSession();
319    
320                            SCProductEntry scProductEntry = (SCProductEntry)session.get(SCProductEntryImpl.class,
321                                            primaryKey);
322    
323                            if (scProductEntry == null) {
324                                    if (_log.isWarnEnabled()) {
325                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
326                                    }
327    
328                                    throw new NoSuchProductEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
329                                            primaryKey);
330                            }
331    
332                            return remove(scProductEntry);
333                    }
334                    catch (NoSuchProductEntryException nsee) {
335                            throw nsee;
336                    }
337                    catch (Exception e) {
338                            throw processException(e);
339                    }
340                    finally {
341                            closeSession(session);
342                    }
343            }
344    
345            @Override
346            protected SCProductEntry removeImpl(SCProductEntry scProductEntry)
347                    throws SystemException {
348                    scProductEntry = toUnwrappedModel(scProductEntry);
349    
350                    try {
351                            clearSCLicenses.clear(scProductEntry.getPrimaryKey());
352                    }
353                    catch (Exception e) {
354                            throw processException(e);
355                    }
356                    finally {
357                            FinderCacheUtil.clearCache(SCProductEntryModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
358                    }
359    
360                    Session session = null;
361    
362                    try {
363                            session = openSession();
364    
365                            BatchSessionUtil.delete(session, scProductEntry);
366                    }
367                    catch (Exception e) {
368                            throw processException(e);
369                    }
370                    finally {
371                            closeSession(session);
372                    }
373    
374                    clearCache(scProductEntry);
375    
376                    return scProductEntry;
377            }
378    
379            @Override
380            public SCProductEntry updateImpl(
381                    com.liferay.portlet.softwarecatalog.model.SCProductEntry scProductEntry,
382                    boolean merge) throws SystemException {
383                    scProductEntry = toUnwrappedModel(scProductEntry);
384    
385                    boolean isNew = scProductEntry.isNew();
386    
387                    SCProductEntryModelImpl scProductEntryModelImpl = (SCProductEntryModelImpl)scProductEntry;
388    
389                    Session session = null;
390    
391                    try {
392                            session = openSession();
393    
394                            BatchSessionUtil.update(session, scProductEntry, merge);
395    
396                            scProductEntry.setNew(false);
397                    }
398                    catch (Exception e) {
399                            throw processException(e);
400                    }
401                    finally {
402                            closeSession(session);
403                    }
404    
405                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
406    
407                    if (isNew || !SCProductEntryModelImpl.COLUMN_BITMASK_ENABLED) {
408                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
409                    }
410                    else {
411                            if ((scProductEntryModelImpl.getColumnBitmask() &
412                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
413                                    Object[] args = new Object[] {
414                                                    Long.valueOf(scProductEntryModelImpl.getOriginalGroupId())
415                                            };
416    
417                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
418                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
419                                            args);
420    
421                                    args = new Object[] {
422                                                    Long.valueOf(scProductEntryModelImpl.getGroupId())
423                                            };
424    
425                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
426                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
427                                            args);
428                            }
429    
430                            if ((scProductEntryModelImpl.getColumnBitmask() &
431                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
432                                    Object[] args = new Object[] {
433                                                    Long.valueOf(scProductEntryModelImpl.getOriginalCompanyId())
434                                            };
435    
436                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
437                                            args);
438                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
439                                            args);
440    
441                                    args = new Object[] {
442                                                    Long.valueOf(scProductEntryModelImpl.getCompanyId())
443                                            };
444    
445                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
446                                            args);
447                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
448                                            args);
449                            }
450    
451                            if ((scProductEntryModelImpl.getColumnBitmask() &
452                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U.getColumnBitmask()) != 0) {
453                                    Object[] args = new Object[] {
454                                                    Long.valueOf(scProductEntryModelImpl.getOriginalGroupId()),
455                                                    Long.valueOf(scProductEntryModelImpl.getOriginalUserId())
456                                            };
457    
458                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U, args);
459                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U,
460                                            args);
461    
462                                    args = new Object[] {
463                                                    Long.valueOf(scProductEntryModelImpl.getGroupId()),
464                                                    Long.valueOf(scProductEntryModelImpl.getUserId())
465                                            };
466    
467                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U, args);
468                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U,
469                                            args);
470                            }
471                    }
472    
473                    EntityCacheUtil.putResult(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
474                            SCProductEntryImpl.class, scProductEntry.getPrimaryKey(),
475                            scProductEntry);
476    
477                    if (isNew) {
478                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_RG_RA,
479                                    new Object[] {
480                                            scProductEntry.getRepoGroupId(),
481                                            
482                                    scProductEntry.getRepoArtifactId()
483                                    }, scProductEntry);
484                    }
485                    else {
486                            if ((scProductEntryModelImpl.getColumnBitmask() &
487                                            FINDER_PATH_FETCH_BY_RG_RA.getColumnBitmask()) != 0) {
488                                    Object[] args = new Object[] {
489                                                    scProductEntryModelImpl.getOriginalRepoGroupId(),
490                                                    
491                                                    scProductEntryModelImpl.getOriginalRepoArtifactId()
492                                            };
493    
494                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_RG_RA, args);
495                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_RG_RA, args);
496    
497                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_RG_RA,
498                                            new Object[] {
499                                                    scProductEntry.getRepoGroupId(),
500                                                    
501                                            scProductEntry.getRepoArtifactId()
502                                            }, scProductEntry);
503                            }
504                    }
505    
506                    return scProductEntry;
507            }
508    
509            protected SCProductEntry toUnwrappedModel(SCProductEntry scProductEntry) {
510                    if (scProductEntry instanceof SCProductEntryImpl) {
511                            return scProductEntry;
512                    }
513    
514                    SCProductEntryImpl scProductEntryImpl = new SCProductEntryImpl();
515    
516                    scProductEntryImpl.setNew(scProductEntry.isNew());
517                    scProductEntryImpl.setPrimaryKey(scProductEntry.getPrimaryKey());
518    
519                    scProductEntryImpl.setProductEntryId(scProductEntry.getProductEntryId());
520                    scProductEntryImpl.setGroupId(scProductEntry.getGroupId());
521                    scProductEntryImpl.setCompanyId(scProductEntry.getCompanyId());
522                    scProductEntryImpl.setUserId(scProductEntry.getUserId());
523                    scProductEntryImpl.setUserName(scProductEntry.getUserName());
524                    scProductEntryImpl.setCreateDate(scProductEntry.getCreateDate());
525                    scProductEntryImpl.setModifiedDate(scProductEntry.getModifiedDate());
526                    scProductEntryImpl.setName(scProductEntry.getName());
527                    scProductEntryImpl.setType(scProductEntry.getType());
528                    scProductEntryImpl.setTags(scProductEntry.getTags());
529                    scProductEntryImpl.setShortDescription(scProductEntry.getShortDescription());
530                    scProductEntryImpl.setLongDescription(scProductEntry.getLongDescription());
531                    scProductEntryImpl.setPageURL(scProductEntry.getPageURL());
532                    scProductEntryImpl.setAuthor(scProductEntry.getAuthor());
533                    scProductEntryImpl.setRepoGroupId(scProductEntry.getRepoGroupId());
534                    scProductEntryImpl.setRepoArtifactId(scProductEntry.getRepoArtifactId());
535    
536                    return scProductEntryImpl;
537            }
538    
539            /**
540             * Returns the s c product entry with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
541             *
542             * @param primaryKey the primary key of the s c product entry
543             * @return the s c product entry
544             * @throws com.liferay.portal.NoSuchModelException if a s c product entry with the primary key could not be found
545             * @throws SystemException if a system exception occurred
546             */
547            @Override
548            public SCProductEntry findByPrimaryKey(Serializable primaryKey)
549                    throws NoSuchModelException, SystemException {
550                    return findByPrimaryKey(((Long)primaryKey).longValue());
551            }
552    
553            /**
554             * Returns the s c product entry with the primary key or throws a {@link com.liferay.portlet.softwarecatalog.NoSuchProductEntryException} if it could not be found.
555             *
556             * @param productEntryId the primary key of the s c product entry
557             * @return the s c product entry
558             * @throws com.liferay.portlet.softwarecatalog.NoSuchProductEntryException if a s c product entry with the primary key could not be found
559             * @throws SystemException if a system exception occurred
560             */
561            public SCProductEntry findByPrimaryKey(long productEntryId)
562                    throws NoSuchProductEntryException, SystemException {
563                    SCProductEntry scProductEntry = fetchByPrimaryKey(productEntryId);
564    
565                    if (scProductEntry == null) {
566                            if (_log.isWarnEnabled()) {
567                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + productEntryId);
568                            }
569    
570                            throw new NoSuchProductEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
571                                    productEntryId);
572                    }
573    
574                    return scProductEntry;
575            }
576    
577            /**
578             * Returns the s c product entry with the primary key or returns <code>null</code> if it could not be found.
579             *
580             * @param primaryKey the primary key of the s c product entry
581             * @return the s c product entry, or <code>null</code> if a s c product entry with the primary key could not be found
582             * @throws SystemException if a system exception occurred
583             */
584            @Override
585            public SCProductEntry fetchByPrimaryKey(Serializable primaryKey)
586                    throws SystemException {
587                    return fetchByPrimaryKey(((Long)primaryKey).longValue());
588            }
589    
590            /**
591             * Returns the s c product entry with the primary key or returns <code>null</code> if it could not be found.
592             *
593             * @param productEntryId the primary key of the s c product entry
594             * @return the s c product entry, or <code>null</code> if a s c product entry with the primary key could not be found
595             * @throws SystemException if a system exception occurred
596             */
597            public SCProductEntry fetchByPrimaryKey(long productEntryId)
598                    throws SystemException {
599                    SCProductEntry scProductEntry = (SCProductEntry)EntityCacheUtil.getResult(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
600                                    SCProductEntryImpl.class, productEntryId);
601    
602                    if (scProductEntry == _nullSCProductEntry) {
603                            return null;
604                    }
605    
606                    if (scProductEntry == null) {
607                            Session session = null;
608    
609                            boolean hasException = false;
610    
611                            try {
612                                    session = openSession();
613    
614                                    scProductEntry = (SCProductEntry)session.get(SCProductEntryImpl.class,
615                                                    Long.valueOf(productEntryId));
616                            }
617                            catch (Exception e) {
618                                    hasException = true;
619    
620                                    throw processException(e);
621                            }
622                            finally {
623                                    if (scProductEntry != null) {
624                                            cacheResult(scProductEntry);
625                                    }
626                                    else if (!hasException) {
627                                            EntityCacheUtil.putResult(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
628                                                    SCProductEntryImpl.class, productEntryId,
629                                                    _nullSCProductEntry);
630                                    }
631    
632                                    closeSession(session);
633                            }
634                    }
635    
636                    return scProductEntry;
637            }
638    
639            /**
640             * Returns all the s c product entries where groupId = &#63;.
641             *
642             * @param groupId the group ID
643             * @return the matching s c product entries
644             * @throws SystemException if a system exception occurred
645             */
646            public List<SCProductEntry> findByGroupId(long groupId)
647                    throws SystemException {
648                    return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
649            }
650    
651            /**
652             * Returns a range of all the s c product entries where groupId = &#63;.
653             *
654             * <p>
655             * 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.
656             * </p>
657             *
658             * @param groupId the group ID
659             * @param start the lower bound of the range of s c product entries
660             * @param end the upper bound of the range of s c product entries (not inclusive)
661             * @return the range of matching s c product entries
662             * @throws SystemException if a system exception occurred
663             */
664            public List<SCProductEntry> findByGroupId(long groupId, int start, int end)
665                    throws SystemException {
666                    return findByGroupId(groupId, start, end, null);
667            }
668    
669            /**
670             * Returns an ordered range of all the s c product entries where groupId = &#63;.
671             *
672             * <p>
673             * 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.
674             * </p>
675             *
676             * @param groupId the group ID
677             * @param start the lower bound of the range of s c product entries
678             * @param end the upper bound of the range of s c product entries (not inclusive)
679             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
680             * @return the ordered range of matching s c product entries
681             * @throws SystemException if a system exception occurred
682             */
683            public List<SCProductEntry> findByGroupId(long groupId, int start, int end,
684                    OrderByComparator orderByComparator) throws SystemException {
685                    FinderPath finderPath = null;
686                    Object[] finderArgs = null;
687    
688                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
689                                    (orderByComparator == null)) {
690                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
691                            finderArgs = new Object[] { groupId };
692                    }
693                    else {
694                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
695                            finderArgs = new Object[] { groupId, start, end, orderByComparator };
696                    }
697    
698                    List<SCProductEntry> list = (List<SCProductEntry>)FinderCacheUtil.getResult(finderPath,
699                                    finderArgs, this);
700    
701                    if ((list != null) && !list.isEmpty()) {
702                            for (SCProductEntry scProductEntry : list) {
703                                    if ((groupId != scProductEntry.getGroupId())) {
704                                            list = null;
705    
706                                            break;
707                                    }
708                            }
709                    }
710    
711                    if (list == null) {
712                            StringBundler query = null;
713    
714                            if (orderByComparator != null) {
715                                    query = new StringBundler(3 +
716                                                    (orderByComparator.getOrderByFields().length * 3));
717                            }
718                            else {
719                                    query = new StringBundler(3);
720                            }
721    
722                            query.append(_SQL_SELECT_SCPRODUCTENTRY_WHERE);
723    
724                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
725    
726                            if (orderByComparator != null) {
727                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
728                                            orderByComparator);
729                            }
730    
731                            else {
732                                    query.append(SCProductEntryModelImpl.ORDER_BY_JPQL);
733                            }
734    
735                            String sql = query.toString();
736    
737                            Session session = null;
738    
739                            try {
740                                    session = openSession();
741    
742                                    Query q = session.createQuery(sql);
743    
744                                    QueryPos qPos = QueryPos.getInstance(q);
745    
746                                    qPos.add(groupId);
747    
748                                    list = (List<SCProductEntry>)QueryUtil.list(q, getDialect(),
749                                                    start, end);
750                            }
751                            catch (Exception e) {
752                                    throw processException(e);
753                            }
754                            finally {
755                                    if (list == null) {
756                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
757                                    }
758                                    else {
759                                            cacheResult(list);
760    
761                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
762                                    }
763    
764                                    closeSession(session);
765                            }
766                    }
767    
768                    return list;
769            }
770    
771            /**
772             * Returns the first s c product entry in the ordered set where groupId = &#63;.
773             *
774             * <p>
775             * 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.
776             * </p>
777             *
778             * @param groupId the group ID
779             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
780             * @return the first matching s c product entry
781             * @throws com.liferay.portlet.softwarecatalog.NoSuchProductEntryException if a matching s c product entry could not be found
782             * @throws SystemException if a system exception occurred
783             */
784            public SCProductEntry findByGroupId_First(long groupId,
785                    OrderByComparator orderByComparator)
786                    throws NoSuchProductEntryException, SystemException {
787                    List<SCProductEntry> list = findByGroupId(groupId, 0, 1,
788                                    orderByComparator);
789    
790                    if (list.isEmpty()) {
791                            StringBundler msg = new StringBundler(4);
792    
793                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
794    
795                            msg.append("groupId=");
796                            msg.append(groupId);
797    
798                            msg.append(StringPool.CLOSE_CURLY_BRACE);
799    
800                            throw new NoSuchProductEntryException(msg.toString());
801                    }
802                    else {
803                            return list.get(0);
804                    }
805            }
806    
807            /**
808             * Returns the last s c product entry in the ordered set where groupId = &#63;.
809             *
810             * <p>
811             * 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.
812             * </p>
813             *
814             * @param groupId the group ID
815             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
816             * @return the last matching s c product entry
817             * @throws com.liferay.portlet.softwarecatalog.NoSuchProductEntryException if a matching s c product entry could not be found
818             * @throws SystemException if a system exception occurred
819             */
820            public SCProductEntry findByGroupId_Last(long groupId,
821                    OrderByComparator orderByComparator)
822                    throws NoSuchProductEntryException, SystemException {
823                    int count = countByGroupId(groupId);
824    
825                    List<SCProductEntry> list = findByGroupId(groupId, count - 1, count,
826                                    orderByComparator);
827    
828                    if (list.isEmpty()) {
829                            StringBundler msg = new StringBundler(4);
830    
831                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
832    
833                            msg.append("groupId=");
834                            msg.append(groupId);
835    
836                            msg.append(StringPool.CLOSE_CURLY_BRACE);
837    
838                            throw new NoSuchProductEntryException(msg.toString());
839                    }
840                    else {
841                            return list.get(0);
842                    }
843            }
844    
845            /**
846             * Returns the s c product entries before and after the current s c product entry in the ordered set where groupId = &#63;.
847             *
848             * <p>
849             * 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.
850             * </p>
851             *
852             * @param productEntryId the primary key of the current s c product entry
853             * @param groupId the group ID
854             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
855             * @return the previous, current, and next s c product entry
856             * @throws com.liferay.portlet.softwarecatalog.NoSuchProductEntryException if a s c product entry with the primary key could not be found
857             * @throws SystemException if a system exception occurred
858             */
859            public SCProductEntry[] findByGroupId_PrevAndNext(long productEntryId,
860                    long groupId, OrderByComparator orderByComparator)
861                    throws NoSuchProductEntryException, SystemException {
862                    SCProductEntry scProductEntry = findByPrimaryKey(productEntryId);
863    
864                    Session session = null;
865    
866                    try {
867                            session = openSession();
868    
869                            SCProductEntry[] array = new SCProductEntryImpl[3];
870    
871                            array[0] = getByGroupId_PrevAndNext(session, scProductEntry,
872                                            groupId, orderByComparator, true);
873    
874                            array[1] = scProductEntry;
875    
876                            array[2] = getByGroupId_PrevAndNext(session, scProductEntry,
877                                            groupId, orderByComparator, false);
878    
879                            return array;
880                    }
881                    catch (Exception e) {
882                            throw processException(e);
883                    }
884                    finally {
885                            closeSession(session);
886                    }
887            }
888    
889            protected SCProductEntry getByGroupId_PrevAndNext(Session session,
890                    SCProductEntry scProductEntry, long groupId,
891                    OrderByComparator orderByComparator, boolean previous) {
892                    StringBundler query = null;
893    
894                    if (orderByComparator != null) {
895                            query = new StringBundler(6 +
896                                            (orderByComparator.getOrderByFields().length * 6));
897                    }
898                    else {
899                            query = new StringBundler(3);
900                    }
901    
902                    query.append(_SQL_SELECT_SCPRODUCTENTRY_WHERE);
903    
904                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
905    
906                    if (orderByComparator != null) {
907                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
908    
909                            if (orderByConditionFields.length > 0) {
910                                    query.append(WHERE_AND);
911                            }
912    
913                            for (int i = 0; i < orderByConditionFields.length; i++) {
914                                    query.append(_ORDER_BY_ENTITY_ALIAS);
915                                    query.append(orderByConditionFields[i]);
916    
917                                    if ((i + 1) < orderByConditionFields.length) {
918                                            if (orderByComparator.isAscending() ^ previous) {
919                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
920                                            }
921                                            else {
922                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
923                                            }
924                                    }
925                                    else {
926                                            if (orderByComparator.isAscending() ^ previous) {
927                                                    query.append(WHERE_GREATER_THAN);
928                                            }
929                                            else {
930                                                    query.append(WHERE_LESSER_THAN);
931                                            }
932                                    }
933                            }
934    
935                            query.append(ORDER_BY_CLAUSE);
936    
937                            String[] orderByFields = orderByComparator.getOrderByFields();
938    
939                            for (int i = 0; i < orderByFields.length; i++) {
940                                    query.append(_ORDER_BY_ENTITY_ALIAS);
941                                    query.append(orderByFields[i]);
942    
943                                    if ((i + 1) < orderByFields.length) {
944                                            if (orderByComparator.isAscending() ^ previous) {
945                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
946                                            }
947                                            else {
948                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
949                                            }
950                                    }
951                                    else {
952                                            if (orderByComparator.isAscending() ^ previous) {
953                                                    query.append(ORDER_BY_ASC);
954                                            }
955                                            else {
956                                                    query.append(ORDER_BY_DESC);
957                                            }
958                                    }
959                            }
960                    }
961    
962                    else {
963                            query.append(SCProductEntryModelImpl.ORDER_BY_JPQL);
964                    }
965    
966                    String sql = query.toString();
967    
968                    Query q = session.createQuery(sql);
969    
970                    q.setFirstResult(0);
971                    q.setMaxResults(2);
972    
973                    QueryPos qPos = QueryPos.getInstance(q);
974    
975                    qPos.add(groupId);
976    
977                    if (orderByComparator != null) {
978                            Object[] values = orderByComparator.getOrderByConditionValues(scProductEntry);
979    
980                            for (Object value : values) {
981                                    qPos.add(value);
982                            }
983                    }
984    
985                    List<SCProductEntry> list = q.list();
986    
987                    if (list.size() == 2) {
988                            return list.get(1);
989                    }
990                    else {
991                            return null;
992                    }
993            }
994    
995            /**
996             * Returns all the s c product entries that the user has permission to view where groupId = &#63;.
997             *
998             * @param groupId the group ID
999             * @return the matching s c product entries that the user has permission to view
1000             * @throws SystemException if a system exception occurred
1001             */
1002            public List<SCProductEntry> filterFindByGroupId(long groupId)
1003                    throws SystemException {
1004                    return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
1005                            QueryUtil.ALL_POS, null);
1006            }
1007    
1008            /**
1009             * Returns a range of all the s c product entries that the user has permission to view where groupId = &#63;.
1010             *
1011             * <p>
1012             * 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.
1013             * </p>
1014             *
1015             * @param groupId the group ID
1016             * @param start the lower bound of the range of s c product entries
1017             * @param end the upper bound of the range of s c product entries (not inclusive)
1018             * @return the range of matching s c product entries that the user has permission to view
1019             * @throws SystemException if a system exception occurred
1020             */
1021            public List<SCProductEntry> filterFindByGroupId(long groupId, int start,
1022                    int end) throws SystemException {
1023                    return filterFindByGroupId(groupId, start, end, null);
1024            }
1025    
1026            /**
1027             * Returns an ordered range of all the s c product entries that the user has permissions to view where groupId = &#63;.
1028             *
1029             * <p>
1030             * 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.
1031             * </p>
1032             *
1033             * @param groupId the group ID
1034             * @param start the lower bound of the range of s c product entries
1035             * @param end the upper bound of the range of s c product entries (not inclusive)
1036             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1037             * @return the ordered range of matching s c product entries that the user has permission to view
1038             * @throws SystemException if a system exception occurred
1039             */
1040            public List<SCProductEntry> filterFindByGroupId(long groupId, int start,
1041                    int end, OrderByComparator orderByComparator) throws SystemException {
1042                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1043                            return findByGroupId(groupId, start, end, orderByComparator);
1044                    }
1045    
1046                    StringBundler query = null;
1047    
1048                    if (orderByComparator != null) {
1049                            query = new StringBundler(3 +
1050                                            (orderByComparator.getOrderByFields().length * 3));
1051                    }
1052                    else {
1053                            query = new StringBundler(3);
1054                    }
1055    
1056                    if (getDB().isSupportsInlineDistinct()) {
1057                            query.append(_FILTER_SQL_SELECT_SCPRODUCTENTRY_WHERE);
1058                    }
1059                    else {
1060                            query.append(_FILTER_SQL_SELECT_SCPRODUCTENTRY_NO_INLINE_DISTINCT_WHERE_1);
1061                    }
1062    
1063                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1064    
1065                    if (!getDB().isSupportsInlineDistinct()) {
1066                            query.append(_FILTER_SQL_SELECT_SCPRODUCTENTRY_NO_INLINE_DISTINCT_WHERE_2);
1067                    }
1068    
1069                    if (orderByComparator != null) {
1070                            if (getDB().isSupportsInlineDistinct()) {
1071                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1072                                            orderByComparator);
1073                            }
1074                            else {
1075                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
1076                                            orderByComparator);
1077                            }
1078                    }
1079    
1080                    else {
1081                            if (getDB().isSupportsInlineDistinct()) {
1082                                    query.append(SCProductEntryModelImpl.ORDER_BY_JPQL);
1083                            }
1084                            else {
1085                                    query.append(SCProductEntryModelImpl.ORDER_BY_SQL);
1086                            }
1087                    }
1088    
1089                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1090                                    SCProductEntry.class.getName(),
1091                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
1092    
1093                    Session session = null;
1094    
1095                    try {
1096                            session = openSession();
1097    
1098                            SQLQuery q = session.createSQLQuery(sql);
1099    
1100                            if (getDB().isSupportsInlineDistinct()) {
1101                                    q.addEntity(_FILTER_ENTITY_ALIAS, SCProductEntryImpl.class);
1102                            }
1103                            else {
1104                                    q.addEntity(_FILTER_ENTITY_TABLE, SCProductEntryImpl.class);
1105                            }
1106    
1107                            QueryPos qPos = QueryPos.getInstance(q);
1108    
1109                            qPos.add(groupId);
1110    
1111                            return (List<SCProductEntry>)QueryUtil.list(q, getDialect(), start,
1112                                    end);
1113                    }
1114                    catch (Exception e) {
1115                            throw processException(e);
1116                    }
1117                    finally {
1118                            closeSession(session);
1119                    }
1120            }
1121    
1122            /**
1123             * Returns the s c product entries before and after the current s c product entry in the ordered set of s c product entries that the user has permission to view where groupId = &#63;.
1124             *
1125             * @param productEntryId the primary key of the current s c product entry
1126             * @param groupId the group ID
1127             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1128             * @return the previous, current, and next s c product entry
1129             * @throws com.liferay.portlet.softwarecatalog.NoSuchProductEntryException if a s c product entry with the primary key could not be found
1130             * @throws SystemException if a system exception occurred
1131             */
1132            public SCProductEntry[] filterFindByGroupId_PrevAndNext(
1133                    long productEntryId, long groupId, OrderByComparator orderByComparator)
1134                    throws NoSuchProductEntryException, SystemException {
1135                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1136                            return findByGroupId_PrevAndNext(productEntryId, groupId,
1137                                    orderByComparator);
1138                    }
1139    
1140                    SCProductEntry scProductEntry = findByPrimaryKey(productEntryId);
1141    
1142                    Session session = null;
1143    
1144                    try {
1145                            session = openSession();
1146    
1147                            SCProductEntry[] array = new SCProductEntryImpl[3];
1148    
1149                            array[0] = filterGetByGroupId_PrevAndNext(session, scProductEntry,
1150                                            groupId, orderByComparator, true);
1151    
1152                            array[1] = scProductEntry;
1153    
1154                            array[2] = filterGetByGroupId_PrevAndNext(session, scProductEntry,
1155                                            groupId, orderByComparator, false);
1156    
1157                            return array;
1158                    }
1159                    catch (Exception e) {
1160                            throw processException(e);
1161                    }
1162                    finally {
1163                            closeSession(session);
1164                    }
1165            }
1166    
1167            protected SCProductEntry filterGetByGroupId_PrevAndNext(Session session,
1168                    SCProductEntry scProductEntry, long groupId,
1169                    OrderByComparator orderByComparator, boolean previous) {
1170                    StringBundler query = null;
1171    
1172                    if (orderByComparator != null) {
1173                            query = new StringBundler(6 +
1174                                            (orderByComparator.getOrderByFields().length * 6));
1175                    }
1176                    else {
1177                            query = new StringBundler(3);
1178                    }
1179    
1180                    if (getDB().isSupportsInlineDistinct()) {
1181                            query.append(_FILTER_SQL_SELECT_SCPRODUCTENTRY_WHERE);
1182                    }
1183                    else {
1184                            query.append(_FILTER_SQL_SELECT_SCPRODUCTENTRY_NO_INLINE_DISTINCT_WHERE_1);
1185                    }
1186    
1187                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1188    
1189                    if (!getDB().isSupportsInlineDistinct()) {
1190                            query.append(_FILTER_SQL_SELECT_SCPRODUCTENTRY_NO_INLINE_DISTINCT_WHERE_2);
1191                    }
1192    
1193                    if (orderByComparator != null) {
1194                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1195    
1196                            if (orderByConditionFields.length > 0) {
1197                                    query.append(WHERE_AND);
1198                            }
1199    
1200                            for (int i = 0; i < orderByConditionFields.length; i++) {
1201                                    if (getDB().isSupportsInlineDistinct()) {
1202                                            query.append(_ORDER_BY_ENTITY_ALIAS);
1203                                    }
1204                                    else {
1205                                            query.append(_ORDER_BY_ENTITY_TABLE);
1206                                    }
1207    
1208                                    query.append(orderByConditionFields[i]);
1209    
1210                                    if ((i + 1) < orderByConditionFields.length) {
1211                                            if (orderByComparator.isAscending() ^ previous) {
1212                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1213                                            }
1214                                            else {
1215                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1216                                            }
1217                                    }
1218                                    else {
1219                                            if (orderByComparator.isAscending() ^ previous) {
1220                                                    query.append(WHERE_GREATER_THAN);
1221                                            }
1222                                            else {
1223                                                    query.append(WHERE_LESSER_THAN);
1224                                            }
1225                                    }
1226                            }
1227    
1228                            query.append(ORDER_BY_CLAUSE);
1229    
1230                            String[] orderByFields = orderByComparator.getOrderByFields();
1231    
1232                            for (int i = 0; i < orderByFields.length; i++) {
1233                                    if (getDB().isSupportsInlineDistinct()) {
1234                                            query.append(_ORDER_BY_ENTITY_ALIAS);
1235                                    }
1236                                    else {
1237                                            query.append(_ORDER_BY_ENTITY_TABLE);
1238                                    }
1239    
1240                                    query.append(orderByFields[i]);
1241    
1242                                    if ((i + 1) < orderByFields.length) {
1243                                            if (orderByComparator.isAscending() ^ previous) {
1244                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1245                                            }
1246                                            else {
1247                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1248                                            }
1249                                    }
1250                                    else {
1251                                            if (orderByComparator.isAscending() ^ previous) {
1252                                                    query.append(ORDER_BY_ASC);
1253                                            }
1254                                            else {
1255                                                    query.append(ORDER_BY_DESC);
1256                                            }
1257                                    }
1258                            }
1259                    }
1260    
1261                    else {
1262                            if (getDB().isSupportsInlineDistinct()) {
1263                                    query.append(SCProductEntryModelImpl.ORDER_BY_JPQL);
1264                            }
1265                            else {
1266                                    query.append(SCProductEntryModelImpl.ORDER_BY_SQL);
1267                            }
1268                    }
1269    
1270                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1271                                    SCProductEntry.class.getName(),
1272                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
1273    
1274                    SQLQuery q = session.createSQLQuery(sql);
1275    
1276                    q.setFirstResult(0);
1277                    q.setMaxResults(2);
1278    
1279                    if (getDB().isSupportsInlineDistinct()) {
1280                            q.addEntity(_FILTER_ENTITY_ALIAS, SCProductEntryImpl.class);
1281                    }
1282                    else {
1283                            q.addEntity(_FILTER_ENTITY_TABLE, SCProductEntryImpl.class);
1284                    }
1285    
1286                    QueryPos qPos = QueryPos.getInstance(q);
1287    
1288                    qPos.add(groupId);
1289    
1290                    if (orderByComparator != null) {
1291                            Object[] values = orderByComparator.getOrderByConditionValues(scProductEntry);
1292    
1293                            for (Object value : values) {
1294                                    qPos.add(value);
1295                            }
1296                    }
1297    
1298                    List<SCProductEntry> list = q.list();
1299    
1300                    if (list.size() == 2) {
1301                            return list.get(1);
1302                    }
1303                    else {
1304                            return null;
1305                    }
1306            }
1307    
1308            /**
1309             * Returns all the s c product entries where companyId = &#63;.
1310             *
1311             * @param companyId the company ID
1312             * @return the matching s c product entries
1313             * @throws SystemException if a system exception occurred
1314             */
1315            public List<SCProductEntry> findByCompanyId(long companyId)
1316                    throws SystemException {
1317                    return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
1318                            null);
1319            }
1320    
1321            /**
1322             * Returns a range of all the s c product entries where companyId = &#63;.
1323             *
1324             * <p>
1325             * 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.
1326             * </p>
1327             *
1328             * @param companyId the company ID
1329             * @param start the lower bound of the range of s c product entries
1330             * @param end the upper bound of the range of s c product entries (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> findByCompanyId(long companyId, int start,
1335                    int end) throws SystemException {
1336                    return findByCompanyId(companyId, start, end, null);
1337            }
1338    
1339            /**
1340             * Returns an ordered range of all the s c product entries where companyId = &#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 companyId the company ID
1347             * @param start the lower bound of the range of s c product entries
1348             * @param end the upper bound of the range of s c product entries (not inclusive)
1349             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1350             * @return the ordered range of matching s c product entries
1351             * @throws SystemException if a system exception occurred
1352             */
1353            public List<SCProductEntry> findByCompanyId(long companyId, int start,
1354                    int end, OrderByComparator orderByComparator) throws SystemException {
1355                    FinderPath finderPath = null;
1356                    Object[] finderArgs = null;
1357    
1358                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1359                                    (orderByComparator == null)) {
1360                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID;
1361                            finderArgs = new Object[] { companyId };
1362                    }
1363                    else {
1364                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID;
1365                            finderArgs = new Object[] { companyId, start, end, orderByComparator };
1366                    }
1367    
1368                    List<SCProductEntry> list = (List<SCProductEntry>)FinderCacheUtil.getResult(finderPath,
1369                                    finderArgs, this);
1370    
1371                    if ((list != null) && !list.isEmpty()) {
1372                            for (SCProductEntry scProductEntry : list) {
1373                                    if ((companyId != scProductEntry.getCompanyId())) {
1374                                            list = null;
1375    
1376                                            break;
1377                                    }
1378                            }
1379                    }
1380    
1381                    if (list == null) {
1382                            StringBundler query = null;
1383    
1384                            if (orderByComparator != null) {
1385                                    query = new StringBundler(3 +
1386                                                    (orderByComparator.getOrderByFields().length * 3));
1387                            }
1388                            else {
1389                                    query = new StringBundler(3);
1390                            }
1391    
1392                            query.append(_SQL_SELECT_SCPRODUCTENTRY_WHERE);
1393    
1394                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1395    
1396                            if (orderByComparator != null) {
1397                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1398                                            orderByComparator);
1399                            }
1400    
1401                            else {
1402                                    query.append(SCProductEntryModelImpl.ORDER_BY_JPQL);
1403                            }
1404    
1405                            String sql = query.toString();
1406    
1407                            Session session = null;
1408    
1409                            try {
1410                                    session = openSession();
1411    
1412                                    Query q = session.createQuery(sql);
1413    
1414                                    QueryPos qPos = QueryPos.getInstance(q);
1415    
1416                                    qPos.add(companyId);
1417    
1418                                    list = (List<SCProductEntry>)QueryUtil.list(q, getDialect(),
1419                                                    start, end);
1420                            }
1421                            catch (Exception e) {
1422                                    throw processException(e);
1423                            }
1424                            finally {
1425                                    if (list == null) {
1426                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1427                                    }
1428                                    else {
1429                                            cacheResult(list);
1430    
1431                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1432                                    }
1433    
1434                                    closeSession(session);
1435                            }
1436                    }
1437    
1438                    return list;
1439            }
1440    
1441            /**
1442             * Returns the first s c product entry in the ordered set where companyId = &#63;.
1443             *
1444             * <p>
1445             * 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.
1446             * </p>
1447             *
1448             * @param companyId the company ID
1449             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1450             * @return the first matching s c product entry
1451             * @throws com.liferay.portlet.softwarecatalog.NoSuchProductEntryException if a matching s c product entry could not be found
1452             * @throws SystemException if a system exception occurred
1453             */
1454            public SCProductEntry findByCompanyId_First(long companyId,
1455                    OrderByComparator orderByComparator)
1456                    throws NoSuchProductEntryException, SystemException {
1457                    List<SCProductEntry> list = findByCompanyId(companyId, 0, 1,
1458                                    orderByComparator);
1459    
1460                    if (list.isEmpty()) {
1461                            StringBundler msg = new StringBundler(4);
1462    
1463                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1464    
1465                            msg.append("companyId=");
1466                            msg.append(companyId);
1467    
1468                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1469    
1470                            throw new NoSuchProductEntryException(msg.toString());
1471                    }
1472                    else {
1473                            return list.get(0);
1474                    }
1475            }
1476    
1477            /**
1478             * Returns the last s c product entry in the ordered set where companyId = &#63;.
1479             *
1480             * <p>
1481             * 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.
1482             * </p>
1483             *
1484             * @param companyId the company ID
1485             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1486             * @return the last matching s c product entry
1487             * @throws com.liferay.portlet.softwarecatalog.NoSuchProductEntryException if a matching s c product entry could not be found
1488             * @throws SystemException if a system exception occurred
1489             */
1490            public SCProductEntry findByCompanyId_Last(long companyId,
1491                    OrderByComparator orderByComparator)
1492                    throws NoSuchProductEntryException, SystemException {
1493                    int count = countByCompanyId(companyId);
1494    
1495                    List<SCProductEntry> list = findByCompanyId(companyId, count - 1,
1496                                    count, orderByComparator);
1497    
1498                    if (list.isEmpty()) {
1499                            StringBundler msg = new StringBundler(4);
1500    
1501                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1502    
1503                            msg.append("companyId=");
1504                            msg.append(companyId);
1505    
1506                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1507    
1508                            throw new NoSuchProductEntryException(msg.toString());
1509                    }
1510                    else {
1511                            return list.get(0);
1512                    }
1513            }
1514    
1515            /**
1516             * Returns the s c product entries before and after the current s c product entry in the ordered set where companyId = &#63;.
1517             *
1518             * <p>
1519             * 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.
1520             * </p>
1521             *
1522             * @param productEntryId the primary key of the current s c product entry
1523             * @param companyId the company ID
1524             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
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[] findByCompanyId_PrevAndNext(long productEntryId,
1530                    long companyId, 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] = getByCompanyId_PrevAndNext(session, scProductEntry,
1542                                            companyId, orderByComparator, true);
1543    
1544                            array[1] = scProductEntry;
1545    
1546                            array[2] = getByCompanyId_PrevAndNext(session, scProductEntry,
1547                                            companyId, 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 getByCompanyId_PrevAndNext(Session session,
1560                    SCProductEntry scProductEntry, long companyId,
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_COMPANYID_COMPANYID_2);
1575    
1576                    if (orderByComparator != null) {
1577                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1578    
1579                            if (orderByConditionFields.length > 0) {
1580                                    query.append(WHERE_AND);
1581                            }
1582    
1583                            for (int i = 0; i < orderByConditionFields.length; i++) {
1584                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1585                                    query.append(orderByConditionFields[i]);
1586    
1587                                    if ((i + 1) < orderByConditionFields.length) {
1588                                            if (orderByComparator.isAscending() ^ previous) {
1589                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1590                                            }
1591                                            else {
1592                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1593                                            }
1594                                    }
1595                                    else {
1596                                            if (orderByComparator.isAscending() ^ previous) {
1597                                                    query.append(WHERE_GREATER_THAN);
1598                                            }
1599                                            else {
1600                                                    query.append(WHERE_LESSER_THAN);
1601                                            }
1602                                    }
1603                            }
1604    
1605                            query.append(ORDER_BY_CLAUSE);
1606    
1607                            String[] orderByFields = orderByComparator.getOrderByFields();
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(companyId);
1646    
1647                    if (orderByComparator != null) {
1648                            Object[] values = orderByComparator.getOrderByConditionValues(scProductEntry);
1649    
1650                            for (Object value : values) {
1651                                    qPos.add(value);
1652                            }
1653                    }
1654    
1655                    List<SCProductEntry> list = q.list();
1656    
1657                    if (list.size() == 2) {
1658                            return list.get(1);
1659                    }
1660                    else {
1661                            return null;
1662                    }
1663            }
1664    
1665            /**
1666             * Returns all the s c product entries where groupId = &#63; and userId = &#63;.
1667             *
1668             * @param groupId the group ID
1669             * @param userId the user ID
1670             * @return the matching s c product entries
1671             * @throws SystemException if a system exception occurred
1672             */
1673            public List<SCProductEntry> findByG_U(long groupId, long userId)
1674                    throws SystemException {
1675                    return findByG_U(groupId, userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
1676                            null);
1677            }
1678    
1679            /**
1680             * Returns a range of all the s c product entries where groupId = &#63; and userId = &#63;.
1681             *
1682             * <p>
1683             * 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.
1684             * </p>
1685             *
1686             * @param groupId the group ID
1687             * @param userId the user ID
1688             * @param start the lower bound of the range of s c product entries
1689             * @param end the upper bound of the range of s c product entries (not inclusive)
1690             * @return the range of matching s c product entries
1691             * @throws SystemException if a system exception occurred
1692             */
1693            public List<SCProductEntry> findByG_U(long groupId, long userId, int start,
1694                    int end) throws SystemException {
1695                    return findByG_U(groupId, userId, start, end, null);
1696            }
1697    
1698            /**
1699             * Returns an ordered range of all the s c product entries where groupId = &#63; and userId = &#63;.
1700             *
1701             * <p>
1702             * 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.
1703             * </p>
1704             *
1705             * @param groupId the group ID
1706             * @param userId the user ID
1707             * @param start the lower bound of the range of s c product entries
1708             * @param end the upper bound of the range of s c product entries (not inclusive)
1709             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1710             * @return the ordered range of matching s c product entries
1711             * @throws SystemException if a system exception occurred
1712             */
1713            public List<SCProductEntry> findByG_U(long groupId, long userId, int start,
1714                    int end, OrderByComparator orderByComparator) throws SystemException {
1715                    FinderPath finderPath = null;
1716                    Object[] finderArgs = null;
1717    
1718                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1719                                    (orderByComparator == null)) {
1720                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U;
1721                            finderArgs = new Object[] { groupId, userId };
1722                    }
1723                    else {
1724                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U;
1725                            finderArgs = new Object[] {
1726                                            groupId, userId,
1727                                            
1728                                            start, end, orderByComparator
1729                                    };
1730                    }
1731    
1732                    List<SCProductEntry> list = (List<SCProductEntry>)FinderCacheUtil.getResult(finderPath,
1733                                    finderArgs, this);
1734    
1735                    if ((list != null) && !list.isEmpty()) {
1736                            for (SCProductEntry scProductEntry : list) {
1737                                    if ((groupId != scProductEntry.getGroupId()) ||
1738                                                    (userId != scProductEntry.getUserId())) {
1739                                            list = null;
1740    
1741                                            break;
1742                                    }
1743                            }
1744                    }
1745    
1746                    if (list == null) {
1747                            StringBundler query = null;
1748    
1749                            if (orderByComparator != null) {
1750                                    query = new StringBundler(4 +
1751                                                    (orderByComparator.getOrderByFields().length * 3));
1752                            }
1753                            else {
1754                                    query = new StringBundler(4);
1755                            }
1756    
1757                            query.append(_SQL_SELECT_SCPRODUCTENTRY_WHERE);
1758    
1759                            query.append(_FINDER_COLUMN_G_U_GROUPID_2);
1760    
1761                            query.append(_FINDER_COLUMN_G_U_USERID_2);
1762    
1763                            if (orderByComparator != null) {
1764                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1765                                            orderByComparator);
1766                            }
1767    
1768                            else {
1769                                    query.append(SCProductEntryModelImpl.ORDER_BY_JPQL);
1770                            }
1771    
1772                            String sql = query.toString();
1773    
1774                            Session session = null;
1775    
1776                            try {
1777                                    session = openSession();
1778    
1779                                    Query q = session.createQuery(sql);
1780    
1781                                    QueryPos qPos = QueryPos.getInstance(q);
1782    
1783                                    qPos.add(groupId);
1784    
1785                                    qPos.add(userId);
1786    
1787                                    list = (List<SCProductEntry>)QueryUtil.list(q, getDialect(),
1788                                                    start, end);
1789                            }
1790                            catch (Exception e) {
1791                                    throw processException(e);
1792                            }
1793                            finally {
1794                                    if (list == null) {
1795                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1796                                    }
1797                                    else {
1798                                            cacheResult(list);
1799    
1800                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1801                                    }
1802    
1803                                    closeSession(session);
1804                            }
1805                    }
1806    
1807                    return list;
1808            }
1809    
1810            /**
1811             * Returns the first s c product entry in the ordered set where groupId = &#63; and userId = &#63;.
1812             *
1813             * <p>
1814             * 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.
1815             * </p>
1816             *
1817             * @param groupId the group ID
1818             * @param userId the user ID
1819             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1820             * @return the first matching s c product entry
1821             * @throws com.liferay.portlet.softwarecatalog.NoSuchProductEntryException if a matching s c product entry could not be found
1822             * @throws SystemException if a system exception occurred
1823             */
1824            public SCProductEntry findByG_U_First(long groupId, long userId,
1825                    OrderByComparator orderByComparator)
1826                    throws NoSuchProductEntryException, SystemException {
1827                    List<SCProductEntry> list = findByG_U(groupId, userId, 0, 1,
1828                                    orderByComparator);
1829    
1830                    if (list.isEmpty()) {
1831                            StringBundler msg = new StringBundler(6);
1832    
1833                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1834    
1835                            msg.append("groupId=");
1836                            msg.append(groupId);
1837    
1838                            msg.append(", userId=");
1839                            msg.append(userId);
1840    
1841                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1842    
1843                            throw new NoSuchProductEntryException(msg.toString());
1844                    }
1845                    else {
1846                            return list.get(0);
1847                    }
1848            }
1849    
1850            /**
1851             * Returns the last s c product entry in the ordered set where groupId = &#63; and userId = &#63;.
1852             *
1853             * <p>
1854             * 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.
1855             * </p>
1856             *
1857             * @param groupId the group ID
1858             * @param userId the user ID
1859             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1860             * @return the last matching s c product entry
1861             * @throws com.liferay.portlet.softwarecatalog.NoSuchProductEntryException if a matching s c product entry could not be found
1862             * @throws SystemException if a system exception occurred
1863             */
1864            public SCProductEntry findByG_U_Last(long groupId, long userId,
1865                    OrderByComparator orderByComparator)
1866                    throws NoSuchProductEntryException, SystemException {
1867                    int count = countByG_U(groupId, userId);
1868    
1869                    List<SCProductEntry> list = findByG_U(groupId, userId, count - 1,
1870                                    count, orderByComparator);
1871    
1872                    if (list.isEmpty()) {
1873                            StringBundler msg = new StringBundler(6);
1874    
1875                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1876    
1877                            msg.append("groupId=");
1878                            msg.append(groupId);
1879    
1880                            msg.append(", userId=");
1881                            msg.append(userId);
1882    
1883                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1884    
1885                            throw new NoSuchProductEntryException(msg.toString());
1886                    }
1887                    else {
1888                            return list.get(0);
1889                    }
1890            }
1891    
1892            /**
1893             * Returns the s c product entries before and after the current s c product entry in the ordered set where groupId = &#63; and userId = &#63;.
1894             *
1895             * <p>
1896             * 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.
1897             * </p>
1898             *
1899             * @param productEntryId the primary key of the current s c product entry
1900             * @param groupId the group ID
1901             * @param userId the user ID
1902             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1903             * @return the previous, current, and next s c product entry
1904             * @throws com.liferay.portlet.softwarecatalog.NoSuchProductEntryException if a s c product entry with the primary key could not be found
1905             * @throws SystemException if a system exception occurred
1906             */
1907            public SCProductEntry[] findByG_U_PrevAndNext(long productEntryId,
1908                    long groupId, long userId, OrderByComparator orderByComparator)
1909                    throws NoSuchProductEntryException, SystemException {
1910                    SCProductEntry scProductEntry = findByPrimaryKey(productEntryId);
1911    
1912                    Session session = null;
1913    
1914                    try {
1915                            session = openSession();
1916    
1917                            SCProductEntry[] array = new SCProductEntryImpl[3];
1918    
1919                            array[0] = getByG_U_PrevAndNext(session, scProductEntry, groupId,
1920                                            userId, orderByComparator, true);
1921    
1922                            array[1] = scProductEntry;
1923    
1924                            array[2] = getByG_U_PrevAndNext(session, scProductEntry, groupId,
1925                                            userId, orderByComparator, false);
1926    
1927                            return array;
1928                    }
1929                    catch (Exception e) {
1930                            throw processException(e);
1931                    }
1932                    finally {
1933                            closeSession(session);
1934                    }
1935            }
1936    
1937            protected SCProductEntry getByG_U_PrevAndNext(Session session,
1938                    SCProductEntry scProductEntry, long groupId, long userId,
1939                    OrderByComparator orderByComparator, boolean previous) {
1940                    StringBundler query = null;
1941    
1942                    if (orderByComparator != null) {
1943                            query = new StringBundler(6 +
1944                                            (orderByComparator.getOrderByFields().length * 6));
1945                    }
1946                    else {
1947                            query = new StringBundler(3);
1948                    }
1949    
1950                    query.append(_SQL_SELECT_SCPRODUCTENTRY_WHERE);
1951    
1952                    query.append(_FINDER_COLUMN_G_U_GROUPID_2);
1953    
1954                    query.append(_FINDER_COLUMN_G_U_USERID_2);
1955    
1956                    if (orderByComparator != null) {
1957                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1958    
1959                            if (orderByConditionFields.length > 0) {
1960                                    query.append(WHERE_AND);
1961                            }
1962    
1963                            for (int i = 0; i < orderByConditionFields.length; i++) {
1964                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1965                                    query.append(orderByConditionFields[i]);
1966    
1967                                    if ((i + 1) < orderByConditionFields.length) {
1968                                            if (orderByComparator.isAscending() ^ previous) {
1969                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1970                                            }
1971                                            else {
1972                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1973                                            }
1974                                    }
1975                                    else {
1976                                            if (orderByComparator.isAscending() ^ previous) {
1977                                                    query.append(WHERE_GREATER_THAN);
1978                                            }
1979                                            else {
1980                                                    query.append(WHERE_LESSER_THAN);
1981                                            }
1982                                    }
1983                            }
1984    
1985                            query.append(ORDER_BY_CLAUSE);
1986    
1987                            String[] orderByFields = orderByComparator.getOrderByFields();
1988    
1989                            for (int i = 0; i < orderByFields.length; i++) {
1990                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1991                                    query.append(orderByFields[i]);
1992    
1993                                    if ((i + 1) < orderByFields.length) {
1994                                            if (orderByComparator.isAscending() ^ previous) {
1995                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1996                                            }
1997                                            else {
1998                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1999                                            }
2000                                    }
2001                                    else {
2002                                            if (orderByComparator.isAscending() ^ previous) {
2003                                                    query.append(ORDER_BY_ASC);
2004                                            }
2005                                            else {
2006                                                    query.append(ORDER_BY_DESC);
2007                                            }
2008                                    }
2009                            }
2010                    }
2011    
2012                    else {
2013                            query.append(SCProductEntryModelImpl.ORDER_BY_JPQL);
2014                    }
2015    
2016                    String sql = query.toString();
2017    
2018                    Query q = session.createQuery(sql);
2019    
2020                    q.setFirstResult(0);
2021                    q.setMaxResults(2);
2022    
2023                    QueryPos qPos = QueryPos.getInstance(q);
2024    
2025                    qPos.add(groupId);
2026    
2027                    qPos.add(userId);
2028    
2029                    if (orderByComparator != null) {
2030                            Object[] values = orderByComparator.getOrderByConditionValues(scProductEntry);
2031    
2032                            for (Object value : values) {
2033                                    qPos.add(value);
2034                            }
2035                    }
2036    
2037                    List<SCProductEntry> list = q.list();
2038    
2039                    if (list.size() == 2) {
2040                            return list.get(1);
2041                    }
2042                    else {
2043                            return null;
2044                    }
2045            }
2046    
2047            /**
2048             * Returns all the s c product entries that the user has permission to view where groupId = &#63; and userId = &#63;.
2049             *
2050             * @param groupId the group ID
2051             * @param userId the user ID
2052             * @return the matching s c product entries that the user has permission to view
2053             * @throws SystemException if a system exception occurred
2054             */
2055            public List<SCProductEntry> filterFindByG_U(long groupId, long userId)
2056                    throws SystemException {
2057                    return filterFindByG_U(groupId, userId, QueryUtil.ALL_POS,
2058                            QueryUtil.ALL_POS, null);
2059            }
2060    
2061            /**
2062             * Returns a range of all the s c product entries that the user has permission to view where groupId = &#63; and userId = &#63;.
2063             *
2064             * <p>
2065             * 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.
2066             * </p>
2067             *
2068             * @param groupId the group ID
2069             * @param userId the user ID
2070             * @param start the lower bound of the range of s c product entries
2071             * @param end the upper bound of the range of s c product entries (not inclusive)
2072             * @return the range of matching s c product entries that the user has permission to view
2073             * @throws SystemException if a system exception occurred
2074             */
2075            public List<SCProductEntry> filterFindByG_U(long groupId, long userId,
2076                    int start, int end) throws SystemException {
2077                    return filterFindByG_U(groupId, userId, start, end, null);
2078            }
2079    
2080            /**
2081             * Returns an ordered range of all the s c product entries that the user has permissions to view where groupId = &#63; and userId = &#63;.
2082             *
2083             * <p>
2084             * 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.
2085             * </p>
2086             *
2087             * @param groupId the group ID
2088             * @param userId the user ID
2089             * @param start the lower bound of the range of s c product entries
2090             * @param end the upper bound of the range of s c product entries (not inclusive)
2091             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2092             * @return the ordered range of matching s c product entries that the user has permission to view
2093             * @throws SystemException if a system exception occurred
2094             */
2095            public List<SCProductEntry> filterFindByG_U(long groupId, long userId,
2096                    int start, int end, OrderByComparator orderByComparator)
2097                    throws SystemException {
2098                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2099                            return findByG_U(groupId, userId, start, end, orderByComparator);
2100                    }
2101    
2102                    StringBundler query = null;
2103    
2104                    if (orderByComparator != null) {
2105                            query = new StringBundler(4 +
2106                                            (orderByComparator.getOrderByFields().length * 3));
2107                    }
2108                    else {
2109                            query = new StringBundler(4);
2110                    }
2111    
2112                    if (getDB().isSupportsInlineDistinct()) {
2113                            query.append(_FILTER_SQL_SELECT_SCPRODUCTENTRY_WHERE);
2114                    }
2115                    else {
2116                            query.append(_FILTER_SQL_SELECT_SCPRODUCTENTRY_NO_INLINE_DISTINCT_WHERE_1);
2117                    }
2118    
2119                    query.append(_FINDER_COLUMN_G_U_GROUPID_2);
2120    
2121                    query.append(_FINDER_COLUMN_G_U_USERID_2);
2122    
2123                    if (!getDB().isSupportsInlineDistinct()) {
2124                            query.append(_FILTER_SQL_SELECT_SCPRODUCTENTRY_NO_INLINE_DISTINCT_WHERE_2);
2125                    }
2126    
2127                    if (orderByComparator != null) {
2128                            if (getDB().isSupportsInlineDistinct()) {
2129                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2130                                            orderByComparator);
2131                            }
2132                            else {
2133                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
2134                                            orderByComparator);
2135                            }
2136                    }
2137    
2138                    else {
2139                            if (getDB().isSupportsInlineDistinct()) {
2140                                    query.append(SCProductEntryModelImpl.ORDER_BY_JPQL);
2141                            }
2142                            else {
2143                                    query.append(SCProductEntryModelImpl.ORDER_BY_SQL);
2144                            }
2145                    }
2146    
2147                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2148                                    SCProductEntry.class.getName(),
2149                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2150    
2151                    Session session = null;
2152    
2153                    try {
2154                            session = openSession();
2155    
2156                            SQLQuery q = session.createSQLQuery(sql);
2157    
2158                            if (getDB().isSupportsInlineDistinct()) {
2159                                    q.addEntity(_FILTER_ENTITY_ALIAS, SCProductEntryImpl.class);
2160                            }
2161                            else {
2162                                    q.addEntity(_FILTER_ENTITY_TABLE, SCProductEntryImpl.class);
2163                            }
2164    
2165                            QueryPos qPos = QueryPos.getInstance(q);
2166    
2167                            qPos.add(groupId);
2168    
2169                            qPos.add(userId);
2170    
2171                            return (List<SCProductEntry>)QueryUtil.list(q, getDialect(), start,
2172                                    end);
2173                    }
2174                    catch (Exception e) {
2175                            throw processException(e);
2176                    }
2177                    finally {
2178                            closeSession(session);
2179                    }
2180            }
2181    
2182            /**
2183             * Returns the s c product entries before and after the current s c product entry in the ordered set of s c product entries that the user has permission to view where groupId = &#63; and userId = &#63;.
2184             *
2185             * @param productEntryId the primary key of the current s c product entry
2186             * @param groupId the group ID
2187             * @param userId the user ID
2188             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2189             * @return the previous, current, and next s c product entry
2190             * @throws com.liferay.portlet.softwarecatalog.NoSuchProductEntryException if a s c product entry with the primary key could not be found
2191             * @throws SystemException if a system exception occurred
2192             */
2193            public SCProductEntry[] filterFindByG_U_PrevAndNext(long productEntryId,
2194                    long groupId, long userId, OrderByComparator orderByComparator)
2195                    throws NoSuchProductEntryException, SystemException {
2196                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2197                            return findByG_U_PrevAndNext(productEntryId, groupId, userId,
2198                                    orderByComparator);
2199                    }
2200    
2201                    SCProductEntry scProductEntry = findByPrimaryKey(productEntryId);
2202    
2203                    Session session = null;
2204    
2205                    try {
2206                            session = openSession();
2207    
2208                            SCProductEntry[] array = new SCProductEntryImpl[3];
2209    
2210                            array[0] = filterGetByG_U_PrevAndNext(session, scProductEntry,
2211                                            groupId, userId, orderByComparator, true);
2212    
2213                            array[1] = scProductEntry;
2214    
2215                            array[2] = filterGetByG_U_PrevAndNext(session, scProductEntry,
2216                                            groupId, userId, orderByComparator, false);
2217    
2218                            return array;
2219                    }
2220                    catch (Exception e) {
2221                            throw processException(e);
2222                    }
2223                    finally {
2224                            closeSession(session);
2225                    }
2226            }
2227    
2228            protected SCProductEntry filterGetByG_U_PrevAndNext(Session session,
2229                    SCProductEntry scProductEntry, long groupId, long userId,
2230                    OrderByComparator orderByComparator, boolean previous) {
2231                    StringBundler query = null;
2232    
2233                    if (orderByComparator != null) {
2234                            query = new StringBundler(6 +
2235                                            (orderByComparator.getOrderByFields().length * 6));
2236                    }
2237                    else {
2238                            query = new StringBundler(3);
2239                    }
2240    
2241                    if (getDB().isSupportsInlineDistinct()) {
2242                            query.append(_FILTER_SQL_SELECT_SCPRODUCTENTRY_WHERE);
2243                    }
2244                    else {
2245                            query.append(_FILTER_SQL_SELECT_SCPRODUCTENTRY_NO_INLINE_DISTINCT_WHERE_1);
2246                    }
2247    
2248                    query.append(_FINDER_COLUMN_G_U_GROUPID_2);
2249    
2250                    query.append(_FINDER_COLUMN_G_U_USERID_2);
2251    
2252                    if (!getDB().isSupportsInlineDistinct()) {
2253                            query.append(_FILTER_SQL_SELECT_SCPRODUCTENTRY_NO_INLINE_DISTINCT_WHERE_2);
2254                    }
2255    
2256                    if (orderByComparator != null) {
2257                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2258    
2259                            if (orderByConditionFields.length > 0) {
2260                                    query.append(WHERE_AND);
2261                            }
2262    
2263                            for (int i = 0; i < orderByConditionFields.length; i++) {
2264                                    if (getDB().isSupportsInlineDistinct()) {
2265                                            query.append(_ORDER_BY_ENTITY_ALIAS);
2266                                    }
2267                                    else {
2268                                            query.append(_ORDER_BY_ENTITY_TABLE);
2269                                    }
2270    
2271                                    query.append(orderByConditionFields[i]);
2272    
2273                                    if ((i + 1) < orderByConditionFields.length) {
2274                                            if (orderByComparator.isAscending() ^ previous) {
2275                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2276                                            }
2277                                            else {
2278                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2279                                            }
2280                                    }
2281                                    else {
2282                                            if (orderByComparator.isAscending() ^ previous) {
2283                                                    query.append(WHERE_GREATER_THAN);
2284                                            }
2285                                            else {
2286                                                    query.append(WHERE_LESSER_THAN);
2287                                            }
2288                                    }
2289                            }
2290    
2291                            query.append(ORDER_BY_CLAUSE);
2292    
2293                            String[] orderByFields = orderByComparator.getOrderByFields();
2294    
2295                            for (int i = 0; i < orderByFields.length; i++) {
2296                                    if (getDB().isSupportsInlineDistinct()) {
2297                                            query.append(_ORDER_BY_ENTITY_ALIAS);
2298                                    }
2299                                    else {
2300                                            query.append(_ORDER_BY_ENTITY_TABLE);
2301                                    }
2302    
2303                                    query.append(orderByFields[i]);
2304    
2305                                    if ((i + 1) < orderByFields.length) {
2306                                            if (orderByComparator.isAscending() ^ previous) {
2307                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2308                                            }
2309                                            else {
2310                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2311                                            }
2312                                    }
2313                                    else {
2314                                            if (orderByComparator.isAscending() ^ previous) {
2315                                                    query.append(ORDER_BY_ASC);
2316                                            }
2317                                            else {
2318                                                    query.append(ORDER_BY_DESC);
2319                                            }
2320                                    }
2321                            }
2322                    }
2323    
2324                    else {
2325                            if (getDB().isSupportsInlineDistinct()) {
2326                                    query.append(SCProductEntryModelImpl.ORDER_BY_JPQL);
2327                            }
2328                            else {
2329                                    query.append(SCProductEntryModelImpl.ORDER_BY_SQL);
2330                            }
2331                    }
2332    
2333                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2334                                    SCProductEntry.class.getName(),
2335                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2336    
2337                    SQLQuery q = session.createSQLQuery(sql);
2338    
2339                    q.setFirstResult(0);
2340                    q.setMaxResults(2);
2341    
2342                    if (getDB().isSupportsInlineDistinct()) {
2343                            q.addEntity(_FILTER_ENTITY_ALIAS, SCProductEntryImpl.class);
2344                    }
2345                    else {
2346                            q.addEntity(_FILTER_ENTITY_TABLE, SCProductEntryImpl.class);
2347                    }
2348    
2349                    QueryPos qPos = QueryPos.getInstance(q);
2350    
2351                    qPos.add(groupId);
2352    
2353                    qPos.add(userId);
2354    
2355                    if (orderByComparator != null) {
2356                            Object[] values = orderByComparator.getOrderByConditionValues(scProductEntry);
2357    
2358                            for (Object value : values) {
2359                                    qPos.add(value);
2360                            }
2361                    }
2362    
2363                    List<SCProductEntry> list = q.list();
2364    
2365                    if (list.size() == 2) {
2366                            return list.get(1);
2367                    }
2368                    else {
2369                            return null;
2370                    }
2371            }
2372    
2373            /**
2374             * Returns 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.
2375             *
2376             * @param repoGroupId the repo group ID
2377             * @param repoArtifactId the repo artifact ID
2378             * @return the matching s c product entry
2379             * @throws com.liferay.portlet.softwarecatalog.NoSuchProductEntryException if a matching s c product entry could not be found
2380             * @throws SystemException if a system exception occurred
2381             */
2382            public SCProductEntry findByRG_RA(String repoGroupId, String repoArtifactId)
2383                    throws NoSuchProductEntryException, SystemException {
2384                    SCProductEntry scProductEntry = fetchByRG_RA(repoGroupId, repoArtifactId);
2385    
2386                    if (scProductEntry == null) {
2387                            StringBundler msg = new StringBundler(6);
2388    
2389                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2390    
2391                            msg.append("repoGroupId=");
2392                            msg.append(repoGroupId);
2393    
2394                            msg.append(", repoArtifactId=");
2395                            msg.append(repoArtifactId);
2396    
2397                            msg.append(StringPool.CLOSE_CURLY_BRACE);
2398    
2399                            if (_log.isWarnEnabled()) {
2400                                    _log.warn(msg.toString());
2401                            }
2402    
2403                            throw new NoSuchProductEntryException(msg.toString());
2404                    }
2405    
2406                    return scProductEntry;
2407            }
2408    
2409            /**
2410             * Returns 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.
2411             *
2412             * @param repoGroupId the repo group ID
2413             * @param repoArtifactId the repo artifact ID
2414             * @return the matching s c product entry, or <code>null</code> if a matching s c product entry could not be found
2415             * @throws SystemException if a system exception occurred
2416             */
2417            public SCProductEntry fetchByRG_RA(String repoGroupId, String repoArtifactId)
2418                    throws SystemException {
2419                    return fetchByRG_RA(repoGroupId, repoArtifactId, true);
2420            }
2421    
2422            /**
2423             * Returns 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.
2424             *
2425             * @param repoGroupId the repo group ID
2426             * @param repoArtifactId the repo artifact ID
2427             * @param retrieveFromCache whether to use the finder cache
2428             * @return the matching s c product entry, or <code>null</code> if a matching s c product entry could not be found
2429             * @throws SystemException if a system exception occurred
2430             */
2431            public SCProductEntry fetchByRG_RA(String repoGroupId,
2432                    String repoArtifactId, boolean retrieveFromCache)
2433                    throws SystemException {
2434                    Object[] finderArgs = new Object[] { repoGroupId, repoArtifactId };
2435    
2436                    Object result = null;
2437    
2438                    if (retrieveFromCache) {
2439                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_RG_RA,
2440                                            finderArgs, this);
2441                    }
2442    
2443                    if (result instanceof SCProductEntry) {
2444                            SCProductEntry scProductEntry = (SCProductEntry)result;
2445    
2446                            if (!Validator.equals(repoGroupId, scProductEntry.getRepoGroupId()) ||
2447                                            !Validator.equals(repoArtifactId,
2448                                                    scProductEntry.getRepoArtifactId())) {
2449                                    result = null;
2450                            }
2451                    }
2452    
2453                    if (result == null) {
2454                            StringBundler query = new StringBundler(4);
2455    
2456                            query.append(_SQL_SELECT_SCPRODUCTENTRY_WHERE);
2457    
2458                            if (repoGroupId == null) {
2459                                    query.append(_FINDER_COLUMN_RG_RA_REPOGROUPID_1);
2460                            }
2461                            else {
2462                                    if (repoGroupId.equals(StringPool.BLANK)) {
2463                                            query.append(_FINDER_COLUMN_RG_RA_REPOGROUPID_3);
2464                                    }
2465                                    else {
2466                                            query.append(_FINDER_COLUMN_RG_RA_REPOGROUPID_2);
2467                                    }
2468                            }
2469    
2470                            if (repoArtifactId == null) {
2471                                    query.append(_FINDER_COLUMN_RG_RA_REPOARTIFACTID_1);
2472                            }
2473                            else {
2474                                    if (repoArtifactId.equals(StringPool.BLANK)) {
2475                                            query.append(_FINDER_COLUMN_RG_RA_REPOARTIFACTID_3);
2476                                    }
2477                                    else {
2478                                            query.append(_FINDER_COLUMN_RG_RA_REPOARTIFACTID_2);
2479                                    }
2480                            }
2481    
2482                            query.append(SCProductEntryModelImpl.ORDER_BY_JPQL);
2483    
2484                            String sql = query.toString();
2485    
2486                            Session session = null;
2487    
2488                            try {
2489                                    session = openSession();
2490    
2491                                    Query q = session.createQuery(sql);
2492    
2493                                    QueryPos qPos = QueryPos.getInstance(q);
2494    
2495                                    if (repoGroupId != null) {
2496                                            qPos.add(repoGroupId);
2497                                    }
2498    
2499                                    if (repoArtifactId != null) {
2500                                            qPos.add(repoArtifactId);
2501                                    }
2502    
2503                                    List<SCProductEntry> list = q.list();
2504    
2505                                    result = list;
2506    
2507                                    SCProductEntry scProductEntry = null;
2508    
2509                                    if (list.isEmpty()) {
2510                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_RG_RA,
2511                                                    finderArgs, list);
2512                                    }
2513                                    else {
2514                                            scProductEntry = list.get(0);
2515    
2516                                            cacheResult(scProductEntry);
2517    
2518                                            if ((scProductEntry.getRepoGroupId() == null) ||
2519                                                            !scProductEntry.getRepoGroupId().equals(repoGroupId) ||
2520                                                            (scProductEntry.getRepoArtifactId() == null) ||
2521                                                            !scProductEntry.getRepoArtifactId()
2522                                                                                               .equals(repoArtifactId)) {
2523                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_RG_RA,
2524                                                            finderArgs, scProductEntry);
2525                                            }
2526                                    }
2527    
2528                                    return scProductEntry;
2529                            }
2530                            catch (Exception e) {
2531                                    throw processException(e);
2532                            }
2533                            finally {
2534                                    if (result == null) {
2535                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_RG_RA,
2536                                                    finderArgs);
2537                                    }
2538    
2539                                    closeSession(session);
2540                            }
2541                    }
2542                    else {
2543                            if (result instanceof List<?>) {
2544                                    return null;
2545                            }
2546                            else {
2547                                    return (SCProductEntry)result;
2548                            }
2549                    }
2550            }
2551    
2552            /**
2553             * Returns all the s c product entries.
2554             *
2555             * @return the s c product entries
2556             * @throws SystemException if a system exception occurred
2557             */
2558            public List<SCProductEntry> findAll() throws SystemException {
2559                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2560            }
2561    
2562            /**
2563             * Returns a range of all the s c product entries.
2564             *
2565             * <p>
2566             * 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.
2567             * </p>
2568             *
2569             * @param start the lower bound of the range of s c product entries
2570             * @param end the upper bound of the range of s c product entries (not inclusive)
2571             * @return the range of s c product entries
2572             * @throws SystemException if a system exception occurred
2573             */
2574            public List<SCProductEntry> findAll(int start, int end)
2575                    throws SystemException {
2576                    return findAll(start, end, null);
2577            }
2578    
2579            /**
2580             * Returns an ordered range of all the s c product entries.
2581             *
2582             * <p>
2583             * 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.
2584             * </p>
2585             *
2586             * @param start the lower bound of the range of s c product entries
2587             * @param end the upper bound of the range of s c product entries (not inclusive)
2588             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2589             * @return the ordered range of s c product entries
2590             * @throws SystemException if a system exception occurred
2591             */
2592            public List<SCProductEntry> findAll(int start, int end,
2593                    OrderByComparator orderByComparator) throws SystemException {
2594                    FinderPath finderPath = null;
2595                    Object[] finderArgs = new Object[] { start, end, orderByComparator };
2596    
2597                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2598                                    (orderByComparator == null)) {
2599                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
2600                            finderArgs = FINDER_ARGS_EMPTY;
2601                    }
2602                    else {
2603                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
2604                            finderArgs = new Object[] { start, end, orderByComparator };
2605                    }
2606    
2607                    List<SCProductEntry> list = (List<SCProductEntry>)FinderCacheUtil.getResult(finderPath,
2608                                    finderArgs, this);
2609    
2610                    if (list == null) {
2611                            StringBundler query = null;
2612                            String sql = null;
2613    
2614                            if (orderByComparator != null) {
2615                                    query = new StringBundler(2 +
2616                                                    (orderByComparator.getOrderByFields().length * 3));
2617    
2618                                    query.append(_SQL_SELECT_SCPRODUCTENTRY);
2619    
2620                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2621                                            orderByComparator);
2622    
2623                                    sql = query.toString();
2624                            }
2625                            else {
2626                                    sql = _SQL_SELECT_SCPRODUCTENTRY.concat(SCProductEntryModelImpl.ORDER_BY_JPQL);
2627                            }
2628    
2629                            Session session = null;
2630    
2631                            try {
2632                                    session = openSession();
2633    
2634                                    Query q = session.createQuery(sql);
2635    
2636                                    if (orderByComparator == null) {
2637                                            list = (List<SCProductEntry>)QueryUtil.list(q,
2638                                                            getDialect(), start, end, false);
2639    
2640                                            Collections.sort(list);
2641                                    }
2642                                    else {
2643                                            list = (List<SCProductEntry>)QueryUtil.list(q,
2644                                                            getDialect(), start, end);
2645                                    }
2646                            }
2647                            catch (Exception e) {
2648                                    throw processException(e);
2649                            }
2650                            finally {
2651                                    if (list == null) {
2652                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
2653                                    }
2654                                    else {
2655                                            cacheResult(list);
2656    
2657                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
2658                                    }
2659    
2660                                    closeSession(session);
2661                            }
2662                    }
2663    
2664                    return list;
2665            }
2666    
2667            /**
2668             * Removes all the s c product entries where groupId = &#63; from the database.
2669             *
2670             * @param groupId the group ID
2671             * @throws SystemException if a system exception occurred
2672             */
2673            public void removeByGroupId(long groupId) throws SystemException {
2674                    for (SCProductEntry scProductEntry : findByGroupId(groupId)) {
2675                            remove(scProductEntry);
2676                    }
2677            }
2678    
2679            /**
2680             * Removes all the s c product entries where companyId = &#63; from the database.
2681             *
2682             * @param companyId the company ID
2683             * @throws SystemException if a system exception occurred
2684             */
2685            public void removeByCompanyId(long companyId) throws SystemException {
2686                    for (SCProductEntry scProductEntry : findByCompanyId(companyId)) {
2687                            remove(scProductEntry);
2688                    }
2689            }
2690    
2691            /**
2692             * Removes all the s c product entries where groupId = &#63; and userId = &#63; from the database.
2693             *
2694             * @param groupId the group ID
2695             * @param userId the user ID
2696             * @throws SystemException if a system exception occurred
2697             */
2698            public void removeByG_U(long groupId, long userId)
2699                    throws SystemException {
2700                    for (SCProductEntry scProductEntry : findByG_U(groupId, userId)) {
2701                            remove(scProductEntry);
2702                    }
2703            }
2704    
2705            /**
2706             * Removes the s c product entry where repoGroupId = &#63; and repoArtifactId = &#63; from the database.
2707             *
2708             * @param repoGroupId the repo group ID
2709             * @param repoArtifactId the repo artifact ID
2710             * @throws SystemException if a system exception occurred
2711             */
2712            public void removeByRG_RA(String repoGroupId, String repoArtifactId)
2713                    throws NoSuchProductEntryException, SystemException {
2714                    SCProductEntry scProductEntry = findByRG_RA(repoGroupId, repoArtifactId);
2715    
2716                    remove(scProductEntry);
2717            }
2718    
2719            /**
2720             * Removes all the s c product entries from the database.
2721             *
2722             * @throws SystemException if a system exception occurred
2723             */
2724            public void removeAll() throws SystemException {
2725                    for (SCProductEntry scProductEntry : findAll()) {
2726                            remove(scProductEntry);
2727                    }
2728            }
2729    
2730            /**
2731             * Returns the number of s c product entries where groupId = &#63;.
2732             *
2733             * @param groupId the group ID
2734             * @return the number of matching s c product entries
2735             * @throws SystemException if a system exception occurred
2736             */
2737            public int countByGroupId(long groupId) throws SystemException {
2738                    Object[] finderArgs = new Object[] { groupId };
2739    
2740                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
2741                                    finderArgs, this);
2742    
2743                    if (count == null) {
2744                            StringBundler query = new StringBundler(2);
2745    
2746                            query.append(_SQL_COUNT_SCPRODUCTENTRY_WHERE);
2747    
2748                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2749    
2750                            String sql = query.toString();
2751    
2752                            Session session = null;
2753    
2754                            try {
2755                                    session = openSession();
2756    
2757                                    Query q = session.createQuery(sql);
2758    
2759                                    QueryPos qPos = QueryPos.getInstance(q);
2760    
2761                                    qPos.add(groupId);
2762    
2763                                    count = (Long)q.uniqueResult();
2764                            }
2765                            catch (Exception e) {
2766                                    throw processException(e);
2767                            }
2768                            finally {
2769                                    if (count == null) {
2770                                            count = Long.valueOf(0);
2771                                    }
2772    
2773                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
2774                                            finderArgs, count);
2775    
2776                                    closeSession(session);
2777                            }
2778                    }
2779    
2780                    return count.intValue();
2781            }
2782    
2783            /**
2784             * Returns the number of s c product entries that the user has permission to view where groupId = &#63;.
2785             *
2786             * @param groupId the group ID
2787             * @return the number of matching s c product entries that the user has permission to view
2788             * @throws SystemException if a system exception occurred
2789             */
2790            public int filterCountByGroupId(long groupId) throws SystemException {
2791                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2792                            return countByGroupId(groupId);
2793                    }
2794    
2795                    StringBundler query = new StringBundler(2);
2796    
2797                    query.append(_FILTER_SQL_COUNT_SCPRODUCTENTRY_WHERE);
2798    
2799                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2800    
2801                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2802                                    SCProductEntry.class.getName(),
2803                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2804    
2805                    Session session = null;
2806    
2807                    try {
2808                            session = openSession();
2809    
2810                            SQLQuery q = session.createSQLQuery(sql);
2811    
2812                            q.addScalar(COUNT_COLUMN_NAME,
2813                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
2814    
2815                            QueryPos qPos = QueryPos.getInstance(q);
2816    
2817                            qPos.add(groupId);
2818    
2819                            Long count = (Long)q.uniqueResult();
2820    
2821                            return count.intValue();
2822                    }
2823                    catch (Exception e) {
2824                            throw processException(e);
2825                    }
2826                    finally {
2827                            closeSession(session);
2828                    }
2829            }
2830    
2831            /**
2832             * Returns the number of s c product entries where companyId = &#63;.
2833             *
2834             * @param companyId the company ID
2835             * @return the number of matching s c product entries
2836             * @throws SystemException if a system exception occurred
2837             */
2838            public int countByCompanyId(long companyId) throws SystemException {
2839                    Object[] finderArgs = new Object[] { companyId };
2840    
2841                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
2842                                    finderArgs, this);
2843    
2844                    if (count == null) {
2845                            StringBundler query = new StringBundler(2);
2846    
2847                            query.append(_SQL_COUNT_SCPRODUCTENTRY_WHERE);
2848    
2849                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2850    
2851                            String sql = query.toString();
2852    
2853                            Session session = null;
2854    
2855                            try {
2856                                    session = openSession();
2857    
2858                                    Query q = session.createQuery(sql);
2859    
2860                                    QueryPos qPos = QueryPos.getInstance(q);
2861    
2862                                    qPos.add(companyId);
2863    
2864                                    count = (Long)q.uniqueResult();
2865                            }
2866                            catch (Exception e) {
2867                                    throw processException(e);
2868                            }
2869                            finally {
2870                                    if (count == null) {
2871                                            count = Long.valueOf(0);
2872                                    }
2873    
2874                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
2875                                            finderArgs, count);
2876    
2877                                    closeSession(session);
2878                            }
2879                    }
2880    
2881                    return count.intValue();
2882            }
2883    
2884            /**
2885             * Returns the number of s c product entries where groupId = &#63; and userId = &#63;.
2886             *
2887             * @param groupId the group ID
2888             * @param userId the user ID
2889             * @return the number of matching s c product entries
2890             * @throws SystemException if a system exception occurred
2891             */
2892            public int countByG_U(long groupId, long userId) throws SystemException {
2893                    Object[] finderArgs = new Object[] { groupId, userId };
2894    
2895                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_U,
2896                                    finderArgs, this);
2897    
2898                    if (count == null) {
2899                            StringBundler query = new StringBundler(3);
2900    
2901                            query.append(_SQL_COUNT_SCPRODUCTENTRY_WHERE);
2902    
2903                            query.append(_FINDER_COLUMN_G_U_GROUPID_2);
2904    
2905                            query.append(_FINDER_COLUMN_G_U_USERID_2);
2906    
2907                            String sql = query.toString();
2908    
2909                            Session session = null;
2910    
2911                            try {
2912                                    session = openSession();
2913    
2914                                    Query q = session.createQuery(sql);
2915    
2916                                    QueryPos qPos = QueryPos.getInstance(q);
2917    
2918                                    qPos.add(groupId);
2919    
2920                                    qPos.add(userId);
2921    
2922                                    count = (Long)q.uniqueResult();
2923                            }
2924                            catch (Exception e) {
2925                                    throw processException(e);
2926                            }
2927                            finally {
2928                                    if (count == null) {
2929                                            count = Long.valueOf(0);
2930                                    }
2931    
2932                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_U, finderArgs,
2933                                            count);
2934    
2935                                    closeSession(session);
2936                            }
2937                    }
2938    
2939                    return count.intValue();
2940            }
2941    
2942            /**
2943             * Returns the number of s c product entries that the user has permission to view where groupId = &#63; and userId = &#63;.
2944             *
2945             * @param groupId the group ID
2946             * @param userId the user ID
2947             * @return the number of matching s c product entries that the user has permission to view
2948             * @throws SystemException if a system exception occurred
2949             */
2950            public int filterCountByG_U(long groupId, long userId)
2951                    throws SystemException {
2952                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2953                            return countByG_U(groupId, userId);
2954                    }
2955    
2956                    StringBundler query = new StringBundler(3);
2957    
2958                    query.append(_FILTER_SQL_COUNT_SCPRODUCTENTRY_WHERE);
2959    
2960                    query.append(_FINDER_COLUMN_G_U_GROUPID_2);
2961    
2962                    query.append(_FINDER_COLUMN_G_U_USERID_2);
2963    
2964                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2965                                    SCProductEntry.class.getName(),
2966                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2967    
2968                    Session session = null;
2969    
2970                    try {
2971                            session = openSession();
2972    
2973                            SQLQuery q = session.createSQLQuery(sql);
2974    
2975                            q.addScalar(COUNT_COLUMN_NAME,
2976                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
2977    
2978                            QueryPos qPos = QueryPos.getInstance(q);
2979    
2980                            qPos.add(groupId);
2981    
2982                            qPos.add(userId);
2983    
2984                            Long count = (Long)q.uniqueResult();
2985    
2986                            return count.intValue();
2987                    }
2988                    catch (Exception e) {
2989                            throw processException(e);
2990                    }
2991                    finally {
2992                            closeSession(session);
2993                    }
2994            }
2995    
2996            /**
2997             * Returns the number of s c product entries where repoGroupId = &#63; and repoArtifactId = &#63;.
2998             *
2999             * @param repoGroupId the repo group ID
3000             * @param repoArtifactId the repo artifact ID
3001             * @return the number of matching s c product entries
3002             * @throws SystemException if a system exception occurred
3003             */
3004            public int countByRG_RA(String repoGroupId, String repoArtifactId)
3005                    throws SystemException {
3006                    Object[] finderArgs = new Object[] { repoGroupId, repoArtifactId };
3007    
3008                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_RG_RA,
3009                                    finderArgs, this);
3010    
3011                    if (count == null) {
3012                            StringBundler query = new StringBundler(3);
3013    
3014                            query.append(_SQL_COUNT_SCPRODUCTENTRY_WHERE);
3015    
3016                            if (repoGroupId == null) {
3017                                    query.append(_FINDER_COLUMN_RG_RA_REPOGROUPID_1);
3018                            }
3019                            else {
3020                                    if (repoGroupId.equals(StringPool.BLANK)) {
3021                                            query.append(_FINDER_COLUMN_RG_RA_REPOGROUPID_3);
3022                                    }
3023                                    else {
3024                                            query.append(_FINDER_COLUMN_RG_RA_REPOGROUPID_2);
3025                                    }
3026                            }
3027    
3028                            if (repoArtifactId == null) {
3029                                    query.append(_FINDER_COLUMN_RG_RA_REPOARTIFACTID_1);
3030                            }
3031                            else {
3032                                    if (repoArtifactId.equals(StringPool.BLANK)) {
3033                                            query.append(_FINDER_COLUMN_RG_RA_REPOARTIFACTID_3);
3034                                    }
3035                                    else {
3036                                            query.append(_FINDER_COLUMN_RG_RA_REPOARTIFACTID_2);
3037                                    }
3038                            }
3039    
3040                            String sql = query.toString();
3041    
3042                            Session session = null;
3043    
3044                            try {
3045                                    session = openSession();
3046    
3047                                    Query q = session.createQuery(sql);
3048    
3049                                    QueryPos qPos = QueryPos.getInstance(q);
3050    
3051                                    if (repoGroupId != null) {
3052                                            qPos.add(repoGroupId);
3053                                    }
3054    
3055                                    if (repoArtifactId != null) {
3056                                            qPos.add(repoArtifactId);
3057                                    }
3058    
3059                                    count = (Long)q.uniqueResult();
3060                            }
3061                            catch (Exception e) {
3062                                    throw processException(e);
3063                            }
3064                            finally {
3065                                    if (count == null) {
3066                                            count = Long.valueOf(0);
3067                                    }
3068    
3069                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_RG_RA,
3070                                            finderArgs, count);
3071    
3072                                    closeSession(session);
3073                            }
3074                    }
3075    
3076                    return count.intValue();
3077            }
3078    
3079            /**
3080             * Returns the number of s c product entries.
3081             *
3082             * @return the number of s c product entries
3083             * @throws SystemException if a system exception occurred
3084             */
3085            public int countAll() throws SystemException {
3086                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
3087                                    FINDER_ARGS_EMPTY, this);
3088    
3089                    if (count == null) {
3090                            Session session = null;
3091    
3092                            try {
3093                                    session = openSession();
3094    
3095                                    Query q = session.createQuery(_SQL_COUNT_SCPRODUCTENTRY);
3096    
3097                                    count = (Long)q.uniqueResult();
3098                            }
3099                            catch (Exception e) {
3100                                    throw processException(e);
3101                            }
3102                            finally {
3103                                    if (count == null) {
3104                                            count = Long.valueOf(0);
3105                                    }
3106    
3107                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
3108                                            FINDER_ARGS_EMPTY, count);
3109    
3110                                    closeSession(session);
3111                            }
3112                    }
3113    
3114                    return count.intValue();
3115            }
3116    
3117            /**
3118             * Returns all the s c licenses associated with the s c product entry.
3119             *
3120             * @param pk the primary key of the s c product entry
3121             * @return the s c licenses associated with the s c product entry
3122             * @throws SystemException if a system exception occurred
3123             */
3124            public List<com.liferay.portlet.softwarecatalog.model.SCLicense> getSCLicenses(
3125                    long pk) throws SystemException {
3126                    return getSCLicenses(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
3127            }
3128    
3129            /**
3130             * Returns a range of all the s c licenses associated with the s c product entry.
3131             *
3132             * <p>
3133             * 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.
3134             * </p>
3135             *
3136             * @param pk the primary key of the s c product entry
3137             * @param start the lower bound of the range of s c product entries
3138             * @param end the upper bound of the range of s c product entries (not inclusive)
3139             * @return the range of s c licenses associated with the s c product entry
3140             * @throws SystemException if a system exception occurred
3141             */
3142            public List<com.liferay.portlet.softwarecatalog.model.SCLicense> getSCLicenses(
3143                    long pk, int start, int end) throws SystemException {
3144                    return getSCLicenses(pk, start, end, null);
3145            }
3146    
3147            public static final FinderPath FINDER_PATH_GET_SCLICENSES = new FinderPath(com.liferay.portlet.softwarecatalog.model.impl.SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
3148                            SCProductEntryModelImpl.FINDER_CACHE_ENABLED_SCLICENSES_SCPRODUCTENTRIES,
3149                            com.liferay.portlet.softwarecatalog.model.impl.SCLicenseImpl.class,
3150                            SCProductEntryModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME,
3151                            "getSCLicenses",
3152                            new String[] {
3153                                    Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
3154                                    "com.liferay.portal.kernel.util.OrderByComparator"
3155                            });
3156    
3157            static {
3158                    FINDER_PATH_GET_SCLICENSES.setCacheKeyGeneratorCacheName(null);
3159            }
3160    
3161            /**
3162             * Returns an ordered range of all the s c licenses associated with the s c product entry.
3163             *
3164             * <p>
3165             * 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.
3166             * </p>
3167             *
3168             * @param pk the primary key of the s c product entry
3169             * @param start the lower bound of the range of s c product entries
3170             * @param end the upper bound of the range of s c product entries (not inclusive)
3171             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3172             * @return the ordered range of s c licenses associated with the s c product entry
3173             * @throws SystemException if a system exception occurred
3174             */
3175            public List<com.liferay.portlet.softwarecatalog.model.SCLicense> getSCLicenses(
3176                    long pk, int start, int end, OrderByComparator orderByComparator)
3177                    throws SystemException {
3178                    Object[] finderArgs = new Object[] { pk, start, end, orderByComparator };
3179    
3180                    List<com.liferay.portlet.softwarecatalog.model.SCLicense> list = (List<com.liferay.portlet.softwarecatalog.model.SCLicense>)FinderCacheUtil.getResult(FINDER_PATH_GET_SCLICENSES,
3181                                    finderArgs, this);
3182    
3183                    if (list == null) {
3184                            Session session = null;
3185    
3186                            try {
3187                                    session = openSession();
3188    
3189                                    String sql = null;
3190    
3191                                    if (orderByComparator != null) {
3192                                            sql = _SQL_GETSCLICENSES.concat(ORDER_BY_CLAUSE)
3193                                                                                            .concat(orderByComparator.getOrderBy());
3194                                    }
3195                                    else {
3196                                            sql = _SQL_GETSCLICENSES.concat(com.liferay.portlet.softwarecatalog.model.impl.SCLicenseModelImpl.ORDER_BY_SQL);
3197                                    }
3198    
3199                                    SQLQuery q = session.createSQLQuery(sql);
3200    
3201                                    q.addEntity("SCLicense",
3202                                            com.liferay.portlet.softwarecatalog.model.impl.SCLicenseImpl.class);
3203    
3204                                    QueryPos qPos = QueryPos.getInstance(q);
3205    
3206                                    qPos.add(pk);
3207    
3208                                    list = (List<com.liferay.portlet.softwarecatalog.model.SCLicense>)QueryUtil.list(q,
3209                                                    getDialect(), start, end);
3210                            }
3211                            catch (Exception e) {
3212                                    throw processException(e);
3213                            }
3214                            finally {
3215                                    if (list == null) {
3216                                            FinderCacheUtil.removeResult(FINDER_PATH_GET_SCLICENSES,
3217                                                    finderArgs);
3218                                    }
3219                                    else {
3220                                            scLicensePersistence.cacheResult(list);
3221    
3222                                            FinderCacheUtil.putResult(FINDER_PATH_GET_SCLICENSES,
3223                                                    finderArgs, list);
3224                                    }
3225    
3226                                    closeSession(session);
3227                            }
3228                    }
3229    
3230                    return list;
3231            }
3232    
3233            public static final FinderPath FINDER_PATH_GET_SCLICENSES_SIZE = new FinderPath(com.liferay.portlet.softwarecatalog.model.impl.SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
3234                            SCProductEntryModelImpl.FINDER_CACHE_ENABLED_SCLICENSES_SCPRODUCTENTRIES,
3235                            Long.class,
3236                            SCProductEntryModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME,
3237                            "getSCLicensesSize", new String[] { Long.class.getName() });
3238    
3239            static {
3240                    FINDER_PATH_GET_SCLICENSES_SIZE.setCacheKeyGeneratorCacheName(null);
3241            }
3242    
3243            /**
3244             * Returns the number of s c licenses associated with the s c product entry.
3245             *
3246             * @param pk the primary key of the s c product entry
3247             * @return the number of s c licenses associated with the s c product entry
3248             * @throws SystemException if a system exception occurred
3249             */
3250            public int getSCLicensesSize(long pk) throws SystemException {
3251                    Object[] finderArgs = new Object[] { pk };
3252    
3253                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_SCLICENSES_SIZE,
3254                                    finderArgs, this);
3255    
3256                    if (count == null) {
3257                            Session session = null;
3258    
3259                            try {
3260                                    session = openSession();
3261    
3262                                    SQLQuery q = session.createSQLQuery(_SQL_GETSCLICENSESSIZE);
3263    
3264                                    q.addScalar(COUNT_COLUMN_NAME,
3265                                            com.liferay.portal.kernel.dao.orm.Type.LONG);
3266    
3267                                    QueryPos qPos = QueryPos.getInstance(q);
3268    
3269                                    qPos.add(pk);
3270    
3271                                    count = (Long)q.uniqueResult();
3272                            }
3273                            catch (Exception e) {
3274                                    throw processException(e);
3275                            }
3276                            finally {
3277                                    if (count == null) {
3278                                            count = Long.valueOf(0);
3279                                    }
3280    
3281                                    FinderCacheUtil.putResult(FINDER_PATH_GET_SCLICENSES_SIZE,
3282                                            finderArgs, count);
3283    
3284                                    closeSession(session);
3285                            }
3286                    }
3287    
3288                    return count.intValue();
3289            }
3290    
3291            public static final FinderPath FINDER_PATH_CONTAINS_SCLICENSE = new FinderPath(com.liferay.portlet.softwarecatalog.model.impl.SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
3292                            SCProductEntryModelImpl.FINDER_CACHE_ENABLED_SCLICENSES_SCPRODUCTENTRIES,
3293                            Boolean.class,
3294                            SCProductEntryModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME,
3295                            "containsSCLicense",
3296                            new String[] { Long.class.getName(), Long.class.getName() });
3297    
3298            /**
3299             * Returns <code>true</code> if the s c license is associated with the s c product entry.
3300             *
3301             * @param pk the primary key of the s c product entry
3302             * @param scLicensePK the primary key of the s c license
3303             * @return <code>true</code> if the s c license is associated with the s c product entry; <code>false</code> otherwise
3304             * @throws SystemException if a system exception occurred
3305             */
3306            public boolean containsSCLicense(long pk, long scLicensePK)
3307                    throws SystemException {
3308                    Object[] finderArgs = new Object[] { pk, scLicensePK };
3309    
3310                    Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_SCLICENSE,
3311                                    finderArgs, this);
3312    
3313                    if (value == null) {
3314                            try {
3315                                    value = Boolean.valueOf(containsSCLicense.contains(pk,
3316                                                            scLicensePK));
3317                            }
3318                            catch (Exception e) {
3319                                    throw processException(e);
3320                            }
3321                            finally {
3322                                    if (value == null) {
3323                                            value = Boolean.FALSE;
3324                                    }
3325    
3326                                    FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_SCLICENSE,
3327                                            finderArgs, value);
3328                            }
3329                    }
3330    
3331                    return value.booleanValue();
3332            }
3333    
3334            /**
3335             * Returns <code>true</code> if the s c product entry has any s c licenses associated with it.
3336             *
3337             * @param pk the primary key of the s c product entry to check for associations with s c licenses
3338             * @return <code>true</code> if the s c product entry has any s c licenses associated with it; <code>false</code> otherwise
3339             * @throws SystemException if a system exception occurred
3340             */
3341            public boolean containsSCLicenses(long pk) throws SystemException {
3342                    if (getSCLicensesSize(pk) > 0) {
3343                            return true;
3344                    }
3345                    else {
3346                            return false;
3347                    }
3348            }
3349    
3350            /**
3351             * 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.
3352             *
3353             * @param pk the primary key of the s c product entry
3354             * @param scLicensePK the primary key of the s c license
3355             * @throws SystemException if a system exception occurred
3356             */
3357            public void addSCLicense(long pk, long scLicensePK)
3358                    throws SystemException {
3359                    try {
3360                            addSCLicense.add(pk, scLicensePK);
3361                    }
3362                    catch (Exception e) {
3363                            throw processException(e);
3364                    }
3365                    finally {
3366                            FinderCacheUtil.clearCache(SCProductEntryModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
3367                    }
3368            }
3369    
3370            /**
3371             * 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.
3372             *
3373             * @param pk the primary key of the s c product entry
3374             * @param scLicense the s c license
3375             * @throws SystemException if a system exception occurred
3376             */
3377            public void addSCLicense(long pk,
3378                    com.liferay.portlet.softwarecatalog.model.SCLicense scLicense)
3379                    throws SystemException {
3380                    try {
3381                            addSCLicense.add(pk, scLicense.getPrimaryKey());
3382                    }
3383                    catch (Exception e) {
3384                            throw processException(e);
3385                    }
3386                    finally {
3387                            FinderCacheUtil.clearCache(SCProductEntryModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
3388                    }
3389            }
3390    
3391            /**
3392             * 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.
3393             *
3394             * @param pk the primary key of the s c product entry
3395             * @param scLicensePKs the primary keys of the s c licenses
3396             * @throws SystemException if a system exception occurred
3397             */
3398            public void addSCLicenses(long pk, long[] scLicensePKs)
3399                    throws SystemException {
3400                    try {
3401                            for (long scLicensePK : scLicensePKs) {
3402                                    addSCLicense.add(pk, scLicensePK);
3403                            }
3404                    }
3405                    catch (Exception e) {
3406                            throw processException(e);
3407                    }
3408                    finally {
3409                            FinderCacheUtil.clearCache(SCProductEntryModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
3410                    }
3411            }
3412    
3413            /**
3414             * 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.
3415             *
3416             * @param pk the primary key of the s c product entry
3417             * @param scLicenses the s c licenses
3418             * @throws SystemException if a system exception occurred
3419             */
3420            public void addSCLicenses(long pk,
3421                    List<com.liferay.portlet.softwarecatalog.model.SCLicense> scLicenses)
3422                    throws SystemException {
3423                    try {
3424                            for (com.liferay.portlet.softwarecatalog.model.SCLicense scLicense : scLicenses) {
3425                                    addSCLicense.add(pk, scLicense.getPrimaryKey());
3426                            }
3427                    }
3428                    catch (Exception e) {
3429                            throw processException(e);
3430                    }
3431                    finally {
3432                            FinderCacheUtil.clearCache(SCProductEntryModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
3433                    }
3434            }
3435    
3436            /**
3437             * 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.
3438             *
3439             * @param pk the primary key of the s c product entry to clear the associated s c licenses from
3440             * @throws SystemException if a system exception occurred
3441             */
3442            public void clearSCLicenses(long pk) throws SystemException {
3443                    try {
3444                            clearSCLicenses.clear(pk);
3445                    }
3446                    catch (Exception e) {
3447                            throw processException(e);
3448                    }
3449                    finally {
3450                            FinderCacheUtil.clearCache(SCProductEntryModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
3451                    }
3452            }
3453    
3454            /**
3455             * 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.
3456             *
3457             * @param pk the primary key of the s c product entry
3458             * @param scLicensePK the primary key of the s c license
3459             * @throws SystemException if a system exception occurred
3460             */
3461            public void removeSCLicense(long pk, long scLicensePK)
3462                    throws SystemException {
3463                    try {
3464                            removeSCLicense.remove(pk, scLicensePK);
3465                    }
3466                    catch (Exception e) {
3467                            throw processException(e);
3468                    }
3469                    finally {
3470                            FinderCacheUtil.clearCache(SCProductEntryModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
3471                    }
3472            }
3473    
3474            /**
3475             * 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.
3476             *
3477             * @param pk the primary key of the s c product entry
3478             * @param scLicense the s c license
3479             * @throws SystemException if a system exception occurred
3480             */
3481            public void removeSCLicense(long pk,
3482                    com.liferay.portlet.softwarecatalog.model.SCLicense scLicense)
3483                    throws SystemException {
3484                    try {
3485                            removeSCLicense.remove(pk, scLicense.getPrimaryKey());
3486                    }
3487                    catch (Exception e) {
3488                            throw processException(e);
3489                    }
3490                    finally {
3491                            FinderCacheUtil.clearCache(SCProductEntryModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
3492                    }
3493            }
3494    
3495            /**
3496             * 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.
3497             *
3498             * @param pk the primary key of the s c product entry
3499             * @param scLicensePKs the primary keys of the s c licenses
3500             * @throws SystemException if a system exception occurred
3501             */
3502            public void removeSCLicenses(long pk, long[] scLicensePKs)
3503                    throws SystemException {
3504                    try {
3505                            for (long scLicensePK : scLicensePKs) {
3506                                    removeSCLicense.remove(pk, scLicensePK);
3507                            }
3508                    }
3509                    catch (Exception e) {
3510                            throw processException(e);
3511                    }
3512                    finally {
3513                            FinderCacheUtil.clearCache(SCProductEntryModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
3514                    }
3515            }
3516    
3517            /**
3518             * 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.
3519             *
3520             * @param pk the primary key of the s c product entry
3521             * @param scLicenses the s c licenses
3522             * @throws SystemException if a system exception occurred
3523             */
3524            public void removeSCLicenses(long pk,
3525                    List<com.liferay.portlet.softwarecatalog.model.SCLicense> scLicenses)
3526                    throws SystemException {
3527                    try {
3528                            for (com.liferay.portlet.softwarecatalog.model.SCLicense scLicense : scLicenses) {
3529                                    removeSCLicense.remove(pk, scLicense.getPrimaryKey());
3530                            }
3531                    }
3532                    catch (Exception e) {
3533                            throw processException(e);
3534                    }
3535                    finally {
3536                            FinderCacheUtil.clearCache(SCProductEntryModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
3537                    }
3538            }
3539    
3540            /**
3541             * 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.
3542             *
3543             * @param pk the primary key of the s c product entry
3544             * @param scLicensePKs the primary keys of the s c licenses to be associated with the s c product entry
3545             * @throws SystemException if a system exception occurred
3546             */
3547            public void setSCLicenses(long pk, long[] scLicensePKs)
3548                    throws SystemException {
3549                    try {
3550                            Set<Long> scLicensePKSet = SetUtil.fromArray(scLicensePKs);
3551    
3552                            List<com.liferay.portlet.softwarecatalog.model.SCLicense> scLicenses =
3553                                    getSCLicenses(pk);
3554    
3555                            for (com.liferay.portlet.softwarecatalog.model.SCLicense scLicense : scLicenses) {
3556                                    if (!scLicensePKSet.remove(scLicense.getPrimaryKey())) {
3557                                            removeSCLicense.remove(pk, scLicense.getPrimaryKey());
3558                                    }
3559                            }
3560    
3561                            for (Long scLicensePK : scLicensePKSet) {
3562                                    addSCLicense.add(pk, scLicensePK);
3563                            }
3564                    }
3565                    catch (Exception e) {
3566                            throw processException(e);
3567                    }
3568                    finally {
3569                            FinderCacheUtil.clearCache(SCProductEntryModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
3570                    }
3571            }
3572    
3573            /**
3574             * 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.
3575             *
3576             * @param pk the primary key of the s c product entry
3577             * @param scLicenses the s c licenses to be associated with the s c product entry
3578             * @throws SystemException if a system exception occurred
3579             */
3580            public void setSCLicenses(long pk,
3581                    List<com.liferay.portlet.softwarecatalog.model.SCLicense> scLicenses)
3582                    throws SystemException {
3583                    try {
3584                            long[] scLicensePKs = new long[scLicenses.size()];
3585    
3586                            for (int i = 0; i < scLicenses.size(); i++) {
3587                                    com.liferay.portlet.softwarecatalog.model.SCLicense scLicense = scLicenses.get(i);
3588    
3589                                    scLicensePKs[i] = scLicense.getPrimaryKey();
3590                            }
3591    
3592                            setSCLicenses(pk, scLicensePKs);
3593                    }
3594                    catch (Exception e) {
3595                            throw processException(e);
3596                    }
3597                    finally {
3598                            FinderCacheUtil.clearCache(SCProductEntryModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
3599                    }
3600            }
3601    
3602            /**
3603             * Initializes the s c product entry persistence.
3604             */
3605            public void afterPropertiesSet() {
3606                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
3607                                            com.liferay.portal.util.PropsUtil.get(
3608                                                    "value.object.listener.com.liferay.portlet.softwarecatalog.model.SCProductEntry")));
3609    
3610                    if (listenerClassNames.length > 0) {
3611                            try {
3612                                    List<ModelListener<SCProductEntry>> listenersList = new ArrayList<ModelListener<SCProductEntry>>();
3613    
3614                                    for (String listenerClassName : listenerClassNames) {
3615                                            listenersList.add((ModelListener<SCProductEntry>)InstanceFactory.newInstance(
3616                                                            listenerClassName));
3617                                    }
3618    
3619                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
3620                            }
3621                            catch (Exception e) {
3622                                    _log.error(e);
3623                            }
3624                    }
3625    
3626                    containsSCLicense = new ContainsSCLicense();
3627    
3628                    addSCLicense = new AddSCLicense();
3629                    clearSCLicenses = new ClearSCLicenses();
3630                    removeSCLicense = new RemoveSCLicense();
3631            }
3632    
3633            public void destroy() {
3634                    EntityCacheUtil.removeCache(SCProductEntryImpl.class.getName());
3635                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
3636                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
3637            }
3638    
3639            @BeanReference(type = SCFrameworkVersionPersistence.class)
3640            protected SCFrameworkVersionPersistence scFrameworkVersionPersistence;
3641            @BeanReference(type = SCLicensePersistence.class)
3642            protected SCLicensePersistence scLicensePersistence;
3643            @BeanReference(type = SCProductEntryPersistence.class)
3644            protected SCProductEntryPersistence scProductEntryPersistence;
3645            @BeanReference(type = SCProductScreenshotPersistence.class)
3646            protected SCProductScreenshotPersistence scProductScreenshotPersistence;
3647            @BeanReference(type = SCProductVersionPersistence.class)
3648            protected SCProductVersionPersistence scProductVersionPersistence;
3649            @BeanReference(type = GroupPersistence.class)
3650            protected GroupPersistence groupPersistence;
3651            @BeanReference(type = ImagePersistence.class)
3652            protected ImagePersistence imagePersistence;
3653            @BeanReference(type = ResourcePersistence.class)
3654            protected ResourcePersistence resourcePersistence;
3655            @BeanReference(type = UserPersistence.class)
3656            protected UserPersistence userPersistence;
3657            @BeanReference(type = MBMessagePersistence.class)
3658            protected MBMessagePersistence mbMessagePersistence;
3659            @BeanReference(type = RatingsStatsPersistence.class)
3660            protected RatingsStatsPersistence ratingsStatsPersistence;
3661            protected ContainsSCLicense containsSCLicense;
3662            protected AddSCLicense addSCLicense;
3663            protected ClearSCLicenses clearSCLicenses;
3664            protected RemoveSCLicense removeSCLicense;
3665    
3666            protected class ContainsSCLicense {
3667                    protected ContainsSCLicense() {
3668                            _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
3669                                            _SQL_CONTAINSSCLICENSE,
3670                                            new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
3671                                            RowMapper.COUNT);
3672                    }
3673    
3674                    protected boolean contains(long productEntryId, long licenseId) {
3675                            List<Integer> results = _mappingSqlQuery.execute(new Object[] {
3676                                                    new Long(productEntryId), new Long(licenseId)
3677                                            });
3678    
3679                            if (results.size() > 0) {
3680                                    Integer count = results.get(0);
3681    
3682                                    if (count.intValue() > 0) {
3683                                            return true;
3684                                    }
3685                            }
3686    
3687                            return false;
3688                    }
3689    
3690                    private MappingSqlQuery<Integer> _mappingSqlQuery;
3691            }
3692    
3693            protected class AddSCLicense {
3694                    protected AddSCLicense() {
3695                            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
3696                                            "INSERT INTO SCLicenses_SCProductEntries (productEntryId, licenseId) VALUES (?, ?)",
3697                                            new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
3698                    }
3699    
3700                    protected void add(long productEntryId, long licenseId)
3701                            throws SystemException {
3702                            if (!containsSCLicense.contains(productEntryId, licenseId)) {
3703                                    ModelListener<com.liferay.portlet.softwarecatalog.model.SCLicense>[] scLicenseListeners =
3704                                            scLicensePersistence.getListeners();
3705    
3706                                    for (ModelListener<SCProductEntry> listener : listeners) {
3707                                            listener.onBeforeAddAssociation(productEntryId,
3708                                                    com.liferay.portlet.softwarecatalog.model.SCLicense.class.getName(),
3709                                                    licenseId);
3710                                    }
3711    
3712                                    for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCLicense> listener : scLicenseListeners) {
3713                                            listener.onBeforeAddAssociation(licenseId,
3714                                                    SCProductEntry.class.getName(), productEntryId);
3715                                    }
3716    
3717                                    _sqlUpdate.update(new Object[] {
3718                                                    new Long(productEntryId), new Long(licenseId)
3719                                            });
3720    
3721                                    for (ModelListener<SCProductEntry> listener : listeners) {
3722                                            listener.onAfterAddAssociation(productEntryId,
3723                                                    com.liferay.portlet.softwarecatalog.model.SCLicense.class.getName(),
3724                                                    licenseId);
3725                                    }
3726    
3727                                    for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCLicense> listener : scLicenseListeners) {
3728                                            listener.onAfterAddAssociation(licenseId,
3729                                                    SCProductEntry.class.getName(), productEntryId);
3730                                    }
3731                            }
3732                    }
3733    
3734                    private SqlUpdate _sqlUpdate;
3735            }
3736    
3737            protected class ClearSCLicenses {
3738                    protected ClearSCLicenses() {
3739                            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
3740                                            "DELETE FROM SCLicenses_SCProductEntries WHERE productEntryId = ?",
3741                                            new int[] { java.sql.Types.BIGINT });
3742                    }
3743    
3744                    protected void clear(long productEntryId) throws SystemException {
3745                            ModelListener<com.liferay.portlet.softwarecatalog.model.SCLicense>[] scLicenseListeners =
3746                                    scLicensePersistence.getListeners();
3747    
3748                            List<com.liferay.portlet.softwarecatalog.model.SCLicense> scLicenses =
3749                                    null;
3750    
3751                            if ((listeners.length > 0) || (scLicenseListeners.length > 0)) {
3752                                    scLicenses = getSCLicenses(productEntryId);
3753    
3754                                    for (com.liferay.portlet.softwarecatalog.model.SCLicense scLicense : scLicenses) {
3755                                            for (ModelListener<SCProductEntry> listener : listeners) {
3756                                                    listener.onBeforeRemoveAssociation(productEntryId,
3757                                                            com.liferay.portlet.softwarecatalog.model.SCLicense.class.getName(),
3758                                                            scLicense.getPrimaryKey());
3759                                            }
3760    
3761                                            for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCLicense> listener : scLicenseListeners) {
3762                                                    listener.onBeforeRemoveAssociation(scLicense.getPrimaryKey(),
3763                                                            SCProductEntry.class.getName(), productEntryId);
3764                                            }
3765                                    }
3766                            }
3767    
3768                            _sqlUpdate.update(new Object[] { new Long(productEntryId) });
3769    
3770                            if ((listeners.length > 0) || (scLicenseListeners.length > 0)) {
3771                                    for (com.liferay.portlet.softwarecatalog.model.SCLicense scLicense : scLicenses) {
3772                                            for (ModelListener<SCProductEntry> listener : listeners) {
3773                                                    listener.onAfterRemoveAssociation(productEntryId,
3774                                                            com.liferay.portlet.softwarecatalog.model.SCLicense.class.getName(),
3775                                                            scLicense.getPrimaryKey());
3776                                            }
3777    
3778                                            for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCLicense> listener : scLicenseListeners) {
3779                                                    listener.onAfterRemoveAssociation(scLicense.getPrimaryKey(),
3780                                                            SCProductEntry.class.getName(), productEntryId);
3781                                            }
3782                                    }
3783                            }
3784                    }
3785    
3786                    private SqlUpdate _sqlUpdate;
3787            }
3788    
3789            protected class RemoveSCLicense {
3790                    protected RemoveSCLicense() {
3791                            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
3792                                            "DELETE FROM SCLicenses_SCProductEntries WHERE productEntryId = ? AND licenseId = ?",
3793                                            new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
3794                    }
3795    
3796                    protected void remove(long productEntryId, long licenseId)
3797                            throws SystemException {
3798                            if (containsSCLicense.contains(productEntryId, licenseId)) {
3799                                    ModelListener<com.liferay.portlet.softwarecatalog.model.SCLicense>[] scLicenseListeners =
3800                                            scLicensePersistence.getListeners();
3801    
3802                                    for (ModelListener<SCProductEntry> listener : listeners) {
3803                                            listener.onBeforeRemoveAssociation(productEntryId,
3804                                                    com.liferay.portlet.softwarecatalog.model.SCLicense.class.getName(),
3805                                                    licenseId);
3806                                    }
3807    
3808                                    for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCLicense> listener : scLicenseListeners) {
3809                                            listener.onBeforeRemoveAssociation(licenseId,
3810                                                    SCProductEntry.class.getName(), productEntryId);
3811                                    }
3812    
3813                                    _sqlUpdate.update(new Object[] {
3814                                                    new Long(productEntryId), new Long(licenseId)
3815                                            });
3816    
3817                                    for (ModelListener<SCProductEntry> listener : listeners) {
3818                                            listener.onAfterRemoveAssociation(productEntryId,
3819                                                    com.liferay.portlet.softwarecatalog.model.SCLicense.class.getName(),
3820                                                    licenseId);
3821                                    }
3822    
3823                                    for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCLicense> listener : scLicenseListeners) {
3824                                            listener.onAfterRemoveAssociation(licenseId,
3825                                                    SCProductEntry.class.getName(), productEntryId);
3826                                    }
3827                            }
3828                    }
3829    
3830                    private SqlUpdate _sqlUpdate;
3831            }
3832    
3833            private static final String _SQL_SELECT_SCPRODUCTENTRY = "SELECT scProductEntry FROM SCProductEntry scProductEntry";
3834            private static final String _SQL_SELECT_SCPRODUCTENTRY_WHERE = "SELECT scProductEntry FROM SCProductEntry scProductEntry WHERE ";
3835            private static final String _SQL_COUNT_SCPRODUCTENTRY = "SELECT COUNT(scProductEntry) FROM SCProductEntry scProductEntry";
3836            private static final String _SQL_COUNT_SCPRODUCTENTRY_WHERE = "SELECT COUNT(scProductEntry) FROM SCProductEntry scProductEntry WHERE ";
3837            private static final String _SQL_GETSCLICENSES = "SELECT {SCLicense.*} FROM SCLicense INNER JOIN SCLicenses_SCProductEntries ON (SCLicenses_SCProductEntries.licenseId = SCLicense.licenseId) WHERE (SCLicenses_SCProductEntries.productEntryId = ?)";
3838            private static final String _SQL_GETSCLICENSESSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM SCLicenses_SCProductEntries WHERE productEntryId = ?";
3839            private static final String _SQL_CONTAINSSCLICENSE = "SELECT COUNT(*) AS COUNT_VALUE FROM SCLicenses_SCProductEntries WHERE productEntryId = ? AND licenseId = ?";
3840            private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "scProductEntry.groupId = ?";
3841            private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "scProductEntry.companyId = ?";
3842            private static final String _FINDER_COLUMN_G_U_GROUPID_2 = "scProductEntry.groupId = ? AND ";
3843            private static final String _FINDER_COLUMN_G_U_USERID_2 = "scProductEntry.userId = ?";
3844            private static final String _FINDER_COLUMN_RG_RA_REPOGROUPID_1 = "scProductEntry.repoGroupId IS NULL AND ";
3845            private static final String _FINDER_COLUMN_RG_RA_REPOGROUPID_2 = "lower(scProductEntry.repoGroupId) = lower(CAST_TEXT(?)) AND ";
3846            private static final String _FINDER_COLUMN_RG_RA_REPOGROUPID_3 = "(scProductEntry.repoGroupId IS NULL OR lower(scProductEntry.repoGroupId) = lower(CAST_TEXT(?))) AND ";
3847            private static final String _FINDER_COLUMN_RG_RA_REPOARTIFACTID_1 = "scProductEntry.repoArtifactId IS NULL";
3848            private static final String _FINDER_COLUMN_RG_RA_REPOARTIFACTID_2 = "lower(scProductEntry.repoArtifactId) = lower(CAST_TEXT(?))";
3849            private static final String _FINDER_COLUMN_RG_RA_REPOARTIFACTID_3 = "(scProductEntry.repoArtifactId IS NULL OR lower(scProductEntry.repoArtifactId) = lower(CAST_TEXT(?)))";
3850            private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "scProductEntry.productEntryId";
3851            private static final String _FILTER_SQL_SELECT_SCPRODUCTENTRY_WHERE = "SELECT DISTINCT {scProductEntry.*} FROM SCProductEntry scProductEntry WHERE ";
3852            private static final String _FILTER_SQL_SELECT_SCPRODUCTENTRY_NO_INLINE_DISTINCT_WHERE_1 =
3853                    "SELECT {SCProductEntry.*} FROM (SELECT DISTINCT scProductEntry.productEntryId FROM SCProductEntry scProductEntry WHERE ";
3854            private static final String _FILTER_SQL_SELECT_SCPRODUCTENTRY_NO_INLINE_DISTINCT_WHERE_2 =
3855                    ") TEMP_TABLE INNER JOIN SCProductEntry ON TEMP_TABLE.productEntryId = SCProductEntry.productEntryId";
3856            private static final String _FILTER_SQL_COUNT_SCPRODUCTENTRY_WHERE = "SELECT COUNT(DISTINCT scProductEntry.productEntryId) AS COUNT_VALUE FROM SCProductEntry scProductEntry WHERE ";
3857            private static final String _FILTER_ENTITY_ALIAS = "scProductEntry";
3858            private static final String _FILTER_ENTITY_TABLE = "SCProductEntry";
3859            private static final String _ORDER_BY_ENTITY_ALIAS = "scProductEntry.";
3860            private static final String _ORDER_BY_ENTITY_TABLE = "SCProductEntry.";
3861            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No SCProductEntry exists with the primary key ";
3862            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No SCProductEntry exists with the key {";
3863            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
3864            private static Log _log = LogFactoryUtil.getLog(SCProductEntryPersistenceImpl.class);
3865            private static SCProductEntry _nullSCProductEntry = new SCProductEntryImpl() {
3866                            @Override
3867                            public Object clone() {
3868                                    return this;
3869                            }
3870    
3871                            @Override
3872                            public CacheModel<SCProductEntry> toCacheModel() {
3873                                    return _nullSCProductEntryCacheModel;
3874                            }
3875                    };
3876    
3877            private static CacheModel<SCProductEntry> _nullSCProductEntryCacheModel = new CacheModel<SCProductEntry>() {
3878                            public SCProductEntry toEntityModel() {
3879                                    return _nullSCProductEntry;
3880                            }
3881                    };
3882    }