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