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