001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portlet.softwarecatalog.service.persistence;
016    
017    import com.liferay.portal.NoSuchModelException;
018    import com.liferay.portal.kernel.annotation.BeanReference;
019    import com.liferay.portal.kernel.cache.CacheRegistryUtil;
020    import com.liferay.portal.kernel.dao.jdbc.MappingSqlQuery;
021    import com.liferay.portal.kernel.dao.jdbc.MappingSqlQueryFactoryUtil;
022    import com.liferay.portal.kernel.dao.jdbc.RowMapper;
023    import com.liferay.portal.kernel.dao.jdbc.SqlUpdate;
024    import com.liferay.portal.kernel.dao.jdbc.SqlUpdateFactoryUtil;
025    import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
026    import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
027    import com.liferay.portal.kernel.dao.orm.FinderPath;
028    import com.liferay.portal.kernel.dao.orm.Query;
029    import com.liferay.portal.kernel.dao.orm.QueryPos;
030    import com.liferay.portal.kernel.dao.orm.QueryUtil;
031    import com.liferay.portal.kernel.dao.orm.SQLQuery;
032    import com.liferay.portal.kernel.dao.orm.Session;
033    import com.liferay.portal.kernel.exception.SystemException;
034    import com.liferay.portal.kernel.log.Log;
035    import com.liferay.portal.kernel.log.LogFactoryUtil;
036    import com.liferay.portal.kernel.util.GetterUtil;
037    import com.liferay.portal.kernel.util.InstanceFactory;
038    import com.liferay.portal.kernel.util.OrderByComparator;
039    import com.liferay.portal.kernel.util.SetUtil;
040    import com.liferay.portal.kernel.util.StringBundler;
041    import com.liferay.portal.kernel.util.StringPool;
042    import com.liferay.portal.kernel.util.StringUtil;
043    import com.liferay.portal.kernel.util.Validator;
044    import com.liferay.portal.model.ModelListener;
045    import com.liferay.portal.security.permission.InlineSQLHelperUtil;
046    import com.liferay.portal.service.persistence.BatchSessionUtil;
047    import com.liferay.portal.service.persistence.GroupPersistence;
048    import com.liferay.portal.service.persistence.ImagePersistence;
049    import com.liferay.portal.service.persistence.ResourcePersistence;
050    import com.liferay.portal.service.persistence.UserPersistence;
051    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
052    
053    import com.liferay.portlet.messageboards.service.persistence.MBMessagePersistence;
054    import com.liferay.portlet.ratings.service.persistence.RatingsStatsPersistence;
055    import com.liferay.portlet.softwarecatalog.NoSuchProductEntryException;
056    import com.liferay.portlet.softwarecatalog.model.SCProductEntry;
057    import com.liferay.portlet.softwarecatalog.model.impl.SCProductEntryImpl;
058    import com.liferay.portlet.softwarecatalog.model.impl.SCProductEntryModelImpl;
059    
060    import java.io.Serializable;
061    
062    import java.util.ArrayList;
063    import java.util.Collections;
064    import java.util.List;
065    import java.util.Set;
066    
067    /**
068     * @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            public static final String FINDER_CLASS_NAME_ENTITY = SCProductEntryImpl.class.getName();
076            public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
077                    ".List";
078            public static final FinderPath FINDER_PATH_FIND_BY_GROUPID = new FinderPath(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
079                            SCProductEntryModelImpl.FINDER_CACHE_ENABLED,
080                            FINDER_CLASS_NAME_LIST, "findByGroupId",
081                            new String[] {
082                                    Long.class.getName(),
083                                    
084                            "java.lang.Integer", "java.lang.Integer",
085                                    "com.liferay.portal.kernel.util.OrderByComparator"
086                            });
087            public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
088                            SCProductEntryModelImpl.FINDER_CACHE_ENABLED,
089                            FINDER_CLASS_NAME_LIST, "countByGroupId",
090                            new String[] { Long.class.getName() });
091            public static final FinderPath FINDER_PATH_FIND_BY_COMPANYID = new FinderPath(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
092                            SCProductEntryModelImpl.FINDER_CACHE_ENABLED,
093                            FINDER_CLASS_NAME_LIST, "findByCompanyId",
094                            new String[] {
095                                    Long.class.getName(),
096                                    
097                            "java.lang.Integer", "java.lang.Integer",
098                                    "com.liferay.portal.kernel.util.OrderByComparator"
099                            });
100            public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
101                            SCProductEntryModelImpl.FINDER_CACHE_ENABLED,
102                            FINDER_CLASS_NAME_LIST, "countByCompanyId",
103                            new String[] { Long.class.getName() });
104            public static final FinderPath FINDER_PATH_FIND_BY_G_U = new FinderPath(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
105                            SCProductEntryModelImpl.FINDER_CACHE_ENABLED,
106                            FINDER_CLASS_NAME_LIST, "findByG_U",
107                            new String[] {
108                                    Long.class.getName(), Long.class.getName(),
109                                    
110                            "java.lang.Integer", "java.lang.Integer",
111                                    "com.liferay.portal.kernel.util.OrderByComparator"
112                            });
113            public static final FinderPath FINDER_PATH_COUNT_BY_G_U = new FinderPath(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
114                            SCProductEntryModelImpl.FINDER_CACHE_ENABLED,
115                            FINDER_CLASS_NAME_LIST, "countByG_U",
116                            new String[] { Long.class.getName(), Long.class.getName() });
117            public static final FinderPath FINDER_PATH_FETCH_BY_RG_RA = new FinderPath(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
118                            SCProductEntryModelImpl.FINDER_CACHE_ENABLED,
119                            FINDER_CLASS_NAME_ENTITY, "fetchByRG_RA",
120                            new String[] { String.class.getName(), String.class.getName() });
121            public static final FinderPath FINDER_PATH_COUNT_BY_RG_RA = new FinderPath(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
122                            SCProductEntryModelImpl.FINDER_CACHE_ENABLED,
123                            FINDER_CLASS_NAME_LIST, "countByRG_RA",
124                            new String[] { String.class.getName(), String.class.getName() });
125            public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
126                            SCProductEntryModelImpl.FINDER_CACHE_ENABLED,
127                            FINDER_CLASS_NAME_LIST, "findAll", new String[0]);
128            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
129                            SCProductEntryModelImpl.FINDER_CACHE_ENABLED,
130                            FINDER_CLASS_NAME_LIST, "countAll", new String[0]);
131    
132            public void cacheResult(SCProductEntry scProductEntry) {
133                    EntityCacheUtil.putResult(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
134                            SCProductEntryImpl.class, scProductEntry.getPrimaryKey(),
135                            scProductEntry);
136    
137                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_RG_RA,
138                            new Object[] {
139                                    scProductEntry.getRepoGroupId(),
140                                    
141                            scProductEntry.getRepoArtifactId()
142                            }, scProductEntry);
143            }
144    
145            public void cacheResult(List<SCProductEntry> scProductEntries) {
146                    for (SCProductEntry scProductEntry : scProductEntries) {
147                            if (EntityCacheUtil.getResult(
148                                                    SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
149                                                    SCProductEntryImpl.class,
150                                                    scProductEntry.getPrimaryKey(), this) == null) {
151                                    cacheResult(scProductEntry);
152                            }
153                    }
154            }
155    
156            public void clearCache() {
157                    CacheRegistryUtil.clear(SCProductEntryImpl.class.getName());
158                    EntityCacheUtil.clearCache(SCProductEntryImpl.class.getName());
159                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
160                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
161            }
162    
163            public void clearCache(SCProductEntry scProductEntry) {
164                    EntityCacheUtil.removeResult(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
165                            SCProductEntryImpl.class, scProductEntry.getPrimaryKey());
166    
167                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_RG_RA,
168                            new Object[] {
169                                    scProductEntry.getRepoGroupId(),
170                                    
171                            scProductEntry.getRepoArtifactId()
172                            });
173            }
174    
175            public SCProductEntry create(long productEntryId) {
176                    SCProductEntry scProductEntry = new SCProductEntryImpl();
177    
178                    scProductEntry.setNew(true);
179                    scProductEntry.setPrimaryKey(productEntryId);
180    
181                    return scProductEntry;
182            }
183    
184            public SCProductEntry remove(Serializable primaryKey)
185                    throws NoSuchModelException, SystemException {
186                    return remove(((Long)primaryKey).longValue());
187            }
188    
189            public SCProductEntry remove(long productEntryId)
190                    throws NoSuchProductEntryException, SystemException {
191                    Session session = null;
192    
193                    try {
194                            session = openSession();
195    
196                            SCProductEntry scProductEntry = (SCProductEntry)session.get(SCProductEntryImpl.class,
197                                            new Long(productEntryId));
198    
199                            if (scProductEntry == null) {
200                                    if (_log.isWarnEnabled()) {
201                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
202                                                    productEntryId);
203                                    }
204    
205                                    throw new NoSuchProductEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
206                                            productEntryId);
207                            }
208    
209                            return remove(scProductEntry);
210                    }
211                    catch (NoSuchProductEntryException nsee) {
212                            throw nsee;
213                    }
214                    catch (Exception e) {
215                            throw processException(e);
216                    }
217                    finally {
218                            closeSession(session);
219                    }
220            }
221    
222            protected SCProductEntry removeImpl(SCProductEntry scProductEntry)
223                    throws SystemException {
224                    scProductEntry = toUnwrappedModel(scProductEntry);
225    
226                    try {
227                            clearSCLicenses.clear(scProductEntry.getPrimaryKey());
228                    }
229                    catch (Exception e) {
230                            throw processException(e);
231                    }
232                    finally {
233                            FinderCacheUtil.clearCache(SCProductEntryModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
234                    }
235    
236                    Session session = null;
237    
238                    try {
239                            session = openSession();
240    
241                            if (scProductEntry.isCachedModel() || BatchSessionUtil.isEnabled()) {
242                                    Object staleObject = session.get(SCProductEntryImpl.class,
243                                                    scProductEntry.getPrimaryKeyObj());
244    
245                                    if (staleObject != null) {
246                                            session.evict(staleObject);
247                                    }
248                            }
249    
250                            session.delete(scProductEntry);
251    
252                            session.flush();
253                    }
254                    catch (Exception e) {
255                            throw processException(e);
256                    }
257                    finally {
258                            closeSession(session);
259                    }
260    
261                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
262    
263                    SCProductEntryModelImpl scProductEntryModelImpl = (SCProductEntryModelImpl)scProductEntry;
264    
265                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_RG_RA,
266                            new Object[] {
267                                    scProductEntryModelImpl.getOriginalRepoGroupId(),
268                                    
269                            scProductEntryModelImpl.getOriginalRepoArtifactId()
270                            });
271    
272                    EntityCacheUtil.removeResult(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
273                            SCProductEntryImpl.class, scProductEntry.getPrimaryKey());
274    
275                    return scProductEntry;
276            }
277    
278            public SCProductEntry updateImpl(
279                    com.liferay.portlet.softwarecatalog.model.SCProductEntry scProductEntry,
280                    boolean merge) throws SystemException {
281                    scProductEntry = toUnwrappedModel(scProductEntry);
282    
283                    boolean isNew = scProductEntry.isNew();
284    
285                    SCProductEntryModelImpl scProductEntryModelImpl = (SCProductEntryModelImpl)scProductEntry;
286    
287                    Session session = null;
288    
289                    try {
290                            session = openSession();
291    
292                            BatchSessionUtil.update(session, scProductEntry, merge);
293    
294                            scProductEntry.setNew(false);
295                    }
296                    catch (Exception e) {
297                            throw processException(e);
298                    }
299                    finally {
300                            closeSession(session);
301                    }
302    
303                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
304    
305                    EntityCacheUtil.putResult(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
306                            SCProductEntryImpl.class, scProductEntry.getPrimaryKey(),
307                            scProductEntry);
308    
309                    if (!isNew &&
310                                    (!Validator.equals(scProductEntry.getRepoGroupId(),
311                                            scProductEntryModelImpl.getOriginalRepoGroupId()) ||
312                                    !Validator.equals(scProductEntry.getRepoArtifactId(),
313                                            scProductEntryModelImpl.getOriginalRepoArtifactId()))) {
314                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_RG_RA,
315                                    new Object[] {
316                                            scProductEntryModelImpl.getOriginalRepoGroupId(),
317                                            
318                                    scProductEntryModelImpl.getOriginalRepoArtifactId()
319                                    });
320                    }
321    
322                    if (isNew ||
323                                    (!Validator.equals(scProductEntry.getRepoGroupId(),
324                                            scProductEntryModelImpl.getOriginalRepoGroupId()) ||
325                                    !Validator.equals(scProductEntry.getRepoArtifactId(),
326                                            scProductEntryModelImpl.getOriginalRepoArtifactId()))) {
327                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_RG_RA,
328                                    new Object[] {
329                                            scProductEntry.getRepoGroupId(),
330                                            
331                                    scProductEntry.getRepoArtifactId()
332                                    }, scProductEntry);
333                    }
334    
335                    return scProductEntry;
336            }
337    
338            protected SCProductEntry toUnwrappedModel(SCProductEntry scProductEntry) {
339                    if (scProductEntry instanceof SCProductEntryImpl) {
340                            return scProductEntry;
341                    }
342    
343                    SCProductEntryImpl scProductEntryImpl = new SCProductEntryImpl();
344    
345                    scProductEntryImpl.setNew(scProductEntry.isNew());
346                    scProductEntryImpl.setPrimaryKey(scProductEntry.getPrimaryKey());
347    
348                    scProductEntryImpl.setProductEntryId(scProductEntry.getProductEntryId());
349                    scProductEntryImpl.setGroupId(scProductEntry.getGroupId());
350                    scProductEntryImpl.setCompanyId(scProductEntry.getCompanyId());
351                    scProductEntryImpl.setUserId(scProductEntry.getUserId());
352                    scProductEntryImpl.setUserName(scProductEntry.getUserName());
353                    scProductEntryImpl.setCreateDate(scProductEntry.getCreateDate());
354                    scProductEntryImpl.setModifiedDate(scProductEntry.getModifiedDate());
355                    scProductEntryImpl.setName(scProductEntry.getName());
356                    scProductEntryImpl.setType(scProductEntry.getType());
357                    scProductEntryImpl.setTags(scProductEntry.getTags());
358                    scProductEntryImpl.setShortDescription(scProductEntry.getShortDescription());
359                    scProductEntryImpl.setLongDescription(scProductEntry.getLongDescription());
360                    scProductEntryImpl.setPageURL(scProductEntry.getPageURL());
361                    scProductEntryImpl.setAuthor(scProductEntry.getAuthor());
362                    scProductEntryImpl.setRepoGroupId(scProductEntry.getRepoGroupId());
363                    scProductEntryImpl.setRepoArtifactId(scProductEntry.getRepoArtifactId());
364    
365                    return scProductEntryImpl;
366            }
367    
368            public SCProductEntry findByPrimaryKey(Serializable primaryKey)
369                    throws NoSuchModelException, SystemException {
370                    return findByPrimaryKey(((Long)primaryKey).longValue());
371            }
372    
373            public SCProductEntry findByPrimaryKey(long productEntryId)
374                    throws NoSuchProductEntryException, SystemException {
375                    SCProductEntry scProductEntry = fetchByPrimaryKey(productEntryId);
376    
377                    if (scProductEntry == null) {
378                            if (_log.isWarnEnabled()) {
379                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + productEntryId);
380                            }
381    
382                            throw new NoSuchProductEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
383                                    productEntryId);
384                    }
385    
386                    return scProductEntry;
387            }
388    
389            public SCProductEntry fetchByPrimaryKey(Serializable primaryKey)
390                    throws SystemException {
391                    return fetchByPrimaryKey(((Long)primaryKey).longValue());
392            }
393    
394            public SCProductEntry fetchByPrimaryKey(long productEntryId)
395                    throws SystemException {
396                    SCProductEntry scProductEntry = (SCProductEntry)EntityCacheUtil.getResult(SCProductEntryModelImpl.ENTITY_CACHE_ENABLED,
397                                    SCProductEntryImpl.class, productEntryId, this);
398    
399                    if (scProductEntry == null) {
400                            Session session = null;
401    
402                            try {
403                                    session = openSession();
404    
405                                    scProductEntry = (SCProductEntry)session.get(SCProductEntryImpl.class,
406                                                    new Long(productEntryId));
407                            }
408                            catch (Exception e) {
409                                    throw processException(e);
410                            }
411                            finally {
412                                    if (scProductEntry != null) {
413                                            cacheResult(scProductEntry);
414                                    }
415    
416                                    closeSession(session);
417                            }
418                    }
419    
420                    return scProductEntry;
421            }
422    
423            public List<SCProductEntry> findByGroupId(long groupId)
424                    throws SystemException {
425                    return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
426            }
427    
428            public List<SCProductEntry> findByGroupId(long groupId, int start, int end)
429                    throws SystemException {
430                    return findByGroupId(groupId, start, end, null);
431            }
432    
433            public List<SCProductEntry> findByGroupId(long groupId, int start, int end,
434                    OrderByComparator orderByComparator) throws SystemException {
435                    Object[] finderArgs = new Object[] {
436                                    groupId,
437                                    
438                                    String.valueOf(start), String.valueOf(end),
439                                    String.valueOf(orderByComparator)
440                            };
441    
442                    List<SCProductEntry> list = (List<SCProductEntry>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_GROUPID,
443                                    finderArgs, this);
444    
445                    if (list == null) {
446                            Session session = null;
447    
448                            try {
449                                    session = openSession();
450    
451                                    StringBundler query = null;
452    
453                                    if (orderByComparator != null) {
454                                            query = new StringBundler(3 +
455                                                            (orderByComparator.getOrderByFields().length * 3));
456                                    }
457                                    else {
458                                            query = new StringBundler(3);
459                                    }
460    
461                                    query.append(_SQL_SELECT_SCPRODUCTENTRY_WHERE);
462    
463                                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
464    
465                                    if (orderByComparator != null) {
466                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
467                                                    orderByComparator);
468                                    }
469    
470                                    else {
471                                            query.append(SCProductEntryModelImpl.ORDER_BY_JPQL);
472                                    }
473    
474                                    String sql = query.toString();
475    
476                                    Query q = session.createQuery(sql);
477    
478                                    QueryPos qPos = QueryPos.getInstance(q);
479    
480                                    qPos.add(groupId);
481    
482                                    list = (List<SCProductEntry>)QueryUtil.list(q, getDialect(),
483                                                    start, end);
484                            }
485                            catch (Exception e) {
486                                    throw processException(e);
487                            }
488                            finally {
489                                    if (list == null) {
490                                            list = new ArrayList<SCProductEntry>();
491                                    }
492    
493                                    cacheResult(list);
494    
495                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_GROUPID,
496                                            finderArgs, list);
497    
498                                    closeSession(session);
499                            }
500                    }
501    
502                    return list;
503            }
504    
505            public SCProductEntry findByGroupId_First(long groupId,
506                    OrderByComparator orderByComparator)
507                    throws NoSuchProductEntryException, SystemException {
508                    List<SCProductEntry> list = findByGroupId(groupId, 0, 1,
509                                    orderByComparator);
510    
511                    if (list.isEmpty()) {
512                            StringBundler msg = new StringBundler(4);
513    
514                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
515    
516                            msg.append("groupId=");
517                            msg.append(groupId);
518    
519                            msg.append(StringPool.CLOSE_CURLY_BRACE);
520    
521                            throw new NoSuchProductEntryException(msg.toString());
522                    }
523                    else {
524                            return list.get(0);
525                    }
526            }
527    
528            public SCProductEntry findByGroupId_Last(long groupId,
529                    OrderByComparator orderByComparator)
530                    throws NoSuchProductEntryException, SystemException {
531                    int count = countByGroupId(groupId);
532    
533                    List<SCProductEntry> list = findByGroupId(groupId, count - 1, count,
534                                    orderByComparator);
535    
536                    if (list.isEmpty()) {
537                            StringBundler msg = new StringBundler(4);
538    
539                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
540    
541                            msg.append("groupId=");
542                            msg.append(groupId);
543    
544                            msg.append(StringPool.CLOSE_CURLY_BRACE);
545    
546                            throw new NoSuchProductEntryException(msg.toString());
547                    }
548                    else {
549                            return list.get(0);
550                    }
551            }
552    
553            public SCProductEntry[] findByGroupId_PrevAndNext(long productEntryId,
554                    long groupId, OrderByComparator orderByComparator)
555                    throws NoSuchProductEntryException, SystemException {
556                    SCProductEntry scProductEntry = findByPrimaryKey(productEntryId);
557    
558                    Session session = null;
559    
560                    try {
561                            session = openSession();
562    
563                            SCProductEntry[] array = new SCProductEntryImpl[3];
564    
565                            array[0] = getByGroupId_PrevAndNext(session, scProductEntry,
566                                            groupId, orderByComparator, true);
567    
568                            array[1] = scProductEntry;
569    
570                            array[2] = getByGroupId_PrevAndNext(session, scProductEntry,
571                                            groupId, orderByComparator, false);
572    
573                            return array;
574                    }
575                    catch (Exception e) {
576                            throw processException(e);
577                    }
578                    finally {
579                            closeSession(session);
580                    }
581            }
582    
583            protected SCProductEntry getByGroupId_PrevAndNext(Session session,
584                    SCProductEntry scProductEntry, long groupId,
585                    OrderByComparator orderByComparator, boolean previous) {
586                    StringBundler query = null;
587    
588                    if (orderByComparator != null) {
589                            query = new StringBundler(6 +
590                                            (orderByComparator.getOrderByFields().length * 6));
591                    }
592                    else {
593                            query = new StringBundler(3);
594                    }
595    
596                    query.append(_SQL_SELECT_SCPRODUCTENTRY_WHERE);
597    
598                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
599    
600                    if (orderByComparator != null) {
601                            String[] orderByFields = orderByComparator.getOrderByFields();
602    
603                            if (orderByFields.length > 0) {
604                                    query.append(WHERE_AND);
605                            }
606    
607                            for (int i = 0; i < orderByFields.length; i++) {
608                                    query.append(_ORDER_BY_ENTITY_ALIAS);
609                                    query.append(orderByFields[i]);
610    
611                                    if ((i + 1) < orderByFields.length) {
612                                            if (orderByComparator.isAscending() ^ previous) {
613                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
614                                            }
615                                            else {
616                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
617                                            }
618                                    }
619                                    else {
620                                            if (orderByComparator.isAscending() ^ previous) {
621                                                    query.append(WHERE_GREATER_THAN);
622                                            }
623                                            else {
624                                                    query.append(WHERE_LESSER_THAN);
625                                            }
626                                    }
627                            }
628    
629                            query.append(ORDER_BY_CLAUSE);
630    
631                            for (int i = 0; i < orderByFields.length; i++) {
632                                    query.append(_ORDER_BY_ENTITY_ALIAS);
633                                    query.append(orderByFields[i]);
634    
635                                    if ((i + 1) < orderByFields.length) {
636                                            if (orderByComparator.isAscending() ^ previous) {
637                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
638                                            }
639                                            else {
640                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
641                                            }
642                                    }
643                                    else {
644                                            if (orderByComparator.isAscending() ^ previous) {
645                                                    query.append(ORDER_BY_ASC);
646                                            }
647                                            else {
648                                                    query.append(ORDER_BY_DESC);
649                                            }
650                                    }
651                            }
652                    }
653    
654                    else {
655                            query.append(SCProductEntryModelImpl.ORDER_BY_JPQL);
656                    }
657    
658                    String sql = query.toString();
659    
660                    Query q = session.createQuery(sql);
661    
662                    q.setFirstResult(0);
663                    q.setMaxResults(2);
664    
665                    QueryPos qPos = QueryPos.getInstance(q);
666    
667                    qPos.add(groupId);
668    
669                    if (orderByComparator != null) {
670                            Object[] values = orderByComparator.getOrderByValues(scProductEntry);
671    
672                            for (Object value : values) {
673                                    qPos.add(value);
674                            }
675                    }
676    
677                    List<SCProductEntry> list = q.list();
678    
679                    if (list.size() == 2) {
680                            return list.get(1);
681                    }
682                    else {
683                            return null;
684                    }
685            }
686    
687            public List<SCProductEntry> filterFindByGroupId(long groupId)
688                    throws SystemException {
689                    return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
690                            QueryUtil.ALL_POS, null);
691            }
692    
693            public List<SCProductEntry> filterFindByGroupId(long groupId, int start,
694                    int end) throws SystemException {
695                    return filterFindByGroupId(groupId, start, end, null);
696            }
697    
698            public List<SCProductEntry> filterFindByGroupId(long groupId, int start,
699                    int end, OrderByComparator orderByComparator) throws SystemException {
700                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
701                            return findByGroupId(groupId, start, end, orderByComparator);
702                    }
703    
704                    Session session = null;
705    
706                    try {
707                            session = openSession();
708    
709                            StringBundler query = null;
710    
711                            if (orderByComparator != null) {
712                                    query = new StringBundler(3 +
713                                                    (orderByComparator.getOrderByFields().length * 3));
714                            }
715                            else {
716                                    query = new StringBundler(3);
717                            }
718    
719                            query.append(_FILTER_SQL_SELECT_SCPRODUCTENTRY_WHERE);
720    
721                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
722    
723                            if (orderByComparator != null) {
724                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
725                                            orderByComparator);
726                            }
727    
728                            else {
729                                    query.append(SCProductEntryModelImpl.ORDER_BY_JPQL);
730                            }
731    
732                            String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
733                                            SCProductEntry.class.getName(), _FILTER_COLUMN_PK,
734                                            _FILTER_COLUMN_USERID, groupId);
735    
736                            SQLQuery q = session.createSQLQuery(sql);
737    
738                            q.addEntity(_FILTER_ENTITY_ALIAS, SCProductEntryImpl.class);
739    
740                            QueryPos qPos = QueryPos.getInstance(q);
741    
742                            qPos.add(groupId);
743    
744                            return (List<SCProductEntry>)QueryUtil.list(q, getDialect(), start,
745                                    end);
746                    }
747                    catch (Exception e) {
748                            throw processException(e);
749                    }
750                    finally {
751                            closeSession(session);
752                    }
753            }
754    
755            public List<SCProductEntry> findByCompanyId(long companyId)
756                    throws SystemException {
757                    return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
758                            null);
759            }
760    
761            public List<SCProductEntry> findByCompanyId(long companyId, int start,
762                    int end) throws SystemException {
763                    return findByCompanyId(companyId, start, end, null);
764            }
765    
766            public List<SCProductEntry> findByCompanyId(long companyId, int start,
767                    int end, OrderByComparator orderByComparator) throws SystemException {
768                    Object[] finderArgs = new Object[] {
769                                    companyId,
770                                    
771                                    String.valueOf(start), String.valueOf(end),
772                                    String.valueOf(orderByComparator)
773                            };
774    
775                    List<SCProductEntry> list = (List<SCProductEntry>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_COMPANYID,
776                                    finderArgs, this);
777    
778                    if (list == null) {
779                            Session session = null;
780    
781                            try {
782                                    session = openSession();
783    
784                                    StringBundler query = null;
785    
786                                    if (orderByComparator != null) {
787                                            query = new StringBundler(3 +
788                                                            (orderByComparator.getOrderByFields().length * 3));
789                                    }
790                                    else {
791                                            query = new StringBundler(3);
792                                    }
793    
794                                    query.append(_SQL_SELECT_SCPRODUCTENTRY_WHERE);
795    
796                                    query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
797    
798                                    if (orderByComparator != null) {
799                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
800                                                    orderByComparator);
801                                    }
802    
803                                    else {
804                                            query.append(SCProductEntryModelImpl.ORDER_BY_JPQL);
805                                    }
806    
807                                    String sql = query.toString();
808    
809                                    Query q = session.createQuery(sql);
810    
811                                    QueryPos qPos = QueryPos.getInstance(q);
812    
813                                    qPos.add(companyId);
814    
815                                    list = (List<SCProductEntry>)QueryUtil.list(q, getDialect(),
816                                                    start, end);
817                            }
818                            catch (Exception e) {
819                                    throw processException(e);
820                            }
821                            finally {
822                                    if (list == null) {
823                                            list = new ArrayList<SCProductEntry>();
824                                    }
825    
826                                    cacheResult(list);
827    
828                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_COMPANYID,
829                                            finderArgs, list);
830    
831                                    closeSession(session);
832                            }
833                    }
834    
835                    return list;
836            }
837    
838            public SCProductEntry findByCompanyId_First(long companyId,
839                    OrderByComparator orderByComparator)
840                    throws NoSuchProductEntryException, SystemException {
841                    List<SCProductEntry> list = findByCompanyId(companyId, 0, 1,
842                                    orderByComparator);
843    
844                    if (list.isEmpty()) {
845                            StringBundler msg = new StringBundler(4);
846    
847                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
848    
849                            msg.append("companyId=");
850                            msg.append(companyId);
851    
852                            msg.append(StringPool.CLOSE_CURLY_BRACE);
853    
854                            throw new NoSuchProductEntryException(msg.toString());
855                    }
856                    else {
857                            return list.get(0);
858                    }
859            }
860    
861            public SCProductEntry findByCompanyId_Last(long companyId,
862                    OrderByComparator orderByComparator)
863                    throws NoSuchProductEntryException, SystemException {
864                    int count = countByCompanyId(companyId);
865    
866                    List<SCProductEntry> list = findByCompanyId(companyId, count - 1,
867                                    count, orderByComparator);
868    
869                    if (list.isEmpty()) {
870                            StringBundler msg = new StringBundler(4);
871    
872                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
873    
874                            msg.append("companyId=");
875                            msg.append(companyId);
876    
877                            msg.append(StringPool.CLOSE_CURLY_BRACE);
878    
879                            throw new NoSuchProductEntryException(msg.toString());
880                    }
881                    else {
882                            return list.get(0);
883                    }
884            }
885    
886            public SCProductEntry[] findByCompanyId_PrevAndNext(long productEntryId,
887                    long companyId, OrderByComparator orderByComparator)
888                    throws NoSuchProductEntryException, SystemException {
889                    SCProductEntry scProductEntry = findByPrimaryKey(productEntryId);
890    
891                    Session session = null;
892    
893                    try {
894                            session = openSession();
895    
896                            SCProductEntry[] array = new SCProductEntryImpl[3];
897    
898                            array[0] = getByCompanyId_PrevAndNext(session, scProductEntry,
899                                            companyId, orderByComparator, true);
900    
901                            array[1] = scProductEntry;
902    
903                            array[2] = getByCompanyId_PrevAndNext(session, scProductEntry,
904                                            companyId, orderByComparator, false);
905    
906                            return array;
907                    }
908                    catch (Exception e) {
909                            throw processException(e);
910                    }
911                    finally {
912                            closeSession(session);
913                    }
914            }
915    
916            protected SCProductEntry getByCompanyId_PrevAndNext(Session session,
917                    SCProductEntry scProductEntry, long companyId,
918                    OrderByComparator orderByComparator, boolean previous) {
919                    StringBundler query = null;
920    
921                    if (orderByComparator != null) {
922                            query = new StringBundler(6 +
923                                            (orderByComparator.getOrderByFields().length * 6));
924                    }
925                    else {
926                            query = new StringBundler(3);
927                    }
928    
929                    query.append(_SQL_SELECT_SCPRODUCTENTRY_WHERE);
930    
931                    query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
932    
933                    if (orderByComparator != null) {
934                            String[] orderByFields = orderByComparator.getOrderByFields();
935    
936                            if (orderByFields.length > 0) {
937                                    query.append(WHERE_AND);
938                            }
939    
940                            for (int i = 0; i < orderByFields.length; i++) {
941                                    query.append(_ORDER_BY_ENTITY_ALIAS);
942                                    query.append(orderByFields[i]);
943    
944                                    if ((i + 1) < orderByFields.length) {
945                                            if (orderByComparator.isAscending() ^ previous) {
946                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
947                                            }
948                                            else {
949                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
950                                            }
951                                    }
952                                    else {
953                                            if (orderByComparator.isAscending() ^ previous) {
954                                                    query.append(WHERE_GREATER_THAN);
955                                            }
956                                            else {
957                                                    query.append(WHERE_LESSER_THAN);
958                                            }
959                                    }
960                            }
961    
962                            query.append(ORDER_BY_CLAUSE);
963    
964                            for (int i = 0; i < orderByFields.length; i++) {
965                                    query.append(_ORDER_BY_ENTITY_ALIAS);
966                                    query.append(orderByFields[i]);
967    
968                                    if ((i + 1) < orderByFields.length) {
969                                            if (orderByComparator.isAscending() ^ previous) {
970                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
971                                            }
972                                            else {
973                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
974                                            }
975                                    }
976                                    else {
977                                            if (orderByComparator.isAscending() ^ previous) {
978                                                    query.append(ORDER_BY_ASC);
979                                            }
980                                            else {
981                                                    query.append(ORDER_BY_DESC);
982                                            }
983                                    }
984                            }
985                    }
986    
987                    else {
988                            query.append(SCProductEntryModelImpl.ORDER_BY_JPQL);
989                    }
990    
991                    String sql = query.toString();
992    
993                    Query q = session.createQuery(sql);
994    
995                    q.setFirstResult(0);
996                    q.setMaxResults(2);
997    
998                    QueryPos qPos = QueryPos.getInstance(q);
999    
1000                    qPos.add(companyId);
1001    
1002                    if (orderByComparator != null) {
1003                            Object[] values = orderByComparator.getOrderByValues(scProductEntry);
1004    
1005                            for (Object value : values) {
1006                                    qPos.add(value);
1007                            }
1008                    }
1009    
1010                    List<SCProductEntry> list = q.list();
1011    
1012                    if (list.size() == 2) {
1013                            return list.get(1);
1014                    }
1015                    else {
1016                            return null;
1017                    }
1018            }
1019    
1020            public List<SCProductEntry> findByG_U(long groupId, long userId)
1021                    throws SystemException {
1022                    return findByG_U(groupId, userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
1023                            null);
1024            }
1025    
1026            public List<SCProductEntry> findByG_U(long groupId, long userId, int start,
1027                    int end) throws SystemException {
1028                    return findByG_U(groupId, userId, start, end, null);
1029            }
1030    
1031            public List<SCProductEntry> findByG_U(long groupId, long userId, int start,
1032                    int end, OrderByComparator orderByComparator) throws SystemException {
1033                    Object[] finderArgs = new Object[] {
1034                                    groupId, userId,
1035                                    
1036                                    String.valueOf(start), String.valueOf(end),
1037                                    String.valueOf(orderByComparator)
1038                            };
1039    
1040                    List<SCProductEntry> list = (List<SCProductEntry>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_G_U,
1041                                    finderArgs, this);
1042    
1043                    if (list == null) {
1044                            Session session = null;
1045    
1046                            try {
1047                                    session = openSession();
1048    
1049                                    StringBundler query = null;
1050    
1051                                    if (orderByComparator != null) {
1052                                            query = new StringBundler(4 +
1053                                                            (orderByComparator.getOrderByFields().length * 3));
1054                                    }
1055                                    else {
1056                                            query = new StringBundler(4);
1057                                    }
1058    
1059                                    query.append(_SQL_SELECT_SCPRODUCTENTRY_WHERE);
1060    
1061                                    query.append(_FINDER_COLUMN_G_U_GROUPID_2);
1062    
1063                                    query.append(_FINDER_COLUMN_G_U_USERID_2);
1064    
1065                                    if (orderByComparator != null) {
1066                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1067                                                    orderByComparator);
1068                                    }
1069    
1070                                    else {
1071                                            query.append(SCProductEntryModelImpl.ORDER_BY_JPQL);
1072                                    }
1073    
1074                                    String sql = query.toString();
1075    
1076                                    Query q = session.createQuery(sql);
1077    
1078                                    QueryPos qPos = QueryPos.getInstance(q);
1079    
1080                                    qPos.add(groupId);
1081    
1082                                    qPos.add(userId);
1083    
1084                                    list = (List<SCProductEntry>)QueryUtil.list(q, getDialect(),
1085                                                    start, end);
1086                            }
1087                            catch (Exception e) {
1088                                    throw processException(e);
1089                            }
1090                            finally {
1091                                    if (list == null) {
1092                                            list = new ArrayList<SCProductEntry>();
1093                                    }
1094    
1095                                    cacheResult(list);
1096    
1097                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_G_U, finderArgs,
1098                                            list);
1099    
1100                                    closeSession(session);
1101                            }
1102                    }
1103    
1104                    return list;
1105            }
1106    
1107            public SCProductEntry findByG_U_First(long groupId, long userId,
1108                    OrderByComparator orderByComparator)
1109                    throws NoSuchProductEntryException, SystemException {
1110                    List<SCProductEntry> list = findByG_U(groupId, userId, 0, 1,
1111                                    orderByComparator);
1112    
1113                    if (list.isEmpty()) {
1114                            StringBundler msg = new StringBundler(6);
1115    
1116                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1117    
1118                            msg.append("groupId=");
1119                            msg.append(groupId);
1120    
1121                            msg.append(", userId=");
1122                            msg.append(userId);
1123    
1124                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1125    
1126                            throw new NoSuchProductEntryException(msg.toString());
1127                    }
1128                    else {
1129                            return list.get(0);
1130                    }
1131            }
1132    
1133            public SCProductEntry findByG_U_Last(long groupId, long userId,
1134                    OrderByComparator orderByComparator)
1135                    throws NoSuchProductEntryException, SystemException {
1136                    int count = countByG_U(groupId, userId);
1137    
1138                    List<SCProductEntry> list = findByG_U(groupId, userId, count - 1,
1139                                    count, orderByComparator);
1140    
1141                    if (list.isEmpty()) {
1142                            StringBundler msg = new StringBundler(6);
1143    
1144                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1145    
1146                            msg.append("groupId=");
1147                            msg.append(groupId);
1148    
1149                            msg.append(", userId=");
1150                            msg.append(userId);
1151    
1152                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1153    
1154                            throw new NoSuchProductEntryException(msg.toString());
1155                    }
1156                    else {
1157                            return list.get(0);
1158                    }
1159            }
1160    
1161            public SCProductEntry[] findByG_U_PrevAndNext(long productEntryId,
1162                    long groupId, long userId, OrderByComparator orderByComparator)
1163                    throws NoSuchProductEntryException, SystemException {
1164                    SCProductEntry scProductEntry = findByPrimaryKey(productEntryId);
1165    
1166                    Session session = null;
1167    
1168                    try {
1169                            session = openSession();
1170    
1171                            SCProductEntry[] array = new SCProductEntryImpl[3];
1172    
1173                            array[0] = getByG_U_PrevAndNext(session, scProductEntry, groupId,
1174                                            userId, orderByComparator, true);
1175    
1176                            array[1] = scProductEntry;
1177    
1178                            array[2] = getByG_U_PrevAndNext(session, scProductEntry, groupId,
1179                                            userId, orderByComparator, false);
1180    
1181                            return array;
1182                    }
1183                    catch (Exception e) {
1184                            throw processException(e);
1185                    }
1186                    finally {
1187                            closeSession(session);
1188                    }
1189            }
1190    
1191            protected SCProductEntry getByG_U_PrevAndNext(Session session,
1192                    SCProductEntry scProductEntry, long groupId, long userId,
1193                    OrderByComparator orderByComparator, boolean previous) {
1194                    StringBundler query = null;
1195    
1196                    if (orderByComparator != null) {
1197                            query = new StringBundler(6 +
1198                                            (orderByComparator.getOrderByFields().length * 6));
1199                    }
1200                    else {
1201                            query = new StringBundler(3);
1202                    }
1203    
1204                    query.append(_SQL_SELECT_SCPRODUCTENTRY_WHERE);
1205    
1206                    query.append(_FINDER_COLUMN_G_U_GROUPID_2);
1207    
1208                    query.append(_FINDER_COLUMN_G_U_USERID_2);
1209    
1210                    if (orderByComparator != null) {
1211                            String[] orderByFields = orderByComparator.getOrderByFields();
1212    
1213                            if (orderByFields.length > 0) {
1214                                    query.append(WHERE_AND);
1215                            }
1216    
1217                            for (int i = 0; i < orderByFields.length; i++) {
1218                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1219                                    query.append(orderByFields[i]);
1220    
1221                                    if ((i + 1) < orderByFields.length) {
1222                                            if (orderByComparator.isAscending() ^ previous) {
1223                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1224                                            }
1225                                            else {
1226                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1227                                            }
1228                                    }
1229                                    else {
1230                                            if (orderByComparator.isAscending() ^ previous) {
1231                                                    query.append(WHERE_GREATER_THAN);
1232                                            }
1233                                            else {
1234                                                    query.append(WHERE_LESSER_THAN);
1235                                            }
1236                                    }
1237                            }
1238    
1239                            query.append(ORDER_BY_CLAUSE);
1240    
1241                            for (int i = 0; i < orderByFields.length; i++) {
1242                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1243                                    query.append(orderByFields[i]);
1244    
1245                                    if ((i + 1) < orderByFields.length) {
1246                                            if (orderByComparator.isAscending() ^ previous) {
1247                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1248                                            }
1249                                            else {
1250                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1251                                            }
1252                                    }
1253                                    else {
1254                                            if (orderByComparator.isAscending() ^ previous) {
1255                                                    query.append(ORDER_BY_ASC);
1256                                            }
1257                                            else {
1258                                                    query.append(ORDER_BY_DESC);
1259                                            }
1260                                    }
1261                            }
1262                    }
1263    
1264                    else {
1265                            query.append(SCProductEntryModelImpl.ORDER_BY_JPQL);
1266                    }
1267    
1268                    String sql = query.toString();
1269    
1270                    Query q = session.createQuery(sql);
1271    
1272                    q.setFirstResult(0);
1273                    q.setMaxResults(2);
1274    
1275                    QueryPos qPos = QueryPos.getInstance(q);
1276    
1277                    qPos.add(groupId);
1278    
1279                    qPos.add(userId);
1280    
1281                    if (orderByComparator != null) {
1282                            Object[] values = orderByComparator.getOrderByValues(scProductEntry);
1283    
1284                            for (Object value : values) {
1285                                    qPos.add(value);
1286                            }
1287                    }
1288    
1289                    List<SCProductEntry> list = q.list();
1290    
1291                    if (list.size() == 2) {
1292                            return list.get(1);
1293                    }
1294                    else {
1295                            return null;
1296                    }
1297            }
1298    
1299            public List<SCProductEntry> filterFindByG_U(long groupId, long userId)
1300                    throws SystemException {
1301                    return filterFindByG_U(groupId, userId, QueryUtil.ALL_POS,
1302                            QueryUtil.ALL_POS, null);
1303            }
1304    
1305            public List<SCProductEntry> filterFindByG_U(long groupId, long userId,
1306                    int start, int end) throws SystemException {
1307                    return filterFindByG_U(groupId, userId, start, end, null);
1308            }
1309    
1310            public List<SCProductEntry> filterFindByG_U(long groupId, long userId,
1311                    int start, int end, OrderByComparator orderByComparator)
1312                    throws SystemException {
1313                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1314                            return findByG_U(groupId, userId, start, end, orderByComparator);
1315                    }
1316    
1317                    Session session = null;
1318    
1319                    try {
1320                            session = openSession();
1321    
1322                            StringBundler query = null;
1323    
1324                            if (orderByComparator != null) {
1325                                    query = new StringBundler(4 +
1326                                                    (orderByComparator.getOrderByFields().length * 3));
1327                            }
1328                            else {
1329                                    query = new StringBundler(4);
1330                            }
1331    
1332                            query.append(_FILTER_SQL_SELECT_SCPRODUCTENTRY_WHERE);
1333    
1334                            query.append(_FINDER_COLUMN_G_U_GROUPID_2);
1335    
1336                            query.append(_FINDER_COLUMN_G_U_USERID_2);
1337    
1338                            if (orderByComparator != null) {
1339                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1340                                            orderByComparator);
1341                            }
1342    
1343                            else {
1344                                    query.append(SCProductEntryModelImpl.ORDER_BY_JPQL);
1345                            }
1346    
1347                            String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1348                                            SCProductEntry.class.getName(), _FILTER_COLUMN_PK,
1349                                            _FILTER_COLUMN_USERID, groupId);
1350    
1351                            SQLQuery q = session.createSQLQuery(sql);
1352    
1353                            q.addEntity(_FILTER_ENTITY_ALIAS, SCProductEntryImpl.class);
1354    
1355                            QueryPos qPos = QueryPos.getInstance(q);
1356    
1357                            qPos.add(groupId);
1358    
1359                            qPos.add(userId);
1360    
1361                            return (List<SCProductEntry>)QueryUtil.list(q, getDialect(), start,
1362                                    end);
1363                    }
1364                    catch (Exception e) {
1365                            throw processException(e);
1366                    }
1367                    finally {
1368                            closeSession(session);
1369                    }
1370            }
1371    
1372            public SCProductEntry findByRG_RA(String repoGroupId, String repoArtifactId)
1373                    throws NoSuchProductEntryException, SystemException {
1374                    SCProductEntry scProductEntry = fetchByRG_RA(repoGroupId, repoArtifactId);
1375    
1376                    if (scProductEntry == null) {
1377                            StringBundler msg = new StringBundler(6);
1378    
1379                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1380    
1381                            msg.append("repoGroupId=");
1382                            msg.append(repoGroupId);
1383    
1384                            msg.append(", repoArtifactId=");
1385                            msg.append(repoArtifactId);
1386    
1387                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1388    
1389                            if (_log.isWarnEnabled()) {
1390                                    _log.warn(msg.toString());
1391                            }
1392    
1393                            throw new NoSuchProductEntryException(msg.toString());
1394                    }
1395    
1396                    return scProductEntry;
1397            }
1398    
1399            public SCProductEntry fetchByRG_RA(String repoGroupId, String repoArtifactId)
1400                    throws SystemException {
1401                    return fetchByRG_RA(repoGroupId, repoArtifactId, true);
1402            }
1403    
1404            public SCProductEntry fetchByRG_RA(String repoGroupId,
1405                    String repoArtifactId, boolean retrieveFromCache)
1406                    throws SystemException {
1407                    Object[] finderArgs = new Object[] { repoGroupId, repoArtifactId };
1408    
1409                    Object result = null;
1410    
1411                    if (retrieveFromCache) {
1412                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_RG_RA,
1413                                            finderArgs, this);
1414                    }
1415    
1416                    if (result == null) {
1417                            Session session = null;
1418    
1419                            try {
1420                                    session = openSession();
1421    
1422                                    StringBundler query = new StringBundler(4);
1423    
1424                                    query.append(_SQL_SELECT_SCPRODUCTENTRY_WHERE);
1425    
1426                                    if (repoGroupId == null) {
1427                                            query.append(_FINDER_COLUMN_RG_RA_REPOGROUPID_1);
1428                                    }
1429                                    else {
1430                                            if (repoGroupId.equals(StringPool.BLANK)) {
1431                                                    query.append(_FINDER_COLUMN_RG_RA_REPOGROUPID_3);
1432                                            }
1433                                            else {
1434                                                    query.append(_FINDER_COLUMN_RG_RA_REPOGROUPID_2);
1435                                            }
1436                                    }
1437    
1438                                    if (repoArtifactId == null) {
1439                                            query.append(_FINDER_COLUMN_RG_RA_REPOARTIFACTID_1);
1440                                    }
1441                                    else {
1442                                            if (repoArtifactId.equals(StringPool.BLANK)) {
1443                                                    query.append(_FINDER_COLUMN_RG_RA_REPOARTIFACTID_3);
1444                                            }
1445                                            else {
1446                                                    query.append(_FINDER_COLUMN_RG_RA_REPOARTIFACTID_2);
1447                                            }
1448                                    }
1449    
1450                                    query.append(SCProductEntryModelImpl.ORDER_BY_JPQL);
1451    
1452                                    String sql = query.toString();
1453    
1454                                    Query q = session.createQuery(sql);
1455    
1456                                    QueryPos qPos = QueryPos.getInstance(q);
1457    
1458                                    if (repoGroupId != null) {
1459                                            qPos.add(repoGroupId);
1460                                    }
1461    
1462                                    if (repoArtifactId != null) {
1463                                            qPos.add(repoArtifactId);
1464                                    }
1465    
1466                                    List<SCProductEntry> list = q.list();
1467    
1468                                    result = list;
1469    
1470                                    SCProductEntry scProductEntry = null;
1471    
1472                                    if (list.isEmpty()) {
1473                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_RG_RA,
1474                                                    finderArgs, list);
1475                                    }
1476                                    else {
1477                                            scProductEntry = list.get(0);
1478    
1479                                            cacheResult(scProductEntry);
1480    
1481                                            if ((scProductEntry.getRepoGroupId() == null) ||
1482                                                            !scProductEntry.getRepoGroupId().equals(repoGroupId) ||
1483                                                            (scProductEntry.getRepoArtifactId() == null) ||
1484                                                            !scProductEntry.getRepoArtifactId()
1485                                                                                               .equals(repoArtifactId)) {
1486                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_RG_RA,
1487                                                            finderArgs, scProductEntry);
1488                                            }
1489                                    }
1490    
1491                                    return scProductEntry;
1492                            }
1493                            catch (Exception e) {
1494                                    throw processException(e);
1495                            }
1496                            finally {
1497                                    if (result == null) {
1498                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_RG_RA,
1499                                                    finderArgs, new ArrayList<SCProductEntry>());
1500                                    }
1501    
1502                                    closeSession(session);
1503                            }
1504                    }
1505                    else {
1506                            if (result instanceof List<?>) {
1507                                    return null;
1508                            }
1509                            else {
1510                                    return (SCProductEntry)result;
1511                            }
1512                    }
1513            }
1514    
1515            public List<SCProductEntry> findAll() throws SystemException {
1516                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1517            }
1518    
1519            public List<SCProductEntry> findAll(int start, int end)
1520                    throws SystemException {
1521                    return findAll(start, end, null);
1522            }
1523    
1524            public List<SCProductEntry> findAll(int start, int end,
1525                    OrderByComparator orderByComparator) throws SystemException {
1526                    Object[] finderArgs = new Object[] {
1527                                    String.valueOf(start), String.valueOf(end),
1528                                    String.valueOf(orderByComparator)
1529                            };
1530    
1531                    List<SCProductEntry> list = (List<SCProductEntry>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
1532                                    finderArgs, this);
1533    
1534                    if (list == null) {
1535                            Session session = null;
1536    
1537                            try {
1538                                    session = openSession();
1539    
1540                                    StringBundler query = null;
1541                                    String sql = null;
1542    
1543                                    if (orderByComparator != null) {
1544                                            query = new StringBundler(2 +
1545                                                            (orderByComparator.getOrderByFields().length * 3));
1546    
1547                                            query.append(_SQL_SELECT_SCPRODUCTENTRY);
1548    
1549                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1550                                                    orderByComparator);
1551    
1552                                            sql = query.toString();
1553                                    }
1554                                    else {
1555                                            sql = _SQL_SELECT_SCPRODUCTENTRY.concat(SCProductEntryModelImpl.ORDER_BY_JPQL);
1556                                    }
1557    
1558                                    Query q = session.createQuery(sql);
1559    
1560                                    if (orderByComparator == null) {
1561                                            list = (List<SCProductEntry>)QueryUtil.list(q,
1562                                                            getDialect(), start, end, false);
1563    
1564                                            Collections.sort(list);
1565                                    }
1566                                    else {
1567                                            list = (List<SCProductEntry>)QueryUtil.list(q,
1568                                                            getDialect(), start, end);
1569                                    }
1570                            }
1571                            catch (Exception e) {
1572                                    throw processException(e);
1573                            }
1574                            finally {
1575                                    if (list == null) {
1576                                            list = new ArrayList<SCProductEntry>();
1577                                    }
1578    
1579                                    cacheResult(list);
1580    
1581                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
1582    
1583                                    closeSession(session);
1584                            }
1585                    }
1586    
1587                    return list;
1588            }
1589    
1590            public void removeByGroupId(long groupId) throws SystemException {
1591                    for (SCProductEntry scProductEntry : findByGroupId(groupId)) {
1592                            remove(scProductEntry);
1593                    }
1594            }
1595    
1596            public void removeByCompanyId(long companyId) throws SystemException {
1597                    for (SCProductEntry scProductEntry : findByCompanyId(companyId)) {
1598                            remove(scProductEntry);
1599                    }
1600            }
1601    
1602            public void removeByG_U(long groupId, long userId)
1603                    throws SystemException {
1604                    for (SCProductEntry scProductEntry : findByG_U(groupId, userId)) {
1605                            remove(scProductEntry);
1606                    }
1607            }
1608    
1609            public void removeByRG_RA(String repoGroupId, String repoArtifactId)
1610                    throws NoSuchProductEntryException, SystemException {
1611                    SCProductEntry scProductEntry = findByRG_RA(repoGroupId, repoArtifactId);
1612    
1613                    remove(scProductEntry);
1614            }
1615    
1616            public void removeAll() throws SystemException {
1617                    for (SCProductEntry scProductEntry : findAll()) {
1618                            remove(scProductEntry);
1619                    }
1620            }
1621    
1622            public int countByGroupId(long groupId) throws SystemException {
1623                    Object[] finderArgs = new Object[] { groupId };
1624    
1625                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
1626                                    finderArgs, this);
1627    
1628                    if (count == null) {
1629                            Session session = null;
1630    
1631                            try {
1632                                    session = openSession();
1633    
1634                                    StringBundler query = new StringBundler(2);
1635    
1636                                    query.append(_SQL_COUNT_SCPRODUCTENTRY_WHERE);
1637    
1638                                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1639    
1640                                    String sql = query.toString();
1641    
1642                                    Query q = session.createQuery(sql);
1643    
1644                                    QueryPos qPos = QueryPos.getInstance(q);
1645    
1646                                    qPos.add(groupId);
1647    
1648                                    count = (Long)q.uniqueResult();
1649                            }
1650                            catch (Exception e) {
1651                                    throw processException(e);
1652                            }
1653                            finally {
1654                                    if (count == null) {
1655                                            count = Long.valueOf(0);
1656                                    }
1657    
1658                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
1659                                            finderArgs, count);
1660    
1661                                    closeSession(session);
1662                            }
1663                    }
1664    
1665                    return count.intValue();
1666            }
1667    
1668            public int filterCountByGroupId(long groupId) throws SystemException {
1669                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1670                            return countByGroupId(groupId);
1671                    }
1672    
1673                    Session session = null;
1674    
1675                    try {
1676                            session = openSession();
1677    
1678                            StringBundler query = new StringBundler(2);
1679    
1680                            query.append(_FILTER_SQL_COUNT_SCPRODUCTENTRY_WHERE);
1681    
1682                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1683    
1684                            String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1685                                            SCProductEntry.class.getName(), _FILTER_COLUMN_PK,
1686                                            _FILTER_COLUMN_USERID, groupId);
1687    
1688                            SQLQuery q = session.createSQLQuery(sql);
1689    
1690                            q.addScalar(COUNT_COLUMN_NAME,
1691                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
1692    
1693                            QueryPos qPos = QueryPos.getInstance(q);
1694    
1695                            qPos.add(groupId);
1696    
1697                            Long count = (Long)q.uniqueResult();
1698    
1699                            return count.intValue();
1700                    }
1701                    catch (Exception e) {
1702                            throw processException(e);
1703                    }
1704                    finally {
1705                            closeSession(session);
1706                    }
1707            }
1708    
1709            public int countByCompanyId(long companyId) throws SystemException {
1710                    Object[] finderArgs = new Object[] { companyId };
1711    
1712                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
1713                                    finderArgs, this);
1714    
1715                    if (count == null) {
1716                            Session session = null;
1717    
1718                            try {
1719                                    session = openSession();
1720    
1721                                    StringBundler query = new StringBundler(2);
1722    
1723                                    query.append(_SQL_COUNT_SCPRODUCTENTRY_WHERE);
1724    
1725                                    query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1726    
1727                                    String sql = query.toString();
1728    
1729                                    Query q = session.createQuery(sql);
1730    
1731                                    QueryPos qPos = QueryPos.getInstance(q);
1732    
1733                                    qPos.add(companyId);
1734    
1735                                    count = (Long)q.uniqueResult();
1736                            }
1737                            catch (Exception e) {
1738                                    throw processException(e);
1739                            }
1740                            finally {
1741                                    if (count == null) {
1742                                            count = Long.valueOf(0);
1743                                    }
1744    
1745                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
1746                                            finderArgs, count);
1747    
1748                                    closeSession(session);
1749                            }
1750                    }
1751    
1752                    return count.intValue();
1753            }
1754    
1755            public int countByG_U(long groupId, long userId) throws SystemException {
1756                    Object[] finderArgs = new Object[] { groupId, userId };
1757    
1758                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_U,
1759                                    finderArgs, this);
1760    
1761                    if (count == null) {
1762                            Session session = null;
1763    
1764                            try {
1765                                    session = openSession();
1766    
1767                                    StringBundler query = new StringBundler(3);
1768    
1769                                    query.append(_SQL_COUNT_SCPRODUCTENTRY_WHERE);
1770    
1771                                    query.append(_FINDER_COLUMN_G_U_GROUPID_2);
1772    
1773                                    query.append(_FINDER_COLUMN_G_U_USERID_2);
1774    
1775                                    String sql = query.toString();
1776    
1777                                    Query q = session.createQuery(sql);
1778    
1779                                    QueryPos qPos = QueryPos.getInstance(q);
1780    
1781                                    qPos.add(groupId);
1782    
1783                                    qPos.add(userId);
1784    
1785                                    count = (Long)q.uniqueResult();
1786                            }
1787                            catch (Exception e) {
1788                                    throw processException(e);
1789                            }
1790                            finally {
1791                                    if (count == null) {
1792                                            count = Long.valueOf(0);
1793                                    }
1794    
1795                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_U, finderArgs,
1796                                            count);
1797    
1798                                    closeSession(session);
1799                            }
1800                    }
1801    
1802                    return count.intValue();
1803            }
1804    
1805            public int filterCountByG_U(long groupId, long userId)
1806                    throws SystemException {
1807                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1808                            return countByG_U(groupId, userId);
1809                    }
1810    
1811                    Session session = null;
1812    
1813                    try {
1814                            session = openSession();
1815    
1816                            StringBundler query = new StringBundler(3);
1817    
1818                            query.append(_FILTER_SQL_COUNT_SCPRODUCTENTRY_WHERE);
1819    
1820                            query.append(_FINDER_COLUMN_G_U_GROUPID_2);
1821    
1822                            query.append(_FINDER_COLUMN_G_U_USERID_2);
1823    
1824                            String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1825                                            SCProductEntry.class.getName(), _FILTER_COLUMN_PK,
1826                                            _FILTER_COLUMN_USERID, groupId);
1827    
1828                            SQLQuery q = session.createSQLQuery(sql);
1829    
1830                            q.addScalar(COUNT_COLUMN_NAME,
1831                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
1832    
1833                            QueryPos qPos = QueryPos.getInstance(q);
1834    
1835                            qPos.add(groupId);
1836    
1837                            qPos.add(userId);
1838    
1839                            Long count = (Long)q.uniqueResult();
1840    
1841                            return count.intValue();
1842                    }
1843                    catch (Exception e) {
1844                            throw processException(e);
1845                    }
1846                    finally {
1847                            closeSession(session);
1848                    }
1849            }
1850    
1851            public int countByRG_RA(String repoGroupId, String repoArtifactId)
1852                    throws SystemException {
1853                    Object[] finderArgs = new Object[] { repoGroupId, repoArtifactId };
1854    
1855                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_RG_RA,
1856                                    finderArgs, this);
1857    
1858                    if (count == null) {
1859                            Session session = null;
1860    
1861                            try {
1862                                    session = openSession();
1863    
1864                                    StringBundler query = new StringBundler(3);
1865    
1866                                    query.append(_SQL_COUNT_SCPRODUCTENTRY_WHERE);
1867    
1868                                    if (repoGroupId == null) {
1869                                            query.append(_FINDER_COLUMN_RG_RA_REPOGROUPID_1);
1870                                    }
1871                                    else {
1872                                            if (repoGroupId.equals(StringPool.BLANK)) {
1873                                                    query.append(_FINDER_COLUMN_RG_RA_REPOGROUPID_3);
1874                                            }
1875                                            else {
1876                                                    query.append(_FINDER_COLUMN_RG_RA_REPOGROUPID_2);
1877                                            }
1878                                    }
1879    
1880                                    if (repoArtifactId == null) {
1881                                            query.append(_FINDER_COLUMN_RG_RA_REPOARTIFACTID_1);
1882                                    }
1883                                    else {
1884                                            if (repoArtifactId.equals(StringPool.BLANK)) {
1885                                                    query.append(_FINDER_COLUMN_RG_RA_REPOARTIFACTID_3);
1886                                            }
1887                                            else {
1888                                                    query.append(_FINDER_COLUMN_RG_RA_REPOARTIFACTID_2);
1889                                            }
1890                                    }
1891    
1892                                    String sql = query.toString();
1893    
1894                                    Query q = session.createQuery(sql);
1895    
1896                                    QueryPos qPos = QueryPos.getInstance(q);
1897    
1898                                    if (repoGroupId != null) {
1899                                            qPos.add(repoGroupId);
1900                                    }
1901    
1902                                    if (repoArtifactId != null) {
1903                                            qPos.add(repoArtifactId);
1904                                    }
1905    
1906                                    count = (Long)q.uniqueResult();
1907                            }
1908                            catch (Exception e) {
1909                                    throw processException(e);
1910                            }
1911                            finally {
1912                                    if (count == null) {
1913                                            count = Long.valueOf(0);
1914                                    }
1915    
1916                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_RG_RA,
1917                                            finderArgs, count);
1918    
1919                                    closeSession(session);
1920                            }
1921                    }
1922    
1923                    return count.intValue();
1924            }
1925    
1926            public int countAll() throws SystemException {
1927                    Object[] finderArgs = new Object[0];
1928    
1929                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1930                                    finderArgs, this);
1931    
1932                    if (count == null) {
1933                            Session session = null;
1934    
1935                            try {
1936                                    session = openSession();
1937    
1938                                    Query q = session.createQuery(_SQL_COUNT_SCPRODUCTENTRY);
1939    
1940                                    count = (Long)q.uniqueResult();
1941                            }
1942                            catch (Exception e) {
1943                                    throw processException(e);
1944                            }
1945                            finally {
1946                                    if (count == null) {
1947                                            count = Long.valueOf(0);
1948                                    }
1949    
1950                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
1951                                            count);
1952    
1953                                    closeSession(session);
1954                            }
1955                    }
1956    
1957                    return count.intValue();
1958            }
1959    
1960            public List<com.liferay.portlet.softwarecatalog.model.SCLicense> getSCLicenses(
1961                    long pk) throws SystemException {
1962                    return getSCLicenses(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
1963            }
1964    
1965            public List<com.liferay.portlet.softwarecatalog.model.SCLicense> getSCLicenses(
1966                    long pk, int start, int end) throws SystemException {
1967                    return getSCLicenses(pk, start, end, null);
1968            }
1969    
1970            public static final FinderPath FINDER_PATH_GET_SCLICENSES = new FinderPath(com.liferay.portlet.softwarecatalog.model.impl.SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
1971                            SCProductEntryModelImpl.FINDER_CACHE_ENABLED_SCLICENSES_SCPRODUCTENTRIES,
1972                            SCProductEntryModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME,
1973                            "getSCLicenses",
1974                            new String[] {
1975                                    Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
1976                                    "com.liferay.portal.kernel.util.OrderByComparator"
1977                            });
1978    
1979            public List<com.liferay.portlet.softwarecatalog.model.SCLicense> getSCLicenses(
1980                    long pk, int start, int end, OrderByComparator orderByComparator)
1981                    throws SystemException {
1982                    Object[] finderArgs = new Object[] {
1983                                    pk, String.valueOf(start), String.valueOf(end),
1984                                    String.valueOf(orderByComparator)
1985                            };
1986    
1987                    List<com.liferay.portlet.softwarecatalog.model.SCLicense> list = (List<com.liferay.portlet.softwarecatalog.model.SCLicense>)FinderCacheUtil.getResult(FINDER_PATH_GET_SCLICENSES,
1988                                    finderArgs, this);
1989    
1990                    if (list == null) {
1991                            Session session = null;
1992    
1993                            try {
1994                                    session = openSession();
1995    
1996                                    String sql = null;
1997    
1998                                    if (orderByComparator != null) {
1999                                            sql = _SQL_GETSCLICENSES.concat(ORDER_BY_CLAUSE)
2000                                                                                            .concat(orderByComparator.getOrderBy());
2001                                    }
2002                                    else {
2003                                            sql = _SQL_GETSCLICENSES.concat(com.liferay.portlet.softwarecatalog.model.impl.SCLicenseModelImpl.ORDER_BY_SQL);
2004                                    }
2005    
2006                                    SQLQuery q = session.createSQLQuery(sql);
2007    
2008                                    q.addEntity("SCLicense",
2009                                            com.liferay.portlet.softwarecatalog.model.impl.SCLicenseImpl.class);
2010    
2011                                    QueryPos qPos = QueryPos.getInstance(q);
2012    
2013                                    qPos.add(pk);
2014    
2015                                    list = (List<com.liferay.portlet.softwarecatalog.model.SCLicense>)QueryUtil.list(q,
2016                                                    getDialect(), start, end);
2017                            }
2018                            catch (Exception e) {
2019                                    throw processException(e);
2020                            }
2021                            finally {
2022                                    if (list == null) {
2023                                            list = new ArrayList<com.liferay.portlet.softwarecatalog.model.SCLicense>();
2024                                    }
2025    
2026                                    scLicensePersistence.cacheResult(list);
2027    
2028                                    FinderCacheUtil.putResult(FINDER_PATH_GET_SCLICENSES,
2029                                            finderArgs, list);
2030    
2031                                    closeSession(session);
2032                            }
2033                    }
2034    
2035                    return list;
2036            }
2037    
2038            public static final FinderPath FINDER_PATH_GET_SCLICENSES_SIZE = new FinderPath(com.liferay.portlet.softwarecatalog.model.impl.SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
2039                            SCProductEntryModelImpl.FINDER_CACHE_ENABLED_SCLICENSES_SCPRODUCTENTRIES,
2040                            SCProductEntryModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME,
2041                            "getSCLicensesSize", new String[] { Long.class.getName() });
2042    
2043            public int getSCLicensesSize(long pk) throws SystemException {
2044                    Object[] finderArgs = new Object[] { pk };
2045    
2046                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_SCLICENSES_SIZE,
2047                                    finderArgs, this);
2048    
2049                    if (count == null) {
2050                            Session session = null;
2051    
2052                            try {
2053                                    session = openSession();
2054    
2055                                    SQLQuery q = session.createSQLQuery(_SQL_GETSCLICENSESSIZE);
2056    
2057                                    q.addScalar(COUNT_COLUMN_NAME,
2058                                            com.liferay.portal.kernel.dao.orm.Type.LONG);
2059    
2060                                    QueryPos qPos = QueryPos.getInstance(q);
2061    
2062                                    qPos.add(pk);
2063    
2064                                    count = (Long)q.uniqueResult();
2065                            }
2066                            catch (Exception e) {
2067                                    throw processException(e);
2068                            }
2069                            finally {
2070                                    if (count == null) {
2071                                            count = Long.valueOf(0);
2072                                    }
2073    
2074                                    FinderCacheUtil.putResult(FINDER_PATH_GET_SCLICENSES_SIZE,
2075                                            finderArgs, count);
2076    
2077                                    closeSession(session);
2078                            }
2079                    }
2080    
2081                    return count.intValue();
2082            }
2083    
2084            public static final FinderPath FINDER_PATH_CONTAINS_SCLICENSE = new FinderPath(com.liferay.portlet.softwarecatalog.model.impl.SCLicenseModelImpl.ENTITY_CACHE_ENABLED,
2085                            SCProductEntryModelImpl.FINDER_CACHE_ENABLED_SCLICENSES_SCPRODUCTENTRIES,
2086                            SCProductEntryModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME,
2087                            "containsSCLicense",
2088                            new String[] { Long.class.getName(), Long.class.getName() });
2089    
2090            public boolean containsSCLicense(long pk, long scLicensePK)
2091                    throws SystemException {
2092                    Object[] finderArgs = new Object[] { pk, scLicensePK };
2093    
2094                    Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_SCLICENSE,
2095                                    finderArgs, this);
2096    
2097                    if (value == null) {
2098                            try {
2099                                    value = Boolean.valueOf(containsSCLicense.contains(pk,
2100                                                            scLicensePK));
2101                            }
2102                            catch (Exception e) {
2103                                    throw processException(e);
2104                            }
2105                            finally {
2106                                    if (value == null) {
2107                                            value = Boolean.FALSE;
2108                                    }
2109    
2110                                    FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_SCLICENSE,
2111                                            finderArgs, value);
2112                            }
2113                    }
2114    
2115                    return value.booleanValue();
2116            }
2117    
2118            public boolean containsSCLicenses(long pk) throws SystemException {
2119                    if (getSCLicensesSize(pk) > 0) {
2120                            return true;
2121                    }
2122                    else {
2123                            return false;
2124                    }
2125            }
2126    
2127            public void addSCLicense(long pk, long scLicensePK)
2128                    throws SystemException {
2129                    try {
2130                            addSCLicense.add(pk, scLicensePK);
2131                    }
2132                    catch (Exception e) {
2133                            throw processException(e);
2134                    }
2135                    finally {
2136                            FinderCacheUtil.clearCache(SCProductEntryModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
2137                    }
2138            }
2139    
2140            public void addSCLicense(long pk,
2141                    com.liferay.portlet.softwarecatalog.model.SCLicense scLicense)
2142                    throws SystemException {
2143                    try {
2144                            addSCLicense.add(pk, scLicense.getPrimaryKey());
2145                    }
2146                    catch (Exception e) {
2147                            throw processException(e);
2148                    }
2149                    finally {
2150                            FinderCacheUtil.clearCache(SCProductEntryModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
2151                    }
2152            }
2153    
2154            public void addSCLicenses(long pk, long[] scLicensePKs)
2155                    throws SystemException {
2156                    try {
2157                            for (long scLicensePK : scLicensePKs) {
2158                                    addSCLicense.add(pk, scLicensePK);
2159                            }
2160                    }
2161                    catch (Exception e) {
2162                            throw processException(e);
2163                    }
2164                    finally {
2165                            FinderCacheUtil.clearCache(SCProductEntryModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
2166                    }
2167            }
2168    
2169            public void addSCLicenses(long pk,
2170                    List<com.liferay.portlet.softwarecatalog.model.SCLicense> scLicenses)
2171                    throws SystemException {
2172                    try {
2173                            for (com.liferay.portlet.softwarecatalog.model.SCLicense scLicense : scLicenses) {
2174                                    addSCLicense.add(pk, scLicense.getPrimaryKey());
2175                            }
2176                    }
2177                    catch (Exception e) {
2178                            throw processException(e);
2179                    }
2180                    finally {
2181                            FinderCacheUtil.clearCache(SCProductEntryModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
2182                    }
2183            }
2184    
2185            public void clearSCLicenses(long pk) throws SystemException {
2186                    try {
2187                            clearSCLicenses.clear(pk);
2188                    }
2189                    catch (Exception e) {
2190                            throw processException(e);
2191                    }
2192                    finally {
2193                            FinderCacheUtil.clearCache(SCProductEntryModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
2194                    }
2195            }
2196    
2197            public void removeSCLicense(long pk, long scLicensePK)
2198                    throws SystemException {
2199                    try {
2200                            removeSCLicense.remove(pk, scLicensePK);
2201                    }
2202                    catch (Exception e) {
2203                            throw processException(e);
2204                    }
2205                    finally {
2206                            FinderCacheUtil.clearCache(SCProductEntryModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
2207                    }
2208            }
2209    
2210            public void removeSCLicense(long pk,
2211                    com.liferay.portlet.softwarecatalog.model.SCLicense scLicense)
2212                    throws SystemException {
2213                    try {
2214                            removeSCLicense.remove(pk, scLicense.getPrimaryKey());
2215                    }
2216                    catch (Exception e) {
2217                            throw processException(e);
2218                    }
2219                    finally {
2220                            FinderCacheUtil.clearCache(SCProductEntryModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
2221                    }
2222            }
2223    
2224            public void removeSCLicenses(long pk, long[] scLicensePKs)
2225                    throws SystemException {
2226                    try {
2227                            for (long scLicensePK : scLicensePKs) {
2228                                    removeSCLicense.remove(pk, scLicensePK);
2229                            }
2230                    }
2231                    catch (Exception e) {
2232                            throw processException(e);
2233                    }
2234                    finally {
2235                            FinderCacheUtil.clearCache(SCProductEntryModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
2236                    }
2237            }
2238    
2239            public void removeSCLicenses(long pk,
2240                    List<com.liferay.portlet.softwarecatalog.model.SCLicense> scLicenses)
2241                    throws SystemException {
2242                    try {
2243                            for (com.liferay.portlet.softwarecatalog.model.SCLicense scLicense : scLicenses) {
2244                                    removeSCLicense.remove(pk, scLicense.getPrimaryKey());
2245                            }
2246                    }
2247                    catch (Exception e) {
2248                            throw processException(e);
2249                    }
2250                    finally {
2251                            FinderCacheUtil.clearCache(SCProductEntryModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
2252                    }
2253            }
2254    
2255            public void setSCLicenses(long pk, long[] scLicensePKs)
2256                    throws SystemException {
2257                    try {
2258                            Set<Long> scLicensePKSet = SetUtil.fromArray(scLicensePKs);
2259    
2260                            List<com.liferay.portlet.softwarecatalog.model.SCLicense> scLicenses =
2261                                    getSCLicenses(pk);
2262    
2263                            for (com.liferay.portlet.softwarecatalog.model.SCLicense scLicense : scLicenses) {
2264                                    if (!scLicensePKSet.contains(scLicense.getPrimaryKey())) {
2265                                            removeSCLicense.remove(pk, scLicense.getPrimaryKey());
2266                                    }
2267                                    else {
2268                                            scLicensePKSet.remove(scLicense.getPrimaryKey());
2269                                    }
2270                            }
2271    
2272                            for (Long scLicensePK : scLicensePKSet) {
2273                                    addSCLicense.add(pk, scLicensePK);
2274                            }
2275                    }
2276                    catch (Exception e) {
2277                            throw processException(e);
2278                    }
2279                    finally {
2280                            FinderCacheUtil.clearCache(SCProductEntryModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
2281                    }
2282            }
2283    
2284            public void setSCLicenses(long pk,
2285                    List<com.liferay.portlet.softwarecatalog.model.SCLicense> scLicenses)
2286                    throws SystemException {
2287                    try {
2288                            long[] scLicensePKs = new long[scLicenses.size()];
2289    
2290                            for (int i = 0; i < scLicenses.size(); i++) {
2291                                    com.liferay.portlet.softwarecatalog.model.SCLicense scLicense = scLicenses.get(i);
2292    
2293                                    scLicensePKs[i] = scLicense.getPrimaryKey();
2294                            }
2295    
2296                            setSCLicenses(pk, scLicensePKs);
2297                    }
2298                    catch (Exception e) {
2299                            throw processException(e);
2300                    }
2301                    finally {
2302                            FinderCacheUtil.clearCache(SCProductEntryModelImpl.MAPPING_TABLE_SCLICENSES_SCPRODUCTENTRIES_NAME);
2303                    }
2304            }
2305    
2306            public void afterPropertiesSet() {
2307                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
2308                                            com.liferay.portal.util.PropsUtil.get(
2309                                                    "value.object.listener.com.liferay.portlet.softwarecatalog.model.SCProductEntry")));
2310    
2311                    if (listenerClassNames.length > 0) {
2312                            try {
2313                                    List<ModelListener<SCProductEntry>> listenersList = new ArrayList<ModelListener<SCProductEntry>>();
2314    
2315                                    for (String listenerClassName : listenerClassNames) {
2316                                            listenersList.add((ModelListener<SCProductEntry>)InstanceFactory.newInstance(
2317                                                            listenerClassName));
2318                                    }
2319    
2320                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
2321                            }
2322                            catch (Exception e) {
2323                                    _log.error(e);
2324                            }
2325                    }
2326    
2327                    containsSCLicense = new ContainsSCLicense(this);
2328    
2329                    addSCLicense = new AddSCLicense(this);
2330                    clearSCLicenses = new ClearSCLicenses(this);
2331                    removeSCLicense = new RemoveSCLicense(this);
2332            }
2333    
2334            @BeanReference(type = SCLicensePersistence.class)
2335            protected SCLicensePersistence scLicensePersistence;
2336            @BeanReference(type = SCFrameworkVersionPersistence.class)
2337            protected SCFrameworkVersionPersistence scFrameworkVersionPersistence;
2338            @BeanReference(type = SCProductEntryPersistence.class)
2339            protected SCProductEntryPersistence scProductEntryPersistence;
2340            @BeanReference(type = SCProductScreenshotPersistence.class)
2341            protected SCProductScreenshotPersistence scProductScreenshotPersistence;
2342            @BeanReference(type = SCProductVersionPersistence.class)
2343            protected SCProductVersionPersistence scProductVersionPersistence;
2344            @BeanReference(type = GroupPersistence.class)
2345            protected GroupPersistence groupPersistence;
2346            @BeanReference(type = ImagePersistence.class)
2347            protected ImagePersistence imagePersistence;
2348            @BeanReference(type = ResourcePersistence.class)
2349            protected ResourcePersistence resourcePersistence;
2350            @BeanReference(type = UserPersistence.class)
2351            protected UserPersistence userPersistence;
2352            @BeanReference(type = MBMessagePersistence.class)
2353            protected MBMessagePersistence mbMessagePersistence;
2354            @BeanReference(type = RatingsStatsPersistence.class)
2355            protected RatingsStatsPersistence ratingsStatsPersistence;
2356            protected ContainsSCLicense containsSCLicense;
2357            protected AddSCLicense addSCLicense;
2358            protected ClearSCLicenses clearSCLicenses;
2359            protected RemoveSCLicense removeSCLicense;
2360    
2361            protected class ContainsSCLicense {
2362                    protected ContainsSCLicense(
2363                            SCProductEntryPersistenceImpl persistenceImpl) {
2364                            super();
2365    
2366                            _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
2367                                            _SQL_CONTAINSSCLICENSE,
2368                                            new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
2369                                            RowMapper.COUNT);
2370                    }
2371    
2372                    protected boolean contains(long productEntryId, long licenseId) {
2373                            List<Integer> results = _mappingSqlQuery.execute(new Object[] {
2374                                                    new Long(productEntryId), new Long(licenseId)
2375                                            });
2376    
2377                            if (results.size() > 0) {
2378                                    Integer count = results.get(0);
2379    
2380                                    if (count.intValue() > 0) {
2381                                            return true;
2382                                    }
2383                            }
2384    
2385                            return false;
2386                    }
2387    
2388                    private MappingSqlQuery<Integer> _mappingSqlQuery;
2389            }
2390    
2391            protected class AddSCLicense {
2392                    protected AddSCLicense(SCProductEntryPersistenceImpl persistenceImpl) {
2393                            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
2394                                            "INSERT INTO SCLicenses_SCProductEntries (productEntryId, licenseId) VALUES (?, ?)",
2395                                            new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
2396                            _persistenceImpl = persistenceImpl;
2397                    }
2398    
2399                    protected void add(long productEntryId, long licenseId)
2400                            throws SystemException {
2401                            if (!_persistenceImpl.containsSCLicense.contains(productEntryId,
2402                                                    licenseId)) {
2403                                    ModelListener<com.liferay.portlet.softwarecatalog.model.SCLicense>[] scLicenseListeners =
2404                                            scLicensePersistence.getListeners();
2405    
2406                                    for (ModelListener<SCProductEntry> listener : listeners) {
2407                                            listener.onBeforeAddAssociation(productEntryId,
2408                                                    com.liferay.portlet.softwarecatalog.model.SCLicense.class.getName(),
2409                                                    licenseId);
2410                                    }
2411    
2412                                    for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCLicense> listener : scLicenseListeners) {
2413                                            listener.onBeforeAddAssociation(licenseId,
2414                                                    SCProductEntry.class.getName(), productEntryId);
2415                                    }
2416    
2417                                    _sqlUpdate.update(new Object[] {
2418                                                    new Long(productEntryId), new Long(licenseId)
2419                                            });
2420    
2421                                    for (ModelListener<SCProductEntry> listener : listeners) {
2422                                            listener.onAfterAddAssociation(productEntryId,
2423                                                    com.liferay.portlet.softwarecatalog.model.SCLicense.class.getName(),
2424                                                    licenseId);
2425                                    }
2426    
2427                                    for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCLicense> listener : scLicenseListeners) {
2428                                            listener.onAfterAddAssociation(licenseId,
2429                                                    SCProductEntry.class.getName(), productEntryId);
2430                                    }
2431                            }
2432                    }
2433    
2434                    private SqlUpdate _sqlUpdate;
2435                    private SCProductEntryPersistenceImpl _persistenceImpl;
2436            }
2437    
2438            protected class ClearSCLicenses {
2439                    protected ClearSCLicenses(SCProductEntryPersistenceImpl persistenceImpl) {
2440                            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
2441                                            "DELETE FROM SCLicenses_SCProductEntries WHERE productEntryId = ?",
2442                                            new int[] { java.sql.Types.BIGINT });
2443                    }
2444    
2445                    protected void clear(long productEntryId) throws SystemException {
2446                            ModelListener<com.liferay.portlet.softwarecatalog.model.SCLicense>[] scLicenseListeners =
2447                                    scLicensePersistence.getListeners();
2448    
2449                            List<com.liferay.portlet.softwarecatalog.model.SCLicense> scLicenses =
2450                                    null;
2451    
2452                            if ((listeners.length > 0) || (scLicenseListeners.length > 0)) {
2453                                    scLicenses = getSCLicenses(productEntryId);
2454    
2455                                    for (com.liferay.portlet.softwarecatalog.model.SCLicense scLicense : scLicenses) {
2456                                            for (ModelListener<SCProductEntry> listener : listeners) {
2457                                                    listener.onBeforeRemoveAssociation(productEntryId,
2458                                                            com.liferay.portlet.softwarecatalog.model.SCLicense.class.getName(),
2459                                                            scLicense.getPrimaryKey());
2460                                            }
2461    
2462                                            for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCLicense> listener : scLicenseListeners) {
2463                                                    listener.onBeforeRemoveAssociation(scLicense.getPrimaryKey(),
2464                                                            SCProductEntry.class.getName(), productEntryId);
2465                                            }
2466                                    }
2467                            }
2468    
2469                            _sqlUpdate.update(new Object[] { new Long(productEntryId) });
2470    
2471                            if ((listeners.length > 0) || (scLicenseListeners.length > 0)) {
2472                                    for (com.liferay.portlet.softwarecatalog.model.SCLicense scLicense : scLicenses) {
2473                                            for (ModelListener<SCProductEntry> listener : listeners) {
2474                                                    listener.onAfterRemoveAssociation(productEntryId,
2475                                                            com.liferay.portlet.softwarecatalog.model.SCLicense.class.getName(),
2476                                                            scLicense.getPrimaryKey());
2477                                            }
2478    
2479                                            for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCLicense> listener : scLicenseListeners) {
2480                                                    listener.onAfterRemoveAssociation(scLicense.getPrimaryKey(),
2481                                                            SCProductEntry.class.getName(), productEntryId);
2482                                            }
2483                                    }
2484                            }
2485                    }
2486    
2487                    private SqlUpdate _sqlUpdate;
2488            }
2489    
2490            protected class RemoveSCLicense {
2491                    protected RemoveSCLicense(SCProductEntryPersistenceImpl persistenceImpl) {
2492                            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
2493                                            "DELETE FROM SCLicenses_SCProductEntries WHERE productEntryId = ? AND licenseId = ?",
2494                                            new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
2495                            _persistenceImpl = persistenceImpl;
2496                    }
2497    
2498                    protected void remove(long productEntryId, long licenseId)
2499                            throws SystemException {
2500                            if (_persistenceImpl.containsSCLicense.contains(productEntryId,
2501                                                    licenseId)) {
2502                                    ModelListener<com.liferay.portlet.softwarecatalog.model.SCLicense>[] scLicenseListeners =
2503                                            scLicensePersistence.getListeners();
2504    
2505                                    for (ModelListener<SCProductEntry> listener : listeners) {
2506                                            listener.onBeforeRemoveAssociation(productEntryId,
2507                                                    com.liferay.portlet.softwarecatalog.model.SCLicense.class.getName(),
2508                                                    licenseId);
2509                                    }
2510    
2511                                    for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCLicense> listener : scLicenseListeners) {
2512                                            listener.onBeforeRemoveAssociation(licenseId,
2513                                                    SCProductEntry.class.getName(), productEntryId);
2514                                    }
2515    
2516                                    _sqlUpdate.update(new Object[] {
2517                                                    new Long(productEntryId), new Long(licenseId)
2518                                            });
2519    
2520                                    for (ModelListener<SCProductEntry> listener : listeners) {
2521                                            listener.onAfterRemoveAssociation(productEntryId,
2522                                                    com.liferay.portlet.softwarecatalog.model.SCLicense.class.getName(),
2523                                                    licenseId);
2524                                    }
2525    
2526                                    for (ModelListener<com.liferay.portlet.softwarecatalog.model.SCLicense> listener : scLicenseListeners) {
2527                                            listener.onAfterRemoveAssociation(licenseId,
2528                                                    SCProductEntry.class.getName(), productEntryId);
2529                                    }
2530                            }
2531                    }
2532    
2533                    private SqlUpdate _sqlUpdate;
2534                    private SCProductEntryPersistenceImpl _persistenceImpl;
2535            }
2536    
2537            private static final String _SQL_SELECT_SCPRODUCTENTRY = "SELECT scProductEntry FROM SCProductEntry scProductEntry";
2538            private static final String _SQL_SELECT_SCPRODUCTENTRY_WHERE = "SELECT scProductEntry FROM SCProductEntry scProductEntry WHERE ";
2539            private static final String _SQL_COUNT_SCPRODUCTENTRY = "SELECT COUNT(scProductEntry) FROM SCProductEntry scProductEntry";
2540            private static final String _SQL_COUNT_SCPRODUCTENTRY_WHERE = "SELECT COUNT(scProductEntry) FROM SCProductEntry scProductEntry WHERE ";
2541            private static final String _SQL_GETSCLICENSES = "SELECT {SCLicense.*} FROM SCLicense INNER JOIN SCLicenses_SCProductEntries ON (SCLicenses_SCProductEntries.licenseId = SCLicense.licenseId) WHERE (SCLicenses_SCProductEntries.productEntryId = ?)";
2542            private static final String _SQL_GETSCLICENSESSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM SCLicenses_SCProductEntries WHERE productEntryId = ?";
2543            private static final String _SQL_CONTAINSSCLICENSE = "SELECT COUNT(*) AS COUNT_VALUE FROM SCLicenses_SCProductEntries WHERE productEntryId = ? AND licenseId = ?";
2544            private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "scProductEntry.groupId = ?";
2545            private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "scProductEntry.companyId = ?";
2546            private static final String _FINDER_COLUMN_G_U_GROUPID_2 = "scProductEntry.groupId = ? AND ";
2547            private static final String _FINDER_COLUMN_G_U_USERID_2 = "scProductEntry.userId = ?";
2548            private static final String _FINDER_COLUMN_RG_RA_REPOGROUPID_1 = "scProductEntry.repoGroupId IS NULL AND ";
2549            private static final String _FINDER_COLUMN_RG_RA_REPOGROUPID_2 = "lower(scProductEntry.repoGroupId) = lower(?) AND ";
2550            private static final String _FINDER_COLUMN_RG_RA_REPOGROUPID_3 = "(scProductEntry.repoGroupId IS NULL OR lower(scProductEntry.repoGroupId) = lower(?)) AND ";
2551            private static final String _FINDER_COLUMN_RG_RA_REPOARTIFACTID_1 = "scProductEntry.repoArtifactId IS NULL";
2552            private static final String _FINDER_COLUMN_RG_RA_REPOARTIFACTID_2 = "lower(scProductEntry.repoArtifactId) = lower(?)";
2553            private static final String _FINDER_COLUMN_RG_RA_REPOARTIFACTID_3 = "(scProductEntry.repoArtifactId IS NULL OR lower(scProductEntry.repoArtifactId) = lower(?))";
2554            private static final String _FILTER_SQL_SELECT_SCPRODUCTENTRY_WHERE = "SELECT DISTINCT {scProductEntry.*} FROM SCProductEntry scProductEntry WHERE ";
2555            private static final String _FILTER_SQL_COUNT_SCPRODUCTENTRY_WHERE = "SELECT COUNT(DISTINCT scProductEntry.productEntryId) AS COUNT_VALUE FROM SCProductEntry scProductEntry WHERE ";
2556            private static final String _FILTER_COLUMN_PK = "scProductEntry.productEntryId";
2557            private static final String _FILTER_COLUMN_USERID = "scProductEntry.userId";
2558            private static final String _FILTER_ENTITY_ALIAS = "scProductEntry";
2559            private static final String _ORDER_BY_ENTITY_ALIAS = "scProductEntry.";
2560            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No SCProductEntry exists with the primary key ";
2561            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No SCProductEntry exists with the key {";
2562            private static Log _log = LogFactoryUtil.getLog(SCProductEntryPersistenceImpl.class);
2563    }