001    /**
002     * Copyright (c) 2000-2012 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.bean.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.CacheModel;
040    import com.liferay.portal.model.ModelListener;
041    import com.liferay.portal.security.permission.InlineSQLHelperUtil;
042    import com.liferay.portal.service.persistence.GroupPersistence;
043    import com.liferay.portal.service.persistence.SubscriptionPersistence;
044    import com.liferay.portal.service.persistence.UserPersistence;
045    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
046    
047    import com.liferay.portlet.trash.service.persistence.TrashEntryPersistence;
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     * Caching information and settings can be found in <code>portal.properties</code>
064     * </p>
065     *
066     * @author Brian Wing Shun Chan
067     * @see WikiNodePersistence
068     * @see WikiNodeUtil
069     * @generated
070     */
071    public class WikiNodePersistenceImpl extends BasePersistenceImpl<WikiNode>
072            implements WikiNodePersistence {
073            /*
074             * NOTE FOR DEVELOPERS:
075             *
076             * 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.
077             */
078            public static final String FINDER_CLASS_NAME_ENTITY = WikiNodeImpl.class.getName();
079            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
080                    ".List1";
081            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
082                    ".List2";
083            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
084                            WikiNodeModelImpl.FINDER_CACHE_ENABLED, WikiNodeImpl.class,
085                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid",
086                            new String[] {
087                                    String.class.getName(),
088                                    
089                            "java.lang.Integer", "java.lang.Integer",
090                                    "com.liferay.portal.kernel.util.OrderByComparator"
091                            });
092            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
093                            WikiNodeModelImpl.FINDER_CACHE_ENABLED, WikiNodeImpl.class,
094                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
095                            new String[] { String.class.getName() },
096                            WikiNodeModelImpl.UUID_COLUMN_BITMASK);
097            public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
098                            WikiNodeModelImpl.FINDER_CACHE_ENABLED, Long.class,
099                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
100                            new String[] { String.class.getName() });
101            public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
102                            WikiNodeModelImpl.FINDER_CACHE_ENABLED, WikiNodeImpl.class,
103                            FINDER_CLASS_NAME_ENTITY, "fetchByUUID_G",
104                            new String[] { String.class.getName(), Long.class.getName() },
105                            WikiNodeModelImpl.UUID_COLUMN_BITMASK |
106                            WikiNodeModelImpl.GROUPID_COLUMN_BITMASK);
107            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
108                            WikiNodeModelImpl.FINDER_CACHE_ENABLED, Long.class,
109                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G",
110                            new String[] { String.class.getName(), Long.class.getName() });
111            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C = new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
112                            WikiNodeModelImpl.FINDER_CACHE_ENABLED, WikiNodeImpl.class,
113                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid_C",
114                            new String[] {
115                                    String.class.getName(), Long.class.getName(),
116                                    
117                            "java.lang.Integer", "java.lang.Integer",
118                                    "com.liferay.portal.kernel.util.OrderByComparator"
119                            });
120            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C =
121                    new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
122                            WikiNodeModelImpl.FINDER_CACHE_ENABLED, WikiNodeImpl.class,
123                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid_C",
124                            new String[] { String.class.getName(), Long.class.getName() },
125                            WikiNodeModelImpl.UUID_COLUMN_BITMASK |
126                            WikiNodeModelImpl.COMPANYID_COLUMN_BITMASK);
127            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_C = new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
128                            WikiNodeModelImpl.FINDER_CACHE_ENABLED, Long.class,
129                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid_C",
130                            new String[] { String.class.getName(), Long.class.getName() });
131            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
132                            WikiNodeModelImpl.FINDER_CACHE_ENABLED, WikiNodeImpl.class,
133                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByGroupId",
134                            new String[] {
135                                    Long.class.getName(),
136                                    
137                            "java.lang.Integer", "java.lang.Integer",
138                                    "com.liferay.portal.kernel.util.OrderByComparator"
139                            });
140            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID =
141                    new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
142                            WikiNodeModelImpl.FINDER_CACHE_ENABLED, WikiNodeImpl.class,
143                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByGroupId",
144                            new String[] { Long.class.getName() },
145                            WikiNodeModelImpl.GROUPID_COLUMN_BITMASK);
146            public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
147                            WikiNodeModelImpl.FINDER_CACHE_ENABLED, Long.class,
148                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId",
149                            new String[] { Long.class.getName() });
150            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID =
151                    new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
152                            WikiNodeModelImpl.FINDER_CACHE_ENABLED, WikiNodeImpl.class,
153                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByCompanyId",
154                            new String[] {
155                                    Long.class.getName(),
156                                    
157                            "java.lang.Integer", "java.lang.Integer",
158                                    "com.liferay.portal.kernel.util.OrderByComparator"
159                            });
160            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID =
161                    new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
162                            WikiNodeModelImpl.FINDER_CACHE_ENABLED, WikiNodeImpl.class,
163                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCompanyId",
164                            new String[] { Long.class.getName() },
165                            WikiNodeModelImpl.COMPANYID_COLUMN_BITMASK);
166            public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
167                            WikiNodeModelImpl.FINDER_CACHE_ENABLED, Long.class,
168                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCompanyId",
169                            new String[] { Long.class.getName() });
170            public static final FinderPath FINDER_PATH_FETCH_BY_G_N = new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
171                            WikiNodeModelImpl.FINDER_CACHE_ENABLED, WikiNodeImpl.class,
172                            FINDER_CLASS_NAME_ENTITY, "fetchByG_N",
173                            new String[] { Long.class.getName(), String.class.getName() },
174                            WikiNodeModelImpl.GROUPID_COLUMN_BITMASK |
175                            WikiNodeModelImpl.NAME_COLUMN_BITMASK);
176            public static final FinderPath FINDER_PATH_COUNT_BY_G_N = new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
177                            WikiNodeModelImpl.FINDER_CACHE_ENABLED, Long.class,
178                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_N",
179                            new String[] { Long.class.getName(), String.class.getName() });
180            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_S = new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
181                            WikiNodeModelImpl.FINDER_CACHE_ENABLED, WikiNodeImpl.class,
182                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_S",
183                            new String[] {
184                                    Long.class.getName(), Integer.class.getName(),
185                                    
186                            "java.lang.Integer", "java.lang.Integer",
187                                    "com.liferay.portal.kernel.util.OrderByComparator"
188                            });
189            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S = new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
190                            WikiNodeModelImpl.FINDER_CACHE_ENABLED, WikiNodeImpl.class,
191                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_S",
192                            new String[] { Long.class.getName(), Integer.class.getName() },
193                            WikiNodeModelImpl.GROUPID_COLUMN_BITMASK |
194                            WikiNodeModelImpl.STATUS_COLUMN_BITMASK);
195            public static final FinderPath FINDER_PATH_COUNT_BY_G_S = new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
196                            WikiNodeModelImpl.FINDER_CACHE_ENABLED, Long.class,
197                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_S",
198                            new String[] { Long.class.getName(), Integer.class.getName() });
199            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_S = new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
200                            WikiNodeModelImpl.FINDER_CACHE_ENABLED, WikiNodeImpl.class,
201                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_S",
202                            new String[] {
203                                    Long.class.getName(), Integer.class.getName(),
204                                    
205                            "java.lang.Integer", "java.lang.Integer",
206                                    "com.liferay.portal.kernel.util.OrderByComparator"
207                            });
208            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S = new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
209                            WikiNodeModelImpl.FINDER_CACHE_ENABLED, WikiNodeImpl.class,
210                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_S",
211                            new String[] { Long.class.getName(), Integer.class.getName() },
212                            WikiNodeModelImpl.COMPANYID_COLUMN_BITMASK |
213                            WikiNodeModelImpl.STATUS_COLUMN_BITMASK);
214            public static final FinderPath FINDER_PATH_COUNT_BY_C_S = new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
215                            WikiNodeModelImpl.FINDER_CACHE_ENABLED, Long.class,
216                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_S",
217                            new String[] { Long.class.getName(), Integer.class.getName() });
218            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
219                            WikiNodeModelImpl.FINDER_CACHE_ENABLED, WikiNodeImpl.class,
220                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
221            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
222                            WikiNodeModelImpl.FINDER_CACHE_ENABLED, WikiNodeImpl.class,
223                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
224            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
225                            WikiNodeModelImpl.FINDER_CACHE_ENABLED, Long.class,
226                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
227    
228            /**
229             * Caches the wiki node in the entity cache if it is enabled.
230             *
231             * @param wikiNode the wiki node
232             */
233            public void cacheResult(WikiNode wikiNode) {
234                    EntityCacheUtil.putResult(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
235                            WikiNodeImpl.class, wikiNode.getPrimaryKey(), wikiNode);
236    
237                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
238                            new Object[] { wikiNode.getUuid(), Long.valueOf(
239                                            wikiNode.getGroupId()) }, wikiNode);
240    
241                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
242                            new Object[] { Long.valueOf(wikiNode.getGroupId()), wikiNode.getName() },
243                            wikiNode);
244    
245                    wikiNode.resetOriginalValues();
246            }
247    
248            /**
249             * Caches the wiki nodes in the entity cache if it is enabled.
250             *
251             * @param wikiNodes the wiki nodes
252             */
253            public void cacheResult(List<WikiNode> wikiNodes) {
254                    for (WikiNode wikiNode : wikiNodes) {
255                            if (EntityCacheUtil.getResult(
256                                                    WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
257                                                    WikiNodeImpl.class, wikiNode.getPrimaryKey()) == null) {
258                                    cacheResult(wikiNode);
259                            }
260                            else {
261                                    wikiNode.resetOriginalValues();
262                            }
263                    }
264            }
265    
266            /**
267             * Clears the cache for all wiki nodes.
268             *
269             * <p>
270             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
271             * </p>
272             */
273            @Override
274            public void clearCache() {
275                    if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
276                            CacheRegistryUtil.clear(WikiNodeImpl.class.getName());
277                    }
278    
279                    EntityCacheUtil.clearCache(WikiNodeImpl.class.getName());
280    
281                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
282                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
283                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
284            }
285    
286            /**
287             * Clears the cache for the wiki node.
288             *
289             * <p>
290             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
291             * </p>
292             */
293            @Override
294            public void clearCache(WikiNode wikiNode) {
295                    EntityCacheUtil.removeResult(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
296                            WikiNodeImpl.class, wikiNode.getPrimaryKey());
297    
298                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
299                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
300    
301                    clearUniqueFindersCache(wikiNode);
302            }
303    
304            @Override
305            public void clearCache(List<WikiNode> wikiNodes) {
306                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
307                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
308    
309                    for (WikiNode wikiNode : wikiNodes) {
310                            EntityCacheUtil.removeResult(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
311                                    WikiNodeImpl.class, wikiNode.getPrimaryKey());
312    
313                            clearUniqueFindersCache(wikiNode);
314                    }
315            }
316    
317            protected void clearUniqueFindersCache(WikiNode wikiNode) {
318                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
319                            new Object[] { wikiNode.getUuid(), Long.valueOf(
320                                            wikiNode.getGroupId()) });
321    
322                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_N,
323                            new Object[] { Long.valueOf(wikiNode.getGroupId()), wikiNode.getName() });
324            }
325    
326            /**
327             * Creates a new wiki node with the primary key. Does not add the wiki node to the database.
328             *
329             * @param nodeId the primary key for the new wiki node
330             * @return the new wiki node
331             */
332            public WikiNode create(long nodeId) {
333                    WikiNode wikiNode = new WikiNodeImpl();
334    
335                    wikiNode.setNew(true);
336                    wikiNode.setPrimaryKey(nodeId);
337    
338                    String uuid = PortalUUIDUtil.generate();
339    
340                    wikiNode.setUuid(uuid);
341    
342                    return wikiNode;
343            }
344    
345            /**
346             * Removes the wiki node with the primary key from the database. Also notifies the appropriate model listeners.
347             *
348             * @param nodeId the primary key of the wiki node
349             * @return the wiki node that was removed
350             * @throws com.liferay.portlet.wiki.NoSuchNodeException if a wiki node with the primary key could not be found
351             * @throws SystemException if a system exception occurred
352             */
353            public WikiNode remove(long nodeId)
354                    throws NoSuchNodeException, SystemException {
355                    return remove(Long.valueOf(nodeId));
356            }
357    
358            /**
359             * Removes the wiki node with the primary key from the database. Also notifies the appropriate model listeners.
360             *
361             * @param primaryKey the primary key of the wiki node
362             * @return the wiki node that was removed
363             * @throws com.liferay.portlet.wiki.NoSuchNodeException if a wiki node with the primary key could not be found
364             * @throws SystemException if a system exception occurred
365             */
366            @Override
367            public WikiNode remove(Serializable primaryKey)
368                    throws NoSuchNodeException, SystemException {
369                    Session session = null;
370    
371                    try {
372                            session = openSession();
373    
374                            WikiNode wikiNode = (WikiNode)session.get(WikiNodeImpl.class,
375                                            primaryKey);
376    
377                            if (wikiNode == null) {
378                                    if (_log.isWarnEnabled()) {
379                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
380                                    }
381    
382                                    throw new NoSuchNodeException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
383                                            primaryKey);
384                            }
385    
386                            return remove(wikiNode);
387                    }
388                    catch (NoSuchNodeException nsee) {
389                            throw nsee;
390                    }
391                    catch (Exception e) {
392                            throw processException(e);
393                    }
394                    finally {
395                            closeSession(session);
396                    }
397            }
398    
399            @Override
400            protected WikiNode removeImpl(WikiNode wikiNode) throws SystemException {
401                    wikiNode = toUnwrappedModel(wikiNode);
402    
403                    Session session = null;
404    
405                    try {
406                            session = openSession();
407    
408                            if (wikiNode.isCachedModel()) {
409                                    wikiNode = (WikiNode)session.get(WikiNodeImpl.class,
410                                                    wikiNode.getPrimaryKeyObj());
411                            }
412    
413                            session.delete(wikiNode);
414                    }
415                    catch (Exception e) {
416                            throw processException(e);
417                    }
418                    finally {
419                            closeSession(session);
420                    }
421    
422                    clearCache(wikiNode);
423    
424                    return wikiNode;
425            }
426    
427            @Override
428            public WikiNode updateImpl(com.liferay.portlet.wiki.model.WikiNode wikiNode)
429                    throws SystemException {
430                    wikiNode = toUnwrappedModel(wikiNode);
431    
432                    boolean isNew = wikiNode.isNew();
433    
434                    WikiNodeModelImpl wikiNodeModelImpl = (WikiNodeModelImpl)wikiNode;
435    
436                    if (Validator.isNull(wikiNode.getUuid())) {
437                            String uuid = PortalUUIDUtil.generate();
438    
439                            wikiNode.setUuid(uuid);
440                    }
441    
442                    Session session = null;
443    
444                    try {
445                            session = openSession();
446    
447                            if (wikiNode.isNew()) {
448                                    session.save(wikiNode);
449    
450                                    wikiNode.setNew(false);
451                            }
452                            else {
453                                    session.merge(wikiNode);
454                            }
455                    }
456                    catch (Exception e) {
457                            throw processException(e);
458                    }
459                    finally {
460                            closeSession(session);
461                    }
462    
463                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
464    
465                    if (isNew || !WikiNodeModelImpl.COLUMN_BITMASK_ENABLED) {
466                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
467                    }
468    
469                    else {
470                            if ((wikiNodeModelImpl.getColumnBitmask() &
471                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
472                                    Object[] args = new Object[] { wikiNodeModelImpl.getOriginalUuid() };
473    
474                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
475                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
476                                            args);
477    
478                                    args = new Object[] { wikiNodeModelImpl.getUuid() };
479    
480                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
481                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
482                                            args);
483                            }
484    
485                            if ((wikiNodeModelImpl.getColumnBitmask() &
486                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C.getColumnBitmask()) != 0) {
487                                    Object[] args = new Object[] {
488                                                    wikiNodeModelImpl.getOriginalUuid(),
489                                                    Long.valueOf(wikiNodeModelImpl.getOriginalCompanyId())
490                                            };
491    
492                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
493                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
494                                            args);
495    
496                                    args = new Object[] {
497                                                    wikiNodeModelImpl.getUuid(),
498                                                    Long.valueOf(wikiNodeModelImpl.getCompanyId())
499                                            };
500    
501                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
502                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
503                                            args);
504                            }
505    
506                            if ((wikiNodeModelImpl.getColumnBitmask() &
507                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
508                                    Object[] args = new Object[] {
509                                                    Long.valueOf(wikiNodeModelImpl.getOriginalGroupId())
510                                            };
511    
512                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
513                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
514                                            args);
515    
516                                    args = new Object[] { Long.valueOf(wikiNodeModelImpl.getGroupId()) };
517    
518                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
519                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
520                                            args);
521                            }
522    
523                            if ((wikiNodeModelImpl.getColumnBitmask() &
524                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
525                                    Object[] args = new Object[] {
526                                                    Long.valueOf(wikiNodeModelImpl.getOriginalCompanyId())
527                                            };
528    
529                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
530                                            args);
531                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
532                                            args);
533    
534                                    args = new Object[] {
535                                                    Long.valueOf(wikiNodeModelImpl.getCompanyId())
536                                            };
537    
538                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
539                                            args);
540                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
541                                            args);
542                            }
543    
544                            if ((wikiNodeModelImpl.getColumnBitmask() &
545                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S.getColumnBitmask()) != 0) {
546                                    Object[] args = new Object[] {
547                                                    Long.valueOf(wikiNodeModelImpl.getOriginalGroupId()),
548                                                    Integer.valueOf(wikiNodeModelImpl.getOriginalStatus())
549                                            };
550    
551                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_S, args);
552                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S,
553                                            args);
554    
555                                    args = new Object[] {
556                                                    Long.valueOf(wikiNodeModelImpl.getGroupId()),
557                                                    Integer.valueOf(wikiNodeModelImpl.getStatus())
558                                            };
559    
560                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_S, args);
561                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S,
562                                            args);
563                            }
564    
565                            if ((wikiNodeModelImpl.getColumnBitmask() &
566                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S.getColumnBitmask()) != 0) {
567                                    Object[] args = new Object[] {
568                                                    Long.valueOf(wikiNodeModelImpl.getOriginalCompanyId()),
569                                                    Integer.valueOf(wikiNodeModelImpl.getOriginalStatus())
570                                            };
571    
572                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_S, args);
573                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S,
574                                            args);
575    
576                                    args = new Object[] {
577                                                    Long.valueOf(wikiNodeModelImpl.getCompanyId()),
578                                                    Integer.valueOf(wikiNodeModelImpl.getStatus())
579                                            };
580    
581                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_S, args);
582                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S,
583                                            args);
584                            }
585                    }
586    
587                    EntityCacheUtil.putResult(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
588                            WikiNodeImpl.class, wikiNode.getPrimaryKey(), wikiNode);
589    
590                    if (isNew) {
591                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
592                                    new Object[] {
593                                            wikiNode.getUuid(), Long.valueOf(wikiNode.getGroupId())
594                                    }, wikiNode);
595    
596                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
597                                    new Object[] {
598                                            Long.valueOf(wikiNode.getGroupId()),
599                                            
600                                    wikiNode.getName()
601                                    }, wikiNode);
602                    }
603                    else {
604                            if ((wikiNodeModelImpl.getColumnBitmask() &
605                                            FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
606                                    Object[] args = new Object[] {
607                                                    wikiNodeModelImpl.getOriginalUuid(),
608                                                    Long.valueOf(wikiNodeModelImpl.getOriginalGroupId())
609                                            };
610    
611                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
612    
613                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
614    
615                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
616                                            new Object[] {
617                                                    wikiNode.getUuid(), Long.valueOf(wikiNode.getGroupId())
618                                            }, wikiNode);
619                            }
620    
621                            if ((wikiNodeModelImpl.getColumnBitmask() &
622                                            FINDER_PATH_FETCH_BY_G_N.getColumnBitmask()) != 0) {
623                                    Object[] args = new Object[] {
624                                                    Long.valueOf(wikiNodeModelImpl.getOriginalGroupId()),
625                                                    
626                                                    wikiNodeModelImpl.getOriginalName()
627                                            };
628    
629                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_N, args);
630    
631                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_N, args);
632    
633                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
634                                            new Object[] {
635                                                    Long.valueOf(wikiNode.getGroupId()),
636                                                    
637                                            wikiNode.getName()
638                                            }, wikiNode);
639                            }
640                    }
641    
642                    return wikiNode;
643            }
644    
645            protected WikiNode toUnwrappedModel(WikiNode wikiNode) {
646                    if (wikiNode instanceof WikiNodeImpl) {
647                            return wikiNode;
648                    }
649    
650                    WikiNodeImpl wikiNodeImpl = new WikiNodeImpl();
651    
652                    wikiNodeImpl.setNew(wikiNode.isNew());
653                    wikiNodeImpl.setPrimaryKey(wikiNode.getPrimaryKey());
654    
655                    wikiNodeImpl.setUuid(wikiNode.getUuid());
656                    wikiNodeImpl.setNodeId(wikiNode.getNodeId());
657                    wikiNodeImpl.setGroupId(wikiNode.getGroupId());
658                    wikiNodeImpl.setCompanyId(wikiNode.getCompanyId());
659                    wikiNodeImpl.setUserId(wikiNode.getUserId());
660                    wikiNodeImpl.setUserName(wikiNode.getUserName());
661                    wikiNodeImpl.setCreateDate(wikiNode.getCreateDate());
662                    wikiNodeImpl.setModifiedDate(wikiNode.getModifiedDate());
663                    wikiNodeImpl.setName(wikiNode.getName());
664                    wikiNodeImpl.setDescription(wikiNode.getDescription());
665                    wikiNodeImpl.setLastPostDate(wikiNode.getLastPostDate());
666                    wikiNodeImpl.setStatus(wikiNode.getStatus());
667                    wikiNodeImpl.setStatusByUserId(wikiNode.getStatusByUserId());
668                    wikiNodeImpl.setStatusByUserName(wikiNode.getStatusByUserName());
669                    wikiNodeImpl.setStatusDate(wikiNode.getStatusDate());
670    
671                    return wikiNodeImpl;
672            }
673    
674            /**
675             * Returns the wiki node with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
676             *
677             * @param primaryKey the primary key of the wiki node
678             * @return the wiki node
679             * @throws com.liferay.portal.NoSuchModelException if a wiki node with the primary key could not be found
680             * @throws SystemException if a system exception occurred
681             */
682            @Override
683            public WikiNode findByPrimaryKey(Serializable primaryKey)
684                    throws NoSuchModelException, SystemException {
685                    return findByPrimaryKey(((Long)primaryKey).longValue());
686            }
687    
688            /**
689             * Returns the wiki node with the primary key or throws a {@link com.liferay.portlet.wiki.NoSuchNodeException} if it could not be found.
690             *
691             * @param nodeId the primary key of the wiki node
692             * @return the wiki node
693             * @throws com.liferay.portlet.wiki.NoSuchNodeException if a wiki node with the primary key could not be found
694             * @throws SystemException if a system exception occurred
695             */
696            public WikiNode findByPrimaryKey(long nodeId)
697                    throws NoSuchNodeException, SystemException {
698                    WikiNode wikiNode = fetchByPrimaryKey(nodeId);
699    
700                    if (wikiNode == null) {
701                            if (_log.isWarnEnabled()) {
702                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + nodeId);
703                            }
704    
705                            throw new NoSuchNodeException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
706                                    nodeId);
707                    }
708    
709                    return wikiNode;
710            }
711    
712            /**
713             * Returns the wiki node with the primary key or returns <code>null</code> if it could not be found.
714             *
715             * @param primaryKey the primary key of the wiki node
716             * @return the wiki node, or <code>null</code> if a wiki node with the primary key could not be found
717             * @throws SystemException if a system exception occurred
718             */
719            @Override
720            public WikiNode fetchByPrimaryKey(Serializable primaryKey)
721                    throws SystemException {
722                    return fetchByPrimaryKey(((Long)primaryKey).longValue());
723            }
724    
725            /**
726             * Returns the wiki node with the primary key or returns <code>null</code> if it could not be found.
727             *
728             * @param nodeId the primary key of the wiki node
729             * @return the wiki node, or <code>null</code> if a wiki node with the primary key could not be found
730             * @throws SystemException if a system exception occurred
731             */
732            public WikiNode fetchByPrimaryKey(long nodeId) throws SystemException {
733                    WikiNode wikiNode = (WikiNode)EntityCacheUtil.getResult(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
734                                    WikiNodeImpl.class, nodeId);
735    
736                    if (wikiNode == _nullWikiNode) {
737                            return null;
738                    }
739    
740                    if (wikiNode == null) {
741                            Session session = null;
742    
743                            boolean hasException = false;
744    
745                            try {
746                                    session = openSession();
747    
748                                    wikiNode = (WikiNode)session.get(WikiNodeImpl.class,
749                                                    Long.valueOf(nodeId));
750                            }
751                            catch (Exception e) {
752                                    hasException = true;
753    
754                                    throw processException(e);
755                            }
756                            finally {
757                                    if (wikiNode != null) {
758                                            cacheResult(wikiNode);
759                                    }
760                                    else if (!hasException) {
761                                            EntityCacheUtil.putResult(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
762                                                    WikiNodeImpl.class, nodeId, _nullWikiNode);
763                                    }
764    
765                                    closeSession(session);
766                            }
767                    }
768    
769                    return wikiNode;
770            }
771    
772            /**
773             * Returns all the wiki nodes where uuid = &#63;.
774             *
775             * @param uuid the uuid
776             * @return the matching wiki nodes
777             * @throws SystemException if a system exception occurred
778             */
779            public List<WikiNode> findByUuid(String uuid) throws SystemException {
780                    return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
781            }
782    
783            /**
784             * Returns a range of all the wiki nodes where uuid = &#63;.
785             *
786             * <p>
787             * 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.
788             * </p>
789             *
790             * @param uuid the uuid
791             * @param start the lower bound of the range of wiki nodes
792             * @param end the upper bound of the range of wiki nodes (not inclusive)
793             * @return the range of matching wiki nodes
794             * @throws SystemException if a system exception occurred
795             */
796            public List<WikiNode> findByUuid(String uuid, int start, int end)
797                    throws SystemException {
798                    return findByUuid(uuid, start, end, null);
799            }
800    
801            /**
802             * Returns an ordered range of all the wiki nodes where uuid = &#63;.
803             *
804             * <p>
805             * 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.
806             * </p>
807             *
808             * @param uuid the uuid
809             * @param start the lower bound of the range of wiki nodes
810             * @param end the upper bound of the range of wiki nodes (not inclusive)
811             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
812             * @return the ordered range of matching wiki nodes
813             * @throws SystemException if a system exception occurred
814             */
815            public List<WikiNode> findByUuid(String uuid, int start, int end,
816                    OrderByComparator orderByComparator) throws SystemException {
817                    FinderPath finderPath = null;
818                    Object[] finderArgs = null;
819    
820                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
821                                    (orderByComparator == null)) {
822                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
823                            finderArgs = new Object[] { uuid };
824                    }
825                    else {
826                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
827                            finderArgs = new Object[] { uuid, start, end, orderByComparator };
828                    }
829    
830                    List<WikiNode> list = (List<WikiNode>)FinderCacheUtil.getResult(finderPath,
831                                    finderArgs, this);
832    
833                    if ((list != null) && !list.isEmpty()) {
834                            for (WikiNode wikiNode : list) {
835                                    if (!Validator.equals(uuid, wikiNode.getUuid())) {
836                                            list = null;
837    
838                                            break;
839                                    }
840                            }
841                    }
842    
843                    if (list == null) {
844                            StringBundler query = null;
845    
846                            if (orderByComparator != null) {
847                                    query = new StringBundler(3 +
848                                                    (orderByComparator.getOrderByFields().length * 3));
849                            }
850                            else {
851                                    query = new StringBundler(3);
852                            }
853    
854                            query.append(_SQL_SELECT_WIKINODE_WHERE);
855    
856                            if (uuid == null) {
857                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
858                            }
859                            else {
860                                    if (uuid.equals(StringPool.BLANK)) {
861                                            query.append(_FINDER_COLUMN_UUID_UUID_3);
862                                    }
863                                    else {
864                                            query.append(_FINDER_COLUMN_UUID_UUID_2);
865                                    }
866                            }
867    
868                            if (orderByComparator != null) {
869                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
870                                            orderByComparator);
871                            }
872    
873                            else {
874                                    query.append(WikiNodeModelImpl.ORDER_BY_JPQL);
875                            }
876    
877                            String sql = query.toString();
878    
879                            Session session = null;
880    
881                            try {
882                                    session = openSession();
883    
884                                    Query q = session.createQuery(sql);
885    
886                                    QueryPos qPos = QueryPos.getInstance(q);
887    
888                                    if (uuid != null) {
889                                            qPos.add(uuid);
890                                    }
891    
892                                    list = (List<WikiNode>)QueryUtil.list(q, getDialect(), start,
893                                                    end);
894                            }
895                            catch (Exception e) {
896                                    throw processException(e);
897                            }
898                            finally {
899                                    if (list == null) {
900                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
901                                    }
902                                    else {
903                                            cacheResult(list);
904    
905                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
906                                    }
907    
908                                    closeSession(session);
909                            }
910                    }
911    
912                    return list;
913            }
914    
915            /**
916             * Returns the first wiki node in the ordered set where uuid = &#63;.
917             *
918             * @param uuid the uuid
919             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
920             * @return the first matching wiki node
921             * @throws com.liferay.portlet.wiki.NoSuchNodeException if a matching wiki node could not be found
922             * @throws SystemException if a system exception occurred
923             */
924            public WikiNode findByUuid_First(String uuid,
925                    OrderByComparator orderByComparator)
926                    throws NoSuchNodeException, SystemException {
927                    WikiNode wikiNode = fetchByUuid_First(uuid, orderByComparator);
928    
929                    if (wikiNode != null) {
930                            return wikiNode;
931                    }
932    
933                    StringBundler msg = new StringBundler(4);
934    
935                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
936    
937                    msg.append("uuid=");
938                    msg.append(uuid);
939    
940                    msg.append(StringPool.CLOSE_CURLY_BRACE);
941    
942                    throw new NoSuchNodeException(msg.toString());
943            }
944    
945            /**
946             * Returns the first wiki node in the ordered set where uuid = &#63;.
947             *
948             * @param uuid the uuid
949             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
950             * @return the first matching wiki node, or <code>null</code> if a matching wiki node could not be found
951             * @throws SystemException if a system exception occurred
952             */
953            public WikiNode fetchByUuid_First(String uuid,
954                    OrderByComparator orderByComparator) throws SystemException {
955                    List<WikiNode> list = findByUuid(uuid, 0, 1, orderByComparator);
956    
957                    if (!list.isEmpty()) {
958                            return list.get(0);
959                    }
960    
961                    return null;
962            }
963    
964            /**
965             * Returns the last wiki node in the ordered set where uuid = &#63;.
966             *
967             * @param uuid the uuid
968             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
969             * @return the last matching wiki node
970             * @throws com.liferay.portlet.wiki.NoSuchNodeException if a matching wiki node could not be found
971             * @throws SystemException if a system exception occurred
972             */
973            public WikiNode findByUuid_Last(String uuid,
974                    OrderByComparator orderByComparator)
975                    throws NoSuchNodeException, SystemException {
976                    WikiNode wikiNode = fetchByUuid_Last(uuid, orderByComparator);
977    
978                    if (wikiNode != null) {
979                            return wikiNode;
980                    }
981    
982                    StringBundler msg = new StringBundler(4);
983    
984                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
985    
986                    msg.append("uuid=");
987                    msg.append(uuid);
988    
989                    msg.append(StringPool.CLOSE_CURLY_BRACE);
990    
991                    throw new NoSuchNodeException(msg.toString());
992            }
993    
994            /**
995             * Returns the last wiki node in the ordered set where uuid = &#63;.
996             *
997             * @param uuid the uuid
998             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
999             * @return the last matching wiki node, or <code>null</code> if a matching wiki node could not be found
1000             * @throws SystemException if a system exception occurred
1001             */
1002            public WikiNode fetchByUuid_Last(String uuid,
1003                    OrderByComparator orderByComparator) throws SystemException {
1004                    int count = countByUuid(uuid);
1005    
1006                    List<WikiNode> list = findByUuid(uuid, count - 1, count,
1007                                    orderByComparator);
1008    
1009                    if (!list.isEmpty()) {
1010                            return list.get(0);
1011                    }
1012    
1013                    return null;
1014            }
1015    
1016            /**
1017             * Returns the wiki nodes before and after the current wiki node in the ordered set where uuid = &#63;.
1018             *
1019             * @param nodeId the primary key of the current wiki node
1020             * @param uuid the uuid
1021             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1022             * @return the previous, current, and next wiki node
1023             * @throws com.liferay.portlet.wiki.NoSuchNodeException if a wiki node with the primary key could not be found
1024             * @throws SystemException if a system exception occurred
1025             */
1026            public WikiNode[] findByUuid_PrevAndNext(long nodeId, String uuid,
1027                    OrderByComparator orderByComparator)
1028                    throws NoSuchNodeException, SystemException {
1029                    WikiNode wikiNode = findByPrimaryKey(nodeId);
1030    
1031                    Session session = null;
1032    
1033                    try {
1034                            session = openSession();
1035    
1036                            WikiNode[] array = new WikiNodeImpl[3];
1037    
1038                            array[0] = getByUuid_PrevAndNext(session, wikiNode, uuid,
1039                                            orderByComparator, true);
1040    
1041                            array[1] = wikiNode;
1042    
1043                            array[2] = getByUuid_PrevAndNext(session, wikiNode, uuid,
1044                                            orderByComparator, false);
1045    
1046                            return array;
1047                    }
1048                    catch (Exception e) {
1049                            throw processException(e);
1050                    }
1051                    finally {
1052                            closeSession(session);
1053                    }
1054            }
1055    
1056            protected WikiNode getByUuid_PrevAndNext(Session session,
1057                    WikiNode wikiNode, String uuid, OrderByComparator orderByComparator,
1058                    boolean previous) {
1059                    StringBundler query = null;
1060    
1061                    if (orderByComparator != null) {
1062                            query = new StringBundler(6 +
1063                                            (orderByComparator.getOrderByFields().length * 6));
1064                    }
1065                    else {
1066                            query = new StringBundler(3);
1067                    }
1068    
1069                    query.append(_SQL_SELECT_WIKINODE_WHERE);
1070    
1071                    if (uuid == null) {
1072                            query.append(_FINDER_COLUMN_UUID_UUID_1);
1073                    }
1074                    else {
1075                            if (uuid.equals(StringPool.BLANK)) {
1076                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
1077                            }
1078                            else {
1079                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
1080                            }
1081                    }
1082    
1083                    if (orderByComparator != null) {
1084                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1085    
1086                            if (orderByConditionFields.length > 0) {
1087                                    query.append(WHERE_AND);
1088                            }
1089    
1090                            for (int i = 0; i < orderByConditionFields.length; i++) {
1091                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1092                                    query.append(orderByConditionFields[i]);
1093    
1094                                    if ((i + 1) < orderByConditionFields.length) {
1095                                            if (orderByComparator.isAscending() ^ previous) {
1096                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1097                                            }
1098                                            else {
1099                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1100                                            }
1101                                    }
1102                                    else {
1103                                            if (orderByComparator.isAscending() ^ previous) {
1104                                                    query.append(WHERE_GREATER_THAN);
1105                                            }
1106                                            else {
1107                                                    query.append(WHERE_LESSER_THAN);
1108                                            }
1109                                    }
1110                            }
1111    
1112                            query.append(ORDER_BY_CLAUSE);
1113    
1114                            String[] orderByFields = orderByComparator.getOrderByFields();
1115    
1116                            for (int i = 0; i < orderByFields.length; i++) {
1117                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1118                                    query.append(orderByFields[i]);
1119    
1120                                    if ((i + 1) < orderByFields.length) {
1121                                            if (orderByComparator.isAscending() ^ previous) {
1122                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1123                                            }
1124                                            else {
1125                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1126                                            }
1127                                    }
1128                                    else {
1129                                            if (orderByComparator.isAscending() ^ previous) {
1130                                                    query.append(ORDER_BY_ASC);
1131                                            }
1132                                            else {
1133                                                    query.append(ORDER_BY_DESC);
1134                                            }
1135                                    }
1136                            }
1137                    }
1138    
1139                    else {
1140                            query.append(WikiNodeModelImpl.ORDER_BY_JPQL);
1141                    }
1142    
1143                    String sql = query.toString();
1144    
1145                    Query q = session.createQuery(sql);
1146    
1147                    q.setFirstResult(0);
1148                    q.setMaxResults(2);
1149    
1150                    QueryPos qPos = QueryPos.getInstance(q);
1151    
1152                    if (uuid != null) {
1153                            qPos.add(uuid);
1154                    }
1155    
1156                    if (orderByComparator != null) {
1157                            Object[] values = orderByComparator.getOrderByConditionValues(wikiNode);
1158    
1159                            for (Object value : values) {
1160                                    qPos.add(value);
1161                            }
1162                    }
1163    
1164                    List<WikiNode> list = q.list();
1165    
1166                    if (list.size() == 2) {
1167                            return list.get(1);
1168                    }
1169                    else {
1170                            return null;
1171                    }
1172            }
1173    
1174            /**
1175             * Returns the wiki node where uuid = &#63; and groupId = &#63; or throws a {@link com.liferay.portlet.wiki.NoSuchNodeException} if it could not be found.
1176             *
1177             * @param uuid the uuid
1178             * @param groupId the group ID
1179             * @return the matching wiki node
1180             * @throws com.liferay.portlet.wiki.NoSuchNodeException if a matching wiki node could not be found
1181             * @throws SystemException if a system exception occurred
1182             */
1183            public WikiNode findByUUID_G(String uuid, long groupId)
1184                    throws NoSuchNodeException, SystemException {
1185                    WikiNode wikiNode = fetchByUUID_G(uuid, groupId);
1186    
1187                    if (wikiNode == null) {
1188                            StringBundler msg = new StringBundler(6);
1189    
1190                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1191    
1192                            msg.append("uuid=");
1193                            msg.append(uuid);
1194    
1195                            msg.append(", groupId=");
1196                            msg.append(groupId);
1197    
1198                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1199    
1200                            if (_log.isWarnEnabled()) {
1201                                    _log.warn(msg.toString());
1202                            }
1203    
1204                            throw new NoSuchNodeException(msg.toString());
1205                    }
1206    
1207                    return wikiNode;
1208            }
1209    
1210            /**
1211             * Returns the wiki node where uuid = &#63; and groupId = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
1212             *
1213             * @param uuid the uuid
1214             * @param groupId the group ID
1215             * @return the matching wiki node, or <code>null</code> if a matching wiki node could not be found
1216             * @throws SystemException if a system exception occurred
1217             */
1218            public WikiNode fetchByUUID_G(String uuid, long groupId)
1219                    throws SystemException {
1220                    return fetchByUUID_G(uuid, groupId, true);
1221            }
1222    
1223            /**
1224             * Returns 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.
1225             *
1226             * @param uuid the uuid
1227             * @param groupId the group ID
1228             * @param retrieveFromCache whether to use the finder cache
1229             * @return the matching wiki node, or <code>null</code> if a matching wiki node could not be found
1230             * @throws SystemException if a system exception occurred
1231             */
1232            public WikiNode fetchByUUID_G(String uuid, long groupId,
1233                    boolean retrieveFromCache) throws SystemException {
1234                    Object[] finderArgs = new Object[] { uuid, groupId };
1235    
1236                    Object result = null;
1237    
1238                    if (retrieveFromCache) {
1239                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
1240                                            finderArgs, this);
1241                    }
1242    
1243                    if (result instanceof WikiNode) {
1244                            WikiNode wikiNode = (WikiNode)result;
1245    
1246                            if (!Validator.equals(uuid, wikiNode.getUuid()) ||
1247                                            (groupId != wikiNode.getGroupId())) {
1248                                    result = null;
1249                            }
1250                    }
1251    
1252                    if (result == null) {
1253                            StringBundler query = new StringBundler(4);
1254    
1255                            query.append(_SQL_SELECT_WIKINODE_WHERE);
1256    
1257                            if (uuid == null) {
1258                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
1259                            }
1260                            else {
1261                                    if (uuid.equals(StringPool.BLANK)) {
1262                                            query.append(_FINDER_COLUMN_UUID_G_UUID_3);
1263                                    }
1264                                    else {
1265                                            query.append(_FINDER_COLUMN_UUID_G_UUID_2);
1266                                    }
1267                            }
1268    
1269                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
1270    
1271                            query.append(WikiNodeModelImpl.ORDER_BY_JPQL);
1272    
1273                            String sql = query.toString();
1274    
1275                            Session session = null;
1276    
1277                            try {
1278                                    session = openSession();
1279    
1280                                    Query q = session.createQuery(sql);
1281    
1282                                    QueryPos qPos = QueryPos.getInstance(q);
1283    
1284                                    if (uuid != null) {
1285                                            qPos.add(uuid);
1286                                    }
1287    
1288                                    qPos.add(groupId);
1289    
1290                                    List<WikiNode> list = q.list();
1291    
1292                                    result = list;
1293    
1294                                    WikiNode wikiNode = null;
1295    
1296                                    if (list.isEmpty()) {
1297                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1298                                                    finderArgs, list);
1299                                    }
1300                                    else {
1301                                            wikiNode = list.get(0);
1302    
1303                                            cacheResult(wikiNode);
1304    
1305                                            if ((wikiNode.getUuid() == null) ||
1306                                                            !wikiNode.getUuid().equals(uuid) ||
1307                                                            (wikiNode.getGroupId() != groupId)) {
1308                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1309                                                            finderArgs, wikiNode);
1310                                            }
1311                                    }
1312    
1313                                    return wikiNode;
1314                            }
1315                            catch (Exception e) {
1316                                    throw processException(e);
1317                            }
1318                            finally {
1319                                    if (result == null) {
1320                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
1321                                                    finderArgs);
1322                                    }
1323    
1324                                    closeSession(session);
1325                            }
1326                    }
1327                    else {
1328                            if (result instanceof List<?>) {
1329                                    return null;
1330                            }
1331                            else {
1332                                    return (WikiNode)result;
1333                            }
1334                    }
1335            }
1336    
1337            /**
1338             * Returns all the wiki nodes where uuid = &#63; and companyId = &#63;.
1339             *
1340             * @param uuid the uuid
1341             * @param companyId the company ID
1342             * @return the matching wiki nodes
1343             * @throws SystemException if a system exception occurred
1344             */
1345            public List<WikiNode> findByUuid_C(String uuid, long companyId)
1346                    throws SystemException {
1347                    return findByUuid_C(uuid, companyId, QueryUtil.ALL_POS,
1348                            QueryUtil.ALL_POS, null);
1349            }
1350    
1351            /**
1352             * Returns a range of all the wiki nodes where uuid = &#63; and companyId = &#63;.
1353             *
1354             * <p>
1355             * 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.
1356             * </p>
1357             *
1358             * @param uuid the uuid
1359             * @param companyId the company ID
1360             * @param start the lower bound of the range of wiki nodes
1361             * @param end the upper bound of the range of wiki nodes (not inclusive)
1362             * @return the range of matching wiki nodes
1363             * @throws SystemException if a system exception occurred
1364             */
1365            public List<WikiNode> findByUuid_C(String uuid, long companyId, int start,
1366                    int end) throws SystemException {
1367                    return findByUuid_C(uuid, companyId, start, end, null);
1368            }
1369    
1370            /**
1371             * Returns an ordered range of all the wiki nodes where uuid = &#63; and companyId = &#63;.
1372             *
1373             * <p>
1374             * 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.
1375             * </p>
1376             *
1377             * @param uuid the uuid
1378             * @param companyId the company ID
1379             * @param start the lower bound of the range of wiki nodes
1380             * @param end the upper bound of the range of wiki nodes (not inclusive)
1381             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1382             * @return the ordered range of matching wiki nodes
1383             * @throws SystemException if a system exception occurred
1384             */
1385            public List<WikiNode> findByUuid_C(String uuid, long companyId, int start,
1386                    int end, OrderByComparator orderByComparator) throws SystemException {
1387                    FinderPath finderPath = null;
1388                    Object[] finderArgs = null;
1389    
1390                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1391                                    (orderByComparator == null)) {
1392                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C;
1393                            finderArgs = new Object[] { uuid, companyId };
1394                    }
1395                    else {
1396                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C;
1397                            finderArgs = new Object[] {
1398                                            uuid, companyId,
1399                                            
1400                                            start, end, orderByComparator
1401                                    };
1402                    }
1403    
1404                    List<WikiNode> list = (List<WikiNode>)FinderCacheUtil.getResult(finderPath,
1405                                    finderArgs, this);
1406    
1407                    if ((list != null) && !list.isEmpty()) {
1408                            for (WikiNode wikiNode : list) {
1409                                    if (!Validator.equals(uuid, wikiNode.getUuid()) ||
1410                                                    (companyId != wikiNode.getCompanyId())) {
1411                                            list = null;
1412    
1413                                            break;
1414                                    }
1415                            }
1416                    }
1417    
1418                    if (list == null) {
1419                            StringBundler query = null;
1420    
1421                            if (orderByComparator != null) {
1422                                    query = new StringBundler(4 +
1423                                                    (orderByComparator.getOrderByFields().length * 3));
1424                            }
1425                            else {
1426                                    query = new StringBundler(4);
1427                            }
1428    
1429                            query.append(_SQL_SELECT_WIKINODE_WHERE);
1430    
1431                            if (uuid == null) {
1432                                    query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1433                            }
1434                            else {
1435                                    if (uuid.equals(StringPool.BLANK)) {
1436                                            query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1437                                    }
1438                                    else {
1439                                            query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1440                                    }
1441                            }
1442    
1443                            query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1444    
1445                            if (orderByComparator != null) {
1446                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1447                                            orderByComparator);
1448                            }
1449    
1450                            else {
1451                                    query.append(WikiNodeModelImpl.ORDER_BY_JPQL);
1452                            }
1453    
1454                            String sql = query.toString();
1455    
1456                            Session session = null;
1457    
1458                            try {
1459                                    session = openSession();
1460    
1461                                    Query q = session.createQuery(sql);
1462    
1463                                    QueryPos qPos = QueryPos.getInstance(q);
1464    
1465                                    if (uuid != null) {
1466                                            qPos.add(uuid);
1467                                    }
1468    
1469                                    qPos.add(companyId);
1470    
1471                                    list = (List<WikiNode>)QueryUtil.list(q, getDialect(), start,
1472                                                    end);
1473                            }
1474                            catch (Exception e) {
1475                                    throw processException(e);
1476                            }
1477                            finally {
1478                                    if (list == null) {
1479                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1480                                    }
1481                                    else {
1482                                            cacheResult(list);
1483    
1484                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1485                                    }
1486    
1487                                    closeSession(session);
1488                            }
1489                    }
1490    
1491                    return list;
1492            }
1493    
1494            /**
1495             * Returns the first wiki node in the ordered set where uuid = &#63; and companyId = &#63;.
1496             *
1497             * @param uuid the uuid
1498             * @param companyId the company ID
1499             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1500             * @return the first matching wiki node
1501             * @throws com.liferay.portlet.wiki.NoSuchNodeException if a matching wiki node could not be found
1502             * @throws SystemException if a system exception occurred
1503             */
1504            public WikiNode findByUuid_C_First(String uuid, long companyId,
1505                    OrderByComparator orderByComparator)
1506                    throws NoSuchNodeException, SystemException {
1507                    WikiNode wikiNode = fetchByUuid_C_First(uuid, companyId,
1508                                    orderByComparator);
1509    
1510                    if (wikiNode != null) {
1511                            return wikiNode;
1512                    }
1513    
1514                    StringBundler msg = new StringBundler(6);
1515    
1516                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1517    
1518                    msg.append("uuid=");
1519                    msg.append(uuid);
1520    
1521                    msg.append(", companyId=");
1522                    msg.append(companyId);
1523    
1524                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1525    
1526                    throw new NoSuchNodeException(msg.toString());
1527            }
1528    
1529            /**
1530             * Returns the first wiki node in the ordered set where uuid = &#63; and companyId = &#63;.
1531             *
1532             * @param uuid the uuid
1533             * @param companyId the company ID
1534             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1535             * @return the first matching wiki node, or <code>null</code> if a matching wiki node could not be found
1536             * @throws SystemException if a system exception occurred
1537             */
1538            public WikiNode fetchByUuid_C_First(String uuid, long companyId,
1539                    OrderByComparator orderByComparator) throws SystemException {
1540                    List<WikiNode> list = findByUuid_C(uuid, companyId, 0, 1,
1541                                    orderByComparator);
1542    
1543                    if (!list.isEmpty()) {
1544                            return list.get(0);
1545                    }
1546    
1547                    return null;
1548            }
1549    
1550            /**
1551             * Returns the last wiki node in the ordered set where uuid = &#63; and companyId = &#63;.
1552             *
1553             * @param uuid the uuid
1554             * @param companyId the company ID
1555             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1556             * @return the last matching wiki node
1557             * @throws com.liferay.portlet.wiki.NoSuchNodeException if a matching wiki node could not be found
1558             * @throws SystemException if a system exception occurred
1559             */
1560            public WikiNode findByUuid_C_Last(String uuid, long companyId,
1561                    OrderByComparator orderByComparator)
1562                    throws NoSuchNodeException, SystemException {
1563                    WikiNode wikiNode = fetchByUuid_C_Last(uuid, companyId,
1564                                    orderByComparator);
1565    
1566                    if (wikiNode != null) {
1567                            return wikiNode;
1568                    }
1569    
1570                    StringBundler msg = new StringBundler(6);
1571    
1572                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1573    
1574                    msg.append("uuid=");
1575                    msg.append(uuid);
1576    
1577                    msg.append(", companyId=");
1578                    msg.append(companyId);
1579    
1580                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1581    
1582                    throw new NoSuchNodeException(msg.toString());
1583            }
1584    
1585            /**
1586             * Returns the last wiki node in the ordered set where uuid = &#63; and companyId = &#63;.
1587             *
1588             * @param uuid the uuid
1589             * @param companyId the company ID
1590             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1591             * @return the last matching wiki node, or <code>null</code> if a matching wiki node could not be found
1592             * @throws SystemException if a system exception occurred
1593             */
1594            public WikiNode fetchByUuid_C_Last(String uuid, long companyId,
1595                    OrderByComparator orderByComparator) throws SystemException {
1596                    int count = countByUuid_C(uuid, companyId);
1597    
1598                    List<WikiNode> list = findByUuid_C(uuid, companyId, count - 1, count,
1599                                    orderByComparator);
1600    
1601                    if (!list.isEmpty()) {
1602                            return list.get(0);
1603                    }
1604    
1605                    return null;
1606            }
1607    
1608            /**
1609             * Returns the wiki nodes before and after the current wiki node in the ordered set where uuid = &#63; and companyId = &#63;.
1610             *
1611             * @param nodeId the primary key of the current wiki node
1612             * @param uuid the uuid
1613             * @param companyId the company ID
1614             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1615             * @return the previous, current, and next wiki node
1616             * @throws com.liferay.portlet.wiki.NoSuchNodeException if a wiki node with the primary key could not be found
1617             * @throws SystemException if a system exception occurred
1618             */
1619            public WikiNode[] findByUuid_C_PrevAndNext(long nodeId, String uuid,
1620                    long companyId, OrderByComparator orderByComparator)
1621                    throws NoSuchNodeException, SystemException {
1622                    WikiNode wikiNode = findByPrimaryKey(nodeId);
1623    
1624                    Session session = null;
1625    
1626                    try {
1627                            session = openSession();
1628    
1629                            WikiNode[] array = new WikiNodeImpl[3];
1630    
1631                            array[0] = getByUuid_C_PrevAndNext(session, wikiNode, uuid,
1632                                            companyId, orderByComparator, true);
1633    
1634                            array[1] = wikiNode;
1635    
1636                            array[2] = getByUuid_C_PrevAndNext(session, wikiNode, uuid,
1637                                            companyId, orderByComparator, false);
1638    
1639                            return array;
1640                    }
1641                    catch (Exception e) {
1642                            throw processException(e);
1643                    }
1644                    finally {
1645                            closeSession(session);
1646                    }
1647            }
1648    
1649            protected WikiNode getByUuid_C_PrevAndNext(Session session,
1650                    WikiNode wikiNode, String uuid, long companyId,
1651                    OrderByComparator orderByComparator, boolean previous) {
1652                    StringBundler query = null;
1653    
1654                    if (orderByComparator != null) {
1655                            query = new StringBundler(6 +
1656                                            (orderByComparator.getOrderByFields().length * 6));
1657                    }
1658                    else {
1659                            query = new StringBundler(3);
1660                    }
1661    
1662                    query.append(_SQL_SELECT_WIKINODE_WHERE);
1663    
1664                    if (uuid == null) {
1665                            query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1666                    }
1667                    else {
1668                            if (uuid.equals(StringPool.BLANK)) {
1669                                    query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1670                            }
1671                            else {
1672                                    query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1673                            }
1674                    }
1675    
1676                    query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1677    
1678                    if (orderByComparator != null) {
1679                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1680    
1681                            if (orderByConditionFields.length > 0) {
1682                                    query.append(WHERE_AND);
1683                            }
1684    
1685                            for (int i = 0; i < orderByConditionFields.length; i++) {
1686                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1687                                    query.append(orderByConditionFields[i]);
1688    
1689                                    if ((i + 1) < orderByConditionFields.length) {
1690                                            if (orderByComparator.isAscending() ^ previous) {
1691                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1692                                            }
1693                                            else {
1694                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1695                                            }
1696                                    }
1697                                    else {
1698                                            if (orderByComparator.isAscending() ^ previous) {
1699                                                    query.append(WHERE_GREATER_THAN);
1700                                            }
1701                                            else {
1702                                                    query.append(WHERE_LESSER_THAN);
1703                                            }
1704                                    }
1705                            }
1706    
1707                            query.append(ORDER_BY_CLAUSE);
1708    
1709                            String[] orderByFields = orderByComparator.getOrderByFields();
1710    
1711                            for (int i = 0; i < orderByFields.length; i++) {
1712                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1713                                    query.append(orderByFields[i]);
1714    
1715                                    if ((i + 1) < orderByFields.length) {
1716                                            if (orderByComparator.isAscending() ^ previous) {
1717                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1718                                            }
1719                                            else {
1720                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1721                                            }
1722                                    }
1723                                    else {
1724                                            if (orderByComparator.isAscending() ^ previous) {
1725                                                    query.append(ORDER_BY_ASC);
1726                                            }
1727                                            else {
1728                                                    query.append(ORDER_BY_DESC);
1729                                            }
1730                                    }
1731                            }
1732                    }
1733    
1734                    else {
1735                            query.append(WikiNodeModelImpl.ORDER_BY_JPQL);
1736                    }
1737    
1738                    String sql = query.toString();
1739    
1740                    Query q = session.createQuery(sql);
1741    
1742                    q.setFirstResult(0);
1743                    q.setMaxResults(2);
1744    
1745                    QueryPos qPos = QueryPos.getInstance(q);
1746    
1747                    if (uuid != null) {
1748                            qPos.add(uuid);
1749                    }
1750    
1751                    qPos.add(companyId);
1752    
1753                    if (orderByComparator != null) {
1754                            Object[] values = orderByComparator.getOrderByConditionValues(wikiNode);
1755    
1756                            for (Object value : values) {
1757                                    qPos.add(value);
1758                            }
1759                    }
1760    
1761                    List<WikiNode> list = q.list();
1762    
1763                    if (list.size() == 2) {
1764                            return list.get(1);
1765                    }
1766                    else {
1767                            return null;
1768                    }
1769            }
1770    
1771            /**
1772             * Returns all the wiki nodes where groupId = &#63;.
1773             *
1774             * @param groupId the group ID
1775             * @return the matching wiki nodes
1776             * @throws SystemException if a system exception occurred
1777             */
1778            public List<WikiNode> findByGroupId(long groupId) throws SystemException {
1779                    return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1780            }
1781    
1782            /**
1783             * Returns a range of all the wiki nodes where groupId = &#63;.
1784             *
1785             * <p>
1786             * 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.
1787             * </p>
1788             *
1789             * @param groupId the group ID
1790             * @param start the lower bound of the range of wiki nodes
1791             * @param end the upper bound of the range of wiki nodes (not inclusive)
1792             * @return the range of matching wiki nodes
1793             * @throws SystemException if a system exception occurred
1794             */
1795            public List<WikiNode> findByGroupId(long groupId, int start, int end)
1796                    throws SystemException {
1797                    return findByGroupId(groupId, start, end, null);
1798            }
1799    
1800            /**
1801             * Returns an ordered range of all the wiki nodes where groupId = &#63;.
1802             *
1803             * <p>
1804             * 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.
1805             * </p>
1806             *
1807             * @param groupId the group ID
1808             * @param start the lower bound of the range of wiki nodes
1809             * @param end the upper bound of the range of wiki nodes (not inclusive)
1810             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1811             * @return the ordered range of matching wiki nodes
1812             * @throws SystemException if a system exception occurred
1813             */
1814            public List<WikiNode> findByGroupId(long groupId, int start, int end,
1815                    OrderByComparator orderByComparator) throws SystemException {
1816                    FinderPath finderPath = null;
1817                    Object[] finderArgs = null;
1818    
1819                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1820                                    (orderByComparator == null)) {
1821                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
1822                            finderArgs = new Object[] { groupId };
1823                    }
1824                    else {
1825                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
1826                            finderArgs = new Object[] { groupId, start, end, orderByComparator };
1827                    }
1828    
1829                    List<WikiNode> list = (List<WikiNode>)FinderCacheUtil.getResult(finderPath,
1830                                    finderArgs, this);
1831    
1832                    if ((list != null) && !list.isEmpty()) {
1833                            for (WikiNode wikiNode : list) {
1834                                    if ((groupId != wikiNode.getGroupId())) {
1835                                            list = null;
1836    
1837                                            break;
1838                                    }
1839                            }
1840                    }
1841    
1842                    if (list == null) {
1843                            StringBundler query = null;
1844    
1845                            if (orderByComparator != null) {
1846                                    query = new StringBundler(3 +
1847                                                    (orderByComparator.getOrderByFields().length * 3));
1848                            }
1849                            else {
1850                                    query = new StringBundler(3);
1851                            }
1852    
1853                            query.append(_SQL_SELECT_WIKINODE_WHERE);
1854    
1855                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1856    
1857                            if (orderByComparator != null) {
1858                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1859                                            orderByComparator);
1860                            }
1861    
1862                            else {
1863                                    query.append(WikiNodeModelImpl.ORDER_BY_JPQL);
1864                            }
1865    
1866                            String sql = query.toString();
1867    
1868                            Session session = null;
1869    
1870                            try {
1871                                    session = openSession();
1872    
1873                                    Query q = session.createQuery(sql);
1874    
1875                                    QueryPos qPos = QueryPos.getInstance(q);
1876    
1877                                    qPos.add(groupId);
1878    
1879                                    list = (List<WikiNode>)QueryUtil.list(q, getDialect(), start,
1880                                                    end);
1881                            }
1882                            catch (Exception e) {
1883                                    throw processException(e);
1884                            }
1885                            finally {
1886                                    if (list == null) {
1887                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1888                                    }
1889                                    else {
1890                                            cacheResult(list);
1891    
1892                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1893                                    }
1894    
1895                                    closeSession(session);
1896                            }
1897                    }
1898    
1899                    return list;
1900            }
1901    
1902            /**
1903             * Returns the first wiki node in the ordered set where groupId = &#63;.
1904             *
1905             * @param groupId the group ID
1906             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1907             * @return the first matching wiki node
1908             * @throws com.liferay.portlet.wiki.NoSuchNodeException if a matching wiki node could not be found
1909             * @throws SystemException if a system exception occurred
1910             */
1911            public WikiNode findByGroupId_First(long groupId,
1912                    OrderByComparator orderByComparator)
1913                    throws NoSuchNodeException, SystemException {
1914                    WikiNode wikiNode = fetchByGroupId_First(groupId, orderByComparator);
1915    
1916                    if (wikiNode != null) {
1917                            return wikiNode;
1918                    }
1919    
1920                    StringBundler msg = new StringBundler(4);
1921    
1922                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1923    
1924                    msg.append("groupId=");
1925                    msg.append(groupId);
1926    
1927                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1928    
1929                    throw new NoSuchNodeException(msg.toString());
1930            }
1931    
1932            /**
1933             * Returns the first wiki node in the ordered set where groupId = &#63;.
1934             *
1935             * @param groupId the group ID
1936             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1937             * @return the first matching wiki node, or <code>null</code> if a matching wiki node could not be found
1938             * @throws SystemException if a system exception occurred
1939             */
1940            public WikiNode fetchByGroupId_First(long groupId,
1941                    OrderByComparator orderByComparator) throws SystemException {
1942                    List<WikiNode> list = findByGroupId(groupId, 0, 1, orderByComparator);
1943    
1944                    if (!list.isEmpty()) {
1945                            return list.get(0);
1946                    }
1947    
1948                    return null;
1949            }
1950    
1951            /**
1952             * Returns the last wiki node in the ordered set where groupId = &#63;.
1953             *
1954             * @param groupId the group ID
1955             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1956             * @return the last matching wiki node
1957             * @throws com.liferay.portlet.wiki.NoSuchNodeException if a matching wiki node could not be found
1958             * @throws SystemException if a system exception occurred
1959             */
1960            public WikiNode findByGroupId_Last(long groupId,
1961                    OrderByComparator orderByComparator)
1962                    throws NoSuchNodeException, SystemException {
1963                    WikiNode wikiNode = fetchByGroupId_Last(groupId, orderByComparator);
1964    
1965                    if (wikiNode != null) {
1966                            return wikiNode;
1967                    }
1968    
1969                    StringBundler msg = new StringBundler(4);
1970    
1971                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1972    
1973                    msg.append("groupId=");
1974                    msg.append(groupId);
1975    
1976                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1977    
1978                    throw new NoSuchNodeException(msg.toString());
1979            }
1980    
1981            /**
1982             * Returns the last wiki node in the ordered set where groupId = &#63;.
1983             *
1984             * @param groupId the group ID
1985             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1986             * @return the last matching wiki node, or <code>null</code> if a matching wiki node could not be found
1987             * @throws SystemException if a system exception occurred
1988             */
1989            public WikiNode fetchByGroupId_Last(long groupId,
1990                    OrderByComparator orderByComparator) throws SystemException {
1991                    int count = countByGroupId(groupId);
1992    
1993                    List<WikiNode> list = findByGroupId(groupId, count - 1, count,
1994                                    orderByComparator);
1995    
1996                    if (!list.isEmpty()) {
1997                            return list.get(0);
1998                    }
1999    
2000                    return null;
2001            }
2002    
2003            /**
2004             * Returns the wiki nodes before and after the current wiki node in the ordered set where groupId = &#63;.
2005             *
2006             * @param nodeId the primary key of the current wiki node
2007             * @param groupId the group ID
2008             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2009             * @return the previous, current, and next wiki node
2010             * @throws com.liferay.portlet.wiki.NoSuchNodeException if a wiki node with the primary key could not be found
2011             * @throws SystemException if a system exception occurred
2012             */
2013            public WikiNode[] findByGroupId_PrevAndNext(long nodeId, long groupId,
2014                    OrderByComparator orderByComparator)
2015                    throws NoSuchNodeException, SystemException {
2016                    WikiNode wikiNode = findByPrimaryKey(nodeId);
2017    
2018                    Session session = null;
2019    
2020                    try {
2021                            session = openSession();
2022    
2023                            WikiNode[] array = new WikiNodeImpl[3];
2024    
2025                            array[0] = getByGroupId_PrevAndNext(session, wikiNode, groupId,
2026                                            orderByComparator, true);
2027    
2028                            array[1] = wikiNode;
2029    
2030                            array[2] = getByGroupId_PrevAndNext(session, wikiNode, groupId,
2031                                            orderByComparator, false);
2032    
2033                            return array;
2034                    }
2035                    catch (Exception e) {
2036                            throw processException(e);
2037                    }
2038                    finally {
2039                            closeSession(session);
2040                    }
2041            }
2042    
2043            protected WikiNode getByGroupId_PrevAndNext(Session session,
2044                    WikiNode wikiNode, long groupId, OrderByComparator orderByComparator,
2045                    boolean previous) {
2046                    StringBundler query = null;
2047    
2048                    if (orderByComparator != null) {
2049                            query = new StringBundler(6 +
2050                                            (orderByComparator.getOrderByFields().length * 6));
2051                    }
2052                    else {
2053                            query = new StringBundler(3);
2054                    }
2055    
2056                    query.append(_SQL_SELECT_WIKINODE_WHERE);
2057    
2058                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2059    
2060                    if (orderByComparator != null) {
2061                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2062    
2063                            if (orderByConditionFields.length > 0) {
2064                                    query.append(WHERE_AND);
2065                            }
2066    
2067                            for (int i = 0; i < orderByConditionFields.length; i++) {
2068                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2069                                    query.append(orderByConditionFields[i]);
2070    
2071                                    if ((i + 1) < orderByConditionFields.length) {
2072                                            if (orderByComparator.isAscending() ^ previous) {
2073                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2074                                            }
2075                                            else {
2076                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2077                                            }
2078                                    }
2079                                    else {
2080                                            if (orderByComparator.isAscending() ^ previous) {
2081                                                    query.append(WHERE_GREATER_THAN);
2082                                            }
2083                                            else {
2084                                                    query.append(WHERE_LESSER_THAN);
2085                                            }
2086                                    }
2087                            }
2088    
2089                            query.append(ORDER_BY_CLAUSE);
2090    
2091                            String[] orderByFields = orderByComparator.getOrderByFields();
2092    
2093                            for (int i = 0; i < orderByFields.length; i++) {
2094                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2095                                    query.append(orderByFields[i]);
2096    
2097                                    if ((i + 1) < orderByFields.length) {
2098                                            if (orderByComparator.isAscending() ^ previous) {
2099                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2100                                            }
2101                                            else {
2102                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2103                                            }
2104                                    }
2105                                    else {
2106                                            if (orderByComparator.isAscending() ^ previous) {
2107                                                    query.append(ORDER_BY_ASC);
2108                                            }
2109                                            else {
2110                                                    query.append(ORDER_BY_DESC);
2111                                            }
2112                                    }
2113                            }
2114                    }
2115    
2116                    else {
2117                            query.append(WikiNodeModelImpl.ORDER_BY_JPQL);
2118                    }
2119    
2120                    String sql = query.toString();
2121    
2122                    Query q = session.createQuery(sql);
2123    
2124                    q.setFirstResult(0);
2125                    q.setMaxResults(2);
2126    
2127                    QueryPos qPos = QueryPos.getInstance(q);
2128    
2129                    qPos.add(groupId);
2130    
2131                    if (orderByComparator != null) {
2132                            Object[] values = orderByComparator.getOrderByConditionValues(wikiNode);
2133    
2134                            for (Object value : values) {
2135                                    qPos.add(value);
2136                            }
2137                    }
2138    
2139                    List<WikiNode> list = q.list();
2140    
2141                    if (list.size() == 2) {
2142                            return list.get(1);
2143                    }
2144                    else {
2145                            return null;
2146                    }
2147            }
2148    
2149            /**
2150             * Returns all the wiki nodes that the user has permission to view where groupId = &#63;.
2151             *
2152             * @param groupId the group ID
2153             * @return the matching wiki nodes that the user has permission to view
2154             * @throws SystemException if a system exception occurred
2155             */
2156            public List<WikiNode> filterFindByGroupId(long groupId)
2157                    throws SystemException {
2158                    return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
2159                            QueryUtil.ALL_POS, null);
2160            }
2161    
2162            /**
2163             * Returns a range of all the wiki nodes that the user has permission to view where groupId = &#63;.
2164             *
2165             * <p>
2166             * 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.
2167             * </p>
2168             *
2169             * @param groupId the group ID
2170             * @param start the lower bound of the range of wiki nodes
2171             * @param end the upper bound of the range of wiki nodes (not inclusive)
2172             * @return the range of matching wiki nodes that the user has permission to view
2173             * @throws SystemException if a system exception occurred
2174             */
2175            public List<WikiNode> filterFindByGroupId(long groupId, int start, int end)
2176                    throws SystemException {
2177                    return filterFindByGroupId(groupId, start, end, null);
2178            }
2179    
2180            /**
2181             * Returns an ordered range of all the wiki nodes that the user has permissions to view where groupId = &#63;.
2182             *
2183             * <p>
2184             * 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.
2185             * </p>
2186             *
2187             * @param groupId the group ID
2188             * @param start the lower bound of the range of wiki nodes
2189             * @param end the upper bound of the range of wiki nodes (not inclusive)
2190             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2191             * @return the ordered range of matching wiki nodes that the user has permission to view
2192             * @throws SystemException if a system exception occurred
2193             */
2194            public List<WikiNode> filterFindByGroupId(long groupId, int start, int end,
2195                    OrderByComparator orderByComparator) throws SystemException {
2196                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2197                            return findByGroupId(groupId, start, end, orderByComparator);
2198                    }
2199    
2200                    StringBundler query = null;
2201    
2202                    if (orderByComparator != null) {
2203                            query = new StringBundler(3 +
2204                                            (orderByComparator.getOrderByFields().length * 3));
2205                    }
2206                    else {
2207                            query = new StringBundler(3);
2208                    }
2209    
2210                    if (getDB().isSupportsInlineDistinct()) {
2211                            query.append(_FILTER_SQL_SELECT_WIKINODE_WHERE);
2212                    }
2213                    else {
2214                            query.append(_FILTER_SQL_SELECT_WIKINODE_NO_INLINE_DISTINCT_WHERE_1);
2215                    }
2216    
2217                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2218    
2219                    if (!getDB().isSupportsInlineDistinct()) {
2220                            query.append(_FILTER_SQL_SELECT_WIKINODE_NO_INLINE_DISTINCT_WHERE_2);
2221                    }
2222    
2223                    if (orderByComparator != null) {
2224                            if (getDB().isSupportsInlineDistinct()) {
2225                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2226                                            orderByComparator);
2227                            }
2228                            else {
2229                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
2230                                            orderByComparator);
2231                            }
2232                    }
2233    
2234                    else {
2235                            if (getDB().isSupportsInlineDistinct()) {
2236                                    query.append(WikiNodeModelImpl.ORDER_BY_JPQL);
2237                            }
2238                            else {
2239                                    query.append(WikiNodeModelImpl.ORDER_BY_SQL);
2240                            }
2241                    }
2242    
2243                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2244                                    WikiNode.class.getName(),
2245                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2246    
2247                    Session session = null;
2248    
2249                    try {
2250                            session = openSession();
2251    
2252                            SQLQuery q = session.createSQLQuery(sql);
2253    
2254                            if (getDB().isSupportsInlineDistinct()) {
2255                                    q.addEntity(_FILTER_ENTITY_ALIAS, WikiNodeImpl.class);
2256                            }
2257                            else {
2258                                    q.addEntity(_FILTER_ENTITY_TABLE, WikiNodeImpl.class);
2259                            }
2260    
2261                            QueryPos qPos = QueryPos.getInstance(q);
2262    
2263                            qPos.add(groupId);
2264    
2265                            return (List<WikiNode>)QueryUtil.list(q, getDialect(), start, end);
2266                    }
2267                    catch (Exception e) {
2268                            throw processException(e);
2269                    }
2270                    finally {
2271                            closeSession(session);
2272                    }
2273            }
2274    
2275            /**
2276             * Returns the wiki nodes before and after the current wiki node in the ordered set of wiki nodes that the user has permission to view where groupId = &#63;.
2277             *
2278             * @param nodeId the primary key of the current wiki node
2279             * @param groupId the group ID
2280             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2281             * @return the previous, current, and next wiki node
2282             * @throws com.liferay.portlet.wiki.NoSuchNodeException if a wiki node with the primary key could not be found
2283             * @throws SystemException if a system exception occurred
2284             */
2285            public WikiNode[] filterFindByGroupId_PrevAndNext(long nodeId,
2286                    long groupId, OrderByComparator orderByComparator)
2287                    throws NoSuchNodeException, SystemException {
2288                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2289                            return findByGroupId_PrevAndNext(nodeId, groupId, orderByComparator);
2290                    }
2291    
2292                    WikiNode wikiNode = findByPrimaryKey(nodeId);
2293    
2294                    Session session = null;
2295    
2296                    try {
2297                            session = openSession();
2298    
2299                            WikiNode[] array = new WikiNodeImpl[3];
2300    
2301                            array[0] = filterGetByGroupId_PrevAndNext(session, wikiNode,
2302                                            groupId, orderByComparator, true);
2303    
2304                            array[1] = wikiNode;
2305    
2306                            array[2] = filterGetByGroupId_PrevAndNext(session, wikiNode,
2307                                            groupId, orderByComparator, false);
2308    
2309                            return array;
2310                    }
2311                    catch (Exception e) {
2312                            throw processException(e);
2313                    }
2314                    finally {
2315                            closeSession(session);
2316                    }
2317            }
2318    
2319            protected WikiNode filterGetByGroupId_PrevAndNext(Session session,
2320                    WikiNode wikiNode, long groupId, OrderByComparator orderByComparator,
2321                    boolean previous) {
2322                    StringBundler query = null;
2323    
2324                    if (orderByComparator != null) {
2325                            query = new StringBundler(6 +
2326                                            (orderByComparator.getOrderByFields().length * 6));
2327                    }
2328                    else {
2329                            query = new StringBundler(3);
2330                    }
2331    
2332                    if (getDB().isSupportsInlineDistinct()) {
2333                            query.append(_FILTER_SQL_SELECT_WIKINODE_WHERE);
2334                    }
2335                    else {
2336                            query.append(_FILTER_SQL_SELECT_WIKINODE_NO_INLINE_DISTINCT_WHERE_1);
2337                    }
2338    
2339                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2340    
2341                    if (!getDB().isSupportsInlineDistinct()) {
2342                            query.append(_FILTER_SQL_SELECT_WIKINODE_NO_INLINE_DISTINCT_WHERE_2);
2343                    }
2344    
2345                    if (orderByComparator != null) {
2346                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2347    
2348                            if (orderByConditionFields.length > 0) {
2349                                    query.append(WHERE_AND);
2350                            }
2351    
2352                            for (int i = 0; i < orderByConditionFields.length; i++) {
2353                                    if (getDB().isSupportsInlineDistinct()) {
2354                                            query.append(_ORDER_BY_ENTITY_ALIAS);
2355                                    }
2356                                    else {
2357                                            query.append(_ORDER_BY_ENTITY_TABLE);
2358                                    }
2359    
2360                                    query.append(orderByConditionFields[i]);
2361    
2362                                    if ((i + 1) < orderByConditionFields.length) {
2363                                            if (orderByComparator.isAscending() ^ previous) {
2364                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2365                                            }
2366                                            else {
2367                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2368                                            }
2369                                    }
2370                                    else {
2371                                            if (orderByComparator.isAscending() ^ previous) {
2372                                                    query.append(WHERE_GREATER_THAN);
2373                                            }
2374                                            else {
2375                                                    query.append(WHERE_LESSER_THAN);
2376                                            }
2377                                    }
2378                            }
2379    
2380                            query.append(ORDER_BY_CLAUSE);
2381    
2382                            String[] orderByFields = orderByComparator.getOrderByFields();
2383    
2384                            for (int i = 0; i < orderByFields.length; i++) {
2385                                    if (getDB().isSupportsInlineDistinct()) {
2386                                            query.append(_ORDER_BY_ENTITY_ALIAS);
2387                                    }
2388                                    else {
2389                                            query.append(_ORDER_BY_ENTITY_TABLE);
2390                                    }
2391    
2392                                    query.append(orderByFields[i]);
2393    
2394                                    if ((i + 1) < orderByFields.length) {
2395                                            if (orderByComparator.isAscending() ^ previous) {
2396                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2397                                            }
2398                                            else {
2399                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2400                                            }
2401                                    }
2402                                    else {
2403                                            if (orderByComparator.isAscending() ^ previous) {
2404                                                    query.append(ORDER_BY_ASC);
2405                                            }
2406                                            else {
2407                                                    query.append(ORDER_BY_DESC);
2408                                            }
2409                                    }
2410                            }
2411                    }
2412    
2413                    else {
2414                            if (getDB().isSupportsInlineDistinct()) {
2415                                    query.append(WikiNodeModelImpl.ORDER_BY_JPQL);
2416                            }
2417                            else {
2418                                    query.append(WikiNodeModelImpl.ORDER_BY_SQL);
2419                            }
2420                    }
2421    
2422                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2423                                    WikiNode.class.getName(),
2424                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2425    
2426                    SQLQuery q = session.createSQLQuery(sql);
2427    
2428                    q.setFirstResult(0);
2429                    q.setMaxResults(2);
2430    
2431                    if (getDB().isSupportsInlineDistinct()) {
2432                            q.addEntity(_FILTER_ENTITY_ALIAS, WikiNodeImpl.class);
2433                    }
2434                    else {
2435                            q.addEntity(_FILTER_ENTITY_TABLE, WikiNodeImpl.class);
2436                    }
2437    
2438                    QueryPos qPos = QueryPos.getInstance(q);
2439    
2440                    qPos.add(groupId);
2441    
2442                    if (orderByComparator != null) {
2443                            Object[] values = orderByComparator.getOrderByConditionValues(wikiNode);
2444    
2445                            for (Object value : values) {
2446                                    qPos.add(value);
2447                            }
2448                    }
2449    
2450                    List<WikiNode> list = q.list();
2451    
2452                    if (list.size() == 2) {
2453                            return list.get(1);
2454                    }
2455                    else {
2456                            return null;
2457                    }
2458            }
2459    
2460            /**
2461             * Returns all the wiki nodes where companyId = &#63;.
2462             *
2463             * @param companyId the company ID
2464             * @return the matching wiki nodes
2465             * @throws SystemException if a system exception occurred
2466             */
2467            public List<WikiNode> findByCompanyId(long companyId)
2468                    throws SystemException {
2469                    return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
2470                            null);
2471            }
2472    
2473            /**
2474             * Returns a range of all the wiki nodes where companyId = &#63;.
2475             *
2476             * <p>
2477             * 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.
2478             * </p>
2479             *
2480             * @param companyId the company ID
2481             * @param start the lower bound of the range of wiki nodes
2482             * @param end the upper bound of the range of wiki nodes (not inclusive)
2483             * @return the range of matching wiki nodes
2484             * @throws SystemException if a system exception occurred
2485             */
2486            public List<WikiNode> findByCompanyId(long companyId, int start, int end)
2487                    throws SystemException {
2488                    return findByCompanyId(companyId, start, end, null);
2489            }
2490    
2491            /**
2492             * Returns an ordered range of all the wiki nodes where companyId = &#63;.
2493             *
2494             * <p>
2495             * 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.
2496             * </p>
2497             *
2498             * @param companyId the company ID
2499             * @param start the lower bound of the range of wiki nodes
2500             * @param end the upper bound of the range of wiki nodes (not inclusive)
2501             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2502             * @return the ordered range of matching wiki nodes
2503             * @throws SystemException if a system exception occurred
2504             */
2505            public List<WikiNode> findByCompanyId(long companyId, int start, int end,
2506                    OrderByComparator orderByComparator) throws SystemException {
2507                    FinderPath finderPath = null;
2508                    Object[] finderArgs = null;
2509    
2510                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2511                                    (orderByComparator == null)) {
2512                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID;
2513                            finderArgs = new Object[] { companyId };
2514                    }
2515                    else {
2516                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID;
2517                            finderArgs = new Object[] { companyId, start, end, orderByComparator };
2518                    }
2519    
2520                    List<WikiNode> list = (List<WikiNode>)FinderCacheUtil.getResult(finderPath,
2521                                    finderArgs, this);
2522    
2523                    if ((list != null) && !list.isEmpty()) {
2524                            for (WikiNode wikiNode : list) {
2525                                    if ((companyId != wikiNode.getCompanyId())) {
2526                                            list = null;
2527    
2528                                            break;
2529                                    }
2530                            }
2531                    }
2532    
2533                    if (list == null) {
2534                            StringBundler query = null;
2535    
2536                            if (orderByComparator != null) {
2537                                    query = new StringBundler(3 +
2538                                                    (orderByComparator.getOrderByFields().length * 3));
2539                            }
2540                            else {
2541                                    query = new StringBundler(3);
2542                            }
2543    
2544                            query.append(_SQL_SELECT_WIKINODE_WHERE);
2545    
2546                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2547    
2548                            if (orderByComparator != null) {
2549                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2550                                            orderByComparator);
2551                            }
2552    
2553                            else {
2554                                    query.append(WikiNodeModelImpl.ORDER_BY_JPQL);
2555                            }
2556    
2557                            String sql = query.toString();
2558    
2559                            Session session = null;
2560    
2561                            try {
2562                                    session = openSession();
2563    
2564                                    Query q = session.createQuery(sql);
2565    
2566                                    QueryPos qPos = QueryPos.getInstance(q);
2567    
2568                                    qPos.add(companyId);
2569    
2570                                    list = (List<WikiNode>)QueryUtil.list(q, getDialect(), start,
2571                                                    end);
2572                            }
2573                            catch (Exception e) {
2574                                    throw processException(e);
2575                            }
2576                            finally {
2577                                    if (list == null) {
2578                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
2579                                    }
2580                                    else {
2581                                            cacheResult(list);
2582    
2583                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
2584                                    }
2585    
2586                                    closeSession(session);
2587                            }
2588                    }
2589    
2590                    return list;
2591            }
2592    
2593            /**
2594             * Returns the first wiki node in the ordered set where companyId = &#63;.
2595             *
2596             * @param companyId the company ID
2597             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2598             * @return the first matching wiki node
2599             * @throws com.liferay.portlet.wiki.NoSuchNodeException if a matching wiki node could not be found
2600             * @throws SystemException if a system exception occurred
2601             */
2602            public WikiNode findByCompanyId_First(long companyId,
2603                    OrderByComparator orderByComparator)
2604                    throws NoSuchNodeException, SystemException {
2605                    WikiNode wikiNode = fetchByCompanyId_First(companyId, orderByComparator);
2606    
2607                    if (wikiNode != null) {
2608                            return wikiNode;
2609                    }
2610    
2611                    StringBundler msg = new StringBundler(4);
2612    
2613                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2614    
2615                    msg.append("companyId=");
2616                    msg.append(companyId);
2617    
2618                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2619    
2620                    throw new NoSuchNodeException(msg.toString());
2621            }
2622    
2623            /**
2624             * Returns the first wiki node in the ordered set where companyId = &#63;.
2625             *
2626             * @param companyId the company ID
2627             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2628             * @return the first matching wiki node, or <code>null</code> if a matching wiki node could not be found
2629             * @throws SystemException if a system exception occurred
2630             */
2631            public WikiNode fetchByCompanyId_First(long companyId,
2632                    OrderByComparator orderByComparator) throws SystemException {
2633                    List<WikiNode> list = findByCompanyId(companyId, 0, 1, orderByComparator);
2634    
2635                    if (!list.isEmpty()) {
2636                            return list.get(0);
2637                    }
2638    
2639                    return null;
2640            }
2641    
2642            /**
2643             * Returns the last wiki node in the ordered set where companyId = &#63;.
2644             *
2645             * @param companyId the company ID
2646             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2647             * @return the last matching wiki node
2648             * @throws com.liferay.portlet.wiki.NoSuchNodeException if a matching wiki node could not be found
2649             * @throws SystemException if a system exception occurred
2650             */
2651            public WikiNode findByCompanyId_Last(long companyId,
2652                    OrderByComparator orderByComparator)
2653                    throws NoSuchNodeException, SystemException {
2654                    WikiNode wikiNode = fetchByCompanyId_Last(companyId, orderByComparator);
2655    
2656                    if (wikiNode != null) {
2657                            return wikiNode;
2658                    }
2659    
2660                    StringBundler msg = new StringBundler(4);
2661    
2662                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2663    
2664                    msg.append("companyId=");
2665                    msg.append(companyId);
2666    
2667                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2668    
2669                    throw new NoSuchNodeException(msg.toString());
2670            }
2671    
2672            /**
2673             * Returns the last wiki node in the ordered set where companyId = &#63;.
2674             *
2675             * @param companyId the company ID
2676             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2677             * @return the last matching wiki node, or <code>null</code> if a matching wiki node could not be found
2678             * @throws SystemException if a system exception occurred
2679             */
2680            public WikiNode fetchByCompanyId_Last(long companyId,
2681                    OrderByComparator orderByComparator) throws SystemException {
2682                    int count = countByCompanyId(companyId);
2683    
2684                    List<WikiNode> list = findByCompanyId(companyId, count - 1, count,
2685                                    orderByComparator);
2686    
2687                    if (!list.isEmpty()) {
2688                            return list.get(0);
2689                    }
2690    
2691                    return null;
2692            }
2693    
2694            /**
2695             * Returns the wiki nodes before and after the current wiki node in the ordered set where companyId = &#63;.
2696             *
2697             * @param nodeId the primary key of the current wiki node
2698             * @param companyId the company ID
2699             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2700             * @return the previous, current, and next wiki node
2701             * @throws com.liferay.portlet.wiki.NoSuchNodeException if a wiki node with the primary key could not be found
2702             * @throws SystemException if a system exception occurred
2703             */
2704            public WikiNode[] findByCompanyId_PrevAndNext(long nodeId, long companyId,
2705                    OrderByComparator orderByComparator)
2706                    throws NoSuchNodeException, SystemException {
2707                    WikiNode wikiNode = findByPrimaryKey(nodeId);
2708    
2709                    Session session = null;
2710    
2711                    try {
2712                            session = openSession();
2713    
2714                            WikiNode[] array = new WikiNodeImpl[3];
2715    
2716                            array[0] = getByCompanyId_PrevAndNext(session, wikiNode, companyId,
2717                                            orderByComparator, true);
2718    
2719                            array[1] = wikiNode;
2720    
2721                            array[2] = getByCompanyId_PrevAndNext(session, wikiNode, companyId,
2722                                            orderByComparator, false);
2723    
2724                            return array;
2725                    }
2726                    catch (Exception e) {
2727                            throw processException(e);
2728                    }
2729                    finally {
2730                            closeSession(session);
2731                    }
2732            }
2733    
2734            protected WikiNode getByCompanyId_PrevAndNext(Session session,
2735                    WikiNode wikiNode, long companyId, OrderByComparator orderByComparator,
2736                    boolean previous) {
2737                    StringBundler query = null;
2738    
2739                    if (orderByComparator != null) {
2740                            query = new StringBundler(6 +
2741                                            (orderByComparator.getOrderByFields().length * 6));
2742                    }
2743                    else {
2744                            query = new StringBundler(3);
2745                    }
2746    
2747                    query.append(_SQL_SELECT_WIKINODE_WHERE);
2748    
2749                    query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2750    
2751                    if (orderByComparator != null) {
2752                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2753    
2754                            if (orderByConditionFields.length > 0) {
2755                                    query.append(WHERE_AND);
2756                            }
2757    
2758                            for (int i = 0; i < orderByConditionFields.length; i++) {
2759                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2760                                    query.append(orderByConditionFields[i]);
2761    
2762                                    if ((i + 1) < orderByConditionFields.length) {
2763                                            if (orderByComparator.isAscending() ^ previous) {
2764                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2765                                            }
2766                                            else {
2767                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2768                                            }
2769                                    }
2770                                    else {
2771                                            if (orderByComparator.isAscending() ^ previous) {
2772                                                    query.append(WHERE_GREATER_THAN);
2773                                            }
2774                                            else {
2775                                                    query.append(WHERE_LESSER_THAN);
2776                                            }
2777                                    }
2778                            }
2779    
2780                            query.append(ORDER_BY_CLAUSE);
2781    
2782                            String[] orderByFields = orderByComparator.getOrderByFields();
2783    
2784                            for (int i = 0; i < orderByFields.length; i++) {
2785                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2786                                    query.append(orderByFields[i]);
2787    
2788                                    if ((i + 1) < orderByFields.length) {
2789                                            if (orderByComparator.isAscending() ^ previous) {
2790                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2791                                            }
2792                                            else {
2793                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2794                                            }
2795                                    }
2796                                    else {
2797                                            if (orderByComparator.isAscending() ^ previous) {
2798                                                    query.append(ORDER_BY_ASC);
2799                                            }
2800                                            else {
2801                                                    query.append(ORDER_BY_DESC);
2802                                            }
2803                                    }
2804                            }
2805                    }
2806    
2807                    else {
2808                            query.append(WikiNodeModelImpl.ORDER_BY_JPQL);
2809                    }
2810    
2811                    String sql = query.toString();
2812    
2813                    Query q = session.createQuery(sql);
2814    
2815                    q.setFirstResult(0);
2816                    q.setMaxResults(2);
2817    
2818                    QueryPos qPos = QueryPos.getInstance(q);
2819    
2820                    qPos.add(companyId);
2821    
2822                    if (orderByComparator != null) {
2823                            Object[] values = orderByComparator.getOrderByConditionValues(wikiNode);
2824    
2825                            for (Object value : values) {
2826                                    qPos.add(value);
2827                            }
2828                    }
2829    
2830                    List<WikiNode> list = q.list();
2831    
2832                    if (list.size() == 2) {
2833                            return list.get(1);
2834                    }
2835                    else {
2836                            return null;
2837                    }
2838            }
2839    
2840            /**
2841             * Returns the wiki node where groupId = &#63; and name = &#63; or throws a {@link com.liferay.portlet.wiki.NoSuchNodeException} if it could not be found.
2842             *
2843             * @param groupId the group ID
2844             * @param name the name
2845             * @return the matching wiki node
2846             * @throws com.liferay.portlet.wiki.NoSuchNodeException if a matching wiki node could not be found
2847             * @throws SystemException if a system exception occurred
2848             */
2849            public WikiNode findByG_N(long groupId, String name)
2850                    throws NoSuchNodeException, SystemException {
2851                    WikiNode wikiNode = fetchByG_N(groupId, name);
2852    
2853                    if (wikiNode == null) {
2854                            StringBundler msg = new StringBundler(6);
2855    
2856                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2857    
2858                            msg.append("groupId=");
2859                            msg.append(groupId);
2860    
2861                            msg.append(", name=");
2862                            msg.append(name);
2863    
2864                            msg.append(StringPool.CLOSE_CURLY_BRACE);
2865    
2866                            if (_log.isWarnEnabled()) {
2867                                    _log.warn(msg.toString());
2868                            }
2869    
2870                            throw new NoSuchNodeException(msg.toString());
2871                    }
2872    
2873                    return wikiNode;
2874            }
2875    
2876            /**
2877             * Returns the wiki node where groupId = &#63; and name = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
2878             *
2879             * @param groupId the group ID
2880             * @param name the name
2881             * @return the matching wiki node, or <code>null</code> if a matching wiki node could not be found
2882             * @throws SystemException if a system exception occurred
2883             */
2884            public WikiNode fetchByG_N(long groupId, String name)
2885                    throws SystemException {
2886                    return fetchByG_N(groupId, name, true);
2887            }
2888    
2889            /**
2890             * Returns 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.
2891             *
2892             * @param groupId the group ID
2893             * @param name the name
2894             * @param retrieveFromCache whether to use the finder cache
2895             * @return the matching wiki node, or <code>null</code> if a matching wiki node could not be found
2896             * @throws SystemException if a system exception occurred
2897             */
2898            public WikiNode fetchByG_N(long groupId, String name,
2899                    boolean retrieveFromCache) throws SystemException {
2900                    Object[] finderArgs = new Object[] { groupId, name };
2901    
2902                    Object result = null;
2903    
2904                    if (retrieveFromCache) {
2905                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_N,
2906                                            finderArgs, this);
2907                    }
2908    
2909                    if (result instanceof WikiNode) {
2910                            WikiNode wikiNode = (WikiNode)result;
2911    
2912                            if ((groupId != wikiNode.getGroupId()) ||
2913                                            !Validator.equals(name, wikiNode.getName())) {
2914                                    result = null;
2915                            }
2916                    }
2917    
2918                    if (result == null) {
2919                            StringBundler query = new StringBundler(4);
2920    
2921                            query.append(_SQL_SELECT_WIKINODE_WHERE);
2922    
2923                            query.append(_FINDER_COLUMN_G_N_GROUPID_2);
2924    
2925                            if (name == null) {
2926                                    query.append(_FINDER_COLUMN_G_N_NAME_1);
2927                            }
2928                            else {
2929                                    if (name.equals(StringPool.BLANK)) {
2930                                            query.append(_FINDER_COLUMN_G_N_NAME_3);
2931                                    }
2932                                    else {
2933                                            query.append(_FINDER_COLUMN_G_N_NAME_2);
2934                                    }
2935                            }
2936    
2937                            query.append(WikiNodeModelImpl.ORDER_BY_JPQL);
2938    
2939                            String sql = query.toString();
2940    
2941                            Session session = null;
2942    
2943                            try {
2944                                    session = openSession();
2945    
2946                                    Query q = session.createQuery(sql);
2947    
2948                                    QueryPos qPos = QueryPos.getInstance(q);
2949    
2950                                    qPos.add(groupId);
2951    
2952                                    if (name != null) {
2953                                            qPos.add(name);
2954                                    }
2955    
2956                                    List<WikiNode> list = q.list();
2957    
2958                                    result = list;
2959    
2960                                    WikiNode wikiNode = null;
2961    
2962                                    if (list.isEmpty()) {
2963                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
2964                                                    finderArgs, list);
2965                                    }
2966                                    else {
2967                                            wikiNode = list.get(0);
2968    
2969                                            cacheResult(wikiNode);
2970    
2971                                            if ((wikiNode.getGroupId() != groupId) ||
2972                                                            (wikiNode.getName() == null) ||
2973                                                            !wikiNode.getName().equals(name)) {
2974                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
2975                                                            finderArgs, wikiNode);
2976                                            }
2977                                    }
2978    
2979                                    return wikiNode;
2980                            }
2981                            catch (Exception e) {
2982                                    throw processException(e);
2983                            }
2984                            finally {
2985                                    if (result == null) {
2986                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_N,
2987                                                    finderArgs);
2988                                    }
2989    
2990                                    closeSession(session);
2991                            }
2992                    }
2993                    else {
2994                            if (result instanceof List<?>) {
2995                                    return null;
2996                            }
2997                            else {
2998                                    return (WikiNode)result;
2999                            }
3000                    }
3001            }
3002    
3003            /**
3004             * Returns all the wiki nodes where groupId = &#63; and status = &#63;.
3005             *
3006             * @param groupId the group ID
3007             * @param status the status
3008             * @return the matching wiki nodes
3009             * @throws SystemException if a system exception occurred
3010             */
3011            public List<WikiNode> findByG_S(long groupId, int status)
3012                    throws SystemException {
3013                    return findByG_S(groupId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
3014                            null);
3015            }
3016    
3017            /**
3018             * Returns a range of all the wiki nodes where groupId = &#63; and status = &#63;.
3019             *
3020             * <p>
3021             * 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.
3022             * </p>
3023             *
3024             * @param groupId the group ID
3025             * @param status the status
3026             * @param start the lower bound of the range of wiki nodes
3027             * @param end the upper bound of the range of wiki nodes (not inclusive)
3028             * @return the range of matching wiki nodes
3029             * @throws SystemException if a system exception occurred
3030             */
3031            public List<WikiNode> findByG_S(long groupId, int status, int start, int end)
3032                    throws SystemException {
3033                    return findByG_S(groupId, status, start, end, null);
3034            }
3035    
3036            /**
3037             * Returns an ordered range of all the wiki nodes where groupId = &#63; and status = &#63;.
3038             *
3039             * <p>
3040             * 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.
3041             * </p>
3042             *
3043             * @param groupId the group ID
3044             * @param status the status
3045             * @param start the lower bound of the range of wiki nodes
3046             * @param end the upper bound of the range of wiki nodes (not inclusive)
3047             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3048             * @return the ordered range of matching wiki nodes
3049             * @throws SystemException if a system exception occurred
3050             */
3051            public List<WikiNode> findByG_S(long groupId, int status, int start,
3052                    int end, OrderByComparator orderByComparator) throws SystemException {
3053                    FinderPath finderPath = null;
3054                    Object[] finderArgs = null;
3055    
3056                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3057                                    (orderByComparator == null)) {
3058                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_S;
3059                            finderArgs = new Object[] { groupId, status };
3060                    }
3061                    else {
3062                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_S;
3063                            finderArgs = new Object[] {
3064                                            groupId, status,
3065                                            
3066                                            start, end, orderByComparator
3067                                    };
3068                    }
3069    
3070                    List<WikiNode> list = (List<WikiNode>)FinderCacheUtil.getResult(finderPath,
3071                                    finderArgs, this);
3072    
3073                    if ((list != null) && !list.isEmpty()) {
3074                            for (WikiNode wikiNode : list) {
3075                                    if ((groupId != wikiNode.getGroupId()) ||
3076                                                    (status != wikiNode.getStatus())) {
3077                                            list = null;
3078    
3079                                            break;
3080                                    }
3081                            }
3082                    }
3083    
3084                    if (list == null) {
3085                            StringBundler query = null;
3086    
3087                            if (orderByComparator != null) {
3088                                    query = new StringBundler(4 +
3089                                                    (orderByComparator.getOrderByFields().length * 3));
3090                            }
3091                            else {
3092                                    query = new StringBundler(4);
3093                            }
3094    
3095                            query.append(_SQL_SELECT_WIKINODE_WHERE);
3096    
3097                            query.append(_FINDER_COLUMN_G_S_GROUPID_2);
3098    
3099                            query.append(_FINDER_COLUMN_G_S_STATUS_2);
3100    
3101                            if (orderByComparator != null) {
3102                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3103                                            orderByComparator);
3104                            }
3105    
3106                            else {
3107                                    query.append(WikiNodeModelImpl.ORDER_BY_JPQL);
3108                            }
3109    
3110                            String sql = query.toString();
3111    
3112                            Session session = null;
3113    
3114                            try {
3115                                    session = openSession();
3116    
3117                                    Query q = session.createQuery(sql);
3118    
3119                                    QueryPos qPos = QueryPos.getInstance(q);
3120    
3121                                    qPos.add(groupId);
3122    
3123                                    qPos.add(status);
3124    
3125                                    list = (List<WikiNode>)QueryUtil.list(q, getDialect(), start,
3126                                                    end);
3127                            }
3128                            catch (Exception e) {
3129                                    throw processException(e);
3130                            }
3131                            finally {
3132                                    if (list == null) {
3133                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
3134                                    }
3135                                    else {
3136                                            cacheResult(list);
3137    
3138                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
3139                                    }
3140    
3141                                    closeSession(session);
3142                            }
3143                    }
3144    
3145                    return list;
3146            }
3147    
3148            /**
3149             * Returns the first wiki node in the ordered set where groupId = &#63; and status = &#63;.
3150             *
3151             * @param groupId the group ID
3152             * @param status the status
3153             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3154             * @return the first matching wiki node
3155             * @throws com.liferay.portlet.wiki.NoSuchNodeException if a matching wiki node could not be found
3156             * @throws SystemException if a system exception occurred
3157             */
3158            public WikiNode findByG_S_First(long groupId, int status,
3159                    OrderByComparator orderByComparator)
3160                    throws NoSuchNodeException, SystemException {
3161                    WikiNode wikiNode = fetchByG_S_First(groupId, status, orderByComparator);
3162    
3163                    if (wikiNode != null) {
3164                            return wikiNode;
3165                    }
3166    
3167                    StringBundler msg = new StringBundler(6);
3168    
3169                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3170    
3171                    msg.append("groupId=");
3172                    msg.append(groupId);
3173    
3174                    msg.append(", status=");
3175                    msg.append(status);
3176    
3177                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3178    
3179                    throw new NoSuchNodeException(msg.toString());
3180            }
3181    
3182            /**
3183             * Returns the first wiki node in the ordered set where groupId = &#63; and status = &#63;.
3184             *
3185             * @param groupId the group ID
3186             * @param status the status
3187             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3188             * @return the first matching wiki node, or <code>null</code> if a matching wiki node could not be found
3189             * @throws SystemException if a system exception occurred
3190             */
3191            public WikiNode fetchByG_S_First(long groupId, int status,
3192                    OrderByComparator orderByComparator) throws SystemException {
3193                    List<WikiNode> list = findByG_S(groupId, status, 0, 1, orderByComparator);
3194    
3195                    if (!list.isEmpty()) {
3196                            return list.get(0);
3197                    }
3198    
3199                    return null;
3200            }
3201    
3202            /**
3203             * Returns the last wiki node in the ordered set where groupId = &#63; and status = &#63;.
3204             *
3205             * @param groupId the group ID
3206             * @param status the status
3207             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3208             * @return the last matching wiki node
3209             * @throws com.liferay.portlet.wiki.NoSuchNodeException if a matching wiki node could not be found
3210             * @throws SystemException if a system exception occurred
3211             */
3212            public WikiNode findByG_S_Last(long groupId, int status,
3213                    OrderByComparator orderByComparator)
3214                    throws NoSuchNodeException, SystemException {
3215                    WikiNode wikiNode = fetchByG_S_Last(groupId, status, orderByComparator);
3216    
3217                    if (wikiNode != null) {
3218                            return wikiNode;
3219                    }
3220    
3221                    StringBundler msg = new StringBundler(6);
3222    
3223                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3224    
3225                    msg.append("groupId=");
3226                    msg.append(groupId);
3227    
3228                    msg.append(", status=");
3229                    msg.append(status);
3230    
3231                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3232    
3233                    throw new NoSuchNodeException(msg.toString());
3234            }
3235    
3236            /**
3237             * Returns the last wiki node in the ordered set where groupId = &#63; and status = &#63;.
3238             *
3239             * @param groupId the group ID
3240             * @param status the status
3241             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3242             * @return the last matching wiki node, or <code>null</code> if a matching wiki node could not be found
3243             * @throws SystemException if a system exception occurred
3244             */
3245            public WikiNode fetchByG_S_Last(long groupId, int status,
3246                    OrderByComparator orderByComparator) throws SystemException {
3247                    int count = countByG_S(groupId, status);
3248    
3249                    List<WikiNode> list = findByG_S(groupId, status, count - 1, count,
3250                                    orderByComparator);
3251    
3252                    if (!list.isEmpty()) {
3253                            return list.get(0);
3254                    }
3255    
3256                    return null;
3257            }
3258    
3259            /**
3260             * Returns the wiki nodes before and after the current wiki node in the ordered set where groupId = &#63; and status = &#63;.
3261             *
3262             * @param nodeId the primary key of the current wiki node
3263             * @param groupId the group ID
3264             * @param status the status
3265             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3266             * @return the previous, current, and next wiki node
3267             * @throws com.liferay.portlet.wiki.NoSuchNodeException if a wiki node with the primary key could not be found
3268             * @throws SystemException if a system exception occurred
3269             */
3270            public WikiNode[] findByG_S_PrevAndNext(long nodeId, long groupId,
3271                    int status, OrderByComparator orderByComparator)
3272                    throws NoSuchNodeException, SystemException {
3273                    WikiNode wikiNode = findByPrimaryKey(nodeId);
3274    
3275                    Session session = null;
3276    
3277                    try {
3278                            session = openSession();
3279    
3280                            WikiNode[] array = new WikiNodeImpl[3];
3281    
3282                            array[0] = getByG_S_PrevAndNext(session, wikiNode, groupId, status,
3283                                            orderByComparator, true);
3284    
3285                            array[1] = wikiNode;
3286    
3287                            array[2] = getByG_S_PrevAndNext(session, wikiNode, groupId, status,
3288                                            orderByComparator, false);
3289    
3290                            return array;
3291                    }
3292                    catch (Exception e) {
3293                            throw processException(e);
3294                    }
3295                    finally {
3296                            closeSession(session);
3297                    }
3298            }
3299    
3300            protected WikiNode getByG_S_PrevAndNext(Session session, WikiNode wikiNode,
3301                    long groupId, int status, OrderByComparator orderByComparator,
3302                    boolean previous) {
3303                    StringBundler query = null;
3304    
3305                    if (orderByComparator != null) {
3306                            query = new StringBundler(6 +
3307                                            (orderByComparator.getOrderByFields().length * 6));
3308                    }
3309                    else {
3310                            query = new StringBundler(3);
3311                    }
3312    
3313                    query.append(_SQL_SELECT_WIKINODE_WHERE);
3314    
3315                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
3316    
3317                    query.append(_FINDER_COLUMN_G_S_STATUS_2);
3318    
3319                    if (orderByComparator != null) {
3320                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3321    
3322                            if (orderByConditionFields.length > 0) {
3323                                    query.append(WHERE_AND);
3324                            }
3325    
3326                            for (int i = 0; i < orderByConditionFields.length; i++) {
3327                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3328                                    query.append(orderByConditionFields[i]);
3329    
3330                                    if ((i + 1) < orderByConditionFields.length) {
3331                                            if (orderByComparator.isAscending() ^ previous) {
3332                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3333                                            }
3334                                            else {
3335                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3336                                            }
3337                                    }
3338                                    else {
3339                                            if (orderByComparator.isAscending() ^ previous) {
3340                                                    query.append(WHERE_GREATER_THAN);
3341                                            }
3342                                            else {
3343                                                    query.append(WHERE_LESSER_THAN);
3344                                            }
3345                                    }
3346                            }
3347    
3348                            query.append(ORDER_BY_CLAUSE);
3349    
3350                            String[] orderByFields = orderByComparator.getOrderByFields();
3351    
3352                            for (int i = 0; i < orderByFields.length; i++) {
3353                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3354                                    query.append(orderByFields[i]);
3355    
3356                                    if ((i + 1) < orderByFields.length) {
3357                                            if (orderByComparator.isAscending() ^ previous) {
3358                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3359                                            }
3360                                            else {
3361                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3362                                            }
3363                                    }
3364                                    else {
3365                                            if (orderByComparator.isAscending() ^ previous) {
3366                                                    query.append(ORDER_BY_ASC);
3367                                            }
3368                                            else {
3369                                                    query.append(ORDER_BY_DESC);
3370                                            }
3371                                    }
3372                            }
3373                    }
3374    
3375                    else {
3376                            query.append(WikiNodeModelImpl.ORDER_BY_JPQL);
3377                    }
3378    
3379                    String sql = query.toString();
3380    
3381                    Query q = session.createQuery(sql);
3382    
3383                    q.setFirstResult(0);
3384                    q.setMaxResults(2);
3385    
3386                    QueryPos qPos = QueryPos.getInstance(q);
3387    
3388                    qPos.add(groupId);
3389    
3390                    qPos.add(status);
3391    
3392                    if (orderByComparator != null) {
3393                            Object[] values = orderByComparator.getOrderByConditionValues(wikiNode);
3394    
3395                            for (Object value : values) {
3396                                    qPos.add(value);
3397                            }
3398                    }
3399    
3400                    List<WikiNode> list = q.list();
3401    
3402                    if (list.size() == 2) {
3403                            return list.get(1);
3404                    }
3405                    else {
3406                            return null;
3407                    }
3408            }
3409    
3410            /**
3411             * Returns all the wiki nodes that the user has permission to view where groupId = &#63; and status = &#63;.
3412             *
3413             * @param groupId the group ID
3414             * @param status the status
3415             * @return the matching wiki nodes that the user has permission to view
3416             * @throws SystemException if a system exception occurred
3417             */
3418            public List<WikiNode> filterFindByG_S(long groupId, int status)
3419                    throws SystemException {
3420                    return filterFindByG_S(groupId, status, QueryUtil.ALL_POS,
3421                            QueryUtil.ALL_POS, null);
3422            }
3423    
3424            /**
3425             * Returns a range of all the wiki nodes that the user has permission to view where groupId = &#63; and status = &#63;.
3426             *
3427             * <p>
3428             * 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.
3429             * </p>
3430             *
3431             * @param groupId the group ID
3432             * @param status the status
3433             * @param start the lower bound of the range of wiki nodes
3434             * @param end the upper bound of the range of wiki nodes (not inclusive)
3435             * @return the range of matching wiki nodes that the user has permission to view
3436             * @throws SystemException if a system exception occurred
3437             */
3438            public List<WikiNode> filterFindByG_S(long groupId, int status, int start,
3439                    int end) throws SystemException {
3440                    return filterFindByG_S(groupId, status, start, end, null);
3441            }
3442    
3443            /**
3444             * Returns an ordered range of all the wiki nodes that the user has permissions to view where groupId = &#63; and status = &#63;.
3445             *
3446             * <p>
3447             * 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.
3448             * </p>
3449             *
3450             * @param groupId the group ID
3451             * @param status the status
3452             * @param start the lower bound of the range of wiki nodes
3453             * @param end the upper bound of the range of wiki nodes (not inclusive)
3454             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3455             * @return the ordered range of matching wiki nodes that the user has permission to view
3456             * @throws SystemException if a system exception occurred
3457             */
3458            public List<WikiNode> filterFindByG_S(long groupId, int status, int start,
3459                    int end, OrderByComparator orderByComparator) throws SystemException {
3460                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3461                            return findByG_S(groupId, status, start, end, orderByComparator);
3462                    }
3463    
3464                    StringBundler query = null;
3465    
3466                    if (orderByComparator != null) {
3467                            query = new StringBundler(4 +
3468                                            (orderByComparator.getOrderByFields().length * 3));
3469                    }
3470                    else {
3471                            query = new StringBundler(4);
3472                    }
3473    
3474                    if (getDB().isSupportsInlineDistinct()) {
3475                            query.append(_FILTER_SQL_SELECT_WIKINODE_WHERE);
3476                    }
3477                    else {
3478                            query.append(_FILTER_SQL_SELECT_WIKINODE_NO_INLINE_DISTINCT_WHERE_1);
3479                    }
3480    
3481                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
3482    
3483                    query.append(_FINDER_COLUMN_G_S_STATUS_2);
3484    
3485                    if (!getDB().isSupportsInlineDistinct()) {
3486                            query.append(_FILTER_SQL_SELECT_WIKINODE_NO_INLINE_DISTINCT_WHERE_2);
3487                    }
3488    
3489                    if (orderByComparator != null) {
3490                            if (getDB().isSupportsInlineDistinct()) {
3491                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3492                                            orderByComparator);
3493                            }
3494                            else {
3495                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
3496                                            orderByComparator);
3497                            }
3498                    }
3499    
3500                    else {
3501                            if (getDB().isSupportsInlineDistinct()) {
3502                                    query.append(WikiNodeModelImpl.ORDER_BY_JPQL);
3503                            }
3504                            else {
3505                                    query.append(WikiNodeModelImpl.ORDER_BY_SQL);
3506                            }
3507                    }
3508    
3509                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3510                                    WikiNode.class.getName(),
3511                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3512    
3513                    Session session = null;
3514    
3515                    try {
3516                            session = openSession();
3517    
3518                            SQLQuery q = session.createSQLQuery(sql);
3519    
3520                            if (getDB().isSupportsInlineDistinct()) {
3521                                    q.addEntity(_FILTER_ENTITY_ALIAS, WikiNodeImpl.class);
3522                            }
3523                            else {
3524                                    q.addEntity(_FILTER_ENTITY_TABLE, WikiNodeImpl.class);
3525                            }
3526    
3527                            QueryPos qPos = QueryPos.getInstance(q);
3528    
3529                            qPos.add(groupId);
3530    
3531                            qPos.add(status);
3532    
3533                            return (List<WikiNode>)QueryUtil.list(q, getDialect(), start, end);
3534                    }
3535                    catch (Exception e) {
3536                            throw processException(e);
3537                    }
3538                    finally {
3539                            closeSession(session);
3540                    }
3541            }
3542    
3543            /**
3544             * Returns the wiki nodes before and after the current wiki node in the ordered set of wiki nodes that the user has permission to view where groupId = &#63; and status = &#63;.
3545             *
3546             * @param nodeId the primary key of the current wiki node
3547             * @param groupId the group ID
3548             * @param status the status
3549             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3550             * @return the previous, current, and next wiki node
3551             * @throws com.liferay.portlet.wiki.NoSuchNodeException if a wiki node with the primary key could not be found
3552             * @throws SystemException if a system exception occurred
3553             */
3554            public WikiNode[] filterFindByG_S_PrevAndNext(long nodeId, long groupId,
3555                    int status, OrderByComparator orderByComparator)
3556                    throws NoSuchNodeException, SystemException {
3557                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3558                            return findByG_S_PrevAndNext(nodeId, groupId, status,
3559                                    orderByComparator);
3560                    }
3561    
3562                    WikiNode wikiNode = findByPrimaryKey(nodeId);
3563    
3564                    Session session = null;
3565    
3566                    try {
3567                            session = openSession();
3568    
3569                            WikiNode[] array = new WikiNodeImpl[3];
3570    
3571                            array[0] = filterGetByG_S_PrevAndNext(session, wikiNode, groupId,
3572                                            status, orderByComparator, true);
3573    
3574                            array[1] = wikiNode;
3575    
3576                            array[2] = filterGetByG_S_PrevAndNext(session, wikiNode, groupId,
3577                                            status, orderByComparator, false);
3578    
3579                            return array;
3580                    }
3581                    catch (Exception e) {
3582                            throw processException(e);
3583                    }
3584                    finally {
3585                            closeSession(session);
3586                    }
3587            }
3588    
3589            protected WikiNode filterGetByG_S_PrevAndNext(Session session,
3590                    WikiNode wikiNode, long groupId, int status,
3591                    OrderByComparator orderByComparator, boolean previous) {
3592                    StringBundler query = null;
3593    
3594                    if (orderByComparator != null) {
3595                            query = new StringBundler(6 +
3596                                            (orderByComparator.getOrderByFields().length * 6));
3597                    }
3598                    else {
3599                            query = new StringBundler(3);
3600                    }
3601    
3602                    if (getDB().isSupportsInlineDistinct()) {
3603                            query.append(_FILTER_SQL_SELECT_WIKINODE_WHERE);
3604                    }
3605                    else {
3606                            query.append(_FILTER_SQL_SELECT_WIKINODE_NO_INLINE_DISTINCT_WHERE_1);
3607                    }
3608    
3609                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
3610    
3611                    query.append(_FINDER_COLUMN_G_S_STATUS_2);
3612    
3613                    if (!getDB().isSupportsInlineDistinct()) {
3614                            query.append(_FILTER_SQL_SELECT_WIKINODE_NO_INLINE_DISTINCT_WHERE_2);
3615                    }
3616    
3617                    if (orderByComparator != null) {
3618                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3619    
3620                            if (orderByConditionFields.length > 0) {
3621                                    query.append(WHERE_AND);
3622                            }
3623    
3624                            for (int i = 0; i < orderByConditionFields.length; i++) {
3625                                    if (getDB().isSupportsInlineDistinct()) {
3626                                            query.append(_ORDER_BY_ENTITY_ALIAS);
3627                                    }
3628                                    else {
3629                                            query.append(_ORDER_BY_ENTITY_TABLE);
3630                                    }
3631    
3632                                    query.append(orderByConditionFields[i]);
3633    
3634                                    if ((i + 1) < orderByConditionFields.length) {
3635                                            if (orderByComparator.isAscending() ^ previous) {
3636                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3637                                            }
3638                                            else {
3639                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3640                                            }
3641                                    }
3642                                    else {
3643                                            if (orderByComparator.isAscending() ^ previous) {
3644                                                    query.append(WHERE_GREATER_THAN);
3645                                            }
3646                                            else {
3647                                                    query.append(WHERE_LESSER_THAN);
3648                                            }
3649                                    }
3650                            }
3651    
3652                            query.append(ORDER_BY_CLAUSE);
3653    
3654                            String[] orderByFields = orderByComparator.getOrderByFields();
3655    
3656                            for (int i = 0; i < orderByFields.length; i++) {
3657                                    if (getDB().isSupportsInlineDistinct()) {
3658                                            query.append(_ORDER_BY_ENTITY_ALIAS);
3659                                    }
3660                                    else {
3661                                            query.append(_ORDER_BY_ENTITY_TABLE);
3662                                    }
3663    
3664                                    query.append(orderByFields[i]);
3665    
3666                                    if ((i + 1) < orderByFields.length) {
3667                                            if (orderByComparator.isAscending() ^ previous) {
3668                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3669                                            }
3670                                            else {
3671                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3672                                            }
3673                                    }
3674                                    else {
3675                                            if (orderByComparator.isAscending() ^ previous) {
3676                                                    query.append(ORDER_BY_ASC);
3677                                            }
3678                                            else {
3679                                                    query.append(ORDER_BY_DESC);
3680                                            }
3681                                    }
3682                            }
3683                    }
3684    
3685                    else {
3686                            if (getDB().isSupportsInlineDistinct()) {
3687                                    query.append(WikiNodeModelImpl.ORDER_BY_JPQL);
3688                            }
3689                            else {
3690                                    query.append(WikiNodeModelImpl.ORDER_BY_SQL);
3691                            }
3692                    }
3693    
3694                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3695                                    WikiNode.class.getName(),
3696                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3697    
3698                    SQLQuery q = session.createSQLQuery(sql);
3699    
3700                    q.setFirstResult(0);
3701                    q.setMaxResults(2);
3702    
3703                    if (getDB().isSupportsInlineDistinct()) {
3704                            q.addEntity(_FILTER_ENTITY_ALIAS, WikiNodeImpl.class);
3705                    }
3706                    else {
3707                            q.addEntity(_FILTER_ENTITY_TABLE, WikiNodeImpl.class);
3708                    }
3709    
3710                    QueryPos qPos = QueryPos.getInstance(q);
3711    
3712                    qPos.add(groupId);
3713    
3714                    qPos.add(status);
3715    
3716                    if (orderByComparator != null) {
3717                            Object[] values = orderByComparator.getOrderByConditionValues(wikiNode);
3718    
3719                            for (Object value : values) {
3720                                    qPos.add(value);
3721                            }
3722                    }
3723    
3724                    List<WikiNode> list = q.list();
3725    
3726                    if (list.size() == 2) {
3727                            return list.get(1);
3728                    }
3729                    else {
3730                            return null;
3731                    }
3732            }
3733    
3734            /**
3735             * Returns all the wiki nodes where companyId = &#63; and status = &#63;.
3736             *
3737             * @param companyId the company ID
3738             * @param status the status
3739             * @return the matching wiki nodes
3740             * @throws SystemException if a system exception occurred
3741             */
3742            public List<WikiNode> findByC_S(long companyId, int status)
3743                    throws SystemException {
3744                    return findByC_S(companyId, status, QueryUtil.ALL_POS,
3745                            QueryUtil.ALL_POS, null);
3746            }
3747    
3748            /**
3749             * Returns a range of all the wiki nodes where companyId = &#63; and status = &#63;.
3750             *
3751             * <p>
3752             * 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.
3753             * </p>
3754             *
3755             * @param companyId the company ID
3756             * @param status the status
3757             * @param start the lower bound of the range of wiki nodes
3758             * @param end the upper bound of the range of wiki nodes (not inclusive)
3759             * @return the range of matching wiki nodes
3760             * @throws SystemException if a system exception occurred
3761             */
3762            public List<WikiNode> findByC_S(long companyId, int status, int start,
3763                    int end) throws SystemException {
3764                    return findByC_S(companyId, status, start, end, null);
3765            }
3766    
3767            /**
3768             * Returns an ordered range of all the wiki nodes where companyId = &#63; and status = &#63;.
3769             *
3770             * <p>
3771             * 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.
3772             * </p>
3773             *
3774             * @param companyId the company ID
3775             * @param status the status
3776             * @param start the lower bound of the range of wiki nodes
3777             * @param end the upper bound of the range of wiki nodes (not inclusive)
3778             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3779             * @return the ordered range of matching wiki nodes
3780             * @throws SystemException if a system exception occurred
3781             */
3782            public List<WikiNode> findByC_S(long companyId, int status, int start,
3783                    int end, OrderByComparator orderByComparator) throws SystemException {
3784                    FinderPath finderPath = null;
3785                    Object[] finderArgs = null;
3786    
3787                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3788                                    (orderByComparator == null)) {
3789                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S;
3790                            finderArgs = new Object[] { companyId, status };
3791                    }
3792                    else {
3793                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_S;
3794                            finderArgs = new Object[] {
3795                                            companyId, status,
3796                                            
3797                                            start, end, orderByComparator
3798                                    };
3799                    }
3800    
3801                    List<WikiNode> list = (List<WikiNode>)FinderCacheUtil.getResult(finderPath,
3802                                    finderArgs, this);
3803    
3804                    if ((list != null) && !list.isEmpty()) {
3805                            for (WikiNode wikiNode : list) {
3806                                    if ((companyId != wikiNode.getCompanyId()) ||
3807                                                    (status != wikiNode.getStatus())) {
3808                                            list = null;
3809    
3810                                            break;
3811                                    }
3812                            }
3813                    }
3814    
3815                    if (list == null) {
3816                            StringBundler query = null;
3817    
3818                            if (orderByComparator != null) {
3819                                    query = new StringBundler(4 +
3820                                                    (orderByComparator.getOrderByFields().length * 3));
3821                            }
3822                            else {
3823                                    query = new StringBundler(4);
3824                            }
3825    
3826                            query.append(_SQL_SELECT_WIKINODE_WHERE);
3827    
3828                            query.append(_FINDER_COLUMN_C_S_COMPANYID_2);
3829    
3830                            query.append(_FINDER_COLUMN_C_S_STATUS_2);
3831    
3832                            if (orderByComparator != null) {
3833                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3834                                            orderByComparator);
3835                            }
3836    
3837                            else {
3838                                    query.append(WikiNodeModelImpl.ORDER_BY_JPQL);
3839                            }
3840    
3841                            String sql = query.toString();
3842    
3843                            Session session = null;
3844    
3845                            try {
3846                                    session = openSession();
3847    
3848                                    Query q = session.createQuery(sql);
3849    
3850                                    QueryPos qPos = QueryPos.getInstance(q);
3851    
3852                                    qPos.add(companyId);
3853    
3854                                    qPos.add(status);
3855    
3856                                    list = (List<WikiNode>)QueryUtil.list(q, getDialect(), start,
3857                                                    end);
3858                            }
3859                            catch (Exception e) {
3860                                    throw processException(e);
3861                            }
3862                            finally {
3863                                    if (list == null) {
3864                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
3865                                    }
3866                                    else {
3867                                            cacheResult(list);
3868    
3869                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
3870                                    }
3871    
3872                                    closeSession(session);
3873                            }
3874                    }
3875    
3876                    return list;
3877            }
3878    
3879            /**
3880             * Returns the first wiki node in the ordered set where companyId = &#63; and status = &#63;.
3881             *
3882             * @param companyId the company ID
3883             * @param status the status
3884             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3885             * @return the first matching wiki node
3886             * @throws com.liferay.portlet.wiki.NoSuchNodeException if a matching wiki node could not be found
3887             * @throws SystemException if a system exception occurred
3888             */
3889            public WikiNode findByC_S_First(long companyId, int status,
3890                    OrderByComparator orderByComparator)
3891                    throws NoSuchNodeException, SystemException {
3892                    WikiNode wikiNode = fetchByC_S_First(companyId, status,
3893                                    orderByComparator);
3894    
3895                    if (wikiNode != null) {
3896                            return wikiNode;
3897                    }
3898    
3899                    StringBundler msg = new StringBundler(6);
3900    
3901                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3902    
3903                    msg.append("companyId=");
3904                    msg.append(companyId);
3905    
3906                    msg.append(", status=");
3907                    msg.append(status);
3908    
3909                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3910    
3911                    throw new NoSuchNodeException(msg.toString());
3912            }
3913    
3914            /**
3915             * Returns the first wiki node in the ordered set where companyId = &#63; and status = &#63;.
3916             *
3917             * @param companyId the company ID
3918             * @param status the status
3919             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3920             * @return the first matching wiki node, or <code>null</code> if a matching wiki node could not be found
3921             * @throws SystemException if a system exception occurred
3922             */
3923            public WikiNode fetchByC_S_First(long companyId, int status,
3924                    OrderByComparator orderByComparator) throws SystemException {
3925                    List<WikiNode> list = findByC_S(companyId, status, 0, 1,
3926                                    orderByComparator);
3927    
3928                    if (!list.isEmpty()) {
3929                            return list.get(0);
3930                    }
3931    
3932                    return null;
3933            }
3934    
3935            /**
3936             * Returns the last wiki node in the ordered set where companyId = &#63; and status = &#63;.
3937             *
3938             * @param companyId the company ID
3939             * @param status the status
3940             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3941             * @return the last matching wiki node
3942             * @throws com.liferay.portlet.wiki.NoSuchNodeException if a matching wiki node could not be found
3943             * @throws SystemException if a system exception occurred
3944             */
3945            public WikiNode findByC_S_Last(long companyId, int status,
3946                    OrderByComparator orderByComparator)
3947                    throws NoSuchNodeException, SystemException {
3948                    WikiNode wikiNode = fetchByC_S_Last(companyId, status, orderByComparator);
3949    
3950                    if (wikiNode != null) {
3951                            return wikiNode;
3952                    }
3953    
3954                    StringBundler msg = new StringBundler(6);
3955    
3956                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3957    
3958                    msg.append("companyId=");
3959                    msg.append(companyId);
3960    
3961                    msg.append(", status=");
3962                    msg.append(status);
3963    
3964                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3965    
3966                    throw new NoSuchNodeException(msg.toString());
3967            }
3968    
3969            /**
3970             * Returns the last wiki node in the ordered set where companyId = &#63; and status = &#63;.
3971             *
3972             * @param companyId the company ID
3973             * @param status the status
3974             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3975             * @return the last matching wiki node, or <code>null</code> if a matching wiki node could not be found
3976             * @throws SystemException if a system exception occurred
3977             */
3978            public WikiNode fetchByC_S_Last(long companyId, int status,
3979                    OrderByComparator orderByComparator) throws SystemException {
3980                    int count = countByC_S(companyId, status);
3981    
3982                    List<WikiNode> list = findByC_S(companyId, status, count - 1, count,
3983                                    orderByComparator);
3984    
3985                    if (!list.isEmpty()) {
3986                            return list.get(0);
3987                    }
3988    
3989                    return null;
3990            }
3991    
3992            /**
3993             * Returns the wiki nodes before and after the current wiki node in the ordered set where companyId = &#63; and status = &#63;.
3994             *
3995             * @param nodeId the primary key of the current wiki node
3996             * @param companyId the company ID
3997             * @param status the status
3998             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3999             * @return the previous, current, and next wiki node
4000             * @throws com.liferay.portlet.wiki.NoSuchNodeException if a wiki node with the primary key could not be found
4001             * @throws SystemException if a system exception occurred
4002             */
4003            public WikiNode[] findByC_S_PrevAndNext(long nodeId, long companyId,
4004                    int status, OrderByComparator orderByComparator)
4005                    throws NoSuchNodeException, SystemException {
4006                    WikiNode wikiNode = findByPrimaryKey(nodeId);
4007    
4008                    Session session = null;
4009    
4010                    try {
4011                            session = openSession();
4012    
4013                            WikiNode[] array = new WikiNodeImpl[3];
4014    
4015                            array[0] = getByC_S_PrevAndNext(session, wikiNode, companyId,
4016                                            status, orderByComparator, true);
4017    
4018                            array[1] = wikiNode;
4019    
4020                            array[2] = getByC_S_PrevAndNext(session, wikiNode, companyId,
4021                                            status, orderByComparator, false);
4022    
4023                            return array;
4024                    }
4025                    catch (Exception e) {
4026                            throw processException(e);
4027                    }
4028                    finally {
4029                            closeSession(session);
4030                    }
4031            }
4032    
4033            protected WikiNode getByC_S_PrevAndNext(Session session, WikiNode wikiNode,
4034                    long companyId, int status, OrderByComparator orderByComparator,
4035                    boolean previous) {
4036                    StringBundler query = null;
4037    
4038                    if (orderByComparator != null) {
4039                            query = new StringBundler(6 +
4040                                            (orderByComparator.getOrderByFields().length * 6));
4041                    }
4042                    else {
4043                            query = new StringBundler(3);
4044                    }
4045    
4046                    query.append(_SQL_SELECT_WIKINODE_WHERE);
4047    
4048                    query.append(_FINDER_COLUMN_C_S_COMPANYID_2);
4049    
4050                    query.append(_FINDER_COLUMN_C_S_STATUS_2);
4051    
4052                    if (orderByComparator != null) {
4053                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4054    
4055                            if (orderByConditionFields.length > 0) {
4056                                    query.append(WHERE_AND);
4057                            }
4058    
4059                            for (int i = 0; i < orderByConditionFields.length; i++) {
4060                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4061                                    query.append(orderByConditionFields[i]);
4062    
4063                                    if ((i + 1) < orderByConditionFields.length) {
4064                                            if (orderByComparator.isAscending() ^ previous) {
4065                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
4066                                            }
4067                                            else {
4068                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
4069                                            }
4070                                    }
4071                                    else {
4072                                            if (orderByComparator.isAscending() ^ previous) {
4073                                                    query.append(WHERE_GREATER_THAN);
4074                                            }
4075                                            else {
4076                                                    query.append(WHERE_LESSER_THAN);
4077                                            }
4078                                    }
4079                            }
4080    
4081                            query.append(ORDER_BY_CLAUSE);
4082    
4083                            String[] orderByFields = orderByComparator.getOrderByFields();
4084    
4085                            for (int i = 0; i < orderByFields.length; i++) {
4086                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4087                                    query.append(orderByFields[i]);
4088    
4089                                    if ((i + 1) < orderByFields.length) {
4090                                            if (orderByComparator.isAscending() ^ previous) {
4091                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
4092                                            }
4093                                            else {
4094                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
4095                                            }
4096                                    }
4097                                    else {
4098                                            if (orderByComparator.isAscending() ^ previous) {
4099                                                    query.append(ORDER_BY_ASC);
4100                                            }
4101                                            else {
4102                                                    query.append(ORDER_BY_DESC);
4103                                            }
4104                                    }
4105                            }
4106                    }
4107    
4108                    else {
4109                            query.append(WikiNodeModelImpl.ORDER_BY_JPQL);
4110                    }
4111    
4112                    String sql = query.toString();
4113    
4114                    Query q = session.createQuery(sql);
4115    
4116                    q.setFirstResult(0);
4117                    q.setMaxResults(2);
4118    
4119                    QueryPos qPos = QueryPos.getInstance(q);
4120    
4121                    qPos.add(companyId);
4122    
4123                    qPos.add(status);
4124    
4125                    if (orderByComparator != null) {
4126                            Object[] values = orderByComparator.getOrderByConditionValues(wikiNode);
4127    
4128                            for (Object value : values) {
4129                                    qPos.add(value);
4130                            }
4131                    }
4132    
4133                    List<WikiNode> list = q.list();
4134    
4135                    if (list.size() == 2) {
4136                            return list.get(1);
4137                    }
4138                    else {
4139                            return null;
4140                    }
4141            }
4142    
4143            /**
4144             * Returns all the wiki nodes.
4145             *
4146             * @return the wiki nodes
4147             * @throws SystemException if a system exception occurred
4148             */
4149            public List<WikiNode> findAll() throws SystemException {
4150                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
4151            }
4152    
4153            /**
4154             * Returns a range of all the wiki nodes.
4155             *
4156             * <p>
4157             * 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.
4158             * </p>
4159             *
4160             * @param start the lower bound of the range of wiki nodes
4161             * @param end the upper bound of the range of wiki nodes (not inclusive)
4162             * @return the range of wiki nodes
4163             * @throws SystemException if a system exception occurred
4164             */
4165            public List<WikiNode> findAll(int start, int end) throws SystemException {
4166                    return findAll(start, end, null);
4167            }
4168    
4169            /**
4170             * Returns an ordered range of all the wiki nodes.
4171             *
4172             * <p>
4173             * 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.
4174             * </p>
4175             *
4176             * @param start the lower bound of the range of wiki nodes
4177             * @param end the upper bound of the range of wiki nodes (not inclusive)
4178             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4179             * @return the ordered range of wiki nodes
4180             * @throws SystemException if a system exception occurred
4181             */
4182            public List<WikiNode> findAll(int start, int end,
4183                    OrderByComparator orderByComparator) throws SystemException {
4184                    FinderPath finderPath = null;
4185                    Object[] finderArgs = new Object[] { start, end, orderByComparator };
4186    
4187                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4188                                    (orderByComparator == null)) {
4189                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
4190                            finderArgs = FINDER_ARGS_EMPTY;
4191                    }
4192                    else {
4193                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
4194                            finderArgs = new Object[] { start, end, orderByComparator };
4195                    }
4196    
4197                    List<WikiNode> list = (List<WikiNode>)FinderCacheUtil.getResult(finderPath,
4198                                    finderArgs, this);
4199    
4200                    if (list == null) {
4201                            StringBundler query = null;
4202                            String sql = null;
4203    
4204                            if (orderByComparator != null) {
4205                                    query = new StringBundler(2 +
4206                                                    (orderByComparator.getOrderByFields().length * 3));
4207    
4208                                    query.append(_SQL_SELECT_WIKINODE);
4209    
4210                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4211                                            orderByComparator);
4212    
4213                                    sql = query.toString();
4214                            }
4215                            else {
4216                                    sql = _SQL_SELECT_WIKINODE.concat(WikiNodeModelImpl.ORDER_BY_JPQL);
4217                            }
4218    
4219                            Session session = null;
4220    
4221                            try {
4222                                    session = openSession();
4223    
4224                                    Query q = session.createQuery(sql);
4225    
4226                                    if (orderByComparator == null) {
4227                                            list = (List<WikiNode>)QueryUtil.list(q, getDialect(),
4228                                                            start, end, false);
4229    
4230                                            Collections.sort(list);
4231                                    }
4232                                    else {
4233                                            list = (List<WikiNode>)QueryUtil.list(q, getDialect(),
4234                                                            start, end);
4235                                    }
4236                            }
4237                            catch (Exception e) {
4238                                    throw processException(e);
4239                            }
4240                            finally {
4241                                    if (list == null) {
4242                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
4243                                    }
4244                                    else {
4245                                            cacheResult(list);
4246    
4247                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
4248                                    }
4249    
4250                                    closeSession(session);
4251                            }
4252                    }
4253    
4254                    return list;
4255            }
4256    
4257            /**
4258             * Removes all the wiki nodes where uuid = &#63; from the database.
4259             *
4260             * @param uuid the uuid
4261             * @throws SystemException if a system exception occurred
4262             */
4263            public void removeByUuid(String uuid) throws SystemException {
4264                    for (WikiNode wikiNode : findByUuid(uuid)) {
4265                            remove(wikiNode);
4266                    }
4267            }
4268    
4269            /**
4270             * Removes the wiki node where uuid = &#63; and groupId = &#63; from the database.
4271             *
4272             * @param uuid the uuid
4273             * @param groupId the group ID
4274             * @return the wiki node that was removed
4275             * @throws SystemException if a system exception occurred
4276             */
4277            public WikiNode removeByUUID_G(String uuid, long groupId)
4278                    throws NoSuchNodeException, SystemException {
4279                    WikiNode wikiNode = findByUUID_G(uuid, groupId);
4280    
4281                    return remove(wikiNode);
4282            }
4283    
4284            /**
4285             * Removes all the wiki nodes where uuid = &#63; and companyId = &#63; from the database.
4286             *
4287             * @param uuid the uuid
4288             * @param companyId the company ID
4289             * @throws SystemException if a system exception occurred
4290             */
4291            public void removeByUuid_C(String uuid, long companyId)
4292                    throws SystemException {
4293                    for (WikiNode wikiNode : findByUuid_C(uuid, companyId)) {
4294                            remove(wikiNode);
4295                    }
4296            }
4297    
4298            /**
4299             * Removes all the wiki nodes where groupId = &#63; from the database.
4300             *
4301             * @param groupId the group ID
4302             * @throws SystemException if a system exception occurred
4303             */
4304            public void removeByGroupId(long groupId) throws SystemException {
4305                    for (WikiNode wikiNode : findByGroupId(groupId)) {
4306                            remove(wikiNode);
4307                    }
4308            }
4309    
4310            /**
4311             * Removes all the wiki nodes where companyId = &#63; from the database.
4312             *
4313             * @param companyId the company ID
4314             * @throws SystemException if a system exception occurred
4315             */
4316            public void removeByCompanyId(long companyId) throws SystemException {
4317                    for (WikiNode wikiNode : findByCompanyId(companyId)) {
4318                            remove(wikiNode);
4319                    }
4320            }
4321    
4322            /**
4323             * Removes the wiki node where groupId = &#63; and name = &#63; from the database.
4324             *
4325             * @param groupId the group ID
4326             * @param name the name
4327             * @return the wiki node that was removed
4328             * @throws SystemException if a system exception occurred
4329             */
4330            public WikiNode removeByG_N(long groupId, String name)
4331                    throws NoSuchNodeException, SystemException {
4332                    WikiNode wikiNode = findByG_N(groupId, name);
4333    
4334                    return remove(wikiNode);
4335            }
4336    
4337            /**
4338             * Removes all the wiki nodes where groupId = &#63; and status = &#63; from the database.
4339             *
4340             * @param groupId the group ID
4341             * @param status the status
4342             * @throws SystemException if a system exception occurred
4343             */
4344            public void removeByG_S(long groupId, int status) throws SystemException {
4345                    for (WikiNode wikiNode : findByG_S(groupId, status)) {
4346                            remove(wikiNode);
4347                    }
4348            }
4349    
4350            /**
4351             * Removes all the wiki nodes where companyId = &#63; and status = &#63; from the database.
4352             *
4353             * @param companyId the company ID
4354             * @param status the status
4355             * @throws SystemException if a system exception occurred
4356             */
4357            public void removeByC_S(long companyId, int status)
4358                    throws SystemException {
4359                    for (WikiNode wikiNode : findByC_S(companyId, status)) {
4360                            remove(wikiNode);
4361                    }
4362            }
4363    
4364            /**
4365             * Removes all the wiki nodes from the database.
4366             *
4367             * @throws SystemException if a system exception occurred
4368             */
4369            public void removeAll() throws SystemException {
4370                    for (WikiNode wikiNode : findAll()) {
4371                            remove(wikiNode);
4372                    }
4373            }
4374    
4375            /**
4376             * Returns the number of wiki nodes where uuid = &#63;.
4377             *
4378             * @param uuid the uuid
4379             * @return the number of matching wiki nodes
4380             * @throws SystemException if a system exception occurred
4381             */
4382            public int countByUuid(String uuid) throws SystemException {
4383                    Object[] finderArgs = new Object[] { uuid };
4384    
4385                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
4386                                    finderArgs, this);
4387    
4388                    if (count == null) {
4389                            StringBundler query = new StringBundler(2);
4390    
4391                            query.append(_SQL_COUNT_WIKINODE_WHERE);
4392    
4393                            if (uuid == null) {
4394                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
4395                            }
4396                            else {
4397                                    if (uuid.equals(StringPool.BLANK)) {
4398                                            query.append(_FINDER_COLUMN_UUID_UUID_3);
4399                                    }
4400                                    else {
4401                                            query.append(_FINDER_COLUMN_UUID_UUID_2);
4402                                    }
4403                            }
4404    
4405                            String sql = query.toString();
4406    
4407                            Session session = null;
4408    
4409                            try {
4410                                    session = openSession();
4411    
4412                                    Query q = session.createQuery(sql);
4413    
4414                                    QueryPos qPos = QueryPos.getInstance(q);
4415    
4416                                    if (uuid != null) {
4417                                            qPos.add(uuid);
4418                                    }
4419    
4420                                    count = (Long)q.uniqueResult();
4421                            }
4422                            catch (Exception e) {
4423                                    throw processException(e);
4424                            }
4425                            finally {
4426                                    if (count == null) {
4427                                            count = Long.valueOf(0);
4428                                    }
4429    
4430                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
4431                                            finderArgs, count);
4432    
4433                                    closeSession(session);
4434                            }
4435                    }
4436    
4437                    return count.intValue();
4438            }
4439    
4440            /**
4441             * Returns the number of wiki nodes where uuid = &#63; and groupId = &#63;.
4442             *
4443             * @param uuid the uuid
4444             * @param groupId the group ID
4445             * @return the number of matching wiki nodes
4446             * @throws SystemException if a system exception occurred
4447             */
4448            public int countByUUID_G(String uuid, long groupId)
4449                    throws SystemException {
4450                    Object[] finderArgs = new Object[] { uuid, groupId };
4451    
4452                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_G,
4453                                    finderArgs, this);
4454    
4455                    if (count == null) {
4456                            StringBundler query = new StringBundler(3);
4457    
4458                            query.append(_SQL_COUNT_WIKINODE_WHERE);
4459    
4460                            if (uuid == null) {
4461                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
4462                            }
4463                            else {
4464                                    if (uuid.equals(StringPool.BLANK)) {
4465                                            query.append(_FINDER_COLUMN_UUID_G_UUID_3);
4466                                    }
4467                                    else {
4468                                            query.append(_FINDER_COLUMN_UUID_G_UUID_2);
4469                                    }
4470                            }
4471    
4472                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
4473    
4474                            String sql = query.toString();
4475    
4476                            Session session = null;
4477    
4478                            try {
4479                                    session = openSession();
4480    
4481                                    Query q = session.createQuery(sql);
4482    
4483                                    QueryPos qPos = QueryPos.getInstance(q);
4484    
4485                                    if (uuid != null) {
4486                                            qPos.add(uuid);
4487                                    }
4488    
4489                                    qPos.add(groupId);
4490    
4491                                    count = (Long)q.uniqueResult();
4492                            }
4493                            catch (Exception e) {
4494                                    throw processException(e);
4495                            }
4496                            finally {
4497                                    if (count == null) {
4498                                            count = Long.valueOf(0);
4499                                    }
4500    
4501                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G,
4502                                            finderArgs, count);
4503    
4504                                    closeSession(session);
4505                            }
4506                    }
4507    
4508                    return count.intValue();
4509            }
4510    
4511            /**
4512             * Returns the number of wiki nodes where uuid = &#63; and companyId = &#63;.
4513             *
4514             * @param uuid the uuid
4515             * @param companyId the company ID
4516             * @return the number of matching wiki nodes
4517             * @throws SystemException if a system exception occurred
4518             */
4519            public int countByUuid_C(String uuid, long companyId)
4520                    throws SystemException {
4521                    Object[] finderArgs = new Object[] { uuid, companyId };
4522    
4523                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_C,
4524                                    finderArgs, this);
4525    
4526                    if (count == null) {
4527                            StringBundler query = new StringBundler(3);
4528    
4529                            query.append(_SQL_COUNT_WIKINODE_WHERE);
4530    
4531                            if (uuid == null) {
4532                                    query.append(_FINDER_COLUMN_UUID_C_UUID_1);
4533                            }
4534                            else {
4535                                    if (uuid.equals(StringPool.BLANK)) {
4536                                            query.append(_FINDER_COLUMN_UUID_C_UUID_3);
4537                                    }
4538                                    else {
4539                                            query.append(_FINDER_COLUMN_UUID_C_UUID_2);
4540                                    }
4541                            }
4542    
4543                            query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
4544    
4545                            String sql = query.toString();
4546    
4547                            Session session = null;
4548    
4549                            try {
4550                                    session = openSession();
4551    
4552                                    Query q = session.createQuery(sql);
4553    
4554                                    QueryPos qPos = QueryPos.getInstance(q);
4555    
4556                                    if (uuid != null) {
4557                                            qPos.add(uuid);
4558                                    }
4559    
4560                                    qPos.add(companyId);
4561    
4562                                    count = (Long)q.uniqueResult();
4563                            }
4564                            catch (Exception e) {
4565                                    throw processException(e);
4566                            }
4567                            finally {
4568                                    if (count == null) {
4569                                            count = Long.valueOf(0);
4570                                    }
4571    
4572                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_C,
4573                                            finderArgs, count);
4574    
4575                                    closeSession(session);
4576                            }
4577                    }
4578    
4579                    return count.intValue();
4580            }
4581    
4582            /**
4583             * Returns the number of wiki nodes where groupId = &#63;.
4584             *
4585             * @param groupId the group ID
4586             * @return the number of matching wiki nodes
4587             * @throws SystemException if a system exception occurred
4588             */
4589            public int countByGroupId(long groupId) throws SystemException {
4590                    Object[] finderArgs = new Object[] { groupId };
4591    
4592                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
4593                                    finderArgs, this);
4594    
4595                    if (count == null) {
4596                            StringBundler query = new StringBundler(2);
4597    
4598                            query.append(_SQL_COUNT_WIKINODE_WHERE);
4599    
4600                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
4601    
4602                            String sql = query.toString();
4603    
4604                            Session session = null;
4605    
4606                            try {
4607                                    session = openSession();
4608    
4609                                    Query q = session.createQuery(sql);
4610    
4611                                    QueryPos qPos = QueryPos.getInstance(q);
4612    
4613                                    qPos.add(groupId);
4614    
4615                                    count = (Long)q.uniqueResult();
4616                            }
4617                            catch (Exception e) {
4618                                    throw processException(e);
4619                            }
4620                            finally {
4621                                    if (count == null) {
4622                                            count = Long.valueOf(0);
4623                                    }
4624    
4625                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
4626                                            finderArgs, count);
4627    
4628                                    closeSession(session);
4629                            }
4630                    }
4631    
4632                    return count.intValue();
4633            }
4634    
4635            /**
4636             * Returns the number of wiki nodes that the user has permission to view where groupId = &#63;.
4637             *
4638             * @param groupId the group ID
4639             * @return the number of matching wiki nodes that the user has permission to view
4640             * @throws SystemException if a system exception occurred
4641             */
4642            public int filterCountByGroupId(long groupId) throws SystemException {
4643                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4644                            return countByGroupId(groupId);
4645                    }
4646    
4647                    StringBundler query = new StringBundler(2);
4648    
4649                    query.append(_FILTER_SQL_COUNT_WIKINODE_WHERE);
4650    
4651                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
4652    
4653                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4654                                    WikiNode.class.getName(),
4655                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4656    
4657                    Session session = null;
4658    
4659                    try {
4660                            session = openSession();
4661    
4662                            SQLQuery q = session.createSQLQuery(sql);
4663    
4664                            q.addScalar(COUNT_COLUMN_NAME,
4665                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
4666    
4667                            QueryPos qPos = QueryPos.getInstance(q);
4668    
4669                            qPos.add(groupId);
4670    
4671                            Long count = (Long)q.uniqueResult();
4672    
4673                            return count.intValue();
4674                    }
4675                    catch (Exception e) {
4676                            throw processException(e);
4677                    }
4678                    finally {
4679                            closeSession(session);
4680                    }
4681            }
4682    
4683            /**
4684             * Returns the number of wiki nodes where companyId = &#63;.
4685             *
4686             * @param companyId the company ID
4687             * @return the number of matching wiki nodes
4688             * @throws SystemException if a system exception occurred
4689             */
4690            public int countByCompanyId(long companyId) throws SystemException {
4691                    Object[] finderArgs = new Object[] { companyId };
4692    
4693                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
4694                                    finderArgs, this);
4695    
4696                    if (count == null) {
4697                            StringBundler query = new StringBundler(2);
4698    
4699                            query.append(_SQL_COUNT_WIKINODE_WHERE);
4700    
4701                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
4702    
4703                            String sql = query.toString();
4704    
4705                            Session session = null;
4706    
4707                            try {
4708                                    session = openSession();
4709    
4710                                    Query q = session.createQuery(sql);
4711    
4712                                    QueryPos qPos = QueryPos.getInstance(q);
4713    
4714                                    qPos.add(companyId);
4715    
4716                                    count = (Long)q.uniqueResult();
4717                            }
4718                            catch (Exception e) {
4719                                    throw processException(e);
4720                            }
4721                            finally {
4722                                    if (count == null) {
4723                                            count = Long.valueOf(0);
4724                                    }
4725    
4726                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
4727                                            finderArgs, count);
4728    
4729                                    closeSession(session);
4730                            }
4731                    }
4732    
4733                    return count.intValue();
4734            }
4735    
4736            /**
4737             * Returns the number of wiki nodes where groupId = &#63; and name = &#63;.
4738             *
4739             * @param groupId the group ID
4740             * @param name the name
4741             * @return the number of matching wiki nodes
4742             * @throws SystemException if a system exception occurred
4743             */
4744            public int countByG_N(long groupId, String name) throws SystemException {
4745                    Object[] finderArgs = new Object[] { groupId, name };
4746    
4747                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_N,
4748                                    finderArgs, this);
4749    
4750                    if (count == null) {
4751                            StringBundler query = new StringBundler(3);
4752    
4753                            query.append(_SQL_COUNT_WIKINODE_WHERE);
4754    
4755                            query.append(_FINDER_COLUMN_G_N_GROUPID_2);
4756    
4757                            if (name == null) {
4758                                    query.append(_FINDER_COLUMN_G_N_NAME_1);
4759                            }
4760                            else {
4761                                    if (name.equals(StringPool.BLANK)) {
4762                                            query.append(_FINDER_COLUMN_G_N_NAME_3);
4763                                    }
4764                                    else {
4765                                            query.append(_FINDER_COLUMN_G_N_NAME_2);
4766                                    }
4767                            }
4768    
4769                            String sql = query.toString();
4770    
4771                            Session session = null;
4772    
4773                            try {
4774                                    session = openSession();
4775    
4776                                    Query q = session.createQuery(sql);
4777    
4778                                    QueryPos qPos = QueryPos.getInstance(q);
4779    
4780                                    qPos.add(groupId);
4781    
4782                                    if (name != null) {
4783                                            qPos.add(name);
4784                                    }
4785    
4786                                    count = (Long)q.uniqueResult();
4787                            }
4788                            catch (Exception e) {
4789                                    throw processException(e);
4790                            }
4791                            finally {
4792                                    if (count == null) {
4793                                            count = Long.valueOf(0);
4794                                    }
4795    
4796                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_N, finderArgs,
4797                                            count);
4798    
4799                                    closeSession(session);
4800                            }
4801                    }
4802    
4803                    return count.intValue();
4804            }
4805    
4806            /**
4807             * Returns the number of wiki nodes where groupId = &#63; and status = &#63;.
4808             *
4809             * @param groupId the group ID
4810             * @param status the status
4811             * @return the number of matching wiki nodes
4812             * @throws SystemException if a system exception occurred
4813             */
4814            public int countByG_S(long groupId, int status) throws SystemException {
4815                    Object[] finderArgs = new Object[] { groupId, status };
4816    
4817                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_S,
4818                                    finderArgs, this);
4819    
4820                    if (count == null) {
4821                            StringBundler query = new StringBundler(3);
4822    
4823                            query.append(_SQL_COUNT_WIKINODE_WHERE);
4824    
4825                            query.append(_FINDER_COLUMN_G_S_GROUPID_2);
4826    
4827                            query.append(_FINDER_COLUMN_G_S_STATUS_2);
4828    
4829                            String sql = query.toString();
4830    
4831                            Session session = null;
4832    
4833                            try {
4834                                    session = openSession();
4835    
4836                                    Query q = session.createQuery(sql);
4837    
4838                                    QueryPos qPos = QueryPos.getInstance(q);
4839    
4840                                    qPos.add(groupId);
4841    
4842                                    qPos.add(status);
4843    
4844                                    count = (Long)q.uniqueResult();
4845                            }
4846                            catch (Exception e) {
4847                                    throw processException(e);
4848                            }
4849                            finally {
4850                                    if (count == null) {
4851                                            count = Long.valueOf(0);
4852                                    }
4853    
4854                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_S, finderArgs,
4855                                            count);
4856    
4857                                    closeSession(session);
4858                            }
4859                    }
4860    
4861                    return count.intValue();
4862            }
4863    
4864            /**
4865             * Returns the number of wiki nodes that the user has permission to view where groupId = &#63; and status = &#63;.
4866             *
4867             * @param groupId the group ID
4868             * @param status the status
4869             * @return the number of matching wiki nodes that the user has permission to view
4870             * @throws SystemException if a system exception occurred
4871             */
4872            public int filterCountByG_S(long groupId, int status)
4873                    throws SystemException {
4874                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4875                            return countByG_S(groupId, status);
4876                    }
4877    
4878                    StringBundler query = new StringBundler(3);
4879    
4880                    query.append(_FILTER_SQL_COUNT_WIKINODE_WHERE);
4881    
4882                    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
4883    
4884                    query.append(_FINDER_COLUMN_G_S_STATUS_2);
4885    
4886                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4887                                    WikiNode.class.getName(),
4888                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4889    
4890                    Session session = null;
4891    
4892                    try {
4893                            session = openSession();
4894    
4895                            SQLQuery q = session.createSQLQuery(sql);
4896    
4897                            q.addScalar(COUNT_COLUMN_NAME,
4898                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
4899    
4900                            QueryPos qPos = QueryPos.getInstance(q);
4901    
4902                            qPos.add(groupId);
4903    
4904                            qPos.add(status);
4905    
4906                            Long count = (Long)q.uniqueResult();
4907    
4908                            return count.intValue();
4909                    }
4910                    catch (Exception e) {
4911                            throw processException(e);
4912                    }
4913                    finally {
4914                            closeSession(session);
4915                    }
4916            }
4917    
4918            /**
4919             * Returns the number of wiki nodes where companyId = &#63; and status = &#63;.
4920             *
4921             * @param companyId the company ID
4922             * @param status the status
4923             * @return the number of matching wiki nodes
4924             * @throws SystemException if a system exception occurred
4925             */
4926            public int countByC_S(long companyId, int status) throws SystemException {
4927                    Object[] finderArgs = new Object[] { companyId, status };
4928    
4929                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_S,
4930                                    finderArgs, this);
4931    
4932                    if (count == null) {
4933                            StringBundler query = new StringBundler(3);
4934    
4935                            query.append(_SQL_COUNT_WIKINODE_WHERE);
4936    
4937                            query.append(_FINDER_COLUMN_C_S_COMPANYID_2);
4938    
4939                            query.append(_FINDER_COLUMN_C_S_STATUS_2);
4940    
4941                            String sql = query.toString();
4942    
4943                            Session session = null;
4944    
4945                            try {
4946                                    session = openSession();
4947    
4948                                    Query q = session.createQuery(sql);
4949    
4950                                    QueryPos qPos = QueryPos.getInstance(q);
4951    
4952                                    qPos.add(companyId);
4953    
4954                                    qPos.add(status);
4955    
4956                                    count = (Long)q.uniqueResult();
4957                            }
4958                            catch (Exception e) {
4959                                    throw processException(e);
4960                            }
4961                            finally {
4962                                    if (count == null) {
4963                                            count = Long.valueOf(0);
4964                                    }
4965    
4966                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_S, finderArgs,
4967                                            count);
4968    
4969                                    closeSession(session);
4970                            }
4971                    }
4972    
4973                    return count.intValue();
4974            }
4975    
4976            /**
4977             * Returns the number of wiki nodes.
4978             *
4979             * @return the number of wiki nodes
4980             * @throws SystemException if a system exception occurred
4981             */
4982            public int countAll() throws SystemException {
4983                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
4984                                    FINDER_ARGS_EMPTY, this);
4985    
4986                    if (count == null) {
4987                            Session session = null;
4988    
4989                            try {
4990                                    session = openSession();
4991    
4992                                    Query q = session.createQuery(_SQL_COUNT_WIKINODE);
4993    
4994                                    count = (Long)q.uniqueResult();
4995                            }
4996                            catch (Exception e) {
4997                                    throw processException(e);
4998                            }
4999                            finally {
5000                                    if (count == null) {
5001                                            count = Long.valueOf(0);
5002                                    }
5003    
5004                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
5005                                            FINDER_ARGS_EMPTY, count);
5006    
5007                                    closeSession(session);
5008                            }
5009                    }
5010    
5011                    return count.intValue();
5012            }
5013    
5014            /**
5015             * Initializes the wiki node persistence.
5016             */
5017            public void afterPropertiesSet() {
5018                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
5019                                            com.liferay.portal.util.PropsUtil.get(
5020                                                    "value.object.listener.com.liferay.portlet.wiki.model.WikiNode")));
5021    
5022                    if (listenerClassNames.length > 0) {
5023                            try {
5024                                    List<ModelListener<WikiNode>> listenersList = new ArrayList<ModelListener<WikiNode>>();
5025    
5026                                    for (String listenerClassName : listenerClassNames) {
5027                                            listenersList.add((ModelListener<WikiNode>)InstanceFactory.newInstance(
5028                                                            listenerClassName));
5029                                    }
5030    
5031                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
5032                            }
5033                            catch (Exception e) {
5034                                    _log.error(e);
5035                            }
5036                    }
5037            }
5038    
5039            public void destroy() {
5040                    EntityCacheUtil.removeCache(WikiNodeImpl.class.getName());
5041                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
5042                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
5043            }
5044    
5045            @BeanReference(type = WikiNodePersistence.class)
5046            protected WikiNodePersistence wikiNodePersistence;
5047            @BeanReference(type = WikiPagePersistence.class)
5048            protected WikiPagePersistence wikiPagePersistence;
5049            @BeanReference(type = WikiPageResourcePersistence.class)
5050            protected WikiPageResourcePersistence wikiPageResourcePersistence;
5051            @BeanReference(type = GroupPersistence.class)
5052            protected GroupPersistence groupPersistence;
5053            @BeanReference(type = SubscriptionPersistence.class)
5054            protected SubscriptionPersistence subscriptionPersistence;
5055            @BeanReference(type = UserPersistence.class)
5056            protected UserPersistence userPersistence;
5057            @BeanReference(type = TrashEntryPersistence.class)
5058            protected TrashEntryPersistence trashEntryPersistence;
5059            private static final String _SQL_SELECT_WIKINODE = "SELECT wikiNode FROM WikiNode wikiNode";
5060            private static final String _SQL_SELECT_WIKINODE_WHERE = "SELECT wikiNode FROM WikiNode wikiNode WHERE ";
5061            private static final String _SQL_COUNT_WIKINODE = "SELECT COUNT(wikiNode) FROM WikiNode wikiNode";
5062            private static final String _SQL_COUNT_WIKINODE_WHERE = "SELECT COUNT(wikiNode) FROM WikiNode wikiNode WHERE ";
5063            private static final String _FINDER_COLUMN_UUID_UUID_1 = "wikiNode.uuid IS NULL";
5064            private static final String _FINDER_COLUMN_UUID_UUID_2 = "wikiNode.uuid = ?";
5065            private static final String _FINDER_COLUMN_UUID_UUID_3 = "(wikiNode.uuid IS NULL OR wikiNode.uuid = ?)";
5066            private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "wikiNode.uuid IS NULL AND ";
5067            private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "wikiNode.uuid = ? AND ";
5068            private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(wikiNode.uuid IS NULL OR wikiNode.uuid = ?) AND ";
5069            private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "wikiNode.groupId = ?";
5070            private static final String _FINDER_COLUMN_UUID_C_UUID_1 = "wikiNode.uuid IS NULL AND ";
5071            private static final String _FINDER_COLUMN_UUID_C_UUID_2 = "wikiNode.uuid = ? AND ";
5072            private static final String _FINDER_COLUMN_UUID_C_UUID_3 = "(wikiNode.uuid IS NULL OR wikiNode.uuid = ?) AND ";
5073            private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 = "wikiNode.companyId = ?";
5074            private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "wikiNode.groupId = ?";
5075            private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "wikiNode.companyId = ?";
5076            private static final String _FINDER_COLUMN_G_N_GROUPID_2 = "wikiNode.groupId = ? AND ";
5077            private static final String _FINDER_COLUMN_G_N_NAME_1 = "wikiNode.name IS NULL";
5078            private static final String _FINDER_COLUMN_G_N_NAME_2 = "wikiNode.name = ?";
5079            private static final String _FINDER_COLUMN_G_N_NAME_3 = "(wikiNode.name IS NULL OR wikiNode.name = ?)";
5080            private static final String _FINDER_COLUMN_G_S_GROUPID_2 = "wikiNode.groupId = ? AND ";
5081            private static final String _FINDER_COLUMN_G_S_STATUS_2 = "wikiNode.status = ?";
5082            private static final String _FINDER_COLUMN_C_S_COMPANYID_2 = "wikiNode.companyId = ? AND ";
5083            private static final String _FINDER_COLUMN_C_S_STATUS_2 = "wikiNode.status = ?";
5084            private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "wikiNode.nodeId";
5085            private static final String _FILTER_SQL_SELECT_WIKINODE_WHERE = "SELECT DISTINCT {wikiNode.*} FROM WikiNode wikiNode WHERE ";
5086            private static final String _FILTER_SQL_SELECT_WIKINODE_NO_INLINE_DISTINCT_WHERE_1 =
5087                    "SELECT {WikiNode.*} FROM (SELECT DISTINCT wikiNode.nodeId FROM WikiNode wikiNode WHERE ";
5088            private static final String _FILTER_SQL_SELECT_WIKINODE_NO_INLINE_DISTINCT_WHERE_2 =
5089                    ") TEMP_TABLE INNER JOIN WikiNode ON TEMP_TABLE.nodeId = WikiNode.nodeId";
5090            private static final String _FILTER_SQL_COUNT_WIKINODE_WHERE = "SELECT COUNT(DISTINCT wikiNode.nodeId) AS COUNT_VALUE FROM WikiNode wikiNode WHERE ";
5091            private static final String _FILTER_ENTITY_ALIAS = "wikiNode";
5092            private static final String _FILTER_ENTITY_TABLE = "WikiNode";
5093            private static final String _ORDER_BY_ENTITY_ALIAS = "wikiNode.";
5094            private static final String _ORDER_BY_ENTITY_TABLE = "WikiNode.";
5095            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No WikiNode exists with the primary key ";
5096            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No WikiNode exists with the key {";
5097            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
5098            private static Log _log = LogFactoryUtil.getLog(WikiNodePersistenceImpl.class);
5099            private static WikiNode _nullWikiNode = new WikiNodeImpl() {
5100                            @Override
5101                            public Object clone() {
5102                                    return this;
5103                            }
5104    
5105                            @Override
5106                            public CacheModel<WikiNode> toCacheModel() {
5107                                    return _nullWikiNodeCacheModel;
5108                            }
5109                    };
5110    
5111            private static CacheModel<WikiNode> _nullWikiNodeCacheModel = new CacheModel<WikiNode>() {
5112                            public WikiNode toEntityModel() {
5113                                    return _nullWikiNode;
5114                            }
5115                    };
5116    }