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