001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portal.service.persistence;
016    
017    import com.liferay.portal.NoSuchModelException;
018    import com.liferay.portal.NoSuchPortletItemException;
019    import com.liferay.portal.kernel.annotation.BeanReference;
020    import com.liferay.portal.kernel.cache.CacheRegistryUtil;
021    import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
022    import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
023    import com.liferay.portal.kernel.dao.orm.FinderPath;
024    import com.liferay.portal.kernel.dao.orm.Query;
025    import com.liferay.portal.kernel.dao.orm.QueryPos;
026    import com.liferay.portal.kernel.dao.orm.QueryUtil;
027    import com.liferay.portal.kernel.dao.orm.Session;
028    import com.liferay.portal.kernel.exception.SystemException;
029    import com.liferay.portal.kernel.log.Log;
030    import com.liferay.portal.kernel.log.LogFactoryUtil;
031    import com.liferay.portal.kernel.util.GetterUtil;
032    import com.liferay.portal.kernel.util.InstanceFactory;
033    import com.liferay.portal.kernel.util.OrderByComparator;
034    import com.liferay.portal.kernel.util.StringBundler;
035    import com.liferay.portal.kernel.util.StringPool;
036    import com.liferay.portal.kernel.util.StringUtil;
037    import com.liferay.portal.kernel.util.Validator;
038    import com.liferay.portal.model.ModelListener;
039    import com.liferay.portal.model.PortletItem;
040    import com.liferay.portal.model.impl.PortletItemImpl;
041    import com.liferay.portal.model.impl.PortletItemModelImpl;
042    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
043    
044    import java.io.Serializable;
045    
046    import java.util.ArrayList;
047    import java.util.Collections;
048    import java.util.List;
049    
050    /**
051     * The persistence implementation for the portlet item service.
052     *
053     * <p>
054     * Never modify or reference this class directly. Always use {@link PortletItemUtil} to access the portlet item persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
055     * </p>
056     *
057     * <p>
058     * Caching information and settings can be found in <code>portal.properties</code>
059     * </p>
060     *
061     * @author Brian Wing Shun Chan
062     * @see PortletItemPersistence
063     * @see PortletItemUtil
064     * @generated
065     */
066    public class PortletItemPersistenceImpl extends BasePersistenceImpl<PortletItem>
067            implements PortletItemPersistence {
068            public static final String FINDER_CLASS_NAME_ENTITY = PortletItemImpl.class.getName();
069            public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
070                    ".List";
071            public static final FinderPath FINDER_PATH_FIND_BY_G_C = new FinderPath(PortletItemModelImpl.ENTITY_CACHE_ENABLED,
072                            PortletItemModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
073                            "findByG_C",
074                            new String[] {
075                                    Long.class.getName(), Long.class.getName(),
076                                    
077                            "java.lang.Integer", "java.lang.Integer",
078                                    "com.liferay.portal.kernel.util.OrderByComparator"
079                            });
080            public static final FinderPath FINDER_PATH_COUNT_BY_G_C = new FinderPath(PortletItemModelImpl.ENTITY_CACHE_ENABLED,
081                            PortletItemModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
082                            "countByG_C",
083                            new String[] { Long.class.getName(), Long.class.getName() });
084            public static final FinderPath FINDER_PATH_FIND_BY_G_P_C = new FinderPath(PortletItemModelImpl.ENTITY_CACHE_ENABLED,
085                            PortletItemModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
086                            "findByG_P_C",
087                            new String[] {
088                                    Long.class.getName(), String.class.getName(),
089                                    Long.class.getName(),
090                                    
091                            "java.lang.Integer", "java.lang.Integer",
092                                    "com.liferay.portal.kernel.util.OrderByComparator"
093                            });
094            public static final FinderPath FINDER_PATH_COUNT_BY_G_P_C = new FinderPath(PortletItemModelImpl.ENTITY_CACHE_ENABLED,
095                            PortletItemModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
096                            "countByG_P_C",
097                            new String[] {
098                                    Long.class.getName(), String.class.getName(),
099                                    Long.class.getName()
100                            });
101            public static final FinderPath FINDER_PATH_FETCH_BY_G_N_P_C = new FinderPath(PortletItemModelImpl.ENTITY_CACHE_ENABLED,
102                            PortletItemModelImpl.FINDER_CACHE_ENABLED,
103                            FINDER_CLASS_NAME_ENTITY, "fetchByG_N_P_C",
104                            new String[] {
105                                    Long.class.getName(), String.class.getName(),
106                                    String.class.getName(), Long.class.getName()
107                            });
108            public static final FinderPath FINDER_PATH_COUNT_BY_G_N_P_C = new FinderPath(PortletItemModelImpl.ENTITY_CACHE_ENABLED,
109                            PortletItemModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
110                            "countByG_N_P_C",
111                            new String[] {
112                                    Long.class.getName(), String.class.getName(),
113                                    String.class.getName(), Long.class.getName()
114                            });
115            public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(PortletItemModelImpl.ENTITY_CACHE_ENABLED,
116                            PortletItemModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
117                            "findAll", new String[0]);
118            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(PortletItemModelImpl.ENTITY_CACHE_ENABLED,
119                            PortletItemModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
120                            "countAll", new String[0]);
121    
122            /**
123             * Caches the portlet item in the entity cache if it is enabled.
124             *
125             * @param portletItem the portlet item to cache
126             */
127            public void cacheResult(PortletItem portletItem) {
128                    EntityCacheUtil.putResult(PortletItemModelImpl.ENTITY_CACHE_ENABLED,
129                            PortletItemImpl.class, portletItem.getPrimaryKey(), portletItem);
130    
131                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N_P_C,
132                            new Object[] {
133                                    new Long(portletItem.getGroupId()),
134                                    
135                            portletItem.getName(),
136                                    
137                            portletItem.getPortletId(), new Long(portletItem.getClassNameId())
138                            }, portletItem);
139            }
140    
141            /**
142             * Caches the portlet items in the entity cache if it is enabled.
143             *
144             * @param portletItems the portlet items to cache
145             */
146            public void cacheResult(List<PortletItem> portletItems) {
147                    for (PortletItem portletItem : portletItems) {
148                            if (EntityCacheUtil.getResult(
149                                                    PortletItemModelImpl.ENTITY_CACHE_ENABLED,
150                                                    PortletItemImpl.class, portletItem.getPrimaryKey(), this) == null) {
151                                    cacheResult(portletItem);
152                            }
153                    }
154            }
155    
156            /**
157             * Clears the cache for all portlet items.
158             *
159             * <p>
160             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
161             * </p>
162             */
163            public void clearCache() {
164                    CacheRegistryUtil.clear(PortletItemImpl.class.getName());
165                    EntityCacheUtil.clearCache(PortletItemImpl.class.getName());
166                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
167                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
168            }
169    
170            /**
171             * Clears the cache for the portlet item.
172             *
173             * <p>
174             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
175             * </p>
176             */
177            public void clearCache(PortletItem portletItem) {
178                    EntityCacheUtil.removeResult(PortletItemModelImpl.ENTITY_CACHE_ENABLED,
179                            PortletItemImpl.class, portletItem.getPrimaryKey());
180    
181                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_N_P_C,
182                            new Object[] {
183                                    new Long(portletItem.getGroupId()),
184                                    
185                            portletItem.getName(),
186                                    
187                            portletItem.getPortletId(), new Long(portletItem.getClassNameId())
188                            });
189            }
190    
191            /**
192             * Creates a new portlet item with the primary key. Does not add the portlet item to the database.
193             *
194             * @param portletItemId the primary key for the new portlet item
195             * @return the new portlet item
196             */
197            public PortletItem create(long portletItemId) {
198                    PortletItem portletItem = new PortletItemImpl();
199    
200                    portletItem.setNew(true);
201                    portletItem.setPrimaryKey(portletItemId);
202    
203                    return portletItem;
204            }
205    
206            /**
207             * Removes the portlet item with the primary key from the database. Also notifies the appropriate model listeners.
208             *
209             * @param primaryKey the primary key of the portlet item to remove
210             * @return the portlet item that was removed
211             * @throws com.liferay.portal.NoSuchModelException if a portlet item with the primary key could not be found
212             * @throws SystemException if a system exception occurred
213             */
214            public PortletItem remove(Serializable primaryKey)
215                    throws NoSuchModelException, SystemException {
216                    return remove(((Long)primaryKey).longValue());
217            }
218    
219            /**
220             * Removes the portlet item with the primary key from the database. Also notifies the appropriate model listeners.
221             *
222             * @param portletItemId the primary key of the portlet item to remove
223             * @return the portlet item that was removed
224             * @throws com.liferay.portal.NoSuchPortletItemException if a portlet item with the primary key could not be found
225             * @throws SystemException if a system exception occurred
226             */
227            public PortletItem remove(long portletItemId)
228                    throws NoSuchPortletItemException, SystemException {
229                    Session session = null;
230    
231                    try {
232                            session = openSession();
233    
234                            PortletItem portletItem = (PortletItem)session.get(PortletItemImpl.class,
235                                            new Long(portletItemId));
236    
237                            if (portletItem == null) {
238                                    if (_log.isWarnEnabled()) {
239                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + portletItemId);
240                                    }
241    
242                                    throw new NoSuchPortletItemException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
243                                            portletItemId);
244                            }
245    
246                            return remove(portletItem);
247                    }
248                    catch (NoSuchPortletItemException nsee) {
249                            throw nsee;
250                    }
251                    catch (Exception e) {
252                            throw processException(e);
253                    }
254                    finally {
255                            closeSession(session);
256                    }
257            }
258    
259            protected PortletItem removeImpl(PortletItem portletItem)
260                    throws SystemException {
261                    portletItem = toUnwrappedModel(portletItem);
262    
263                    Session session = null;
264    
265                    try {
266                            session = openSession();
267    
268                            BatchSessionUtil.delete(session, portletItem);
269                    }
270                    catch (Exception e) {
271                            throw processException(e);
272                    }
273                    finally {
274                            closeSession(session);
275                    }
276    
277                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
278    
279                    PortletItemModelImpl portletItemModelImpl = (PortletItemModelImpl)portletItem;
280    
281                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_N_P_C,
282                            new Object[] {
283                                    new Long(portletItemModelImpl.getOriginalGroupId()),
284                                    
285                            portletItemModelImpl.getOriginalName(),
286                                    
287                            portletItemModelImpl.getOriginalPortletId(),
288                                    new Long(portletItemModelImpl.getOriginalClassNameId())
289                            });
290    
291                    EntityCacheUtil.removeResult(PortletItemModelImpl.ENTITY_CACHE_ENABLED,
292                            PortletItemImpl.class, portletItem.getPrimaryKey());
293    
294                    return portletItem;
295            }
296    
297            public PortletItem updateImpl(
298                    com.liferay.portal.model.PortletItem portletItem, boolean merge)
299                    throws SystemException {
300                    portletItem = toUnwrappedModel(portletItem);
301    
302                    boolean isNew = portletItem.isNew();
303    
304                    PortletItemModelImpl portletItemModelImpl = (PortletItemModelImpl)portletItem;
305    
306                    Session session = null;
307    
308                    try {
309                            session = openSession();
310    
311                            BatchSessionUtil.update(session, portletItem, merge);
312    
313                            portletItem.setNew(false);
314                    }
315                    catch (Exception e) {
316                            throw processException(e);
317                    }
318                    finally {
319                            closeSession(session);
320                    }
321    
322                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
323    
324                    EntityCacheUtil.putResult(PortletItemModelImpl.ENTITY_CACHE_ENABLED,
325                            PortletItemImpl.class, portletItem.getPrimaryKey(), portletItem);
326    
327                    if (!isNew &&
328                                    ((portletItem.getGroupId() != portletItemModelImpl.getOriginalGroupId()) ||
329                                    !Validator.equals(portletItem.getName(),
330                                            portletItemModelImpl.getOriginalName()) ||
331                                    !Validator.equals(portletItem.getPortletId(),
332                                            portletItemModelImpl.getOriginalPortletId()) ||
333                                    (portletItem.getClassNameId() != portletItemModelImpl.getOriginalClassNameId()))) {
334                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_N_P_C,
335                                    new Object[] {
336                                            new Long(portletItemModelImpl.getOriginalGroupId()),
337                                            
338                                    portletItemModelImpl.getOriginalName(),
339                                            
340                                    portletItemModelImpl.getOriginalPortletId(),
341                                            new Long(portletItemModelImpl.getOriginalClassNameId())
342                                    });
343                    }
344    
345                    if (isNew ||
346                                    ((portletItem.getGroupId() != portletItemModelImpl.getOriginalGroupId()) ||
347                                    !Validator.equals(portletItem.getName(),
348                                            portletItemModelImpl.getOriginalName()) ||
349                                    !Validator.equals(portletItem.getPortletId(),
350                                            portletItemModelImpl.getOriginalPortletId()) ||
351                                    (portletItem.getClassNameId() != portletItemModelImpl.getOriginalClassNameId()))) {
352                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N_P_C,
353                                    new Object[] {
354                                            new Long(portletItem.getGroupId()),
355                                            
356                                    portletItem.getName(),
357                                            
358                                    portletItem.getPortletId(),
359                                            new Long(portletItem.getClassNameId())
360                                    }, portletItem);
361                    }
362    
363                    return portletItem;
364            }
365    
366            protected PortletItem toUnwrappedModel(PortletItem portletItem) {
367                    if (portletItem instanceof PortletItemImpl) {
368                            return portletItem;
369                    }
370    
371                    PortletItemImpl portletItemImpl = new PortletItemImpl();
372    
373                    portletItemImpl.setNew(portletItem.isNew());
374                    portletItemImpl.setPrimaryKey(portletItem.getPrimaryKey());
375    
376                    portletItemImpl.setPortletItemId(portletItem.getPortletItemId());
377                    portletItemImpl.setGroupId(portletItem.getGroupId());
378                    portletItemImpl.setCompanyId(portletItem.getCompanyId());
379                    portletItemImpl.setUserId(portletItem.getUserId());
380                    portletItemImpl.setUserName(portletItem.getUserName());
381                    portletItemImpl.setCreateDate(portletItem.getCreateDate());
382                    portletItemImpl.setModifiedDate(portletItem.getModifiedDate());
383                    portletItemImpl.setName(portletItem.getName());
384                    portletItemImpl.setPortletId(portletItem.getPortletId());
385                    portletItemImpl.setClassNameId(portletItem.getClassNameId());
386    
387                    return portletItemImpl;
388            }
389    
390            /**
391             * Finds the portlet item with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
392             *
393             * @param primaryKey the primary key of the portlet item to find
394             * @return the portlet item
395             * @throws com.liferay.portal.NoSuchModelException if a portlet item with the primary key could not be found
396             * @throws SystemException if a system exception occurred
397             */
398            public PortletItem findByPrimaryKey(Serializable primaryKey)
399                    throws NoSuchModelException, SystemException {
400                    return findByPrimaryKey(((Long)primaryKey).longValue());
401            }
402    
403            /**
404             * Finds the portlet item with the primary key or throws a {@link com.liferay.portal.NoSuchPortletItemException} if it could not be found.
405             *
406             * @param portletItemId the primary key of the portlet item to find
407             * @return the portlet item
408             * @throws com.liferay.portal.NoSuchPortletItemException if a portlet item with the primary key could not be found
409             * @throws SystemException if a system exception occurred
410             */
411            public PortletItem findByPrimaryKey(long portletItemId)
412                    throws NoSuchPortletItemException, SystemException {
413                    PortletItem portletItem = fetchByPrimaryKey(portletItemId);
414    
415                    if (portletItem == null) {
416                            if (_log.isWarnEnabled()) {
417                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + portletItemId);
418                            }
419    
420                            throw new NoSuchPortletItemException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
421                                    portletItemId);
422                    }
423    
424                    return portletItem;
425            }
426    
427            /**
428             * Finds the portlet item with the primary key or returns <code>null</code> if it could not be found.
429             *
430             * @param primaryKey the primary key of the portlet item to find
431             * @return the portlet item, or <code>null</code> if a portlet item with the primary key could not be found
432             * @throws SystemException if a system exception occurred
433             */
434            public PortletItem fetchByPrimaryKey(Serializable primaryKey)
435                    throws SystemException {
436                    return fetchByPrimaryKey(((Long)primaryKey).longValue());
437            }
438    
439            /**
440             * Finds the portlet item with the primary key or returns <code>null</code> if it could not be found.
441             *
442             * @param portletItemId the primary key of the portlet item to find
443             * @return the portlet item, or <code>null</code> if a portlet item with the primary key could not be found
444             * @throws SystemException if a system exception occurred
445             */
446            public PortletItem fetchByPrimaryKey(long portletItemId)
447                    throws SystemException {
448                    PortletItem portletItem = (PortletItem)EntityCacheUtil.getResult(PortletItemModelImpl.ENTITY_CACHE_ENABLED,
449                                    PortletItemImpl.class, portletItemId, this);
450    
451                    if (portletItem == null) {
452                            Session session = null;
453    
454                            try {
455                                    session = openSession();
456    
457                                    portletItem = (PortletItem)session.get(PortletItemImpl.class,
458                                                    new Long(portletItemId));
459                            }
460                            catch (Exception e) {
461                                    throw processException(e);
462                            }
463                            finally {
464                                    if (portletItem != null) {
465                                            cacheResult(portletItem);
466                                    }
467    
468                                    closeSession(session);
469                            }
470                    }
471    
472                    return portletItem;
473            }
474    
475            /**
476             * Finds all the portlet items where groupId = &#63; and classNameId = &#63;.
477             *
478             * @param groupId the group id to search with
479             * @param classNameId the class name id to search with
480             * @return the matching portlet items
481             * @throws SystemException if a system exception occurred
482             */
483            public List<PortletItem> findByG_C(long groupId, long classNameId)
484                    throws SystemException {
485                    return findByG_C(groupId, classNameId, QueryUtil.ALL_POS,
486                            QueryUtil.ALL_POS, null);
487            }
488    
489            /**
490             * Finds a range of all the portlet items where groupId = &#63; and classNameId = &#63;.
491             *
492             * <p>
493             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
494             * </p>
495             *
496             * @param groupId the group id to search with
497             * @param classNameId the class name id to search with
498             * @param start the lower bound of the range of portlet items to return
499             * @param end the upper bound of the range of portlet items to return (not inclusive)
500             * @return the range of matching portlet items
501             * @throws SystemException if a system exception occurred
502             */
503            public List<PortletItem> findByG_C(long groupId, long classNameId,
504                    int start, int end) throws SystemException {
505                    return findByG_C(groupId, classNameId, start, end, null);
506            }
507    
508            /**
509             * Finds an ordered range of all the portlet items where groupId = &#63; and classNameId = &#63;.
510             *
511             * <p>
512             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
513             * </p>
514             *
515             * @param groupId the group id to search with
516             * @param classNameId the class name id to search with
517             * @param start the lower bound of the range of portlet items to return
518             * @param end the upper bound of the range of portlet items to return (not inclusive)
519             * @param orderByComparator the comparator to order the results by
520             * @return the ordered range of matching portlet items
521             * @throws SystemException if a system exception occurred
522             */
523            public List<PortletItem> findByG_C(long groupId, long classNameId,
524                    int start, int end, OrderByComparator orderByComparator)
525                    throws SystemException {
526                    Object[] finderArgs = new Object[] {
527                                    groupId, classNameId,
528                                    
529                                    String.valueOf(start), String.valueOf(end),
530                                    String.valueOf(orderByComparator)
531                            };
532    
533                    List<PortletItem> list = (List<PortletItem>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_G_C,
534                                    finderArgs, this);
535    
536                    if (list == null) {
537                            Session session = null;
538    
539                            try {
540                                    session = openSession();
541    
542                                    StringBundler query = null;
543    
544                                    if (orderByComparator != null) {
545                                            query = new StringBundler(4 +
546                                                            (orderByComparator.getOrderByFields().length * 3));
547                                    }
548                                    else {
549                                            query = new StringBundler(3);
550                                    }
551    
552                                    query.append(_SQL_SELECT_PORTLETITEM_WHERE);
553    
554                                    query.append(_FINDER_COLUMN_G_C_GROUPID_2);
555    
556                                    query.append(_FINDER_COLUMN_G_C_CLASSNAMEID_2);
557    
558                                    if (orderByComparator != null) {
559                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
560                                                    orderByComparator);
561                                    }
562    
563                                    String sql = query.toString();
564    
565                                    Query q = session.createQuery(sql);
566    
567                                    QueryPos qPos = QueryPos.getInstance(q);
568    
569                                    qPos.add(groupId);
570    
571                                    qPos.add(classNameId);
572    
573                                    list = (List<PortletItem>)QueryUtil.list(q, getDialect(),
574                                                    start, end);
575                            }
576                            catch (Exception e) {
577                                    throw processException(e);
578                            }
579                            finally {
580                                    if (list == null) {
581                                            list = new ArrayList<PortletItem>();
582                                    }
583    
584                                    cacheResult(list);
585    
586                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_G_C, finderArgs,
587                                            list);
588    
589                                    closeSession(session);
590                            }
591                    }
592    
593                    return list;
594            }
595    
596            /**
597             * Finds the first portlet item in the ordered set where groupId = &#63; and classNameId = &#63;.
598             *
599             * <p>
600             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
601             * </p>
602             *
603             * @param groupId the group id to search with
604             * @param classNameId the class name id to search with
605             * @param orderByComparator the comparator to order the set by
606             * @return the first matching portlet item
607             * @throws com.liferay.portal.NoSuchPortletItemException if a matching portlet item could not be found
608             * @throws SystemException if a system exception occurred
609             */
610            public PortletItem findByG_C_First(long groupId, long classNameId,
611                    OrderByComparator orderByComparator)
612                    throws NoSuchPortletItemException, SystemException {
613                    List<PortletItem> list = findByG_C(groupId, classNameId, 0, 1,
614                                    orderByComparator);
615    
616                    if (list.isEmpty()) {
617                            StringBundler msg = new StringBundler(6);
618    
619                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
620    
621                            msg.append("groupId=");
622                            msg.append(groupId);
623    
624                            msg.append(", classNameId=");
625                            msg.append(classNameId);
626    
627                            msg.append(StringPool.CLOSE_CURLY_BRACE);
628    
629                            throw new NoSuchPortletItemException(msg.toString());
630                    }
631                    else {
632                            return list.get(0);
633                    }
634            }
635    
636            /**
637             * Finds the last portlet item in the ordered set where groupId = &#63; and classNameId = &#63;.
638             *
639             * <p>
640             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
641             * </p>
642             *
643             * @param groupId the group id to search with
644             * @param classNameId the class name id to search with
645             * @param orderByComparator the comparator to order the set by
646             * @return the last matching portlet item
647             * @throws com.liferay.portal.NoSuchPortletItemException if a matching portlet item could not be found
648             * @throws SystemException if a system exception occurred
649             */
650            public PortletItem findByG_C_Last(long groupId, long classNameId,
651                    OrderByComparator orderByComparator)
652                    throws NoSuchPortletItemException, SystemException {
653                    int count = countByG_C(groupId, classNameId);
654    
655                    List<PortletItem> list = findByG_C(groupId, classNameId, count - 1,
656                                    count, orderByComparator);
657    
658                    if (list.isEmpty()) {
659                            StringBundler msg = new StringBundler(6);
660    
661                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
662    
663                            msg.append("groupId=");
664                            msg.append(groupId);
665    
666                            msg.append(", classNameId=");
667                            msg.append(classNameId);
668    
669                            msg.append(StringPool.CLOSE_CURLY_BRACE);
670    
671                            throw new NoSuchPortletItemException(msg.toString());
672                    }
673                    else {
674                            return list.get(0);
675                    }
676            }
677    
678            /**
679             * Finds the portlet items before and after the current portlet item in the ordered set where groupId = &#63; and classNameId = &#63;.
680             *
681             * <p>
682             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
683             * </p>
684             *
685             * @param portletItemId the primary key of the current portlet item
686             * @param groupId the group id to search with
687             * @param classNameId the class name id to search with
688             * @param orderByComparator the comparator to order the set by
689             * @return the previous, current, and next portlet item
690             * @throws com.liferay.portal.NoSuchPortletItemException if a portlet item with the primary key could not be found
691             * @throws SystemException if a system exception occurred
692             */
693            public PortletItem[] findByG_C_PrevAndNext(long portletItemId,
694                    long groupId, long classNameId, OrderByComparator orderByComparator)
695                    throws NoSuchPortletItemException, SystemException {
696                    PortletItem portletItem = findByPrimaryKey(portletItemId);
697    
698                    Session session = null;
699    
700                    try {
701                            session = openSession();
702    
703                            PortletItem[] array = new PortletItemImpl[3];
704    
705                            array[0] = getByG_C_PrevAndNext(session, portletItem, groupId,
706                                            classNameId, orderByComparator, true);
707    
708                            array[1] = portletItem;
709    
710                            array[2] = getByG_C_PrevAndNext(session, portletItem, groupId,
711                                            classNameId, orderByComparator, false);
712    
713                            return array;
714                    }
715                    catch (Exception e) {
716                            throw processException(e);
717                    }
718                    finally {
719                            closeSession(session);
720                    }
721            }
722    
723            protected PortletItem getByG_C_PrevAndNext(Session session,
724                    PortletItem portletItem, long groupId, long classNameId,
725                    OrderByComparator orderByComparator, boolean previous) {
726                    StringBundler query = null;
727    
728                    if (orderByComparator != null) {
729                            query = new StringBundler(6 +
730                                            (orderByComparator.getOrderByFields().length * 6));
731                    }
732                    else {
733                            query = new StringBundler(3);
734                    }
735    
736                    query.append(_SQL_SELECT_PORTLETITEM_WHERE);
737    
738                    query.append(_FINDER_COLUMN_G_C_GROUPID_2);
739    
740                    query.append(_FINDER_COLUMN_G_C_CLASSNAMEID_2);
741    
742                    if (orderByComparator != null) {
743                            String[] orderByFields = orderByComparator.getOrderByFields();
744    
745                            if (orderByFields.length > 0) {
746                                    query.append(WHERE_AND);
747                            }
748    
749                            for (int i = 0; i < orderByFields.length; i++) {
750                                    query.append(_ORDER_BY_ENTITY_ALIAS);
751                                    query.append(orderByFields[i]);
752    
753                                    if ((i + 1) < orderByFields.length) {
754                                            if (orderByComparator.isAscending() ^ previous) {
755                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
756                                            }
757                                            else {
758                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
759                                            }
760                                    }
761                                    else {
762                                            if (orderByComparator.isAscending() ^ previous) {
763                                                    query.append(WHERE_GREATER_THAN);
764                                            }
765                                            else {
766                                                    query.append(WHERE_LESSER_THAN);
767                                            }
768                                    }
769                            }
770    
771                            query.append(ORDER_BY_CLAUSE);
772    
773                            for (int i = 0; i < orderByFields.length; i++) {
774                                    query.append(_ORDER_BY_ENTITY_ALIAS);
775                                    query.append(orderByFields[i]);
776    
777                                    if ((i + 1) < orderByFields.length) {
778                                            if (orderByComparator.isAscending() ^ previous) {
779                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
780                                            }
781                                            else {
782                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
783                                            }
784                                    }
785                                    else {
786                                            if (orderByComparator.isAscending() ^ previous) {
787                                                    query.append(ORDER_BY_ASC);
788                                            }
789                                            else {
790                                                    query.append(ORDER_BY_DESC);
791                                            }
792                                    }
793                            }
794                    }
795    
796                    String sql = query.toString();
797    
798                    Query q = session.createQuery(sql);
799    
800                    q.setFirstResult(0);
801                    q.setMaxResults(2);
802    
803                    QueryPos qPos = QueryPos.getInstance(q);
804    
805                    qPos.add(groupId);
806    
807                    qPos.add(classNameId);
808    
809                    if (orderByComparator != null) {
810                            Object[] values = orderByComparator.getOrderByValues(portletItem);
811    
812                            for (Object value : values) {
813                                    qPos.add(value);
814                            }
815                    }
816    
817                    List<PortletItem> list = q.list();
818    
819                    if (list.size() == 2) {
820                            return list.get(1);
821                    }
822                    else {
823                            return null;
824                    }
825            }
826    
827            /**
828             * Finds all the portlet items where groupId = &#63; and portletId = &#63; and classNameId = &#63;.
829             *
830             * @param groupId the group id to search with
831             * @param portletId the portlet id to search with
832             * @param classNameId the class name id to search with
833             * @return the matching portlet items
834             * @throws SystemException if a system exception occurred
835             */
836            public List<PortletItem> findByG_P_C(long groupId, String portletId,
837                    long classNameId) throws SystemException {
838                    return findByG_P_C(groupId, portletId, classNameId, QueryUtil.ALL_POS,
839                            QueryUtil.ALL_POS, null);
840            }
841    
842            /**
843             * Finds a range of all the portlet items where groupId = &#63; and portletId = &#63; and classNameId = &#63;.
844             *
845             * <p>
846             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
847             * </p>
848             *
849             * @param groupId the group id to search with
850             * @param portletId the portlet id to search with
851             * @param classNameId the class name id to search with
852             * @param start the lower bound of the range of portlet items to return
853             * @param end the upper bound of the range of portlet items to return (not inclusive)
854             * @return the range of matching portlet items
855             * @throws SystemException if a system exception occurred
856             */
857            public List<PortletItem> findByG_P_C(long groupId, String portletId,
858                    long classNameId, int start, int end) throws SystemException {
859                    return findByG_P_C(groupId, portletId, classNameId, start, end, null);
860            }
861    
862            /**
863             * Finds an ordered range of all the portlet items where groupId = &#63; and portletId = &#63; and classNameId = &#63;.
864             *
865             * <p>
866             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
867             * </p>
868             *
869             * @param groupId the group id to search with
870             * @param portletId the portlet id to search with
871             * @param classNameId the class name id to search with
872             * @param start the lower bound of the range of portlet items to return
873             * @param end the upper bound of the range of portlet items to return (not inclusive)
874             * @param orderByComparator the comparator to order the results by
875             * @return the ordered range of matching portlet items
876             * @throws SystemException if a system exception occurred
877             */
878            public List<PortletItem> findByG_P_C(long groupId, String portletId,
879                    long classNameId, int start, int end,
880                    OrderByComparator orderByComparator) throws SystemException {
881                    Object[] finderArgs = new Object[] {
882                                    groupId, portletId, classNameId,
883                                    
884                                    String.valueOf(start), String.valueOf(end),
885                                    String.valueOf(orderByComparator)
886                            };
887    
888                    List<PortletItem> list = (List<PortletItem>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_G_P_C,
889                                    finderArgs, this);
890    
891                    if (list == null) {
892                            Session session = null;
893    
894                            try {
895                                    session = openSession();
896    
897                                    StringBundler query = null;
898    
899                                    if (orderByComparator != null) {
900                                            query = new StringBundler(5 +
901                                                            (orderByComparator.getOrderByFields().length * 3));
902                                    }
903                                    else {
904                                            query = new StringBundler(4);
905                                    }
906    
907                                    query.append(_SQL_SELECT_PORTLETITEM_WHERE);
908    
909                                    query.append(_FINDER_COLUMN_G_P_C_GROUPID_2);
910    
911                                    if (portletId == null) {
912                                            query.append(_FINDER_COLUMN_G_P_C_PORTLETID_1);
913                                    }
914                                    else {
915                                            if (portletId.equals(StringPool.BLANK)) {
916                                                    query.append(_FINDER_COLUMN_G_P_C_PORTLETID_3);
917                                            }
918                                            else {
919                                                    query.append(_FINDER_COLUMN_G_P_C_PORTLETID_2);
920                                            }
921                                    }
922    
923                                    query.append(_FINDER_COLUMN_G_P_C_CLASSNAMEID_2);
924    
925                                    if (orderByComparator != null) {
926                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
927                                                    orderByComparator);
928                                    }
929    
930                                    String sql = query.toString();
931    
932                                    Query q = session.createQuery(sql);
933    
934                                    QueryPos qPos = QueryPos.getInstance(q);
935    
936                                    qPos.add(groupId);
937    
938                                    if (portletId != null) {
939                                            qPos.add(portletId);
940                                    }
941    
942                                    qPos.add(classNameId);
943    
944                                    list = (List<PortletItem>)QueryUtil.list(q, getDialect(),
945                                                    start, end);
946                            }
947                            catch (Exception e) {
948                                    throw processException(e);
949                            }
950                            finally {
951                                    if (list == null) {
952                                            list = new ArrayList<PortletItem>();
953                                    }
954    
955                                    cacheResult(list);
956    
957                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_G_P_C,
958                                            finderArgs, list);
959    
960                                    closeSession(session);
961                            }
962                    }
963    
964                    return list;
965            }
966    
967            /**
968             * Finds the first portlet item in the ordered set where groupId = &#63; and portletId = &#63; and classNameId = &#63;.
969             *
970             * <p>
971             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
972             * </p>
973             *
974             * @param groupId the group id to search with
975             * @param portletId the portlet id to search with
976             * @param classNameId the class name id to search with
977             * @param orderByComparator the comparator to order the set by
978             * @return the first matching portlet item
979             * @throws com.liferay.portal.NoSuchPortletItemException if a matching portlet item could not be found
980             * @throws SystemException if a system exception occurred
981             */
982            public PortletItem findByG_P_C_First(long groupId, String portletId,
983                    long classNameId, OrderByComparator orderByComparator)
984                    throws NoSuchPortletItemException, SystemException {
985                    List<PortletItem> list = findByG_P_C(groupId, portletId, classNameId,
986                                    0, 1, orderByComparator);
987    
988                    if (list.isEmpty()) {
989                            StringBundler msg = new StringBundler(8);
990    
991                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
992    
993                            msg.append("groupId=");
994                            msg.append(groupId);
995    
996                            msg.append(", portletId=");
997                            msg.append(portletId);
998    
999                            msg.append(", classNameId=");
1000                            msg.append(classNameId);
1001    
1002                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1003    
1004                            throw new NoSuchPortletItemException(msg.toString());
1005                    }
1006                    else {
1007                            return list.get(0);
1008                    }
1009            }
1010    
1011            /**
1012             * Finds the last portlet item in the ordered set where groupId = &#63; and portletId = &#63; and classNameId = &#63;.
1013             *
1014             * <p>
1015             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1016             * </p>
1017             *
1018             * @param groupId the group id to search with
1019             * @param portletId the portlet id to search with
1020             * @param classNameId the class name id to search with
1021             * @param orderByComparator the comparator to order the set by
1022             * @return the last matching portlet item
1023             * @throws com.liferay.portal.NoSuchPortletItemException if a matching portlet item could not be found
1024             * @throws SystemException if a system exception occurred
1025             */
1026            public PortletItem findByG_P_C_Last(long groupId, String portletId,
1027                    long classNameId, OrderByComparator orderByComparator)
1028                    throws NoSuchPortletItemException, SystemException {
1029                    int count = countByG_P_C(groupId, portletId, classNameId);
1030    
1031                    List<PortletItem> list = findByG_P_C(groupId, portletId, classNameId,
1032                                    count - 1, count, orderByComparator);
1033    
1034                    if (list.isEmpty()) {
1035                            StringBundler msg = new StringBundler(8);
1036    
1037                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1038    
1039                            msg.append("groupId=");
1040                            msg.append(groupId);
1041    
1042                            msg.append(", portletId=");
1043                            msg.append(portletId);
1044    
1045                            msg.append(", classNameId=");
1046                            msg.append(classNameId);
1047    
1048                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1049    
1050                            throw new NoSuchPortletItemException(msg.toString());
1051                    }
1052                    else {
1053                            return list.get(0);
1054                    }
1055            }
1056    
1057            /**
1058             * Finds the portlet items before and after the current portlet item in the ordered set where groupId = &#63; and portletId = &#63; and classNameId = &#63;.
1059             *
1060             * <p>
1061             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1062             * </p>
1063             *
1064             * @param portletItemId the primary key of the current portlet item
1065             * @param groupId the group id to search with
1066             * @param portletId the portlet id to search with
1067             * @param classNameId the class name id to search with
1068             * @param orderByComparator the comparator to order the set by
1069             * @return the previous, current, and next portlet item
1070             * @throws com.liferay.portal.NoSuchPortletItemException if a portlet item with the primary key could not be found
1071             * @throws SystemException if a system exception occurred
1072             */
1073            public PortletItem[] findByG_P_C_PrevAndNext(long portletItemId,
1074                    long groupId, String portletId, long classNameId,
1075                    OrderByComparator orderByComparator)
1076                    throws NoSuchPortletItemException, SystemException {
1077                    PortletItem portletItem = findByPrimaryKey(portletItemId);
1078    
1079                    Session session = null;
1080    
1081                    try {
1082                            session = openSession();
1083    
1084                            PortletItem[] array = new PortletItemImpl[3];
1085    
1086                            array[0] = getByG_P_C_PrevAndNext(session, portletItem, groupId,
1087                                            portletId, classNameId, orderByComparator, true);
1088    
1089                            array[1] = portletItem;
1090    
1091                            array[2] = getByG_P_C_PrevAndNext(session, portletItem, groupId,
1092                                            portletId, classNameId, orderByComparator, false);
1093    
1094                            return array;
1095                    }
1096                    catch (Exception e) {
1097                            throw processException(e);
1098                    }
1099                    finally {
1100                            closeSession(session);
1101                    }
1102            }
1103    
1104            protected PortletItem getByG_P_C_PrevAndNext(Session session,
1105                    PortletItem portletItem, long groupId, String portletId,
1106                    long classNameId, OrderByComparator orderByComparator, boolean previous) {
1107                    StringBundler query = null;
1108    
1109                    if (orderByComparator != null) {
1110                            query = new StringBundler(6 +
1111                                            (orderByComparator.getOrderByFields().length * 6));
1112                    }
1113                    else {
1114                            query = new StringBundler(3);
1115                    }
1116    
1117                    query.append(_SQL_SELECT_PORTLETITEM_WHERE);
1118    
1119                    query.append(_FINDER_COLUMN_G_P_C_GROUPID_2);
1120    
1121                    if (portletId == null) {
1122                            query.append(_FINDER_COLUMN_G_P_C_PORTLETID_1);
1123                    }
1124                    else {
1125                            if (portletId.equals(StringPool.BLANK)) {
1126                                    query.append(_FINDER_COLUMN_G_P_C_PORTLETID_3);
1127                            }
1128                            else {
1129                                    query.append(_FINDER_COLUMN_G_P_C_PORTLETID_2);
1130                            }
1131                    }
1132    
1133                    query.append(_FINDER_COLUMN_G_P_C_CLASSNAMEID_2);
1134    
1135                    if (orderByComparator != null) {
1136                            String[] orderByFields = orderByComparator.getOrderByFields();
1137    
1138                            if (orderByFields.length > 0) {
1139                                    query.append(WHERE_AND);
1140                            }
1141    
1142                            for (int i = 0; i < orderByFields.length; i++) {
1143                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1144                                    query.append(orderByFields[i]);
1145    
1146                                    if ((i + 1) < orderByFields.length) {
1147                                            if (orderByComparator.isAscending() ^ previous) {
1148                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1149                                            }
1150                                            else {
1151                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1152                                            }
1153                                    }
1154                                    else {
1155                                            if (orderByComparator.isAscending() ^ previous) {
1156                                                    query.append(WHERE_GREATER_THAN);
1157                                            }
1158                                            else {
1159                                                    query.append(WHERE_LESSER_THAN);
1160                                            }
1161                                    }
1162                            }
1163    
1164                            query.append(ORDER_BY_CLAUSE);
1165    
1166                            for (int i = 0; i < orderByFields.length; i++) {
1167                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1168                                    query.append(orderByFields[i]);
1169    
1170                                    if ((i + 1) < orderByFields.length) {
1171                                            if (orderByComparator.isAscending() ^ previous) {
1172                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1173                                            }
1174                                            else {
1175                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1176                                            }
1177                                    }
1178                                    else {
1179                                            if (orderByComparator.isAscending() ^ previous) {
1180                                                    query.append(ORDER_BY_ASC);
1181                                            }
1182                                            else {
1183                                                    query.append(ORDER_BY_DESC);
1184                                            }
1185                                    }
1186                            }
1187                    }
1188    
1189                    String sql = query.toString();
1190    
1191                    Query q = session.createQuery(sql);
1192    
1193                    q.setFirstResult(0);
1194                    q.setMaxResults(2);
1195    
1196                    QueryPos qPos = QueryPos.getInstance(q);
1197    
1198                    qPos.add(groupId);
1199    
1200                    if (portletId != null) {
1201                            qPos.add(portletId);
1202                    }
1203    
1204                    qPos.add(classNameId);
1205    
1206                    if (orderByComparator != null) {
1207                            Object[] values = orderByComparator.getOrderByValues(portletItem);
1208    
1209                            for (Object value : values) {
1210                                    qPos.add(value);
1211                            }
1212                    }
1213    
1214                    List<PortletItem> list = q.list();
1215    
1216                    if (list.size() == 2) {
1217                            return list.get(1);
1218                    }
1219                    else {
1220                            return null;
1221                    }
1222            }
1223    
1224            /**
1225             * Finds the portlet item where groupId = &#63; and name = &#63; and portletId = &#63; and classNameId = &#63; or throws a {@link com.liferay.portal.NoSuchPortletItemException} if it could not be found.
1226             *
1227             * @param groupId the group id to search with
1228             * @param name the name to search with
1229             * @param portletId the portlet id to search with
1230             * @param classNameId the class name id to search with
1231             * @return the matching portlet item
1232             * @throws com.liferay.portal.NoSuchPortletItemException if a matching portlet item could not be found
1233             * @throws SystemException if a system exception occurred
1234             */
1235            public PortletItem findByG_N_P_C(long groupId, String name,
1236                    String portletId, long classNameId)
1237                    throws NoSuchPortletItemException, SystemException {
1238                    PortletItem portletItem = fetchByG_N_P_C(groupId, name, portletId,
1239                                    classNameId);
1240    
1241                    if (portletItem == null) {
1242                            StringBundler msg = new StringBundler(10);
1243    
1244                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1245    
1246                            msg.append("groupId=");
1247                            msg.append(groupId);
1248    
1249                            msg.append(", name=");
1250                            msg.append(name);
1251    
1252                            msg.append(", portletId=");
1253                            msg.append(portletId);
1254    
1255                            msg.append(", classNameId=");
1256                            msg.append(classNameId);
1257    
1258                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1259    
1260                            if (_log.isWarnEnabled()) {
1261                                    _log.warn(msg.toString());
1262                            }
1263    
1264                            throw new NoSuchPortletItemException(msg.toString());
1265                    }
1266    
1267                    return portletItem;
1268            }
1269    
1270            /**
1271             * Finds the portlet item where groupId = &#63; and name = &#63; and portletId = &#63; and classNameId = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
1272             *
1273             * @param groupId the group id to search with
1274             * @param name the name to search with
1275             * @param portletId the portlet id to search with
1276             * @param classNameId the class name id to search with
1277             * @return the matching portlet item, or <code>null</code> if a matching portlet item could not be found
1278             * @throws SystemException if a system exception occurred
1279             */
1280            public PortletItem fetchByG_N_P_C(long groupId, String name,
1281                    String portletId, long classNameId) throws SystemException {
1282                    return fetchByG_N_P_C(groupId, name, portletId, classNameId, true);
1283            }
1284    
1285            /**
1286             * Finds the portlet item where groupId = &#63; and name = &#63; and portletId = &#63; and classNameId = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
1287             *
1288             * @param groupId the group id to search with
1289             * @param name the name to search with
1290             * @param portletId the portlet id to search with
1291             * @param classNameId the class name id to search with
1292             * @return the matching portlet item, or <code>null</code> if a matching portlet item could not be found
1293             * @throws SystemException if a system exception occurred
1294             */
1295            public PortletItem fetchByG_N_P_C(long groupId, String name,
1296                    String portletId, long classNameId, boolean retrieveFromCache)
1297                    throws SystemException {
1298                    Object[] finderArgs = new Object[] { groupId, name, portletId, classNameId };
1299    
1300                    Object result = null;
1301    
1302                    if (retrieveFromCache) {
1303                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_N_P_C,
1304                                            finderArgs, this);
1305                    }
1306    
1307                    if (result == null) {
1308                            Session session = null;
1309    
1310                            try {
1311                                    session = openSession();
1312    
1313                                    StringBundler query = new StringBundler(5);
1314    
1315                                    query.append(_SQL_SELECT_PORTLETITEM_WHERE);
1316    
1317                                    query.append(_FINDER_COLUMN_G_N_P_C_GROUPID_2);
1318    
1319                                    if (name == null) {
1320                                            query.append(_FINDER_COLUMN_G_N_P_C_NAME_1);
1321                                    }
1322                                    else {
1323                                            if (name.equals(StringPool.BLANK)) {
1324                                                    query.append(_FINDER_COLUMN_G_N_P_C_NAME_3);
1325                                            }
1326                                            else {
1327                                                    query.append(_FINDER_COLUMN_G_N_P_C_NAME_2);
1328                                            }
1329                                    }
1330    
1331                                    if (portletId == null) {
1332                                            query.append(_FINDER_COLUMN_G_N_P_C_PORTLETID_1);
1333                                    }
1334                                    else {
1335                                            if (portletId.equals(StringPool.BLANK)) {
1336                                                    query.append(_FINDER_COLUMN_G_N_P_C_PORTLETID_3);
1337                                            }
1338                                            else {
1339                                                    query.append(_FINDER_COLUMN_G_N_P_C_PORTLETID_2);
1340                                            }
1341                                    }
1342    
1343                                    query.append(_FINDER_COLUMN_G_N_P_C_CLASSNAMEID_2);
1344    
1345                                    String sql = query.toString();
1346    
1347                                    Query q = session.createQuery(sql);
1348    
1349                                    QueryPos qPos = QueryPos.getInstance(q);
1350    
1351                                    qPos.add(groupId);
1352    
1353                                    if (name != null) {
1354                                            qPos.add(name);
1355                                    }
1356    
1357                                    if (portletId != null) {
1358                                            qPos.add(portletId);
1359                                    }
1360    
1361                                    qPos.add(classNameId);
1362    
1363                                    List<PortletItem> list = q.list();
1364    
1365                                    result = list;
1366    
1367                                    PortletItem portletItem = null;
1368    
1369                                    if (list.isEmpty()) {
1370                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N_P_C,
1371                                                    finderArgs, list);
1372                                    }
1373                                    else {
1374                                            portletItem = list.get(0);
1375    
1376                                            cacheResult(portletItem);
1377    
1378                                            if ((portletItem.getGroupId() != groupId) ||
1379                                                            (portletItem.getName() == null) ||
1380                                                            !portletItem.getName().equals(name) ||
1381                                                            (portletItem.getPortletId() == null) ||
1382                                                            !portletItem.getPortletId().equals(portletId) ||
1383                                                            (portletItem.getClassNameId() != classNameId)) {
1384                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N_P_C,
1385                                                            finderArgs, portletItem);
1386                                            }
1387                                    }
1388    
1389                                    return portletItem;
1390                            }
1391                            catch (Exception e) {
1392                                    throw processException(e);
1393                            }
1394                            finally {
1395                                    if (result == null) {
1396                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N_P_C,
1397                                                    finderArgs, new ArrayList<PortletItem>());
1398                                    }
1399    
1400                                    closeSession(session);
1401                            }
1402                    }
1403                    else {
1404                            if (result instanceof List<?>) {
1405                                    return null;
1406                            }
1407                            else {
1408                                    return (PortletItem)result;
1409                            }
1410                    }
1411            }
1412    
1413            /**
1414             * Finds all the portlet items.
1415             *
1416             * @return the portlet items
1417             * @throws SystemException if a system exception occurred
1418             */
1419            public List<PortletItem> findAll() throws SystemException {
1420                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1421            }
1422    
1423            /**
1424             * Finds a range of all the portlet items.
1425             *
1426             * <p>
1427             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1428             * </p>
1429             *
1430             * @param start the lower bound of the range of portlet items to return
1431             * @param end the upper bound of the range of portlet items to return (not inclusive)
1432             * @return the range of portlet items
1433             * @throws SystemException if a system exception occurred
1434             */
1435            public List<PortletItem> findAll(int start, int end)
1436                    throws SystemException {
1437                    return findAll(start, end, null);
1438            }
1439    
1440            /**
1441             * Finds an ordered range of all the portlet items.
1442             *
1443             * <p>
1444             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1445             * </p>
1446             *
1447             * @param start the lower bound of the range of portlet items to return
1448             * @param end the upper bound of the range of portlet items to return (not inclusive)
1449             * @param orderByComparator the comparator to order the results by
1450             * @return the ordered range of portlet items
1451             * @throws SystemException if a system exception occurred
1452             */
1453            public List<PortletItem> findAll(int start, int end,
1454                    OrderByComparator orderByComparator) throws SystemException {
1455                    Object[] finderArgs = new Object[] {
1456                                    String.valueOf(start), String.valueOf(end),
1457                                    String.valueOf(orderByComparator)
1458                            };
1459    
1460                    List<PortletItem> list = (List<PortletItem>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
1461                                    finderArgs, this);
1462    
1463                    if (list == null) {
1464                            Session session = null;
1465    
1466                            try {
1467                                    session = openSession();
1468    
1469                                    StringBundler query = null;
1470                                    String sql = null;
1471    
1472                                    if (orderByComparator != null) {
1473                                            query = new StringBundler(2 +
1474                                                            (orderByComparator.getOrderByFields().length * 3));
1475    
1476                                            query.append(_SQL_SELECT_PORTLETITEM);
1477    
1478                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1479                                                    orderByComparator);
1480    
1481                                            sql = query.toString();
1482                                    }
1483                                    else {
1484                                            sql = _SQL_SELECT_PORTLETITEM;
1485                                    }
1486    
1487                                    Query q = session.createQuery(sql);
1488    
1489                                    if (orderByComparator == null) {
1490                                            list = (List<PortletItem>)QueryUtil.list(q, getDialect(),
1491                                                            start, end, false);
1492    
1493                                            Collections.sort(list);
1494                                    }
1495                                    else {
1496                                            list = (List<PortletItem>)QueryUtil.list(q, getDialect(),
1497                                                            start, end);
1498                                    }
1499                            }
1500                            catch (Exception e) {
1501                                    throw processException(e);
1502                            }
1503                            finally {
1504                                    if (list == null) {
1505                                            list = new ArrayList<PortletItem>();
1506                                    }
1507    
1508                                    cacheResult(list);
1509    
1510                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
1511    
1512                                    closeSession(session);
1513                            }
1514                    }
1515    
1516                    return list;
1517            }
1518    
1519            /**
1520             * Removes all the portlet items where groupId = &#63; and classNameId = &#63; from the database.
1521             *
1522             * @param groupId the group id to search with
1523             * @param classNameId the class name id to search with
1524             * @throws SystemException if a system exception occurred
1525             */
1526            public void removeByG_C(long groupId, long classNameId)
1527                    throws SystemException {
1528                    for (PortletItem portletItem : findByG_C(groupId, classNameId)) {
1529                            remove(portletItem);
1530                    }
1531            }
1532    
1533            /**
1534             * Removes all the portlet items where groupId = &#63; and portletId = &#63; and classNameId = &#63; from the database.
1535             *
1536             * @param groupId the group id to search with
1537             * @param portletId the portlet id to search with
1538             * @param classNameId the class name id to search with
1539             * @throws SystemException if a system exception occurred
1540             */
1541            public void removeByG_P_C(long groupId, String portletId, long classNameId)
1542                    throws SystemException {
1543                    for (PortletItem portletItem : findByG_P_C(groupId, portletId,
1544                                    classNameId)) {
1545                            remove(portletItem);
1546                    }
1547            }
1548    
1549            /**
1550             * Removes the portlet item where groupId = &#63; and name = &#63; and portletId = &#63; and classNameId = &#63; from the database.
1551             *
1552             * @param groupId the group id to search with
1553             * @param name the name to search with
1554             * @param portletId the portlet id to search with
1555             * @param classNameId the class name id to search with
1556             * @throws SystemException if a system exception occurred
1557             */
1558            public void removeByG_N_P_C(long groupId, String name, String portletId,
1559                    long classNameId) throws NoSuchPortletItemException, SystemException {
1560                    PortletItem portletItem = findByG_N_P_C(groupId, name, portletId,
1561                                    classNameId);
1562    
1563                    remove(portletItem);
1564            }
1565    
1566            /**
1567             * Removes all the portlet items from the database.
1568             *
1569             * @throws SystemException if a system exception occurred
1570             */
1571            public void removeAll() throws SystemException {
1572                    for (PortletItem portletItem : findAll()) {
1573                            remove(portletItem);
1574                    }
1575            }
1576    
1577            /**
1578             * Counts all the portlet items where groupId = &#63; and classNameId = &#63;.
1579             *
1580             * @param groupId the group id to search with
1581             * @param classNameId the class name id to search with
1582             * @return the number of matching portlet items
1583             * @throws SystemException if a system exception occurred
1584             */
1585            public int countByG_C(long groupId, long classNameId)
1586                    throws SystemException {
1587                    Object[] finderArgs = new Object[] { groupId, classNameId };
1588    
1589                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_C,
1590                                    finderArgs, this);
1591    
1592                    if (count == null) {
1593                            Session session = null;
1594    
1595                            try {
1596                                    session = openSession();
1597    
1598                                    StringBundler query = new StringBundler(3);
1599    
1600                                    query.append(_SQL_COUNT_PORTLETITEM_WHERE);
1601    
1602                                    query.append(_FINDER_COLUMN_G_C_GROUPID_2);
1603    
1604                                    query.append(_FINDER_COLUMN_G_C_CLASSNAMEID_2);
1605    
1606                                    String sql = query.toString();
1607    
1608                                    Query q = session.createQuery(sql);
1609    
1610                                    QueryPos qPos = QueryPos.getInstance(q);
1611    
1612                                    qPos.add(groupId);
1613    
1614                                    qPos.add(classNameId);
1615    
1616                                    count = (Long)q.uniqueResult();
1617                            }
1618                            catch (Exception e) {
1619                                    throw processException(e);
1620                            }
1621                            finally {
1622                                    if (count == null) {
1623                                            count = Long.valueOf(0);
1624                                    }
1625    
1626                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_C, finderArgs,
1627                                            count);
1628    
1629                                    closeSession(session);
1630                            }
1631                    }
1632    
1633                    return count.intValue();
1634            }
1635    
1636            /**
1637             * Counts all the portlet items where groupId = &#63; and portletId = &#63; and classNameId = &#63;.
1638             *
1639             * @param groupId the group id to search with
1640             * @param portletId the portlet id to search with
1641             * @param classNameId the class name id to search with
1642             * @return the number of matching portlet items
1643             * @throws SystemException if a system exception occurred
1644             */
1645            public int countByG_P_C(long groupId, String portletId, long classNameId)
1646                    throws SystemException {
1647                    Object[] finderArgs = new Object[] { groupId, portletId, classNameId };
1648    
1649                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_P_C,
1650                                    finderArgs, this);
1651    
1652                    if (count == null) {
1653                            Session session = null;
1654    
1655                            try {
1656                                    session = openSession();
1657    
1658                                    StringBundler query = new StringBundler(4);
1659    
1660                                    query.append(_SQL_COUNT_PORTLETITEM_WHERE);
1661    
1662                                    query.append(_FINDER_COLUMN_G_P_C_GROUPID_2);
1663    
1664                                    if (portletId == null) {
1665                                            query.append(_FINDER_COLUMN_G_P_C_PORTLETID_1);
1666                                    }
1667                                    else {
1668                                            if (portletId.equals(StringPool.BLANK)) {
1669                                                    query.append(_FINDER_COLUMN_G_P_C_PORTLETID_3);
1670                                            }
1671                                            else {
1672                                                    query.append(_FINDER_COLUMN_G_P_C_PORTLETID_2);
1673                                            }
1674                                    }
1675    
1676                                    query.append(_FINDER_COLUMN_G_P_C_CLASSNAMEID_2);
1677    
1678                                    String sql = query.toString();
1679    
1680                                    Query q = session.createQuery(sql);
1681    
1682                                    QueryPos qPos = QueryPos.getInstance(q);
1683    
1684                                    qPos.add(groupId);
1685    
1686                                    if (portletId != null) {
1687                                            qPos.add(portletId);
1688                                    }
1689    
1690                                    qPos.add(classNameId);
1691    
1692                                    count = (Long)q.uniqueResult();
1693                            }
1694                            catch (Exception e) {
1695                                    throw processException(e);
1696                            }
1697                            finally {
1698                                    if (count == null) {
1699                                            count = Long.valueOf(0);
1700                                    }
1701    
1702                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_P_C,
1703                                            finderArgs, count);
1704    
1705                                    closeSession(session);
1706                            }
1707                    }
1708    
1709                    return count.intValue();
1710            }
1711    
1712            /**
1713             * Counts all the portlet items where groupId = &#63; and name = &#63; and portletId = &#63; and classNameId = &#63;.
1714             *
1715             * @param groupId the group id to search with
1716             * @param name the name to search with
1717             * @param portletId the portlet id to search with
1718             * @param classNameId the class name id to search with
1719             * @return the number of matching portlet items
1720             * @throws SystemException if a system exception occurred
1721             */
1722            public int countByG_N_P_C(long groupId, String name, String portletId,
1723                    long classNameId) throws SystemException {
1724                    Object[] finderArgs = new Object[] { groupId, name, portletId, classNameId };
1725    
1726                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_N_P_C,
1727                                    finderArgs, this);
1728    
1729                    if (count == null) {
1730                            Session session = null;
1731    
1732                            try {
1733                                    session = openSession();
1734    
1735                                    StringBundler query = new StringBundler(5);
1736    
1737                                    query.append(_SQL_COUNT_PORTLETITEM_WHERE);
1738    
1739                                    query.append(_FINDER_COLUMN_G_N_P_C_GROUPID_2);
1740    
1741                                    if (name == null) {
1742                                            query.append(_FINDER_COLUMN_G_N_P_C_NAME_1);
1743                                    }
1744                                    else {
1745                                            if (name.equals(StringPool.BLANK)) {
1746                                                    query.append(_FINDER_COLUMN_G_N_P_C_NAME_3);
1747                                            }
1748                                            else {
1749                                                    query.append(_FINDER_COLUMN_G_N_P_C_NAME_2);
1750                                            }
1751                                    }
1752    
1753                                    if (portletId == null) {
1754                                            query.append(_FINDER_COLUMN_G_N_P_C_PORTLETID_1);
1755                                    }
1756                                    else {
1757                                            if (portletId.equals(StringPool.BLANK)) {
1758                                                    query.append(_FINDER_COLUMN_G_N_P_C_PORTLETID_3);
1759                                            }
1760                                            else {
1761                                                    query.append(_FINDER_COLUMN_G_N_P_C_PORTLETID_2);
1762                                            }
1763                                    }
1764    
1765                                    query.append(_FINDER_COLUMN_G_N_P_C_CLASSNAMEID_2);
1766    
1767                                    String sql = query.toString();
1768    
1769                                    Query q = session.createQuery(sql);
1770    
1771                                    QueryPos qPos = QueryPos.getInstance(q);
1772    
1773                                    qPos.add(groupId);
1774    
1775                                    if (name != null) {
1776                                            qPos.add(name);
1777                                    }
1778    
1779                                    if (portletId != null) {
1780                                            qPos.add(portletId);
1781                                    }
1782    
1783                                    qPos.add(classNameId);
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_N_P_C,
1796                                            finderArgs, count);
1797    
1798                                    closeSession(session);
1799                            }
1800                    }
1801    
1802                    return count.intValue();
1803            }
1804    
1805            /**
1806             * Counts all the portlet items.
1807             *
1808             * @return the number of portlet items
1809             * @throws SystemException if a system exception occurred
1810             */
1811            public int countAll() throws SystemException {
1812                    Object[] finderArgs = new Object[0];
1813    
1814                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1815                                    finderArgs, this);
1816    
1817                    if (count == null) {
1818                            Session session = null;
1819    
1820                            try {
1821                                    session = openSession();
1822    
1823                                    Query q = session.createQuery(_SQL_COUNT_PORTLETITEM);
1824    
1825                                    count = (Long)q.uniqueResult();
1826                            }
1827                            catch (Exception e) {
1828                                    throw processException(e);
1829                            }
1830                            finally {
1831                                    if (count == null) {
1832                                            count = Long.valueOf(0);
1833                                    }
1834    
1835                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
1836                                            count);
1837    
1838                                    closeSession(session);
1839                            }
1840                    }
1841    
1842                    return count.intValue();
1843            }
1844    
1845            /**
1846             * Initializes the portlet item persistence.
1847             */
1848            public void afterPropertiesSet() {
1849                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1850                                            com.liferay.portal.util.PropsUtil.get(
1851                                                    "value.object.listener.com.liferay.portal.model.PortletItem")));
1852    
1853                    if (listenerClassNames.length > 0) {
1854                            try {
1855                                    List<ModelListener<PortletItem>> listenersList = new ArrayList<ModelListener<PortletItem>>();
1856    
1857                                    for (String listenerClassName : listenerClassNames) {
1858                                            listenersList.add((ModelListener<PortletItem>)InstanceFactory.newInstance(
1859                                                            listenerClassName));
1860                                    }
1861    
1862                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1863                            }
1864                            catch (Exception e) {
1865                                    _log.error(e);
1866                            }
1867                    }
1868            }
1869    
1870            public void destroy() {
1871                    EntityCacheUtil.removeCache(PortletItemImpl.class.getName());
1872                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
1873                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST);
1874            }
1875    
1876            @BeanReference(type = AccountPersistence.class)
1877            protected AccountPersistence accountPersistence;
1878            @BeanReference(type = AddressPersistence.class)
1879            protected AddressPersistence addressPersistence;
1880            @BeanReference(type = BrowserTrackerPersistence.class)
1881            protected BrowserTrackerPersistence browserTrackerPersistence;
1882            @BeanReference(type = ClassNamePersistence.class)
1883            protected ClassNamePersistence classNamePersistence;
1884            @BeanReference(type = ClusterGroupPersistence.class)
1885            protected ClusterGroupPersistence clusterGroupPersistence;
1886            @BeanReference(type = CompanyPersistence.class)
1887            protected CompanyPersistence companyPersistence;
1888            @BeanReference(type = ContactPersistence.class)
1889            protected ContactPersistence contactPersistence;
1890            @BeanReference(type = CountryPersistence.class)
1891            protected CountryPersistence countryPersistence;
1892            @BeanReference(type = EmailAddressPersistence.class)
1893            protected EmailAddressPersistence emailAddressPersistence;
1894            @BeanReference(type = GroupPersistence.class)
1895            protected GroupPersistence groupPersistence;
1896            @BeanReference(type = ImagePersistence.class)
1897            protected ImagePersistence imagePersistence;
1898            @BeanReference(type = LayoutPersistence.class)
1899            protected LayoutPersistence layoutPersistence;
1900            @BeanReference(type = LayoutPrototypePersistence.class)
1901            protected LayoutPrototypePersistence layoutPrototypePersistence;
1902            @BeanReference(type = LayoutSetPersistence.class)
1903            protected LayoutSetPersistence layoutSetPersistence;
1904            @BeanReference(type = LayoutSetPrototypePersistence.class)
1905            protected LayoutSetPrototypePersistence layoutSetPrototypePersistence;
1906            @BeanReference(type = ListTypePersistence.class)
1907            protected ListTypePersistence listTypePersistence;
1908            @BeanReference(type = LockPersistence.class)
1909            protected LockPersistence lockPersistence;
1910            @BeanReference(type = MembershipRequestPersistence.class)
1911            protected MembershipRequestPersistence membershipRequestPersistence;
1912            @BeanReference(type = OrganizationPersistence.class)
1913            protected OrganizationPersistence organizationPersistence;
1914            @BeanReference(type = OrgGroupPermissionPersistence.class)
1915            protected OrgGroupPermissionPersistence orgGroupPermissionPersistence;
1916            @BeanReference(type = OrgGroupRolePersistence.class)
1917            protected OrgGroupRolePersistence orgGroupRolePersistence;
1918            @BeanReference(type = OrgLaborPersistence.class)
1919            protected OrgLaborPersistence orgLaborPersistence;
1920            @BeanReference(type = PasswordPolicyPersistence.class)
1921            protected PasswordPolicyPersistence passwordPolicyPersistence;
1922            @BeanReference(type = PasswordPolicyRelPersistence.class)
1923            protected PasswordPolicyRelPersistence passwordPolicyRelPersistence;
1924            @BeanReference(type = PasswordTrackerPersistence.class)
1925            protected PasswordTrackerPersistence passwordTrackerPersistence;
1926            @BeanReference(type = PermissionPersistence.class)
1927            protected PermissionPersistence permissionPersistence;
1928            @BeanReference(type = PhonePersistence.class)
1929            protected PhonePersistence phonePersistence;
1930            @BeanReference(type = PluginSettingPersistence.class)
1931            protected PluginSettingPersistence pluginSettingPersistence;
1932            @BeanReference(type = PortletPersistence.class)
1933            protected PortletPersistence portletPersistence;
1934            @BeanReference(type = PortletItemPersistence.class)
1935            protected PortletItemPersistence portletItemPersistence;
1936            @BeanReference(type = PortletPreferencesPersistence.class)
1937            protected PortletPreferencesPersistence portletPreferencesPersistence;
1938            @BeanReference(type = RegionPersistence.class)
1939            protected RegionPersistence regionPersistence;
1940            @BeanReference(type = ReleasePersistence.class)
1941            protected ReleasePersistence releasePersistence;
1942            @BeanReference(type = ResourcePersistence.class)
1943            protected ResourcePersistence resourcePersistence;
1944            @BeanReference(type = ResourceActionPersistence.class)
1945            protected ResourceActionPersistence resourceActionPersistence;
1946            @BeanReference(type = ResourceCodePersistence.class)
1947            protected ResourceCodePersistence resourceCodePersistence;
1948            @BeanReference(type = ResourcePermissionPersistence.class)
1949            protected ResourcePermissionPersistence resourcePermissionPersistence;
1950            @BeanReference(type = RolePersistence.class)
1951            protected RolePersistence rolePersistence;
1952            @BeanReference(type = ServiceComponentPersistence.class)
1953            protected ServiceComponentPersistence serviceComponentPersistence;
1954            @BeanReference(type = ShardPersistence.class)
1955            protected ShardPersistence shardPersistence;
1956            @BeanReference(type = SubscriptionPersistence.class)
1957            protected SubscriptionPersistence subscriptionPersistence;
1958            @BeanReference(type = TicketPersistence.class)
1959            protected TicketPersistence ticketPersistence;
1960            @BeanReference(type = TeamPersistence.class)
1961            protected TeamPersistence teamPersistence;
1962            @BeanReference(type = UserPersistence.class)
1963            protected UserPersistence userPersistence;
1964            @BeanReference(type = UserGroupPersistence.class)
1965            protected UserGroupPersistence userGroupPersistence;
1966            @BeanReference(type = UserGroupGroupRolePersistence.class)
1967            protected UserGroupGroupRolePersistence userGroupGroupRolePersistence;
1968            @BeanReference(type = UserGroupRolePersistence.class)
1969            protected UserGroupRolePersistence userGroupRolePersistence;
1970            @BeanReference(type = UserIdMapperPersistence.class)
1971            protected UserIdMapperPersistence userIdMapperPersistence;
1972            @BeanReference(type = UserTrackerPersistence.class)
1973            protected UserTrackerPersistence userTrackerPersistence;
1974            @BeanReference(type = UserTrackerPathPersistence.class)
1975            protected UserTrackerPathPersistence userTrackerPathPersistence;
1976            @BeanReference(type = WebDAVPropsPersistence.class)
1977            protected WebDAVPropsPersistence webDAVPropsPersistence;
1978            @BeanReference(type = WebsitePersistence.class)
1979            protected WebsitePersistence websitePersistence;
1980            @BeanReference(type = WorkflowDefinitionLinkPersistence.class)
1981            protected WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
1982            @BeanReference(type = WorkflowInstanceLinkPersistence.class)
1983            protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
1984            private static final String _SQL_SELECT_PORTLETITEM = "SELECT portletItem FROM PortletItem portletItem";
1985            private static final String _SQL_SELECT_PORTLETITEM_WHERE = "SELECT portletItem FROM PortletItem portletItem WHERE ";
1986            private static final String _SQL_COUNT_PORTLETITEM = "SELECT COUNT(portletItem) FROM PortletItem portletItem";
1987            private static final String _SQL_COUNT_PORTLETITEM_WHERE = "SELECT COUNT(portletItem) FROM PortletItem portletItem WHERE ";
1988            private static final String _FINDER_COLUMN_G_C_GROUPID_2 = "portletItem.groupId = ? AND ";
1989            private static final String _FINDER_COLUMN_G_C_CLASSNAMEID_2 = "portletItem.classNameId = ?";
1990            private static final String _FINDER_COLUMN_G_P_C_GROUPID_2 = "portletItem.groupId = ? AND ";
1991            private static final String _FINDER_COLUMN_G_P_C_PORTLETID_1 = "portletItem.portletId IS NULL AND ";
1992            private static final String _FINDER_COLUMN_G_P_C_PORTLETID_2 = "portletItem.portletId = ? AND ";
1993            private static final String _FINDER_COLUMN_G_P_C_PORTLETID_3 = "(portletItem.portletId IS NULL OR portletItem.portletId = ?) AND ";
1994            private static final String _FINDER_COLUMN_G_P_C_CLASSNAMEID_2 = "portletItem.classNameId = ?";
1995            private static final String _FINDER_COLUMN_G_N_P_C_GROUPID_2 = "portletItem.groupId = ? AND ";
1996            private static final String _FINDER_COLUMN_G_N_P_C_NAME_1 = "portletItem.name IS NULL AND ";
1997            private static final String _FINDER_COLUMN_G_N_P_C_NAME_2 = "lower(portletItem.name) = lower(?) AND ";
1998            private static final String _FINDER_COLUMN_G_N_P_C_NAME_3 = "(portletItem.name IS NULL OR lower(portletItem.name) = lower(?)) AND ";
1999            private static final String _FINDER_COLUMN_G_N_P_C_PORTLETID_1 = "portletItem.portletId IS NULL AND ";
2000            private static final String _FINDER_COLUMN_G_N_P_C_PORTLETID_2 = "portletItem.portletId = ? AND ";
2001            private static final String _FINDER_COLUMN_G_N_P_C_PORTLETID_3 = "(portletItem.portletId IS NULL OR portletItem.portletId = ?) AND ";
2002            private static final String _FINDER_COLUMN_G_N_P_C_CLASSNAMEID_2 = "portletItem.classNameId = ?";
2003            private static final String _ORDER_BY_ENTITY_ALIAS = "portletItem.";
2004            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No PortletItem exists with the primary key ";
2005            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No PortletItem exists with the key {";
2006            private static Log _log = LogFactoryUtil.getLog(PortletItemPersistenceImpl.class);
2007    }