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