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