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