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