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