001    /**
002     * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.service.persistence;
016    
017    import com.liferay.portal.NoSuchModelException;
018    import com.liferay.portal.NoSuchPortletException;
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.Portlet;
040    import com.liferay.portal.model.impl.PortletImpl;
041    import com.liferay.portal.model.impl.PortletModelImpl;
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 service.
052     *
053     * <p>
054     * Never modify or reference this class directly. Always use {@link PortletUtil} to access the portlet 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 PortletPersistence
063     * @see PortletUtil
064     * @generated
065     */
066    public class PortletPersistenceImpl extends BasePersistenceImpl<Portlet>
067            implements PortletPersistence {
068            public static final String FINDER_CLASS_NAME_ENTITY = PortletImpl.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_COMPANYID = new FinderPath(PortletModelImpl.ENTITY_CACHE_ENABLED,
072                            PortletModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
073                            "findByCompanyId",
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_COMPANYID = new FinderPath(PortletModelImpl.ENTITY_CACHE_ENABLED,
081                            PortletModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
082                            "countByCompanyId", new String[] { Long.class.getName() });
083            public static final FinderPath FINDER_PATH_FETCH_BY_C_P = new FinderPath(PortletModelImpl.ENTITY_CACHE_ENABLED,
084                            PortletModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_ENTITY,
085                            "fetchByC_P",
086                            new String[] { Long.class.getName(), String.class.getName() });
087            public static final FinderPath FINDER_PATH_COUNT_BY_C_P = new FinderPath(PortletModelImpl.ENTITY_CACHE_ENABLED,
088                            PortletModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
089                            "countByC_P",
090                            new String[] { Long.class.getName(), String.class.getName() });
091            public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(PortletModelImpl.ENTITY_CACHE_ENABLED,
092                            PortletModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
093                            "findAll", new String[0]);
094            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(PortletModelImpl.ENTITY_CACHE_ENABLED,
095                            PortletModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
096                            "countAll", new String[0]);
097    
098            /**
099             * Caches the portlet in the entity cache if it is enabled.
100             *
101             * @param portlet the portlet to cache
102             */
103            public void cacheResult(Portlet portlet) {
104                    EntityCacheUtil.putResult(PortletModelImpl.ENTITY_CACHE_ENABLED,
105                            PortletImpl.class, portlet.getPrimaryKey(), portlet);
106    
107                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_P,
108                            new Object[] {
109                                    new Long(portlet.getCompanyId()),
110                                    
111                            portlet.getPortletId()
112                            }, portlet);
113            }
114    
115            /**
116             * Caches the portlets in the entity cache if it is enabled.
117             *
118             * @param portlets the portlets to cache
119             */
120            public void cacheResult(List<Portlet> portlets) {
121                    for (Portlet portlet : portlets) {
122                            if (EntityCacheUtil.getResult(
123                                                    PortletModelImpl.ENTITY_CACHE_ENABLED,
124                                                    PortletImpl.class, portlet.getPrimaryKey(), this) == null) {
125                                    cacheResult(portlet);
126                            }
127                    }
128            }
129    
130            /**
131             * Clears the cache for all portlets.
132             *
133             * <p>
134             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
135             * </p>
136             */
137            public void clearCache() {
138                    CacheRegistryUtil.clear(PortletImpl.class.getName());
139                    EntityCacheUtil.clearCache(PortletImpl.class.getName());
140                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
141                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
142            }
143    
144            /**
145             * Clears the cache for the portlet.
146             *
147             * <p>
148             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
149             * </p>
150             */
151            public void clearCache(Portlet portlet) {
152                    EntityCacheUtil.removeResult(PortletModelImpl.ENTITY_CACHE_ENABLED,
153                            PortletImpl.class, portlet.getPrimaryKey());
154    
155                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_P,
156                            new Object[] {
157                                    new Long(portlet.getCompanyId()),
158                                    
159                            portlet.getPortletId()
160                            });
161            }
162    
163            /**
164             * Creates a new portlet with the primary key. Does not add the portlet to the database.
165             *
166             * @param id the primary key for the new portlet
167             * @return the new portlet
168             */
169            public Portlet create(long id) {
170                    Portlet portlet = new PortletImpl();
171    
172                    portlet.setNew(true);
173                    portlet.setPrimaryKey(id);
174    
175                    return portlet;
176            }
177    
178            /**
179             * Removes the portlet with the primary key from the database. Also notifies the appropriate model listeners.
180             *
181             * @param primaryKey the primary key of the portlet to remove
182             * @return the portlet that was removed
183             * @throws com.liferay.portal.NoSuchModelException if a portlet with the primary key could not be found
184             * @throws SystemException if a system exception occurred
185             */
186            public Portlet remove(Serializable primaryKey)
187                    throws NoSuchModelException, SystemException {
188                    return remove(((Long)primaryKey).longValue());
189            }
190    
191            /**
192             * Removes the portlet with the primary key from the database. Also notifies the appropriate model listeners.
193             *
194             * @param id the primary key of the portlet to remove
195             * @return the portlet that was removed
196             * @throws com.liferay.portal.NoSuchPortletException if a portlet with the primary key could not be found
197             * @throws SystemException if a system exception occurred
198             */
199            public Portlet remove(long id)
200                    throws NoSuchPortletException, SystemException {
201                    Session session = null;
202    
203                    try {
204                            session = openSession();
205    
206                            Portlet portlet = (Portlet)session.get(PortletImpl.class,
207                                            new Long(id));
208    
209                            if (portlet == null) {
210                                    if (_log.isWarnEnabled()) {
211                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + id);
212                                    }
213    
214                                    throw new NoSuchPortletException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
215                                            id);
216                            }
217    
218                            return remove(portlet);
219                    }
220                    catch (NoSuchPortletException nsee) {
221                            throw nsee;
222                    }
223                    catch (Exception e) {
224                            throw processException(e);
225                    }
226                    finally {
227                            closeSession(session);
228                    }
229            }
230    
231            protected Portlet removeImpl(Portlet portlet) throws SystemException {
232                    portlet = toUnwrappedModel(portlet);
233    
234                    Session session = null;
235    
236                    try {
237                            session = openSession();
238    
239                            BatchSessionUtil.delete(session, portlet);
240                    }
241                    catch (Exception e) {
242                            throw processException(e);
243                    }
244                    finally {
245                            closeSession(session);
246                    }
247    
248                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
249    
250                    PortletModelImpl portletModelImpl = (PortletModelImpl)portlet;
251    
252                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_P,
253                            new Object[] {
254                                    new Long(portletModelImpl.getCompanyId()),
255                                    
256                            portletModelImpl.getPortletId()
257                            });
258    
259                    EntityCacheUtil.removeResult(PortletModelImpl.ENTITY_CACHE_ENABLED,
260                            PortletImpl.class, portlet.getPrimaryKey());
261    
262                    return portlet;
263            }
264    
265            public Portlet updateImpl(com.liferay.portal.model.Portlet portlet,
266                    boolean merge) throws SystemException {
267                    portlet = toUnwrappedModel(portlet);
268    
269                    boolean isNew = portlet.isNew();
270    
271                    PortletModelImpl portletModelImpl = (PortletModelImpl)portlet;
272    
273                    Session session = null;
274    
275                    try {
276                            session = openSession();
277    
278                            BatchSessionUtil.update(session, portlet, merge);
279    
280                            portlet.setNew(false);
281                    }
282                    catch (Exception e) {
283                            throw processException(e);
284                    }
285                    finally {
286                            closeSession(session);
287                    }
288    
289                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
290    
291                    EntityCacheUtil.putResult(PortletModelImpl.ENTITY_CACHE_ENABLED,
292                            PortletImpl.class, portlet.getPrimaryKey(), portlet);
293    
294                    if (!isNew &&
295                                    ((portlet.getCompanyId() != portletModelImpl.getOriginalCompanyId()) ||
296                                    !Validator.equals(portlet.getPortletId(),
297                                            portletModelImpl.getOriginalPortletId()))) {
298                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_P,
299                                    new Object[] {
300                                            new Long(portletModelImpl.getOriginalCompanyId()),
301                                            
302                                    portletModelImpl.getOriginalPortletId()
303                                    });
304                    }
305    
306                    if (isNew ||
307                                    ((portlet.getCompanyId() != portletModelImpl.getOriginalCompanyId()) ||
308                                    !Validator.equals(portlet.getPortletId(),
309                                            portletModelImpl.getOriginalPortletId()))) {
310                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_P,
311                                    new Object[] {
312                                            new Long(portlet.getCompanyId()),
313                                            
314                                    portlet.getPortletId()
315                                    }, portlet);
316                    }
317    
318                    return portlet;
319            }
320    
321            protected Portlet toUnwrappedModel(Portlet portlet) {
322                    if (portlet instanceof PortletImpl) {
323                            return portlet;
324                    }
325    
326                    PortletImpl portletImpl = new PortletImpl();
327    
328                    portletImpl.setNew(portlet.isNew());
329                    portletImpl.setPrimaryKey(portlet.getPrimaryKey());
330    
331                    portletImpl.setId(portlet.getId());
332                    portletImpl.setCompanyId(portlet.getCompanyId());
333                    portletImpl.setPortletId(portlet.getPortletId());
334                    portletImpl.setRoles(portlet.getRoles());
335                    portletImpl.setActive(portlet.isActive());
336    
337                    return portletImpl;
338            }
339    
340            /**
341             * Finds the portlet with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
342             *
343             * @param primaryKey the primary key of the portlet to find
344             * @return the portlet
345             * @throws com.liferay.portal.NoSuchModelException if a portlet with the primary key could not be found
346             * @throws SystemException if a system exception occurred
347             */
348            public Portlet findByPrimaryKey(Serializable primaryKey)
349                    throws NoSuchModelException, SystemException {
350                    return findByPrimaryKey(((Long)primaryKey).longValue());
351            }
352    
353            /**
354             * Finds the portlet with the primary key or throws a {@link com.liferay.portal.NoSuchPortletException} if it could not be found.
355             *
356             * @param id the primary key of the portlet to find
357             * @return the portlet
358             * @throws com.liferay.portal.NoSuchPortletException if a portlet with the primary key could not be found
359             * @throws SystemException if a system exception occurred
360             */
361            public Portlet findByPrimaryKey(long id)
362                    throws NoSuchPortletException, SystemException {
363                    Portlet portlet = fetchByPrimaryKey(id);
364    
365                    if (portlet == null) {
366                            if (_log.isWarnEnabled()) {
367                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + id);
368                            }
369    
370                            throw new NoSuchPortletException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
371                                    id);
372                    }
373    
374                    return portlet;
375            }
376    
377            /**
378             * Finds the portlet with the primary key or returns <code>null</code> if it could not be found.
379             *
380             * @param primaryKey the primary key of the portlet to find
381             * @return the portlet, or <code>null</code> if a portlet with the primary key could not be found
382             * @throws SystemException if a system exception occurred
383             */
384            public Portlet fetchByPrimaryKey(Serializable primaryKey)
385                    throws SystemException {
386                    return fetchByPrimaryKey(((Long)primaryKey).longValue());
387            }
388    
389            /**
390             * Finds the portlet with the primary key or returns <code>null</code> if it could not be found.
391             *
392             * @param id the primary key of the portlet to find
393             * @return the portlet, or <code>null</code> if a portlet with the primary key could not be found
394             * @throws SystemException if a system exception occurred
395             */
396            public Portlet fetchByPrimaryKey(long id) throws SystemException {
397                    Portlet portlet = (Portlet)EntityCacheUtil.getResult(PortletModelImpl.ENTITY_CACHE_ENABLED,
398                                    PortletImpl.class, id, this);
399    
400                    if (portlet == null) {
401                            Session session = null;
402    
403                            try {
404                                    session = openSession();
405    
406                                    portlet = (Portlet)session.get(PortletImpl.class, new Long(id));
407                            }
408                            catch (Exception e) {
409                                    throw processException(e);
410                            }
411                            finally {
412                                    if (portlet != null) {
413                                            cacheResult(portlet);
414                                    }
415    
416                                    closeSession(session);
417                            }
418                    }
419    
420                    return portlet;
421            }
422    
423            /**
424             * Finds all the portlets where companyId = &#63;.
425             *
426             * @param companyId the company id to search with
427             * @return the matching portlets
428             * @throws SystemException if a system exception occurred
429             */
430            public List<Portlet> findByCompanyId(long companyId)
431                    throws SystemException {
432                    return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
433                            null);
434            }
435    
436            /**
437             * Finds a range of all the portlets where companyId = &#63;.
438             *
439             * <p>
440             * 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.
441             * </p>
442             *
443             * @param companyId the company id to search with
444             * @param start the lower bound of the range of portlets to return
445             * @param end the upper bound of the range of portlets to return (not inclusive)
446             * @return the range of matching portlets
447             * @throws SystemException if a system exception occurred
448             */
449            public List<Portlet> findByCompanyId(long companyId, int start, int end)
450                    throws SystemException {
451                    return findByCompanyId(companyId, start, end, null);
452            }
453    
454            /**
455             * Finds an ordered range of all the portlets where companyId = &#63;.
456             *
457             * <p>
458             * 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.
459             * </p>
460             *
461             * @param companyId the company id to search with
462             * @param start the lower bound of the range of portlets to return
463             * @param end the upper bound of the range of portlets to return (not inclusive)
464             * @param orderByComparator the comparator to order the results by
465             * @return the ordered range of matching portlets
466             * @throws SystemException if a system exception occurred
467             */
468            public List<Portlet> findByCompanyId(long companyId, int start, int end,
469                    OrderByComparator orderByComparator) throws SystemException {
470                    Object[] finderArgs = new Object[] {
471                                    companyId,
472                                    
473                                    String.valueOf(start), String.valueOf(end),
474                                    String.valueOf(orderByComparator)
475                            };
476    
477                    List<Portlet> list = (List<Portlet>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_COMPANYID,
478                                    finderArgs, this);
479    
480                    if (list == null) {
481                            StringBundler query = null;
482    
483                            if (orderByComparator != null) {
484                                    query = new StringBundler(3 +
485                                                    (orderByComparator.getOrderByFields().length * 3));
486                            }
487                            else {
488                                    query = new StringBundler(2);
489                            }
490    
491                            query.append(_SQL_SELECT_PORTLET_WHERE);
492    
493                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
494    
495                            if (orderByComparator != null) {
496                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
497                                            orderByComparator);
498                            }
499    
500                            String sql = query.toString();
501    
502                            Session session = null;
503    
504                            try {
505                                    session = openSession();
506    
507                                    Query q = session.createQuery(sql);
508    
509                                    QueryPos qPos = QueryPos.getInstance(q);
510    
511                                    qPos.add(companyId);
512    
513                                    list = (List<Portlet>)QueryUtil.list(q, getDialect(), start, end);
514                            }
515                            catch (Exception e) {
516                                    throw processException(e);
517                            }
518                            finally {
519                                    if (list == null) {
520                                            FinderCacheUtil.removeResult(FINDER_PATH_FIND_BY_COMPANYID,
521                                                    finderArgs);
522                                    }
523                                    else {
524                                            cacheResult(list);
525    
526                                            FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_COMPANYID,
527                                                    finderArgs, list);
528                                    }
529    
530                                    closeSession(session);
531                            }
532                    }
533    
534                    return list;
535            }
536    
537            /**
538             * Finds the first portlet in the ordered set where companyId = &#63;.
539             *
540             * <p>
541             * 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.
542             * </p>
543             *
544             * @param companyId the company id to search with
545             * @param orderByComparator the comparator to order the set by
546             * @return the first matching portlet
547             * @throws com.liferay.portal.NoSuchPortletException if a matching portlet could not be found
548             * @throws SystemException if a system exception occurred
549             */
550            public Portlet findByCompanyId_First(long companyId,
551                    OrderByComparator orderByComparator)
552                    throws NoSuchPortletException, SystemException {
553                    List<Portlet> list = findByCompanyId(companyId, 0, 1, orderByComparator);
554    
555                    if (list.isEmpty()) {
556                            StringBundler msg = new StringBundler(4);
557    
558                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
559    
560                            msg.append("companyId=");
561                            msg.append(companyId);
562    
563                            msg.append(StringPool.CLOSE_CURLY_BRACE);
564    
565                            throw new NoSuchPortletException(msg.toString());
566                    }
567                    else {
568                            return list.get(0);
569                    }
570            }
571    
572            /**
573             * Finds the last portlet in the ordered set where companyId = &#63;.
574             *
575             * <p>
576             * 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.
577             * </p>
578             *
579             * @param companyId the company id to search with
580             * @param orderByComparator the comparator to order the set by
581             * @return the last matching portlet
582             * @throws com.liferay.portal.NoSuchPortletException if a matching portlet could not be found
583             * @throws SystemException if a system exception occurred
584             */
585            public Portlet findByCompanyId_Last(long companyId,
586                    OrderByComparator orderByComparator)
587                    throws NoSuchPortletException, SystemException {
588                    int count = countByCompanyId(companyId);
589    
590                    List<Portlet> list = findByCompanyId(companyId, count - 1, count,
591                                    orderByComparator);
592    
593                    if (list.isEmpty()) {
594                            StringBundler msg = new StringBundler(4);
595    
596                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
597    
598                            msg.append("companyId=");
599                            msg.append(companyId);
600    
601                            msg.append(StringPool.CLOSE_CURLY_BRACE);
602    
603                            throw new NoSuchPortletException(msg.toString());
604                    }
605                    else {
606                            return list.get(0);
607                    }
608            }
609    
610            /**
611             * Finds the portlets before and after the current portlet in the ordered set where companyId = &#63;.
612             *
613             * <p>
614             * 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.
615             * </p>
616             *
617             * @param id the primary key of the current portlet
618             * @param companyId the company id to search with
619             * @param orderByComparator the comparator to order the set by
620             * @return the previous, current, and next portlet
621             * @throws com.liferay.portal.NoSuchPortletException if a portlet with the primary key could not be found
622             * @throws SystemException if a system exception occurred
623             */
624            public Portlet[] findByCompanyId_PrevAndNext(long id, long companyId,
625                    OrderByComparator orderByComparator)
626                    throws NoSuchPortletException, SystemException {
627                    Portlet portlet = findByPrimaryKey(id);
628    
629                    Session session = null;
630    
631                    try {
632                            session = openSession();
633    
634                            Portlet[] array = new PortletImpl[3];
635    
636                            array[0] = getByCompanyId_PrevAndNext(session, portlet, companyId,
637                                            orderByComparator, true);
638    
639                            array[1] = portlet;
640    
641                            array[2] = getByCompanyId_PrevAndNext(session, portlet, companyId,
642                                            orderByComparator, false);
643    
644                            return array;
645                    }
646                    catch (Exception e) {
647                            throw processException(e);
648                    }
649                    finally {
650                            closeSession(session);
651                    }
652            }
653    
654            protected Portlet getByCompanyId_PrevAndNext(Session session,
655                    Portlet portlet, long companyId, OrderByComparator orderByComparator,
656                    boolean previous) {
657                    StringBundler query = null;
658    
659                    if (orderByComparator != null) {
660                            query = new StringBundler(6 +
661                                            (orderByComparator.getOrderByFields().length * 6));
662                    }
663                    else {
664                            query = new StringBundler(3);
665                    }
666    
667                    query.append(_SQL_SELECT_PORTLET_WHERE);
668    
669                    query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
670    
671                    if (orderByComparator != null) {
672                            String[] orderByFields = orderByComparator.getOrderByFields();
673    
674                            if (orderByFields.length > 0) {
675                                    query.append(WHERE_AND);
676                            }
677    
678                            for (int i = 0; i < orderByFields.length; i++) {
679                                    query.append(_ORDER_BY_ENTITY_ALIAS);
680                                    query.append(orderByFields[i]);
681    
682                                    if ((i + 1) < orderByFields.length) {
683                                            if (orderByComparator.isAscending() ^ previous) {
684                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
685                                            }
686                                            else {
687                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
688                                            }
689                                    }
690                                    else {
691                                            if (orderByComparator.isAscending() ^ previous) {
692                                                    query.append(WHERE_GREATER_THAN);
693                                            }
694                                            else {
695                                                    query.append(WHERE_LESSER_THAN);
696                                            }
697                                    }
698                            }
699    
700                            query.append(ORDER_BY_CLAUSE);
701    
702                            for (int i = 0; i < orderByFields.length; i++) {
703                                    query.append(_ORDER_BY_ENTITY_ALIAS);
704                                    query.append(orderByFields[i]);
705    
706                                    if ((i + 1) < orderByFields.length) {
707                                            if (orderByComparator.isAscending() ^ previous) {
708                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
709                                            }
710                                            else {
711                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
712                                            }
713                                    }
714                                    else {
715                                            if (orderByComparator.isAscending() ^ previous) {
716                                                    query.append(ORDER_BY_ASC);
717                                            }
718                                            else {
719                                                    query.append(ORDER_BY_DESC);
720                                            }
721                                    }
722                            }
723                    }
724    
725                    String sql = query.toString();
726    
727                    Query q = session.createQuery(sql);
728    
729                    q.setFirstResult(0);
730                    q.setMaxResults(2);
731    
732                    QueryPos qPos = QueryPos.getInstance(q);
733    
734                    qPos.add(companyId);
735    
736                    if (orderByComparator != null) {
737                            Object[] values = orderByComparator.getOrderByValues(portlet);
738    
739                            for (Object value : values) {
740                                    qPos.add(value);
741                            }
742                    }
743    
744                    List<Portlet> list = q.list();
745    
746                    if (list.size() == 2) {
747                            return list.get(1);
748                    }
749                    else {
750                            return null;
751                    }
752            }
753    
754            /**
755             * Finds the portlet where companyId = &#63; and portletId = &#63; or throws a {@link com.liferay.portal.NoSuchPortletException} if it could not be found.
756             *
757             * @param companyId the company id to search with
758             * @param portletId the portlet id to search with
759             * @return the matching portlet
760             * @throws com.liferay.portal.NoSuchPortletException if a matching portlet could not be found
761             * @throws SystemException if a system exception occurred
762             */
763            public Portlet findByC_P(long companyId, String portletId)
764                    throws NoSuchPortletException, SystemException {
765                    Portlet portlet = fetchByC_P(companyId, portletId);
766    
767                    if (portlet == null) {
768                            StringBundler msg = new StringBundler(6);
769    
770                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
771    
772                            msg.append("companyId=");
773                            msg.append(companyId);
774    
775                            msg.append(", portletId=");
776                            msg.append(portletId);
777    
778                            msg.append(StringPool.CLOSE_CURLY_BRACE);
779    
780                            if (_log.isWarnEnabled()) {
781                                    _log.warn(msg.toString());
782                            }
783    
784                            throw new NoSuchPortletException(msg.toString());
785                    }
786    
787                    return portlet;
788            }
789    
790            /**
791             * Finds the portlet where companyId = &#63; and portletId = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
792             *
793             * @param companyId the company id to search with
794             * @param portletId the portlet id to search with
795             * @return the matching portlet, or <code>null</code> if a matching portlet could not be found
796             * @throws SystemException if a system exception occurred
797             */
798            public Portlet fetchByC_P(long companyId, String portletId)
799                    throws SystemException {
800                    return fetchByC_P(companyId, portletId, true);
801            }
802    
803            /**
804             * Finds the portlet where companyId = &#63; and portletId = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
805             *
806             * @param companyId the company id to search with
807             * @param portletId the portlet id to search with
808             * @return the matching portlet, or <code>null</code> if a matching portlet could not be found
809             * @throws SystemException if a system exception occurred
810             */
811            public Portlet fetchByC_P(long companyId, String portletId,
812                    boolean retrieveFromCache) throws SystemException {
813                    Object[] finderArgs = new Object[] { companyId, portletId };
814    
815                    Object result = null;
816    
817                    if (retrieveFromCache) {
818                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_P,
819                                            finderArgs, this);
820                    }
821    
822                    if (result == null) {
823                            StringBundler query = new StringBundler(3);
824    
825                            query.append(_SQL_SELECT_PORTLET_WHERE);
826    
827                            query.append(_FINDER_COLUMN_C_P_COMPANYID_2);
828    
829                            if (portletId == null) {
830                                    query.append(_FINDER_COLUMN_C_P_PORTLETID_1);
831                            }
832                            else {
833                                    if (portletId.equals(StringPool.BLANK)) {
834                                            query.append(_FINDER_COLUMN_C_P_PORTLETID_3);
835                                    }
836                                    else {
837                                            query.append(_FINDER_COLUMN_C_P_PORTLETID_2);
838                                    }
839                            }
840    
841                            String sql = query.toString();
842    
843                            Session session = null;
844    
845                            try {
846                                    session = openSession();
847    
848                                    Query q = session.createQuery(sql);
849    
850                                    QueryPos qPos = QueryPos.getInstance(q);
851    
852                                    qPos.add(companyId);
853    
854                                    if (portletId != null) {
855                                            qPos.add(portletId);
856                                    }
857    
858                                    List<Portlet> list = q.list();
859    
860                                    result = list;
861    
862                                    Portlet portlet = null;
863    
864                                    if (list.isEmpty()) {
865                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_P,
866                                                    finderArgs, list);
867                                    }
868                                    else {
869                                            portlet = list.get(0);
870    
871                                            cacheResult(portlet);
872    
873                                            if ((portlet.getCompanyId() != companyId) ||
874                                                            (portlet.getPortletId() == null) ||
875                                                            !portlet.getPortletId().equals(portletId)) {
876                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_P,
877                                                            finderArgs, portlet);
878                                            }
879                                    }
880    
881                                    return portlet;
882                            }
883                            catch (Exception e) {
884                                    throw processException(e);
885                            }
886                            finally {
887                                    if (result == null) {
888                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_P,
889                                                    finderArgs);
890                                    }
891    
892                                    closeSession(session);
893                            }
894                    }
895                    else {
896                            if (result instanceof List<?>) {
897                                    return null;
898                            }
899                            else {
900                                    return (Portlet)result;
901                            }
902                    }
903            }
904    
905            /**
906             * Finds all the portlets.
907             *
908             * @return the portlets
909             * @throws SystemException if a system exception occurred
910             */
911            public List<Portlet> findAll() throws SystemException {
912                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
913            }
914    
915            /**
916             * Finds a range of all the portlets.
917             *
918             * <p>
919             * 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.
920             * </p>
921             *
922             * @param start the lower bound of the range of portlets to return
923             * @param end the upper bound of the range of portlets to return (not inclusive)
924             * @return the range of portlets
925             * @throws SystemException if a system exception occurred
926             */
927            public List<Portlet> findAll(int start, int end) throws SystemException {
928                    return findAll(start, end, null);
929            }
930    
931            /**
932             * Finds an ordered range of all the portlets.
933             *
934             * <p>
935             * 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.
936             * </p>
937             *
938             * @param start the lower bound of the range of portlets to return
939             * @param end the upper bound of the range of portlets to return (not inclusive)
940             * @param orderByComparator the comparator to order the results by
941             * @return the ordered range of portlets
942             * @throws SystemException if a system exception occurred
943             */
944            public List<Portlet> findAll(int start, int end,
945                    OrderByComparator orderByComparator) throws SystemException {
946                    Object[] finderArgs = new Object[] {
947                                    String.valueOf(start), String.valueOf(end),
948                                    String.valueOf(orderByComparator)
949                            };
950    
951                    List<Portlet> list = (List<Portlet>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
952                                    finderArgs, this);
953    
954                    if (list == null) {
955                            StringBundler query = null;
956                            String sql = null;
957    
958                            if (orderByComparator != null) {
959                                    query = new StringBundler(2 +
960                                                    (orderByComparator.getOrderByFields().length * 3));
961    
962                                    query.append(_SQL_SELECT_PORTLET);
963    
964                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
965                                            orderByComparator);
966    
967                                    sql = query.toString();
968                            }
969                            else {
970                                    sql = _SQL_SELECT_PORTLET;
971                            }
972    
973                            Session session = null;
974    
975                            try {
976                                    session = openSession();
977    
978                                    Query q = session.createQuery(sql);
979    
980                                    if (orderByComparator == null) {
981                                            list = (List<Portlet>)QueryUtil.list(q, getDialect(),
982                                                            start, end, false);
983    
984                                            Collections.sort(list);
985                                    }
986                                    else {
987                                            list = (List<Portlet>)QueryUtil.list(q, getDialect(),
988                                                            start, end);
989                                    }
990                            }
991                            catch (Exception e) {
992                                    throw processException(e);
993                            }
994                            finally {
995                                    if (list == null) {
996                                            FinderCacheUtil.removeResult(FINDER_PATH_FIND_ALL,
997                                                    finderArgs);
998                                    }
999                                    else {
1000                                            cacheResult(list);
1001    
1002                                            FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs,
1003                                                    list);
1004                                    }
1005    
1006                                    closeSession(session);
1007                            }
1008                    }
1009    
1010                    return list;
1011            }
1012    
1013            /**
1014             * Removes all the portlets where companyId = &#63; from the database.
1015             *
1016             * @param companyId the company id to search with
1017             * @throws SystemException if a system exception occurred
1018             */
1019            public void removeByCompanyId(long companyId) throws SystemException {
1020                    for (Portlet portlet : findByCompanyId(companyId)) {
1021                            remove(portlet);
1022                    }
1023            }
1024    
1025            /**
1026             * Removes the portlet where companyId = &#63; and portletId = &#63; from the database.
1027             *
1028             * @param companyId the company id to search with
1029             * @param portletId the portlet id to search with
1030             * @throws SystemException if a system exception occurred
1031             */
1032            public void removeByC_P(long companyId, String portletId)
1033                    throws NoSuchPortletException, SystemException {
1034                    Portlet portlet = findByC_P(companyId, portletId);
1035    
1036                    remove(portlet);
1037            }
1038    
1039            /**
1040             * Removes all the portlets from the database.
1041             *
1042             * @throws SystemException if a system exception occurred
1043             */
1044            public void removeAll() throws SystemException {
1045                    for (Portlet portlet : findAll()) {
1046                            remove(portlet);
1047                    }
1048            }
1049    
1050            /**
1051             * Counts all the portlets where companyId = &#63;.
1052             *
1053             * @param companyId the company id to search with
1054             * @return the number of matching portlets
1055             * @throws SystemException if a system exception occurred
1056             */
1057            public int countByCompanyId(long companyId) throws SystemException {
1058                    Object[] finderArgs = new Object[] { companyId };
1059    
1060                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
1061                                    finderArgs, this);
1062    
1063                    if (count == null) {
1064                            StringBundler query = new StringBundler(2);
1065    
1066                            query.append(_SQL_COUNT_PORTLET_WHERE);
1067    
1068                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1069    
1070                            String sql = query.toString();
1071    
1072                            Session session = null;
1073    
1074                            try {
1075                                    session = openSession();
1076    
1077                                    Query q = session.createQuery(sql);
1078    
1079                                    QueryPos qPos = QueryPos.getInstance(q);
1080    
1081                                    qPos.add(companyId);
1082    
1083                                    count = (Long)q.uniqueResult();
1084                            }
1085                            catch (Exception e) {
1086                                    throw processException(e);
1087                            }
1088                            finally {
1089                                    if (count == null) {
1090                                            count = Long.valueOf(0);
1091                                    }
1092    
1093                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
1094                                            finderArgs, count);
1095    
1096                                    closeSession(session);
1097                            }
1098                    }
1099    
1100                    return count.intValue();
1101            }
1102    
1103            /**
1104             * Counts all the portlets where companyId = &#63; and portletId = &#63;.
1105             *
1106             * @param companyId the company id to search with
1107             * @param portletId the portlet id to search with
1108             * @return the number of matching portlets
1109             * @throws SystemException if a system exception occurred
1110             */
1111            public int countByC_P(long companyId, String portletId)
1112                    throws SystemException {
1113                    Object[] finderArgs = new Object[] { companyId, portletId };
1114    
1115                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_P,
1116                                    finderArgs, this);
1117    
1118                    if (count == null) {
1119                            StringBundler query = new StringBundler(3);
1120    
1121                            query.append(_SQL_COUNT_PORTLET_WHERE);
1122    
1123                            query.append(_FINDER_COLUMN_C_P_COMPANYID_2);
1124    
1125                            if (portletId == null) {
1126                                    query.append(_FINDER_COLUMN_C_P_PORTLETID_1);
1127                            }
1128                            else {
1129                                    if (portletId.equals(StringPool.BLANK)) {
1130                                            query.append(_FINDER_COLUMN_C_P_PORTLETID_3);
1131                                    }
1132                                    else {
1133                                            query.append(_FINDER_COLUMN_C_P_PORTLETID_2);
1134                                    }
1135                            }
1136    
1137                            String sql = query.toString();
1138    
1139                            Session session = null;
1140    
1141                            try {
1142                                    session = openSession();
1143    
1144                                    Query q = session.createQuery(sql);
1145    
1146                                    QueryPos qPos = QueryPos.getInstance(q);
1147    
1148                                    qPos.add(companyId);
1149    
1150                                    if (portletId != null) {
1151                                            qPos.add(portletId);
1152                                    }
1153    
1154                                    count = (Long)q.uniqueResult();
1155                            }
1156                            catch (Exception e) {
1157                                    throw processException(e);
1158                            }
1159                            finally {
1160                                    if (count == null) {
1161                                            count = Long.valueOf(0);
1162                                    }
1163    
1164                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_P, finderArgs,
1165                                            count);
1166    
1167                                    closeSession(session);
1168                            }
1169                    }
1170    
1171                    return count.intValue();
1172            }
1173    
1174            /**
1175             * Counts all the portlets.
1176             *
1177             * @return the number of portlets
1178             * @throws SystemException if a system exception occurred
1179             */
1180            public int countAll() throws SystemException {
1181                    Object[] finderArgs = new Object[0];
1182    
1183                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1184                                    finderArgs, this);
1185    
1186                    if (count == null) {
1187                            Session session = null;
1188    
1189                            try {
1190                                    session = openSession();
1191    
1192                                    Query q = session.createQuery(_SQL_COUNT_PORTLET);
1193    
1194                                    count = (Long)q.uniqueResult();
1195                            }
1196                            catch (Exception e) {
1197                                    throw processException(e);
1198                            }
1199                            finally {
1200                                    if (count == null) {
1201                                            count = Long.valueOf(0);
1202                                    }
1203    
1204                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
1205                                            count);
1206    
1207                                    closeSession(session);
1208                            }
1209                    }
1210    
1211                    return count.intValue();
1212            }
1213    
1214            /**
1215             * Initializes the portlet persistence.
1216             */
1217            public void afterPropertiesSet() {
1218                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1219                                            com.liferay.portal.util.PropsUtil.get(
1220                                                    "value.object.listener.com.liferay.portal.model.Portlet")));
1221    
1222                    if (listenerClassNames.length > 0) {
1223                            try {
1224                                    List<ModelListener<Portlet>> listenersList = new ArrayList<ModelListener<Portlet>>();
1225    
1226                                    for (String listenerClassName : listenerClassNames) {
1227                                            listenersList.add((ModelListener<Portlet>)InstanceFactory.newInstance(
1228                                                            listenerClassName));
1229                                    }
1230    
1231                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1232                            }
1233                            catch (Exception e) {
1234                                    _log.error(e);
1235                            }
1236                    }
1237            }
1238    
1239            public void destroy() {
1240                    EntityCacheUtil.removeCache(PortletImpl.class.getName());
1241                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
1242                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST);
1243            }
1244    
1245            @BeanReference(type = AccountPersistence.class)
1246            protected AccountPersistence accountPersistence;
1247            @BeanReference(type = AddressPersistence.class)
1248            protected AddressPersistence addressPersistence;
1249            @BeanReference(type = BrowserTrackerPersistence.class)
1250            protected BrowserTrackerPersistence browserTrackerPersistence;
1251            @BeanReference(type = ClassNamePersistence.class)
1252            protected ClassNamePersistence classNamePersistence;
1253            @BeanReference(type = ClusterGroupPersistence.class)
1254            protected ClusterGroupPersistence clusterGroupPersistence;
1255            @BeanReference(type = CompanyPersistence.class)
1256            protected CompanyPersistence companyPersistence;
1257            @BeanReference(type = ContactPersistence.class)
1258            protected ContactPersistence contactPersistence;
1259            @BeanReference(type = CountryPersistence.class)
1260            protected CountryPersistence countryPersistence;
1261            @BeanReference(type = EmailAddressPersistence.class)
1262            protected EmailAddressPersistence emailAddressPersistence;
1263            @BeanReference(type = GroupPersistence.class)
1264            protected GroupPersistence groupPersistence;
1265            @BeanReference(type = ImagePersistence.class)
1266            protected ImagePersistence imagePersistence;
1267            @BeanReference(type = LayoutPersistence.class)
1268            protected LayoutPersistence layoutPersistence;
1269            @BeanReference(type = LayoutPrototypePersistence.class)
1270            protected LayoutPrototypePersistence layoutPrototypePersistence;
1271            @BeanReference(type = LayoutSetPersistence.class)
1272            protected LayoutSetPersistence layoutSetPersistence;
1273            @BeanReference(type = LayoutSetPrototypePersistence.class)
1274            protected LayoutSetPrototypePersistence layoutSetPrototypePersistence;
1275            @BeanReference(type = ListTypePersistence.class)
1276            protected ListTypePersistence listTypePersistence;
1277            @BeanReference(type = LockPersistence.class)
1278            protected LockPersistence lockPersistence;
1279            @BeanReference(type = MembershipRequestPersistence.class)
1280            protected MembershipRequestPersistence membershipRequestPersistence;
1281            @BeanReference(type = OrganizationPersistence.class)
1282            protected OrganizationPersistence organizationPersistence;
1283            @BeanReference(type = OrgGroupPermissionPersistence.class)
1284            protected OrgGroupPermissionPersistence orgGroupPermissionPersistence;
1285            @BeanReference(type = OrgGroupRolePersistence.class)
1286            protected OrgGroupRolePersistence orgGroupRolePersistence;
1287            @BeanReference(type = OrgLaborPersistence.class)
1288            protected OrgLaborPersistence orgLaborPersistence;
1289            @BeanReference(type = PasswordPolicyPersistence.class)
1290            protected PasswordPolicyPersistence passwordPolicyPersistence;
1291            @BeanReference(type = PasswordPolicyRelPersistence.class)
1292            protected PasswordPolicyRelPersistence passwordPolicyRelPersistence;
1293            @BeanReference(type = PasswordTrackerPersistence.class)
1294            protected PasswordTrackerPersistence passwordTrackerPersistence;
1295            @BeanReference(type = PermissionPersistence.class)
1296            protected PermissionPersistence permissionPersistence;
1297            @BeanReference(type = PhonePersistence.class)
1298            protected PhonePersistence phonePersistence;
1299            @BeanReference(type = PluginSettingPersistence.class)
1300            protected PluginSettingPersistence pluginSettingPersistence;
1301            @BeanReference(type = PortletPersistence.class)
1302            protected PortletPersistence portletPersistence;
1303            @BeanReference(type = PortletItemPersistence.class)
1304            protected PortletItemPersistence portletItemPersistence;
1305            @BeanReference(type = PortletPreferencesPersistence.class)
1306            protected PortletPreferencesPersistence portletPreferencesPersistence;
1307            @BeanReference(type = RegionPersistence.class)
1308            protected RegionPersistence regionPersistence;
1309            @BeanReference(type = ReleasePersistence.class)
1310            protected ReleasePersistence releasePersistence;
1311            @BeanReference(type = ResourcePersistence.class)
1312            protected ResourcePersistence resourcePersistence;
1313            @BeanReference(type = ResourceActionPersistence.class)
1314            protected ResourceActionPersistence resourceActionPersistence;
1315            @BeanReference(type = ResourceCodePersistence.class)
1316            protected ResourceCodePersistence resourceCodePersistence;
1317            @BeanReference(type = ResourcePermissionPersistence.class)
1318            protected ResourcePermissionPersistence resourcePermissionPersistence;
1319            @BeanReference(type = RolePersistence.class)
1320            protected RolePersistence rolePersistence;
1321            @BeanReference(type = ServiceComponentPersistence.class)
1322            protected ServiceComponentPersistence serviceComponentPersistence;
1323            @BeanReference(type = ShardPersistence.class)
1324            protected ShardPersistence shardPersistence;
1325            @BeanReference(type = SubscriptionPersistence.class)
1326            protected SubscriptionPersistence subscriptionPersistence;
1327            @BeanReference(type = TicketPersistence.class)
1328            protected TicketPersistence ticketPersistence;
1329            @BeanReference(type = TeamPersistence.class)
1330            protected TeamPersistence teamPersistence;
1331            @BeanReference(type = UserPersistence.class)
1332            protected UserPersistence userPersistence;
1333            @BeanReference(type = UserGroupPersistence.class)
1334            protected UserGroupPersistence userGroupPersistence;
1335            @BeanReference(type = UserGroupGroupRolePersistence.class)
1336            protected UserGroupGroupRolePersistence userGroupGroupRolePersistence;
1337            @BeanReference(type = UserGroupRolePersistence.class)
1338            protected UserGroupRolePersistence userGroupRolePersistence;
1339            @BeanReference(type = UserIdMapperPersistence.class)
1340            protected UserIdMapperPersistence userIdMapperPersistence;
1341            @BeanReference(type = UserTrackerPersistence.class)
1342            protected UserTrackerPersistence userTrackerPersistence;
1343            @BeanReference(type = UserTrackerPathPersistence.class)
1344            protected UserTrackerPathPersistence userTrackerPathPersistence;
1345            @BeanReference(type = WebDAVPropsPersistence.class)
1346            protected WebDAVPropsPersistence webDAVPropsPersistence;
1347            @BeanReference(type = WebsitePersistence.class)
1348            protected WebsitePersistence websitePersistence;
1349            @BeanReference(type = WorkflowDefinitionLinkPersistence.class)
1350            protected WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
1351            @BeanReference(type = WorkflowInstanceLinkPersistence.class)
1352            protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
1353            private static final String _SQL_SELECT_PORTLET = "SELECT portlet FROM Portlet portlet";
1354            private static final String _SQL_SELECT_PORTLET_WHERE = "SELECT portlet FROM Portlet portlet WHERE ";
1355            private static final String _SQL_COUNT_PORTLET = "SELECT COUNT(portlet) FROM Portlet portlet";
1356            private static final String _SQL_COUNT_PORTLET_WHERE = "SELECT COUNT(portlet) FROM Portlet portlet WHERE ";
1357            private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "portlet.companyId = ?";
1358            private static final String _FINDER_COLUMN_C_P_COMPANYID_2 = "portlet.companyId = ? AND ";
1359            private static final String _FINDER_COLUMN_C_P_PORTLETID_1 = "portlet.portletId IS NULL";
1360            private static final String _FINDER_COLUMN_C_P_PORTLETID_2 = "portlet.portletId = ?";
1361            private static final String _FINDER_COLUMN_C_P_PORTLETID_3 = "(portlet.portletId IS NULL OR portlet.portletId = ?)";
1362            private static final String _ORDER_BY_ENTITY_ALIAS = "portlet.";
1363            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No Portlet exists with the primary key ";
1364            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No Portlet exists with the key {";
1365            private static Log _log = LogFactoryUtil.getLog(PortletPersistenceImpl.class);
1366    }