1   /**
2    * Copyright (c) 2000-2008 Liferay, Inc. All rights reserved.
3    *
4    * Permission is hereby granted, free of charge, to any person obtaining a copy
5    * of this software and associated documentation files (the "Software"), to deal
6    * in the Software without restriction, including without limitation the rights
7    * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8    * copies of the Software, and to permit persons to whom the Software is
9    * furnished to do so, subject to the following conditions:
10   *
11   * The above copyright notice and this permission notice shall be included in
12   * all copies or substantial portions of the Software.
13   *
14   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20   * SOFTWARE.
21   */
22  
23  package com.liferay.portlet.journal.service.persistence;
24  
25  import com.liferay.portal.SystemException;
26  import com.liferay.portal.kernel.dao.DynamicQuery;
27  import com.liferay.portal.kernel.dao.DynamicQueryInitializer;
28  import com.liferay.portal.kernel.util.GetterUtil;
29  import com.liferay.portal.kernel.util.OrderByComparator;
30  import com.liferay.portal.kernel.util.StringMaker;
31  import com.liferay.portal.kernel.util.StringPool;
32  import com.liferay.portal.kernel.util.Validator;
33  import com.liferay.portal.model.ModelListener;
34  import com.liferay.portal.service.persistence.BasePersistence;
35  import com.liferay.portal.spring.hibernate.FinderCache;
36  import com.liferay.portal.spring.hibernate.HibernateUtil;
37  import com.liferay.portal.util.PropsUtil;
38  
39  import com.liferay.portlet.journal.NoSuchContentSearchException;
40  import com.liferay.portlet.journal.model.JournalContentSearch;
41  import com.liferay.portlet.journal.model.impl.JournalContentSearchImpl;
42  import com.liferay.portlet.journal.model.impl.JournalContentSearchModelImpl;
43  
44  import com.liferay.util.dao.hibernate.QueryUtil;
45  
46  import org.apache.commons.logging.Log;
47  import org.apache.commons.logging.LogFactory;
48  
49  import org.hibernate.Query;
50  import org.hibernate.Session;
51  
52  import java.util.Collections;
53  import java.util.Iterator;
54  import java.util.List;
55  
56  /**
57   * <a href="JournalContentSearchPersistenceImpl.java.html"><b><i>View Source</i></b></a>
58   *
59   * @author Brian Wing Shun Chan
60   *
61   */
62  public class JournalContentSearchPersistenceImpl extends BasePersistence
63      implements JournalContentSearchPersistence {
64      public JournalContentSearch create(long contentSearchId) {
65          JournalContentSearch journalContentSearch = new JournalContentSearchImpl();
66  
67          journalContentSearch.setNew(true);
68          journalContentSearch.setPrimaryKey(contentSearchId);
69  
70          return journalContentSearch;
71      }
72  
73      public JournalContentSearch remove(long contentSearchId)
74          throws NoSuchContentSearchException, SystemException {
75          Session session = null;
76  
77          try {
78              session = openSession();
79  
80              JournalContentSearch journalContentSearch = (JournalContentSearch)session.get(JournalContentSearchImpl.class,
81                      new Long(contentSearchId));
82  
83              if (journalContentSearch == null) {
84                  if (_log.isWarnEnabled()) {
85                      _log.warn(
86                          "No JournalContentSearch exists with the primary key " +
87                          contentSearchId);
88                  }
89  
90                  throw new NoSuchContentSearchException(
91                      "No JournalContentSearch exists with the primary key " +
92                      contentSearchId);
93              }
94  
95              return remove(journalContentSearch);
96          }
97          catch (NoSuchContentSearchException nsee) {
98              throw nsee;
99          }
100         catch (Exception e) {
101             throw HibernateUtil.processException(e);
102         }
103         finally {
104             closeSession(session);
105         }
106     }
107 
108     public JournalContentSearch remove(
109         JournalContentSearch journalContentSearch) throws SystemException {
110         ModelListener listener = _getListener();
111 
112         if (listener != null) {
113             listener.onBeforeRemove(journalContentSearch);
114         }
115 
116         journalContentSearch = removeImpl(journalContentSearch);
117 
118         if (listener != null) {
119             listener.onAfterRemove(journalContentSearch);
120         }
121 
122         return journalContentSearch;
123     }
124 
125     protected JournalContentSearch removeImpl(
126         JournalContentSearch journalContentSearch) throws SystemException {
127         Session session = null;
128 
129         try {
130             session = openSession();
131 
132             session.delete(journalContentSearch);
133 
134             session.flush();
135 
136             return journalContentSearch;
137         }
138         catch (Exception e) {
139             throw HibernateUtil.processException(e);
140         }
141         finally {
142             closeSession(session);
143 
144             FinderCache.clearCache(JournalContentSearch.class.getName());
145         }
146     }
147 
148     public JournalContentSearch update(
149         JournalContentSearch journalContentSearch) throws SystemException {
150         return update(journalContentSearch, false);
151     }
152 
153     public JournalContentSearch update(
154         JournalContentSearch journalContentSearch, boolean merge)
155         throws SystemException {
156         ModelListener listener = _getListener();
157 
158         boolean isNew = journalContentSearch.isNew();
159 
160         if (listener != null) {
161             if (isNew) {
162                 listener.onBeforeCreate(journalContentSearch);
163             }
164             else {
165                 listener.onBeforeUpdate(journalContentSearch);
166             }
167         }
168 
169         journalContentSearch = updateImpl(journalContentSearch, merge);
170 
171         if (listener != null) {
172             if (isNew) {
173                 listener.onAfterCreate(journalContentSearch);
174             }
175             else {
176                 listener.onAfterUpdate(journalContentSearch);
177             }
178         }
179 
180         return journalContentSearch;
181     }
182 
183     public JournalContentSearch updateImpl(
184         com.liferay.portlet.journal.model.JournalContentSearch journalContentSearch,
185         boolean merge) throws SystemException {
186         Session session = null;
187 
188         try {
189             session = openSession();
190 
191             if (merge) {
192                 session.merge(journalContentSearch);
193             }
194             else {
195                 if (journalContentSearch.isNew()) {
196                     session.save(journalContentSearch);
197                 }
198             }
199 
200             session.flush();
201 
202             journalContentSearch.setNew(false);
203 
204             return journalContentSearch;
205         }
206         catch (Exception e) {
207             throw HibernateUtil.processException(e);
208         }
209         finally {
210             closeSession(session);
211 
212             FinderCache.clearCache(JournalContentSearch.class.getName());
213         }
214     }
215 
216     public JournalContentSearch findByPrimaryKey(long contentSearchId)
217         throws NoSuchContentSearchException, SystemException {
218         JournalContentSearch journalContentSearch = fetchByPrimaryKey(contentSearchId);
219 
220         if (journalContentSearch == null) {
221             if (_log.isWarnEnabled()) {
222                 _log.warn(
223                     "No JournalContentSearch exists with the primary key " +
224                     contentSearchId);
225             }
226 
227             throw new NoSuchContentSearchException(
228                 "No JournalContentSearch exists with the primary key " +
229                 contentSearchId);
230         }
231 
232         return journalContentSearch;
233     }
234 
235     public JournalContentSearch fetchByPrimaryKey(long contentSearchId)
236         throws SystemException {
237         Session session = null;
238 
239         try {
240             session = openSession();
241 
242             return (JournalContentSearch)session.get(JournalContentSearchImpl.class,
243                 new Long(contentSearchId));
244         }
245         catch (Exception e) {
246             throw HibernateUtil.processException(e);
247         }
248         finally {
249             closeSession(session);
250         }
251     }
252 
253     public List findByG_P(long groupId, boolean privateLayout)
254         throws SystemException {
255         boolean finderClassNameCacheEnabled = JournalContentSearchModelImpl.CACHE_ENABLED;
256         String finderClassName = JournalContentSearch.class.getName();
257         String finderMethodName = "findByG_P";
258         String[] finderParams = new String[] {
259                 Long.class.getName(), Boolean.class.getName()
260             };
261         Object[] finderArgs = new Object[] {
262                 new Long(groupId), Boolean.valueOf(privateLayout)
263             };
264 
265         Object result = null;
266 
267         if (finderClassNameCacheEnabled) {
268             result = FinderCache.getResult(finderClassName, finderMethodName,
269                     finderParams, finderArgs, getSessionFactory());
270         }
271 
272         if (result == null) {
273             Session session = null;
274 
275             try {
276                 session = openSession();
277 
278                 StringMaker query = new StringMaker();
279 
280                 query.append(
281                     "FROM com.liferay.portlet.journal.model.JournalContentSearch WHERE ");
282 
283                 query.append("groupId = ?");
284 
285                 query.append(" AND ");
286 
287                 query.append("privateLayout = ?");
288 
289                 query.append(" ");
290 
291                 Query q = session.createQuery(query.toString());
292 
293                 int queryPos = 0;
294 
295                 q.setLong(queryPos++, groupId);
296 
297                 q.setBoolean(queryPos++, privateLayout);
298 
299                 List list = q.list();
300 
301                 FinderCache.putResult(finderClassNameCacheEnabled,
302                     finderClassName, finderMethodName, finderParams,
303                     finderArgs, list);
304 
305                 return list;
306             }
307             catch (Exception e) {
308                 throw HibernateUtil.processException(e);
309             }
310             finally {
311                 closeSession(session);
312             }
313         }
314         else {
315             return (List)result;
316         }
317     }
318 
319     public List findByG_P(long groupId, boolean privateLayout, int begin,
320         int end) throws SystemException {
321         return findByG_P(groupId, privateLayout, begin, end, null);
322     }
323 
324     public List findByG_P(long groupId, boolean privateLayout, int begin,
325         int end, OrderByComparator obc) throws SystemException {
326         boolean finderClassNameCacheEnabled = JournalContentSearchModelImpl.CACHE_ENABLED;
327         String finderClassName = JournalContentSearch.class.getName();
328         String finderMethodName = "findByG_P";
329         String[] finderParams = new String[] {
330                 Long.class.getName(), Boolean.class.getName(),
331                 
332                 "java.lang.Integer", "java.lang.Integer",
333                 "com.liferay.portal.kernel.util.OrderByComparator"
334             };
335         Object[] finderArgs = new Object[] {
336                 new Long(groupId), Boolean.valueOf(privateLayout),
337                 
338                 String.valueOf(begin), String.valueOf(end), String.valueOf(obc)
339             };
340 
341         Object result = null;
342 
343         if (finderClassNameCacheEnabled) {
344             result = FinderCache.getResult(finderClassName, finderMethodName,
345                     finderParams, finderArgs, getSessionFactory());
346         }
347 
348         if (result == null) {
349             Session session = null;
350 
351             try {
352                 session = openSession();
353 
354                 StringMaker query = new StringMaker();
355 
356                 query.append(
357                     "FROM com.liferay.portlet.journal.model.JournalContentSearch WHERE ");
358 
359                 query.append("groupId = ?");
360 
361                 query.append(" AND ");
362 
363                 query.append("privateLayout = ?");
364 
365                 query.append(" ");
366 
367                 if (obc != null) {
368                     query.append("ORDER BY ");
369                     query.append(obc.getOrderBy());
370                 }
371 
372                 Query q = session.createQuery(query.toString());
373 
374                 int queryPos = 0;
375 
376                 q.setLong(queryPos++, groupId);
377 
378                 q.setBoolean(queryPos++, privateLayout);
379 
380                 List list = QueryUtil.list(q, getDialect(), begin, end);
381 
382                 FinderCache.putResult(finderClassNameCacheEnabled,
383                     finderClassName, finderMethodName, finderParams,
384                     finderArgs, list);
385 
386                 return list;
387             }
388             catch (Exception e) {
389                 throw HibernateUtil.processException(e);
390             }
391             finally {
392                 closeSession(session);
393             }
394         }
395         else {
396             return (List)result;
397         }
398     }
399 
400     public JournalContentSearch findByG_P_First(long groupId,
401         boolean privateLayout, OrderByComparator obc)
402         throws NoSuchContentSearchException, SystemException {
403         List list = findByG_P(groupId, privateLayout, 0, 1, obc);
404 
405         if (list.size() == 0) {
406             StringMaker msg = new StringMaker();
407 
408             msg.append("No JournalContentSearch exists with the key {");
409 
410             msg.append("groupId=" + groupId);
411 
412             msg.append(", ");
413             msg.append("privateLayout=" + privateLayout);
414 
415             msg.append(StringPool.CLOSE_CURLY_BRACE);
416 
417             throw new NoSuchContentSearchException(msg.toString());
418         }
419         else {
420             return (JournalContentSearch)list.get(0);
421         }
422     }
423 
424     public JournalContentSearch findByG_P_Last(long groupId,
425         boolean privateLayout, OrderByComparator obc)
426         throws NoSuchContentSearchException, SystemException {
427         int count = countByG_P(groupId, privateLayout);
428 
429         List list = findByG_P(groupId, privateLayout, count - 1, count, obc);
430 
431         if (list.size() == 0) {
432             StringMaker msg = new StringMaker();
433 
434             msg.append("No JournalContentSearch exists with the key {");
435 
436             msg.append("groupId=" + groupId);
437 
438             msg.append(", ");
439             msg.append("privateLayout=" + privateLayout);
440 
441             msg.append(StringPool.CLOSE_CURLY_BRACE);
442 
443             throw new NoSuchContentSearchException(msg.toString());
444         }
445         else {
446             return (JournalContentSearch)list.get(0);
447         }
448     }
449 
450     public JournalContentSearch[] findByG_P_PrevAndNext(long contentSearchId,
451         long groupId, boolean privateLayout, OrderByComparator obc)
452         throws NoSuchContentSearchException, SystemException {
453         JournalContentSearch journalContentSearch = findByPrimaryKey(contentSearchId);
454 
455         int count = countByG_P(groupId, privateLayout);
456 
457         Session session = null;
458 
459         try {
460             session = openSession();
461 
462             StringMaker query = new StringMaker();
463 
464             query.append(
465                 "FROM com.liferay.portlet.journal.model.JournalContentSearch WHERE ");
466 
467             query.append("groupId = ?");
468 
469             query.append(" AND ");
470 
471             query.append("privateLayout = ?");
472 
473             query.append(" ");
474 
475             if (obc != null) {
476                 query.append("ORDER BY ");
477                 query.append(obc.getOrderBy());
478             }
479 
480             Query q = session.createQuery(query.toString());
481 
482             int queryPos = 0;
483 
484             q.setLong(queryPos++, groupId);
485 
486             q.setBoolean(queryPos++, privateLayout);
487 
488             Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
489                     journalContentSearch);
490 
491             JournalContentSearch[] array = new JournalContentSearchImpl[3];
492 
493             array[0] = (JournalContentSearch)objArray[0];
494             array[1] = (JournalContentSearch)objArray[1];
495             array[2] = (JournalContentSearch)objArray[2];
496 
497             return array;
498         }
499         catch (Exception e) {
500             throw HibernateUtil.processException(e);
501         }
502         finally {
503             closeSession(session);
504         }
505     }
506 
507     public List findByG_A(long groupId, String articleId)
508         throws SystemException {
509         boolean finderClassNameCacheEnabled = JournalContentSearchModelImpl.CACHE_ENABLED;
510         String finderClassName = JournalContentSearch.class.getName();
511         String finderMethodName = "findByG_A";
512         String[] finderParams = new String[] {
513                 Long.class.getName(), String.class.getName()
514             };
515         Object[] finderArgs = new Object[] { new Long(groupId), articleId };
516 
517         Object result = null;
518 
519         if (finderClassNameCacheEnabled) {
520             result = FinderCache.getResult(finderClassName, finderMethodName,
521                     finderParams, finderArgs, getSessionFactory());
522         }
523 
524         if (result == null) {
525             Session session = null;
526 
527             try {
528                 session = openSession();
529 
530                 StringMaker query = new StringMaker();
531 
532                 query.append(
533                     "FROM com.liferay.portlet.journal.model.JournalContentSearch WHERE ");
534 
535                 query.append("groupId = ?");
536 
537                 query.append(" AND ");
538 
539                 if (articleId == null) {
540                     query.append("articleId IS NULL");
541                 }
542                 else {
543                     query.append("articleId = ?");
544                 }
545 
546                 query.append(" ");
547 
548                 Query q = session.createQuery(query.toString());
549 
550                 int queryPos = 0;
551 
552                 q.setLong(queryPos++, groupId);
553 
554                 if (articleId != null) {
555                     q.setString(queryPos++, articleId);
556                 }
557 
558                 List list = q.list();
559 
560                 FinderCache.putResult(finderClassNameCacheEnabled,
561                     finderClassName, finderMethodName, finderParams,
562                     finderArgs, list);
563 
564                 return list;
565             }
566             catch (Exception e) {
567                 throw HibernateUtil.processException(e);
568             }
569             finally {
570                 closeSession(session);
571             }
572         }
573         else {
574             return (List)result;
575         }
576     }
577 
578     public List findByG_A(long groupId, String articleId, int begin, int end)
579         throws SystemException {
580         return findByG_A(groupId, articleId, begin, end, null);
581     }
582 
583     public List findByG_A(long groupId, String articleId, int begin, int end,
584         OrderByComparator obc) throws SystemException {
585         boolean finderClassNameCacheEnabled = JournalContentSearchModelImpl.CACHE_ENABLED;
586         String finderClassName = JournalContentSearch.class.getName();
587         String finderMethodName = "findByG_A";
588         String[] finderParams = new String[] {
589                 Long.class.getName(), String.class.getName(),
590                 
591                 "java.lang.Integer", "java.lang.Integer",
592                 "com.liferay.portal.kernel.util.OrderByComparator"
593             };
594         Object[] finderArgs = new Object[] {
595                 new Long(groupId),
596                 
597                 articleId,
598                 
599                 String.valueOf(begin), String.valueOf(end), String.valueOf(obc)
600             };
601 
602         Object result = null;
603 
604         if (finderClassNameCacheEnabled) {
605             result = FinderCache.getResult(finderClassName, finderMethodName,
606                     finderParams, finderArgs, getSessionFactory());
607         }
608 
609         if (result == null) {
610             Session session = null;
611 
612             try {
613                 session = openSession();
614 
615                 StringMaker query = new StringMaker();
616 
617                 query.append(
618                     "FROM com.liferay.portlet.journal.model.JournalContentSearch WHERE ");
619 
620                 query.append("groupId = ?");
621 
622                 query.append(" AND ");
623 
624                 if (articleId == null) {
625                     query.append("articleId IS NULL");
626                 }
627                 else {
628                     query.append("articleId = ?");
629                 }
630 
631                 query.append(" ");
632 
633                 if (obc != null) {
634                     query.append("ORDER BY ");
635                     query.append(obc.getOrderBy());
636                 }
637 
638                 Query q = session.createQuery(query.toString());
639 
640                 int queryPos = 0;
641 
642                 q.setLong(queryPos++, groupId);
643 
644                 if (articleId != null) {
645                     q.setString(queryPos++, articleId);
646                 }
647 
648                 List list = QueryUtil.list(q, getDialect(), begin, end);
649 
650                 FinderCache.putResult(finderClassNameCacheEnabled,
651                     finderClassName, finderMethodName, finderParams,
652                     finderArgs, list);
653 
654                 return list;
655             }
656             catch (Exception e) {
657                 throw HibernateUtil.processException(e);
658             }
659             finally {
660                 closeSession(session);
661             }
662         }
663         else {
664             return (List)result;
665         }
666     }
667 
668     public JournalContentSearch findByG_A_First(long groupId, String articleId,
669         OrderByComparator obc)
670         throws NoSuchContentSearchException, SystemException {
671         List list = findByG_A(groupId, articleId, 0, 1, obc);
672 
673         if (list.size() == 0) {
674             StringMaker msg = new StringMaker();
675 
676             msg.append("No JournalContentSearch exists with the key {");
677 
678             msg.append("groupId=" + groupId);
679 
680             msg.append(", ");
681             msg.append("articleId=" + articleId);
682 
683             msg.append(StringPool.CLOSE_CURLY_BRACE);
684 
685             throw new NoSuchContentSearchException(msg.toString());
686         }
687         else {
688             return (JournalContentSearch)list.get(0);
689         }
690     }
691 
692     public JournalContentSearch findByG_A_Last(long groupId, String articleId,
693         OrderByComparator obc)
694         throws NoSuchContentSearchException, SystemException {
695         int count = countByG_A(groupId, articleId);
696 
697         List list = findByG_A(groupId, articleId, count - 1, count, obc);
698 
699         if (list.size() == 0) {
700             StringMaker msg = new StringMaker();
701 
702             msg.append("No JournalContentSearch exists with the key {");
703 
704             msg.append("groupId=" + groupId);
705 
706             msg.append(", ");
707             msg.append("articleId=" + articleId);
708 
709             msg.append(StringPool.CLOSE_CURLY_BRACE);
710 
711             throw new NoSuchContentSearchException(msg.toString());
712         }
713         else {
714             return (JournalContentSearch)list.get(0);
715         }
716     }
717 
718     public JournalContentSearch[] findByG_A_PrevAndNext(long contentSearchId,
719         long groupId, String articleId, OrderByComparator obc)
720         throws NoSuchContentSearchException, SystemException {
721         JournalContentSearch journalContentSearch = findByPrimaryKey(contentSearchId);
722 
723         int count = countByG_A(groupId, articleId);
724 
725         Session session = null;
726 
727         try {
728             session = openSession();
729 
730             StringMaker query = new StringMaker();
731 
732             query.append(
733                 "FROM com.liferay.portlet.journal.model.JournalContentSearch WHERE ");
734 
735             query.append("groupId = ?");
736 
737             query.append(" AND ");
738 
739             if (articleId == null) {
740                 query.append("articleId IS NULL");
741             }
742             else {
743                 query.append("articleId = ?");
744             }
745 
746             query.append(" ");
747 
748             if (obc != null) {
749                 query.append("ORDER BY ");
750                 query.append(obc.getOrderBy());
751             }
752 
753             Query q = session.createQuery(query.toString());
754 
755             int queryPos = 0;
756 
757             q.setLong(queryPos++, groupId);
758 
759             if (articleId != null) {
760                 q.setString(queryPos++, articleId);
761             }
762 
763             Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
764                     journalContentSearch);
765 
766             JournalContentSearch[] array = new JournalContentSearchImpl[3];
767 
768             array[0] = (JournalContentSearch)objArray[0];
769             array[1] = (JournalContentSearch)objArray[1];
770             array[2] = (JournalContentSearch)objArray[2];
771 
772             return array;
773         }
774         catch (Exception e) {
775             throw HibernateUtil.processException(e);
776         }
777         finally {
778             closeSession(session);
779         }
780     }
781 
782     public List findByG_P_L(long groupId, boolean privateLayout, long layoutId)
783         throws SystemException {
784         boolean finderClassNameCacheEnabled = JournalContentSearchModelImpl.CACHE_ENABLED;
785         String finderClassName = JournalContentSearch.class.getName();
786         String finderMethodName = "findByG_P_L";
787         String[] finderParams = new String[] {
788                 Long.class.getName(), Boolean.class.getName(),
789                 Long.class.getName()
790             };
791         Object[] finderArgs = new Object[] {
792                 new Long(groupId), Boolean.valueOf(privateLayout),
793                 new Long(layoutId)
794             };
795 
796         Object result = null;
797 
798         if (finderClassNameCacheEnabled) {
799             result = FinderCache.getResult(finderClassName, finderMethodName,
800                     finderParams, finderArgs, getSessionFactory());
801         }
802 
803         if (result == null) {
804             Session session = null;
805 
806             try {
807                 session = openSession();
808 
809                 StringMaker query = new StringMaker();
810 
811                 query.append(
812                     "FROM com.liferay.portlet.journal.model.JournalContentSearch WHERE ");
813 
814                 query.append("groupId = ?");
815 
816                 query.append(" AND ");
817 
818                 query.append("privateLayout = ?");
819 
820                 query.append(" AND ");
821 
822                 query.append("layoutId = ?");
823 
824                 query.append(" ");
825 
826                 Query q = session.createQuery(query.toString());
827 
828                 int queryPos = 0;
829 
830                 q.setLong(queryPos++, groupId);
831 
832                 q.setBoolean(queryPos++, privateLayout);
833 
834                 q.setLong(queryPos++, layoutId);
835 
836                 List list = q.list();
837 
838                 FinderCache.putResult(finderClassNameCacheEnabled,
839                     finderClassName, finderMethodName, finderParams,
840                     finderArgs, list);
841 
842                 return list;
843             }
844             catch (Exception e) {
845                 throw HibernateUtil.processException(e);
846             }
847             finally {
848                 closeSession(session);
849             }
850         }
851         else {
852             return (List)result;
853         }
854     }
855 
856     public List findByG_P_L(long groupId, boolean privateLayout, long layoutId,
857         int begin, int end) throws SystemException {
858         return findByG_P_L(groupId, privateLayout, layoutId, begin, end, null);
859     }
860 
861     public List findByG_P_L(long groupId, boolean privateLayout, long layoutId,
862         int begin, int end, OrderByComparator obc) throws SystemException {
863         boolean finderClassNameCacheEnabled = JournalContentSearchModelImpl.CACHE_ENABLED;
864         String finderClassName = JournalContentSearch.class.getName();
865         String finderMethodName = "findByG_P_L";
866         String[] finderParams = new String[] {
867                 Long.class.getName(), Boolean.class.getName(),
868                 Long.class.getName(),
869                 
870                 "java.lang.Integer", "java.lang.Integer",
871                 "com.liferay.portal.kernel.util.OrderByComparator"
872             };
873         Object[] finderArgs = new Object[] {
874                 new Long(groupId), Boolean.valueOf(privateLayout),
875                 new Long(layoutId),
876                 
877                 String.valueOf(begin), String.valueOf(end), String.valueOf(obc)
878             };
879 
880         Object result = null;
881 
882         if (finderClassNameCacheEnabled) {
883             result = FinderCache.getResult(finderClassName, finderMethodName,
884                     finderParams, finderArgs, getSessionFactory());
885         }
886 
887         if (result == null) {
888             Session session = null;
889 
890             try {
891                 session = openSession();
892 
893                 StringMaker query = new StringMaker();
894 
895                 query.append(
896                     "FROM com.liferay.portlet.journal.model.JournalContentSearch WHERE ");
897 
898                 query.append("groupId = ?");
899 
900                 query.append(" AND ");
901 
902                 query.append("privateLayout = ?");
903 
904                 query.append(" AND ");
905 
906                 query.append("layoutId = ?");
907 
908                 query.append(" ");
909 
910                 if (obc != null) {
911                     query.append("ORDER BY ");
912                     query.append(obc.getOrderBy());
913                 }
914 
915                 Query q = session.createQuery(query.toString());
916 
917                 int queryPos = 0;
918 
919                 q.setLong(queryPos++, groupId);
920 
921                 q.setBoolean(queryPos++, privateLayout);
922 
923                 q.setLong(queryPos++, layoutId);
924 
925                 List list = QueryUtil.list(q, getDialect(), begin, end);
926 
927                 FinderCache.putResult(finderClassNameCacheEnabled,
928                     finderClassName, finderMethodName, finderParams,
929                     finderArgs, list);
930 
931                 return list;
932             }
933             catch (Exception e) {
934                 throw HibernateUtil.processException(e);
935             }
936             finally {
937                 closeSession(session);
938             }
939         }
940         else {
941             return (List)result;
942         }
943     }
944 
945     public JournalContentSearch findByG_P_L_First(long groupId,
946         boolean privateLayout, long layoutId, OrderByComparator obc)
947         throws NoSuchContentSearchException, SystemException {
948         List list = findByG_P_L(groupId, privateLayout, layoutId, 0, 1, obc);
949 
950         if (list.size() == 0) {
951             StringMaker msg = new StringMaker();
952 
953             msg.append("No JournalContentSearch exists with the key {");
954 
955             msg.append("groupId=" + groupId);
956 
957             msg.append(", ");
958             msg.append("privateLayout=" + privateLayout);
959 
960             msg.append(", ");
961             msg.append("layoutId=" + layoutId);
962 
963             msg.append(StringPool.CLOSE_CURLY_BRACE);
964 
965             throw new NoSuchContentSearchException(msg.toString());
966         }
967         else {
968             return (JournalContentSearch)list.get(0);
969         }
970     }
971 
972     public JournalContentSearch findByG_P_L_Last(long groupId,
973         boolean privateLayout, long layoutId, OrderByComparator obc)
974         throws NoSuchContentSearchException, SystemException {
975         int count = countByG_P_L(groupId, privateLayout, layoutId);
976 
977         List list = findByG_P_L(groupId, privateLayout, layoutId, count - 1,
978                 count, obc);
979 
980         if (list.size() == 0) {
981             StringMaker msg = new StringMaker();
982 
983             msg.append("No JournalContentSearch exists with the key {");
984 
985             msg.append("groupId=" + groupId);
986 
987             msg.append(", ");
988             msg.append("privateLayout=" + privateLayout);
989 
990             msg.append(", ");
991             msg.append("layoutId=" + layoutId);
992 
993             msg.append(StringPool.CLOSE_CURLY_BRACE);
994 
995             throw new NoSuchContentSearchException(msg.toString());
996         }
997         else {
998             return (JournalContentSearch)list.get(0);
999         }
1000    }
1001
1002    public JournalContentSearch[] findByG_P_L_PrevAndNext(
1003        long contentSearchId, long groupId, boolean privateLayout,
1004        long layoutId, OrderByComparator obc)
1005        throws NoSuchContentSearchException, SystemException {
1006        JournalContentSearch journalContentSearch = findByPrimaryKey(contentSearchId);
1007
1008        int count = countByG_P_L(groupId, privateLayout, layoutId);
1009
1010        Session session = null;
1011
1012        try {
1013            session = openSession();
1014
1015            StringMaker query = new StringMaker();
1016
1017            query.append(
1018                "FROM com.liferay.portlet.journal.model.JournalContentSearch WHERE ");
1019
1020            query.append("groupId = ?");
1021
1022            query.append(" AND ");
1023
1024            query.append("privateLayout = ?");
1025
1026            query.append(" AND ");
1027
1028            query.append("layoutId = ?");
1029
1030            query.append(" ");
1031
1032            if (obc != null) {
1033                query.append("ORDER BY ");
1034                query.append(obc.getOrderBy());
1035            }
1036
1037            Query q = session.createQuery(query.toString());
1038
1039            int queryPos = 0;
1040
1041            q.setLong(queryPos++, groupId);
1042
1043            q.setBoolean(queryPos++, privateLayout);
1044
1045            q.setLong(queryPos++, layoutId);
1046
1047            Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
1048                    journalContentSearch);
1049
1050            JournalContentSearch[] array = new JournalContentSearchImpl[3];
1051
1052            array[0] = (JournalContentSearch)objArray[0];
1053            array[1] = (JournalContentSearch)objArray[1];
1054            array[2] = (JournalContentSearch)objArray[2];
1055
1056            return array;
1057        }
1058        catch (Exception e) {
1059            throw HibernateUtil.processException(e);
1060        }
1061        finally {
1062            closeSession(session);
1063        }
1064    }
1065
1066    public List findByG_P_A(long groupId, boolean privateLayout,
1067        String articleId) throws SystemException {
1068        boolean finderClassNameCacheEnabled = JournalContentSearchModelImpl.CACHE_ENABLED;
1069        String finderClassName = JournalContentSearch.class.getName();
1070        String finderMethodName = "findByG_P_A";
1071        String[] finderParams = new String[] {
1072                Long.class.getName(), Boolean.class.getName(),
1073                String.class.getName()
1074            };
1075        Object[] finderArgs = new Object[] {
1076                new Long(groupId), Boolean.valueOf(privateLayout),
1077                
1078                articleId
1079            };
1080
1081        Object result = null;
1082
1083        if (finderClassNameCacheEnabled) {
1084            result = FinderCache.getResult(finderClassName, finderMethodName,
1085                    finderParams, finderArgs, getSessionFactory());
1086        }
1087
1088        if (result == null) {
1089            Session session = null;
1090
1091            try {
1092                session = openSession();
1093
1094                StringMaker query = new StringMaker();
1095
1096                query.append(
1097                    "FROM com.liferay.portlet.journal.model.JournalContentSearch WHERE ");
1098
1099                query.append("groupId = ?");
1100
1101                query.append(" AND ");
1102
1103                query.append("privateLayout = ?");
1104
1105                query.append(" AND ");
1106
1107                if (articleId == null) {
1108                    query.append("articleId IS NULL");
1109                }
1110                else {
1111                    query.append("articleId = ?");
1112                }
1113
1114                query.append(" ");
1115
1116                Query q = session.createQuery(query.toString());
1117
1118                int queryPos = 0;
1119
1120                q.setLong(queryPos++, groupId);
1121
1122                q.setBoolean(queryPos++, privateLayout);
1123
1124                if (articleId != null) {
1125                    q.setString(queryPos++, articleId);
1126                }
1127
1128                List list = q.list();
1129
1130                FinderCache.putResult(finderClassNameCacheEnabled,
1131                    finderClassName, finderMethodName, finderParams,
1132                    finderArgs, list);
1133
1134                return list;
1135            }
1136            catch (Exception e) {
1137                throw HibernateUtil.processException(e);
1138            }
1139            finally {
1140                closeSession(session);
1141            }
1142        }
1143        else {
1144            return (List)result;
1145        }
1146    }
1147
1148    public List findByG_P_A(long groupId, boolean privateLayout,
1149        String articleId, int begin, int end) throws SystemException {
1150        return findByG_P_A(groupId, privateLayout, articleId, begin, end, null);
1151    }
1152
1153    public List findByG_P_A(long groupId, boolean privateLayout,
1154        String articleId, int begin, int end, OrderByComparator obc)
1155        throws SystemException {
1156        boolean finderClassNameCacheEnabled = JournalContentSearchModelImpl.CACHE_ENABLED;
1157        String finderClassName = JournalContentSearch.class.getName();
1158        String finderMethodName = "findByG_P_A";
1159        String[] finderParams = new String[] {
1160                Long.class.getName(), Boolean.class.getName(),
1161                String.class.getName(),
1162                
1163                "java.lang.Integer", "java.lang.Integer",
1164                "com.liferay.portal.kernel.util.OrderByComparator"
1165            };
1166        Object[] finderArgs = new Object[] {
1167                new Long(groupId), Boolean.valueOf(privateLayout),
1168                
1169                articleId,
1170                
1171                String.valueOf(begin), String.valueOf(end), String.valueOf(obc)
1172            };
1173
1174        Object result = null;
1175
1176        if (finderClassNameCacheEnabled) {
1177            result = FinderCache.getResult(finderClassName, finderMethodName,
1178                    finderParams, finderArgs, getSessionFactory());
1179        }
1180
1181        if (result == null) {
1182            Session session = null;
1183
1184            try {
1185                session = openSession();
1186
1187                StringMaker query = new StringMaker();
1188
1189                query.append(
1190                    "FROM com.liferay.portlet.journal.model.JournalContentSearch WHERE ");
1191
1192                query.append("groupId = ?");
1193
1194                query.append(" AND ");
1195
1196                query.append("privateLayout = ?");
1197
1198                query.append(" AND ");
1199
1200                if (articleId == null) {
1201                    query.append("articleId IS NULL");
1202                }
1203                else {
1204                    query.append("articleId = ?");
1205                }
1206
1207                query.append(" ");
1208
1209                if (obc != null) {
1210                    query.append("ORDER BY ");
1211                    query.append(obc.getOrderBy());
1212                }
1213
1214                Query q = session.createQuery(query.toString());
1215
1216                int queryPos = 0;
1217
1218                q.setLong(queryPos++, groupId);
1219
1220                q.setBoolean(queryPos++, privateLayout);
1221
1222                if (articleId != null) {
1223                    q.setString(queryPos++, articleId);
1224                }
1225
1226                List list = QueryUtil.list(q, getDialect(), begin, end);
1227
1228                FinderCache.putResult(finderClassNameCacheEnabled,
1229                    finderClassName, finderMethodName, finderParams,
1230                    finderArgs, list);
1231
1232                return list;
1233            }
1234            catch (Exception e) {
1235                throw HibernateUtil.processException(e);
1236            }
1237            finally {
1238                closeSession(session);
1239            }
1240        }
1241        else {
1242            return (List)result;
1243        }
1244    }
1245
1246    public JournalContentSearch findByG_P_A_First(long groupId,
1247        boolean privateLayout, String articleId, OrderByComparator obc)
1248        throws NoSuchContentSearchException, SystemException {
1249        List list = findByG_P_A(groupId, privateLayout, articleId, 0, 1, obc);
1250
1251        if (list.size() == 0) {
1252            StringMaker msg = new StringMaker();
1253
1254            msg.append("No JournalContentSearch exists with the key {");
1255
1256            msg.append("groupId=" + groupId);
1257
1258            msg.append(", ");
1259            msg.append("privateLayout=" + privateLayout);
1260
1261            msg.append(", ");
1262            msg.append("articleId=" + articleId);
1263
1264            msg.append(StringPool.CLOSE_CURLY_BRACE);
1265
1266            throw new NoSuchContentSearchException(msg.toString());
1267        }
1268        else {
1269            return (JournalContentSearch)list.get(0);
1270        }
1271    }
1272
1273    public JournalContentSearch findByG_P_A_Last(long groupId,
1274        boolean privateLayout, String articleId, OrderByComparator obc)
1275        throws NoSuchContentSearchException, SystemException {
1276        int count = countByG_P_A(groupId, privateLayout, articleId);
1277
1278        List list = findByG_P_A(groupId, privateLayout, articleId, count - 1,
1279                count, obc);
1280
1281        if (list.size() == 0) {
1282            StringMaker msg = new StringMaker();
1283
1284            msg.append("No JournalContentSearch exists with the key {");
1285
1286            msg.append("groupId=" + groupId);
1287
1288            msg.append(", ");
1289            msg.append("privateLayout=" + privateLayout);
1290
1291            msg.append(", ");
1292            msg.append("articleId=" + articleId);
1293
1294            msg.append(StringPool.CLOSE_CURLY_BRACE);
1295
1296            throw new NoSuchContentSearchException(msg.toString());
1297        }
1298        else {
1299            return (JournalContentSearch)list.get(0);
1300        }
1301    }
1302
1303    public JournalContentSearch[] findByG_P_A_PrevAndNext(
1304        long contentSearchId, long groupId, boolean privateLayout,
1305        String articleId, OrderByComparator obc)
1306        throws NoSuchContentSearchException, SystemException {
1307        JournalContentSearch journalContentSearch = findByPrimaryKey(contentSearchId);
1308
1309        int count = countByG_P_A(groupId, privateLayout, articleId);
1310
1311        Session session = null;
1312
1313        try {
1314            session = openSession();
1315
1316            StringMaker query = new StringMaker();
1317
1318            query.append(
1319                "FROM com.liferay.portlet.journal.model.JournalContentSearch WHERE ");
1320
1321            query.append("groupId = ?");
1322
1323            query.append(" AND ");
1324
1325            query.append("privateLayout = ?");
1326
1327            query.append(" AND ");
1328
1329            if (articleId == null) {
1330                query.append("articleId IS NULL");
1331            }
1332            else {
1333                query.append("articleId = ?");
1334            }
1335
1336            query.append(" ");
1337
1338            if (obc != null) {
1339                query.append("ORDER BY ");
1340                query.append(obc.getOrderBy());
1341            }
1342
1343            Query q = session.createQuery(query.toString());
1344
1345            int queryPos = 0;
1346
1347            q.setLong(queryPos++, groupId);
1348
1349            q.setBoolean(queryPos++, privateLayout);
1350
1351            if (articleId != null) {
1352                q.setString(queryPos++, articleId);
1353            }
1354
1355            Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
1356                    journalContentSearch);
1357
1358            JournalContentSearch[] array = new JournalContentSearchImpl[3];
1359
1360            array[0] = (JournalContentSearch)objArray[0];
1361            array[1] = (JournalContentSearch)objArray[1];
1362            array[2] = (JournalContentSearch)objArray[2];
1363
1364            return array;
1365        }
1366        catch (Exception e) {
1367            throw HibernateUtil.processException(e);
1368        }
1369        finally {
1370            closeSession(session);
1371        }
1372    }
1373
1374    public List findByG_P_L_P(long groupId, boolean privateLayout,
1375        long layoutId, String portletId) throws SystemException {
1376        boolean finderClassNameCacheEnabled = JournalContentSearchModelImpl.CACHE_ENABLED;
1377        String finderClassName = JournalContentSearch.class.getName();
1378        String finderMethodName = "findByG_P_L_P";
1379        String[] finderParams = new String[] {
1380                Long.class.getName(), Boolean.class.getName(),
1381                Long.class.getName(), String.class.getName()
1382            };
1383        Object[] finderArgs = new Object[] {
1384                new Long(groupId), Boolean.valueOf(privateLayout),
1385                new Long(layoutId),
1386                
1387                portletId
1388            };
1389
1390        Object result = null;
1391
1392        if (finderClassNameCacheEnabled) {
1393            result = FinderCache.getResult(finderClassName, finderMethodName,
1394                    finderParams, finderArgs, getSessionFactory());
1395        }
1396
1397        if (result == null) {
1398            Session session = null;
1399
1400            try {
1401                session = openSession();
1402
1403                StringMaker query = new StringMaker();
1404
1405                query.append(
1406                    "FROM com.liferay.portlet.journal.model.JournalContentSearch WHERE ");
1407
1408                query.append("groupId = ?");
1409
1410                query.append(" AND ");
1411
1412                query.append("privateLayout = ?");
1413
1414                query.append(" AND ");
1415
1416                query.append("layoutId = ?");
1417
1418                query.append(" AND ");
1419
1420                if (portletId == null) {
1421                    query.append("portletId IS NULL");
1422                }
1423                else {
1424                    query.append("portletId = ?");
1425                }
1426
1427                query.append(" ");
1428
1429                Query q = session.createQuery(query.toString());
1430
1431                int queryPos = 0;
1432
1433                q.setLong(queryPos++, groupId);
1434
1435                q.setBoolean(queryPos++, privateLayout);
1436
1437                q.setLong(queryPos++, layoutId);
1438
1439                if (portletId != null) {
1440                    q.setString(queryPos++, portletId);
1441                }
1442
1443                List list = q.list();
1444
1445                FinderCache.putResult(finderClassNameCacheEnabled,
1446                    finderClassName, finderMethodName, finderParams,
1447                    finderArgs, list);
1448
1449                return list;
1450            }
1451            catch (Exception e) {
1452                throw HibernateUtil.processException(e);
1453            }
1454            finally {
1455                closeSession(session);
1456            }
1457        }
1458        else {
1459            return (List)result;
1460        }
1461    }
1462
1463    public List findByG_P_L_P(long groupId, boolean privateLayout,
1464        long layoutId, String portletId, int begin, int end)
1465        throws SystemException {
1466        return findByG_P_L_P(groupId, privateLayout, layoutId, portletId,
1467            begin, end, null);
1468    }
1469
1470    public List findByG_P_L_P(long groupId, boolean privateLayout,
1471        long layoutId, String portletId, int begin, int end,
1472        OrderByComparator obc) throws SystemException {
1473        boolean finderClassNameCacheEnabled = JournalContentSearchModelImpl.CACHE_ENABLED;
1474        String finderClassName = JournalContentSearch.class.getName();
1475        String finderMethodName = "findByG_P_L_P";
1476        String[] finderParams = new String[] {
1477                Long.class.getName(), Boolean.class.getName(),
1478                Long.class.getName(), String.class.getName(),
1479                
1480                "java.lang.Integer", "java.lang.Integer",
1481                "com.liferay.portal.kernel.util.OrderByComparator"
1482            };
1483        Object[] finderArgs = new Object[] {
1484                new Long(groupId), Boolean.valueOf(privateLayout),
1485                new Long(layoutId),
1486                
1487                portletId,
1488                
1489                String.valueOf(begin), String.valueOf(end), String.valueOf(obc)
1490            };
1491
1492        Object result = null;
1493
1494        if (finderClassNameCacheEnabled) {
1495            result = FinderCache.getResult(finderClassName, finderMethodName,
1496                    finderParams, finderArgs, getSessionFactory());
1497        }
1498
1499        if (result == null) {
1500            Session session = null;
1501
1502            try {
1503                session = openSession();
1504
1505                StringMaker query = new StringMaker();
1506
1507                query.append(
1508                    "FROM com.liferay.portlet.journal.model.JournalContentSearch WHERE ");
1509
1510                query.append("groupId = ?");
1511
1512                query.append(" AND ");
1513
1514                query.append("privateLayout = ?");
1515
1516                query.append(" AND ");
1517
1518                query.append("layoutId = ?");
1519
1520                query.append(" AND ");
1521
1522                if (portletId == null) {
1523                    query.append("portletId IS NULL");
1524                }
1525                else {
1526                    query.append("portletId = ?");
1527                }
1528
1529                query.append(" ");
1530
1531                if (obc != null) {
1532                    query.append("ORDER BY ");
1533                    query.append(obc.getOrderBy());
1534                }
1535
1536                Query q = session.createQuery(query.toString());
1537
1538                int queryPos = 0;
1539
1540                q.setLong(queryPos++, groupId);
1541
1542                q.setBoolean(queryPos++, privateLayout);
1543
1544                q.setLong(queryPos++, layoutId);
1545
1546                if (portletId != null) {
1547                    q.setString(queryPos++, portletId);
1548                }
1549
1550                List list = QueryUtil.list(q, getDialect(), begin, end);
1551
1552                FinderCache.putResult(finderClassNameCacheEnabled,
1553                    finderClassName, finderMethodName, finderParams,
1554                    finderArgs, list);
1555
1556                return list;
1557            }
1558            catch (Exception e) {
1559                throw HibernateUtil.processException(e);
1560            }
1561            finally {
1562                closeSession(session);
1563            }
1564        }
1565        else {
1566            return (List)result;
1567        }
1568    }
1569
1570    public JournalContentSearch findByG_P_L_P_First(long groupId,
1571        boolean privateLayout, long layoutId, String portletId,
1572        OrderByComparator obc)
1573        throws NoSuchContentSearchException, SystemException {
1574        List list = findByG_P_L_P(groupId, privateLayout, layoutId, portletId,
1575                0, 1, obc);
1576
1577        if (list.size() == 0) {
1578            StringMaker msg = new StringMaker();
1579
1580            msg.append("No JournalContentSearch exists with the key {");
1581
1582            msg.append("groupId=" + groupId);
1583
1584            msg.append(", ");
1585            msg.append("privateLayout=" + privateLayout);
1586
1587            msg.append(", ");
1588            msg.append("layoutId=" + layoutId);
1589
1590            msg.append(", ");
1591            msg.append("portletId=" + portletId);
1592
1593            msg.append(StringPool.CLOSE_CURLY_BRACE);
1594
1595            throw new NoSuchContentSearchException(msg.toString());
1596        }
1597        else {
1598            return (JournalContentSearch)list.get(0);
1599        }
1600    }
1601
1602    public JournalContentSearch findByG_P_L_P_Last(long groupId,
1603        boolean privateLayout, long layoutId, String portletId,
1604        OrderByComparator obc)
1605        throws NoSuchContentSearchException, SystemException {
1606        int count = countByG_P_L_P(groupId, privateLayout, layoutId, portletId);
1607
1608        List list = findByG_P_L_P(groupId, privateLayout, layoutId, portletId,
1609                count - 1, count, obc);
1610
1611        if (list.size() == 0) {
1612            StringMaker msg = new StringMaker();
1613
1614            msg.append("No JournalContentSearch exists with the key {");
1615
1616            msg.append("groupId=" + groupId);
1617
1618            msg.append(", ");
1619            msg.append("privateLayout=" + privateLayout);
1620
1621            msg.append(", ");
1622            msg.append("layoutId=" + layoutId);
1623
1624            msg.append(", ");
1625            msg.append("portletId=" + portletId);
1626
1627            msg.append(StringPool.CLOSE_CURLY_BRACE);
1628
1629            throw new NoSuchContentSearchException(msg.toString());
1630        }
1631        else {
1632            return (JournalContentSearch)list.get(0);
1633        }
1634    }
1635
1636    public JournalContentSearch[] findByG_P_L_P_PrevAndNext(
1637        long contentSearchId, long groupId, boolean privateLayout,
1638        long layoutId, String portletId, OrderByComparator obc)
1639        throws NoSuchContentSearchException, SystemException {
1640        JournalContentSearch journalContentSearch = findByPrimaryKey(contentSearchId);
1641
1642        int count = countByG_P_L_P(groupId, privateLayout, layoutId, portletId);
1643
1644        Session session = null;
1645
1646        try {
1647            session = openSession();
1648
1649            StringMaker query = new StringMaker();
1650
1651            query.append(
1652                "FROM com.liferay.portlet.journal.model.JournalContentSearch WHERE ");
1653
1654            query.append("groupId = ?");
1655
1656            query.append(" AND ");
1657
1658            query.append("privateLayout = ?");
1659
1660            query.append(" AND ");
1661
1662            query.append("layoutId = ?");
1663
1664            query.append(" AND ");
1665
1666            if (portletId == null) {
1667                query.append("portletId IS NULL");
1668            }
1669            else {
1670                query.append("portletId = ?");
1671            }
1672
1673            query.append(" ");
1674
1675            if (obc != null) {
1676                query.append("ORDER BY ");
1677                query.append(obc.getOrderBy());
1678            }
1679
1680            Query q = session.createQuery(query.toString());
1681
1682            int queryPos = 0;
1683
1684            q.setLong(queryPos++, groupId);
1685
1686            q.setBoolean(queryPos++, privateLayout);
1687
1688            q.setLong(queryPos++, layoutId);
1689
1690            if (portletId != null) {
1691                q.setString(queryPos++, portletId);
1692            }
1693
1694            Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
1695                    journalContentSearch);
1696
1697            JournalContentSearch[] array = new JournalContentSearchImpl[3];
1698
1699            array[0] = (JournalContentSearch)objArray[0];
1700            array[1] = (JournalContentSearch)objArray[1];
1701            array[2] = (JournalContentSearch)objArray[2];
1702
1703            return array;
1704        }
1705        catch (Exception e) {
1706            throw HibernateUtil.processException(e);
1707        }
1708        finally {
1709            closeSession(session);
1710        }
1711    }
1712
1713    public JournalContentSearch findByG_P_L_P_A(long groupId,
1714        boolean privateLayout, long layoutId, String portletId, String articleId)
1715        throws NoSuchContentSearchException, SystemException {
1716        JournalContentSearch journalContentSearch = fetchByG_P_L_P_A(groupId,
1717                privateLayout, layoutId, portletId, articleId);
1718
1719        if (journalContentSearch == null) {
1720            StringMaker msg = new StringMaker();
1721
1722            msg.append("No JournalContentSearch exists with the key {");
1723
1724            msg.append("groupId=" + groupId);
1725
1726            msg.append(", ");
1727            msg.append("privateLayout=" + privateLayout);
1728
1729            msg.append(", ");
1730            msg.append("layoutId=" + layoutId);
1731
1732            msg.append(", ");
1733            msg.append("portletId=" + portletId);
1734
1735            msg.append(", ");
1736            msg.append("articleId=" + articleId);
1737
1738            msg.append(StringPool.CLOSE_CURLY_BRACE);
1739
1740            if (_log.isWarnEnabled()) {
1741                _log.warn(msg.toString());
1742            }
1743
1744            throw new NoSuchContentSearchException(msg.toString());
1745        }
1746
1747        return journalContentSearch;
1748    }
1749
1750    public JournalContentSearch fetchByG_P_L_P_A(long groupId,
1751        boolean privateLayout, long layoutId, String portletId, String articleId)
1752        throws SystemException {
1753        boolean finderClassNameCacheEnabled = JournalContentSearchModelImpl.CACHE_ENABLED;
1754        String finderClassName = JournalContentSearch.class.getName();
1755        String finderMethodName = "fetchByG_P_L_P_A";
1756        String[] finderParams = new String[] {
1757                Long.class.getName(), Boolean.class.getName(),
1758                Long.class.getName(), String.class.getName(),
1759                String.class.getName()
1760            };
1761        Object[] finderArgs = new Object[] {
1762                new Long(groupId), Boolean.valueOf(privateLayout),
1763                new Long(layoutId),
1764                
1765                portletId,
1766                
1767                articleId
1768            };
1769
1770        Object result = null;
1771
1772        if (finderClassNameCacheEnabled) {
1773            result = FinderCache.getResult(finderClassName, finderMethodName,
1774                    finderParams, finderArgs, getSessionFactory());
1775        }
1776
1777        if (result == null) {
1778            Session session = null;
1779
1780            try {
1781                session = openSession();
1782
1783                StringMaker query = new StringMaker();
1784
1785                query.append(
1786                    "FROM com.liferay.portlet.journal.model.JournalContentSearch WHERE ");
1787
1788                query.append("groupId = ?");
1789
1790                query.append(" AND ");
1791
1792                query.append("privateLayout = ?");
1793
1794                query.append(" AND ");
1795
1796                query.append("layoutId = ?");
1797
1798                query.append(" AND ");
1799
1800                if (portletId == null) {
1801                    query.append("portletId IS NULL");
1802                }
1803                else {
1804                    query.append("portletId = ?");
1805                }
1806
1807                query.append(" AND ");
1808
1809                if (articleId == null) {
1810                    query.append("articleId IS NULL");
1811                }
1812                else {
1813                    query.append("articleId = ?");
1814                }
1815
1816                query.append(" ");
1817
1818                Query q = session.createQuery(query.toString());
1819
1820                int queryPos = 0;
1821
1822                q.setLong(queryPos++, groupId);
1823
1824                q.setBoolean(queryPos++, privateLayout);
1825
1826                q.setLong(queryPos++, layoutId);
1827
1828                if (portletId != null) {
1829                    q.setString(queryPos++, portletId);
1830                }
1831
1832                if (articleId != null) {
1833                    q.setString(queryPos++, articleId);
1834                }
1835
1836                List list = q.list();
1837
1838                FinderCache.putResult(finderClassNameCacheEnabled,
1839                    finderClassName, finderMethodName, finderParams,
1840                    finderArgs, list);
1841
1842                if (list.size() == 0) {
1843                    return null;
1844                }
1845                else {
1846                    return (JournalContentSearch)list.get(0);
1847                }
1848            }
1849            catch (Exception e) {
1850                throw HibernateUtil.processException(e);
1851            }
1852            finally {
1853                closeSession(session);
1854            }
1855        }
1856        else {
1857            List list = (List)result;
1858
1859            if (list.size() == 0) {
1860                return null;
1861            }
1862            else {
1863                return (JournalContentSearch)list.get(0);
1864            }
1865        }
1866    }
1867
1868    public List findWithDynamicQuery(DynamicQueryInitializer queryInitializer)
1869        throws SystemException {
1870        Session session = null;
1871
1872        try {
1873            session = openSession();
1874
1875            DynamicQuery query = queryInitializer.initialize(session);
1876
1877            return query.list();
1878        }
1879        catch (Exception e) {
1880            throw HibernateUtil.processException(e);
1881        }
1882        finally {
1883            closeSession(session);
1884        }
1885    }
1886
1887    public List findWithDynamicQuery(DynamicQueryInitializer queryInitializer,
1888        int begin, int end) throws SystemException {
1889        Session session = null;
1890
1891        try {
1892            session = openSession();
1893
1894            DynamicQuery query = queryInitializer.initialize(session);
1895
1896            query.setLimit(begin, end);
1897
1898            return query.list();
1899        }
1900        catch (Exception e) {
1901            throw HibernateUtil.processException(e);
1902        }
1903        finally {
1904            closeSession(session);
1905        }
1906    }
1907
1908    public List findAll() throws SystemException {
1909        return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1910    }
1911
1912    public List findAll(int begin, int end) throws SystemException {
1913        return findAll(begin, end, null);
1914    }
1915
1916    public List findAll(int begin, int end, OrderByComparator obc)
1917        throws SystemException {
1918        boolean finderClassNameCacheEnabled = JournalContentSearchModelImpl.CACHE_ENABLED;
1919        String finderClassName = JournalContentSearch.class.getName();
1920        String finderMethodName = "findAll";
1921        String[] finderParams = new String[] {
1922                "java.lang.Integer", "java.lang.Integer",
1923                "com.liferay.portal.kernel.util.OrderByComparator"
1924            };
1925        Object[] finderArgs = new Object[] {
1926                String.valueOf(begin), String.valueOf(end), String.valueOf(obc)
1927            };
1928
1929        Object result = null;
1930
1931        if (finderClassNameCacheEnabled) {
1932            result = FinderCache.getResult(finderClassName, finderMethodName,
1933                    finderParams, finderArgs, getSessionFactory());
1934        }
1935
1936        if (result == null) {
1937            Session session = null;
1938
1939            try {
1940                session = openSession();
1941
1942                StringMaker query = new StringMaker();
1943
1944                query.append(
1945                    "FROM com.liferay.portlet.journal.model.JournalContentSearch ");
1946
1947                if (obc != null) {
1948                    query.append("ORDER BY ");
1949                    query.append(obc.getOrderBy());
1950                }
1951
1952                Query q = session.createQuery(query.toString());
1953
1954                List list = QueryUtil.list(q, getDialect(), begin, end);
1955
1956                if (obc == null) {
1957                    Collections.sort(list);
1958                }
1959
1960                FinderCache.putResult(finderClassNameCacheEnabled,
1961                    finderClassName, finderMethodName, finderParams,
1962                    finderArgs, list);
1963
1964                return list;
1965            }
1966            catch (Exception e) {
1967                throw HibernateUtil.processException(e);
1968            }
1969            finally {
1970                closeSession(session);
1971            }
1972        }
1973        else {
1974            return (List)result;
1975        }
1976    }
1977
1978    public void removeByG_P(long groupId, boolean privateLayout)
1979        throws SystemException {
1980        Iterator itr = findByG_P(groupId, privateLayout).iterator();
1981
1982        while (itr.hasNext()) {
1983            JournalContentSearch journalContentSearch = (JournalContentSearch)itr.next();
1984
1985            remove(journalContentSearch);
1986        }
1987    }
1988
1989    public void removeByG_A(long groupId, String articleId)
1990        throws SystemException {
1991        Iterator itr = findByG_A(groupId, articleId).iterator();
1992
1993        while (itr.hasNext()) {
1994            JournalContentSearch journalContentSearch = (JournalContentSearch)itr.next();
1995
1996            remove(journalContentSearch);
1997        }
1998    }
1999
2000    public void removeByG_P_L(long groupId, boolean privateLayout, long layoutId)
2001        throws SystemException {
2002        Iterator itr = findByG_P_L(groupId, privateLayout, layoutId).iterator();
2003
2004        while (itr.hasNext()) {
2005            JournalContentSearch journalContentSearch = (JournalContentSearch)itr.next();
2006
2007            remove(journalContentSearch);
2008        }
2009    }
2010
2011    public void removeByG_P_A(long groupId, boolean privateLayout,
2012        String articleId) throws SystemException {
2013        Iterator itr = findByG_P_A(groupId, privateLayout, articleId).iterator();
2014
2015        while (itr.hasNext()) {
2016            JournalContentSearch journalContentSearch = (JournalContentSearch)itr.next();
2017
2018            remove(journalContentSearch);
2019        }
2020    }
2021
2022    public void removeByG_P_L_P(long groupId, boolean privateLayout,
2023        long layoutId, String portletId) throws SystemException {
2024        Iterator itr = findByG_P_L_P(groupId, privateLayout, layoutId, portletId)
2025                           .iterator();
2026
2027        while (itr.hasNext()) {
2028            JournalContentSearch journalContentSearch = (JournalContentSearch)itr.next();
2029
2030            remove(journalContentSearch);
2031        }
2032    }
2033
2034    public void removeByG_P_L_P_A(long groupId, boolean privateLayout,
2035        long layoutId, String portletId, String articleId)
2036        throws NoSuchContentSearchException, SystemException {
2037        JournalContentSearch journalContentSearch = findByG_P_L_P_A(groupId,
2038                privateLayout, layoutId, portletId, articleId);
2039
2040        remove(journalContentSearch);
2041    }
2042
2043    public void removeAll() throws SystemException {
2044        Iterator itr = findAll().iterator();
2045
2046        while (itr.hasNext()) {
2047            remove((JournalContentSearch)itr.next());
2048        }
2049    }
2050
2051    public int countByG_P(long groupId, boolean privateLayout)
2052        throws SystemException {
2053        boolean finderClassNameCacheEnabled = JournalContentSearchModelImpl.CACHE_ENABLED;
2054        String finderClassName = JournalContentSearch.class.getName();
2055        String finderMethodName = "countByG_P";
2056        String[] finderParams = new String[] {
2057                Long.class.getName(), Boolean.class.getName()
2058            };
2059        Object[] finderArgs = new Object[] {
2060                new Long(groupId), Boolean.valueOf(privateLayout)
2061            };
2062
2063        Object result = null;
2064
2065        if (finderClassNameCacheEnabled) {
2066            result = FinderCache.getResult(finderClassName, finderMethodName,
2067                    finderParams, finderArgs, getSessionFactory());
2068        }
2069
2070        if (result == null) {
2071            Session session = null;
2072
2073            try {
2074                session = openSession();
2075
2076                StringMaker query = new StringMaker();
2077
2078                query.append("SELECT COUNT(*) ");
2079                query.append(
2080                    "FROM com.liferay.portlet.journal.model.JournalContentSearch WHERE ");
2081
2082                query.append("groupId = ?");
2083
2084                query.append(" AND ");
2085
2086                query.append("privateLayout = ?");
2087
2088                query.append(" ");
2089
2090                Query q = session.createQuery(query.toString());
2091
2092                int queryPos = 0;
2093
2094                q.setLong(queryPos++, groupId);
2095
2096                q.setBoolean(queryPos++, privateLayout);
2097
2098                Long count = null;
2099
2100                Iterator itr = q.list().iterator();
2101
2102                if (itr.hasNext()) {
2103                    count = (Long)itr.next();
2104                }
2105
2106                if (count == null) {
2107                    count = new Long(0);
2108                }
2109
2110                FinderCache.putResult(finderClassNameCacheEnabled,
2111                    finderClassName, finderMethodName, finderParams,
2112                    finderArgs, count);
2113
2114                return count.intValue();
2115            }
2116            catch (Exception e) {
2117                throw HibernateUtil.processException(e);
2118            }
2119            finally {
2120                closeSession(session);
2121            }
2122        }
2123        else {
2124            return ((Long)result).intValue();
2125        }
2126    }
2127
2128    public int countByG_A(long groupId, String articleId)
2129        throws SystemException {
2130        boolean finderClassNameCacheEnabled = JournalContentSearchModelImpl.CACHE_ENABLED;
2131        String finderClassName = JournalContentSearch.class.getName();
2132        String finderMethodName = "countByG_A";
2133        String[] finderParams = new String[] {
2134                Long.class.getName(), String.class.getName()
2135            };
2136        Object[] finderArgs = new Object[] { new Long(groupId), articleId };
2137
2138        Object result = null;
2139
2140        if (finderClassNameCacheEnabled) {
2141            result = FinderCache.getResult(finderClassName, finderMethodName,
2142                    finderParams, finderArgs, getSessionFactory());
2143        }
2144
2145        if (result == null) {
2146            Session session = null;
2147
2148            try {
2149                session = openSession();
2150
2151                StringMaker query = new StringMaker();
2152
2153                query.append("SELECT COUNT(*) ");
2154                query.append(
2155                    "FROM com.liferay.portlet.journal.model.JournalContentSearch WHERE ");
2156
2157                query.append("groupId = ?");
2158
2159                query.append(" AND ");
2160
2161                if (articleId == null) {
2162                    query.append("articleId IS NULL");
2163                }
2164                else {
2165                    query.append("articleId = ?");
2166                }
2167
2168                query.append(" ");
2169
2170                Query q = session.createQuery(query.toString());
2171
2172                int queryPos = 0;
2173
2174                q.setLong(queryPos++, groupId);
2175
2176                if (articleId != null) {
2177                    q.setString(queryPos++, articleId);
2178                }
2179
2180                Long count = null;
2181
2182                Iterator itr = q.list().iterator();
2183
2184                if (itr.hasNext()) {
2185                    count = (Long)itr.next();
2186                }
2187
2188                if (count == null) {
2189                    count = new Long(0);
2190                }
2191
2192                FinderCache.putResult(finderClassNameCacheEnabled,
2193                    finderClassName, finderMethodName, finderParams,
2194                    finderArgs, count);
2195
2196                return count.intValue();
2197            }
2198            catch (Exception e) {
2199                throw HibernateUtil.processException(e);
2200            }
2201            finally {
2202                closeSession(session);
2203            }
2204        }
2205        else {
2206            return ((Long)result).intValue();
2207        }
2208    }
2209
2210    public int countByG_P_L(long groupId, boolean privateLayout, long layoutId)
2211        throws SystemException {
2212        boolean finderClassNameCacheEnabled = JournalContentSearchModelImpl.CACHE_ENABLED;
2213        String finderClassName = JournalContentSearch.class.getName();
2214        String finderMethodName = "countByG_P_L";
2215        String[] finderParams = new String[] {
2216                Long.class.getName(), Boolean.class.getName(),
2217                Long.class.getName()
2218            };
2219        Object[] finderArgs = new Object[] {
2220                new Long(groupId), Boolean.valueOf(privateLayout),
2221                new Long(layoutId)
2222            };
2223
2224        Object result = null;
2225
2226        if (finderClassNameCacheEnabled) {
2227            result = FinderCache.getResult(finderClassName, finderMethodName,
2228                    finderParams, finderArgs, getSessionFactory());
2229        }
2230
2231        if (result == null) {
2232            Session session = null;
2233
2234            try {
2235                session = openSession();
2236
2237                StringMaker query = new StringMaker();
2238
2239                query.append("SELECT COUNT(*) ");
2240                query.append(
2241                    "FROM com.liferay.portlet.journal.model.JournalContentSearch WHERE ");
2242
2243                query.append("groupId = ?");
2244
2245                query.append(" AND ");
2246
2247                query.append("privateLayout = ?");
2248
2249                query.append(" AND ");
2250
2251                query.append("layoutId = ?");
2252
2253                query.append(" ");
2254
2255                Query q = session.createQuery(query.toString());
2256
2257                int queryPos = 0;
2258
2259                q.setLong(queryPos++, groupId);
2260
2261                q.setBoolean(queryPos++, privateLayout);
2262
2263                q.setLong(queryPos++, layoutId);
2264
2265                Long count = null;
2266
2267                Iterator itr = q.list().iterator();
2268
2269                if (itr.hasNext()) {
2270                    count = (Long)itr.next();
2271                }
2272
2273                if (count == null) {
2274                    count = new Long(0);
2275                }
2276
2277                FinderCache.putResult(finderClassNameCacheEnabled,
2278                    finderClassName, finderMethodName, finderParams,
2279                    finderArgs, count);
2280
2281                return count.intValue();
2282            }
2283            catch (Exception e) {
2284                throw HibernateUtil.processException(e);
2285            }
2286            finally {
2287                closeSession(session);
2288            }
2289        }
2290        else {
2291            return ((Long)result).intValue();
2292        }
2293    }
2294
2295    public int countByG_P_A(long groupId, boolean privateLayout,
2296        String articleId) throws SystemException {
2297        boolean finderClassNameCacheEnabled = JournalContentSearchModelImpl.CACHE_ENABLED;
2298        String finderClassName = JournalContentSearch.class.getName();
2299        String finderMethodName = "countByG_P_A";
2300        String[] finderParams = new String[] {
2301                Long.class.getName(), Boolean.class.getName(),
2302                String.class.getName()
2303            };
2304        Object[] finderArgs = new Object[] {
2305                new Long(groupId), Boolean.valueOf(privateLayout),
2306                
2307                articleId
2308            };
2309
2310        Object result = null;
2311
2312        if (finderClassNameCacheEnabled) {
2313            result = FinderCache.getResult(finderClassName, finderMethodName,
2314                    finderParams, finderArgs, getSessionFactory());
2315        }
2316
2317        if (result == null) {
2318            Session session = null;
2319
2320            try {
2321                session = openSession();
2322
2323                StringMaker query = new StringMaker();
2324
2325                query.append("SELECT COUNT(*) ");
2326                query.append(
2327                    "FROM com.liferay.portlet.journal.model.JournalContentSearch WHERE ");
2328
2329                query.append("groupId = ?");
2330
2331                query.append(" AND ");
2332
2333                query.append("privateLayout = ?");
2334
2335                query.append(" AND ");
2336
2337                if (articleId == null) {
2338                    query.append("articleId IS NULL");
2339                }
2340                else {
2341                    query.append("articleId = ?");
2342                }
2343
2344                query.append(" ");
2345
2346                Query q = session.createQuery(query.toString());
2347
2348                int queryPos = 0;
2349
2350                q.setLong(queryPos++, groupId);
2351
2352                q.setBoolean(queryPos++, privateLayout);
2353
2354                if (articleId != null) {
2355                    q.setString(queryPos++, articleId);
2356                }
2357
2358                Long count = null;
2359
2360                Iterator itr = q.list().iterator();
2361
2362                if (itr.hasNext()) {
2363                    count = (Long)itr.next();
2364                }
2365
2366                if (count == null) {
2367                    count = new Long(0);
2368                }
2369
2370                FinderCache.putResult(finderClassNameCacheEnabled,
2371                    finderClassName, finderMethodName, finderParams,
2372                    finderArgs, count);
2373
2374                return count.intValue();
2375            }
2376            catch (Exception e) {
2377                throw HibernateUtil.processException(e);
2378            }
2379            finally {
2380                closeSession(session);
2381            }
2382        }
2383        else {
2384            return ((Long)result).intValue();
2385        }
2386    }
2387
2388    public int countByG_P_L_P(long groupId, boolean privateLayout,
2389        long layoutId, String portletId) throws SystemException {
2390        boolean finderClassNameCacheEnabled = JournalContentSearchModelImpl.CACHE_ENABLED;
2391        String finderClassName = JournalContentSearch.class.getName();
2392        String finderMethodName = "countByG_P_L_P";
2393        String[] finderParams = new String[] {
2394                Long.class.getName(), Boolean.class.getName(),
2395                Long.class.getName(), String.class.getName()
2396            };
2397        Object[] finderArgs = new Object[] {
2398                new Long(groupId), Boolean.valueOf(privateLayout),
2399                new Long(layoutId),
2400                
2401                portletId
2402            };
2403
2404        Object result = null;
2405
2406        if (finderClassNameCacheEnabled) {
2407            result = FinderCache.getResult(finderClassName, finderMethodName,
2408                    finderParams, finderArgs, getSessionFactory());
2409        }
2410
2411        if (result == null) {
2412            Session session = null;
2413
2414            try {
2415                session = openSession();
2416
2417                StringMaker query = new StringMaker();
2418
2419                query.append("SELECT COUNT(*) ");
2420                query.append(
2421                    "FROM com.liferay.portlet.journal.model.JournalContentSearch WHERE ");
2422
2423                query.append("groupId = ?");
2424
2425                query.append(" AND ");
2426
2427                query.append("privateLayout = ?");
2428
2429                query.append(" AND ");
2430
2431                query.append("layoutId = ?");
2432
2433                query.append(" AND ");
2434
2435                if (portletId == null) {
2436                    query.append("portletId IS NULL");
2437                }
2438                else {
2439                    query.append("portletId = ?");
2440                }
2441
2442                query.append(" ");
2443
2444                Query q = session.createQuery(query.toString());
2445
2446                int queryPos = 0;
2447
2448                q.setLong(queryPos++, groupId);
2449
2450                q.setBoolean(queryPos++, privateLayout);
2451
2452                q.setLong(queryPos++, layoutId);
2453
2454                if (portletId != null) {
2455                    q.setString(queryPos++, portletId);
2456                }
2457
2458                Long count = null;
2459
2460                Iterator itr = q.list().iterator();
2461
2462                if (itr.hasNext()) {
2463                    count = (Long)itr.next();
2464                }
2465
2466                if (count == null) {
2467                    count = new Long(0);
2468                }
2469
2470                FinderCache.putResult(finderClassNameCacheEnabled,
2471                    finderClassName, finderMethodName, finderParams,
2472                    finderArgs, count);
2473
2474                return count.intValue();
2475            }
2476            catch (Exception e) {
2477                throw HibernateUtil.processException(e);
2478            }
2479            finally {
2480                closeSession(session);
2481            }
2482        }
2483        else {
2484            return ((Long)result).intValue();
2485        }
2486    }
2487
2488    public int countByG_P_L_P_A(long groupId, boolean privateLayout,
2489        long layoutId, String portletId, String articleId)
2490        throws SystemException {
2491        boolean finderClassNameCacheEnabled = JournalContentSearchModelImpl.CACHE_ENABLED;
2492        String finderClassName = JournalContentSearch.class.getName();
2493        String finderMethodName = "countByG_P_L_P_A";
2494        String[] finderParams = new String[] {
2495                Long.class.getName(), Boolean.class.getName(),
2496                Long.class.getName(), String.class.getName(),
2497                String.class.getName()
2498            };
2499        Object[] finderArgs = new Object[] {
2500                new Long(groupId), Boolean.valueOf(privateLayout),
2501                new Long(layoutId),
2502                
2503                portletId,
2504                
2505                articleId
2506            };
2507
2508        Object result = null;
2509
2510        if (finderClassNameCacheEnabled) {
2511            result = FinderCache.getResult(finderClassName, finderMethodName,
2512                    finderParams, finderArgs, getSessionFactory());
2513        }
2514
2515        if (result == null) {
2516            Session session = null;
2517
2518            try {
2519                session = openSession();
2520
2521                StringMaker query = new StringMaker();
2522
2523                query.append("SELECT COUNT(*) ");
2524                query.append(
2525                    "FROM com.liferay.portlet.journal.model.JournalContentSearch WHERE ");
2526
2527                query.append("groupId = ?");
2528
2529                query.append(" AND ");
2530
2531                query.append("privateLayout = ?");
2532
2533                query.append(" AND ");
2534
2535                query.append("layoutId = ?");
2536
2537                query.append(" AND ");
2538
2539                if (portletId == null) {
2540                    query.append("portletId IS NULL");
2541                }
2542                else {
2543                    query.append("portletId = ?");
2544                }
2545
2546                query.append(" AND ");
2547
2548                if (articleId == null) {
2549                    query.append("articleId IS NULL");
2550                }
2551                else {
2552                    query.append("articleId = ?");
2553                }
2554
2555                query.append(" ");
2556
2557                Query q = session.createQuery(query.toString());
2558
2559                int queryPos = 0;
2560
2561                q.setLong(queryPos++, groupId);
2562
2563                q.setBoolean(queryPos++, privateLayout);
2564
2565                q.setLong(queryPos++, layoutId);
2566
2567                if (portletId != null) {
2568                    q.setString(queryPos++, portletId);
2569                }
2570
2571                if (articleId != null) {
2572                    q.setString(queryPos++, articleId);
2573                }
2574
2575                Long count = null;
2576
2577                Iterator itr = q.list().iterator();
2578
2579                if (itr.hasNext()) {
2580                    count = (Long)itr.next();
2581                }
2582
2583                if (count == null) {
2584                    count = new Long(0);
2585                }
2586
2587                FinderCache.putResult(finderClassNameCacheEnabled,
2588                    finderClassName, finderMethodName, finderParams,
2589                    finderArgs, count);
2590
2591                return count.intValue();
2592            }
2593            catch (Exception e) {
2594                throw HibernateUtil.processException(e);
2595            }
2596            finally {
2597                closeSession(session);
2598            }
2599        }
2600        else {
2601            return ((Long)result).intValue();
2602        }
2603    }
2604
2605    public int countAll() throws SystemException {
2606        boolean finderClassNameCacheEnabled = JournalContentSearchModelImpl.CACHE_ENABLED;
2607        String finderClassName = JournalContentSearch.class.getName();
2608        String finderMethodName = "countAll";
2609        String[] finderParams = new String[] {  };
2610        Object[] finderArgs = new Object[] {  };
2611
2612        Object result = null;
2613
2614        if (finderClassNameCacheEnabled) {
2615            result = FinderCache.getResult(finderClassName, finderMethodName,
2616                    finderParams, finderArgs, getSessionFactory());
2617        }
2618
2619        if (result == null) {
2620            Session session = null;
2621
2622            try {
2623                session = openSession();
2624
2625                Query q = session.createQuery(
2626                        "SELECT COUNT(*) FROM com.liferay.portlet.journal.model.JournalContentSearch");
2627
2628                Long count = null;
2629
2630                Iterator itr = q.list().iterator();
2631
2632                if (itr.hasNext()) {
2633                    count = (Long)itr.next();
2634                }
2635
2636                if (count == null) {
2637                    count = new Long(0);
2638                }
2639
2640                FinderCache.putResult(finderClassNameCacheEnabled,
2641                    finderClassName, finderMethodName, finderParams,
2642                    finderArgs, count);
2643
2644                return count.intValue();
2645            }
2646            catch (Exception e) {
2647                throw HibernateUtil.processException(e);
2648            }
2649            finally {
2650                closeSession(session);
2651            }
2652        }
2653        else {
2654            return ((Long)result).intValue();
2655        }
2656    }
2657
2658    protected void initDao() {
2659    }
2660
2661    private static ModelListener _getListener() {
2662        if (Validator.isNotNull(_LISTENER)) {
2663            try {
2664                return (ModelListener)Class.forName(_LISTENER).newInstance();
2665            }
2666            catch (Exception e) {
2667                _log.error(e);
2668            }
2669        }
2670
2671        return null;
2672    }
2673
2674    private static final String _LISTENER = GetterUtil.getString(PropsUtil.get(
2675                "value.object.listener.com.liferay.portlet.journal.model.JournalContentSearch"));
2676    private static Log _log = LogFactory.getLog(JournalContentSearchPersistenceImpl.class);
2677}