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