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