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.NoSuchPortletPreferencesException;
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.PortletPreferences;
040    import com.liferay.portal.model.impl.PortletPreferencesImpl;
041    import com.liferay.portal.model.impl.PortletPreferencesModelImpl;
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 preferences service.
052     *
053     * <p>
054     * Never modify or reference this class directly. Always use {@link PortletPreferencesUtil} to access the portlet preferences 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 PortletPreferencesPersistence
063     * @see PortletPreferencesUtil
064     * @generated
065     */
066    public class PortletPreferencesPersistenceImpl extends BasePersistenceImpl<PortletPreferences>
067            implements PortletPreferencesPersistence {
068            public static final String FINDER_CLASS_NAME_ENTITY = PortletPreferencesImpl.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_PLID = new FinderPath(PortletPreferencesModelImpl.ENTITY_CACHE_ENABLED,
072                            PortletPreferencesModelImpl.FINDER_CACHE_ENABLED,
073                            FINDER_CLASS_NAME_LIST, "findByPlid",
074                            new String[] {
075                                    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_PLID = new FinderPath(PortletPreferencesModelImpl.ENTITY_CACHE_ENABLED,
081                            PortletPreferencesModelImpl.FINDER_CACHE_ENABLED,
082                            FINDER_CLASS_NAME_LIST, "countByPlid",
083                            new String[] { Long.class.getName() });
084            public static final FinderPath FINDER_PATH_FIND_BY_P_P = new FinderPath(PortletPreferencesModelImpl.ENTITY_CACHE_ENABLED,
085                            PortletPreferencesModelImpl.FINDER_CACHE_ENABLED,
086                            FINDER_CLASS_NAME_LIST, "findByP_P",
087                            new String[] {
088                                    Long.class.getName(), String.class.getName(),
089                                    
090                            "java.lang.Integer", "java.lang.Integer",
091                                    "com.liferay.portal.kernel.util.OrderByComparator"
092                            });
093            public static final FinderPath FINDER_PATH_COUNT_BY_P_P = new FinderPath(PortletPreferencesModelImpl.ENTITY_CACHE_ENABLED,
094                            PortletPreferencesModelImpl.FINDER_CACHE_ENABLED,
095                            FINDER_CLASS_NAME_LIST, "countByP_P",
096                            new String[] { Long.class.getName(), String.class.getName() });
097            public static final FinderPath FINDER_PATH_FIND_BY_O_O_P = new FinderPath(PortletPreferencesModelImpl.ENTITY_CACHE_ENABLED,
098                            PortletPreferencesModelImpl.FINDER_CACHE_ENABLED,
099                            FINDER_CLASS_NAME_LIST, "findByO_O_P",
100                            new String[] {
101                                    Long.class.getName(), Integer.class.getName(),
102                                    Long.class.getName(),
103                                    
104                            "java.lang.Integer", "java.lang.Integer",
105                                    "com.liferay.portal.kernel.util.OrderByComparator"
106                            });
107            public static final FinderPath FINDER_PATH_COUNT_BY_O_O_P = new FinderPath(PortletPreferencesModelImpl.ENTITY_CACHE_ENABLED,
108                            PortletPreferencesModelImpl.FINDER_CACHE_ENABLED,
109                            FINDER_CLASS_NAME_LIST, "countByO_O_P",
110                            new String[] {
111                                    Long.class.getName(), Integer.class.getName(),
112                                    Long.class.getName()
113                            });
114            public static final FinderPath FINDER_PATH_FETCH_BY_O_O_P_P = new FinderPath(PortletPreferencesModelImpl.ENTITY_CACHE_ENABLED,
115                            PortletPreferencesModelImpl.FINDER_CACHE_ENABLED,
116                            FINDER_CLASS_NAME_ENTITY, "fetchByO_O_P_P",
117                            new String[] {
118                                    Long.class.getName(), Integer.class.getName(),
119                                    Long.class.getName(), String.class.getName()
120                            });
121            public static final FinderPath FINDER_PATH_COUNT_BY_O_O_P_P = new FinderPath(PortletPreferencesModelImpl.ENTITY_CACHE_ENABLED,
122                            PortletPreferencesModelImpl.FINDER_CACHE_ENABLED,
123                            FINDER_CLASS_NAME_LIST, "countByO_O_P_P",
124                            new String[] {
125                                    Long.class.getName(), Integer.class.getName(),
126                                    Long.class.getName(), String.class.getName()
127                            });
128            public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(PortletPreferencesModelImpl.ENTITY_CACHE_ENABLED,
129                            PortletPreferencesModelImpl.FINDER_CACHE_ENABLED,
130                            FINDER_CLASS_NAME_LIST, "findAll", new String[0]);
131            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(PortletPreferencesModelImpl.ENTITY_CACHE_ENABLED,
132                            PortletPreferencesModelImpl.FINDER_CACHE_ENABLED,
133                            FINDER_CLASS_NAME_LIST, "countAll", new String[0]);
134    
135            /**
136             * Caches the portlet preferences in the entity cache if it is enabled.
137             *
138             * @param portletPreferences the portlet preferences to cache
139             */
140            public void cacheResult(PortletPreferences portletPreferences) {
141                    EntityCacheUtil.putResult(PortletPreferencesModelImpl.ENTITY_CACHE_ENABLED,
142                            PortletPreferencesImpl.class, portletPreferences.getPrimaryKey(),
143                            portletPreferences);
144    
145                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_O_O_P_P,
146                            new Object[] {
147                                    new Long(portletPreferences.getOwnerId()),
148                                    new Integer(portletPreferences.getOwnerType()),
149                                    new Long(portletPreferences.getPlid()),
150                                    
151                            portletPreferences.getPortletId()
152                            }, portletPreferences);
153            }
154    
155            /**
156             * Caches the portlet preferenceses in the entity cache if it is enabled.
157             *
158             * @param portletPreferenceses the portlet preferenceses to cache
159             */
160            public void cacheResult(List<PortletPreferences> portletPreferenceses) {
161                    for (PortletPreferences portletPreferences : portletPreferenceses) {
162                            if (EntityCacheUtil.getResult(
163                                                    PortletPreferencesModelImpl.ENTITY_CACHE_ENABLED,
164                                                    PortletPreferencesImpl.class,
165                                                    portletPreferences.getPrimaryKey(), this) == null) {
166                                    cacheResult(portletPreferences);
167                            }
168                    }
169            }
170    
171            /**
172             * Clears the cache for all portlet preferenceses.
173             *
174             * <p>
175             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
176             * </p>
177             */
178            public void clearCache() {
179                    CacheRegistryUtil.clear(PortletPreferencesImpl.class.getName());
180                    EntityCacheUtil.clearCache(PortletPreferencesImpl.class.getName());
181                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
182                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
183            }
184    
185            /**
186             * Clears the cache for the portlet preferences.
187             *
188             * <p>
189             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
190             * </p>
191             */
192            public void clearCache(PortletPreferences portletPreferences) {
193                    EntityCacheUtil.removeResult(PortletPreferencesModelImpl.ENTITY_CACHE_ENABLED,
194                            PortletPreferencesImpl.class, portletPreferences.getPrimaryKey());
195    
196                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_O_O_P_P,
197                            new Object[] {
198                                    new Long(portletPreferences.getOwnerId()),
199                                    new Integer(portletPreferences.getOwnerType()),
200                                    new Long(portletPreferences.getPlid()),
201                                    
202                            portletPreferences.getPortletId()
203                            });
204            }
205    
206            /**
207             * Creates a new portlet preferences with the primary key. Does not add the portlet preferences to the database.
208             *
209             * @param portletPreferencesId the primary key for the new portlet preferences
210             * @return the new portlet preferences
211             */
212            public PortletPreferences create(long portletPreferencesId) {
213                    PortletPreferences portletPreferences = new PortletPreferencesImpl();
214    
215                    portletPreferences.setNew(true);
216                    portletPreferences.setPrimaryKey(portletPreferencesId);
217    
218                    return portletPreferences;
219            }
220    
221            /**
222             * Removes the portlet preferences with the primary key from the database. Also notifies the appropriate model listeners.
223             *
224             * @param primaryKey the primary key of the portlet preferences to remove
225             * @return the portlet preferences that was removed
226             * @throws com.liferay.portal.NoSuchModelException if a portlet preferences with the primary key could not be found
227             * @throws SystemException if a system exception occurred
228             */
229            public PortletPreferences remove(Serializable primaryKey)
230                    throws NoSuchModelException, SystemException {
231                    return remove(((Long)primaryKey).longValue());
232            }
233    
234            /**
235             * Removes the portlet preferences with the primary key from the database. Also notifies the appropriate model listeners.
236             *
237             * @param portletPreferencesId the primary key of the portlet preferences to remove
238             * @return the portlet preferences that was removed
239             * @throws com.liferay.portal.NoSuchPortletPreferencesException if a portlet preferences with the primary key could not be found
240             * @throws SystemException if a system exception occurred
241             */
242            public PortletPreferences remove(long portletPreferencesId)
243                    throws NoSuchPortletPreferencesException, SystemException {
244                    Session session = null;
245    
246                    try {
247                            session = openSession();
248    
249                            PortletPreferences portletPreferences = (PortletPreferences)session.get(PortletPreferencesImpl.class,
250                                            new Long(portletPreferencesId));
251    
252                            if (portletPreferences == null) {
253                                    if (_log.isWarnEnabled()) {
254                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
255                                                    portletPreferencesId);
256                                    }
257    
258                                    throw new NoSuchPortletPreferencesException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
259                                            portletPreferencesId);
260                            }
261    
262                            return remove(portletPreferences);
263                    }
264                    catch (NoSuchPortletPreferencesException nsee) {
265                            throw nsee;
266                    }
267                    catch (Exception e) {
268                            throw processException(e);
269                    }
270                    finally {
271                            closeSession(session);
272                    }
273            }
274    
275            protected PortletPreferences removeImpl(
276                    PortletPreferences portletPreferences) throws SystemException {
277                    portletPreferences = toUnwrappedModel(portletPreferences);
278    
279                    Session session = null;
280    
281                    try {
282                            session = openSession();
283    
284                            BatchSessionUtil.delete(session, portletPreferences);
285                    }
286                    catch (Exception e) {
287                            throw processException(e);
288                    }
289                    finally {
290                            closeSession(session);
291                    }
292    
293                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
294    
295                    PortletPreferencesModelImpl portletPreferencesModelImpl = (PortletPreferencesModelImpl)portletPreferences;
296    
297                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_O_O_P_P,
298                            new Object[] {
299                                    new Long(portletPreferencesModelImpl.getOriginalOwnerId()),
300                                    new Integer(portletPreferencesModelImpl.getOriginalOwnerType()),
301                                    new Long(portletPreferencesModelImpl.getOriginalPlid()),
302                                    
303                            portletPreferencesModelImpl.getOriginalPortletId()
304                            });
305    
306                    EntityCacheUtil.removeResult(PortletPreferencesModelImpl.ENTITY_CACHE_ENABLED,
307                            PortletPreferencesImpl.class, portletPreferences.getPrimaryKey());
308    
309                    return portletPreferences;
310            }
311    
312            public PortletPreferences updateImpl(
313                    com.liferay.portal.model.PortletPreferences portletPreferences,
314                    boolean merge) throws SystemException {
315                    portletPreferences = toUnwrappedModel(portletPreferences);
316    
317                    boolean isNew = portletPreferences.isNew();
318    
319                    PortletPreferencesModelImpl portletPreferencesModelImpl = (PortletPreferencesModelImpl)portletPreferences;
320    
321                    Session session = null;
322    
323                    try {
324                            session = openSession();
325    
326                            BatchSessionUtil.update(session, portletPreferences, merge);
327    
328                            portletPreferences.setNew(false);
329                    }
330                    catch (Exception e) {
331                            throw processException(e);
332                    }
333                    finally {
334                            closeSession(session);
335                    }
336    
337                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
338    
339                    EntityCacheUtil.putResult(PortletPreferencesModelImpl.ENTITY_CACHE_ENABLED,
340                            PortletPreferencesImpl.class, portletPreferences.getPrimaryKey(),
341                            portletPreferences);
342    
343                    if (!isNew &&
344                                    ((portletPreferences.getOwnerId() != portletPreferencesModelImpl.getOriginalOwnerId()) ||
345                                    (portletPreferences.getOwnerType() != portletPreferencesModelImpl.getOriginalOwnerType()) ||
346                                    (portletPreferences.getPlid() != portletPreferencesModelImpl.getOriginalPlid()) ||
347                                    !Validator.equals(portletPreferences.getPortletId(),
348                                            portletPreferencesModelImpl.getOriginalPortletId()))) {
349                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_O_O_P_P,
350                                    new Object[] {
351                                            new Long(portletPreferencesModelImpl.getOriginalOwnerId()),
352                                            new Integer(portletPreferencesModelImpl.getOriginalOwnerType()),
353                                            new Long(portletPreferencesModelImpl.getOriginalPlid()),
354                                            
355                                    portletPreferencesModelImpl.getOriginalPortletId()
356                                    });
357                    }
358    
359                    if (isNew ||
360                                    ((portletPreferences.getOwnerId() != portletPreferencesModelImpl.getOriginalOwnerId()) ||
361                                    (portletPreferences.getOwnerType() != portletPreferencesModelImpl.getOriginalOwnerType()) ||
362                                    (portletPreferences.getPlid() != portletPreferencesModelImpl.getOriginalPlid()) ||
363                                    !Validator.equals(portletPreferences.getPortletId(),
364                                            portletPreferencesModelImpl.getOriginalPortletId()))) {
365                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_O_O_P_P,
366                                    new Object[] {
367                                            new Long(portletPreferences.getOwnerId()),
368                                            new Integer(portletPreferences.getOwnerType()),
369                                            new Long(portletPreferences.getPlid()),
370                                            
371                                    portletPreferences.getPortletId()
372                                    }, portletPreferences);
373                    }
374    
375                    return portletPreferences;
376            }
377    
378            protected PortletPreferences toUnwrappedModel(
379                    PortletPreferences portletPreferences) {
380                    if (portletPreferences instanceof PortletPreferencesImpl) {
381                            return portletPreferences;
382                    }
383    
384                    PortletPreferencesImpl portletPreferencesImpl = new PortletPreferencesImpl();
385    
386                    portletPreferencesImpl.setNew(portletPreferences.isNew());
387                    portletPreferencesImpl.setPrimaryKey(portletPreferences.getPrimaryKey());
388    
389                    portletPreferencesImpl.setPortletPreferencesId(portletPreferences.getPortletPreferencesId());
390                    portletPreferencesImpl.setOwnerId(portletPreferences.getOwnerId());
391                    portletPreferencesImpl.setOwnerType(portletPreferences.getOwnerType());
392                    portletPreferencesImpl.setPlid(portletPreferences.getPlid());
393                    portletPreferencesImpl.setPortletId(portletPreferences.getPortletId());
394                    portletPreferencesImpl.setPreferences(portletPreferences.getPreferences());
395    
396                    return portletPreferencesImpl;
397            }
398    
399            /**
400             * Finds the portlet preferences with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
401             *
402             * @param primaryKey the primary key of the portlet preferences to find
403             * @return the portlet preferences
404             * @throws com.liferay.portal.NoSuchModelException if a portlet preferences with the primary key could not be found
405             * @throws SystemException if a system exception occurred
406             */
407            public PortletPreferences findByPrimaryKey(Serializable primaryKey)
408                    throws NoSuchModelException, SystemException {
409                    return findByPrimaryKey(((Long)primaryKey).longValue());
410            }
411    
412            /**
413             * Finds the portlet preferences with the primary key or throws a {@link com.liferay.portal.NoSuchPortletPreferencesException} if it could not be found.
414             *
415             * @param portletPreferencesId the primary key of the portlet preferences to find
416             * @return the portlet preferences
417             * @throws com.liferay.portal.NoSuchPortletPreferencesException if a portlet preferences with the primary key could not be found
418             * @throws SystemException if a system exception occurred
419             */
420            public PortletPreferences findByPrimaryKey(long portletPreferencesId)
421                    throws NoSuchPortletPreferencesException, SystemException {
422                    PortletPreferences portletPreferences = fetchByPrimaryKey(portletPreferencesId);
423    
424                    if (portletPreferences == null) {
425                            if (_log.isWarnEnabled()) {
426                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
427                                            portletPreferencesId);
428                            }
429    
430                            throw new NoSuchPortletPreferencesException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
431                                    portletPreferencesId);
432                    }
433    
434                    return portletPreferences;
435            }
436    
437            /**
438             * Finds the portlet preferences with the primary key or returns <code>null</code> if it could not be found.
439             *
440             * @param primaryKey the primary key of the portlet preferences to find
441             * @return the portlet preferences, or <code>null</code> if a portlet preferences with the primary key could not be found
442             * @throws SystemException if a system exception occurred
443             */
444            public PortletPreferences fetchByPrimaryKey(Serializable primaryKey)
445                    throws SystemException {
446                    return fetchByPrimaryKey(((Long)primaryKey).longValue());
447            }
448    
449            /**
450             * Finds the portlet preferences with the primary key or returns <code>null</code> if it could not be found.
451             *
452             * @param portletPreferencesId the primary key of the portlet preferences to find
453             * @return the portlet preferences, or <code>null</code> if a portlet preferences with the primary key could not be found
454             * @throws SystemException if a system exception occurred
455             */
456            public PortletPreferences fetchByPrimaryKey(long portletPreferencesId)
457                    throws SystemException {
458                    PortletPreferences portletPreferences = (PortletPreferences)EntityCacheUtil.getResult(PortletPreferencesModelImpl.ENTITY_CACHE_ENABLED,
459                                    PortletPreferencesImpl.class, portletPreferencesId, this);
460    
461                    if (portletPreferences == null) {
462                            Session session = null;
463    
464                            try {
465                                    session = openSession();
466    
467                                    portletPreferences = (PortletPreferences)session.get(PortletPreferencesImpl.class,
468                                                    new Long(portletPreferencesId));
469                            }
470                            catch (Exception e) {
471                                    throw processException(e);
472                            }
473                            finally {
474                                    if (portletPreferences != null) {
475                                            cacheResult(portletPreferences);
476                                    }
477    
478                                    closeSession(session);
479                            }
480                    }
481    
482                    return portletPreferences;
483            }
484    
485            /**
486             * Finds all the portlet preferenceses where plid = &#63;.
487             *
488             * @param plid the plid to search with
489             * @return the matching portlet preferenceses
490             * @throws SystemException if a system exception occurred
491             */
492            public List<PortletPreferences> findByPlid(long plid)
493                    throws SystemException {
494                    return findByPlid(plid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
495            }
496    
497            /**
498             * Finds a range of all the portlet preferenceses where plid = &#63;.
499             *
500             * <p>
501             * 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.
502             * </p>
503             *
504             * @param plid the plid to search with
505             * @param start the lower bound of the range of portlet preferenceses to return
506             * @param end the upper bound of the range of portlet preferenceses to return (not inclusive)
507             * @return the range of matching portlet preferenceses
508             * @throws SystemException if a system exception occurred
509             */
510            public List<PortletPreferences> findByPlid(long plid, int start, int end)
511                    throws SystemException {
512                    return findByPlid(plid, start, end, null);
513            }
514    
515            /**
516             * Finds an ordered range of all the portlet preferenceses where plid = &#63;.
517             *
518             * <p>
519             * 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.
520             * </p>
521             *
522             * @param plid the plid to search with
523             * @param start the lower bound of the range of portlet preferenceses to return
524             * @param end the upper bound of the range of portlet preferenceses to return (not inclusive)
525             * @param orderByComparator the comparator to order the results by
526             * @return the ordered range of matching portlet preferenceses
527             * @throws SystemException if a system exception occurred
528             */
529            public List<PortletPreferences> findByPlid(long plid, int start, int end,
530                    OrderByComparator orderByComparator) throws SystemException {
531                    Object[] finderArgs = new Object[] {
532                                    plid,
533                                    
534                                    String.valueOf(start), String.valueOf(end),
535                                    String.valueOf(orderByComparator)
536                            };
537    
538                    List<PortletPreferences> list = (List<PortletPreferences>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_PLID,
539                                    finderArgs, this);
540    
541                    if (list == null) {
542                            Session session = null;
543    
544                            try {
545                                    session = openSession();
546    
547                                    StringBundler query = null;
548    
549                                    if (orderByComparator != null) {
550                                            query = new StringBundler(3 +
551                                                            (orderByComparator.getOrderByFields().length * 3));
552                                    }
553                                    else {
554                                            query = new StringBundler(2);
555                                    }
556    
557                                    query.append(_SQL_SELECT_PORTLETPREFERENCES_WHERE);
558    
559                                    query.append(_FINDER_COLUMN_PLID_PLID_2);
560    
561                                    if (orderByComparator != null) {
562                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
563                                                    orderByComparator);
564                                    }
565    
566                                    String sql = query.toString();
567    
568                                    Query q = session.createQuery(sql);
569    
570                                    QueryPos qPos = QueryPos.getInstance(q);
571    
572                                    qPos.add(plid);
573    
574                                    list = (List<PortletPreferences>)QueryUtil.list(q,
575                                                    getDialect(), start, end);
576                            }
577                            catch (Exception e) {
578                                    throw processException(e);
579                            }
580                            finally {
581                                    if (list == null) {
582                                            list = new ArrayList<PortletPreferences>();
583                                    }
584    
585                                    cacheResult(list);
586    
587                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_PLID, finderArgs,
588                                            list);
589    
590                                    closeSession(session);
591                            }
592                    }
593    
594                    return list;
595            }
596    
597            /**
598             * Finds the first portlet preferences in the ordered set where plid = &#63;.
599             *
600             * <p>
601             * 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.
602             * </p>
603             *
604             * @param plid the plid to search with
605             * @param orderByComparator the comparator to order the set by
606             * @return the first matching portlet preferences
607             * @throws com.liferay.portal.NoSuchPortletPreferencesException if a matching portlet preferences could not be found
608             * @throws SystemException if a system exception occurred
609             */
610            public PortletPreferences findByPlid_First(long plid,
611                    OrderByComparator orderByComparator)
612                    throws NoSuchPortletPreferencesException, SystemException {
613                    List<PortletPreferences> list = findByPlid(plid, 0, 1, orderByComparator);
614    
615                    if (list.isEmpty()) {
616                            StringBundler msg = new StringBundler(4);
617    
618                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
619    
620                            msg.append("plid=");
621                            msg.append(plid);
622    
623                            msg.append(StringPool.CLOSE_CURLY_BRACE);
624    
625                            throw new NoSuchPortletPreferencesException(msg.toString());
626                    }
627                    else {
628                            return list.get(0);
629                    }
630            }
631    
632            /**
633             * Finds the last portlet preferences in the ordered set where plid = &#63;.
634             *
635             * <p>
636             * 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.
637             * </p>
638             *
639             * @param plid the plid to search with
640             * @param orderByComparator the comparator to order the set by
641             * @return the last matching portlet preferences
642             * @throws com.liferay.portal.NoSuchPortletPreferencesException if a matching portlet preferences could not be found
643             * @throws SystemException if a system exception occurred
644             */
645            public PortletPreferences findByPlid_Last(long plid,
646                    OrderByComparator orderByComparator)
647                    throws NoSuchPortletPreferencesException, SystemException {
648                    int count = countByPlid(plid);
649    
650                    List<PortletPreferences> list = findByPlid(plid, count - 1, count,
651                                    orderByComparator);
652    
653                    if (list.isEmpty()) {
654                            StringBundler msg = new StringBundler(4);
655    
656                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
657    
658                            msg.append("plid=");
659                            msg.append(plid);
660    
661                            msg.append(StringPool.CLOSE_CURLY_BRACE);
662    
663                            throw new NoSuchPortletPreferencesException(msg.toString());
664                    }
665                    else {
666                            return list.get(0);
667                    }
668            }
669    
670            /**
671             * Finds the portlet preferenceses before and after the current portlet preferences in the ordered set where plid = &#63;.
672             *
673             * <p>
674             * 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.
675             * </p>
676             *
677             * @param portletPreferencesId the primary key of the current portlet preferences
678             * @param plid the plid to search with
679             * @param orderByComparator the comparator to order the set by
680             * @return the previous, current, and next portlet preferences
681             * @throws com.liferay.portal.NoSuchPortletPreferencesException if a portlet preferences with the primary key could not be found
682             * @throws SystemException if a system exception occurred
683             */
684            public PortletPreferences[] findByPlid_PrevAndNext(
685                    long portletPreferencesId, long plid,
686                    OrderByComparator orderByComparator)
687                    throws NoSuchPortletPreferencesException, SystemException {
688                    PortletPreferences portletPreferences = findByPrimaryKey(portletPreferencesId);
689    
690                    Session session = null;
691    
692                    try {
693                            session = openSession();
694    
695                            PortletPreferences[] array = new PortletPreferencesImpl[3];
696    
697                            array[0] = getByPlid_PrevAndNext(session, portletPreferences, plid,
698                                            orderByComparator, true);
699    
700                            array[1] = portletPreferences;
701    
702                            array[2] = getByPlid_PrevAndNext(session, portletPreferences, plid,
703                                            orderByComparator, false);
704    
705                            return array;
706                    }
707                    catch (Exception e) {
708                            throw processException(e);
709                    }
710                    finally {
711                            closeSession(session);
712                    }
713            }
714    
715            protected PortletPreferences getByPlid_PrevAndNext(Session session,
716                    PortletPreferences portletPreferences, long plid,
717                    OrderByComparator orderByComparator, boolean previous) {
718                    StringBundler query = null;
719    
720                    if (orderByComparator != null) {
721                            query = new StringBundler(6 +
722                                            (orderByComparator.getOrderByFields().length * 6));
723                    }
724                    else {
725                            query = new StringBundler(3);
726                    }
727    
728                    query.append(_SQL_SELECT_PORTLETPREFERENCES_WHERE);
729    
730                    query.append(_FINDER_COLUMN_PLID_PLID_2);
731    
732                    if (orderByComparator != null) {
733                            String[] orderByFields = orderByComparator.getOrderByFields();
734    
735                            if (orderByFields.length > 0) {
736                                    query.append(WHERE_AND);
737                            }
738    
739                            for (int i = 0; i < orderByFields.length; i++) {
740                                    query.append(_ORDER_BY_ENTITY_ALIAS);
741                                    query.append(orderByFields[i]);
742    
743                                    if ((i + 1) < orderByFields.length) {
744                                            if (orderByComparator.isAscending() ^ previous) {
745                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
746                                            }
747                                            else {
748                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
749                                            }
750                                    }
751                                    else {
752                                            if (orderByComparator.isAscending() ^ previous) {
753                                                    query.append(WHERE_GREATER_THAN);
754                                            }
755                                            else {
756                                                    query.append(WHERE_LESSER_THAN);
757                                            }
758                                    }
759                            }
760    
761                            query.append(ORDER_BY_CLAUSE);
762    
763                            for (int i = 0; i < orderByFields.length; i++) {
764                                    query.append(_ORDER_BY_ENTITY_ALIAS);
765                                    query.append(orderByFields[i]);
766    
767                                    if ((i + 1) < orderByFields.length) {
768                                            if (orderByComparator.isAscending() ^ previous) {
769                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
770                                            }
771                                            else {
772                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
773                                            }
774                                    }
775                                    else {
776                                            if (orderByComparator.isAscending() ^ previous) {
777                                                    query.append(ORDER_BY_ASC);
778                                            }
779                                            else {
780                                                    query.append(ORDER_BY_DESC);
781                                            }
782                                    }
783                            }
784                    }
785    
786                    String sql = query.toString();
787    
788                    Query q = session.createQuery(sql);
789    
790                    q.setFirstResult(0);
791                    q.setMaxResults(2);
792    
793                    QueryPos qPos = QueryPos.getInstance(q);
794    
795                    qPos.add(plid);
796    
797                    if (orderByComparator != null) {
798                            Object[] values = orderByComparator.getOrderByValues(portletPreferences);
799    
800                            for (Object value : values) {
801                                    qPos.add(value);
802                            }
803                    }
804    
805                    List<PortletPreferences> list = q.list();
806    
807                    if (list.size() == 2) {
808                            return list.get(1);
809                    }
810                    else {
811                            return null;
812                    }
813            }
814    
815            /**
816             * Finds all the portlet preferenceses where plid = &#63; and portletId = &#63;.
817             *
818             * @param plid the plid to search with
819             * @param portletId the portlet id to search with
820             * @return the matching portlet preferenceses
821             * @throws SystemException if a system exception occurred
822             */
823            public List<PortletPreferences> findByP_P(long plid, String portletId)
824                    throws SystemException {
825                    return findByP_P(plid, portletId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
826                            null);
827            }
828    
829            /**
830             * Finds a range of all the portlet preferenceses where plid = &#63; and portletId = &#63;.
831             *
832             * <p>
833             * 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.
834             * </p>
835             *
836             * @param plid the plid to search with
837             * @param portletId the portlet id to search with
838             * @param start the lower bound of the range of portlet preferenceses to return
839             * @param end the upper bound of the range of portlet preferenceses to return (not inclusive)
840             * @return the range of matching portlet preferenceses
841             * @throws SystemException if a system exception occurred
842             */
843            public List<PortletPreferences> findByP_P(long plid, String portletId,
844                    int start, int end) throws SystemException {
845                    return findByP_P(plid, portletId, start, end, null);
846            }
847    
848            /**
849             * Finds an ordered range of all the portlet preferenceses where plid = &#63; and portletId = &#63;.
850             *
851             * <p>
852             * 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.
853             * </p>
854             *
855             * @param plid the plid to search with
856             * @param portletId the portlet id to search with
857             * @param start the lower bound of the range of portlet preferenceses to return
858             * @param end the upper bound of the range of portlet preferenceses to return (not inclusive)
859             * @param orderByComparator the comparator to order the results by
860             * @return the ordered range of matching portlet preferenceses
861             * @throws SystemException if a system exception occurred
862             */
863            public List<PortletPreferences> findByP_P(long plid, String portletId,
864                    int start, int end, OrderByComparator orderByComparator)
865                    throws SystemException {
866                    Object[] finderArgs = new Object[] {
867                                    plid, portletId,
868                                    
869                                    String.valueOf(start), String.valueOf(end),
870                                    String.valueOf(orderByComparator)
871                            };
872    
873                    List<PortletPreferences> list = (List<PortletPreferences>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_P_P,
874                                    finderArgs, this);
875    
876                    if (list == null) {
877                            Session session = null;
878    
879                            try {
880                                    session = openSession();
881    
882                                    StringBundler query = null;
883    
884                                    if (orderByComparator != null) {
885                                            query = new StringBundler(4 +
886                                                            (orderByComparator.getOrderByFields().length * 3));
887                                    }
888                                    else {
889                                            query = new StringBundler(3);
890                                    }
891    
892                                    query.append(_SQL_SELECT_PORTLETPREFERENCES_WHERE);
893    
894                                    query.append(_FINDER_COLUMN_P_P_PLID_2);
895    
896                                    if (portletId == null) {
897                                            query.append(_FINDER_COLUMN_P_P_PORTLETID_1);
898                                    }
899                                    else {
900                                            if (portletId.equals(StringPool.BLANK)) {
901                                                    query.append(_FINDER_COLUMN_P_P_PORTLETID_3);
902                                            }
903                                            else {
904                                                    query.append(_FINDER_COLUMN_P_P_PORTLETID_2);
905                                            }
906                                    }
907    
908                                    if (orderByComparator != null) {
909                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
910                                                    orderByComparator);
911                                    }
912    
913                                    String sql = query.toString();
914    
915                                    Query q = session.createQuery(sql);
916    
917                                    QueryPos qPos = QueryPos.getInstance(q);
918    
919                                    qPos.add(plid);
920    
921                                    if (portletId != null) {
922                                            qPos.add(portletId);
923                                    }
924    
925                                    list = (List<PortletPreferences>)QueryUtil.list(q,
926                                                    getDialect(), start, end);
927                            }
928                            catch (Exception e) {
929                                    throw processException(e);
930                            }
931                            finally {
932                                    if (list == null) {
933                                            list = new ArrayList<PortletPreferences>();
934                                    }
935    
936                                    cacheResult(list);
937    
938                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_P_P, finderArgs,
939                                            list);
940    
941                                    closeSession(session);
942                            }
943                    }
944    
945                    return list;
946            }
947    
948            /**
949             * Finds the first portlet preferences in the ordered set where plid = &#63; and portletId = &#63;.
950             *
951             * <p>
952             * 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.
953             * </p>
954             *
955             * @param plid the plid to search with
956             * @param portletId the portlet id to search with
957             * @param orderByComparator the comparator to order the set by
958             * @return the first matching portlet preferences
959             * @throws com.liferay.portal.NoSuchPortletPreferencesException if a matching portlet preferences could not be found
960             * @throws SystemException if a system exception occurred
961             */
962            public PortletPreferences findByP_P_First(long plid, String portletId,
963                    OrderByComparator orderByComparator)
964                    throws NoSuchPortletPreferencesException, SystemException {
965                    List<PortletPreferences> list = findByP_P(plid, portletId, 0, 1,
966                                    orderByComparator);
967    
968                    if (list.isEmpty()) {
969                            StringBundler msg = new StringBundler(6);
970    
971                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
972    
973                            msg.append("plid=");
974                            msg.append(plid);
975    
976                            msg.append(", portletId=");
977                            msg.append(portletId);
978    
979                            msg.append(StringPool.CLOSE_CURLY_BRACE);
980    
981                            throw new NoSuchPortletPreferencesException(msg.toString());
982                    }
983                    else {
984                            return list.get(0);
985                    }
986            }
987    
988            /**
989             * Finds the last portlet preferences in the ordered set where plid = &#63; and portletId = &#63;.
990             *
991             * <p>
992             * 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.
993             * </p>
994             *
995             * @param plid the plid to search with
996             * @param portletId the portlet id to search with
997             * @param orderByComparator the comparator to order the set by
998             * @return the last matching portlet preferences
999             * @throws com.liferay.portal.NoSuchPortletPreferencesException if a matching portlet preferences could not be found
1000             * @throws SystemException if a system exception occurred
1001             */
1002            public PortletPreferences findByP_P_Last(long plid, String portletId,
1003                    OrderByComparator orderByComparator)
1004                    throws NoSuchPortletPreferencesException, SystemException {
1005                    int count = countByP_P(plid, portletId);
1006    
1007                    List<PortletPreferences> list = findByP_P(plid, portletId, count - 1,
1008                                    count, orderByComparator);
1009    
1010                    if (list.isEmpty()) {
1011                            StringBundler msg = new StringBundler(6);
1012    
1013                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1014    
1015                            msg.append("plid=");
1016                            msg.append(plid);
1017    
1018                            msg.append(", portletId=");
1019                            msg.append(portletId);
1020    
1021                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1022    
1023                            throw new NoSuchPortletPreferencesException(msg.toString());
1024                    }
1025                    else {
1026                            return list.get(0);
1027                    }
1028            }
1029    
1030            /**
1031             * Finds the portlet preferenceses before and after the current portlet preferences in the ordered set where plid = &#63; and portletId = &#63;.
1032             *
1033             * <p>
1034             * 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.
1035             * </p>
1036             *
1037             * @param portletPreferencesId the primary key of the current portlet preferences
1038             * @param plid the plid to search with
1039             * @param portletId the portlet id to search with
1040             * @param orderByComparator the comparator to order the set by
1041             * @return the previous, current, and next portlet preferences
1042             * @throws com.liferay.portal.NoSuchPortletPreferencesException if a portlet preferences with the primary key could not be found
1043             * @throws SystemException if a system exception occurred
1044             */
1045            public PortletPreferences[] findByP_P_PrevAndNext(
1046                    long portletPreferencesId, long plid, String portletId,
1047                    OrderByComparator orderByComparator)
1048                    throws NoSuchPortletPreferencesException, SystemException {
1049                    PortletPreferences portletPreferences = findByPrimaryKey(portletPreferencesId);
1050    
1051                    Session session = null;
1052    
1053                    try {
1054                            session = openSession();
1055    
1056                            PortletPreferences[] array = new PortletPreferencesImpl[3];
1057    
1058                            array[0] = getByP_P_PrevAndNext(session, portletPreferences, plid,
1059                                            portletId, orderByComparator, true);
1060    
1061                            array[1] = portletPreferences;
1062    
1063                            array[2] = getByP_P_PrevAndNext(session, portletPreferences, plid,
1064                                            portletId, orderByComparator, false);
1065    
1066                            return array;
1067                    }
1068                    catch (Exception e) {
1069                            throw processException(e);
1070                    }
1071                    finally {
1072                            closeSession(session);
1073                    }
1074            }
1075    
1076            protected PortletPreferences getByP_P_PrevAndNext(Session session,
1077                    PortletPreferences portletPreferences, long plid, String portletId,
1078                    OrderByComparator orderByComparator, boolean previous) {
1079                    StringBundler query = null;
1080    
1081                    if (orderByComparator != null) {
1082                            query = new StringBundler(6 +
1083                                            (orderByComparator.getOrderByFields().length * 6));
1084                    }
1085                    else {
1086                            query = new StringBundler(3);
1087                    }
1088    
1089                    query.append(_SQL_SELECT_PORTLETPREFERENCES_WHERE);
1090    
1091                    query.append(_FINDER_COLUMN_P_P_PLID_2);
1092    
1093                    if (portletId == null) {
1094                            query.append(_FINDER_COLUMN_P_P_PORTLETID_1);
1095                    }
1096                    else {
1097                            if (portletId.equals(StringPool.BLANK)) {
1098                                    query.append(_FINDER_COLUMN_P_P_PORTLETID_3);
1099                            }
1100                            else {
1101                                    query.append(_FINDER_COLUMN_P_P_PORTLETID_2);
1102                            }
1103                    }
1104    
1105                    if (orderByComparator != null) {
1106                            String[] orderByFields = orderByComparator.getOrderByFields();
1107    
1108                            if (orderByFields.length > 0) {
1109                                    query.append(WHERE_AND);
1110                            }
1111    
1112                            for (int i = 0; i < orderByFields.length; i++) {
1113                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1114                                    query.append(orderByFields[i]);
1115    
1116                                    if ((i + 1) < orderByFields.length) {
1117                                            if (orderByComparator.isAscending() ^ previous) {
1118                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1119                                            }
1120                                            else {
1121                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1122                                            }
1123                                    }
1124                                    else {
1125                                            if (orderByComparator.isAscending() ^ previous) {
1126                                                    query.append(WHERE_GREATER_THAN);
1127                                            }
1128                                            else {
1129                                                    query.append(WHERE_LESSER_THAN);
1130                                            }
1131                                    }
1132                            }
1133    
1134                            query.append(ORDER_BY_CLAUSE);
1135    
1136                            for (int i = 0; i < orderByFields.length; i++) {
1137                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1138                                    query.append(orderByFields[i]);
1139    
1140                                    if ((i + 1) < orderByFields.length) {
1141                                            if (orderByComparator.isAscending() ^ previous) {
1142                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1143                                            }
1144                                            else {
1145                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1146                                            }
1147                                    }
1148                                    else {
1149                                            if (orderByComparator.isAscending() ^ previous) {
1150                                                    query.append(ORDER_BY_ASC);
1151                                            }
1152                                            else {
1153                                                    query.append(ORDER_BY_DESC);
1154                                            }
1155                                    }
1156                            }
1157                    }
1158    
1159                    String sql = query.toString();
1160    
1161                    Query q = session.createQuery(sql);
1162    
1163                    q.setFirstResult(0);
1164                    q.setMaxResults(2);
1165    
1166                    QueryPos qPos = QueryPos.getInstance(q);
1167    
1168                    qPos.add(plid);
1169    
1170                    if (portletId != null) {
1171                            qPos.add(portletId);
1172                    }
1173    
1174                    if (orderByComparator != null) {
1175                            Object[] values = orderByComparator.getOrderByValues(portletPreferences);
1176    
1177                            for (Object value : values) {
1178                                    qPos.add(value);
1179                            }
1180                    }
1181    
1182                    List<PortletPreferences> list = q.list();
1183    
1184                    if (list.size() == 2) {
1185                            return list.get(1);
1186                    }
1187                    else {
1188                            return null;
1189                    }
1190            }
1191    
1192            /**
1193             * Finds all the portlet preferenceses where ownerId = &#63; and ownerType = &#63; and plid = &#63;.
1194             *
1195             * @param ownerId the owner id to search with
1196             * @param ownerType the owner type to search with
1197             * @param plid the plid to search with
1198             * @return the matching portlet preferenceses
1199             * @throws SystemException if a system exception occurred
1200             */
1201            public List<PortletPreferences> findByO_O_P(long ownerId, int ownerType,
1202                    long plid) throws SystemException {
1203                    return findByO_O_P(ownerId, ownerType, plid, QueryUtil.ALL_POS,
1204                            QueryUtil.ALL_POS, null);
1205            }
1206    
1207            /**
1208             * Finds a range of all the portlet preferenceses where ownerId = &#63; and ownerType = &#63; and plid = &#63;.
1209             *
1210             * <p>
1211             * 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.
1212             * </p>
1213             *
1214             * @param ownerId the owner id to search with
1215             * @param ownerType the owner type to search with
1216             * @param plid the plid to search with
1217             * @param start the lower bound of the range of portlet preferenceses to return
1218             * @param end the upper bound of the range of portlet preferenceses to return (not inclusive)
1219             * @return the range of matching portlet preferenceses
1220             * @throws SystemException if a system exception occurred
1221             */
1222            public List<PortletPreferences> findByO_O_P(long ownerId, int ownerType,
1223                    long plid, int start, int end) throws SystemException {
1224                    return findByO_O_P(ownerId, ownerType, plid, start, end, null);
1225            }
1226    
1227            /**
1228             * Finds an ordered range of all the portlet preferenceses where ownerId = &#63; and ownerType = &#63; and plid = &#63;.
1229             *
1230             * <p>
1231             * 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.
1232             * </p>
1233             *
1234             * @param ownerId the owner id to search with
1235             * @param ownerType the owner type to search with
1236             * @param plid the plid to search with
1237             * @param start the lower bound of the range of portlet preferenceses to return
1238             * @param end the upper bound of the range of portlet preferenceses to return (not inclusive)
1239             * @param orderByComparator the comparator to order the results by
1240             * @return the ordered range of matching portlet preferenceses
1241             * @throws SystemException if a system exception occurred
1242             */
1243            public List<PortletPreferences> findByO_O_P(long ownerId, int ownerType,
1244                    long plid, int start, int end, OrderByComparator orderByComparator)
1245                    throws SystemException {
1246                    Object[] finderArgs = new Object[] {
1247                                    ownerId, ownerType, plid,
1248                                    
1249                                    String.valueOf(start), String.valueOf(end),
1250                                    String.valueOf(orderByComparator)
1251                            };
1252    
1253                    List<PortletPreferences> list = (List<PortletPreferences>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_O_O_P,
1254                                    finderArgs, this);
1255    
1256                    if (list == null) {
1257                            Session session = null;
1258    
1259                            try {
1260                                    session = openSession();
1261    
1262                                    StringBundler query = null;
1263    
1264                                    if (orderByComparator != null) {
1265                                            query = new StringBundler(5 +
1266                                                            (orderByComparator.getOrderByFields().length * 3));
1267                                    }
1268                                    else {
1269                                            query = new StringBundler(4);
1270                                    }
1271    
1272                                    query.append(_SQL_SELECT_PORTLETPREFERENCES_WHERE);
1273    
1274                                    query.append(_FINDER_COLUMN_O_O_P_OWNERID_2);
1275    
1276                                    query.append(_FINDER_COLUMN_O_O_P_OWNERTYPE_2);
1277    
1278                                    query.append(_FINDER_COLUMN_O_O_P_PLID_2);
1279    
1280                                    if (orderByComparator != null) {
1281                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1282                                                    orderByComparator);
1283                                    }
1284    
1285                                    String sql = query.toString();
1286    
1287                                    Query q = session.createQuery(sql);
1288    
1289                                    QueryPos qPos = QueryPos.getInstance(q);
1290    
1291                                    qPos.add(ownerId);
1292    
1293                                    qPos.add(ownerType);
1294    
1295                                    qPos.add(plid);
1296    
1297                                    list = (List<PortletPreferences>)QueryUtil.list(q,
1298                                                    getDialect(), start, end);
1299                            }
1300                            catch (Exception e) {
1301                                    throw processException(e);
1302                            }
1303                            finally {
1304                                    if (list == null) {
1305                                            list = new ArrayList<PortletPreferences>();
1306                                    }
1307    
1308                                    cacheResult(list);
1309    
1310                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_O_O_P,
1311                                            finderArgs, list);
1312    
1313                                    closeSession(session);
1314                            }
1315                    }
1316    
1317                    return list;
1318            }
1319    
1320            /**
1321             * Finds the first portlet preferences in the ordered set where ownerId = &#63; and ownerType = &#63; and plid = &#63;.
1322             *
1323             * <p>
1324             * 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.
1325             * </p>
1326             *
1327             * @param ownerId the owner id to search with
1328             * @param ownerType the owner type to search with
1329             * @param plid the plid to search with
1330             * @param orderByComparator the comparator to order the set by
1331             * @return the first matching portlet preferences
1332             * @throws com.liferay.portal.NoSuchPortletPreferencesException if a matching portlet preferences could not be found
1333             * @throws SystemException if a system exception occurred
1334             */
1335            public PortletPreferences findByO_O_P_First(long ownerId, int ownerType,
1336                    long plid, OrderByComparator orderByComparator)
1337                    throws NoSuchPortletPreferencesException, SystemException {
1338                    List<PortletPreferences> list = findByO_O_P(ownerId, ownerType, plid,
1339                                    0, 1, orderByComparator);
1340    
1341                    if (list.isEmpty()) {
1342                            StringBundler msg = new StringBundler(8);
1343    
1344                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1345    
1346                            msg.append("ownerId=");
1347                            msg.append(ownerId);
1348    
1349                            msg.append(", ownerType=");
1350                            msg.append(ownerType);
1351    
1352                            msg.append(", plid=");
1353                            msg.append(plid);
1354    
1355                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1356    
1357                            throw new NoSuchPortletPreferencesException(msg.toString());
1358                    }
1359                    else {
1360                            return list.get(0);
1361                    }
1362            }
1363    
1364            /**
1365             * Finds the last portlet preferences in the ordered set where ownerId = &#63; and ownerType = &#63; and plid = &#63;.
1366             *
1367             * <p>
1368             * 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.
1369             * </p>
1370             *
1371             * @param ownerId the owner id to search with
1372             * @param ownerType the owner type to search with
1373             * @param plid the plid to search with
1374             * @param orderByComparator the comparator to order the set by
1375             * @return the last matching portlet preferences
1376             * @throws com.liferay.portal.NoSuchPortletPreferencesException if a matching portlet preferences could not be found
1377             * @throws SystemException if a system exception occurred
1378             */
1379            public PortletPreferences findByO_O_P_Last(long ownerId, int ownerType,
1380                    long plid, OrderByComparator orderByComparator)
1381                    throws NoSuchPortletPreferencesException, SystemException {
1382                    int count = countByO_O_P(ownerId, ownerType, plid);
1383    
1384                    List<PortletPreferences> list = findByO_O_P(ownerId, ownerType, plid,
1385                                    count - 1, count, orderByComparator);
1386    
1387                    if (list.isEmpty()) {
1388                            StringBundler msg = new StringBundler(8);
1389    
1390                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1391    
1392                            msg.append("ownerId=");
1393                            msg.append(ownerId);
1394    
1395                            msg.append(", ownerType=");
1396                            msg.append(ownerType);
1397    
1398                            msg.append(", plid=");
1399                            msg.append(plid);
1400    
1401                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1402    
1403                            throw new NoSuchPortletPreferencesException(msg.toString());
1404                    }
1405                    else {
1406                            return list.get(0);
1407                    }
1408            }
1409    
1410            /**
1411             * Finds the portlet preferenceses before and after the current portlet preferences in the ordered set where ownerId = &#63; and ownerType = &#63; and plid = &#63;.
1412             *
1413             * <p>
1414             * 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.
1415             * </p>
1416             *
1417             * @param portletPreferencesId the primary key of the current portlet preferences
1418             * @param ownerId the owner id to search with
1419             * @param ownerType the owner type to search with
1420             * @param plid the plid to search with
1421             * @param orderByComparator the comparator to order the set by
1422             * @return the previous, current, and next portlet preferences
1423             * @throws com.liferay.portal.NoSuchPortletPreferencesException if a portlet preferences with the primary key could not be found
1424             * @throws SystemException if a system exception occurred
1425             */
1426            public PortletPreferences[] findByO_O_P_PrevAndNext(
1427                    long portletPreferencesId, long ownerId, int ownerType, long plid,
1428                    OrderByComparator orderByComparator)
1429                    throws NoSuchPortletPreferencesException, SystemException {
1430                    PortletPreferences portletPreferences = findByPrimaryKey(portletPreferencesId);
1431    
1432                    Session session = null;
1433    
1434                    try {
1435                            session = openSession();
1436    
1437                            PortletPreferences[] array = new PortletPreferencesImpl[3];
1438    
1439                            array[0] = getByO_O_P_PrevAndNext(session, portletPreferences,
1440                                            ownerId, ownerType, plid, orderByComparator, true);
1441    
1442                            array[1] = portletPreferences;
1443    
1444                            array[2] = getByO_O_P_PrevAndNext(session, portletPreferences,
1445                                            ownerId, ownerType, plid, orderByComparator, false);
1446    
1447                            return array;
1448                    }
1449                    catch (Exception e) {
1450                            throw processException(e);
1451                    }
1452                    finally {
1453                            closeSession(session);
1454                    }
1455            }
1456    
1457            protected PortletPreferences getByO_O_P_PrevAndNext(Session session,
1458                    PortletPreferences portletPreferences, long ownerId, int ownerType,
1459                    long plid, OrderByComparator orderByComparator, boolean previous) {
1460                    StringBundler query = null;
1461    
1462                    if (orderByComparator != null) {
1463                            query = new StringBundler(6 +
1464                                            (orderByComparator.getOrderByFields().length * 6));
1465                    }
1466                    else {
1467                            query = new StringBundler(3);
1468                    }
1469    
1470                    query.append(_SQL_SELECT_PORTLETPREFERENCES_WHERE);
1471    
1472                    query.append(_FINDER_COLUMN_O_O_P_OWNERID_2);
1473    
1474                    query.append(_FINDER_COLUMN_O_O_P_OWNERTYPE_2);
1475    
1476                    query.append(_FINDER_COLUMN_O_O_P_PLID_2);
1477    
1478                    if (orderByComparator != null) {
1479                            String[] orderByFields = orderByComparator.getOrderByFields();
1480    
1481                            if (orderByFields.length > 0) {
1482                                    query.append(WHERE_AND);
1483                            }
1484    
1485                            for (int i = 0; i < orderByFields.length; i++) {
1486                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1487                                    query.append(orderByFields[i]);
1488    
1489                                    if ((i + 1) < orderByFields.length) {
1490                                            if (orderByComparator.isAscending() ^ previous) {
1491                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1492                                            }
1493                                            else {
1494                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1495                                            }
1496                                    }
1497                                    else {
1498                                            if (orderByComparator.isAscending() ^ previous) {
1499                                                    query.append(WHERE_GREATER_THAN);
1500                                            }
1501                                            else {
1502                                                    query.append(WHERE_LESSER_THAN);
1503                                            }
1504                                    }
1505                            }
1506    
1507                            query.append(ORDER_BY_CLAUSE);
1508    
1509                            for (int i = 0; i < orderByFields.length; i++) {
1510                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1511                                    query.append(orderByFields[i]);
1512    
1513                                    if ((i + 1) < orderByFields.length) {
1514                                            if (orderByComparator.isAscending() ^ previous) {
1515                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1516                                            }
1517                                            else {
1518                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1519                                            }
1520                                    }
1521                                    else {
1522                                            if (orderByComparator.isAscending() ^ previous) {
1523                                                    query.append(ORDER_BY_ASC);
1524                                            }
1525                                            else {
1526                                                    query.append(ORDER_BY_DESC);
1527                                            }
1528                                    }
1529                            }
1530                    }
1531    
1532                    String sql = query.toString();
1533    
1534                    Query q = session.createQuery(sql);
1535    
1536                    q.setFirstResult(0);
1537                    q.setMaxResults(2);
1538    
1539                    QueryPos qPos = QueryPos.getInstance(q);
1540    
1541                    qPos.add(ownerId);
1542    
1543                    qPos.add(ownerType);
1544    
1545                    qPos.add(plid);
1546    
1547                    if (orderByComparator != null) {
1548                            Object[] values = orderByComparator.getOrderByValues(portletPreferences);
1549    
1550                            for (Object value : values) {
1551                                    qPos.add(value);
1552                            }
1553                    }
1554    
1555                    List<PortletPreferences> list = q.list();
1556    
1557                    if (list.size() == 2) {
1558                            return list.get(1);
1559                    }
1560                    else {
1561                            return null;
1562                    }
1563            }
1564    
1565            /**
1566             * Finds the portlet preferences where ownerId = &#63; and ownerType = &#63; and plid = &#63; and portletId = &#63; or throws a {@link com.liferay.portal.NoSuchPortletPreferencesException} if it could not be found.
1567             *
1568             * @param ownerId the owner id to search with
1569             * @param ownerType the owner type to search with
1570             * @param plid the plid to search with
1571             * @param portletId the portlet id to search with
1572             * @return the matching portlet preferences
1573             * @throws com.liferay.portal.NoSuchPortletPreferencesException if a matching portlet preferences could not be found
1574             * @throws SystemException if a system exception occurred
1575             */
1576            public PortletPreferences findByO_O_P_P(long ownerId, int ownerType,
1577                    long plid, String portletId)
1578                    throws NoSuchPortletPreferencesException, SystemException {
1579                    PortletPreferences portletPreferences = fetchByO_O_P_P(ownerId,
1580                                    ownerType, plid, portletId);
1581    
1582                    if (portletPreferences == null) {
1583                            StringBundler msg = new StringBundler(10);
1584    
1585                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1586    
1587                            msg.append("ownerId=");
1588                            msg.append(ownerId);
1589    
1590                            msg.append(", ownerType=");
1591                            msg.append(ownerType);
1592    
1593                            msg.append(", plid=");
1594                            msg.append(plid);
1595    
1596                            msg.append(", portletId=");
1597                            msg.append(portletId);
1598    
1599                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1600    
1601                            if (_log.isWarnEnabled()) {
1602                                    _log.warn(msg.toString());
1603                            }
1604    
1605                            throw new NoSuchPortletPreferencesException(msg.toString());
1606                    }
1607    
1608                    return portletPreferences;
1609            }
1610    
1611            /**
1612             * Finds the portlet preferences where ownerId = &#63; and ownerType = &#63; and plid = &#63; and portletId = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
1613             *
1614             * @param ownerId the owner id to search with
1615             * @param ownerType the owner type to search with
1616             * @param plid the plid to search with
1617             * @param portletId the portlet id to search with
1618             * @return the matching portlet preferences, or <code>null</code> if a matching portlet preferences could not be found
1619             * @throws SystemException if a system exception occurred
1620             */
1621            public PortletPreferences fetchByO_O_P_P(long ownerId, int ownerType,
1622                    long plid, String portletId) throws SystemException {
1623                    return fetchByO_O_P_P(ownerId, ownerType, plid, portletId, true);
1624            }
1625    
1626            /**
1627             * Finds the portlet preferences where ownerId = &#63; and ownerType = &#63; and plid = &#63; and portletId = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
1628             *
1629             * @param ownerId the owner id to search with
1630             * @param ownerType the owner type to search with
1631             * @param plid the plid to search with
1632             * @param portletId the portlet id to search with
1633             * @return the matching portlet preferences, or <code>null</code> if a matching portlet preferences could not be found
1634             * @throws SystemException if a system exception occurred
1635             */
1636            public PortletPreferences fetchByO_O_P_P(long ownerId, int ownerType,
1637                    long plid, String portletId, boolean retrieveFromCache)
1638                    throws SystemException {
1639                    Object[] finderArgs = new Object[] { ownerId, ownerType, plid, portletId };
1640    
1641                    Object result = null;
1642    
1643                    if (retrieveFromCache) {
1644                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_O_O_P_P,
1645                                            finderArgs, this);
1646                    }
1647    
1648                    if (result == null) {
1649                            Session session = null;
1650    
1651                            try {
1652                                    session = openSession();
1653    
1654                                    StringBundler query = new StringBundler(5);
1655    
1656                                    query.append(_SQL_SELECT_PORTLETPREFERENCES_WHERE);
1657    
1658                                    query.append(_FINDER_COLUMN_O_O_P_P_OWNERID_2);
1659    
1660                                    query.append(_FINDER_COLUMN_O_O_P_P_OWNERTYPE_2);
1661    
1662                                    query.append(_FINDER_COLUMN_O_O_P_P_PLID_2);
1663    
1664                                    if (portletId == null) {
1665                                            query.append(_FINDER_COLUMN_O_O_P_P_PORTLETID_1);
1666                                    }
1667                                    else {
1668                                            if (portletId.equals(StringPool.BLANK)) {
1669                                                    query.append(_FINDER_COLUMN_O_O_P_P_PORTLETID_3);
1670                                            }
1671                                            else {
1672                                                    query.append(_FINDER_COLUMN_O_O_P_P_PORTLETID_2);
1673                                            }
1674                                    }
1675    
1676                                    String sql = query.toString();
1677    
1678                                    Query q = session.createQuery(sql);
1679    
1680                                    QueryPos qPos = QueryPos.getInstance(q);
1681    
1682                                    qPos.add(ownerId);
1683    
1684                                    qPos.add(ownerType);
1685    
1686                                    qPos.add(plid);
1687    
1688                                    if (portletId != null) {
1689                                            qPos.add(portletId);
1690                                    }
1691    
1692                                    List<PortletPreferences> list = q.list();
1693    
1694                                    result = list;
1695    
1696                                    PortletPreferences portletPreferences = null;
1697    
1698                                    if (list.isEmpty()) {
1699                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_O_O_P_P,
1700                                                    finderArgs, list);
1701                                    }
1702                                    else {
1703                                            portletPreferences = list.get(0);
1704    
1705                                            cacheResult(portletPreferences);
1706    
1707                                            if ((portletPreferences.getOwnerId() != ownerId) ||
1708                                                            (portletPreferences.getOwnerType() != ownerType) ||
1709                                                            (portletPreferences.getPlid() != plid) ||
1710                                                            (portletPreferences.getPortletId() == null) ||
1711                                                            !portletPreferences.getPortletId().equals(portletId)) {
1712                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_O_O_P_P,
1713                                                            finderArgs, portletPreferences);
1714                                            }
1715                                    }
1716    
1717                                    return portletPreferences;
1718                            }
1719                            catch (Exception e) {
1720                                    throw processException(e);
1721                            }
1722                            finally {
1723                                    if (result == null) {
1724                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_O_O_P_P,
1725                                                    finderArgs, new ArrayList<PortletPreferences>());
1726                                    }
1727    
1728                                    closeSession(session);
1729                            }
1730                    }
1731                    else {
1732                            if (result instanceof List<?>) {
1733                                    return null;
1734                            }
1735                            else {
1736                                    return (PortletPreferences)result;
1737                            }
1738                    }
1739            }
1740    
1741            /**
1742             * Finds all the portlet preferenceses.
1743             *
1744             * @return the portlet preferenceses
1745             * @throws SystemException if a system exception occurred
1746             */
1747            public List<PortletPreferences> findAll() throws SystemException {
1748                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1749            }
1750    
1751            /**
1752             * Finds a range of all the portlet preferenceses.
1753             *
1754             * <p>
1755             * 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.
1756             * </p>
1757             *
1758             * @param start the lower bound of the range of portlet preferenceses to return
1759             * @param end the upper bound of the range of portlet preferenceses to return (not inclusive)
1760             * @return the range of portlet preferenceses
1761             * @throws SystemException if a system exception occurred
1762             */
1763            public List<PortletPreferences> findAll(int start, int end)
1764                    throws SystemException {
1765                    return findAll(start, end, null);
1766            }
1767    
1768            /**
1769             * Finds an ordered range of all the portlet preferenceses.
1770             *
1771             * <p>
1772             * 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.
1773             * </p>
1774             *
1775             * @param start the lower bound of the range of portlet preferenceses to return
1776             * @param end the upper bound of the range of portlet preferenceses to return (not inclusive)
1777             * @param orderByComparator the comparator to order the results by
1778             * @return the ordered range of portlet preferenceses
1779             * @throws SystemException if a system exception occurred
1780             */
1781            public List<PortletPreferences> findAll(int start, int end,
1782                    OrderByComparator orderByComparator) throws SystemException {
1783                    Object[] finderArgs = new Object[] {
1784                                    String.valueOf(start), String.valueOf(end),
1785                                    String.valueOf(orderByComparator)
1786                            };
1787    
1788                    List<PortletPreferences> list = (List<PortletPreferences>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
1789                                    finderArgs, this);
1790    
1791                    if (list == null) {
1792                            Session session = null;
1793    
1794                            try {
1795                                    session = openSession();
1796    
1797                                    StringBundler query = null;
1798                                    String sql = null;
1799    
1800                                    if (orderByComparator != null) {
1801                                            query = new StringBundler(2 +
1802                                                            (orderByComparator.getOrderByFields().length * 3));
1803    
1804                                            query.append(_SQL_SELECT_PORTLETPREFERENCES);
1805    
1806                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1807                                                    orderByComparator);
1808    
1809                                            sql = query.toString();
1810                                    }
1811                                    else {
1812                                            sql = _SQL_SELECT_PORTLETPREFERENCES;
1813                                    }
1814    
1815                                    Query q = session.createQuery(sql);
1816    
1817                                    if (orderByComparator == null) {
1818                                            list = (List<PortletPreferences>)QueryUtil.list(q,
1819                                                            getDialect(), start, end, false);
1820    
1821                                            Collections.sort(list);
1822                                    }
1823                                    else {
1824                                            list = (List<PortletPreferences>)QueryUtil.list(q,
1825                                                            getDialect(), start, end);
1826                                    }
1827                            }
1828                            catch (Exception e) {
1829                                    throw processException(e);
1830                            }
1831                            finally {
1832                                    if (list == null) {
1833                                            list = new ArrayList<PortletPreferences>();
1834                                    }
1835    
1836                                    cacheResult(list);
1837    
1838                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
1839    
1840                                    closeSession(session);
1841                            }
1842                    }
1843    
1844                    return list;
1845            }
1846    
1847            /**
1848             * Removes all the portlet preferenceses where plid = &#63; from the database.
1849             *
1850             * @param plid the plid to search with
1851             * @throws SystemException if a system exception occurred
1852             */
1853            public void removeByPlid(long plid) throws SystemException {
1854                    for (PortletPreferences portletPreferences : findByPlid(plid)) {
1855                            remove(portletPreferences);
1856                    }
1857            }
1858    
1859            /**
1860             * Removes all the portlet preferenceses where plid = &#63; and portletId = &#63; from the database.
1861             *
1862             * @param plid the plid to search with
1863             * @param portletId the portlet id to search with
1864             * @throws SystemException if a system exception occurred
1865             */
1866            public void removeByP_P(long plid, String portletId)
1867                    throws SystemException {
1868                    for (PortletPreferences portletPreferences : findByP_P(plid, portletId)) {
1869                            remove(portletPreferences);
1870                    }
1871            }
1872    
1873            /**
1874             * Removes all the portlet preferenceses where ownerId = &#63; and ownerType = &#63; and plid = &#63; from the database.
1875             *
1876             * @param ownerId the owner id to search with
1877             * @param ownerType the owner type to search with
1878             * @param plid the plid to search with
1879             * @throws SystemException if a system exception occurred
1880             */
1881            public void removeByO_O_P(long ownerId, int ownerType, long plid)
1882                    throws SystemException {
1883                    for (PortletPreferences portletPreferences : findByO_O_P(ownerId,
1884                                    ownerType, plid)) {
1885                            remove(portletPreferences);
1886                    }
1887            }
1888    
1889            /**
1890             * Removes the portlet preferences where ownerId = &#63; and ownerType = &#63; and plid = &#63; and portletId = &#63; from the database.
1891             *
1892             * @param ownerId the owner id to search with
1893             * @param ownerType the owner type to search with
1894             * @param plid the plid to search with
1895             * @param portletId the portlet id to search with
1896             * @throws SystemException if a system exception occurred
1897             */
1898            public void removeByO_O_P_P(long ownerId, int ownerType, long plid,
1899                    String portletId)
1900                    throws NoSuchPortletPreferencesException, SystemException {
1901                    PortletPreferences portletPreferences = findByO_O_P_P(ownerId,
1902                                    ownerType, plid, portletId);
1903    
1904                    remove(portletPreferences);
1905            }
1906    
1907            /**
1908             * Removes all the portlet preferenceses from the database.
1909             *
1910             * @throws SystemException if a system exception occurred
1911             */
1912            public void removeAll() throws SystemException {
1913                    for (PortletPreferences portletPreferences : findAll()) {
1914                            remove(portletPreferences);
1915                    }
1916            }
1917    
1918            /**
1919             * Counts all the portlet preferenceses where plid = &#63;.
1920             *
1921             * @param plid the plid to search with
1922             * @return the number of matching portlet preferenceses
1923             * @throws SystemException if a system exception occurred
1924             */
1925            public int countByPlid(long plid) throws SystemException {
1926                    Object[] finderArgs = new Object[] { plid };
1927    
1928                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_PLID,
1929                                    finderArgs, this);
1930    
1931                    if (count == null) {
1932                            Session session = null;
1933    
1934                            try {
1935                                    session = openSession();
1936    
1937                                    StringBundler query = new StringBundler(2);
1938    
1939                                    query.append(_SQL_COUNT_PORTLETPREFERENCES_WHERE);
1940    
1941                                    query.append(_FINDER_COLUMN_PLID_PLID_2);
1942    
1943                                    String sql = query.toString();
1944    
1945                                    Query q = session.createQuery(sql);
1946    
1947                                    QueryPos qPos = QueryPos.getInstance(q);
1948    
1949                                    qPos.add(plid);
1950    
1951                                    count = (Long)q.uniqueResult();
1952                            }
1953                            catch (Exception e) {
1954                                    throw processException(e);
1955                            }
1956                            finally {
1957                                    if (count == null) {
1958                                            count = Long.valueOf(0);
1959                                    }
1960    
1961                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_PLID,
1962                                            finderArgs, count);
1963    
1964                                    closeSession(session);
1965                            }
1966                    }
1967    
1968                    return count.intValue();
1969            }
1970    
1971            /**
1972             * Counts all the portlet preferenceses where plid = &#63; and portletId = &#63;.
1973             *
1974             * @param plid the plid to search with
1975             * @param portletId the portlet id to search with
1976             * @return the number of matching portlet preferenceses
1977             * @throws SystemException if a system exception occurred
1978             */
1979            public int countByP_P(long plid, String portletId)
1980                    throws SystemException {
1981                    Object[] finderArgs = new Object[] { plid, portletId };
1982    
1983                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_P_P,
1984                                    finderArgs, this);
1985    
1986                    if (count == null) {
1987                            Session session = null;
1988    
1989                            try {
1990                                    session = openSession();
1991    
1992                                    StringBundler query = new StringBundler(3);
1993    
1994                                    query.append(_SQL_COUNT_PORTLETPREFERENCES_WHERE);
1995    
1996                                    query.append(_FINDER_COLUMN_P_P_PLID_2);
1997    
1998                                    if (portletId == null) {
1999                                            query.append(_FINDER_COLUMN_P_P_PORTLETID_1);
2000                                    }
2001                                    else {
2002                                            if (portletId.equals(StringPool.BLANK)) {
2003                                                    query.append(_FINDER_COLUMN_P_P_PORTLETID_3);
2004                                            }
2005                                            else {
2006                                                    query.append(_FINDER_COLUMN_P_P_PORTLETID_2);
2007                                            }
2008                                    }
2009    
2010                                    String sql = query.toString();
2011    
2012                                    Query q = session.createQuery(sql);
2013    
2014                                    QueryPos qPos = QueryPos.getInstance(q);
2015    
2016                                    qPos.add(plid);
2017    
2018                                    if (portletId != null) {
2019                                            qPos.add(portletId);
2020                                    }
2021    
2022                                    count = (Long)q.uniqueResult();
2023                            }
2024                            catch (Exception e) {
2025                                    throw processException(e);
2026                            }
2027                            finally {
2028                                    if (count == null) {
2029                                            count = Long.valueOf(0);
2030                                    }
2031    
2032                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_P_P, finderArgs,
2033                                            count);
2034    
2035                                    closeSession(session);
2036                            }
2037                    }
2038    
2039                    return count.intValue();
2040            }
2041    
2042            /**
2043             * Counts all the portlet preferenceses where ownerId = &#63; and ownerType = &#63; and plid = &#63;.
2044             *
2045             * @param ownerId the owner id to search with
2046             * @param ownerType the owner type to search with
2047             * @param plid the plid to search with
2048             * @return the number of matching portlet preferenceses
2049             * @throws SystemException if a system exception occurred
2050             */
2051            public int countByO_O_P(long ownerId, int ownerType, long plid)
2052                    throws SystemException {
2053                    Object[] finderArgs = new Object[] { ownerId, ownerType, plid };
2054    
2055                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_O_O_P,
2056                                    finderArgs, this);
2057    
2058                    if (count == null) {
2059                            Session session = null;
2060    
2061                            try {
2062                                    session = openSession();
2063    
2064                                    StringBundler query = new StringBundler(4);
2065    
2066                                    query.append(_SQL_COUNT_PORTLETPREFERENCES_WHERE);
2067    
2068                                    query.append(_FINDER_COLUMN_O_O_P_OWNERID_2);
2069    
2070                                    query.append(_FINDER_COLUMN_O_O_P_OWNERTYPE_2);
2071    
2072                                    query.append(_FINDER_COLUMN_O_O_P_PLID_2);
2073    
2074                                    String sql = query.toString();
2075    
2076                                    Query q = session.createQuery(sql);
2077    
2078                                    QueryPos qPos = QueryPos.getInstance(q);
2079    
2080                                    qPos.add(ownerId);
2081    
2082                                    qPos.add(ownerType);
2083    
2084                                    qPos.add(plid);
2085    
2086                                    count = (Long)q.uniqueResult();
2087                            }
2088                            catch (Exception e) {
2089                                    throw processException(e);
2090                            }
2091                            finally {
2092                                    if (count == null) {
2093                                            count = Long.valueOf(0);
2094                                    }
2095    
2096                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_O_O_P,
2097                                            finderArgs, count);
2098    
2099                                    closeSession(session);
2100                            }
2101                    }
2102    
2103                    return count.intValue();
2104            }
2105    
2106            /**
2107             * Counts all the portlet preferenceses where ownerId = &#63; and ownerType = &#63; and plid = &#63; and portletId = &#63;.
2108             *
2109             * @param ownerId the owner id to search with
2110             * @param ownerType the owner type to search with
2111             * @param plid the plid to search with
2112             * @param portletId the portlet id to search with
2113             * @return the number of matching portlet preferenceses
2114             * @throws SystemException if a system exception occurred
2115             */
2116            public int countByO_O_P_P(long ownerId, int ownerType, long plid,
2117                    String portletId) throws SystemException {
2118                    Object[] finderArgs = new Object[] { ownerId, ownerType, plid, portletId };
2119    
2120                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_O_O_P_P,
2121                                    finderArgs, this);
2122    
2123                    if (count == null) {
2124                            Session session = null;
2125    
2126                            try {
2127                                    session = openSession();
2128    
2129                                    StringBundler query = new StringBundler(5);
2130    
2131                                    query.append(_SQL_COUNT_PORTLETPREFERENCES_WHERE);
2132    
2133                                    query.append(_FINDER_COLUMN_O_O_P_P_OWNERID_2);
2134    
2135                                    query.append(_FINDER_COLUMN_O_O_P_P_OWNERTYPE_2);
2136    
2137                                    query.append(_FINDER_COLUMN_O_O_P_P_PLID_2);
2138    
2139                                    if (portletId == null) {
2140                                            query.append(_FINDER_COLUMN_O_O_P_P_PORTLETID_1);
2141                                    }
2142                                    else {
2143                                            if (portletId.equals(StringPool.BLANK)) {
2144                                                    query.append(_FINDER_COLUMN_O_O_P_P_PORTLETID_3);
2145                                            }
2146                                            else {
2147                                                    query.append(_FINDER_COLUMN_O_O_P_P_PORTLETID_2);
2148                                            }
2149                                    }
2150    
2151                                    String sql = query.toString();
2152    
2153                                    Query q = session.createQuery(sql);
2154    
2155                                    QueryPos qPos = QueryPos.getInstance(q);
2156    
2157                                    qPos.add(ownerId);
2158    
2159                                    qPos.add(ownerType);
2160    
2161                                    qPos.add(plid);
2162    
2163                                    if (portletId != null) {
2164                                            qPos.add(portletId);
2165                                    }
2166    
2167                                    count = (Long)q.uniqueResult();
2168                            }
2169                            catch (Exception e) {
2170                                    throw processException(e);
2171                            }
2172                            finally {
2173                                    if (count == null) {
2174                                            count = Long.valueOf(0);
2175                                    }
2176    
2177                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_O_O_P_P,
2178                                            finderArgs, count);
2179    
2180                                    closeSession(session);
2181                            }
2182                    }
2183    
2184                    return count.intValue();
2185            }
2186    
2187            /**
2188             * Counts all the portlet preferenceses.
2189             *
2190             * @return the number of portlet preferenceses
2191             * @throws SystemException if a system exception occurred
2192             */
2193            public int countAll() throws SystemException {
2194                    Object[] finderArgs = new Object[0];
2195    
2196                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
2197                                    finderArgs, this);
2198    
2199                    if (count == null) {
2200                            Session session = null;
2201    
2202                            try {
2203                                    session = openSession();
2204    
2205                                    Query q = session.createQuery(_SQL_COUNT_PORTLETPREFERENCES);
2206    
2207                                    count = (Long)q.uniqueResult();
2208                            }
2209                            catch (Exception e) {
2210                                    throw processException(e);
2211                            }
2212                            finally {
2213                                    if (count == null) {
2214                                            count = Long.valueOf(0);
2215                                    }
2216    
2217                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
2218                                            count);
2219    
2220                                    closeSession(session);
2221                            }
2222                    }
2223    
2224                    return count.intValue();
2225            }
2226    
2227            /**
2228             * Initializes the portlet preferences persistence.
2229             */
2230            public void afterPropertiesSet() {
2231                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
2232                                            com.liferay.portal.util.PropsUtil.get(
2233                                                    "value.object.listener.com.liferay.portal.model.PortletPreferences")));
2234    
2235                    if (listenerClassNames.length > 0) {
2236                            try {
2237                                    List<ModelListener<PortletPreferences>> listenersList = new ArrayList<ModelListener<PortletPreferences>>();
2238    
2239                                    for (String listenerClassName : listenerClassNames) {
2240                                            listenersList.add((ModelListener<PortletPreferences>)InstanceFactory.newInstance(
2241                                                            listenerClassName));
2242                                    }
2243    
2244                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
2245                            }
2246                            catch (Exception e) {
2247                                    _log.error(e);
2248                            }
2249                    }
2250            }
2251    
2252            public void destroy() {
2253                    EntityCacheUtil.removeCache(PortletPreferencesImpl.class.getName());
2254                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
2255                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST);
2256            }
2257    
2258            @BeanReference(type = AccountPersistence.class)
2259            protected AccountPersistence accountPersistence;
2260            @BeanReference(type = AddressPersistence.class)
2261            protected AddressPersistence addressPersistence;
2262            @BeanReference(type = BrowserTrackerPersistence.class)
2263            protected BrowserTrackerPersistence browserTrackerPersistence;
2264            @BeanReference(type = ClassNamePersistence.class)
2265            protected ClassNamePersistence classNamePersistence;
2266            @BeanReference(type = ClusterGroupPersistence.class)
2267            protected ClusterGroupPersistence clusterGroupPersistence;
2268            @BeanReference(type = CompanyPersistence.class)
2269            protected CompanyPersistence companyPersistence;
2270            @BeanReference(type = ContactPersistence.class)
2271            protected ContactPersistence contactPersistence;
2272            @BeanReference(type = CountryPersistence.class)
2273            protected CountryPersistence countryPersistence;
2274            @BeanReference(type = EmailAddressPersistence.class)
2275            protected EmailAddressPersistence emailAddressPersistence;
2276            @BeanReference(type = GroupPersistence.class)
2277            protected GroupPersistence groupPersistence;
2278            @BeanReference(type = ImagePersistence.class)
2279            protected ImagePersistence imagePersistence;
2280            @BeanReference(type = LayoutPersistence.class)
2281            protected LayoutPersistence layoutPersistence;
2282            @BeanReference(type = LayoutPrototypePersistence.class)
2283            protected LayoutPrototypePersistence layoutPrototypePersistence;
2284            @BeanReference(type = LayoutSetPersistence.class)
2285            protected LayoutSetPersistence layoutSetPersistence;
2286            @BeanReference(type = LayoutSetPrototypePersistence.class)
2287            protected LayoutSetPrototypePersistence layoutSetPrototypePersistence;
2288            @BeanReference(type = ListTypePersistence.class)
2289            protected ListTypePersistence listTypePersistence;
2290            @BeanReference(type = LockPersistence.class)
2291            protected LockPersistence lockPersistence;
2292            @BeanReference(type = MembershipRequestPersistence.class)
2293            protected MembershipRequestPersistence membershipRequestPersistence;
2294            @BeanReference(type = OrganizationPersistence.class)
2295            protected OrganizationPersistence organizationPersistence;
2296            @BeanReference(type = OrgGroupPermissionPersistence.class)
2297            protected OrgGroupPermissionPersistence orgGroupPermissionPersistence;
2298            @BeanReference(type = OrgGroupRolePersistence.class)
2299            protected OrgGroupRolePersistence orgGroupRolePersistence;
2300            @BeanReference(type = OrgLaborPersistence.class)
2301            protected OrgLaborPersistence orgLaborPersistence;
2302            @BeanReference(type = PasswordPolicyPersistence.class)
2303            protected PasswordPolicyPersistence passwordPolicyPersistence;
2304            @BeanReference(type = PasswordPolicyRelPersistence.class)
2305            protected PasswordPolicyRelPersistence passwordPolicyRelPersistence;
2306            @BeanReference(type = PasswordTrackerPersistence.class)
2307            protected PasswordTrackerPersistence passwordTrackerPersistence;
2308            @BeanReference(type = PermissionPersistence.class)
2309            protected PermissionPersistence permissionPersistence;
2310            @BeanReference(type = PhonePersistence.class)
2311            protected PhonePersistence phonePersistence;
2312            @BeanReference(type = PluginSettingPersistence.class)
2313            protected PluginSettingPersistence pluginSettingPersistence;
2314            @BeanReference(type = PortletPersistence.class)
2315            protected PortletPersistence portletPersistence;
2316            @BeanReference(type = PortletItemPersistence.class)
2317            protected PortletItemPersistence portletItemPersistence;
2318            @BeanReference(type = PortletPreferencesPersistence.class)
2319            protected PortletPreferencesPersistence portletPreferencesPersistence;
2320            @BeanReference(type = RegionPersistence.class)
2321            protected RegionPersistence regionPersistence;
2322            @BeanReference(type = ReleasePersistence.class)
2323            protected ReleasePersistence releasePersistence;
2324            @BeanReference(type = ResourcePersistence.class)
2325            protected ResourcePersistence resourcePersistence;
2326            @BeanReference(type = ResourceActionPersistence.class)
2327            protected ResourceActionPersistence resourceActionPersistence;
2328            @BeanReference(type = ResourceCodePersistence.class)
2329            protected ResourceCodePersistence resourceCodePersistence;
2330            @BeanReference(type = ResourcePermissionPersistence.class)
2331            protected ResourcePermissionPersistence resourcePermissionPersistence;
2332            @BeanReference(type = RolePersistence.class)
2333            protected RolePersistence rolePersistence;
2334            @BeanReference(type = ServiceComponentPersistence.class)
2335            protected ServiceComponentPersistence serviceComponentPersistence;
2336            @BeanReference(type = ShardPersistence.class)
2337            protected ShardPersistence shardPersistence;
2338            @BeanReference(type = SubscriptionPersistence.class)
2339            protected SubscriptionPersistence subscriptionPersistence;
2340            @BeanReference(type = TicketPersistence.class)
2341            protected TicketPersistence ticketPersistence;
2342            @BeanReference(type = TeamPersistence.class)
2343            protected TeamPersistence teamPersistence;
2344            @BeanReference(type = UserPersistence.class)
2345            protected UserPersistence userPersistence;
2346            @BeanReference(type = UserGroupPersistence.class)
2347            protected UserGroupPersistence userGroupPersistence;
2348            @BeanReference(type = UserGroupGroupRolePersistence.class)
2349            protected UserGroupGroupRolePersistence userGroupGroupRolePersistence;
2350            @BeanReference(type = UserGroupRolePersistence.class)
2351            protected UserGroupRolePersistence userGroupRolePersistence;
2352            @BeanReference(type = UserIdMapperPersistence.class)
2353            protected UserIdMapperPersistence userIdMapperPersistence;
2354            @BeanReference(type = UserTrackerPersistence.class)
2355            protected UserTrackerPersistence userTrackerPersistence;
2356            @BeanReference(type = UserTrackerPathPersistence.class)
2357            protected UserTrackerPathPersistence userTrackerPathPersistence;
2358            @BeanReference(type = WebDAVPropsPersistence.class)
2359            protected WebDAVPropsPersistence webDAVPropsPersistence;
2360            @BeanReference(type = WebsitePersistence.class)
2361            protected WebsitePersistence websitePersistence;
2362            @BeanReference(type = WorkflowDefinitionLinkPersistence.class)
2363            protected WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
2364            @BeanReference(type = WorkflowInstanceLinkPersistence.class)
2365            protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
2366            private static final String _SQL_SELECT_PORTLETPREFERENCES = "SELECT portletPreferences FROM PortletPreferences portletPreferences";
2367            private static final String _SQL_SELECT_PORTLETPREFERENCES_WHERE = "SELECT portletPreferences FROM PortletPreferences portletPreferences WHERE ";
2368            private static final String _SQL_COUNT_PORTLETPREFERENCES = "SELECT COUNT(portletPreferences) FROM PortletPreferences portletPreferences";
2369            private static final String _SQL_COUNT_PORTLETPREFERENCES_WHERE = "SELECT COUNT(portletPreferences) FROM PortletPreferences portletPreferences WHERE ";
2370            private static final String _FINDER_COLUMN_PLID_PLID_2 = "portletPreferences.plid = ?";
2371            private static final String _FINDER_COLUMN_P_P_PLID_2 = "portletPreferences.plid = ? AND ";
2372            private static final String _FINDER_COLUMN_P_P_PORTLETID_1 = "portletPreferences.portletId IS NULL";
2373            private static final String _FINDER_COLUMN_P_P_PORTLETID_2 = "portletPreferences.portletId = ?";
2374            private static final String _FINDER_COLUMN_P_P_PORTLETID_3 = "(portletPreferences.portletId IS NULL OR portletPreferences.portletId = ?)";
2375            private static final String _FINDER_COLUMN_O_O_P_OWNERID_2 = "portletPreferences.ownerId = ? AND ";
2376            private static final String _FINDER_COLUMN_O_O_P_OWNERTYPE_2 = "portletPreferences.ownerType = ? AND ";
2377            private static final String _FINDER_COLUMN_O_O_P_PLID_2 = "portletPreferences.plid = ?";
2378            private static final String _FINDER_COLUMN_O_O_P_P_OWNERID_2 = "portletPreferences.ownerId = ? AND ";
2379            private static final String _FINDER_COLUMN_O_O_P_P_OWNERTYPE_2 = "portletPreferences.ownerType = ? AND ";
2380            private static final String _FINDER_COLUMN_O_O_P_P_PLID_2 = "portletPreferences.plid = ? AND ";
2381            private static final String _FINDER_COLUMN_O_O_P_P_PORTLETID_1 = "portletPreferences.portletId IS NULL";
2382            private static final String _FINDER_COLUMN_O_O_P_P_PORTLETID_2 = "portletPreferences.portletId = ?";
2383            private static final String _FINDER_COLUMN_O_O_P_P_PORTLETID_3 = "(portletPreferences.portletId IS NULL OR portletPreferences.portletId = ?)";
2384            private static final String _ORDER_BY_ENTITY_ALIAS = "portletPreferences.";
2385            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No PortletPreferences exists with the primary key ";
2386            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No PortletPreferences exists with the key {";
2387            private static Log _log = LogFactoryUtil.getLog(PortletPreferencesPersistenceImpl.class);
2388    }