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