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