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