1
22
23 package com.liferay.portlet.bookmarks.service.persistence;
24
25 import com.liferay.portal.SystemException;
26 import com.liferay.portal.kernel.annotation.BeanReference;
27 import com.liferay.portal.kernel.cache.CacheRegistry;
28 import com.liferay.portal.kernel.dao.orm.DynamicQuery;
29 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
30 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
31 import com.liferay.portal.kernel.dao.orm.FinderPath;
32 import com.liferay.portal.kernel.dao.orm.Query;
33 import com.liferay.portal.kernel.dao.orm.QueryPos;
34 import com.liferay.portal.kernel.dao.orm.QueryUtil;
35 import com.liferay.portal.kernel.dao.orm.Session;
36 import com.liferay.portal.kernel.log.Log;
37 import com.liferay.portal.kernel.log.LogFactoryUtil;
38 import com.liferay.portal.kernel.util.GetterUtil;
39 import com.liferay.portal.kernel.util.OrderByComparator;
40 import com.liferay.portal.kernel.util.StringPool;
41 import com.liferay.portal.kernel.util.StringUtil;
42 import com.liferay.portal.kernel.util.Validator;
43 import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
44 import com.liferay.portal.model.ModelListener;
45 import com.liferay.portal.service.persistence.BatchSessionUtil;
46 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
47
48 import com.liferay.portlet.bookmarks.NoSuchEntryException;
49 import com.liferay.portlet.bookmarks.model.BookmarksEntry;
50 import com.liferay.portlet.bookmarks.model.impl.BookmarksEntryImpl;
51 import com.liferay.portlet.bookmarks.model.impl.BookmarksEntryModelImpl;
52
53 import java.util.ArrayList;
54 import java.util.Collections;
55 import java.util.List;
56
57
63 public class BookmarksEntryPersistenceImpl extends BasePersistenceImpl
64 implements BookmarksEntryPersistence {
65 public static final String FINDER_CLASS_NAME_ENTITY = BookmarksEntryImpl.class.getName();
66 public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
67 ".List";
68 public static final FinderPath FINDER_PATH_FIND_BY_UUID = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
69 BookmarksEntryModelImpl.FINDER_CACHE_ENABLED,
70 FINDER_CLASS_NAME_LIST, "findByUuid",
71 new String[] { String.class.getName() });
72 public static final FinderPath FINDER_PATH_FIND_BY_OBC_UUID = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
73 BookmarksEntryModelImpl.FINDER_CACHE_ENABLED,
74 FINDER_CLASS_NAME_LIST, "findByUuid",
75 new String[] {
76 String.class.getName(),
77
78 "java.lang.Integer", "java.lang.Integer",
79 "com.liferay.portal.kernel.util.OrderByComparator"
80 });
81 public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
82 BookmarksEntryModelImpl.FINDER_CACHE_ENABLED,
83 FINDER_CLASS_NAME_LIST, "countByUuid",
84 new String[] { String.class.getName() });
85 public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
86 BookmarksEntryModelImpl.FINDER_CACHE_ENABLED,
87 FINDER_CLASS_NAME_ENTITY, "fetchByUUID_G",
88 new String[] { String.class.getName(), Long.class.getName() });
89 public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
90 BookmarksEntryModelImpl.FINDER_CACHE_ENABLED,
91 FINDER_CLASS_NAME_LIST, "countByUUID_G",
92 new String[] { String.class.getName(), Long.class.getName() });
93 public static final FinderPath FINDER_PATH_FIND_BY_GROUPID = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
94 BookmarksEntryModelImpl.FINDER_CACHE_ENABLED,
95 FINDER_CLASS_NAME_LIST, "findByGroupId",
96 new String[] { Long.class.getName() });
97 public static final FinderPath FINDER_PATH_FIND_BY_OBC_GROUPID = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
98 BookmarksEntryModelImpl.FINDER_CACHE_ENABLED,
99 FINDER_CLASS_NAME_LIST, "findByGroupId",
100 new String[] {
101 Long.class.getName(),
102
103 "java.lang.Integer", "java.lang.Integer",
104 "com.liferay.portal.kernel.util.OrderByComparator"
105 });
106 public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
107 BookmarksEntryModelImpl.FINDER_CACHE_ENABLED,
108 FINDER_CLASS_NAME_LIST, "countByGroupId",
109 new String[] { Long.class.getName() });
110 public static final FinderPath FINDER_PATH_FIND_BY_FOLDERID = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
111 BookmarksEntryModelImpl.FINDER_CACHE_ENABLED,
112 FINDER_CLASS_NAME_LIST, "findByFolderId",
113 new String[] { Long.class.getName() });
114 public static final FinderPath FINDER_PATH_FIND_BY_OBC_FOLDERID = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
115 BookmarksEntryModelImpl.FINDER_CACHE_ENABLED,
116 FINDER_CLASS_NAME_LIST, "findByFolderId",
117 new String[] {
118 Long.class.getName(),
119
120 "java.lang.Integer", "java.lang.Integer",
121 "com.liferay.portal.kernel.util.OrderByComparator"
122 });
123 public static final FinderPath FINDER_PATH_COUNT_BY_FOLDERID = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
124 BookmarksEntryModelImpl.FINDER_CACHE_ENABLED,
125 FINDER_CLASS_NAME_LIST, "countByFolderId",
126 new String[] { Long.class.getName() });
127 public static final FinderPath FINDER_PATH_FIND_BY_G_U = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
128 BookmarksEntryModelImpl.FINDER_CACHE_ENABLED,
129 FINDER_CLASS_NAME_LIST, "findByG_U",
130 new String[] { Long.class.getName(), Long.class.getName() });
131 public static final FinderPath FINDER_PATH_FIND_BY_OBC_G_U = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
132 BookmarksEntryModelImpl.FINDER_CACHE_ENABLED,
133 FINDER_CLASS_NAME_LIST, "findByG_U",
134 new String[] {
135 Long.class.getName(), Long.class.getName(),
136
137 "java.lang.Integer", "java.lang.Integer",
138 "com.liferay.portal.kernel.util.OrderByComparator"
139 });
140 public static final FinderPath FINDER_PATH_COUNT_BY_G_U = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
141 BookmarksEntryModelImpl.FINDER_CACHE_ENABLED,
142 FINDER_CLASS_NAME_LIST, "countByG_U",
143 new String[] { Long.class.getName(), Long.class.getName() });
144 public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
145 BookmarksEntryModelImpl.FINDER_CACHE_ENABLED,
146 FINDER_CLASS_NAME_LIST, "findAll", new String[0]);
147 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
148 BookmarksEntryModelImpl.FINDER_CACHE_ENABLED,
149 FINDER_CLASS_NAME_LIST, "countAll", new String[0]);
150
151 public void cacheResult(BookmarksEntry bookmarksEntry) {
152 EntityCacheUtil.putResult(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
153 BookmarksEntryImpl.class, bookmarksEntry.getPrimaryKey(),
154 bookmarksEntry);
155
156 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
157 new Object[] {
158 bookmarksEntry.getUuid(), new Long(bookmarksEntry.getGroupId())
159 }, bookmarksEntry);
160 }
161
162 public void cacheResult(List<BookmarksEntry> bookmarksEntries) {
163 for (BookmarksEntry bookmarksEntry : bookmarksEntries) {
164 if (EntityCacheUtil.getResult(
165 BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
166 BookmarksEntryImpl.class,
167 bookmarksEntry.getPrimaryKey(), this) == null) {
168 cacheResult(bookmarksEntry);
169 }
170 }
171 }
172
173 public void clearCache() {
174 CacheRegistry.clear(BookmarksEntryImpl.class.getName());
175 EntityCacheUtil.clearCache(BookmarksEntryImpl.class.getName());
176 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
177 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
178 }
179
180 public BookmarksEntry create(long entryId) {
181 BookmarksEntry bookmarksEntry = new BookmarksEntryImpl();
182
183 bookmarksEntry.setNew(true);
184 bookmarksEntry.setPrimaryKey(entryId);
185
186 String uuid = PortalUUIDUtil.generate();
187
188 bookmarksEntry.setUuid(uuid);
189
190 return bookmarksEntry;
191 }
192
193 public BookmarksEntry remove(long entryId)
194 throws NoSuchEntryException, SystemException {
195 Session session = null;
196
197 try {
198 session = openSession();
199
200 BookmarksEntry bookmarksEntry = (BookmarksEntry)session.get(BookmarksEntryImpl.class,
201 new Long(entryId));
202
203 if (bookmarksEntry == null) {
204 if (_log.isWarnEnabled()) {
205 _log.warn("No BookmarksEntry exists with the primary key " +
206 entryId);
207 }
208
209 throw new NoSuchEntryException(
210 "No BookmarksEntry exists with the primary key " + entryId);
211 }
212
213 return remove(bookmarksEntry);
214 }
215 catch (NoSuchEntryException nsee) {
216 throw nsee;
217 }
218 catch (Exception e) {
219 throw processException(e);
220 }
221 finally {
222 closeSession(session);
223 }
224 }
225
226 public BookmarksEntry remove(BookmarksEntry bookmarksEntry)
227 throws SystemException {
228 for (ModelListener<BookmarksEntry> listener : listeners) {
229 listener.onBeforeRemove(bookmarksEntry);
230 }
231
232 bookmarksEntry = removeImpl(bookmarksEntry);
233
234 for (ModelListener<BookmarksEntry> listener : listeners) {
235 listener.onAfterRemove(bookmarksEntry);
236 }
237
238 return bookmarksEntry;
239 }
240
241 protected BookmarksEntry removeImpl(BookmarksEntry bookmarksEntry)
242 throws SystemException {
243 Session session = null;
244
245 try {
246 session = openSession();
247
248 if (bookmarksEntry.isCachedModel() || BatchSessionUtil.isEnabled()) {
249 Object staleObject = session.get(BookmarksEntryImpl.class,
250 bookmarksEntry.getPrimaryKeyObj());
251
252 if (staleObject != null) {
253 session.evict(staleObject);
254 }
255 }
256
257 session.delete(bookmarksEntry);
258
259 session.flush();
260 }
261 catch (Exception e) {
262 throw processException(e);
263 }
264 finally {
265 closeSession(session);
266 }
267
268 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
269
270 BookmarksEntryModelImpl bookmarksEntryModelImpl = (BookmarksEntryModelImpl)bookmarksEntry;
271
272 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
273 new Object[] {
274 bookmarksEntryModelImpl.getOriginalUuid(),
275 new Long(bookmarksEntryModelImpl.getOriginalGroupId())
276 });
277
278 EntityCacheUtil.removeResult(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
279 BookmarksEntryImpl.class, bookmarksEntry.getPrimaryKey());
280
281 return bookmarksEntry;
282 }
283
284
287 public BookmarksEntry update(BookmarksEntry bookmarksEntry)
288 throws SystemException {
289 if (_log.isWarnEnabled()) {
290 _log.warn(
291 "Using the deprecated update(BookmarksEntry bookmarksEntry) method. Use update(BookmarksEntry bookmarksEntry, boolean merge) instead.");
292 }
293
294 return update(bookmarksEntry, false);
295 }
296
297
310 public BookmarksEntry update(BookmarksEntry bookmarksEntry, boolean merge)
311 throws SystemException {
312 boolean isNew = bookmarksEntry.isNew();
313
314 for (ModelListener<BookmarksEntry> listener : listeners) {
315 if (isNew) {
316 listener.onBeforeCreate(bookmarksEntry);
317 }
318 else {
319 listener.onBeforeUpdate(bookmarksEntry);
320 }
321 }
322
323 bookmarksEntry = updateImpl(bookmarksEntry, merge);
324
325 for (ModelListener<BookmarksEntry> listener : listeners) {
326 if (isNew) {
327 listener.onAfterCreate(bookmarksEntry);
328 }
329 else {
330 listener.onAfterUpdate(bookmarksEntry);
331 }
332 }
333
334 return bookmarksEntry;
335 }
336
337 public BookmarksEntry updateImpl(
338 com.liferay.portlet.bookmarks.model.BookmarksEntry bookmarksEntry,
339 boolean merge) throws SystemException {
340 boolean isNew = bookmarksEntry.isNew();
341
342 BookmarksEntryModelImpl bookmarksEntryModelImpl = (BookmarksEntryModelImpl)bookmarksEntry;
343
344 if (Validator.isNull(bookmarksEntry.getUuid())) {
345 String uuid = PortalUUIDUtil.generate();
346
347 bookmarksEntry.setUuid(uuid);
348 }
349
350 Session session = null;
351
352 try {
353 session = openSession();
354
355 BatchSessionUtil.update(session, bookmarksEntry, merge);
356
357 bookmarksEntry.setNew(false);
358 }
359 catch (Exception e) {
360 throw processException(e);
361 }
362 finally {
363 closeSession(session);
364 }
365
366 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
367
368 EntityCacheUtil.putResult(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
369 BookmarksEntryImpl.class, bookmarksEntry.getPrimaryKey(),
370 bookmarksEntry);
371
372 if (!isNew &&
373 (!Validator.equals(bookmarksEntry.getUuid(),
374 bookmarksEntryModelImpl.getOriginalUuid()) ||
375 (bookmarksEntry.getGroupId() != bookmarksEntryModelImpl.getOriginalGroupId()))) {
376 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
377 new Object[] {
378 bookmarksEntryModelImpl.getOriginalUuid(),
379 new Long(bookmarksEntryModelImpl.getOriginalGroupId())
380 });
381 }
382
383 if (isNew ||
384 (!Validator.equals(bookmarksEntry.getUuid(),
385 bookmarksEntryModelImpl.getOriginalUuid()) ||
386 (bookmarksEntry.getGroupId() != bookmarksEntryModelImpl.getOriginalGroupId()))) {
387 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
388 new Object[] {
389 bookmarksEntry.getUuid(),
390 new Long(bookmarksEntry.getGroupId())
391 }, bookmarksEntry);
392 }
393
394 return bookmarksEntry;
395 }
396
397 public BookmarksEntry findByPrimaryKey(long entryId)
398 throws NoSuchEntryException, SystemException {
399 BookmarksEntry bookmarksEntry = fetchByPrimaryKey(entryId);
400
401 if (bookmarksEntry == null) {
402 if (_log.isWarnEnabled()) {
403 _log.warn("No BookmarksEntry exists with the primary key " +
404 entryId);
405 }
406
407 throw new NoSuchEntryException(
408 "No BookmarksEntry exists with the primary key " + entryId);
409 }
410
411 return bookmarksEntry;
412 }
413
414 public BookmarksEntry fetchByPrimaryKey(long entryId)
415 throws SystemException {
416 BookmarksEntry bookmarksEntry = (BookmarksEntry)EntityCacheUtil.getResult(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED,
417 BookmarksEntryImpl.class, entryId, this);
418
419 if (bookmarksEntry == null) {
420 Session session = null;
421
422 try {
423 session = openSession();
424
425 bookmarksEntry = (BookmarksEntry)session.get(BookmarksEntryImpl.class,
426 new Long(entryId));
427 }
428 catch (Exception e) {
429 throw processException(e);
430 }
431 finally {
432 if (bookmarksEntry != null) {
433 cacheResult(bookmarksEntry);
434 }
435
436 closeSession(session);
437 }
438 }
439
440 return bookmarksEntry;
441 }
442
443 public List<BookmarksEntry> findByUuid(String uuid)
444 throws SystemException {
445 Object[] finderArgs = new Object[] { uuid };
446
447 List<BookmarksEntry> list = (List<BookmarksEntry>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_UUID,
448 finderArgs, this);
449
450 if (list == null) {
451 Session session = null;
452
453 try {
454 session = openSession();
455
456 StringBuilder query = new StringBuilder();
457
458 query.append(
459 "FROM com.liferay.portlet.bookmarks.model.BookmarksEntry WHERE ");
460
461 if (uuid == null) {
462 query.append("uuid_ IS NULL");
463 }
464 else {
465 query.append("uuid_ = ?");
466 }
467
468 query.append(" ");
469
470 query.append("ORDER BY ");
471
472 query.append("folderId ASC, ");
473 query.append("name ASC");
474
475 Query q = session.createQuery(query.toString());
476
477 QueryPos qPos = QueryPos.getInstance(q);
478
479 if (uuid != null) {
480 qPos.add(uuid);
481 }
482
483 list = q.list();
484 }
485 catch (Exception e) {
486 throw processException(e);
487 }
488 finally {
489 if (list == null) {
490 list = new ArrayList<BookmarksEntry>();
491 }
492
493 cacheResult(list);
494
495 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_UUID, finderArgs,
496 list);
497
498 closeSession(session);
499 }
500 }
501
502 return list;
503 }
504
505 public List<BookmarksEntry> findByUuid(String uuid, int start, int end)
506 throws SystemException {
507 return findByUuid(uuid, start, end, null);
508 }
509
510 public List<BookmarksEntry> findByUuid(String uuid, int start, int end,
511 OrderByComparator obc) throws SystemException {
512 Object[] finderArgs = new Object[] {
513 uuid,
514
515 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
516 };
517
518 List<BookmarksEntry> list = (List<BookmarksEntry>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_UUID,
519 finderArgs, this);
520
521 if (list == null) {
522 Session session = null;
523
524 try {
525 session = openSession();
526
527 StringBuilder query = new StringBuilder();
528
529 query.append(
530 "FROM com.liferay.portlet.bookmarks.model.BookmarksEntry WHERE ");
531
532 if (uuid == null) {
533 query.append("uuid_ IS NULL");
534 }
535 else {
536 query.append("uuid_ = ?");
537 }
538
539 query.append(" ");
540
541 if (obc != null) {
542 query.append("ORDER BY ");
543 query.append(obc.getOrderBy());
544 }
545
546 else {
547 query.append("ORDER BY ");
548
549 query.append("folderId ASC, ");
550 query.append("name ASC");
551 }
552
553 Query q = session.createQuery(query.toString());
554
555 QueryPos qPos = QueryPos.getInstance(q);
556
557 if (uuid != null) {
558 qPos.add(uuid);
559 }
560
561 list = (List<BookmarksEntry>)QueryUtil.list(q, getDialect(),
562 start, end);
563 }
564 catch (Exception e) {
565 throw processException(e);
566 }
567 finally {
568 if (list == null) {
569 list = new ArrayList<BookmarksEntry>();
570 }
571
572 cacheResult(list);
573
574 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_UUID,
575 finderArgs, list);
576
577 closeSession(session);
578 }
579 }
580
581 return list;
582 }
583
584 public BookmarksEntry findByUuid_First(String uuid, OrderByComparator obc)
585 throws NoSuchEntryException, SystemException {
586 List<BookmarksEntry> list = findByUuid(uuid, 0, 1, obc);
587
588 if (list.isEmpty()) {
589 StringBuilder msg = new StringBuilder();
590
591 msg.append("No BookmarksEntry exists with the key {");
592
593 msg.append("uuid=" + uuid);
594
595 msg.append(StringPool.CLOSE_CURLY_BRACE);
596
597 throw new NoSuchEntryException(msg.toString());
598 }
599 else {
600 return list.get(0);
601 }
602 }
603
604 public BookmarksEntry findByUuid_Last(String uuid, OrderByComparator obc)
605 throws NoSuchEntryException, SystemException {
606 int count = countByUuid(uuid);
607
608 List<BookmarksEntry> list = findByUuid(uuid, count - 1, count, obc);
609
610 if (list.isEmpty()) {
611 StringBuilder msg = new StringBuilder();
612
613 msg.append("No BookmarksEntry exists with the key {");
614
615 msg.append("uuid=" + uuid);
616
617 msg.append(StringPool.CLOSE_CURLY_BRACE);
618
619 throw new NoSuchEntryException(msg.toString());
620 }
621 else {
622 return list.get(0);
623 }
624 }
625
626 public BookmarksEntry[] findByUuid_PrevAndNext(long entryId, String uuid,
627 OrderByComparator obc) throws NoSuchEntryException, SystemException {
628 BookmarksEntry bookmarksEntry = findByPrimaryKey(entryId);
629
630 int count = countByUuid(uuid);
631
632 Session session = null;
633
634 try {
635 session = openSession();
636
637 StringBuilder query = new StringBuilder();
638
639 query.append(
640 "FROM com.liferay.portlet.bookmarks.model.BookmarksEntry WHERE ");
641
642 if (uuid == null) {
643 query.append("uuid_ IS NULL");
644 }
645 else {
646 query.append("uuid_ = ?");
647 }
648
649 query.append(" ");
650
651 if (obc != null) {
652 query.append("ORDER BY ");
653 query.append(obc.getOrderBy());
654 }
655
656 else {
657 query.append("ORDER BY ");
658
659 query.append("folderId ASC, ");
660 query.append("name ASC");
661 }
662
663 Query q = session.createQuery(query.toString());
664
665 QueryPos qPos = QueryPos.getInstance(q);
666
667 if (uuid != null) {
668 qPos.add(uuid);
669 }
670
671 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
672 bookmarksEntry);
673
674 BookmarksEntry[] array = new BookmarksEntryImpl[3];
675
676 array[0] = (BookmarksEntry)objArray[0];
677 array[1] = (BookmarksEntry)objArray[1];
678 array[2] = (BookmarksEntry)objArray[2];
679
680 return array;
681 }
682 catch (Exception e) {
683 throw processException(e);
684 }
685 finally {
686 closeSession(session);
687 }
688 }
689
690 public BookmarksEntry findByUUID_G(String uuid, long groupId)
691 throws NoSuchEntryException, SystemException {
692 BookmarksEntry bookmarksEntry = fetchByUUID_G(uuid, groupId);
693
694 if (bookmarksEntry == null) {
695 StringBuilder msg = new StringBuilder();
696
697 msg.append("No BookmarksEntry exists with the key {");
698
699 msg.append("uuid=" + uuid);
700
701 msg.append(", ");
702 msg.append("groupId=" + groupId);
703
704 msg.append(StringPool.CLOSE_CURLY_BRACE);
705
706 if (_log.isWarnEnabled()) {
707 _log.warn(msg.toString());
708 }
709
710 throw new NoSuchEntryException(msg.toString());
711 }
712
713 return bookmarksEntry;
714 }
715
716 public BookmarksEntry fetchByUUID_G(String uuid, long groupId)
717 throws SystemException {
718 return fetchByUUID_G(uuid, groupId, true);
719 }
720
721 public BookmarksEntry fetchByUUID_G(String uuid, long groupId,
722 boolean retrieveFromCache) throws SystemException {
723 Object[] finderArgs = new Object[] { uuid, new Long(groupId) };
724
725 Object result = null;
726
727 if (retrieveFromCache) {
728 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
729 finderArgs, this);
730 }
731
732 if (result == null) {
733 Session session = null;
734
735 try {
736 session = openSession();
737
738 StringBuilder query = new StringBuilder();
739
740 query.append(
741 "FROM com.liferay.portlet.bookmarks.model.BookmarksEntry WHERE ");
742
743 if (uuid == null) {
744 query.append("uuid_ IS NULL");
745 }
746 else {
747 query.append("uuid_ = ?");
748 }
749
750 query.append(" AND ");
751
752 query.append("groupId = ?");
753
754 query.append(" ");
755
756 query.append("ORDER BY ");
757
758 query.append("folderId ASC, ");
759 query.append("name ASC");
760
761 Query q = session.createQuery(query.toString());
762
763 QueryPos qPos = QueryPos.getInstance(q);
764
765 if (uuid != null) {
766 qPos.add(uuid);
767 }
768
769 qPos.add(groupId);
770
771 List<BookmarksEntry> list = q.list();
772
773 result = list;
774
775 BookmarksEntry bookmarksEntry = null;
776
777 if (list.isEmpty()) {
778 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
779 finderArgs, list);
780 }
781 else {
782 bookmarksEntry = list.get(0);
783
784 cacheResult(bookmarksEntry);
785
786 if ((bookmarksEntry.getUuid() == null) ||
787 !bookmarksEntry.getUuid().equals(uuid) ||
788 (bookmarksEntry.getGroupId() != groupId)) {
789 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
790 finderArgs, bookmarksEntry);
791 }
792 }
793
794 return bookmarksEntry;
795 }
796 catch (Exception e) {
797 throw processException(e);
798 }
799 finally {
800 if (result == null) {
801 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
802 finderArgs, new ArrayList<BookmarksEntry>());
803 }
804
805 closeSession(session);
806 }
807 }
808 else {
809 if (result instanceof List) {
810 return null;
811 }
812 else {
813 return (BookmarksEntry)result;
814 }
815 }
816 }
817
818 public List<BookmarksEntry> findByGroupId(long groupId)
819 throws SystemException {
820 Object[] finderArgs = new Object[] { new Long(groupId) };
821
822 List<BookmarksEntry> list = (List<BookmarksEntry>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_GROUPID,
823 finderArgs, this);
824
825 if (list == null) {
826 Session session = null;
827
828 try {
829 session = openSession();
830
831 StringBuilder query = new StringBuilder();
832
833 query.append(
834 "FROM com.liferay.portlet.bookmarks.model.BookmarksEntry WHERE ");
835
836 query.append("groupId = ?");
837
838 query.append(" ");
839
840 query.append("ORDER BY ");
841
842 query.append("folderId ASC, ");
843 query.append("name ASC");
844
845 Query q = session.createQuery(query.toString());
846
847 QueryPos qPos = QueryPos.getInstance(q);
848
849 qPos.add(groupId);
850
851 list = q.list();
852 }
853 catch (Exception e) {
854 throw processException(e);
855 }
856 finally {
857 if (list == null) {
858 list = new ArrayList<BookmarksEntry>();
859 }
860
861 cacheResult(list);
862
863 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_GROUPID,
864 finderArgs, list);
865
866 closeSession(session);
867 }
868 }
869
870 return list;
871 }
872
873 public List<BookmarksEntry> findByGroupId(long groupId, int start, int end)
874 throws SystemException {
875 return findByGroupId(groupId, start, end, null);
876 }
877
878 public List<BookmarksEntry> findByGroupId(long groupId, int start, int end,
879 OrderByComparator obc) throws SystemException {
880 Object[] finderArgs = new Object[] {
881 new Long(groupId),
882
883 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
884 };
885
886 List<BookmarksEntry> list = (List<BookmarksEntry>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_GROUPID,
887 finderArgs, this);
888
889 if (list == null) {
890 Session session = null;
891
892 try {
893 session = openSession();
894
895 StringBuilder query = new StringBuilder();
896
897 query.append(
898 "FROM com.liferay.portlet.bookmarks.model.BookmarksEntry WHERE ");
899
900 query.append("groupId = ?");
901
902 query.append(" ");
903
904 if (obc != null) {
905 query.append("ORDER BY ");
906 query.append(obc.getOrderBy());
907 }
908
909 else {
910 query.append("ORDER BY ");
911
912 query.append("folderId ASC, ");
913 query.append("name ASC");
914 }
915
916 Query q = session.createQuery(query.toString());
917
918 QueryPos qPos = QueryPos.getInstance(q);
919
920 qPos.add(groupId);
921
922 list = (List<BookmarksEntry>)QueryUtil.list(q, getDialect(),
923 start, end);
924 }
925 catch (Exception e) {
926 throw processException(e);
927 }
928 finally {
929 if (list == null) {
930 list = new ArrayList<BookmarksEntry>();
931 }
932
933 cacheResult(list);
934
935 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_GROUPID,
936 finderArgs, list);
937
938 closeSession(session);
939 }
940 }
941
942 return list;
943 }
944
945 public BookmarksEntry findByGroupId_First(long groupId,
946 OrderByComparator obc) throws NoSuchEntryException, SystemException {
947 List<BookmarksEntry> list = findByGroupId(groupId, 0, 1, obc);
948
949 if (list.isEmpty()) {
950 StringBuilder msg = new StringBuilder();
951
952 msg.append("No BookmarksEntry exists with the key {");
953
954 msg.append("groupId=" + groupId);
955
956 msg.append(StringPool.CLOSE_CURLY_BRACE);
957
958 throw new NoSuchEntryException(msg.toString());
959 }
960 else {
961 return list.get(0);
962 }
963 }
964
965 public BookmarksEntry findByGroupId_Last(long groupId, OrderByComparator obc)
966 throws NoSuchEntryException, SystemException {
967 int count = countByGroupId(groupId);
968
969 List<BookmarksEntry> list = findByGroupId(groupId, count - 1, count, obc);
970
971 if (list.isEmpty()) {
972 StringBuilder msg = new StringBuilder();
973
974 msg.append("No BookmarksEntry exists with the key {");
975
976 msg.append("groupId=" + groupId);
977
978 msg.append(StringPool.CLOSE_CURLY_BRACE);
979
980 throw new NoSuchEntryException(msg.toString());
981 }
982 else {
983 return list.get(0);
984 }
985 }
986
987 public BookmarksEntry[] findByGroupId_PrevAndNext(long entryId,
988 long groupId, OrderByComparator obc)
989 throws NoSuchEntryException, SystemException {
990 BookmarksEntry bookmarksEntry = findByPrimaryKey(entryId);
991
992 int count = countByGroupId(groupId);
993
994 Session session = null;
995
996 try {
997 session = openSession();
998
999 StringBuilder query = new StringBuilder();
1000
1001 query.append(
1002 "FROM com.liferay.portlet.bookmarks.model.BookmarksEntry WHERE ");
1003
1004 query.append("groupId = ?");
1005
1006 query.append(" ");
1007
1008 if (obc != null) {
1009 query.append("ORDER BY ");
1010 query.append(obc.getOrderBy());
1011 }
1012
1013 else {
1014 query.append("ORDER BY ");
1015
1016 query.append("folderId ASC, ");
1017 query.append("name ASC");
1018 }
1019
1020 Query q = session.createQuery(query.toString());
1021
1022 QueryPos qPos = QueryPos.getInstance(q);
1023
1024 qPos.add(groupId);
1025
1026 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
1027 bookmarksEntry);
1028
1029 BookmarksEntry[] array = new BookmarksEntryImpl[3];
1030
1031 array[0] = (BookmarksEntry)objArray[0];
1032 array[1] = (BookmarksEntry)objArray[1];
1033 array[2] = (BookmarksEntry)objArray[2];
1034
1035 return array;
1036 }
1037 catch (Exception e) {
1038 throw processException(e);
1039 }
1040 finally {
1041 closeSession(session);
1042 }
1043 }
1044
1045 public List<BookmarksEntry> findByFolderId(long folderId)
1046 throws SystemException {
1047 Object[] finderArgs = new Object[] { new Long(folderId) };
1048
1049 List<BookmarksEntry> list = (List<BookmarksEntry>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_FOLDERID,
1050 finderArgs, this);
1051
1052 if (list == null) {
1053 Session session = null;
1054
1055 try {
1056 session = openSession();
1057
1058 StringBuilder query = new StringBuilder();
1059
1060 query.append(
1061 "FROM com.liferay.portlet.bookmarks.model.BookmarksEntry WHERE ");
1062
1063 query.append("folderId = ?");
1064
1065 query.append(" ");
1066
1067 query.append("ORDER BY ");
1068
1069 query.append("folderId ASC, ");
1070 query.append("name ASC");
1071
1072 Query q = session.createQuery(query.toString());
1073
1074 QueryPos qPos = QueryPos.getInstance(q);
1075
1076 qPos.add(folderId);
1077
1078 list = q.list();
1079 }
1080 catch (Exception e) {
1081 throw processException(e);
1082 }
1083 finally {
1084 if (list == null) {
1085 list = new ArrayList<BookmarksEntry>();
1086 }
1087
1088 cacheResult(list);
1089
1090 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_FOLDERID,
1091 finderArgs, list);
1092
1093 closeSession(session);
1094 }
1095 }
1096
1097 return list;
1098 }
1099
1100 public List<BookmarksEntry> findByFolderId(long folderId, int start, int end)
1101 throws SystemException {
1102 return findByFolderId(folderId, start, end, null);
1103 }
1104
1105 public List<BookmarksEntry> findByFolderId(long folderId, int start,
1106 int end, OrderByComparator obc) throws SystemException {
1107 Object[] finderArgs = new Object[] {
1108 new Long(folderId),
1109
1110 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
1111 };
1112
1113 List<BookmarksEntry> list = (List<BookmarksEntry>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_FOLDERID,
1114 finderArgs, this);
1115
1116 if (list == null) {
1117 Session session = null;
1118
1119 try {
1120 session = openSession();
1121
1122 StringBuilder query = new StringBuilder();
1123
1124 query.append(
1125 "FROM com.liferay.portlet.bookmarks.model.BookmarksEntry WHERE ");
1126
1127 query.append("folderId = ?");
1128
1129 query.append(" ");
1130
1131 if (obc != null) {
1132 query.append("ORDER BY ");
1133 query.append(obc.getOrderBy());
1134 }
1135
1136 else {
1137 query.append("ORDER BY ");
1138
1139 query.append("folderId ASC, ");
1140 query.append("name ASC");
1141 }
1142
1143 Query q = session.createQuery(query.toString());
1144
1145 QueryPos qPos = QueryPos.getInstance(q);
1146
1147 qPos.add(folderId);
1148
1149 list = (List<BookmarksEntry>)QueryUtil.list(q, getDialect(),
1150 start, end);
1151 }
1152 catch (Exception e) {
1153 throw processException(e);
1154 }
1155 finally {
1156 if (list == null) {
1157 list = new ArrayList<BookmarksEntry>();
1158 }
1159
1160 cacheResult(list);
1161
1162 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_FOLDERID,
1163 finderArgs, list);
1164
1165 closeSession(session);
1166 }
1167 }
1168
1169 return list;
1170 }
1171
1172 public BookmarksEntry findByFolderId_First(long folderId,
1173 OrderByComparator obc) throws NoSuchEntryException, SystemException {
1174 List<BookmarksEntry> list = findByFolderId(folderId, 0, 1, obc);
1175
1176 if (list.isEmpty()) {
1177 StringBuilder msg = new StringBuilder();
1178
1179 msg.append("No BookmarksEntry exists with the key {");
1180
1181 msg.append("folderId=" + folderId);
1182
1183 msg.append(StringPool.CLOSE_CURLY_BRACE);
1184
1185 throw new NoSuchEntryException(msg.toString());
1186 }
1187 else {
1188 return list.get(0);
1189 }
1190 }
1191
1192 public BookmarksEntry findByFolderId_Last(long folderId,
1193 OrderByComparator obc) throws NoSuchEntryException, SystemException {
1194 int count = countByFolderId(folderId);
1195
1196 List<BookmarksEntry> list = findByFolderId(folderId, count - 1, count,
1197 obc);
1198
1199 if (list.isEmpty()) {
1200 StringBuilder msg = new StringBuilder();
1201
1202 msg.append("No BookmarksEntry exists with the key {");
1203
1204 msg.append("folderId=" + folderId);
1205
1206 msg.append(StringPool.CLOSE_CURLY_BRACE);
1207
1208 throw new NoSuchEntryException(msg.toString());
1209 }
1210 else {
1211 return list.get(0);
1212 }
1213 }
1214
1215 public BookmarksEntry[] findByFolderId_PrevAndNext(long entryId,
1216 long folderId, OrderByComparator obc)
1217 throws NoSuchEntryException, SystemException {
1218 BookmarksEntry bookmarksEntry = findByPrimaryKey(entryId);
1219
1220 int count = countByFolderId(folderId);
1221
1222 Session session = null;
1223
1224 try {
1225 session = openSession();
1226
1227 StringBuilder query = new StringBuilder();
1228
1229 query.append(
1230 "FROM com.liferay.portlet.bookmarks.model.BookmarksEntry WHERE ");
1231
1232 query.append("folderId = ?");
1233
1234 query.append(" ");
1235
1236 if (obc != null) {
1237 query.append("ORDER BY ");
1238 query.append(obc.getOrderBy());
1239 }
1240
1241 else {
1242 query.append("ORDER BY ");
1243
1244 query.append("folderId ASC, ");
1245 query.append("name ASC");
1246 }
1247
1248 Query q = session.createQuery(query.toString());
1249
1250 QueryPos qPos = QueryPos.getInstance(q);
1251
1252 qPos.add(folderId);
1253
1254 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
1255 bookmarksEntry);
1256
1257 BookmarksEntry[] array = new BookmarksEntryImpl[3];
1258
1259 array[0] = (BookmarksEntry)objArray[0];
1260 array[1] = (BookmarksEntry)objArray[1];
1261 array[2] = (BookmarksEntry)objArray[2];
1262
1263 return array;
1264 }
1265 catch (Exception e) {
1266 throw processException(e);
1267 }
1268 finally {
1269 closeSession(session);
1270 }
1271 }
1272
1273 public List<BookmarksEntry> findByG_U(long groupId, long userId)
1274 throws SystemException {
1275 Object[] finderArgs = new Object[] { new Long(groupId), new Long(userId) };
1276
1277 List<BookmarksEntry> list = (List<BookmarksEntry>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_G_U,
1278 finderArgs, this);
1279
1280 if (list == null) {
1281 Session session = null;
1282
1283 try {
1284 session = openSession();
1285
1286 StringBuilder query = new StringBuilder();
1287
1288 query.append(
1289 "FROM com.liferay.portlet.bookmarks.model.BookmarksEntry WHERE ");
1290
1291 query.append("groupId = ?");
1292
1293 query.append(" AND ");
1294
1295 query.append("userId = ?");
1296
1297 query.append(" ");
1298
1299 query.append("ORDER BY ");
1300
1301 query.append("folderId ASC, ");
1302 query.append("name ASC");
1303
1304 Query q = session.createQuery(query.toString());
1305
1306 QueryPos qPos = QueryPos.getInstance(q);
1307
1308 qPos.add(groupId);
1309
1310 qPos.add(userId);
1311
1312 list = q.list();
1313 }
1314 catch (Exception e) {
1315 throw processException(e);
1316 }
1317 finally {
1318 if (list == null) {
1319 list = new ArrayList<BookmarksEntry>();
1320 }
1321
1322 cacheResult(list);
1323
1324 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_G_U, finderArgs,
1325 list);
1326
1327 closeSession(session);
1328 }
1329 }
1330
1331 return list;
1332 }
1333
1334 public List<BookmarksEntry> findByG_U(long groupId, long userId, int start,
1335 int end) throws SystemException {
1336 return findByG_U(groupId, userId, start, end, null);
1337 }
1338
1339 public List<BookmarksEntry> findByG_U(long groupId, long userId, int start,
1340 int end, OrderByComparator obc) throws SystemException {
1341 Object[] finderArgs = new Object[] {
1342 new Long(groupId), new Long(userId),
1343
1344 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
1345 };
1346
1347 List<BookmarksEntry> list = (List<BookmarksEntry>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_G_U,
1348 finderArgs, this);
1349
1350 if (list == null) {
1351 Session session = null;
1352
1353 try {
1354 session = openSession();
1355
1356 StringBuilder query = new StringBuilder();
1357
1358 query.append(
1359 "FROM com.liferay.portlet.bookmarks.model.BookmarksEntry WHERE ");
1360
1361 query.append("groupId = ?");
1362
1363 query.append(" AND ");
1364
1365 query.append("userId = ?");
1366
1367 query.append(" ");
1368
1369 if (obc != null) {
1370 query.append("ORDER BY ");
1371 query.append(obc.getOrderBy());
1372 }
1373
1374 else {
1375 query.append("ORDER BY ");
1376
1377 query.append("folderId ASC, ");
1378 query.append("name ASC");
1379 }
1380
1381 Query q = session.createQuery(query.toString());
1382
1383 QueryPos qPos = QueryPos.getInstance(q);
1384
1385 qPos.add(groupId);
1386
1387 qPos.add(userId);
1388
1389 list = (List<BookmarksEntry>)QueryUtil.list(q, getDialect(),
1390 start, end);
1391 }
1392 catch (Exception e) {
1393 throw processException(e);
1394 }
1395 finally {
1396 if (list == null) {
1397 list = new ArrayList<BookmarksEntry>();
1398 }
1399
1400 cacheResult(list);
1401
1402 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_G_U,
1403 finderArgs, list);
1404
1405 closeSession(session);
1406 }
1407 }
1408
1409 return list;
1410 }
1411
1412 public BookmarksEntry findByG_U_First(long groupId, long userId,
1413 OrderByComparator obc) throws NoSuchEntryException, SystemException {
1414 List<BookmarksEntry> list = findByG_U(groupId, userId, 0, 1, obc);
1415
1416 if (list.isEmpty()) {
1417 StringBuilder msg = new StringBuilder();
1418
1419 msg.append("No BookmarksEntry exists with the key {");
1420
1421 msg.append("groupId=" + groupId);
1422
1423 msg.append(", ");
1424 msg.append("userId=" + userId);
1425
1426 msg.append(StringPool.CLOSE_CURLY_BRACE);
1427
1428 throw new NoSuchEntryException(msg.toString());
1429 }
1430 else {
1431 return list.get(0);
1432 }
1433 }
1434
1435 public BookmarksEntry findByG_U_Last(long groupId, long userId,
1436 OrderByComparator obc) throws NoSuchEntryException, SystemException {
1437 int count = countByG_U(groupId, userId);
1438
1439 List<BookmarksEntry> list = findByG_U(groupId, userId, count - 1,
1440 count, obc);
1441
1442 if (list.isEmpty()) {
1443 StringBuilder msg = new StringBuilder();
1444
1445 msg.append("No BookmarksEntry exists with the key {");
1446
1447 msg.append("groupId=" + groupId);
1448
1449 msg.append(", ");
1450 msg.append("userId=" + userId);
1451
1452 msg.append(StringPool.CLOSE_CURLY_BRACE);
1453
1454 throw new NoSuchEntryException(msg.toString());
1455 }
1456 else {
1457 return list.get(0);
1458 }
1459 }
1460
1461 public BookmarksEntry[] findByG_U_PrevAndNext(long entryId, long groupId,
1462 long userId, OrderByComparator obc)
1463 throws NoSuchEntryException, SystemException {
1464 BookmarksEntry bookmarksEntry = findByPrimaryKey(entryId);
1465
1466 int count = countByG_U(groupId, userId);
1467
1468 Session session = null;
1469
1470 try {
1471 session = openSession();
1472
1473 StringBuilder query = new StringBuilder();
1474
1475 query.append(
1476 "FROM com.liferay.portlet.bookmarks.model.BookmarksEntry WHERE ");
1477
1478 query.append("groupId = ?");
1479
1480 query.append(" AND ");
1481
1482 query.append("userId = ?");
1483
1484 query.append(" ");
1485
1486 if (obc != null) {
1487 query.append("ORDER BY ");
1488 query.append(obc.getOrderBy());
1489 }
1490
1491 else {
1492 query.append("ORDER BY ");
1493
1494 query.append("folderId ASC, ");
1495 query.append("name ASC");
1496 }
1497
1498 Query q = session.createQuery(query.toString());
1499
1500 QueryPos qPos = QueryPos.getInstance(q);
1501
1502 qPos.add(groupId);
1503
1504 qPos.add(userId);
1505
1506 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
1507 bookmarksEntry);
1508
1509 BookmarksEntry[] array = new BookmarksEntryImpl[3];
1510
1511 array[0] = (BookmarksEntry)objArray[0];
1512 array[1] = (BookmarksEntry)objArray[1];
1513 array[2] = (BookmarksEntry)objArray[2];
1514
1515 return array;
1516 }
1517 catch (Exception e) {
1518 throw processException(e);
1519 }
1520 finally {
1521 closeSession(session);
1522 }
1523 }
1524
1525 public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery)
1526 throws SystemException {
1527 Session session = null;
1528
1529 try {
1530 session = openSession();
1531
1532 dynamicQuery.compile(session);
1533
1534 return dynamicQuery.list();
1535 }
1536 catch (Exception e) {
1537 throw processException(e);
1538 }
1539 finally {
1540 closeSession(session);
1541 }
1542 }
1543
1544 public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery,
1545 int start, int end) throws SystemException {
1546 Session session = null;
1547
1548 try {
1549 session = openSession();
1550
1551 dynamicQuery.setLimit(start, end);
1552
1553 dynamicQuery.compile(session);
1554
1555 return dynamicQuery.list();
1556 }
1557 catch (Exception e) {
1558 throw processException(e);
1559 }
1560 finally {
1561 closeSession(session);
1562 }
1563 }
1564
1565 public List<BookmarksEntry> findAll() throws SystemException {
1566 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1567 }
1568
1569 public List<BookmarksEntry> findAll(int start, int end)
1570 throws SystemException {
1571 return findAll(start, end, null);
1572 }
1573
1574 public List<BookmarksEntry> findAll(int start, int end,
1575 OrderByComparator obc) throws SystemException {
1576 Object[] finderArgs = new Object[] {
1577 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
1578 };
1579
1580 List<BookmarksEntry> list = (List<BookmarksEntry>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
1581 finderArgs, this);
1582
1583 if (list == null) {
1584 Session session = null;
1585
1586 try {
1587 session = openSession();
1588
1589 StringBuilder query = new StringBuilder();
1590
1591 query.append(
1592 "FROM com.liferay.portlet.bookmarks.model.BookmarksEntry ");
1593
1594 if (obc != null) {
1595 query.append("ORDER BY ");
1596 query.append(obc.getOrderBy());
1597 }
1598
1599 else {
1600 query.append("ORDER BY ");
1601
1602 query.append("folderId ASC, ");
1603 query.append("name ASC");
1604 }
1605
1606 Query q = session.createQuery(query.toString());
1607
1608 if (obc == null) {
1609 list = (List<BookmarksEntry>)QueryUtil.list(q,
1610 getDialect(), start, end, false);
1611
1612 Collections.sort(list);
1613 }
1614 else {
1615 list = (List<BookmarksEntry>)QueryUtil.list(q,
1616 getDialect(), start, end);
1617 }
1618 }
1619 catch (Exception e) {
1620 throw processException(e);
1621 }
1622 finally {
1623 if (list == null) {
1624 list = new ArrayList<BookmarksEntry>();
1625 }
1626
1627 cacheResult(list);
1628
1629 FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
1630
1631 closeSession(session);
1632 }
1633 }
1634
1635 return list;
1636 }
1637
1638 public void removeByUuid(String uuid) throws SystemException {
1639 for (BookmarksEntry bookmarksEntry : findByUuid(uuid)) {
1640 remove(bookmarksEntry);
1641 }
1642 }
1643
1644 public void removeByUUID_G(String uuid, long groupId)
1645 throws NoSuchEntryException, SystemException {
1646 BookmarksEntry bookmarksEntry = findByUUID_G(uuid, groupId);
1647
1648 remove(bookmarksEntry);
1649 }
1650
1651 public void removeByGroupId(long groupId) throws SystemException {
1652 for (BookmarksEntry bookmarksEntry : findByGroupId(groupId)) {
1653 remove(bookmarksEntry);
1654 }
1655 }
1656
1657 public void removeByFolderId(long folderId) throws SystemException {
1658 for (BookmarksEntry bookmarksEntry : findByFolderId(folderId)) {
1659 remove(bookmarksEntry);
1660 }
1661 }
1662
1663 public void removeByG_U(long groupId, long userId)
1664 throws SystemException {
1665 for (BookmarksEntry bookmarksEntry : findByG_U(groupId, userId)) {
1666 remove(bookmarksEntry);
1667 }
1668 }
1669
1670 public void removeAll() throws SystemException {
1671 for (BookmarksEntry bookmarksEntry : findAll()) {
1672 remove(bookmarksEntry);
1673 }
1674 }
1675
1676 public int countByUuid(String uuid) throws SystemException {
1677 Object[] finderArgs = new Object[] { uuid };
1678
1679 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
1680 finderArgs, this);
1681
1682 if (count == null) {
1683 Session session = null;
1684
1685 try {
1686 session = openSession();
1687
1688 StringBuilder query = new StringBuilder();
1689
1690 query.append("SELECT COUNT(*) ");
1691 query.append(
1692 "FROM com.liferay.portlet.bookmarks.model.BookmarksEntry WHERE ");
1693
1694 if (uuid == null) {
1695 query.append("uuid_ IS NULL");
1696 }
1697 else {
1698 query.append("uuid_ = ?");
1699 }
1700
1701 query.append(" ");
1702
1703 Query q = session.createQuery(query.toString());
1704
1705 QueryPos qPos = QueryPos.getInstance(q);
1706
1707 if (uuid != null) {
1708 qPos.add(uuid);
1709 }
1710
1711 count = (Long)q.uniqueResult();
1712 }
1713 catch (Exception e) {
1714 throw processException(e);
1715 }
1716 finally {
1717 if (count == null) {
1718 count = Long.valueOf(0);
1719 }
1720
1721 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
1722 finderArgs, count);
1723
1724 closeSession(session);
1725 }
1726 }
1727
1728 return count.intValue();
1729 }
1730
1731 public int countByUUID_G(String uuid, long groupId)
1732 throws SystemException {
1733 Object[] finderArgs = new Object[] { uuid, new Long(groupId) };
1734
1735 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_G,
1736 finderArgs, this);
1737
1738 if (count == null) {
1739 Session session = null;
1740
1741 try {
1742 session = openSession();
1743
1744 StringBuilder query = new StringBuilder();
1745
1746 query.append("SELECT COUNT(*) ");
1747 query.append(
1748 "FROM com.liferay.portlet.bookmarks.model.BookmarksEntry WHERE ");
1749
1750 if (uuid == null) {
1751 query.append("uuid_ IS NULL");
1752 }
1753 else {
1754 query.append("uuid_ = ?");
1755 }
1756
1757 query.append(" AND ");
1758
1759 query.append("groupId = ?");
1760
1761 query.append(" ");
1762
1763 Query q = session.createQuery(query.toString());
1764
1765 QueryPos qPos = QueryPos.getInstance(q);
1766
1767 if (uuid != null) {
1768 qPos.add(uuid);
1769 }
1770
1771 qPos.add(groupId);
1772
1773 count = (Long)q.uniqueResult();
1774 }
1775 catch (Exception e) {
1776 throw processException(e);
1777 }
1778 finally {
1779 if (count == null) {
1780 count = Long.valueOf(0);
1781 }
1782
1783 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G,
1784 finderArgs, count);
1785
1786 closeSession(session);
1787 }
1788 }
1789
1790 return count.intValue();
1791 }
1792
1793 public int countByGroupId(long groupId) throws SystemException {
1794 Object[] finderArgs = new Object[] { new Long(groupId) };
1795
1796 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
1797 finderArgs, this);
1798
1799 if (count == null) {
1800 Session session = null;
1801
1802 try {
1803 session = openSession();
1804
1805 StringBuilder query = new StringBuilder();
1806
1807 query.append("SELECT COUNT(*) ");
1808 query.append(
1809 "FROM com.liferay.portlet.bookmarks.model.BookmarksEntry WHERE ");
1810
1811 query.append("groupId = ?");
1812
1813 query.append(" ");
1814
1815 Query q = session.createQuery(query.toString());
1816
1817 QueryPos qPos = QueryPos.getInstance(q);
1818
1819 qPos.add(groupId);
1820
1821 count = (Long)q.uniqueResult();
1822 }
1823 catch (Exception e) {
1824 throw processException(e);
1825 }
1826 finally {
1827 if (count == null) {
1828 count = Long.valueOf(0);
1829 }
1830
1831 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
1832 finderArgs, count);
1833
1834 closeSession(session);
1835 }
1836 }
1837
1838 return count.intValue();
1839 }
1840
1841 public int countByFolderId(long folderId) throws SystemException {
1842 Object[] finderArgs = new Object[] { new Long(folderId) };
1843
1844 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_FOLDERID,
1845 finderArgs, this);
1846
1847 if (count == null) {
1848 Session session = null;
1849
1850 try {
1851 session = openSession();
1852
1853 StringBuilder query = new StringBuilder();
1854
1855 query.append("SELECT COUNT(*) ");
1856 query.append(
1857 "FROM com.liferay.portlet.bookmarks.model.BookmarksEntry WHERE ");
1858
1859 query.append("folderId = ?");
1860
1861 query.append(" ");
1862
1863 Query q = session.createQuery(query.toString());
1864
1865 QueryPos qPos = QueryPos.getInstance(q);
1866
1867 qPos.add(folderId);
1868
1869 count = (Long)q.uniqueResult();
1870 }
1871 catch (Exception e) {
1872 throw processException(e);
1873 }
1874 finally {
1875 if (count == null) {
1876 count = Long.valueOf(0);
1877 }
1878
1879 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_FOLDERID,
1880 finderArgs, count);
1881
1882 closeSession(session);
1883 }
1884 }
1885
1886 return count.intValue();
1887 }
1888
1889 public int countByG_U(long groupId, long userId) throws SystemException {
1890 Object[] finderArgs = new Object[] { new Long(groupId), new Long(userId) };
1891
1892 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_U,
1893 finderArgs, this);
1894
1895 if (count == null) {
1896 Session session = null;
1897
1898 try {
1899 session = openSession();
1900
1901 StringBuilder query = new StringBuilder();
1902
1903 query.append("SELECT COUNT(*) ");
1904 query.append(
1905 "FROM com.liferay.portlet.bookmarks.model.BookmarksEntry WHERE ");
1906
1907 query.append("groupId = ?");
1908
1909 query.append(" AND ");
1910
1911 query.append("userId = ?");
1912
1913 query.append(" ");
1914
1915 Query q = session.createQuery(query.toString());
1916
1917 QueryPos qPos = QueryPos.getInstance(q);
1918
1919 qPos.add(groupId);
1920
1921 qPos.add(userId);
1922
1923 count = (Long)q.uniqueResult();
1924 }
1925 catch (Exception e) {
1926 throw processException(e);
1927 }
1928 finally {
1929 if (count == null) {
1930 count = Long.valueOf(0);
1931 }
1932
1933 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_U, finderArgs,
1934 count);
1935
1936 closeSession(session);
1937 }
1938 }
1939
1940 return count.intValue();
1941 }
1942
1943 public int countAll() throws SystemException {
1944 Object[] finderArgs = new Object[0];
1945
1946 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1947 finderArgs, this);
1948
1949 if (count == null) {
1950 Session session = null;
1951
1952 try {
1953 session = openSession();
1954
1955 Query q = session.createQuery(
1956 "SELECT COUNT(*) FROM com.liferay.portlet.bookmarks.model.BookmarksEntry");
1957
1958 count = (Long)q.uniqueResult();
1959 }
1960 catch (Exception e) {
1961 throw processException(e);
1962 }
1963 finally {
1964 if (count == null) {
1965 count = Long.valueOf(0);
1966 }
1967
1968 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
1969 count);
1970
1971 closeSession(session);
1972 }
1973 }
1974
1975 return count.intValue();
1976 }
1977
1978 public void afterPropertiesSet() {
1979 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1980 com.liferay.portal.util.PropsUtil.get(
1981 "value.object.listener.com.liferay.portlet.bookmarks.model.BookmarksEntry")));
1982
1983 if (listenerClassNames.length > 0) {
1984 try {
1985 List<ModelListener<BookmarksEntry>> listenersList = new ArrayList<ModelListener<BookmarksEntry>>();
1986
1987 for (String listenerClassName : listenerClassNames) {
1988 listenersList.add((ModelListener<BookmarksEntry>)Class.forName(
1989 listenerClassName).newInstance());
1990 }
1991
1992 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1993 }
1994 catch (Exception e) {
1995 _log.error(e);
1996 }
1997 }
1998 }
1999
2000 @BeanReference(name = "com.liferay.portlet.bookmarks.service.persistence.BookmarksEntryPersistence.impl")
2001 protected com.liferay.portlet.bookmarks.service.persistence.BookmarksEntryPersistence bookmarksEntryPersistence;
2002 @BeanReference(name = "com.liferay.portlet.bookmarks.service.persistence.BookmarksFolderPersistence.impl")
2003 protected com.liferay.portlet.bookmarks.service.persistence.BookmarksFolderPersistence bookmarksFolderPersistence;
2004 @BeanReference(name = "com.liferay.portal.service.persistence.ResourcePersistence.impl")
2005 protected com.liferay.portal.service.persistence.ResourcePersistence resourcePersistence;
2006 @BeanReference(name = "com.liferay.portal.service.persistence.UserPersistence.impl")
2007 protected com.liferay.portal.service.persistence.UserPersistence userPersistence;
2008 @BeanReference(name = "com.liferay.portlet.expando.service.persistence.ExpandoValuePersistence.impl")
2009 protected com.liferay.portlet.expando.service.persistence.ExpandoValuePersistence expandoValuePersistence;
2010 @BeanReference(name = "com.liferay.portlet.tags.service.persistence.TagsAssetPersistence.impl")
2011 protected com.liferay.portlet.tags.service.persistence.TagsAssetPersistence tagsAssetPersistence;
2012 @BeanReference(name = "com.liferay.portlet.tags.service.persistence.TagsEntryPersistence.impl")
2013 protected com.liferay.portlet.tags.service.persistence.TagsEntryPersistence tagsEntryPersistence;
2014 private static Log _log = LogFactoryUtil.getLog(BookmarksEntryPersistenceImpl.class);
2015}