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.portlet.wiki.service.persistence;
016    
017    import com.liferay.portal.NoSuchModelException;
018    import com.liferay.portal.kernel.annotation.BeanReference;
019    import com.liferay.portal.kernel.cache.CacheRegistryUtil;
020    import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
021    import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
022    import com.liferay.portal.kernel.dao.orm.FinderPath;
023    import com.liferay.portal.kernel.dao.orm.Query;
024    import com.liferay.portal.kernel.dao.orm.QueryPos;
025    import com.liferay.portal.kernel.dao.orm.QueryUtil;
026    import com.liferay.portal.kernel.dao.orm.Session;
027    import com.liferay.portal.kernel.exception.SystemException;
028    import com.liferay.portal.kernel.log.Log;
029    import com.liferay.portal.kernel.log.LogFactoryUtil;
030    import com.liferay.portal.kernel.util.GetterUtil;
031    import com.liferay.portal.kernel.util.InstanceFactory;
032    import com.liferay.portal.kernel.util.OrderByComparator;
033    import com.liferay.portal.kernel.util.StringBundler;
034    import com.liferay.portal.kernel.util.StringPool;
035    import com.liferay.portal.kernel.util.StringUtil;
036    import com.liferay.portal.kernel.util.Validator;
037    import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
038    import com.liferay.portal.model.ModelListener;
039    import com.liferay.portal.service.persistence.BatchSessionUtil;
040    import com.liferay.portal.service.persistence.ResourcePersistence;
041    import com.liferay.portal.service.persistence.UserPersistence;
042    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
043    
044    import com.liferay.portlet.wiki.NoSuchPageResourceException;
045    import com.liferay.portlet.wiki.model.WikiPageResource;
046    import com.liferay.portlet.wiki.model.impl.WikiPageResourceImpl;
047    import com.liferay.portlet.wiki.model.impl.WikiPageResourceModelImpl;
048    
049    import java.io.Serializable;
050    
051    import java.util.ArrayList;
052    import java.util.Collections;
053    import java.util.List;
054    
055    /**
056     * The persistence implementation for the wiki page resource service.
057     *
058     * <p>
059     * Never modify or reference this class directly. Always use {@link WikiPageResourceUtil} to access the wiki page resource persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
060     * </p>
061     *
062     * <p>
063     * Caching information and settings can be found in <code>portal.properties</code>
064     * </p>
065     *
066     * @author Brian Wing Shun Chan
067     * @see WikiPageResourcePersistence
068     * @see WikiPageResourceUtil
069     * @generated
070     */
071    public class WikiPageResourcePersistenceImpl extends BasePersistenceImpl<WikiPageResource>
072            implements WikiPageResourcePersistence {
073            public static final String FINDER_CLASS_NAME_ENTITY = WikiPageResourceImpl.class.getName();
074            public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
075                    ".List";
076            public static final FinderPath FINDER_PATH_FIND_BY_UUID = new FinderPath(WikiPageResourceModelImpl.ENTITY_CACHE_ENABLED,
077                            WikiPageResourceModelImpl.FINDER_CACHE_ENABLED,
078                            FINDER_CLASS_NAME_LIST, "findByUuid",
079                            new String[] {
080                                    String.class.getName(),
081                                    
082                            "java.lang.Integer", "java.lang.Integer",
083                                    "com.liferay.portal.kernel.util.OrderByComparator"
084                            });
085            public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(WikiPageResourceModelImpl.ENTITY_CACHE_ENABLED,
086                            WikiPageResourceModelImpl.FINDER_CACHE_ENABLED,
087                            FINDER_CLASS_NAME_LIST, "countByUuid",
088                            new String[] { String.class.getName() });
089            public static final FinderPath FINDER_PATH_FETCH_BY_N_T = new FinderPath(WikiPageResourceModelImpl.ENTITY_CACHE_ENABLED,
090                            WikiPageResourceModelImpl.FINDER_CACHE_ENABLED,
091                            FINDER_CLASS_NAME_ENTITY, "fetchByN_T",
092                            new String[] { Long.class.getName(), String.class.getName() });
093            public static final FinderPath FINDER_PATH_COUNT_BY_N_T = new FinderPath(WikiPageResourceModelImpl.ENTITY_CACHE_ENABLED,
094                            WikiPageResourceModelImpl.FINDER_CACHE_ENABLED,
095                            FINDER_CLASS_NAME_LIST, "countByN_T",
096                            new String[] { Long.class.getName(), String.class.getName() });
097            public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(WikiPageResourceModelImpl.ENTITY_CACHE_ENABLED,
098                            WikiPageResourceModelImpl.FINDER_CACHE_ENABLED,
099                            FINDER_CLASS_NAME_LIST, "findAll", new String[0]);
100            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(WikiPageResourceModelImpl.ENTITY_CACHE_ENABLED,
101                            WikiPageResourceModelImpl.FINDER_CACHE_ENABLED,
102                            FINDER_CLASS_NAME_LIST, "countAll", new String[0]);
103    
104            /**
105             * Caches the wiki page resource in the entity cache if it is enabled.
106             *
107             * @param wikiPageResource the wiki page resource to cache
108             */
109            public void cacheResult(WikiPageResource wikiPageResource) {
110                    EntityCacheUtil.putResult(WikiPageResourceModelImpl.ENTITY_CACHE_ENABLED,
111                            WikiPageResourceImpl.class, wikiPageResource.getPrimaryKey(),
112                            wikiPageResource);
113    
114                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_N_T,
115                            new Object[] {
116                                    new Long(wikiPageResource.getNodeId()),
117                                    
118                            wikiPageResource.getTitle()
119                            }, wikiPageResource);
120            }
121    
122            /**
123             * Caches the wiki page resources in the entity cache if it is enabled.
124             *
125             * @param wikiPageResources the wiki page resources to cache
126             */
127            public void cacheResult(List<WikiPageResource> wikiPageResources) {
128                    for (WikiPageResource wikiPageResource : wikiPageResources) {
129                            if (EntityCacheUtil.getResult(
130                                                    WikiPageResourceModelImpl.ENTITY_CACHE_ENABLED,
131                                                    WikiPageResourceImpl.class,
132                                                    wikiPageResource.getPrimaryKey(), this) == null) {
133                                    cacheResult(wikiPageResource);
134                            }
135                    }
136            }
137    
138            /**
139             * Clears the cache for all wiki page resources.
140             *
141             * <p>
142             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
143             * </p>
144             */
145            public void clearCache() {
146                    CacheRegistryUtil.clear(WikiPageResourceImpl.class.getName());
147                    EntityCacheUtil.clearCache(WikiPageResourceImpl.class.getName());
148                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
149                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
150            }
151    
152            /**
153             * Clears the cache for the wiki page resource.
154             *
155             * <p>
156             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
157             * </p>
158             */
159            public void clearCache(WikiPageResource wikiPageResource) {
160                    EntityCacheUtil.removeResult(WikiPageResourceModelImpl.ENTITY_CACHE_ENABLED,
161                            WikiPageResourceImpl.class, wikiPageResource.getPrimaryKey());
162    
163                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_N_T,
164                            new Object[] {
165                                    new Long(wikiPageResource.getNodeId()),
166                                    
167                            wikiPageResource.getTitle()
168                            });
169            }
170    
171            /**
172             * Creates a new wiki page resource with the primary key. Does not add the wiki page resource to the database.
173             *
174             * @param resourcePrimKey the primary key for the new wiki page resource
175             * @return the new wiki page resource
176             */
177            public WikiPageResource create(long resourcePrimKey) {
178                    WikiPageResource wikiPageResource = new WikiPageResourceImpl();
179    
180                    wikiPageResource.setNew(true);
181                    wikiPageResource.setPrimaryKey(resourcePrimKey);
182    
183                    String uuid = PortalUUIDUtil.generate();
184    
185                    wikiPageResource.setUuid(uuid);
186    
187                    return wikiPageResource;
188            }
189    
190            /**
191             * Removes the wiki page resource with the primary key from the database. Also notifies the appropriate model listeners.
192             *
193             * @param primaryKey the primary key of the wiki page resource to remove
194             * @return the wiki page resource that was removed
195             * @throws com.liferay.portal.NoSuchModelException if a wiki page resource with the primary key could not be found
196             * @throws SystemException if a system exception occurred
197             */
198            public WikiPageResource remove(Serializable primaryKey)
199                    throws NoSuchModelException, SystemException {
200                    return remove(((Long)primaryKey).longValue());
201            }
202    
203            /**
204             * Removes the wiki page resource with the primary key from the database. Also notifies the appropriate model listeners.
205             *
206             * @param resourcePrimKey the primary key of the wiki page resource to remove
207             * @return the wiki page resource that was removed
208             * @throws com.liferay.portlet.wiki.NoSuchPageResourceException if a wiki page resource with the primary key could not be found
209             * @throws SystemException if a system exception occurred
210             */
211            public WikiPageResource remove(long resourcePrimKey)
212                    throws NoSuchPageResourceException, SystemException {
213                    Session session = null;
214    
215                    try {
216                            session = openSession();
217    
218                            WikiPageResource wikiPageResource = (WikiPageResource)session.get(WikiPageResourceImpl.class,
219                                            new Long(resourcePrimKey));
220    
221                            if (wikiPageResource == null) {
222                                    if (_log.isWarnEnabled()) {
223                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
224                                                    resourcePrimKey);
225                                    }
226    
227                                    throw new NoSuchPageResourceException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
228                                            resourcePrimKey);
229                            }
230    
231                            return remove(wikiPageResource);
232                    }
233                    catch (NoSuchPageResourceException nsee) {
234                            throw nsee;
235                    }
236                    catch (Exception e) {
237                            throw processException(e);
238                    }
239                    finally {
240                            closeSession(session);
241                    }
242            }
243    
244            protected WikiPageResource removeImpl(WikiPageResource wikiPageResource)
245                    throws SystemException {
246                    wikiPageResource = toUnwrappedModel(wikiPageResource);
247    
248                    Session session = null;
249    
250                    try {
251                            session = openSession();
252    
253                            BatchSessionUtil.delete(session, wikiPageResource);
254                    }
255                    catch (Exception e) {
256                            throw processException(e);
257                    }
258                    finally {
259                            closeSession(session);
260                    }
261    
262                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
263    
264                    WikiPageResourceModelImpl wikiPageResourceModelImpl = (WikiPageResourceModelImpl)wikiPageResource;
265    
266                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_N_T,
267                            new Object[] {
268                                    new Long(wikiPageResourceModelImpl.getOriginalNodeId()),
269                                    
270                            wikiPageResourceModelImpl.getOriginalTitle()
271                            });
272    
273                    EntityCacheUtil.removeResult(WikiPageResourceModelImpl.ENTITY_CACHE_ENABLED,
274                            WikiPageResourceImpl.class, wikiPageResource.getPrimaryKey());
275    
276                    return wikiPageResource;
277            }
278    
279            public WikiPageResource updateImpl(
280                    com.liferay.portlet.wiki.model.WikiPageResource wikiPageResource,
281                    boolean merge) throws SystemException {
282                    wikiPageResource = toUnwrappedModel(wikiPageResource);
283    
284                    boolean isNew = wikiPageResource.isNew();
285    
286                    WikiPageResourceModelImpl wikiPageResourceModelImpl = (WikiPageResourceModelImpl)wikiPageResource;
287    
288                    if (Validator.isNull(wikiPageResource.getUuid())) {
289                            String uuid = PortalUUIDUtil.generate();
290    
291                            wikiPageResource.setUuid(uuid);
292                    }
293    
294                    Session session = null;
295    
296                    try {
297                            session = openSession();
298    
299                            BatchSessionUtil.update(session, wikiPageResource, merge);
300    
301                            wikiPageResource.setNew(false);
302                    }
303                    catch (Exception e) {
304                            throw processException(e);
305                    }
306                    finally {
307                            closeSession(session);
308                    }
309    
310                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
311    
312                    EntityCacheUtil.putResult(WikiPageResourceModelImpl.ENTITY_CACHE_ENABLED,
313                            WikiPageResourceImpl.class, wikiPageResource.getPrimaryKey(),
314                            wikiPageResource);
315    
316                    if (!isNew &&
317                                    ((wikiPageResource.getNodeId() != wikiPageResourceModelImpl.getOriginalNodeId()) ||
318                                    !Validator.equals(wikiPageResource.getTitle(),
319                                            wikiPageResourceModelImpl.getOriginalTitle()))) {
320                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_N_T,
321                                    new Object[] {
322                                            new Long(wikiPageResourceModelImpl.getOriginalNodeId()),
323                                            
324                                    wikiPageResourceModelImpl.getOriginalTitle()
325                                    });
326                    }
327    
328                    if (isNew ||
329                                    ((wikiPageResource.getNodeId() != wikiPageResourceModelImpl.getOriginalNodeId()) ||
330                                    !Validator.equals(wikiPageResource.getTitle(),
331                                            wikiPageResourceModelImpl.getOriginalTitle()))) {
332                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_N_T,
333                                    new Object[] {
334                                            new Long(wikiPageResource.getNodeId()),
335                                            
336                                    wikiPageResource.getTitle()
337                                    }, wikiPageResource);
338                    }
339    
340                    return wikiPageResource;
341            }
342    
343            protected WikiPageResource toUnwrappedModel(
344                    WikiPageResource wikiPageResource) {
345                    if (wikiPageResource instanceof WikiPageResourceImpl) {
346                            return wikiPageResource;
347                    }
348    
349                    WikiPageResourceImpl wikiPageResourceImpl = new WikiPageResourceImpl();
350    
351                    wikiPageResourceImpl.setNew(wikiPageResource.isNew());
352                    wikiPageResourceImpl.setPrimaryKey(wikiPageResource.getPrimaryKey());
353    
354                    wikiPageResourceImpl.setUuid(wikiPageResource.getUuid());
355                    wikiPageResourceImpl.setResourcePrimKey(wikiPageResource.getResourcePrimKey());
356                    wikiPageResourceImpl.setNodeId(wikiPageResource.getNodeId());
357                    wikiPageResourceImpl.setTitle(wikiPageResource.getTitle());
358    
359                    return wikiPageResourceImpl;
360            }
361    
362            /**
363             * Finds the wiki page resource with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
364             *
365             * @param primaryKey the primary key of the wiki page resource to find
366             * @return the wiki page resource
367             * @throws com.liferay.portal.NoSuchModelException if a wiki page resource with the primary key could not be found
368             * @throws SystemException if a system exception occurred
369             */
370            public WikiPageResource findByPrimaryKey(Serializable primaryKey)
371                    throws NoSuchModelException, SystemException {
372                    return findByPrimaryKey(((Long)primaryKey).longValue());
373            }
374    
375            /**
376             * Finds the wiki page resource with the primary key or throws a {@link com.liferay.portlet.wiki.NoSuchPageResourceException} if it could not be found.
377             *
378             * @param resourcePrimKey the primary key of the wiki page resource to find
379             * @return the wiki page resource
380             * @throws com.liferay.portlet.wiki.NoSuchPageResourceException if a wiki page resource with the primary key could not be found
381             * @throws SystemException if a system exception occurred
382             */
383            public WikiPageResource findByPrimaryKey(long resourcePrimKey)
384                    throws NoSuchPageResourceException, SystemException {
385                    WikiPageResource wikiPageResource = fetchByPrimaryKey(resourcePrimKey);
386    
387                    if (wikiPageResource == null) {
388                            if (_log.isWarnEnabled()) {
389                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + resourcePrimKey);
390                            }
391    
392                            throw new NoSuchPageResourceException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
393                                    resourcePrimKey);
394                    }
395    
396                    return wikiPageResource;
397            }
398    
399            /**
400             * Finds the wiki page resource with the primary key or returns <code>null</code> if it could not be found.
401             *
402             * @param primaryKey the primary key of the wiki page resource to find
403             * @return the wiki page resource, or <code>null</code> if a wiki page resource with the primary key could not be found
404             * @throws SystemException if a system exception occurred
405             */
406            public WikiPageResource fetchByPrimaryKey(Serializable primaryKey)
407                    throws SystemException {
408                    return fetchByPrimaryKey(((Long)primaryKey).longValue());
409            }
410    
411            /**
412             * Finds the wiki page resource with the primary key or returns <code>null</code> if it could not be found.
413             *
414             * @param resourcePrimKey the primary key of the wiki page resource to find
415             * @return the wiki page resource, or <code>null</code> if a wiki page resource with the primary key could not be found
416             * @throws SystemException if a system exception occurred
417             */
418            public WikiPageResource fetchByPrimaryKey(long resourcePrimKey)
419                    throws SystemException {
420                    WikiPageResource wikiPageResource = (WikiPageResource)EntityCacheUtil.getResult(WikiPageResourceModelImpl.ENTITY_CACHE_ENABLED,
421                                    WikiPageResourceImpl.class, resourcePrimKey, this);
422    
423                    if (wikiPageResource == null) {
424                            Session session = null;
425    
426                            try {
427                                    session = openSession();
428    
429                                    wikiPageResource = (WikiPageResource)session.get(WikiPageResourceImpl.class,
430                                                    new Long(resourcePrimKey));
431                            }
432                            catch (Exception e) {
433                                    throw processException(e);
434                            }
435                            finally {
436                                    if (wikiPageResource != null) {
437                                            cacheResult(wikiPageResource);
438                                    }
439    
440                                    closeSession(session);
441                            }
442                    }
443    
444                    return wikiPageResource;
445            }
446    
447            /**
448             * Finds all the wiki page resources where uuid = &#63;.
449             *
450             * @param uuid the uuid to search with
451             * @return the matching wiki page resources
452             * @throws SystemException if a system exception occurred
453             */
454            public List<WikiPageResource> findByUuid(String uuid)
455                    throws SystemException {
456                    return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
457            }
458    
459            /**
460             * Finds a range of all the wiki page resources where uuid = &#63;.
461             *
462             * <p>
463             * 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.
464             * </p>
465             *
466             * @param uuid the uuid to search with
467             * @param start the lower bound of the range of wiki page resources to return
468             * @param end the upper bound of the range of wiki page resources to return (not inclusive)
469             * @return the range of matching wiki page resources
470             * @throws SystemException if a system exception occurred
471             */
472            public List<WikiPageResource> findByUuid(String uuid, int start, int end)
473                    throws SystemException {
474                    return findByUuid(uuid, start, end, null);
475            }
476    
477            /**
478             * Finds an ordered range of all the wiki page resources where uuid = &#63;.
479             *
480             * <p>
481             * 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.
482             * </p>
483             *
484             * @param uuid the uuid to search with
485             * @param start the lower bound of the range of wiki page resources to return
486             * @param end the upper bound of the range of wiki page resources to return (not inclusive)
487             * @param orderByComparator the comparator to order the results by
488             * @return the ordered range of matching wiki page resources
489             * @throws SystemException if a system exception occurred
490             */
491            public List<WikiPageResource> findByUuid(String uuid, int start, int end,
492                    OrderByComparator orderByComparator) throws SystemException {
493                    Object[] finderArgs = new Object[] {
494                                    uuid,
495                                    
496                                    String.valueOf(start), String.valueOf(end),
497                                    String.valueOf(orderByComparator)
498                            };
499    
500                    List<WikiPageResource> list = (List<WikiPageResource>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_UUID,
501                                    finderArgs, this);
502    
503                    if (list == null) {
504                            Session session = null;
505    
506                            try {
507                                    session = openSession();
508    
509                                    StringBundler query = null;
510    
511                                    if (orderByComparator != null) {
512                                            query = new StringBundler(3 +
513                                                            (orderByComparator.getOrderByFields().length * 3));
514                                    }
515                                    else {
516                                            query = new StringBundler(2);
517                                    }
518    
519                                    query.append(_SQL_SELECT_WIKIPAGERESOURCE_WHERE);
520    
521                                    if (uuid == null) {
522                                            query.append(_FINDER_COLUMN_UUID_UUID_1);
523                                    }
524                                    else {
525                                            if (uuid.equals(StringPool.BLANK)) {
526                                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
527                                            }
528                                            else {
529                                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
530                                            }
531                                    }
532    
533                                    if (orderByComparator != null) {
534                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
535                                                    orderByComparator);
536                                    }
537    
538                                    String sql = query.toString();
539    
540                                    Query q = session.createQuery(sql);
541    
542                                    QueryPos qPos = QueryPos.getInstance(q);
543    
544                                    if (uuid != null) {
545                                            qPos.add(uuid);
546                                    }
547    
548                                    list = (List<WikiPageResource>)QueryUtil.list(q, getDialect(),
549                                                    start, end);
550                            }
551                            catch (Exception e) {
552                                    throw processException(e);
553                            }
554                            finally {
555                                    if (list == null) {
556                                            list = new ArrayList<WikiPageResource>();
557                                    }
558    
559                                    cacheResult(list);
560    
561                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_UUID, finderArgs,
562                                            list);
563    
564                                    closeSession(session);
565                            }
566                    }
567    
568                    return list;
569            }
570    
571            /**
572             * Finds the first wiki page resource in the ordered set where uuid = &#63;.
573             *
574             * <p>
575             * 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.
576             * </p>
577             *
578             * @param uuid the uuid to search with
579             * @param orderByComparator the comparator to order the set by
580             * @return the first matching wiki page resource
581             * @throws com.liferay.portlet.wiki.NoSuchPageResourceException if a matching wiki page resource could not be found
582             * @throws SystemException if a system exception occurred
583             */
584            public WikiPageResource findByUuid_First(String uuid,
585                    OrderByComparator orderByComparator)
586                    throws NoSuchPageResourceException, SystemException {
587                    List<WikiPageResource> list = findByUuid(uuid, 0, 1, orderByComparator);
588    
589                    if (list.isEmpty()) {
590                            StringBundler msg = new StringBundler(4);
591    
592                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
593    
594                            msg.append("uuid=");
595                            msg.append(uuid);
596    
597                            msg.append(StringPool.CLOSE_CURLY_BRACE);
598    
599                            throw new NoSuchPageResourceException(msg.toString());
600                    }
601                    else {
602                            return list.get(0);
603                    }
604            }
605    
606            /**
607             * Finds the last wiki page resource in the ordered set where uuid = &#63;.
608             *
609             * <p>
610             * 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.
611             * </p>
612             *
613             * @param uuid the uuid to search with
614             * @param orderByComparator the comparator to order the set by
615             * @return the last matching wiki page resource
616             * @throws com.liferay.portlet.wiki.NoSuchPageResourceException if a matching wiki page resource could not be found
617             * @throws SystemException if a system exception occurred
618             */
619            public WikiPageResource findByUuid_Last(String uuid,
620                    OrderByComparator orderByComparator)
621                    throws NoSuchPageResourceException, SystemException {
622                    int count = countByUuid(uuid);
623    
624                    List<WikiPageResource> list = findByUuid(uuid, count - 1, count,
625                                    orderByComparator);
626    
627                    if (list.isEmpty()) {
628                            StringBundler msg = new StringBundler(4);
629    
630                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
631    
632                            msg.append("uuid=");
633                            msg.append(uuid);
634    
635                            msg.append(StringPool.CLOSE_CURLY_BRACE);
636    
637                            throw new NoSuchPageResourceException(msg.toString());
638                    }
639                    else {
640                            return list.get(0);
641                    }
642            }
643    
644            /**
645             * Finds the wiki page resources before and after the current wiki page resource in the ordered set where uuid = &#63;.
646             *
647             * <p>
648             * 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.
649             * </p>
650             *
651             * @param resourcePrimKey the primary key of the current wiki page resource
652             * @param uuid the uuid to search with
653             * @param orderByComparator the comparator to order the set by
654             * @return the previous, current, and next wiki page resource
655             * @throws com.liferay.portlet.wiki.NoSuchPageResourceException if a wiki page resource with the primary key could not be found
656             * @throws SystemException if a system exception occurred
657             */
658            public WikiPageResource[] findByUuid_PrevAndNext(long resourcePrimKey,
659                    String uuid, OrderByComparator orderByComparator)
660                    throws NoSuchPageResourceException, SystemException {
661                    WikiPageResource wikiPageResource = findByPrimaryKey(resourcePrimKey);
662    
663                    Session session = null;
664    
665                    try {
666                            session = openSession();
667    
668                            WikiPageResource[] array = new WikiPageResourceImpl[3];
669    
670                            array[0] = getByUuid_PrevAndNext(session, wikiPageResource, uuid,
671                                            orderByComparator, true);
672    
673                            array[1] = wikiPageResource;
674    
675                            array[2] = getByUuid_PrevAndNext(session, wikiPageResource, uuid,
676                                            orderByComparator, false);
677    
678                            return array;
679                    }
680                    catch (Exception e) {
681                            throw processException(e);
682                    }
683                    finally {
684                            closeSession(session);
685                    }
686            }
687    
688            protected WikiPageResource getByUuid_PrevAndNext(Session session,
689                    WikiPageResource wikiPageResource, String uuid,
690                    OrderByComparator orderByComparator, boolean previous) {
691                    StringBundler query = null;
692    
693                    if (orderByComparator != null) {
694                            query = new StringBundler(6 +
695                                            (orderByComparator.getOrderByFields().length * 6));
696                    }
697                    else {
698                            query = new StringBundler(3);
699                    }
700    
701                    query.append(_SQL_SELECT_WIKIPAGERESOURCE_WHERE);
702    
703                    if (uuid == null) {
704                            query.append(_FINDER_COLUMN_UUID_UUID_1);
705                    }
706                    else {
707                            if (uuid.equals(StringPool.BLANK)) {
708                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
709                            }
710                            else {
711                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
712                            }
713                    }
714    
715                    if (orderByComparator != null) {
716                            String[] orderByFields = orderByComparator.getOrderByFields();
717    
718                            if (orderByFields.length > 0) {
719                                    query.append(WHERE_AND);
720                            }
721    
722                            for (int i = 0; i < orderByFields.length; i++) {
723                                    query.append(_ORDER_BY_ENTITY_ALIAS);
724                                    query.append(orderByFields[i]);
725    
726                                    if ((i + 1) < orderByFields.length) {
727                                            if (orderByComparator.isAscending() ^ previous) {
728                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
729                                            }
730                                            else {
731                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
732                                            }
733                                    }
734                                    else {
735                                            if (orderByComparator.isAscending() ^ previous) {
736                                                    query.append(WHERE_GREATER_THAN);
737                                            }
738                                            else {
739                                                    query.append(WHERE_LESSER_THAN);
740                                            }
741                                    }
742                            }
743    
744                            query.append(ORDER_BY_CLAUSE);
745    
746                            for (int i = 0; i < orderByFields.length; i++) {
747                                    query.append(_ORDER_BY_ENTITY_ALIAS);
748                                    query.append(orderByFields[i]);
749    
750                                    if ((i + 1) < orderByFields.length) {
751                                            if (orderByComparator.isAscending() ^ previous) {
752                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
753                                            }
754                                            else {
755                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
756                                            }
757                                    }
758                                    else {
759                                            if (orderByComparator.isAscending() ^ previous) {
760                                                    query.append(ORDER_BY_ASC);
761                                            }
762                                            else {
763                                                    query.append(ORDER_BY_DESC);
764                                            }
765                                    }
766                            }
767                    }
768    
769                    String sql = query.toString();
770    
771                    Query q = session.createQuery(sql);
772    
773                    q.setFirstResult(0);
774                    q.setMaxResults(2);
775    
776                    QueryPos qPos = QueryPos.getInstance(q);
777    
778                    if (uuid != null) {
779                            qPos.add(uuid);
780                    }
781    
782                    if (orderByComparator != null) {
783                            Object[] values = orderByComparator.getOrderByValues(wikiPageResource);
784    
785                            for (Object value : values) {
786                                    qPos.add(value);
787                            }
788                    }
789    
790                    List<WikiPageResource> list = q.list();
791    
792                    if (list.size() == 2) {
793                            return list.get(1);
794                    }
795                    else {
796                            return null;
797                    }
798            }
799    
800            /**
801             * Finds the wiki page resource where nodeId = &#63; and title = &#63; or throws a {@link com.liferay.portlet.wiki.NoSuchPageResourceException} if it could not be found.
802             *
803             * @param nodeId the node id to search with
804             * @param title the title to search with
805             * @return the matching wiki page resource
806             * @throws com.liferay.portlet.wiki.NoSuchPageResourceException if a matching wiki page resource could not be found
807             * @throws SystemException if a system exception occurred
808             */
809            public WikiPageResource findByN_T(long nodeId, String title)
810                    throws NoSuchPageResourceException, SystemException {
811                    WikiPageResource wikiPageResource = fetchByN_T(nodeId, title);
812    
813                    if (wikiPageResource == null) {
814                            StringBundler msg = new StringBundler(6);
815    
816                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
817    
818                            msg.append("nodeId=");
819                            msg.append(nodeId);
820    
821                            msg.append(", title=");
822                            msg.append(title);
823    
824                            msg.append(StringPool.CLOSE_CURLY_BRACE);
825    
826                            if (_log.isWarnEnabled()) {
827                                    _log.warn(msg.toString());
828                            }
829    
830                            throw new NoSuchPageResourceException(msg.toString());
831                    }
832    
833                    return wikiPageResource;
834            }
835    
836            /**
837             * Finds the wiki page resource where nodeId = &#63; and title = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
838             *
839             * @param nodeId the node id to search with
840             * @param title the title to search with
841             * @return the matching wiki page resource, or <code>null</code> if a matching wiki page resource could not be found
842             * @throws SystemException if a system exception occurred
843             */
844            public WikiPageResource fetchByN_T(long nodeId, String title)
845                    throws SystemException {
846                    return fetchByN_T(nodeId, title, true);
847            }
848    
849            /**
850             * Finds the wiki page resource where nodeId = &#63; and title = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
851             *
852             * @param nodeId the node id to search with
853             * @param title the title to search with
854             * @return the matching wiki page resource, or <code>null</code> if a matching wiki page resource could not be found
855             * @throws SystemException if a system exception occurred
856             */
857            public WikiPageResource fetchByN_T(long nodeId, String title,
858                    boolean retrieveFromCache) throws SystemException {
859                    Object[] finderArgs = new Object[] { nodeId, title };
860    
861                    Object result = null;
862    
863                    if (retrieveFromCache) {
864                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_N_T,
865                                            finderArgs, this);
866                    }
867    
868                    if (result == null) {
869                            Session session = null;
870    
871                            try {
872                                    session = openSession();
873    
874                                    StringBundler query = new StringBundler(3);
875    
876                                    query.append(_SQL_SELECT_WIKIPAGERESOURCE_WHERE);
877    
878                                    query.append(_FINDER_COLUMN_N_T_NODEID_2);
879    
880                                    if (title == null) {
881                                            query.append(_FINDER_COLUMN_N_T_TITLE_1);
882                                    }
883                                    else {
884                                            if (title.equals(StringPool.BLANK)) {
885                                                    query.append(_FINDER_COLUMN_N_T_TITLE_3);
886                                            }
887                                            else {
888                                                    query.append(_FINDER_COLUMN_N_T_TITLE_2);
889                                            }
890                                    }
891    
892                                    String sql = query.toString();
893    
894                                    Query q = session.createQuery(sql);
895    
896                                    QueryPos qPos = QueryPos.getInstance(q);
897    
898                                    qPos.add(nodeId);
899    
900                                    if (title != null) {
901                                            qPos.add(title);
902                                    }
903    
904                                    List<WikiPageResource> list = q.list();
905    
906                                    result = list;
907    
908                                    WikiPageResource wikiPageResource = null;
909    
910                                    if (list.isEmpty()) {
911                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_N_T,
912                                                    finderArgs, list);
913                                    }
914                                    else {
915                                            wikiPageResource = list.get(0);
916    
917                                            cacheResult(wikiPageResource);
918    
919                                            if ((wikiPageResource.getNodeId() != nodeId) ||
920                                                            (wikiPageResource.getTitle() == null) ||
921                                                            !wikiPageResource.getTitle().equals(title)) {
922                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_N_T,
923                                                            finderArgs, wikiPageResource);
924                                            }
925                                    }
926    
927                                    return wikiPageResource;
928                            }
929                            catch (Exception e) {
930                                    throw processException(e);
931                            }
932                            finally {
933                                    if (result == null) {
934                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_N_T,
935                                                    finderArgs, new ArrayList<WikiPageResource>());
936                                    }
937    
938                                    closeSession(session);
939                            }
940                    }
941                    else {
942                            if (result instanceof List<?>) {
943                                    return null;
944                            }
945                            else {
946                                    return (WikiPageResource)result;
947                            }
948                    }
949            }
950    
951            /**
952             * Finds all the wiki page resources.
953             *
954             * @return the wiki page resources
955             * @throws SystemException if a system exception occurred
956             */
957            public List<WikiPageResource> findAll() throws SystemException {
958                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
959            }
960    
961            /**
962             * Finds a range of all the wiki page resources.
963             *
964             * <p>
965             * 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.
966             * </p>
967             *
968             * @param start the lower bound of the range of wiki page resources to return
969             * @param end the upper bound of the range of wiki page resources to return (not inclusive)
970             * @return the range of wiki page resources
971             * @throws SystemException if a system exception occurred
972             */
973            public List<WikiPageResource> findAll(int start, int end)
974                    throws SystemException {
975                    return findAll(start, end, null);
976            }
977    
978            /**
979             * Finds an ordered range of all the wiki page resources.
980             *
981             * <p>
982             * 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.
983             * </p>
984             *
985             * @param start the lower bound of the range of wiki page resources to return
986             * @param end the upper bound of the range of wiki page resources to return (not inclusive)
987             * @param orderByComparator the comparator to order the results by
988             * @return the ordered range of wiki page resources
989             * @throws SystemException if a system exception occurred
990             */
991            public List<WikiPageResource> findAll(int start, int end,
992                    OrderByComparator orderByComparator) throws SystemException {
993                    Object[] finderArgs = new Object[] {
994                                    String.valueOf(start), String.valueOf(end),
995                                    String.valueOf(orderByComparator)
996                            };
997    
998                    List<WikiPageResource> list = (List<WikiPageResource>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
999                                    finderArgs, this);
1000    
1001                    if (list == null) {
1002                            Session session = null;
1003    
1004                            try {
1005                                    session = openSession();
1006    
1007                                    StringBundler query = null;
1008                                    String sql = null;
1009    
1010                                    if (orderByComparator != null) {
1011                                            query = new StringBundler(2 +
1012                                                            (orderByComparator.getOrderByFields().length * 3));
1013    
1014                                            query.append(_SQL_SELECT_WIKIPAGERESOURCE);
1015    
1016                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1017                                                    orderByComparator);
1018    
1019                                            sql = query.toString();
1020                                    }
1021                                    else {
1022                                            sql = _SQL_SELECT_WIKIPAGERESOURCE;
1023                                    }
1024    
1025                                    Query q = session.createQuery(sql);
1026    
1027                                    if (orderByComparator == null) {
1028                                            list = (List<WikiPageResource>)QueryUtil.list(q,
1029                                                            getDialect(), start, end, false);
1030    
1031                                            Collections.sort(list);
1032                                    }
1033                                    else {
1034                                            list = (List<WikiPageResource>)QueryUtil.list(q,
1035                                                            getDialect(), start, end);
1036                                    }
1037                            }
1038                            catch (Exception e) {
1039                                    throw processException(e);
1040                            }
1041                            finally {
1042                                    if (list == null) {
1043                                            list = new ArrayList<WikiPageResource>();
1044                                    }
1045    
1046                                    cacheResult(list);
1047    
1048                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
1049    
1050                                    closeSession(session);
1051                            }
1052                    }
1053    
1054                    return list;
1055            }
1056    
1057            /**
1058             * Removes all the wiki page resources where uuid = &#63; from the database.
1059             *
1060             * @param uuid the uuid to search with
1061             * @throws SystemException if a system exception occurred
1062             */
1063            public void removeByUuid(String uuid) throws SystemException {
1064                    for (WikiPageResource wikiPageResource : findByUuid(uuid)) {
1065                            remove(wikiPageResource);
1066                    }
1067            }
1068    
1069            /**
1070             * Removes the wiki page resource where nodeId = &#63; and title = &#63; from the database.
1071             *
1072             * @param nodeId the node id to search with
1073             * @param title the title to search with
1074             * @throws SystemException if a system exception occurred
1075             */
1076            public void removeByN_T(long nodeId, String title)
1077                    throws NoSuchPageResourceException, SystemException {
1078                    WikiPageResource wikiPageResource = findByN_T(nodeId, title);
1079    
1080                    remove(wikiPageResource);
1081            }
1082    
1083            /**
1084             * Removes all the wiki page resources from the database.
1085             *
1086             * @throws SystemException if a system exception occurred
1087             */
1088            public void removeAll() throws SystemException {
1089                    for (WikiPageResource wikiPageResource : findAll()) {
1090                            remove(wikiPageResource);
1091                    }
1092            }
1093    
1094            /**
1095             * Counts all the wiki page resources where uuid = &#63;.
1096             *
1097             * @param uuid the uuid to search with
1098             * @return the number of matching wiki page resources
1099             * @throws SystemException if a system exception occurred
1100             */
1101            public int countByUuid(String uuid) throws SystemException {
1102                    Object[] finderArgs = new Object[] { uuid };
1103    
1104                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
1105                                    finderArgs, this);
1106    
1107                    if (count == null) {
1108                            Session session = null;
1109    
1110                            try {
1111                                    session = openSession();
1112    
1113                                    StringBundler query = new StringBundler(2);
1114    
1115                                    query.append(_SQL_COUNT_WIKIPAGERESOURCE_WHERE);
1116    
1117                                    if (uuid == null) {
1118                                            query.append(_FINDER_COLUMN_UUID_UUID_1);
1119                                    }
1120                                    else {
1121                                            if (uuid.equals(StringPool.BLANK)) {
1122                                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
1123                                            }
1124                                            else {
1125                                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
1126                                            }
1127                                    }
1128    
1129                                    String sql = query.toString();
1130    
1131                                    Query q = session.createQuery(sql);
1132    
1133                                    QueryPos qPos = QueryPos.getInstance(q);
1134    
1135                                    if (uuid != null) {
1136                                            qPos.add(uuid);
1137                                    }
1138    
1139                                    count = (Long)q.uniqueResult();
1140                            }
1141                            catch (Exception e) {
1142                                    throw processException(e);
1143                            }
1144                            finally {
1145                                    if (count == null) {
1146                                            count = Long.valueOf(0);
1147                                    }
1148    
1149                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
1150                                            finderArgs, count);
1151    
1152                                    closeSession(session);
1153                            }
1154                    }
1155    
1156                    return count.intValue();
1157            }
1158    
1159            /**
1160             * Counts all the wiki page resources where nodeId = &#63; and title = &#63;.
1161             *
1162             * @param nodeId the node id to search with
1163             * @param title the title to search with
1164             * @return the number of matching wiki page resources
1165             * @throws SystemException if a system exception occurred
1166             */
1167            public int countByN_T(long nodeId, String title) throws SystemException {
1168                    Object[] finderArgs = new Object[] { nodeId, title };
1169    
1170                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_N_T,
1171                                    finderArgs, this);
1172    
1173                    if (count == null) {
1174                            Session session = null;
1175    
1176                            try {
1177                                    session = openSession();
1178    
1179                                    StringBundler query = new StringBundler(3);
1180    
1181                                    query.append(_SQL_COUNT_WIKIPAGERESOURCE_WHERE);
1182    
1183                                    query.append(_FINDER_COLUMN_N_T_NODEID_2);
1184    
1185                                    if (title == null) {
1186                                            query.append(_FINDER_COLUMN_N_T_TITLE_1);
1187                                    }
1188                                    else {
1189                                            if (title.equals(StringPool.BLANK)) {
1190                                                    query.append(_FINDER_COLUMN_N_T_TITLE_3);
1191                                            }
1192                                            else {
1193                                                    query.append(_FINDER_COLUMN_N_T_TITLE_2);
1194                                            }
1195                                    }
1196    
1197                                    String sql = query.toString();
1198    
1199                                    Query q = session.createQuery(sql);
1200    
1201                                    QueryPos qPos = QueryPos.getInstance(q);
1202    
1203                                    qPos.add(nodeId);
1204    
1205                                    if (title != null) {
1206                                            qPos.add(title);
1207                                    }
1208    
1209                                    count = (Long)q.uniqueResult();
1210                            }
1211                            catch (Exception e) {
1212                                    throw processException(e);
1213                            }
1214                            finally {
1215                                    if (count == null) {
1216                                            count = Long.valueOf(0);
1217                                    }
1218    
1219                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_N_T, finderArgs,
1220                                            count);
1221    
1222                                    closeSession(session);
1223                            }
1224                    }
1225    
1226                    return count.intValue();
1227            }
1228    
1229            /**
1230             * Counts all the wiki page resources.
1231             *
1232             * @return the number of wiki page resources
1233             * @throws SystemException if a system exception occurred
1234             */
1235            public int countAll() throws SystemException {
1236                    Object[] finderArgs = new Object[0];
1237    
1238                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1239                                    finderArgs, this);
1240    
1241                    if (count == null) {
1242                            Session session = null;
1243    
1244                            try {
1245                                    session = openSession();
1246    
1247                                    Query q = session.createQuery(_SQL_COUNT_WIKIPAGERESOURCE);
1248    
1249                                    count = (Long)q.uniqueResult();
1250                            }
1251                            catch (Exception e) {
1252                                    throw processException(e);
1253                            }
1254                            finally {
1255                                    if (count == null) {
1256                                            count = Long.valueOf(0);
1257                                    }
1258    
1259                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
1260                                            count);
1261    
1262                                    closeSession(session);
1263                            }
1264                    }
1265    
1266                    return count.intValue();
1267            }
1268    
1269            /**
1270             * Initializes the wiki page resource persistence.
1271             */
1272            public void afterPropertiesSet() {
1273                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1274                                            com.liferay.portal.util.PropsUtil.get(
1275                                                    "value.object.listener.com.liferay.portlet.wiki.model.WikiPageResource")));
1276    
1277                    if (listenerClassNames.length > 0) {
1278                            try {
1279                                    List<ModelListener<WikiPageResource>> listenersList = new ArrayList<ModelListener<WikiPageResource>>();
1280    
1281                                    for (String listenerClassName : listenerClassNames) {
1282                                            listenersList.add((ModelListener<WikiPageResource>)InstanceFactory.newInstance(
1283                                                            listenerClassName));
1284                                    }
1285    
1286                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1287                            }
1288                            catch (Exception e) {
1289                                    _log.error(e);
1290                            }
1291                    }
1292            }
1293    
1294            public void destroy() {
1295                    EntityCacheUtil.removeCache(WikiPageResourceImpl.class.getName());
1296                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
1297                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST);
1298            }
1299    
1300            @BeanReference(type = WikiNodePersistence.class)
1301            protected WikiNodePersistence wikiNodePersistence;
1302            @BeanReference(type = WikiPagePersistence.class)
1303            protected WikiPagePersistence wikiPagePersistence;
1304            @BeanReference(type = WikiPageResourcePersistence.class)
1305            protected WikiPageResourcePersistence wikiPageResourcePersistence;
1306            @BeanReference(type = ResourcePersistence.class)
1307            protected ResourcePersistence resourcePersistence;
1308            @BeanReference(type = UserPersistence.class)
1309            protected UserPersistence userPersistence;
1310            private static final String _SQL_SELECT_WIKIPAGERESOURCE = "SELECT wikiPageResource FROM WikiPageResource wikiPageResource";
1311            private static final String _SQL_SELECT_WIKIPAGERESOURCE_WHERE = "SELECT wikiPageResource FROM WikiPageResource wikiPageResource WHERE ";
1312            private static final String _SQL_COUNT_WIKIPAGERESOURCE = "SELECT COUNT(wikiPageResource) FROM WikiPageResource wikiPageResource";
1313            private static final String _SQL_COUNT_WIKIPAGERESOURCE_WHERE = "SELECT COUNT(wikiPageResource) FROM WikiPageResource wikiPageResource WHERE ";
1314            private static final String _FINDER_COLUMN_UUID_UUID_1 = "wikiPageResource.uuid IS NULL";
1315            private static final String _FINDER_COLUMN_UUID_UUID_2 = "wikiPageResource.uuid = ?";
1316            private static final String _FINDER_COLUMN_UUID_UUID_3 = "(wikiPageResource.uuid IS NULL OR wikiPageResource.uuid = ?)";
1317            private static final String _FINDER_COLUMN_N_T_NODEID_2 = "wikiPageResource.nodeId = ? AND ";
1318            private static final String _FINDER_COLUMN_N_T_TITLE_1 = "wikiPageResource.title IS NULL";
1319            private static final String _FINDER_COLUMN_N_T_TITLE_2 = "wikiPageResource.title = ?";
1320            private static final String _FINDER_COLUMN_N_T_TITLE_3 = "(wikiPageResource.title IS NULL OR wikiPageResource.title = ?)";
1321            private static final String _ORDER_BY_ENTITY_ALIAS = "wikiPageResource.";
1322            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No WikiPageResource exists with the primary key ";
1323            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No WikiPageResource exists with the key {";
1324            private static Log _log = LogFactoryUtil.getLog(WikiPageResourcePersistenceImpl.class);
1325    }