1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   *
12   * 
13   */
14  
15  package com.liferay.portlet.wiki.service.persistence;
16  
17  import com.liferay.portal.NoSuchModelException;
18  import com.liferay.portal.SystemException;
19  import com.liferay.portal.kernel.annotation.BeanReference;
20  import com.liferay.portal.kernel.cache.CacheRegistry;
21  import com.liferay.portal.kernel.dao.orm.DynamicQuery;
22  import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
23  import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
24  import com.liferay.portal.kernel.dao.orm.FinderPath;
25  import com.liferay.portal.kernel.dao.orm.Query;
26  import com.liferay.portal.kernel.dao.orm.QueryPos;
27  import com.liferay.portal.kernel.dao.orm.QueryUtil;
28  import com.liferay.portal.kernel.dao.orm.Session;
29  import com.liferay.portal.kernel.log.Log;
30  import com.liferay.portal.kernel.log.LogFactoryUtil;
31  import com.liferay.portal.kernel.util.GetterUtil;
32  import com.liferay.portal.kernel.util.OrderByComparator;
33  import com.liferay.portal.kernel.util.StringBundler;
34  import com.liferay.portal.kernel.util.StringPool;
35  import com.liferay.portal.kernel.util.StringUtil;
36  import com.liferay.portal.kernel.util.Validator;
37  import com.liferay.portal.model.ModelListener;
38  import com.liferay.portal.service.persistence.BatchSessionUtil;
39  import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
40  
41  import com.liferay.portlet.wiki.NoSuchPageResourceException;
42  import com.liferay.portlet.wiki.model.WikiPageResource;
43  import com.liferay.portlet.wiki.model.impl.WikiPageResourceImpl;
44  import com.liferay.portlet.wiki.model.impl.WikiPageResourceModelImpl;
45  
46  import java.io.Serializable;
47  
48  import java.util.ArrayList;
49  import java.util.Collections;
50  import java.util.List;
51  
52  /**
53   * <a href="WikiPageResourcePersistenceImpl.java.html"><b><i>View Source</i></b></a>
54   *
55   * <p>
56   * ServiceBuilder generated this class. Modifications in this class will be
57   * overwritten the next time is generated.
58   * </p>
59   *
60   * @author    Brian Wing Shun Chan
61   * @see       WikiPageResourcePersistence
62   * @see       WikiPageResourceUtil
63   * @generated
64   */
65  public class WikiPageResourcePersistenceImpl extends BasePersistenceImpl<WikiPageResource>
66      implements WikiPageResourcePersistence {
67      public static final String FINDER_CLASS_NAME_ENTITY = WikiPageResourceImpl.class.getName();
68      public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
69          ".List";
70      public static final FinderPath FINDER_PATH_FETCH_BY_N_T = new FinderPath(WikiPageResourceModelImpl.ENTITY_CACHE_ENABLED,
71              WikiPageResourceModelImpl.FINDER_CACHE_ENABLED,
72              FINDER_CLASS_NAME_ENTITY, "fetchByN_T",
73              new String[] { Long.class.getName(), String.class.getName() });
74      public static final FinderPath FINDER_PATH_COUNT_BY_N_T = new FinderPath(WikiPageResourceModelImpl.ENTITY_CACHE_ENABLED,
75              WikiPageResourceModelImpl.FINDER_CACHE_ENABLED,
76              FINDER_CLASS_NAME_LIST, "countByN_T",
77              new String[] { Long.class.getName(), String.class.getName() });
78      public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(WikiPageResourceModelImpl.ENTITY_CACHE_ENABLED,
79              WikiPageResourceModelImpl.FINDER_CACHE_ENABLED,
80              FINDER_CLASS_NAME_LIST, "findAll", new String[0]);
81      public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(WikiPageResourceModelImpl.ENTITY_CACHE_ENABLED,
82              WikiPageResourceModelImpl.FINDER_CACHE_ENABLED,
83              FINDER_CLASS_NAME_LIST, "countAll", new String[0]);
84  
85      public void cacheResult(WikiPageResource wikiPageResource) {
86          EntityCacheUtil.putResult(WikiPageResourceModelImpl.ENTITY_CACHE_ENABLED,
87              WikiPageResourceImpl.class, wikiPageResource.getPrimaryKey(),
88              wikiPageResource);
89  
90          FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_N_T,
91              new Object[] {
92                  new Long(wikiPageResource.getNodeId()),
93                  
94              wikiPageResource.getTitle()
95              }, wikiPageResource);
96      }
97  
98      public void cacheResult(List<WikiPageResource> wikiPageResources) {
99          for (WikiPageResource wikiPageResource : wikiPageResources) {
100             if (EntityCacheUtil.getResult(
101                         WikiPageResourceModelImpl.ENTITY_CACHE_ENABLED,
102                         WikiPageResourceImpl.class,
103                         wikiPageResource.getPrimaryKey(), this) == null) {
104                 cacheResult(wikiPageResource);
105             }
106         }
107     }
108 
109     public void clearCache() {
110         CacheRegistry.clear(WikiPageResourceImpl.class.getName());
111         EntityCacheUtil.clearCache(WikiPageResourceImpl.class.getName());
112         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
113         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
114     }
115 
116     public WikiPageResource create(long resourcePrimKey) {
117         WikiPageResource wikiPageResource = new WikiPageResourceImpl();
118 
119         wikiPageResource.setNew(true);
120         wikiPageResource.setPrimaryKey(resourcePrimKey);
121 
122         return wikiPageResource;
123     }
124 
125     public WikiPageResource remove(Serializable primaryKey)
126         throws NoSuchModelException, SystemException {
127         return remove(((Long)primaryKey).longValue());
128     }
129 
130     public WikiPageResource remove(long resourcePrimKey)
131         throws NoSuchPageResourceException, SystemException {
132         Session session = null;
133 
134         try {
135             session = openSession();
136 
137             WikiPageResource wikiPageResource = (WikiPageResource)session.get(WikiPageResourceImpl.class,
138                     new Long(resourcePrimKey));
139 
140             if (wikiPageResource == null) {
141                 if (_log.isWarnEnabled()) {
142                     _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
143                         resourcePrimKey);
144                 }
145 
146                 throw new NoSuchPageResourceException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
147                     resourcePrimKey);
148             }
149 
150             return remove(wikiPageResource);
151         }
152         catch (NoSuchPageResourceException nsee) {
153             throw nsee;
154         }
155         catch (Exception e) {
156             throw processException(e);
157         }
158         finally {
159             closeSession(session);
160         }
161     }
162 
163     public WikiPageResource remove(WikiPageResource wikiPageResource)
164         throws SystemException {
165         for (ModelListener<WikiPageResource> listener : listeners) {
166             listener.onBeforeRemove(wikiPageResource);
167         }
168 
169         wikiPageResource = removeImpl(wikiPageResource);
170 
171         for (ModelListener<WikiPageResource> listener : listeners) {
172             listener.onAfterRemove(wikiPageResource);
173         }
174 
175         return wikiPageResource;
176     }
177 
178     protected WikiPageResource removeImpl(WikiPageResource wikiPageResource)
179         throws SystemException {
180         wikiPageResource = toUnwrappedModel(wikiPageResource);
181 
182         Session session = null;
183 
184         try {
185             session = openSession();
186 
187             if (wikiPageResource.isCachedModel() ||
188                     BatchSessionUtil.isEnabled()) {
189                 Object staleObject = session.get(WikiPageResourceImpl.class,
190                         wikiPageResource.getPrimaryKeyObj());
191 
192                 if (staleObject != null) {
193                     session.evict(staleObject);
194                 }
195             }
196 
197             session.delete(wikiPageResource);
198 
199             session.flush();
200         }
201         catch (Exception e) {
202             throw processException(e);
203         }
204         finally {
205             closeSession(session);
206         }
207 
208         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
209 
210         WikiPageResourceModelImpl wikiPageResourceModelImpl = (WikiPageResourceModelImpl)wikiPageResource;
211 
212         FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_N_T,
213             new Object[] {
214                 new Long(wikiPageResourceModelImpl.getOriginalNodeId()),
215                 
216             wikiPageResourceModelImpl.getOriginalTitle()
217             });
218 
219         EntityCacheUtil.removeResult(WikiPageResourceModelImpl.ENTITY_CACHE_ENABLED,
220             WikiPageResourceImpl.class, wikiPageResource.getPrimaryKey());
221 
222         return wikiPageResource;
223     }
224 
225     /**
226      * @deprecated Use {@link BasePersistence#update(com.liferay.portal.model.BaseModel, boolean)}.
227      */
228     public WikiPageResource update(WikiPageResource wikiPageResource)
229         throws SystemException {
230         if (_log.isWarnEnabled()) {
231             _log.warn(
232                 "Using the deprecated update(WikiPageResource wikiPageResource) method. Use update(WikiPageResource wikiPageResource, boolean merge) instead.");
233         }
234 
235         return update(wikiPageResource, false);
236     }
237 
238     public WikiPageResource updateImpl(
239         com.liferay.portlet.wiki.model.WikiPageResource wikiPageResource,
240         boolean merge) throws SystemException {
241         wikiPageResource = toUnwrappedModel(wikiPageResource);
242 
243         boolean isNew = wikiPageResource.isNew();
244 
245         WikiPageResourceModelImpl wikiPageResourceModelImpl = (WikiPageResourceModelImpl)wikiPageResource;
246 
247         Session session = null;
248 
249         try {
250             session = openSession();
251 
252             BatchSessionUtil.update(session, wikiPageResource, merge);
253 
254             wikiPageResource.setNew(false);
255         }
256         catch (Exception e) {
257             throw processException(e);
258         }
259         finally {
260             closeSession(session);
261         }
262 
263         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
264 
265         EntityCacheUtil.putResult(WikiPageResourceModelImpl.ENTITY_CACHE_ENABLED,
266             WikiPageResourceImpl.class, wikiPageResource.getPrimaryKey(),
267             wikiPageResource);
268 
269         if (!isNew &&
270                 ((wikiPageResource.getNodeId() != wikiPageResourceModelImpl.getOriginalNodeId()) ||
271                 !Validator.equals(wikiPageResource.getTitle(),
272                     wikiPageResourceModelImpl.getOriginalTitle()))) {
273             FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_N_T,
274                 new Object[] {
275                     new Long(wikiPageResourceModelImpl.getOriginalNodeId()),
276                     
277                 wikiPageResourceModelImpl.getOriginalTitle()
278                 });
279         }
280 
281         if (isNew ||
282                 ((wikiPageResource.getNodeId() != wikiPageResourceModelImpl.getOriginalNodeId()) ||
283                 !Validator.equals(wikiPageResource.getTitle(),
284                     wikiPageResourceModelImpl.getOriginalTitle()))) {
285             FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_N_T,
286                 new Object[] {
287                     new Long(wikiPageResource.getNodeId()),
288                     
289                 wikiPageResource.getTitle()
290                 }, wikiPageResource);
291         }
292 
293         return wikiPageResource;
294     }
295 
296     protected WikiPageResource toUnwrappedModel(
297         WikiPageResource wikiPageResource) {
298         if (wikiPageResource instanceof WikiPageResourceImpl) {
299             return wikiPageResource;
300         }
301 
302         WikiPageResourceImpl wikiPageResourceImpl = new WikiPageResourceImpl();
303 
304         wikiPageResourceImpl.setNew(wikiPageResource.isNew());
305         wikiPageResourceImpl.setPrimaryKey(wikiPageResource.getPrimaryKey());
306 
307         wikiPageResourceImpl.setResourcePrimKey(wikiPageResource.getResourcePrimKey());
308         wikiPageResourceImpl.setNodeId(wikiPageResource.getNodeId());
309         wikiPageResourceImpl.setTitle(wikiPageResource.getTitle());
310 
311         return wikiPageResourceImpl;
312     }
313 
314     public WikiPageResource findByPrimaryKey(Serializable primaryKey)
315         throws NoSuchModelException, SystemException {
316         return findByPrimaryKey(((Long)primaryKey).longValue());
317     }
318 
319     public WikiPageResource findByPrimaryKey(long resourcePrimKey)
320         throws NoSuchPageResourceException, SystemException {
321         WikiPageResource wikiPageResource = fetchByPrimaryKey(resourcePrimKey);
322 
323         if (wikiPageResource == null) {
324             if (_log.isWarnEnabled()) {
325                 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + resourcePrimKey);
326             }
327 
328             throw new NoSuchPageResourceException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
329                 resourcePrimKey);
330         }
331 
332         return wikiPageResource;
333     }
334 
335     public WikiPageResource fetchByPrimaryKey(Serializable primaryKey)
336         throws SystemException {
337         return fetchByPrimaryKey(((Long)primaryKey).longValue());
338     }
339 
340     public WikiPageResource fetchByPrimaryKey(long resourcePrimKey)
341         throws SystemException {
342         WikiPageResource wikiPageResource = (WikiPageResource)EntityCacheUtil.getResult(WikiPageResourceModelImpl.ENTITY_CACHE_ENABLED,
343                 WikiPageResourceImpl.class, resourcePrimKey, this);
344 
345         if (wikiPageResource == null) {
346             Session session = null;
347 
348             try {
349                 session = openSession();
350 
351                 wikiPageResource = (WikiPageResource)session.get(WikiPageResourceImpl.class,
352                         new Long(resourcePrimKey));
353             }
354             catch (Exception e) {
355                 throw processException(e);
356             }
357             finally {
358                 if (wikiPageResource != null) {
359                     cacheResult(wikiPageResource);
360                 }
361 
362                 closeSession(session);
363             }
364         }
365 
366         return wikiPageResource;
367     }
368 
369     public WikiPageResource findByN_T(long nodeId, String title)
370         throws NoSuchPageResourceException, SystemException {
371         WikiPageResource wikiPageResource = fetchByN_T(nodeId, title);
372 
373         if (wikiPageResource == null) {
374             StringBundler msg = new StringBundler(6);
375 
376             msg.append(_NO_SUCH_ENTITY_WITH_KEY);
377 
378             msg.append("nodeId=");
379             msg.append(nodeId);
380 
381             msg.append(", title=");
382             msg.append(title);
383 
384             msg.append(StringPool.CLOSE_CURLY_BRACE);
385 
386             if (_log.isWarnEnabled()) {
387                 _log.warn(msg.toString());
388             }
389 
390             throw new NoSuchPageResourceException(msg.toString());
391         }
392 
393         return wikiPageResource;
394     }
395 
396     public WikiPageResource fetchByN_T(long nodeId, String title)
397         throws SystemException {
398         return fetchByN_T(nodeId, title, true);
399     }
400 
401     public WikiPageResource fetchByN_T(long nodeId, String title,
402         boolean retrieveFromCache) throws SystemException {
403         Object[] finderArgs = new Object[] { new Long(nodeId), title };
404 
405         Object result = null;
406 
407         if (retrieveFromCache) {
408             result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_N_T,
409                     finderArgs, this);
410         }
411 
412         if (result == null) {
413             Session session = null;
414 
415             try {
416                 session = openSession();
417 
418                 StringBundler query = new StringBundler(3);
419 
420                 query.append(_SQL_SELECT_WIKIPAGERESOURCE_WHERE);
421 
422                 query.append(_FINDER_COLUMN_N_T_NODEID_2);
423 
424                 if (title == null) {
425                     query.append(_FINDER_COLUMN_N_T_TITLE_1);
426                 }
427                 else {
428                     if (title.equals(StringPool.BLANK)) {
429                         query.append(_FINDER_COLUMN_N_T_TITLE_3);
430                     }
431                     else {
432                         query.append(_FINDER_COLUMN_N_T_TITLE_2);
433                     }
434                 }
435 
436                 String sql = query.toString();
437 
438                 Query q = session.createQuery(sql);
439 
440                 QueryPos qPos = QueryPos.getInstance(q);
441 
442                 qPos.add(nodeId);
443 
444                 if (title != null) {
445                     qPos.add(title);
446                 }
447 
448                 List<WikiPageResource> list = q.list();
449 
450                 result = list;
451 
452                 WikiPageResource wikiPageResource = null;
453 
454                 if (list.isEmpty()) {
455                     FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_N_T,
456                         finderArgs, list);
457                 }
458                 else {
459                     wikiPageResource = list.get(0);
460 
461                     cacheResult(wikiPageResource);
462 
463                     if ((wikiPageResource.getNodeId() != nodeId) ||
464                             (wikiPageResource.getTitle() == null) ||
465                             !wikiPageResource.getTitle().equals(title)) {
466                         FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_N_T,
467                             finderArgs, wikiPageResource);
468                     }
469                 }
470 
471                 return wikiPageResource;
472             }
473             catch (Exception e) {
474                 throw processException(e);
475             }
476             finally {
477                 if (result == null) {
478                     FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_N_T,
479                         finderArgs, new ArrayList<WikiPageResource>());
480                 }
481 
482                 closeSession(session);
483             }
484         }
485         else {
486             if (result instanceof List<?>) {
487                 return null;
488             }
489             else {
490                 return (WikiPageResource)result;
491             }
492         }
493     }
494 
495     public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery)
496         throws SystemException {
497         Session session = null;
498 
499         try {
500             session = openSession();
501 
502             dynamicQuery.compile(session);
503 
504             return dynamicQuery.list();
505         }
506         catch (Exception e) {
507             throw processException(e);
508         }
509         finally {
510             closeSession(session);
511         }
512     }
513 
514     public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery,
515         int start, int end) throws SystemException {
516         Session session = null;
517 
518         try {
519             session = openSession();
520 
521             dynamicQuery.setLimit(start, end);
522 
523             dynamicQuery.compile(session);
524 
525             return dynamicQuery.list();
526         }
527         catch (Exception e) {
528             throw processException(e);
529         }
530         finally {
531             closeSession(session);
532         }
533     }
534 
535     public List<WikiPageResource> findAll() throws SystemException {
536         return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
537     }
538 
539     public List<WikiPageResource> findAll(int start, int end)
540         throws SystemException {
541         return findAll(start, end, null);
542     }
543 
544     public List<WikiPageResource> findAll(int start, int end,
545         OrderByComparator obc) throws SystemException {
546         Object[] finderArgs = new Object[] {
547                 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
548             };
549 
550         List<WikiPageResource> list = (List<WikiPageResource>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
551                 finderArgs, this);
552 
553         if (list == null) {
554             Session session = null;
555 
556             try {
557                 session = openSession();
558 
559                 StringBundler query = null;
560                 String sql = null;
561 
562                 if (obc != null) {
563                     query = new StringBundler(2 +
564                             (obc.getOrderByFields().length * 3));
565 
566                     query.append(_SQL_SELECT_WIKIPAGERESOURCE);
567 
568                     appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
569 
570                     sql = query.toString();
571                 }
572 
573                 sql = _SQL_SELECT_WIKIPAGERESOURCE;
574 
575                 Query q = session.createQuery(sql);
576 
577                 if (obc == null) {
578                     list = (List<WikiPageResource>)QueryUtil.list(q,
579                             getDialect(), start, end, false);
580 
581                     Collections.sort(list);
582                 }
583                 else {
584                     list = (List<WikiPageResource>)QueryUtil.list(q,
585                             getDialect(), start, end);
586                 }
587             }
588             catch (Exception e) {
589                 throw processException(e);
590             }
591             finally {
592                 if (list == null) {
593                     list = new ArrayList<WikiPageResource>();
594                 }
595 
596                 cacheResult(list);
597 
598                 FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
599 
600                 closeSession(session);
601             }
602         }
603 
604         return list;
605     }
606 
607     public void removeByN_T(long nodeId, String title)
608         throws NoSuchPageResourceException, SystemException {
609         WikiPageResource wikiPageResource = findByN_T(nodeId, title);
610 
611         remove(wikiPageResource);
612     }
613 
614     public void removeAll() throws SystemException {
615         for (WikiPageResource wikiPageResource : findAll()) {
616             remove(wikiPageResource);
617         }
618     }
619 
620     public int countByN_T(long nodeId, String title) throws SystemException {
621         Object[] finderArgs = new Object[] { new Long(nodeId), title };
622 
623         Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_N_T,
624                 finderArgs, this);
625 
626         if (count == null) {
627             Session session = null;
628 
629             try {
630                 session = openSession();
631 
632                 StringBundler query = new StringBundler(3);
633 
634                 query.append(_SQL_COUNT_WIKIPAGERESOURCE_WHERE);
635 
636                 query.append(_FINDER_COLUMN_N_T_NODEID_2);
637 
638                 if (title == null) {
639                     query.append(_FINDER_COLUMN_N_T_TITLE_1);
640                 }
641                 else {
642                     if (title.equals(StringPool.BLANK)) {
643                         query.append(_FINDER_COLUMN_N_T_TITLE_3);
644                     }
645                     else {
646                         query.append(_FINDER_COLUMN_N_T_TITLE_2);
647                     }
648                 }
649 
650                 String sql = query.toString();
651 
652                 Query q = session.createQuery(sql);
653 
654                 QueryPos qPos = QueryPos.getInstance(q);
655 
656                 qPos.add(nodeId);
657 
658                 if (title != null) {
659                     qPos.add(title);
660                 }
661 
662                 count = (Long)q.uniqueResult();
663             }
664             catch (Exception e) {
665                 throw processException(e);
666             }
667             finally {
668                 if (count == null) {
669                     count = Long.valueOf(0);
670                 }
671 
672                 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_N_T, finderArgs,
673                     count);
674 
675                 closeSession(session);
676             }
677         }
678 
679         return count.intValue();
680     }
681 
682     public int countAll() throws SystemException {
683         Object[] finderArgs = new Object[0];
684 
685         Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
686                 finderArgs, this);
687 
688         if (count == null) {
689             Session session = null;
690 
691             try {
692                 session = openSession();
693 
694                 Query q = session.createQuery(_SQL_COUNT_WIKIPAGERESOURCE);
695 
696                 count = (Long)q.uniqueResult();
697             }
698             catch (Exception e) {
699                 throw processException(e);
700             }
701             finally {
702                 if (count == null) {
703                     count = Long.valueOf(0);
704                 }
705 
706                 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
707                     count);
708 
709                 closeSession(session);
710             }
711         }
712 
713         return count.intValue();
714     }
715 
716     public void afterPropertiesSet() {
717         String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
718                     com.liferay.portal.util.PropsUtil.get(
719                         "value.object.listener.com.liferay.portlet.wiki.model.WikiPageResource")));
720 
721         if (listenerClassNames.length > 0) {
722             try {
723                 List<ModelListener<WikiPageResource>> listenersList = new ArrayList<ModelListener<WikiPageResource>>();
724 
725                 for (String listenerClassName : listenerClassNames) {
726                     listenersList.add((ModelListener<WikiPageResource>)Class.forName(
727                             listenerClassName).newInstance());
728                 }
729 
730                 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
731             }
732             catch (Exception e) {
733                 _log.error(e);
734             }
735         }
736     }
737 
738     @BeanReference(name = "com.liferay.portlet.wiki.service.persistence.WikiNodePersistence")
739     protected com.liferay.portlet.wiki.service.persistence.WikiNodePersistence wikiNodePersistence;
740     @BeanReference(name = "com.liferay.portlet.wiki.service.persistence.WikiPagePersistence")
741     protected com.liferay.portlet.wiki.service.persistence.WikiPagePersistence wikiPagePersistence;
742     @BeanReference(name = "com.liferay.portlet.wiki.service.persistence.WikiPageResourcePersistence")
743     protected com.liferay.portlet.wiki.service.persistence.WikiPageResourcePersistence wikiPageResourcePersistence;
744     @BeanReference(name = "com.liferay.portal.service.persistence.ResourcePersistence")
745     protected com.liferay.portal.service.persistence.ResourcePersistence resourcePersistence;
746     @BeanReference(name = "com.liferay.portal.service.persistence.UserPersistence")
747     protected com.liferay.portal.service.persistence.UserPersistence userPersistence;
748     private static final String _SQL_SELECT_WIKIPAGERESOURCE = "SELECT wikiPageResource FROM WikiPageResource wikiPageResource";
749     private static final String _SQL_SELECT_WIKIPAGERESOURCE_WHERE = "SELECT wikiPageResource FROM WikiPageResource wikiPageResource WHERE ";
750     private static final String _SQL_COUNT_WIKIPAGERESOURCE = "SELECT COUNT(wikiPageResource) FROM WikiPageResource wikiPageResource";
751     private static final String _SQL_COUNT_WIKIPAGERESOURCE_WHERE = "SELECT COUNT(wikiPageResource) FROM WikiPageResource wikiPageResource WHERE ";
752     private static final String _FINDER_COLUMN_N_T_NODEID_2 = "wikiPageResource.nodeId = ? AND ";
753     private static final String _FINDER_COLUMN_N_T_TITLE_1 = "wikiPageResource.title IS NULL";
754     private static final String _FINDER_COLUMN_N_T_TITLE_2 = "wikiPageResource.title = ?";
755     private static final String _FINDER_COLUMN_N_T_TITLE_3 = "(wikiPageResource.title IS NULL OR wikiPageResource.title = ?)";
756     private static final String _ORDER_BY_ENTITY_ALIAS = "wikiPageResource.";
757     private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No WikiPageResource exists with the primary key ";
758     private static final String _NO_SUCH_ENTITY_WITH_KEY = "No WikiPageResource exists with the key {";
759     private static Log _log = LogFactoryUtil.getLog(WikiPageResourcePersistenceImpl.class);
760 }