1   /**
2    * Copyright (c) 2000-2009 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.blogs.service.persistence;
24  
25  import com.liferay.portal.SystemException;
26  import com.liferay.portal.kernel.annotation.BeanReference;
27  import com.liferay.portal.kernel.dao.orm.DynamicQuery;
28  import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
29  import com.liferay.portal.kernel.dao.orm.Query;
30  import com.liferay.portal.kernel.dao.orm.QueryPos;
31  import com.liferay.portal.kernel.dao.orm.QueryUtil;
32  import com.liferay.portal.kernel.dao.orm.Session;
33  import com.liferay.portal.kernel.log.Log;
34  import com.liferay.portal.kernel.log.LogFactoryUtil;
35  import com.liferay.portal.kernel.util.CalendarUtil;
36  import com.liferay.portal.kernel.util.GetterUtil;
37  import com.liferay.portal.kernel.util.OrderByComparator;
38  import com.liferay.portal.kernel.util.StringPool;
39  import com.liferay.portal.kernel.util.StringUtil;
40  import com.liferay.portal.kernel.util.Validator;
41  import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
42  import com.liferay.portal.model.ModelListener;
43  import com.liferay.portal.service.persistence.BatchSessionUtil;
44  import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
45  
46  import com.liferay.portlet.blogs.NoSuchEntryException;
47  import com.liferay.portlet.blogs.model.BlogsEntry;
48  import com.liferay.portlet.blogs.model.impl.BlogsEntryImpl;
49  import com.liferay.portlet.blogs.model.impl.BlogsEntryModelImpl;
50  
51  import java.util.ArrayList;
52  import java.util.Collections;
53  import java.util.Date;
54  import java.util.Iterator;
55  import java.util.List;
56  
57  /**
58   * <a href="BlogsEntryPersistenceImpl.java.html"><b><i>View Source</i></b></a>
59   *
60   * @author Brian Wing Shun Chan
61   *
62   */
63  public class BlogsEntryPersistenceImpl extends BasePersistenceImpl
64      implements BlogsEntryPersistence {
65      public BlogsEntry create(long entryId) {
66          BlogsEntry blogsEntry = new BlogsEntryImpl();
67  
68          blogsEntry.setNew(true);
69          blogsEntry.setPrimaryKey(entryId);
70  
71          String uuid = PortalUUIDUtil.generate();
72  
73          blogsEntry.setUuid(uuid);
74  
75          return blogsEntry;
76      }
77  
78      public BlogsEntry remove(long entryId)
79          throws NoSuchEntryException, SystemException {
80          Session session = null;
81  
82          try {
83              session = openSession();
84  
85              BlogsEntry blogsEntry = (BlogsEntry)session.get(BlogsEntryImpl.class,
86                      new Long(entryId));
87  
88              if (blogsEntry == null) {
89                  if (_log.isWarnEnabled()) {
90                      _log.warn("No BlogsEntry exists with the primary key " +
91                          entryId);
92                  }
93  
94                  throw new NoSuchEntryException(
95                      "No BlogsEntry exists with the primary key " + entryId);
96              }
97  
98              return remove(blogsEntry);
99          }
100         catch (NoSuchEntryException nsee) {
101             throw nsee;
102         }
103         catch (Exception e) {
104             throw processException(e);
105         }
106         finally {
107             closeSession(session);
108         }
109     }
110 
111     public BlogsEntry remove(BlogsEntry blogsEntry) throws SystemException {
112         for (ModelListener listener : listeners) {
113             listener.onBeforeRemove(blogsEntry);
114         }
115 
116         blogsEntry = removeImpl(blogsEntry);
117 
118         for (ModelListener listener : listeners) {
119             listener.onAfterRemove(blogsEntry);
120         }
121 
122         return blogsEntry;
123     }
124 
125     protected BlogsEntry removeImpl(BlogsEntry blogsEntry)
126         throws SystemException {
127         Session session = null;
128 
129         try {
130             session = openSession();
131 
132             if (BatchSessionUtil.isEnabled()) {
133                 Object staleObject = session.get(BlogsEntryImpl.class,
134                         blogsEntry.getPrimaryKeyObj());
135 
136                 if (staleObject != null) {
137                     session.evict(staleObject);
138                 }
139             }
140 
141             session.delete(blogsEntry);
142 
143             session.flush();
144 
145             return blogsEntry;
146         }
147         catch (Exception e) {
148             throw processException(e);
149         }
150         finally {
151             closeSession(session);
152 
153             FinderCacheUtil.clearCache(BlogsEntry.class.getName());
154         }
155     }
156 
157     /**
158      * @deprecated Use <code>update(BlogsEntry blogsEntry, boolean merge)</code>.
159      */
160     public BlogsEntry update(BlogsEntry blogsEntry) throws SystemException {
161         if (_log.isWarnEnabled()) {
162             _log.warn(
163                 "Using the deprecated update(BlogsEntry blogsEntry) method. Use update(BlogsEntry blogsEntry, boolean merge) instead.");
164         }
165 
166         return update(blogsEntry, false);
167     }
168 
169     /**
170      * Add, update, or merge, the entity. This method also calls the model
171      * listeners to trigger the proper events associated with adding, deleting,
172      * or updating an entity.
173      *
174      * @param        blogsEntry the entity to add, update, or merge
175      * @param        merge boolean value for whether to merge the entity. The
176      *                default value is false. Setting merge to true is more
177      *                expensive and should only be true when blogsEntry is
178      *                transient. See LEP-5473 for a detailed discussion of this
179      *                method.
180      * @return        true if the portlet can be displayed via Ajax
181      */
182     public BlogsEntry update(BlogsEntry blogsEntry, boolean merge)
183         throws SystemException {
184         boolean isNew = blogsEntry.isNew();
185 
186         for (ModelListener listener : listeners) {
187             if (isNew) {
188                 listener.onBeforeCreate(blogsEntry);
189             }
190             else {
191                 listener.onBeforeUpdate(blogsEntry);
192             }
193         }
194 
195         blogsEntry = updateImpl(blogsEntry, merge);
196 
197         for (ModelListener listener : listeners) {
198             if (isNew) {
199                 listener.onAfterCreate(blogsEntry);
200             }
201             else {
202                 listener.onAfterUpdate(blogsEntry);
203             }
204         }
205 
206         return blogsEntry;
207     }
208 
209     public BlogsEntry updateImpl(
210         com.liferay.portlet.blogs.model.BlogsEntry blogsEntry, boolean merge)
211         throws SystemException {
212         if (Validator.isNull(blogsEntry.getUuid())) {
213             String uuid = PortalUUIDUtil.generate();
214 
215             blogsEntry.setUuid(uuid);
216         }
217 
218         Session session = null;
219 
220         try {
221             session = openSession();
222 
223             BatchSessionUtil.update(session, blogsEntry, merge);
224 
225             blogsEntry.setNew(false);
226 
227             return blogsEntry;
228         }
229         catch (Exception e) {
230             throw processException(e);
231         }
232         finally {
233             closeSession(session);
234 
235             FinderCacheUtil.clearCache(BlogsEntry.class.getName());
236         }
237     }
238 
239     public BlogsEntry findByPrimaryKey(long entryId)
240         throws NoSuchEntryException, SystemException {
241         BlogsEntry blogsEntry = fetchByPrimaryKey(entryId);
242 
243         if (blogsEntry == null) {
244             if (_log.isWarnEnabled()) {
245                 _log.warn("No BlogsEntry exists with the primary key " +
246                     entryId);
247             }
248 
249             throw new NoSuchEntryException(
250                 "No BlogsEntry exists with the primary key " + entryId);
251         }
252 
253         return blogsEntry;
254     }
255 
256     public BlogsEntry fetchByPrimaryKey(long entryId) throws SystemException {
257         Session session = null;
258 
259         try {
260             session = openSession();
261 
262             return (BlogsEntry)session.get(BlogsEntryImpl.class,
263                 new Long(entryId));
264         }
265         catch (Exception e) {
266             throw processException(e);
267         }
268         finally {
269             closeSession(session);
270         }
271     }
272 
273     public List<BlogsEntry> findByUuid(String uuid) throws SystemException {
274         boolean finderClassNameCacheEnabled = BlogsEntryModelImpl.CACHE_ENABLED;
275         String finderClassName = BlogsEntry.class.getName();
276         String finderMethodName = "findByUuid";
277         String[] finderParams = new String[] { String.class.getName() };
278         Object[] finderArgs = new Object[] { uuid };
279 
280         Object result = null;
281 
282         if (finderClassNameCacheEnabled) {
283             result = FinderCacheUtil.getResult(finderClassName,
284                     finderMethodName, finderParams, finderArgs, this);
285         }
286 
287         if (result == null) {
288             Session session = null;
289 
290             try {
291                 session = openSession();
292 
293                 StringBuilder query = new StringBuilder();
294 
295                 query.append(
296                     "FROM com.liferay.portlet.blogs.model.BlogsEntry WHERE ");
297 
298                 if (uuid == null) {
299                     query.append("uuid_ IS NULL");
300                 }
301                 else {
302                     query.append("uuid_ = ?");
303                 }
304 
305                 query.append(" ");
306 
307                 query.append("ORDER BY ");
308 
309                 query.append("displayDate DESC");
310 
311                 Query q = session.createQuery(query.toString());
312 
313                 QueryPos qPos = QueryPos.getInstance(q);
314 
315                 if (uuid != null) {
316                     qPos.add(uuid);
317                 }
318 
319                 List<BlogsEntry> list = q.list();
320 
321                 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
322                     finderClassName, finderMethodName, finderParams,
323                     finderArgs, list);
324 
325                 return list;
326             }
327             catch (Exception e) {
328                 throw processException(e);
329             }
330             finally {
331                 closeSession(session);
332             }
333         }
334         else {
335             return (List<BlogsEntry>)result;
336         }
337     }
338 
339     public List<BlogsEntry> findByUuid(String uuid, int start, int end)
340         throws SystemException {
341         return findByUuid(uuid, start, end, null);
342     }
343 
344     public List<BlogsEntry> findByUuid(String uuid, int start, int end,
345         OrderByComparator obc) throws SystemException {
346         boolean finderClassNameCacheEnabled = BlogsEntryModelImpl.CACHE_ENABLED;
347         String finderClassName = BlogsEntry.class.getName();
348         String finderMethodName = "findByUuid";
349         String[] finderParams = new String[] {
350                 String.class.getName(),
351                 
352                 "java.lang.Integer", "java.lang.Integer",
353                 "com.liferay.portal.kernel.util.OrderByComparator"
354             };
355         Object[] finderArgs = new Object[] {
356                 uuid,
357                 
358                 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
359             };
360 
361         Object result = null;
362 
363         if (finderClassNameCacheEnabled) {
364             result = FinderCacheUtil.getResult(finderClassName,
365                     finderMethodName, finderParams, finderArgs, this);
366         }
367 
368         if (result == null) {
369             Session session = null;
370 
371             try {
372                 session = openSession();
373 
374                 StringBuilder query = new StringBuilder();
375 
376                 query.append(
377                     "FROM com.liferay.portlet.blogs.model.BlogsEntry WHERE ");
378 
379                 if (uuid == null) {
380                     query.append("uuid_ IS NULL");
381                 }
382                 else {
383                     query.append("uuid_ = ?");
384                 }
385 
386                 query.append(" ");
387 
388                 if (obc != null) {
389                     query.append("ORDER BY ");
390                     query.append(obc.getOrderBy());
391                 }
392 
393                 else {
394                     query.append("ORDER BY ");
395 
396                     query.append("displayDate DESC");
397                 }
398 
399                 Query q = session.createQuery(query.toString());
400 
401                 QueryPos qPos = QueryPos.getInstance(q);
402 
403                 if (uuid != null) {
404                     qPos.add(uuid);
405                 }
406 
407                 List<BlogsEntry> list = (List<BlogsEntry>)QueryUtil.list(q,
408                         getDialect(), start, end);
409 
410                 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
411                     finderClassName, finderMethodName, finderParams,
412                     finderArgs, list);
413 
414                 return list;
415             }
416             catch (Exception e) {
417                 throw processException(e);
418             }
419             finally {
420                 closeSession(session);
421             }
422         }
423         else {
424             return (List<BlogsEntry>)result;
425         }
426     }
427 
428     public BlogsEntry findByUuid_First(String uuid, OrderByComparator obc)
429         throws NoSuchEntryException, SystemException {
430         List<BlogsEntry> list = findByUuid(uuid, 0, 1, obc);
431 
432         if (list.size() == 0) {
433             StringBuilder msg = new StringBuilder();
434 
435             msg.append("No BlogsEntry exists with the key {");
436 
437             msg.append("uuid=" + uuid);
438 
439             msg.append(StringPool.CLOSE_CURLY_BRACE);
440 
441             throw new NoSuchEntryException(msg.toString());
442         }
443         else {
444             return list.get(0);
445         }
446     }
447 
448     public BlogsEntry findByUuid_Last(String uuid, OrderByComparator obc)
449         throws NoSuchEntryException, SystemException {
450         int count = countByUuid(uuid);
451 
452         List<BlogsEntry> list = findByUuid(uuid, count - 1, count, obc);
453 
454         if (list.size() == 0) {
455             StringBuilder msg = new StringBuilder();
456 
457             msg.append("No BlogsEntry exists with the key {");
458 
459             msg.append("uuid=" + uuid);
460 
461             msg.append(StringPool.CLOSE_CURLY_BRACE);
462 
463             throw new NoSuchEntryException(msg.toString());
464         }
465         else {
466             return list.get(0);
467         }
468     }
469 
470     public BlogsEntry[] findByUuid_PrevAndNext(long entryId, String uuid,
471         OrderByComparator obc) throws NoSuchEntryException, SystemException {
472         BlogsEntry blogsEntry = findByPrimaryKey(entryId);
473 
474         int count = countByUuid(uuid);
475 
476         Session session = null;
477 
478         try {
479             session = openSession();
480 
481             StringBuilder query = new StringBuilder();
482 
483             query.append(
484                 "FROM com.liferay.portlet.blogs.model.BlogsEntry WHERE ");
485 
486             if (uuid == null) {
487                 query.append("uuid_ IS NULL");
488             }
489             else {
490                 query.append("uuid_ = ?");
491             }
492 
493             query.append(" ");
494 
495             if (obc != null) {
496                 query.append("ORDER BY ");
497                 query.append(obc.getOrderBy());
498             }
499 
500             else {
501                 query.append("ORDER BY ");
502 
503                 query.append("displayDate DESC");
504             }
505 
506             Query q = session.createQuery(query.toString());
507 
508             QueryPos qPos = QueryPos.getInstance(q);
509 
510             if (uuid != null) {
511                 qPos.add(uuid);
512             }
513 
514             Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
515                     blogsEntry);
516 
517             BlogsEntry[] array = new BlogsEntryImpl[3];
518 
519             array[0] = (BlogsEntry)objArray[0];
520             array[1] = (BlogsEntry)objArray[1];
521             array[2] = (BlogsEntry)objArray[2];
522 
523             return array;
524         }
525         catch (Exception e) {
526             throw processException(e);
527         }
528         finally {
529             closeSession(session);
530         }
531     }
532 
533     public BlogsEntry findByUUID_G(String uuid, long groupId)
534         throws NoSuchEntryException, SystemException {
535         BlogsEntry blogsEntry = fetchByUUID_G(uuid, groupId);
536 
537         if (blogsEntry == null) {
538             StringBuilder msg = new StringBuilder();
539 
540             msg.append("No BlogsEntry exists with the key {");
541 
542             msg.append("uuid=" + uuid);
543 
544             msg.append(", ");
545             msg.append("groupId=" + groupId);
546 
547             msg.append(StringPool.CLOSE_CURLY_BRACE);
548 
549             if (_log.isWarnEnabled()) {
550                 _log.warn(msg.toString());
551             }
552 
553             throw new NoSuchEntryException(msg.toString());
554         }
555 
556         return blogsEntry;
557     }
558 
559     public BlogsEntry fetchByUUID_G(String uuid, long groupId)
560         throws SystemException {
561         boolean finderClassNameCacheEnabled = BlogsEntryModelImpl.CACHE_ENABLED;
562         String finderClassName = BlogsEntry.class.getName();
563         String finderMethodName = "fetchByUUID_G";
564         String[] finderParams = new String[] {
565                 String.class.getName(), Long.class.getName()
566             };
567         Object[] finderArgs = new Object[] { uuid, new Long(groupId) };
568 
569         Object result = null;
570 
571         if (finderClassNameCacheEnabled) {
572             result = FinderCacheUtil.getResult(finderClassName,
573                     finderMethodName, finderParams, finderArgs, this);
574         }
575 
576         if (result == null) {
577             Session session = null;
578 
579             try {
580                 session = openSession();
581 
582                 StringBuilder query = new StringBuilder();
583 
584                 query.append(
585                     "FROM com.liferay.portlet.blogs.model.BlogsEntry WHERE ");
586 
587                 if (uuid == null) {
588                     query.append("uuid_ IS NULL");
589                 }
590                 else {
591                     query.append("uuid_ = ?");
592                 }
593 
594                 query.append(" AND ");
595 
596                 query.append("groupId = ?");
597 
598                 query.append(" ");
599 
600                 query.append("ORDER BY ");
601 
602                 query.append("displayDate DESC");
603 
604                 Query q = session.createQuery(query.toString());
605 
606                 QueryPos qPos = QueryPos.getInstance(q);
607 
608                 if (uuid != null) {
609                     qPos.add(uuid);
610                 }
611 
612                 qPos.add(groupId);
613 
614                 List<BlogsEntry> list = q.list();
615 
616                 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
617                     finderClassName, finderMethodName, finderParams,
618                     finderArgs, list);
619 
620                 if (list.size() == 0) {
621                     return null;
622                 }
623                 else {
624                     return list.get(0);
625                 }
626             }
627             catch (Exception e) {
628                 throw processException(e);
629             }
630             finally {
631                 closeSession(session);
632             }
633         }
634         else {
635             List<BlogsEntry> list = (List<BlogsEntry>)result;
636 
637             if (list.size() == 0) {
638                 return null;
639             }
640             else {
641                 return list.get(0);
642             }
643         }
644     }
645 
646     public List<BlogsEntry> findByGroupId(long groupId)
647         throws SystemException {
648         boolean finderClassNameCacheEnabled = BlogsEntryModelImpl.CACHE_ENABLED;
649         String finderClassName = BlogsEntry.class.getName();
650         String finderMethodName = "findByGroupId";
651         String[] finderParams = new String[] { Long.class.getName() };
652         Object[] finderArgs = new Object[] { new Long(groupId) };
653 
654         Object result = null;
655 
656         if (finderClassNameCacheEnabled) {
657             result = FinderCacheUtil.getResult(finderClassName,
658                     finderMethodName, finderParams, finderArgs, this);
659         }
660 
661         if (result == null) {
662             Session session = null;
663 
664             try {
665                 session = openSession();
666 
667                 StringBuilder query = new StringBuilder();
668 
669                 query.append(
670                     "FROM com.liferay.portlet.blogs.model.BlogsEntry WHERE ");
671 
672                 query.append("groupId = ?");
673 
674                 query.append(" ");
675 
676                 query.append("ORDER BY ");
677 
678                 query.append("displayDate DESC");
679 
680                 Query q = session.createQuery(query.toString());
681 
682                 QueryPos qPos = QueryPos.getInstance(q);
683 
684                 qPos.add(groupId);
685 
686                 List<BlogsEntry> list = q.list();
687 
688                 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
689                     finderClassName, finderMethodName, finderParams,
690                     finderArgs, list);
691 
692                 return list;
693             }
694             catch (Exception e) {
695                 throw processException(e);
696             }
697             finally {
698                 closeSession(session);
699             }
700         }
701         else {
702             return (List<BlogsEntry>)result;
703         }
704     }
705 
706     public List<BlogsEntry> findByGroupId(long groupId, int start, int end)
707         throws SystemException {
708         return findByGroupId(groupId, start, end, null);
709     }
710 
711     public List<BlogsEntry> findByGroupId(long groupId, int start, int end,
712         OrderByComparator obc) throws SystemException {
713         boolean finderClassNameCacheEnabled = BlogsEntryModelImpl.CACHE_ENABLED;
714         String finderClassName = BlogsEntry.class.getName();
715         String finderMethodName = "findByGroupId";
716         String[] finderParams = new String[] {
717                 Long.class.getName(),
718                 
719                 "java.lang.Integer", "java.lang.Integer",
720                 "com.liferay.portal.kernel.util.OrderByComparator"
721             };
722         Object[] finderArgs = new Object[] {
723                 new Long(groupId),
724                 
725                 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
726             };
727 
728         Object result = null;
729 
730         if (finderClassNameCacheEnabled) {
731             result = FinderCacheUtil.getResult(finderClassName,
732                     finderMethodName, finderParams, finderArgs, this);
733         }
734 
735         if (result == null) {
736             Session session = null;
737 
738             try {
739                 session = openSession();
740 
741                 StringBuilder query = new StringBuilder();
742 
743                 query.append(
744                     "FROM com.liferay.portlet.blogs.model.BlogsEntry WHERE ");
745 
746                 query.append("groupId = ?");
747 
748                 query.append(" ");
749 
750                 if (obc != null) {
751                     query.append("ORDER BY ");
752                     query.append(obc.getOrderBy());
753                 }
754 
755                 else {
756                     query.append("ORDER BY ");
757 
758                     query.append("displayDate DESC");
759                 }
760 
761                 Query q = session.createQuery(query.toString());
762 
763                 QueryPos qPos = QueryPos.getInstance(q);
764 
765                 qPos.add(groupId);
766 
767                 List<BlogsEntry> list = (List<BlogsEntry>)QueryUtil.list(q,
768                         getDialect(), start, end);
769 
770                 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
771                     finderClassName, finderMethodName, finderParams,
772                     finderArgs, list);
773 
774                 return list;
775             }
776             catch (Exception e) {
777                 throw processException(e);
778             }
779             finally {
780                 closeSession(session);
781             }
782         }
783         else {
784             return (List<BlogsEntry>)result;
785         }
786     }
787 
788     public BlogsEntry findByGroupId_First(long groupId, OrderByComparator obc)
789         throws NoSuchEntryException, SystemException {
790         List<BlogsEntry> list = findByGroupId(groupId, 0, 1, obc);
791 
792         if (list.size() == 0) {
793             StringBuilder msg = new StringBuilder();
794 
795             msg.append("No BlogsEntry exists with the key {");
796 
797             msg.append("groupId=" + groupId);
798 
799             msg.append(StringPool.CLOSE_CURLY_BRACE);
800 
801             throw new NoSuchEntryException(msg.toString());
802         }
803         else {
804             return list.get(0);
805         }
806     }
807 
808     public BlogsEntry findByGroupId_Last(long groupId, OrderByComparator obc)
809         throws NoSuchEntryException, SystemException {
810         int count = countByGroupId(groupId);
811 
812         List<BlogsEntry> list = findByGroupId(groupId, count - 1, count, obc);
813 
814         if (list.size() == 0) {
815             StringBuilder msg = new StringBuilder();
816 
817             msg.append("No BlogsEntry exists with the key {");
818 
819             msg.append("groupId=" + groupId);
820 
821             msg.append(StringPool.CLOSE_CURLY_BRACE);
822 
823             throw new NoSuchEntryException(msg.toString());
824         }
825         else {
826             return list.get(0);
827         }
828     }
829 
830     public BlogsEntry[] findByGroupId_PrevAndNext(long entryId, long groupId,
831         OrderByComparator obc) throws NoSuchEntryException, SystemException {
832         BlogsEntry blogsEntry = findByPrimaryKey(entryId);
833 
834         int count = countByGroupId(groupId);
835 
836         Session session = null;
837 
838         try {
839             session = openSession();
840 
841             StringBuilder query = new StringBuilder();
842 
843             query.append(
844                 "FROM com.liferay.portlet.blogs.model.BlogsEntry WHERE ");
845 
846             query.append("groupId = ?");
847 
848             query.append(" ");
849 
850             if (obc != null) {
851                 query.append("ORDER BY ");
852                 query.append(obc.getOrderBy());
853             }
854 
855             else {
856                 query.append("ORDER BY ");
857 
858                 query.append("displayDate DESC");
859             }
860 
861             Query q = session.createQuery(query.toString());
862 
863             QueryPos qPos = QueryPos.getInstance(q);
864 
865             qPos.add(groupId);
866 
867             Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
868                     blogsEntry);
869 
870             BlogsEntry[] array = new BlogsEntryImpl[3];
871 
872             array[0] = (BlogsEntry)objArray[0];
873             array[1] = (BlogsEntry)objArray[1];
874             array[2] = (BlogsEntry)objArray[2];
875 
876             return array;
877         }
878         catch (Exception e) {
879             throw processException(e);
880         }
881         finally {
882             closeSession(session);
883         }
884     }
885 
886     public List<BlogsEntry> findByCompanyId(long companyId)
887         throws SystemException {
888         boolean finderClassNameCacheEnabled = BlogsEntryModelImpl.CACHE_ENABLED;
889         String finderClassName = BlogsEntry.class.getName();
890         String finderMethodName = "findByCompanyId";
891         String[] finderParams = new String[] { Long.class.getName() };
892         Object[] finderArgs = new Object[] { new Long(companyId) };
893 
894         Object result = null;
895 
896         if (finderClassNameCacheEnabled) {
897             result = FinderCacheUtil.getResult(finderClassName,
898                     finderMethodName, finderParams, finderArgs, this);
899         }
900 
901         if (result == null) {
902             Session session = null;
903 
904             try {
905                 session = openSession();
906 
907                 StringBuilder query = new StringBuilder();
908 
909                 query.append(
910                     "FROM com.liferay.portlet.blogs.model.BlogsEntry WHERE ");
911 
912                 query.append("companyId = ?");
913 
914                 query.append(" ");
915 
916                 query.append("ORDER BY ");
917 
918                 query.append("displayDate DESC");
919 
920                 Query q = session.createQuery(query.toString());
921 
922                 QueryPos qPos = QueryPos.getInstance(q);
923 
924                 qPos.add(companyId);
925 
926                 List<BlogsEntry> list = q.list();
927 
928                 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
929                     finderClassName, finderMethodName, finderParams,
930                     finderArgs, list);
931 
932                 return list;
933             }
934             catch (Exception e) {
935                 throw processException(e);
936             }
937             finally {
938                 closeSession(session);
939             }
940         }
941         else {
942             return (List<BlogsEntry>)result;
943         }
944     }
945 
946     public List<BlogsEntry> findByCompanyId(long companyId, int start, int end)
947         throws SystemException {
948         return findByCompanyId(companyId, start, end, null);
949     }
950 
951     public List<BlogsEntry> findByCompanyId(long companyId, int start, int end,
952         OrderByComparator obc) throws SystemException {
953         boolean finderClassNameCacheEnabled = BlogsEntryModelImpl.CACHE_ENABLED;
954         String finderClassName = BlogsEntry.class.getName();
955         String finderMethodName = "findByCompanyId";
956         String[] finderParams = new String[] {
957                 Long.class.getName(),
958                 
959                 "java.lang.Integer", "java.lang.Integer",
960                 "com.liferay.portal.kernel.util.OrderByComparator"
961             };
962         Object[] finderArgs = new Object[] {
963                 new Long(companyId),
964                 
965                 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
966             };
967 
968         Object result = null;
969 
970         if (finderClassNameCacheEnabled) {
971             result = FinderCacheUtil.getResult(finderClassName,
972                     finderMethodName, finderParams, finderArgs, this);
973         }
974 
975         if (result == null) {
976             Session session = null;
977 
978             try {
979                 session = openSession();
980 
981                 StringBuilder query = new StringBuilder();
982 
983                 query.append(
984                     "FROM com.liferay.portlet.blogs.model.BlogsEntry WHERE ");
985 
986                 query.append("companyId = ?");
987 
988                 query.append(" ");
989 
990                 if (obc != null) {
991                     query.append("ORDER BY ");
992                     query.append(obc.getOrderBy());
993                 }
994 
995                 else {
996                     query.append("ORDER BY ");
997 
998                     query.append("displayDate DESC");
999                 }
1000
1001                Query q = session.createQuery(query.toString());
1002
1003                QueryPos qPos = QueryPos.getInstance(q);
1004
1005                qPos.add(companyId);
1006
1007                List<BlogsEntry> list = (List<BlogsEntry>)QueryUtil.list(q,
1008                        getDialect(), start, end);
1009
1010                FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1011                    finderClassName, finderMethodName, finderParams,
1012                    finderArgs, list);
1013
1014                return list;
1015            }
1016            catch (Exception e) {
1017                throw processException(e);
1018            }
1019            finally {
1020                closeSession(session);
1021            }
1022        }
1023        else {
1024            return (List<BlogsEntry>)result;
1025        }
1026    }
1027
1028    public BlogsEntry findByCompanyId_First(long companyId,
1029        OrderByComparator obc) throws NoSuchEntryException, SystemException {
1030        List<BlogsEntry> list = findByCompanyId(companyId, 0, 1, obc);
1031
1032        if (list.size() == 0) {
1033            StringBuilder msg = new StringBuilder();
1034
1035            msg.append("No BlogsEntry exists with the key {");
1036
1037            msg.append("companyId=" + companyId);
1038
1039            msg.append(StringPool.CLOSE_CURLY_BRACE);
1040
1041            throw new NoSuchEntryException(msg.toString());
1042        }
1043        else {
1044            return list.get(0);
1045        }
1046    }
1047
1048    public BlogsEntry findByCompanyId_Last(long companyId, OrderByComparator obc)
1049        throws NoSuchEntryException, SystemException {
1050        int count = countByCompanyId(companyId);
1051
1052        List<BlogsEntry> list = findByCompanyId(companyId, count - 1, count, obc);
1053
1054        if (list.size() == 0) {
1055            StringBuilder msg = new StringBuilder();
1056
1057            msg.append("No BlogsEntry exists with the key {");
1058
1059            msg.append("companyId=" + companyId);
1060
1061            msg.append(StringPool.CLOSE_CURLY_BRACE);
1062
1063            throw new NoSuchEntryException(msg.toString());
1064        }
1065        else {
1066            return list.get(0);
1067        }
1068    }
1069
1070    public BlogsEntry[] findByCompanyId_PrevAndNext(long entryId,
1071        long companyId, OrderByComparator obc)
1072        throws NoSuchEntryException, SystemException {
1073        BlogsEntry blogsEntry = findByPrimaryKey(entryId);
1074
1075        int count = countByCompanyId(companyId);
1076
1077        Session session = null;
1078
1079        try {
1080            session = openSession();
1081
1082            StringBuilder query = new StringBuilder();
1083
1084            query.append(
1085                "FROM com.liferay.portlet.blogs.model.BlogsEntry WHERE ");
1086
1087            query.append("companyId = ?");
1088
1089            query.append(" ");
1090
1091            if (obc != null) {
1092                query.append("ORDER BY ");
1093                query.append(obc.getOrderBy());
1094            }
1095
1096            else {
1097                query.append("ORDER BY ");
1098
1099                query.append("displayDate DESC");
1100            }
1101
1102            Query q = session.createQuery(query.toString());
1103
1104            QueryPos qPos = QueryPos.getInstance(q);
1105
1106            qPos.add(companyId);
1107
1108            Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
1109                    blogsEntry);
1110
1111            BlogsEntry[] array = new BlogsEntryImpl[3];
1112
1113            array[0] = (BlogsEntry)objArray[0];
1114            array[1] = (BlogsEntry)objArray[1];
1115            array[2] = (BlogsEntry)objArray[2];
1116
1117            return array;
1118        }
1119        catch (Exception e) {
1120            throw processException(e);
1121        }
1122        finally {
1123            closeSession(session);
1124        }
1125    }
1126
1127    public List<BlogsEntry> findByG_U(long groupId, long userId)
1128        throws SystemException {
1129        boolean finderClassNameCacheEnabled = BlogsEntryModelImpl.CACHE_ENABLED;
1130        String finderClassName = BlogsEntry.class.getName();
1131        String finderMethodName = "findByG_U";
1132        String[] finderParams = new String[] {
1133                Long.class.getName(), Long.class.getName()
1134            };
1135        Object[] finderArgs = new Object[] { new Long(groupId), new Long(userId) };
1136
1137        Object result = null;
1138
1139        if (finderClassNameCacheEnabled) {
1140            result = FinderCacheUtil.getResult(finderClassName,
1141                    finderMethodName, finderParams, finderArgs, this);
1142        }
1143
1144        if (result == null) {
1145            Session session = null;
1146
1147            try {
1148                session = openSession();
1149
1150                StringBuilder query = new StringBuilder();
1151
1152                query.append(
1153                    "FROM com.liferay.portlet.blogs.model.BlogsEntry WHERE ");
1154
1155                query.append("groupId = ?");
1156
1157                query.append(" AND ");
1158
1159                query.append("userId = ?");
1160
1161                query.append(" ");
1162
1163                query.append("ORDER BY ");
1164
1165                query.append("displayDate DESC");
1166
1167                Query q = session.createQuery(query.toString());
1168
1169                QueryPos qPos = QueryPos.getInstance(q);
1170
1171                qPos.add(groupId);
1172
1173                qPos.add(userId);
1174
1175                List<BlogsEntry> list = q.list();
1176
1177                FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1178                    finderClassName, finderMethodName, finderParams,
1179                    finderArgs, list);
1180
1181                return list;
1182            }
1183            catch (Exception e) {
1184                throw processException(e);
1185            }
1186            finally {
1187                closeSession(session);
1188            }
1189        }
1190        else {
1191            return (List<BlogsEntry>)result;
1192        }
1193    }
1194
1195    public List<BlogsEntry> findByG_U(long groupId, long userId, int start,
1196        int end) throws SystemException {
1197        return findByG_U(groupId, userId, start, end, null);
1198    }
1199
1200    public List<BlogsEntry> findByG_U(long groupId, long userId, int start,
1201        int end, OrderByComparator obc) throws SystemException {
1202        boolean finderClassNameCacheEnabled = BlogsEntryModelImpl.CACHE_ENABLED;
1203        String finderClassName = BlogsEntry.class.getName();
1204        String finderMethodName = "findByG_U";
1205        String[] finderParams = new String[] {
1206                Long.class.getName(), Long.class.getName(),
1207                
1208                "java.lang.Integer", "java.lang.Integer",
1209                "com.liferay.portal.kernel.util.OrderByComparator"
1210            };
1211        Object[] finderArgs = new Object[] {
1212                new Long(groupId), new Long(userId),
1213                
1214                String.valueOf(start), String.valueOf(end), String.valueOf(obc)
1215            };
1216
1217        Object result = null;
1218
1219        if (finderClassNameCacheEnabled) {
1220            result = FinderCacheUtil.getResult(finderClassName,
1221                    finderMethodName, finderParams, finderArgs, this);
1222        }
1223
1224        if (result == null) {
1225            Session session = null;
1226
1227            try {
1228                session = openSession();
1229
1230                StringBuilder query = new StringBuilder();
1231
1232                query.append(
1233                    "FROM com.liferay.portlet.blogs.model.BlogsEntry WHERE ");
1234
1235                query.append("groupId = ?");
1236
1237                query.append(" AND ");
1238
1239                query.append("userId = ?");
1240
1241                query.append(" ");
1242
1243                if (obc != null) {
1244                    query.append("ORDER BY ");
1245                    query.append(obc.getOrderBy());
1246                }
1247
1248                else {
1249                    query.append("ORDER BY ");
1250
1251                    query.append("displayDate DESC");
1252                }
1253
1254                Query q = session.createQuery(query.toString());
1255
1256                QueryPos qPos = QueryPos.getInstance(q);
1257
1258                qPos.add(groupId);
1259
1260                qPos.add(userId);
1261
1262                List<BlogsEntry> list = (List<BlogsEntry>)QueryUtil.list(q,
1263                        getDialect(), start, end);
1264
1265                FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1266                    finderClassName, finderMethodName, finderParams,
1267                    finderArgs, list);
1268
1269                return list;
1270            }
1271            catch (Exception e) {
1272                throw processException(e);
1273            }
1274            finally {
1275                closeSession(session);
1276            }
1277        }
1278        else {
1279            return (List<BlogsEntry>)result;
1280        }
1281    }
1282
1283    public BlogsEntry findByG_U_First(long groupId, long userId,
1284        OrderByComparator obc) throws NoSuchEntryException, SystemException {
1285        List<BlogsEntry> list = findByG_U(groupId, userId, 0, 1, obc);
1286
1287        if (list.size() == 0) {
1288            StringBuilder msg = new StringBuilder();
1289
1290            msg.append("No BlogsEntry exists with the key {");
1291
1292            msg.append("groupId=" + groupId);
1293
1294            msg.append(", ");
1295            msg.append("userId=" + userId);
1296
1297            msg.append(StringPool.CLOSE_CURLY_BRACE);
1298
1299            throw new NoSuchEntryException(msg.toString());
1300        }
1301        else {
1302            return list.get(0);
1303        }
1304    }
1305
1306    public BlogsEntry findByG_U_Last(long groupId, long userId,
1307        OrderByComparator obc) throws NoSuchEntryException, SystemException {
1308        int count = countByG_U(groupId, userId);
1309
1310        List<BlogsEntry> list = findByG_U(groupId, userId, count - 1, count, obc);
1311
1312        if (list.size() == 0) {
1313            StringBuilder msg = new StringBuilder();
1314
1315            msg.append("No BlogsEntry exists with the key {");
1316
1317            msg.append("groupId=" + groupId);
1318
1319            msg.append(", ");
1320            msg.append("userId=" + userId);
1321
1322            msg.append(StringPool.CLOSE_CURLY_BRACE);
1323
1324            throw new NoSuchEntryException(msg.toString());
1325        }
1326        else {
1327            return list.get(0);
1328        }
1329    }
1330
1331    public BlogsEntry[] findByG_U_PrevAndNext(long entryId, long groupId,
1332        long userId, OrderByComparator obc)
1333        throws NoSuchEntryException, SystemException {
1334        BlogsEntry blogsEntry = findByPrimaryKey(entryId);
1335
1336        int count = countByG_U(groupId, userId);
1337
1338        Session session = null;
1339
1340        try {
1341            session = openSession();
1342
1343            StringBuilder query = new StringBuilder();
1344
1345            query.append(
1346                "FROM com.liferay.portlet.blogs.model.BlogsEntry WHERE ");
1347
1348            query.append("groupId = ?");
1349
1350            query.append(" AND ");
1351
1352            query.append("userId = ?");
1353
1354            query.append(" ");
1355
1356            if (obc != null) {
1357                query.append("ORDER BY ");
1358                query.append(obc.getOrderBy());
1359            }
1360
1361            else {
1362                query.append("ORDER BY ");
1363
1364                query.append("displayDate DESC");
1365            }
1366
1367            Query q = session.createQuery(query.toString());
1368
1369            QueryPos qPos = QueryPos.getInstance(q);
1370
1371            qPos.add(groupId);
1372
1373            qPos.add(userId);
1374
1375            Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
1376                    blogsEntry);
1377
1378            BlogsEntry[] array = new BlogsEntryImpl[3];
1379
1380            array[0] = (BlogsEntry)objArray[0];
1381            array[1] = (BlogsEntry)objArray[1];
1382            array[2] = (BlogsEntry)objArray[2];
1383
1384            return array;
1385        }
1386        catch (Exception e) {
1387            throw processException(e);
1388        }
1389        finally {
1390            closeSession(session);
1391        }
1392    }
1393
1394    public BlogsEntry findByG_UT(long groupId, String urlTitle)
1395        throws NoSuchEntryException, SystemException {
1396        BlogsEntry blogsEntry = fetchByG_UT(groupId, urlTitle);
1397
1398        if (blogsEntry == null) {
1399            StringBuilder msg = new StringBuilder();
1400
1401            msg.append("No BlogsEntry exists with the key {");
1402
1403            msg.append("groupId=" + groupId);
1404
1405            msg.append(", ");
1406            msg.append("urlTitle=" + urlTitle);
1407
1408            msg.append(StringPool.CLOSE_CURLY_BRACE);
1409
1410            if (_log.isWarnEnabled()) {
1411                _log.warn(msg.toString());
1412            }
1413
1414            throw new NoSuchEntryException(msg.toString());
1415        }
1416
1417        return blogsEntry;
1418    }
1419
1420    public BlogsEntry fetchByG_UT(long groupId, String urlTitle)
1421        throws SystemException {
1422        boolean finderClassNameCacheEnabled = BlogsEntryModelImpl.CACHE_ENABLED;
1423        String finderClassName = BlogsEntry.class.getName();
1424        String finderMethodName = "fetchByG_UT";
1425        String[] finderParams = new String[] {
1426                Long.class.getName(), String.class.getName()
1427            };
1428        Object[] finderArgs = new Object[] { new Long(groupId), urlTitle };
1429
1430        Object result = null;
1431
1432        if (finderClassNameCacheEnabled) {
1433            result = FinderCacheUtil.getResult(finderClassName,
1434                    finderMethodName, finderParams, finderArgs, this);
1435        }
1436
1437        if (result == null) {
1438            Session session = null;
1439
1440            try {
1441                session = openSession();
1442
1443                StringBuilder query = new StringBuilder();
1444
1445                query.append(
1446                    "FROM com.liferay.portlet.blogs.model.BlogsEntry WHERE ");
1447
1448                query.append("groupId = ?");
1449
1450                query.append(" AND ");
1451
1452                if (urlTitle == null) {
1453                    query.append("urlTitle IS NULL");
1454                }
1455                else {
1456                    query.append("urlTitle = ?");
1457                }
1458
1459                query.append(" ");
1460
1461                query.append("ORDER BY ");
1462
1463                query.append("displayDate DESC");
1464
1465                Query q = session.createQuery(query.toString());
1466
1467                QueryPos qPos = QueryPos.getInstance(q);
1468
1469                qPos.add(groupId);
1470
1471                if (urlTitle != null) {
1472                    qPos.add(urlTitle);
1473                }
1474
1475                List<BlogsEntry> list = q.list();
1476
1477                FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1478                    finderClassName, finderMethodName, finderParams,
1479                    finderArgs, list);
1480
1481                if (list.size() == 0) {
1482                    return null;
1483                }
1484                else {
1485                    return list.get(0);
1486                }
1487            }
1488            catch (Exception e) {
1489                throw processException(e);
1490            }
1491            finally {
1492                closeSession(session);
1493            }
1494        }
1495        else {
1496            List<BlogsEntry> list = (List<BlogsEntry>)result;
1497
1498            if (list.size() == 0) {
1499                return null;
1500            }
1501            else {
1502                return list.get(0);
1503            }
1504        }
1505    }
1506
1507    public List<BlogsEntry> findByG_D_D(long groupId, Date displayDate,
1508        boolean draft) throws SystemException {
1509        boolean finderClassNameCacheEnabled = BlogsEntryModelImpl.CACHE_ENABLED;
1510        String finderClassName = BlogsEntry.class.getName();
1511        String finderMethodName = "findByG_D_D";
1512        String[] finderParams = new String[] {
1513                Long.class.getName(), Date.class.getName(),
1514                Boolean.class.getName()
1515            };
1516        Object[] finderArgs = new Object[] {
1517                new Long(groupId),
1518                
1519                displayDate, Boolean.valueOf(draft)
1520            };
1521
1522        Object result = null;
1523
1524        if (finderClassNameCacheEnabled) {
1525            result = FinderCacheUtil.getResult(finderClassName,
1526                    finderMethodName, finderParams, finderArgs, this);
1527        }
1528
1529        if (result == null) {
1530            Session session = null;
1531
1532            try {
1533                session = openSession();
1534
1535                StringBuilder query = new StringBuilder();
1536
1537                query.append(
1538                    "FROM com.liferay.portlet.blogs.model.BlogsEntry WHERE ");
1539
1540                query.append("groupId = ?");
1541
1542                query.append(" AND ");
1543
1544                if (displayDate == null) {
1545                    query.append("displayDate < null");
1546                }
1547                else {
1548                    query.append("displayDate < ?");
1549                }
1550
1551                query.append(" AND ");
1552
1553                query.append("draft = ?");
1554
1555                query.append(" ");
1556
1557                query.append("ORDER BY ");
1558
1559                query.append("displayDate DESC");
1560
1561                Query q = session.createQuery(query.toString());
1562
1563                QueryPos qPos = QueryPos.getInstance(q);
1564
1565                qPos.add(groupId);
1566
1567                if (displayDate != null) {
1568                    qPos.add(CalendarUtil.getTimestamp(displayDate));
1569                }
1570
1571                qPos.add(draft);
1572
1573                List<BlogsEntry> list = q.list();
1574
1575                FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1576                    finderClassName, finderMethodName, finderParams,
1577                    finderArgs, list);
1578
1579                return list;
1580            }
1581            catch (Exception e) {
1582                throw processException(e);
1583            }
1584            finally {
1585                closeSession(session);
1586            }
1587        }
1588        else {
1589            return (List<BlogsEntry>)result;
1590        }
1591    }
1592
1593    public List<BlogsEntry> findByG_D_D(long groupId, Date displayDate,
1594        boolean draft, int start, int end) throws SystemException {
1595        return findByG_D_D(groupId, displayDate, draft, start, end, null);
1596    }
1597
1598    public List<BlogsEntry> findByG_D_D(long groupId, Date displayDate,
1599        boolean draft, int start, int end, OrderByComparator obc)
1600        throws SystemException {
1601        boolean finderClassNameCacheEnabled = BlogsEntryModelImpl.CACHE_ENABLED;
1602        String finderClassName = BlogsEntry.class.getName();
1603        String finderMethodName = "findByG_D_D";
1604        String[] finderParams = new String[] {
1605                Long.class.getName(), Date.class.getName(),
1606                Boolean.class.getName(),
1607                
1608                "java.lang.Integer", "java.lang.Integer",
1609                "com.liferay.portal.kernel.util.OrderByComparator"
1610            };
1611        Object[] finderArgs = new Object[] {
1612                new Long(groupId),
1613                
1614                displayDate, Boolean.valueOf(draft),
1615                
1616                String.valueOf(start), String.valueOf(end), String.valueOf(obc)
1617            };
1618
1619        Object result = null;
1620
1621        if (finderClassNameCacheEnabled) {
1622            result = FinderCacheUtil.getResult(finderClassName,
1623                    finderMethodName, finderParams, finderArgs, this);
1624        }
1625
1626        if (result == null) {
1627            Session session = null;
1628
1629            try {
1630                session = openSession();
1631
1632                StringBuilder query = new StringBuilder();
1633
1634                query.append(
1635                    "FROM com.liferay.portlet.blogs.model.BlogsEntry WHERE ");
1636
1637                query.append("groupId = ?");
1638
1639                query.append(" AND ");
1640
1641                if (displayDate == null) {
1642                    query.append("displayDate < null");
1643                }
1644                else {
1645                    query.append("displayDate < ?");
1646                }
1647
1648                query.append(" AND ");
1649
1650                query.append("draft = ?");
1651
1652                query.append(" ");
1653
1654                if (obc != null) {
1655                    query.append("ORDER BY ");
1656                    query.append(obc.getOrderBy());
1657                }
1658
1659                else {
1660                    query.append("ORDER BY ");
1661
1662                    query.append("displayDate DESC");
1663                }
1664
1665                Query q = session.createQuery(query.toString());
1666
1667                QueryPos qPos = QueryPos.getInstance(q);
1668
1669                qPos.add(groupId);
1670
1671                if (displayDate != null) {
1672                    qPos.add(CalendarUtil.getTimestamp(displayDate));
1673                }
1674
1675                qPos.add(draft);
1676
1677                List<BlogsEntry> list = (List<BlogsEntry>)QueryUtil.list(q,
1678                        getDialect(), start, end);
1679
1680                FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1681                    finderClassName, finderMethodName, finderParams,
1682                    finderArgs, list);
1683
1684                return list;
1685            }
1686            catch (Exception e) {
1687                throw processException(e);
1688            }
1689            finally {
1690                closeSession(session);
1691            }
1692        }
1693        else {
1694            return (List<BlogsEntry>)result;
1695        }
1696    }
1697
1698    public BlogsEntry findByG_D_D_First(long groupId, Date displayDate,
1699        boolean draft, OrderByComparator obc)
1700        throws NoSuchEntryException, SystemException {
1701        List<BlogsEntry> list = findByG_D_D(groupId, displayDate, draft, 0, 1,
1702                obc);
1703
1704        if (list.size() == 0) {
1705            StringBuilder msg = new StringBuilder();
1706
1707            msg.append("No BlogsEntry exists with the key {");
1708
1709            msg.append("groupId=" + groupId);
1710
1711            msg.append(", ");
1712            msg.append("displayDate=" + displayDate);
1713
1714            msg.append(", ");
1715            msg.append("draft=" + draft);
1716
1717            msg.append(StringPool.CLOSE_CURLY_BRACE);
1718
1719            throw new NoSuchEntryException(msg.toString());
1720        }
1721        else {
1722            return list.get(0);
1723        }
1724    }
1725
1726    public BlogsEntry findByG_D_D_Last(long groupId, Date displayDate,
1727        boolean draft, OrderByComparator obc)
1728        throws NoSuchEntryException, SystemException {
1729        int count = countByG_D_D(groupId, displayDate, draft);
1730
1731        List<BlogsEntry> list = findByG_D_D(groupId, displayDate, draft,
1732                count - 1, count, obc);
1733
1734        if (list.size() == 0) {
1735            StringBuilder msg = new StringBuilder();
1736
1737            msg.append("No BlogsEntry exists with the key {");
1738
1739            msg.append("groupId=" + groupId);
1740
1741            msg.append(", ");
1742            msg.append("displayDate=" + displayDate);
1743
1744            msg.append(", ");
1745            msg.append("draft=" + draft);
1746
1747            msg.append(StringPool.CLOSE_CURLY_BRACE);
1748
1749            throw new NoSuchEntryException(msg.toString());
1750        }
1751        else {
1752            return list.get(0);
1753        }
1754    }
1755
1756    public BlogsEntry[] findByG_D_D_PrevAndNext(long entryId, long groupId,
1757        Date displayDate, boolean draft, OrderByComparator obc)
1758        throws NoSuchEntryException, SystemException {
1759        BlogsEntry blogsEntry = findByPrimaryKey(entryId);
1760
1761        int count = countByG_D_D(groupId, displayDate, draft);
1762
1763        Session session = null;
1764
1765        try {
1766            session = openSession();
1767
1768            StringBuilder query = new StringBuilder();
1769
1770            query.append(
1771                "FROM com.liferay.portlet.blogs.model.BlogsEntry WHERE ");
1772
1773            query.append("groupId = ?");
1774
1775            query.append(" AND ");
1776
1777            if (displayDate == null) {
1778                query.append("displayDate < null");
1779            }
1780            else {
1781                query.append("displayDate < ?");
1782            }
1783
1784            query.append(" AND ");
1785
1786            query.append("draft = ?");
1787
1788            query.append(" ");
1789
1790            if (obc != null) {
1791                query.append("ORDER BY ");
1792                query.append(obc.getOrderBy());
1793            }
1794
1795            else {
1796                query.append("ORDER BY ");
1797
1798                query.append("displayDate DESC");
1799            }
1800
1801            Query q = session.createQuery(query.toString());
1802
1803            QueryPos qPos = QueryPos.getInstance(q);
1804
1805            qPos.add(groupId);
1806
1807            if (displayDate != null) {
1808                qPos.add(CalendarUtil.getTimestamp(displayDate));
1809            }
1810
1811            qPos.add(draft);
1812
1813            Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
1814                    blogsEntry);
1815
1816            BlogsEntry[] array = new BlogsEntryImpl[3];
1817
1818            array[0] = (BlogsEntry)objArray[0];
1819            array[1] = (BlogsEntry)objArray[1];
1820            array[2] = (BlogsEntry)objArray[2];
1821
1822            return array;
1823        }
1824        catch (Exception e) {
1825            throw processException(e);
1826        }
1827        finally {
1828            closeSession(session);
1829        }
1830    }
1831
1832    public List<BlogsEntry> findByC_D_D(long companyId, Date displayDate,
1833        boolean draft) throws SystemException {
1834        boolean finderClassNameCacheEnabled = BlogsEntryModelImpl.CACHE_ENABLED;
1835        String finderClassName = BlogsEntry.class.getName();
1836        String finderMethodName = "findByC_D_D";
1837        String[] finderParams = new String[] {
1838                Long.class.getName(), Date.class.getName(),
1839                Boolean.class.getName()
1840            };
1841        Object[] finderArgs = new Object[] {
1842                new Long(companyId),
1843                
1844                displayDate, Boolean.valueOf(draft)
1845            };
1846
1847        Object result = null;
1848
1849        if (finderClassNameCacheEnabled) {
1850            result = FinderCacheUtil.getResult(finderClassName,
1851                    finderMethodName, finderParams, finderArgs, this);
1852        }
1853
1854        if (result == null) {
1855            Session session = null;
1856
1857            try {
1858                session = openSession();
1859
1860                StringBuilder query = new StringBuilder();
1861
1862                query.append(
1863                    "FROM com.liferay.portlet.blogs.model.BlogsEntry WHERE ");
1864
1865                query.append("companyId = ?");
1866
1867                query.append(" AND ");
1868
1869                if (displayDate == null) {
1870                    query.append("displayDate < null");
1871                }
1872                else {
1873                    query.append("displayDate < ?");
1874                }
1875
1876                query.append(" AND ");
1877
1878                query.append("draft = ?");
1879
1880                query.append(" ");
1881
1882                query.append("ORDER BY ");
1883
1884                query.append("displayDate DESC");
1885
1886                Query q = session.createQuery(query.toString());
1887
1888                QueryPos qPos = QueryPos.getInstance(q);
1889
1890                qPos.add(companyId);
1891
1892                if (displayDate != null) {
1893                    qPos.add(CalendarUtil.getTimestamp(displayDate));
1894                }
1895
1896                qPos.add(draft);
1897
1898                List<BlogsEntry> list = q.list();
1899
1900                FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1901                    finderClassName, finderMethodName, finderParams,
1902                    finderArgs, list);
1903
1904                return list;
1905            }
1906            catch (Exception e) {
1907                throw processException(e);
1908            }
1909            finally {
1910                closeSession(session);
1911            }
1912        }
1913        else {
1914            return (List<BlogsEntry>)result;
1915        }
1916    }
1917
1918    public List<BlogsEntry> findByC_D_D(long companyId, Date displayDate,
1919        boolean draft, int start, int end) throws SystemException {
1920        return findByC_D_D(companyId, displayDate, draft, start, end, null);
1921    }
1922
1923    public List<BlogsEntry> findByC_D_D(long companyId, Date displayDate,
1924        boolean draft, int start, int end, OrderByComparator obc)
1925        throws SystemException {
1926        boolean finderClassNameCacheEnabled = BlogsEntryModelImpl.CACHE_ENABLED;
1927        String finderClassName = BlogsEntry.class.getName();
1928        String finderMethodName = "findByC_D_D";
1929        String[] finderParams = new String[] {
1930                Long.class.getName(), Date.class.getName(),
1931                Boolean.class.getName(),
1932                
1933                "java.lang.Integer", "java.lang.Integer",
1934                "com.liferay.portal.kernel.util.OrderByComparator"
1935            };
1936        Object[] finderArgs = new Object[] {
1937                new Long(companyId),
1938                
1939                displayDate, Boolean.valueOf(draft),
1940                
1941                String.valueOf(start), String.valueOf(end), String.valueOf(obc)
1942            };
1943
1944        Object result = null;
1945
1946        if (finderClassNameCacheEnabled) {
1947            result = FinderCacheUtil.getResult(finderClassName,
1948                    finderMethodName, finderParams, finderArgs, this);
1949        }
1950
1951        if (result == null) {
1952            Session session = null;
1953
1954            try {
1955                session = openSession();
1956
1957                StringBuilder query = new StringBuilder();
1958
1959                query.append(
1960                    "FROM com.liferay.portlet.blogs.model.BlogsEntry WHERE ");
1961
1962                query.append("companyId = ?");
1963
1964                query.append(" AND ");
1965
1966                if (displayDate == null) {
1967                    query.append("displayDate < null");
1968                }
1969                else {
1970                    query.append("displayDate < ?");
1971                }
1972
1973                query.append(" AND ");
1974
1975                query.append("draft = ?");
1976
1977                query.append(" ");
1978
1979                if (obc != null) {
1980                    query.append("ORDER BY ");
1981                    query.append(obc.getOrderBy());
1982                }
1983
1984                else {
1985                    query.append("ORDER BY ");
1986
1987                    query.append("displayDate DESC");
1988                }
1989
1990                Query q = session.createQuery(query.toString());
1991
1992                QueryPos qPos = QueryPos.getInstance(q);
1993
1994                qPos.add(companyId);
1995
1996                if (displayDate != null) {
1997                    qPos.add(CalendarUtil.getTimestamp(displayDate));
1998                }
1999
2000                qPos.add(draft);
2001
2002                List<BlogsEntry> list = (List<BlogsEntry>)QueryUtil.list(q,
2003                        getDialect(), start, end);
2004
2005                FinderCacheUtil.putResult(finderClassNameCacheEnabled,
2006                    finderClassName, finderMethodName, finderParams,
2007                    finderArgs, list);
2008
2009                return list;
2010            }
2011            catch (Exception e) {
2012                throw processException(e);
2013            }
2014            finally {
2015                closeSession(session);
2016            }
2017        }
2018        else {
2019            return (List<BlogsEntry>)result;
2020        }
2021    }
2022
2023    public BlogsEntry findByC_D_D_First(long companyId, Date displayDate,
2024        boolean draft, OrderByComparator obc)
2025        throws NoSuchEntryException, SystemException {
2026        List<BlogsEntry> list = findByC_D_D(companyId, displayDate, draft, 0,
2027                1, obc);
2028
2029        if (list.size() == 0) {
2030            StringBuilder msg = new StringBuilder();
2031
2032            msg.append("No BlogsEntry exists with the key {");
2033
2034            msg.append("companyId=" + companyId);
2035
2036            msg.append(", ");
2037            msg.append("displayDate=" + displayDate);
2038
2039            msg.append(", ");
2040            msg.append("draft=" + draft);
2041
2042            msg.append(StringPool.CLOSE_CURLY_BRACE);
2043
2044            throw new NoSuchEntryException(msg.toString());
2045        }
2046        else {
2047            return list.get(0);
2048        }
2049    }
2050
2051    public BlogsEntry findByC_D_D_Last(long companyId, Date displayDate,
2052        boolean draft, OrderByComparator obc)
2053        throws NoSuchEntryException, SystemException {
2054        int count = countByC_D_D(companyId, displayDate, draft);
2055
2056        List<BlogsEntry> list = findByC_D_D(companyId, displayDate, draft,
2057                count - 1, count, obc);
2058
2059        if (list.size() == 0) {
2060            StringBuilder msg = new StringBuilder();
2061
2062            msg.append("No BlogsEntry exists with the key {");
2063
2064            msg.append("companyId=" + companyId);
2065
2066            msg.append(", ");
2067            msg.append("displayDate=" + displayDate);
2068
2069            msg.append(", ");
2070            msg.append("draft=" + draft);
2071
2072            msg.append(StringPool.CLOSE_CURLY_BRACE);
2073
2074            throw new NoSuchEntryException(msg.toString());
2075        }
2076        else {
2077            return list.get(0);
2078        }
2079    }
2080
2081    public BlogsEntry[] findByC_D_D_PrevAndNext(long entryId, long companyId,
2082        Date displayDate, boolean draft, OrderByComparator obc)
2083        throws NoSuchEntryException, SystemException {
2084        BlogsEntry blogsEntry = findByPrimaryKey(entryId);
2085
2086        int count = countByC_D_D(companyId, displayDate, draft);
2087
2088        Session session = null;
2089
2090        try {
2091            session = openSession();
2092
2093            StringBuilder query = new StringBuilder();
2094
2095            query.append(
2096                "FROM com.liferay.portlet.blogs.model.BlogsEntry WHERE ");
2097
2098            query.append("companyId = ?");
2099
2100            query.append(" AND ");
2101
2102            if (displayDate == null) {
2103                query.append("displayDate < null");
2104            }
2105            else {
2106                query.append("displayDate < ?");
2107            }
2108
2109            query.append(" AND ");
2110
2111            query.append("draft = ?");
2112
2113            query.append(" ");
2114
2115            if (obc != null) {
2116                query.append("ORDER BY ");
2117                query.append(obc.getOrderBy());
2118            }
2119
2120            else {
2121                query.append("ORDER BY ");
2122
2123                query.append("displayDate DESC");
2124            }
2125
2126            Query q = session.createQuery(query.toString());
2127
2128            QueryPos qPos = QueryPos.getInstance(q);
2129
2130            qPos.add(companyId);
2131
2132            if (displayDate != null) {
2133                qPos.add(CalendarUtil.getTimestamp(displayDate));
2134            }
2135
2136            qPos.add(draft);
2137
2138            Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
2139                    blogsEntry);
2140
2141            BlogsEntry[] array = new BlogsEntryImpl[3];
2142
2143            array[0] = (BlogsEntry)objArray[0];
2144            array[1] = (BlogsEntry)objArray[1];
2145            array[2] = (BlogsEntry)objArray[2];
2146
2147            return array;
2148        }
2149        catch (Exception e) {
2150            throw processException(e);
2151        }
2152        finally {
2153            closeSession(session);
2154        }
2155    }
2156
2157    public List<BlogsEntry> findByG_U_D_D(long groupId, long userId,
2158        Date displayDate, boolean draft) throws SystemException {
2159        boolean finderClassNameCacheEnabled = BlogsEntryModelImpl.CACHE_ENABLED;
2160        String finderClassName = BlogsEntry.class.getName();
2161        String finderMethodName = "findByG_U_D_D";
2162        String[] finderParams = new String[] {
2163                Long.class.getName(), Long.class.getName(), Date.class.getName(),
2164                Boolean.class.getName()
2165            };
2166        Object[] finderArgs = new Object[] {
2167                new Long(groupId), new Long(userId),
2168                
2169                displayDate, Boolean.valueOf(draft)
2170            };
2171
2172        Object result = null;
2173
2174        if (finderClassNameCacheEnabled) {
2175            result = FinderCacheUtil.getResult(finderClassName,
2176                    finderMethodName, finderParams, finderArgs, this);
2177        }
2178
2179        if (result == null) {
2180            Session session = null;
2181
2182            try {
2183                session = openSession();
2184
2185                StringBuilder query = new StringBuilder();
2186
2187                query.append(
2188                    "FROM com.liferay.portlet.blogs.model.BlogsEntry WHERE ");
2189
2190                query.append("groupId = ?");
2191
2192                query.append(" AND ");
2193
2194                query.append("userId = ?");
2195
2196                query.append(" AND ");
2197
2198                if (displayDate == null) {
2199                    query.append("displayDate < null");
2200                }
2201                else {
2202                    query.append("displayDate < ?");
2203                }
2204
2205                query.append(" AND ");
2206
2207                query.append("draft = ?");
2208
2209                query.append(" ");
2210
2211                query.append("ORDER BY ");
2212
2213                query.append("displayDate DESC");
2214
2215                Query q = session.createQuery(query.toString());
2216
2217                QueryPos qPos = QueryPos.getInstance(q);
2218
2219                qPos.add(groupId);
2220
2221                qPos.add(userId);
2222
2223                if (displayDate != null) {
2224                    qPos.add(CalendarUtil.getTimestamp(displayDate));
2225                }
2226
2227                qPos.add(draft);
2228
2229                List<BlogsEntry> list = q.list();
2230
2231                FinderCacheUtil.putResult(finderClassNameCacheEnabled,
2232                    finderClassName, finderMethodName, finderParams,
2233                    finderArgs, list);
2234
2235                return list;
2236            }
2237            catch (Exception e) {
2238                throw processException(e);
2239            }
2240            finally {
2241                closeSession(session);
2242            }
2243        }
2244        else {
2245            return (List<BlogsEntry>)result;
2246        }
2247    }
2248
2249    public List<BlogsEntry> findByG_U_D_D(long groupId, long userId,
2250        Date displayDate, boolean draft, int start, int end)
2251        throws SystemException {
2252        return findByG_U_D_D(groupId, userId, displayDate, draft, start, end,
2253            null);
2254    }
2255
2256    public List<BlogsEntry> findByG_U_D_D(long groupId, long userId,
2257        Date displayDate, boolean draft, int start, int end,
2258        OrderByComparator obc) throws SystemException {
2259        boolean finderClassNameCacheEnabled = BlogsEntryModelImpl.CACHE_ENABLED;
2260        String finderClassName = BlogsEntry.class.getName();
2261        String finderMethodName = "findByG_U_D_D";
2262        String[] finderParams = new String[] {
2263                Long.class.getName(), Long.class.getName(), Date.class.getName(),
2264                Boolean.class.getName(),
2265                
2266                "java.lang.Integer", "java.lang.Integer",
2267                "com.liferay.portal.kernel.util.OrderByComparator"
2268            };
2269        Object[] finderArgs = new Object[] {
2270                new Long(groupId), new Long(userId),
2271                
2272                displayDate, Boolean.valueOf(draft),
2273                
2274                String.valueOf(start), String.valueOf(end), String.valueOf(obc)
2275            };
2276
2277        Object result = null;
2278
2279        if (finderClassNameCacheEnabled) {
2280            result = FinderCacheUtil.getResult(finderClassName,
2281                    finderMethodName, finderParams, finderArgs, this);
2282        }
2283
2284        if (result == null) {
2285            Session session = null;
2286
2287            try {
2288                session = openSession();
2289
2290                StringBuilder query = new StringBuilder();
2291
2292                query.append(
2293                    "FROM com.liferay.portlet.blogs.model.BlogsEntry WHERE ");
2294
2295                query.append("groupId = ?");
2296
2297                query.append(" AND ");
2298
2299                query.append("userId = ?");
2300
2301                query.append(" AND ");
2302
2303                if (displayDate == null) {
2304                    query.append("displayDate < null");
2305                }
2306                else {
2307                    query.append("displayDate < ?");
2308                }
2309
2310                query.append(" AND ");
2311
2312                query.append("draft = ?");
2313
2314                query.append(" ");
2315
2316                if (obc != null) {
2317                    query.append("ORDER BY ");
2318                    query.append(obc.getOrderBy());
2319                }
2320
2321                else {
2322                    query.append("ORDER BY ");
2323
2324                    query.append("displayDate DESC");
2325                }
2326
2327                Query q = session.createQuery(query.toString());
2328
2329                QueryPos qPos = QueryPos.getInstance(q);
2330
2331                qPos.add(groupId);
2332
2333                qPos.add(userId);
2334
2335                if (displayDate != null) {
2336                    qPos.add(CalendarUtil.getTimestamp(displayDate));
2337                }
2338
2339                qPos.add(draft);
2340
2341                List<BlogsEntry> list = (List<BlogsEntry>)QueryUtil.list(q,
2342                        getDialect(), start, end);
2343
2344                FinderCacheUtil.putResult(finderClassNameCacheEnabled,
2345                    finderClassName, finderMethodName, finderParams,
2346                    finderArgs, list);
2347
2348                return list;
2349            }
2350            catch (Exception e) {
2351                throw processException(e);
2352            }
2353            finally {
2354                closeSession(session);
2355            }
2356        }
2357        else {
2358            return (List<BlogsEntry>)result;
2359        }
2360    }
2361
2362    public BlogsEntry findByG_U_D_D_First(long groupId, long userId,
2363        Date displayDate, boolean draft, OrderByComparator obc)
2364        throws NoSuchEntryException, SystemException {
2365        List<BlogsEntry> list = findByG_U_D_D(groupId, userId, displayDate,
2366                draft, 0, 1, obc);
2367
2368        if (list.size() == 0) {
2369            StringBuilder msg = new StringBuilder();
2370
2371            msg.append("No BlogsEntry exists with the key {");
2372
2373            msg.append("groupId=" + groupId);
2374
2375            msg.append(", ");
2376            msg.append("userId=" + userId);
2377
2378            msg.append(", ");
2379            msg.append("displayDate=" + displayDate);
2380
2381            msg.append(", ");
2382            msg.append("draft=" + draft);
2383
2384            msg.append(StringPool.CLOSE_CURLY_BRACE);
2385
2386            throw new NoSuchEntryException(msg.toString());
2387        }
2388        else {
2389            return list.get(0);
2390        }
2391    }
2392
2393    public BlogsEntry findByG_U_D_D_Last(long groupId, long userId,
2394        Date displayDate, boolean draft, OrderByComparator obc)
2395        throws NoSuchEntryException, SystemException {
2396        int count = countByG_U_D_D(groupId, userId, displayDate, draft);
2397
2398        List<BlogsEntry> list = findByG_U_D_D(groupId, userId, displayDate,
2399                draft, count - 1, count, obc);
2400
2401        if (list.size() == 0) {
2402            StringBuilder msg = new StringBuilder();
2403
2404            msg.append("No BlogsEntry exists with the key {");
2405
2406            msg.append("groupId=" + groupId);
2407
2408            msg.append(", ");
2409            msg.append("userId=" + userId);
2410
2411            msg.append(", ");
2412            msg.append("displayDate=" + displayDate);
2413
2414            msg.append(", ");
2415            msg.append("draft=" + draft);
2416
2417            msg.append(StringPool.CLOSE_CURLY_BRACE);
2418
2419            throw new NoSuchEntryException(msg.toString());
2420        }
2421        else {
2422            return list.get(0);
2423        }
2424    }
2425
2426    public BlogsEntry[] findByG_U_D_D_PrevAndNext(long entryId, long groupId,
2427        long userId, Date displayDate, boolean draft, OrderByComparator obc)
2428        throws NoSuchEntryException, SystemException {
2429        BlogsEntry blogsEntry = findByPrimaryKey(entryId);
2430
2431        int count = countByG_U_D_D(groupId, userId, displayDate, draft);
2432
2433        Session session = null;
2434
2435        try {
2436            session = openSession();
2437
2438            StringBuilder query = new StringBuilder();
2439
2440            query.append(
2441                "FROM com.liferay.portlet.blogs.model.BlogsEntry WHERE ");
2442
2443            query.append("groupId = ?");
2444
2445            query.append(" AND ");
2446
2447            query.append("userId = ?");
2448
2449            query.append(" AND ");
2450
2451            if (displayDate == null) {
2452                query.append("displayDate < null");
2453            }
2454            else {
2455                query.append("displayDate < ?");
2456            }
2457
2458            query.append(" AND ");
2459
2460            query.append("draft = ?");
2461
2462            query.append(" ");
2463
2464            if (obc != null) {
2465                query.append("ORDER BY ");
2466                query.append(obc.getOrderBy());
2467            }
2468
2469            else {
2470                query.append("ORDER BY ");
2471
2472                query.append("displayDate DESC");
2473            }
2474
2475            Query q = session.createQuery(query.toString());
2476
2477            QueryPos qPos = QueryPos.getInstance(q);
2478
2479            qPos.add(groupId);
2480
2481            qPos.add(userId);
2482
2483            if (displayDate != null) {
2484                qPos.add(CalendarUtil.getTimestamp(displayDate));
2485            }
2486
2487            qPos.add(draft);
2488
2489            Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
2490                    blogsEntry);
2491
2492            BlogsEntry[] array = new BlogsEntryImpl[3];
2493
2494            array[0] = (BlogsEntry)objArray[0];
2495            array[1] = (BlogsEntry)objArray[1];
2496            array[2] = (BlogsEntry)objArray[2];
2497
2498            return array;
2499        }
2500        catch (Exception e) {
2501            throw processException(e);
2502        }
2503        finally {
2504            closeSession(session);
2505        }
2506    }
2507
2508    public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery)
2509        throws SystemException {
2510        Session session = null;
2511
2512        try {
2513            session = openSession();
2514
2515            dynamicQuery.compile(session);
2516
2517            return dynamicQuery.list();
2518        }
2519        catch (Exception e) {
2520            throw processException(e);
2521        }
2522        finally {
2523            closeSession(session);
2524        }
2525    }
2526
2527    public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery,
2528        int start, int end) throws SystemException {
2529        Session session = null;
2530
2531        try {
2532            session = openSession();
2533
2534            dynamicQuery.setLimit(start, end);
2535
2536            dynamicQuery.compile(session);
2537
2538            return dynamicQuery.list();
2539        }
2540        catch (Exception e) {
2541            throw processException(e);
2542        }
2543        finally {
2544            closeSession(session);
2545        }
2546    }
2547
2548    public List<BlogsEntry> findAll() throws SystemException {
2549        return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2550    }
2551
2552    public List<BlogsEntry> findAll(int start, int end)
2553        throws SystemException {
2554        return findAll(start, end, null);
2555    }
2556
2557    public List<BlogsEntry> findAll(int start, int end, OrderByComparator obc)
2558        throws SystemException {
2559        boolean finderClassNameCacheEnabled = BlogsEntryModelImpl.CACHE_ENABLED;
2560        String finderClassName = BlogsEntry.class.getName();
2561        String finderMethodName = "findAll";
2562        String[] finderParams = new String[] {
2563                "java.lang.Integer", "java.lang.Integer",
2564                "com.liferay.portal.kernel.util.OrderByComparator"
2565            };
2566        Object[] finderArgs = new Object[] {
2567                String.valueOf(start), String.valueOf(end), String.valueOf(obc)
2568            };
2569
2570        Object result = null;
2571
2572        if (finderClassNameCacheEnabled) {
2573            result = FinderCacheUtil.getResult(finderClassName,
2574                    finderMethodName, finderParams, finderArgs, this);
2575        }
2576
2577        if (result == null) {
2578            Session session = null;
2579
2580            try {
2581                session = openSession();
2582
2583                StringBuilder query = new StringBuilder();
2584
2585                query.append("FROM com.liferay.portlet.blogs.model.BlogsEntry ");
2586
2587                if (obc != null) {
2588                    query.append("ORDER BY ");
2589                    query.append(obc.getOrderBy());
2590                }
2591
2592                else {
2593                    query.append("ORDER BY ");
2594
2595                    query.append("displayDate DESC");
2596                }
2597
2598                Query q = session.createQuery(query.toString());
2599
2600                List<BlogsEntry> list = null;
2601
2602                if (obc == null) {
2603                    list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
2604                            start, end, false);
2605
2606                    Collections.sort(list);
2607                }
2608                else {
2609                    list = (List<BlogsEntry>)QueryUtil.list(q, getDialect(),
2610                            start, end);
2611                }
2612
2613                FinderCacheUtil.putResult(finderClassNameCacheEnabled,
2614                    finderClassName, finderMethodName, finderParams,
2615                    finderArgs, list);
2616
2617                return list;
2618            }
2619            catch (Exception e) {
2620                throw processException(e);
2621            }
2622            finally {
2623                closeSession(session);
2624            }
2625        }
2626        else {
2627            return (List<BlogsEntry>)result;
2628        }
2629    }
2630
2631    public void removeByUuid(String uuid) throws SystemException {
2632        for (BlogsEntry blogsEntry : findByUuid(uuid)) {
2633            remove(blogsEntry);
2634        }
2635    }
2636
2637    public void removeByUUID_G(String uuid, long groupId)
2638        throws NoSuchEntryException, SystemException {
2639        BlogsEntry blogsEntry = findByUUID_G(uuid, groupId);
2640
2641        remove(blogsEntry);
2642    }
2643
2644    public void removeByGroupId(long groupId) throws SystemException {
2645        for (BlogsEntry blogsEntry : findByGroupId(groupId)) {
2646            remove(blogsEntry);
2647        }
2648    }
2649
2650    public void removeByCompanyId(long companyId) throws SystemException {
2651        for (BlogsEntry blogsEntry : findByCompanyId(companyId)) {
2652            remove(blogsEntry);
2653        }
2654    }
2655
2656    public void removeByG_U(long groupId, long userId)
2657        throws SystemException {
2658        for (BlogsEntry blogsEntry : findByG_U(groupId, userId)) {
2659            remove(blogsEntry);
2660        }
2661    }
2662
2663    public void removeByG_UT(long groupId, String urlTitle)
2664        throws NoSuchEntryException, SystemException {
2665        BlogsEntry blogsEntry = findByG_UT(groupId, urlTitle);
2666
2667        remove(blogsEntry);
2668    }
2669
2670    public void removeByG_D_D(long groupId, Date displayDate, boolean draft)
2671        throws SystemException {
2672        for (BlogsEntry blogsEntry : findByG_D_D(groupId, displayDate, draft)) {
2673            remove(blogsEntry);
2674        }
2675    }
2676
2677    public void removeByC_D_D(long companyId, Date displayDate, boolean draft)
2678        throws SystemException {
2679        for (BlogsEntry blogsEntry : findByC_D_D(companyId, displayDate, draft)) {
2680            remove(blogsEntry);
2681        }
2682    }
2683
2684    public void removeByG_U_D_D(long groupId, long userId, Date displayDate,
2685        boolean draft) throws SystemException {
2686        for (BlogsEntry blogsEntry : findByG_U_D_D(groupId, userId,
2687                displayDate, draft)) {
2688            remove(blogsEntry);
2689        }
2690    }
2691
2692    public void removeAll() throws SystemException {
2693        for (BlogsEntry blogsEntry : findAll()) {
2694            remove(blogsEntry);
2695        }
2696    }
2697
2698    public int countByUuid(String uuid) throws SystemException {
2699        boolean finderClassNameCacheEnabled = BlogsEntryModelImpl.CACHE_ENABLED;
2700        String finderClassName = BlogsEntry.class.getName();
2701        String finderMethodName = "countByUuid";
2702        String[] finderParams = new String[] { String.class.getName() };
2703        Object[] finderArgs = new Object[] { uuid };
2704
2705        Object result = null;
2706
2707        if (finderClassNameCacheEnabled) {
2708            result = FinderCacheUtil.getResult(finderClassName,
2709                    finderMethodName, finderParams, finderArgs, this);
2710        }
2711
2712        if (result == null) {
2713            Session session = null;
2714
2715            try {
2716                session = openSession();
2717
2718                StringBuilder query = new StringBuilder();
2719
2720                query.append("SELECT COUNT(*) ");
2721                query.append(
2722                    "FROM com.liferay.portlet.blogs.model.BlogsEntry WHERE ");
2723
2724                if (uuid == null) {
2725                    query.append("uuid_ IS NULL");
2726                }
2727                else {
2728                    query.append("uuid_ = ?");
2729                }
2730
2731                query.append(" ");
2732
2733                Query q = session.createQuery(query.toString());
2734
2735                QueryPos qPos = QueryPos.getInstance(q);
2736
2737                if (uuid != null) {
2738                    qPos.add(uuid);
2739                }
2740
2741                Long count = null;
2742
2743                Iterator<Long> itr = q.list().iterator();
2744
2745                if (itr.hasNext()) {
2746                    count = itr.next();
2747                }
2748
2749                if (count == null) {
2750                    count = new Long(0);
2751                }
2752
2753                FinderCacheUtil.putResult(finderClassNameCacheEnabled,
2754                    finderClassName, finderMethodName, finderParams,
2755                    finderArgs, count);
2756
2757                return count.intValue();
2758            }
2759            catch (Exception e) {
2760                throw processException(e);
2761            }
2762            finally {
2763                closeSession(session);
2764            }
2765        }
2766        else {
2767            return ((Long)result).intValue();
2768        }
2769    }
2770
2771    public int countByUUID_G(String uuid, long groupId)
2772        throws SystemException {
2773        boolean finderClassNameCacheEnabled = BlogsEntryModelImpl.CACHE_ENABLED;
2774        String finderClassName = BlogsEntry.class.getName();
2775        String finderMethodName = "countByUUID_G";
2776        String[] finderParams = new String[] {
2777                String.class.getName(), Long.class.getName()
2778            };
2779        Object[] finderArgs = new Object[] { uuid, new Long(groupId) };
2780
2781        Object result = null;
2782
2783        if (finderClassNameCacheEnabled) {
2784            result = FinderCacheUtil.getResult(finderClassName,
2785                    finderMethodName, finderParams, finderArgs, this);
2786        }
2787
2788        if (result == null) {
2789            Session session = null;
2790
2791            try {
2792                session = openSession();
2793
2794                StringBuilder query = new StringBuilder();
2795
2796                query.append("SELECT COUNT(*) ");
2797                query.append(
2798                    "FROM com.liferay.portlet.blogs.model.BlogsEntry WHERE ");
2799
2800                if (uuid == null) {
2801                    query.append("uuid_ IS NULL");
2802                }
2803                else {
2804                    query.append("uuid_ = ?");
2805                }
2806
2807                query.append(" AND ");
2808
2809                query.append("groupId = ?");
2810
2811                query.append(" ");
2812
2813                Query q = session.createQuery(query.toString());
2814
2815                QueryPos qPos = QueryPos.getInstance(q);
2816
2817                if (uuid != null) {
2818                    qPos.add(uuid);
2819                }
2820
2821                qPos.add(groupId);
2822
2823                Long count = null;
2824
2825                Iterator<Long> itr = q.list().iterator();
2826
2827                if (itr.hasNext()) {
2828                    count = itr.next();
2829                }
2830
2831                if (count == null) {
2832                    count = new Long(0);
2833                }
2834
2835                FinderCacheUtil.putResult(finderClassNameCacheEnabled,
2836                    finderClassName, finderMethodName, finderParams,
2837                    finderArgs, count);
2838
2839                return count.intValue();
2840            }
2841            catch (Exception e) {
2842                throw processException(e);
2843            }
2844            finally {
2845                closeSession(session);
2846            }
2847        }
2848        else {
2849            return ((Long)result).intValue();
2850        }
2851    }
2852
2853    public int countByGroupId(long groupId) throws SystemException {
2854        boolean finderClassNameCacheEnabled = BlogsEntryModelImpl.CACHE_ENABLED;
2855        String finderClassName = BlogsEntry.class.getName();
2856        String finderMethodName = "countByGroupId";
2857        String[] finderParams = new String[] { Long.class.getName() };
2858        Object[] finderArgs = new Object[] { new Long(groupId) };
2859
2860        Object result = null;
2861
2862        if (finderClassNameCacheEnabled) {
2863            result = FinderCacheUtil.getResult(finderClassName,
2864                    finderMethodName, finderParams, finderArgs, this);
2865        }
2866
2867        if (result == null) {
2868            Session session = null;
2869
2870            try {
2871                session = openSession();
2872
2873                StringBuilder query = new StringBuilder();
2874
2875                query.append("SELECT COUNT(*) ");
2876                query.append(
2877                    "FROM com.liferay.portlet.blogs.model.BlogsEntry WHERE ");
2878
2879                query.append("groupId = ?");
2880
2881                query.append(" ");
2882
2883                Query q = session.createQuery(query.toString());
2884
2885                QueryPos qPos = QueryPos.getInstance(q);
2886
2887                qPos.add(groupId);
2888
2889                Long count = null;
2890
2891                Iterator<Long> itr = q.list().iterator();
2892
2893                if (itr.hasNext()) {
2894                    count = itr.next();
2895                }
2896
2897                if (count == null) {
2898                    count = new Long(0);
2899                }
2900
2901                FinderCacheUtil.putResult(finderClassNameCacheEnabled,
2902                    finderClassName, finderMethodName, finderParams,
2903                    finderArgs, count);
2904
2905                return count.intValue();
2906            }
2907            catch (Exception e) {
2908                throw processException(e);
2909            }
2910            finally {
2911                closeSession(session);
2912            }
2913        }
2914        else {
2915            return ((Long)result).intValue();
2916        }
2917    }
2918
2919    public int countByCompanyId(long companyId) throws SystemException {
2920        boolean finderClassNameCacheEnabled = BlogsEntryModelImpl.CACHE_ENABLED;
2921        String finderClassName = BlogsEntry.class.getName();
2922        String finderMethodName = "countByCompanyId";
2923        String[] finderParams = new String[] { Long.class.getName() };
2924        Object[] finderArgs = new Object[] { new Long(companyId) };
2925
2926        Object result = null;
2927
2928        if (finderClassNameCacheEnabled) {
2929            result = FinderCacheUtil.getResult(finderClassName,
2930                    finderMethodName, finderParams, finderArgs, this);
2931        }
2932
2933        if (result == null) {
2934            Session session = null;
2935
2936            try {
2937                session = openSession();
2938
2939                StringBuilder query = new StringBuilder();
2940
2941                query.append("SELECT COUNT(*) ");
2942                query.append(
2943                    "FROM com.liferay.portlet.blogs.model.BlogsEntry WHERE ");
2944
2945                query.append("companyId = ?");
2946
2947                query.append(" ");
2948
2949                Query q = session.createQuery(query.toString());
2950
2951                QueryPos qPos = QueryPos.getInstance(q);
2952
2953                qPos.add(companyId);
2954
2955                Long count = null;
2956
2957                Iterator<Long> itr = q.list().iterator();
2958
2959                if (itr.hasNext()) {
2960                    count = itr.next();
2961                }
2962
2963                if (count == null) {
2964                    count = new Long(0);
2965                }
2966
2967                FinderCacheUtil.putResult(finderClassNameCacheEnabled,
2968                    finderClassName, finderMethodName, finderParams,
2969                    finderArgs, count);
2970
2971                return count.intValue();
2972            }
2973            catch (Exception e) {
2974                throw processException(e);
2975            }
2976            finally {
2977                closeSession(session);
2978            }
2979        }
2980        else {
2981            return ((Long)result).intValue();
2982        }
2983    }
2984
2985    public int countByG_U(long groupId, long userId) throws SystemException {
2986        boolean finderClassNameCacheEnabled = BlogsEntryModelImpl.CACHE_ENABLED;
2987        String finderClassName = BlogsEntry.class.getName();
2988        String finderMethodName = "countByG_U";
2989        String[] finderParams = new String[] {
2990                Long.class.getName(), Long.class.getName()
2991            };
2992        Object[] finderArgs = new Object[] { new Long(groupId), new Long(userId) };
2993
2994        Object result = null;
2995
2996        if (finderClassNameCacheEnabled) {
2997            result = FinderCacheUtil.getResult(finderClassName,
2998                    finderMethodName, finderParams, finderArgs, this);
2999        }
3000
3001        if (result == null) {
3002            Session session = null;
3003
3004            try {
3005                session = openSession();
3006
3007                StringBuilder query = new StringBuilder();
3008
3009                query.append("SELECT COUNT(*) ");
3010                query.append(
3011                    "FROM com.liferay.portlet.blogs.model.BlogsEntry WHERE ");
3012
3013                query.append("groupId = ?");
3014
3015                query.append(" AND ");
3016
3017                query.append("userId = ?");
3018
3019                query.append(" ");
3020
3021                Query q = session.createQuery(query.toString());
3022
3023                QueryPos qPos = QueryPos.getInstance(q);
3024
3025                qPos.add(groupId);
3026
3027                qPos.add(userId);
3028
3029                Long count = null;
3030
3031                Iterator<Long> itr = q.list().iterator();
3032
3033                if (itr.hasNext()) {
3034                    count = itr.next();
3035                }
3036
3037                if (count == null) {
3038                    count = new Long(0);
3039                }
3040
3041                FinderCacheUtil.putResult(finderClassNameCacheEnabled,
3042                    finderClassName, finderMethodName, finderParams,
3043                    finderArgs, count);
3044
3045                return count.intValue();
3046            }
3047            catch (Exception e) {
3048                throw processException(e);
3049            }
3050            finally {
3051                closeSession(session);
3052            }
3053        }
3054        else {
3055            return ((Long)result).intValue();
3056        }
3057    }
3058
3059    public int countByG_UT(long groupId, String urlTitle)
3060        throws SystemException {
3061        boolean finderClassNameCacheEnabled = BlogsEntryModelImpl.CACHE_ENABLED;
3062        String finderClassName = BlogsEntry.class.getName();
3063        String finderMethodName = "countByG_UT";
3064        String[] finderParams = new String[] {
3065                Long.class.getName(), String.class.getName()
3066            };
3067        Object[] finderArgs = new Object[] { new Long(groupId), urlTitle };
3068
3069        Object result = null;
3070
3071        if (finderClassNameCacheEnabled) {
3072            result = FinderCacheUtil.getResult(finderClassName,
3073                    finderMethodName, finderParams, finderArgs, this);
3074        }
3075
3076        if (result == null) {
3077            Session session = null;
3078
3079            try {
3080                session = openSession();
3081
3082                StringBuilder query = new StringBuilder();
3083
3084                query.append("SELECT COUNT(*) ");
3085                query.append(
3086                    "FROM com.liferay.portlet.blogs.model.BlogsEntry WHERE ");
3087
3088                query.append("groupId = ?");
3089
3090                query.append(" AND ");
3091
3092                if (urlTitle == null) {
3093                    query.append("urlTitle IS NULL");
3094                }
3095                else {
3096                    query.append("urlTitle = ?");
3097                }
3098
3099                query.append(" ");
3100
3101                Query q = session.createQuery(query.toString());
3102
3103                QueryPos qPos = QueryPos.getInstance(q);
3104
3105                qPos.add(groupId);
3106
3107                if (urlTitle != null) {
3108                    qPos.add(urlTitle);
3109                }
3110
3111                Long count = null;
3112
3113                Iterator<Long> itr = q.list().iterator();
3114
3115                if (itr.hasNext()) {
3116                    count = itr.next();
3117                }
3118
3119                if (count == null) {
3120                    count = new Long(0);
3121                }
3122
3123                FinderCacheUtil.putResult(finderClassNameCacheEnabled,
3124                    finderClassName, finderMethodName, finderParams,
3125                    finderArgs, count);
3126
3127                return count.intValue();
3128            }
3129            catch (Exception e) {
3130                throw processException(e);
3131            }
3132            finally {
3133                closeSession(session);
3134            }
3135        }
3136        else {
3137            return ((Long)result).intValue();
3138        }
3139    }
3140
3141    public int countByG_D_D(long groupId, Date displayDate, boolean draft)
3142        throws SystemException {
3143        boolean finderClassNameCacheEnabled = BlogsEntryModelImpl.CACHE_ENABLED;
3144        String finderClassName = BlogsEntry.class.getName();
3145        String finderMethodName = "countByG_D_D";
3146        String[] finderParams = new String[] {
3147                Long.class.getName(), Date.class.getName(),
3148                Boolean.class.getName()
3149            };
3150        Object[] finderArgs = new Object[] {
3151                new Long(groupId),
3152                
3153                displayDate, Boolean.valueOf(draft)
3154            };
3155
3156        Object result = null;
3157
3158        if (finderClassNameCacheEnabled) {
3159            result = FinderCacheUtil.getResult(finderClassName,
3160                    finderMethodName, finderParams, finderArgs, this);
3161        }
3162
3163        if (result == null) {
3164            Session session = null;
3165
3166            try {
3167                session = openSession();
3168
3169                StringBuilder query = new StringBuilder();
3170
3171                query.append("SELECT COUNT(*) ");
3172                query.append(
3173                    "FROM com.liferay.portlet.blogs.model.BlogsEntry WHERE ");
3174
3175                query.append("groupId = ?");
3176
3177                query.append(" AND ");
3178
3179                if (displayDate == null) {
3180                    query.append("displayDate < null");
3181                }
3182                else {
3183                    query.append("displayDate < ?");
3184                }
3185
3186                query.append(" AND ");
3187
3188                query.append("draft = ?");
3189
3190                query.append(" ");
3191
3192                Query q = session.createQuery(query.toString());
3193
3194                QueryPos qPos = QueryPos.getInstance(q);
3195
3196                qPos.add(groupId);
3197
3198                if (displayDate != null) {
3199                    qPos.add(CalendarUtil.getTimestamp(displayDate));
3200                }
3201
3202                qPos.add(draft);
3203
3204                Long count = null;
3205
3206                Iterator<Long> itr = q.list().iterator();
3207
3208                if (itr.hasNext()) {
3209                    count = itr.next();
3210                }
3211
3212                if (count == null) {
3213                    count = new Long(0);
3214                }
3215
3216                FinderCacheUtil.putResult(finderClassNameCacheEnabled,
3217                    finderClassName, finderMethodName, finderParams,
3218                    finderArgs, count);
3219
3220                return count.intValue();
3221            }
3222            catch (Exception e) {
3223                throw processException(e);
3224            }
3225            finally {
3226                closeSession(session);
3227            }
3228        }
3229        else {
3230            return ((Long)result).intValue();
3231        }
3232    }
3233
3234    public int countByC_D_D(long companyId, Date displayDate, boolean draft)
3235        throws SystemException {
3236        boolean finderClassNameCacheEnabled = BlogsEntryModelImpl.CACHE_ENABLED;
3237        String finderClassName = BlogsEntry.class.getName();
3238        String finderMethodName = "countByC_D_D";
3239        String[] finderParams = new String[] {
3240                Long.class.getName(), Date.class.getName(),
3241                Boolean.class.getName()
3242            };
3243        Object[] finderArgs = new Object[] {
3244                new Long(companyId),
3245                
3246                displayDate, Boolean.valueOf(draft)
3247            };
3248
3249        Object result = null;
3250
3251        if (finderClassNameCacheEnabled) {
3252            result = FinderCacheUtil.getResult(finderClassName,
3253                    finderMethodName, finderParams, finderArgs, this);
3254        }
3255
3256        if (result == null) {
3257            Session session = null;
3258
3259            try {
3260                session = openSession();
3261
3262                StringBuilder query = new StringBuilder();
3263
3264                query.append("SELECT COUNT(*) ");
3265                query.append(
3266                    "FROM com.liferay.portlet.blogs.model.BlogsEntry WHERE ");
3267
3268                query.append("companyId = ?");
3269
3270                query.append(" AND ");
3271
3272                if (displayDate == null) {
3273                    query.append("displayDate < null");
3274                }
3275                else {
3276                    query.append("displayDate < ?");
3277                }
3278
3279                query.append(" AND ");
3280
3281                query.append("draft = ?");
3282
3283                query.append(" ");
3284
3285                Query q = session.createQuery(query.toString());
3286
3287                QueryPos qPos = QueryPos.getInstance(q);
3288
3289                qPos.add(companyId);
3290
3291                if (displayDate != null) {
3292                    qPos.add(CalendarUtil.getTimestamp(displayDate));
3293                }
3294
3295                qPos.add(draft);
3296
3297                Long count = null;
3298
3299                Iterator<Long> itr = q.list().iterator();
3300
3301                if (itr.hasNext()) {
3302                    count = itr.next();
3303                }
3304
3305                if (count == null) {
3306                    count = new Long(0);
3307                }
3308
3309                FinderCacheUtil.putResult(finderClassNameCacheEnabled,
3310                    finderClassName, finderMethodName, finderParams,
3311                    finderArgs, count);
3312
3313                return count.intValue();
3314            }
3315            catch (Exception e) {
3316                throw processException(e);
3317            }
3318            finally {
3319                closeSession(session);
3320            }
3321        }
3322        else {
3323            return ((Long)result).intValue();
3324        }
3325    }
3326
3327    public int countByG_U_D_D(long groupId, long userId, Date displayDate,
3328        boolean draft) throws SystemException {
3329        boolean finderClassNameCacheEnabled = BlogsEntryModelImpl.CACHE_ENABLED;
3330        String finderClassName = BlogsEntry.class.getName();
3331        String finderMethodName = "countByG_U_D_D";
3332        String[] finderParams = new String[] {
3333                Long.class.getName(), Long.class.getName(), Date.class.getName(),
3334                Boolean.class.getName()
3335            };
3336        Object[] finderArgs = new Object[] {
3337                new Long(groupId), new Long(userId),
3338                
3339                displayDate, Boolean.valueOf(draft)
3340            };
3341
3342        Object result = null;
3343
3344        if (finderClassNameCacheEnabled) {
3345            result = FinderCacheUtil.getResult(finderClassName,
3346                    finderMethodName, finderParams, finderArgs, this);
3347        }
3348
3349        if (result == null) {
3350            Session session = null;
3351
3352            try {
3353                session = openSession();
3354
3355                StringBuilder query = new StringBuilder();
3356
3357                query.append("SELECT COUNT(*) ");
3358                query.append(
3359                    "FROM com.liferay.portlet.blogs.model.BlogsEntry WHERE ");
3360
3361                query.append("groupId = ?");
3362
3363                query.append(" AND ");
3364
3365                query.append("userId = ?");
3366
3367                query.append(" AND ");
3368
3369                if (displayDate == null) {
3370                    query.append("displayDate < null");
3371                }
3372                else {
3373                    query.append("displayDate < ?");
3374                }
3375
3376                query.append(" AND ");
3377
3378                query.append("draft = ?");
3379
3380                query.append(" ");
3381
3382                Query q = session.createQuery(query.toString());
3383
3384                QueryPos qPos = QueryPos.getInstance(q);
3385
3386                qPos.add(groupId);
3387
3388                qPos.add(userId);
3389
3390                if (displayDate != null) {
3391                    qPos.add(CalendarUtil.getTimestamp(displayDate));
3392                }
3393
3394                qPos.add(draft);
3395
3396                Long count = null;
3397
3398                Iterator<Long> itr = q.list().iterator();
3399
3400                if (itr.hasNext()) {
3401                    count = itr.next();
3402                }
3403
3404                if (count == null) {
3405                    count = new Long(0);
3406                }
3407
3408                FinderCacheUtil.putResult(finderClassNameCacheEnabled,
3409                    finderClassName, finderMethodName, finderParams,
3410                    finderArgs, count);
3411
3412                return count.intValue();
3413            }
3414            catch (Exception e) {
3415                throw processException(e);
3416            }
3417            finally {
3418                closeSession(session);
3419            }
3420        }
3421        else {
3422            return ((Long)result).intValue();
3423        }
3424    }
3425
3426    public int countAll() throws SystemException {
3427        boolean finderClassNameCacheEnabled = BlogsEntryModelImpl.CACHE_ENABLED;
3428        String finderClassName = BlogsEntry.class.getName();
3429        String finderMethodName = "countAll";
3430        String[] finderParams = new String[] {  };
3431        Object[] finderArgs = new Object[] {  };
3432
3433        Object result = null;
3434
3435        if (finderClassNameCacheEnabled) {
3436            result = FinderCacheUtil.getResult(finderClassName,
3437                    finderMethodName, finderParams, finderArgs, this);
3438        }
3439
3440        if (result == null) {
3441            Session session = null;
3442
3443            try {
3444                session = openSession();
3445
3446                Query q = session.createQuery(
3447                        "SELECT COUNT(*) FROM com.liferay.portlet.blogs.model.BlogsEntry");
3448
3449                Long count = null;
3450
3451                Iterator<Long> itr = q.list().iterator();
3452
3453                if (itr.hasNext()) {
3454                    count = itr.next();
3455                }
3456
3457                if (count == null) {
3458                    count = new Long(0);
3459                }
3460
3461                FinderCacheUtil.putResult(finderClassNameCacheEnabled,
3462                    finderClassName, finderMethodName, finderParams,
3463                    finderArgs, count);
3464
3465                return count.intValue();
3466            }
3467            catch (Exception e) {
3468                throw processException(e);
3469            }
3470            finally {
3471                closeSession(session);
3472            }
3473        }
3474        else {
3475            return ((Long)result).intValue();
3476        }
3477    }
3478
3479    public void afterPropertiesSet() {
3480        String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
3481                    com.liferay.portal.util.PropsUtil.get(
3482                        "value.object.listener.com.liferay.portlet.blogs.model.BlogsEntry")));
3483
3484        if (listenerClassNames.length > 0) {
3485            try {
3486                List<ModelListener> listenersList = new ArrayList<ModelListener>();
3487
3488                for (String listenerClassName : listenerClassNames) {
3489                    listenersList.add((ModelListener)Class.forName(
3490                            listenerClassName).newInstance());
3491                }
3492
3493                listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
3494            }
3495            catch (Exception e) {
3496                _log.error(e);
3497            }
3498        }
3499    }
3500
3501    @BeanReference(name = "com.liferay.portlet.blogs.service.persistence.BlogsEntryPersistence.impl")
3502    protected com.liferay.portlet.blogs.service.persistence.BlogsEntryPersistence blogsEntryPersistence;
3503    @BeanReference(name = "com.liferay.portlet.blogs.service.persistence.BlogsStatsUserPersistence.impl")
3504    protected com.liferay.portlet.blogs.service.persistence.BlogsStatsUserPersistence blogsStatsUserPersistence;
3505    @BeanReference(name = "com.liferay.portal.service.persistence.CompanyPersistence.impl")
3506    protected com.liferay.portal.service.persistence.CompanyPersistence companyPersistence;
3507    @BeanReference(name = "com.liferay.portal.service.persistence.GroupPersistence.impl")
3508    protected com.liferay.portal.service.persistence.GroupPersistence groupPersistence;
3509    @BeanReference(name = "com.liferay.portal.service.persistence.OrganizationPersistence.impl")
3510    protected com.liferay.portal.service.persistence.OrganizationPersistence organizationPersistence;
3511    @BeanReference(name = "com.liferay.portal.service.persistence.ResourcePersistence.impl")
3512    protected com.liferay.portal.service.persistence.ResourcePersistence resourcePersistence;
3513    @BeanReference(name = "com.liferay.portal.service.persistence.UserPersistence.impl")
3514    protected com.liferay.portal.service.persistence.UserPersistence userPersistence;
3515    @BeanReference(name = "com.liferay.portlet.messageboards.service.persistence.MBMessagePersistence.impl")
3516    protected com.liferay.portlet.messageboards.service.persistence.MBMessagePersistence mbMessagePersistence;
3517    @BeanReference(name = "com.liferay.portlet.ratings.service.persistence.RatingsStatsPersistence.impl")
3518    protected com.liferay.portlet.ratings.service.persistence.RatingsStatsPersistence ratingsStatsPersistence;
3519    @BeanReference(name = "com.liferay.portlet.social.service.persistence.SocialActivityPersistence.impl")
3520    protected com.liferay.portlet.social.service.persistence.SocialActivityPersistence socialActivityPersistence;
3521    @BeanReference(name = "com.liferay.portlet.tags.service.persistence.TagsAssetPersistence.impl")
3522    protected com.liferay.portlet.tags.service.persistence.TagsAssetPersistence tagsAssetPersistence;
3523    @BeanReference(name = "com.liferay.portlet.tags.service.persistence.TagsEntryPersistence.impl")
3524    protected com.liferay.portlet.tags.service.persistence.TagsEntryPersistence tagsEntryPersistence;
3525    private static Log _log = LogFactoryUtil.getLog(BlogsEntryPersistenceImpl.class);
3526}