001
014
015 package com.liferay.portal.service.persistence;
016
017 import com.liferay.portal.NoSuchModelException;
018 import com.liferay.portal.NoSuchRepositoryEntryException;
019 import com.liferay.portal.kernel.bean.BeanReference;
020 import com.liferay.portal.kernel.cache.CacheRegistryUtil;
021 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
022 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
023 import com.liferay.portal.kernel.dao.orm.FinderPath;
024 import com.liferay.portal.kernel.dao.orm.Query;
025 import com.liferay.portal.kernel.dao.orm.QueryPos;
026 import com.liferay.portal.kernel.dao.orm.QueryUtil;
027 import com.liferay.portal.kernel.dao.orm.Session;
028 import com.liferay.portal.kernel.exception.SystemException;
029 import com.liferay.portal.kernel.log.Log;
030 import com.liferay.portal.kernel.log.LogFactoryUtil;
031 import com.liferay.portal.kernel.util.GetterUtil;
032 import com.liferay.portal.kernel.util.InstanceFactory;
033 import com.liferay.portal.kernel.util.OrderByComparator;
034 import com.liferay.portal.kernel.util.StringBundler;
035 import com.liferay.portal.kernel.util.StringPool;
036 import com.liferay.portal.kernel.util.StringUtil;
037 import com.liferay.portal.kernel.util.Validator;
038 import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
039 import com.liferay.portal.model.CacheModel;
040 import com.liferay.portal.model.ModelListener;
041 import com.liferay.portal.model.RepositoryEntry;
042 import com.liferay.portal.model.impl.RepositoryEntryImpl;
043 import com.liferay.portal.model.impl.RepositoryEntryModelImpl;
044 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
045
046 import java.io.Serializable;
047
048 import java.util.ArrayList;
049 import java.util.Collections;
050 import java.util.List;
051
052
064 public class RepositoryEntryPersistenceImpl extends BasePersistenceImpl<RepositoryEntry>
065 implements RepositoryEntryPersistence {
066
071 public static final String FINDER_CLASS_NAME_ENTITY = RepositoryEntryImpl.class.getName();
072 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
073 ".List1";
074 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
075 ".List2";
076 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(RepositoryEntryModelImpl.ENTITY_CACHE_ENABLED,
077 RepositoryEntryModelImpl.FINDER_CACHE_ENABLED,
078 RepositoryEntryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
079 "findByUuid",
080 new String[] {
081 String.class.getName(),
082
083 "java.lang.Integer", "java.lang.Integer",
084 "com.liferay.portal.kernel.util.OrderByComparator"
085 });
086 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(RepositoryEntryModelImpl.ENTITY_CACHE_ENABLED,
087 RepositoryEntryModelImpl.FINDER_CACHE_ENABLED,
088 RepositoryEntryImpl.class,
089 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
090 new String[] { String.class.getName() },
091 RepositoryEntryModelImpl.UUID_COLUMN_BITMASK);
092 public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(RepositoryEntryModelImpl.ENTITY_CACHE_ENABLED,
093 RepositoryEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
094 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
095 new String[] { String.class.getName() });
096 public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(RepositoryEntryModelImpl.ENTITY_CACHE_ENABLED,
097 RepositoryEntryModelImpl.FINDER_CACHE_ENABLED,
098 RepositoryEntryImpl.class, FINDER_CLASS_NAME_ENTITY,
099 "fetchByUUID_G",
100 new String[] { String.class.getName(), Long.class.getName() },
101 RepositoryEntryModelImpl.UUID_COLUMN_BITMASK |
102 RepositoryEntryModelImpl.GROUPID_COLUMN_BITMASK);
103 public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(RepositoryEntryModelImpl.ENTITY_CACHE_ENABLED,
104 RepositoryEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
105 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G",
106 new String[] { String.class.getName(), Long.class.getName() });
107 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_REPOSITORYID =
108 new FinderPath(RepositoryEntryModelImpl.ENTITY_CACHE_ENABLED,
109 RepositoryEntryModelImpl.FINDER_CACHE_ENABLED,
110 RepositoryEntryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
111 "findByRepositoryId",
112 new String[] {
113 Long.class.getName(),
114
115 "java.lang.Integer", "java.lang.Integer",
116 "com.liferay.portal.kernel.util.OrderByComparator"
117 });
118 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_REPOSITORYID =
119 new FinderPath(RepositoryEntryModelImpl.ENTITY_CACHE_ENABLED,
120 RepositoryEntryModelImpl.FINDER_CACHE_ENABLED,
121 RepositoryEntryImpl.class,
122 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByRepositoryId",
123 new String[] { Long.class.getName() },
124 RepositoryEntryModelImpl.REPOSITORYID_COLUMN_BITMASK);
125 public static final FinderPath FINDER_PATH_COUNT_BY_REPOSITORYID = new FinderPath(RepositoryEntryModelImpl.ENTITY_CACHE_ENABLED,
126 RepositoryEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
127 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByRepositoryId",
128 new String[] { Long.class.getName() });
129 public static final FinderPath FINDER_PATH_FETCH_BY_R_M = new FinderPath(RepositoryEntryModelImpl.ENTITY_CACHE_ENABLED,
130 RepositoryEntryModelImpl.FINDER_CACHE_ENABLED,
131 RepositoryEntryImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByR_M",
132 new String[] { Long.class.getName(), String.class.getName() },
133 RepositoryEntryModelImpl.REPOSITORYID_COLUMN_BITMASK |
134 RepositoryEntryModelImpl.MAPPEDID_COLUMN_BITMASK);
135 public static final FinderPath FINDER_PATH_COUNT_BY_R_M = new FinderPath(RepositoryEntryModelImpl.ENTITY_CACHE_ENABLED,
136 RepositoryEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
137 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByR_M",
138 new String[] { Long.class.getName(), String.class.getName() });
139 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(RepositoryEntryModelImpl.ENTITY_CACHE_ENABLED,
140 RepositoryEntryModelImpl.FINDER_CACHE_ENABLED,
141 RepositoryEntryImpl.class,
142 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
143 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(RepositoryEntryModelImpl.ENTITY_CACHE_ENABLED,
144 RepositoryEntryModelImpl.FINDER_CACHE_ENABLED,
145 RepositoryEntryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
146 "findAll", new String[0]);
147 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(RepositoryEntryModelImpl.ENTITY_CACHE_ENABLED,
148 RepositoryEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
149 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
150
151
156 public void cacheResult(RepositoryEntry repositoryEntry) {
157 EntityCacheUtil.putResult(RepositoryEntryModelImpl.ENTITY_CACHE_ENABLED,
158 RepositoryEntryImpl.class, repositoryEntry.getPrimaryKey(),
159 repositoryEntry);
160
161 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
162 new Object[] {
163 repositoryEntry.getUuid(),
164 Long.valueOf(repositoryEntry.getGroupId())
165 }, repositoryEntry);
166
167 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_R_M,
168 new Object[] {
169 Long.valueOf(repositoryEntry.getRepositoryId()),
170
171 repositoryEntry.getMappedId()
172 }, repositoryEntry);
173
174 repositoryEntry.resetOriginalValues();
175 }
176
177
182 public void cacheResult(List<RepositoryEntry> repositoryEntries) {
183 for (RepositoryEntry repositoryEntry : repositoryEntries) {
184 if (EntityCacheUtil.getResult(
185 RepositoryEntryModelImpl.ENTITY_CACHE_ENABLED,
186 RepositoryEntryImpl.class,
187 repositoryEntry.getPrimaryKey()) == null) {
188 cacheResult(repositoryEntry);
189 }
190 else {
191 repositoryEntry.resetOriginalValues();
192 }
193 }
194 }
195
196
203 @Override
204 public void clearCache() {
205 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
206 CacheRegistryUtil.clear(RepositoryEntryImpl.class.getName());
207 }
208
209 EntityCacheUtil.clearCache(RepositoryEntryImpl.class.getName());
210
211 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
212 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
213 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
214 }
215
216
223 @Override
224 public void clearCache(RepositoryEntry repositoryEntry) {
225 EntityCacheUtil.removeResult(RepositoryEntryModelImpl.ENTITY_CACHE_ENABLED,
226 RepositoryEntryImpl.class, repositoryEntry.getPrimaryKey());
227
228 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
229 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
230
231 clearUniqueFindersCache(repositoryEntry);
232 }
233
234 @Override
235 public void clearCache(List<RepositoryEntry> repositoryEntries) {
236 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
237 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
238
239 for (RepositoryEntry repositoryEntry : repositoryEntries) {
240 EntityCacheUtil.removeResult(RepositoryEntryModelImpl.ENTITY_CACHE_ENABLED,
241 RepositoryEntryImpl.class, repositoryEntry.getPrimaryKey());
242
243 clearUniqueFindersCache(repositoryEntry);
244 }
245 }
246
247 protected void clearUniqueFindersCache(RepositoryEntry repositoryEntry) {
248 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
249 new Object[] {
250 repositoryEntry.getUuid(),
251 Long.valueOf(repositoryEntry.getGroupId())
252 });
253
254 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_R_M,
255 new Object[] {
256 Long.valueOf(repositoryEntry.getRepositoryId()),
257
258 repositoryEntry.getMappedId()
259 });
260 }
261
262
268 public RepositoryEntry create(long repositoryEntryId) {
269 RepositoryEntry repositoryEntry = new RepositoryEntryImpl();
270
271 repositoryEntry.setNew(true);
272 repositoryEntry.setPrimaryKey(repositoryEntryId);
273
274 String uuid = PortalUUIDUtil.generate();
275
276 repositoryEntry.setUuid(uuid);
277
278 return repositoryEntry;
279 }
280
281
289 public RepositoryEntry remove(long repositoryEntryId)
290 throws NoSuchRepositoryEntryException, SystemException {
291 return remove(Long.valueOf(repositoryEntryId));
292 }
293
294
302 @Override
303 public RepositoryEntry remove(Serializable primaryKey)
304 throws NoSuchRepositoryEntryException, SystemException {
305 Session session = null;
306
307 try {
308 session = openSession();
309
310 RepositoryEntry repositoryEntry = (RepositoryEntry)session.get(RepositoryEntryImpl.class,
311 primaryKey);
312
313 if (repositoryEntry == null) {
314 if (_log.isWarnEnabled()) {
315 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
316 }
317
318 throw new NoSuchRepositoryEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
319 primaryKey);
320 }
321
322 return remove(repositoryEntry);
323 }
324 catch (NoSuchRepositoryEntryException nsee) {
325 throw nsee;
326 }
327 catch (Exception e) {
328 throw processException(e);
329 }
330 finally {
331 closeSession(session);
332 }
333 }
334
335 @Override
336 protected RepositoryEntry removeImpl(RepositoryEntry repositoryEntry)
337 throws SystemException {
338 repositoryEntry = toUnwrappedModel(repositoryEntry);
339
340 Session session = null;
341
342 try {
343 session = openSession();
344
345 BatchSessionUtil.delete(session, repositoryEntry);
346 }
347 catch (Exception e) {
348 throw processException(e);
349 }
350 finally {
351 closeSession(session);
352 }
353
354 clearCache(repositoryEntry);
355
356 return repositoryEntry;
357 }
358
359 @Override
360 public RepositoryEntry updateImpl(
361 com.liferay.portal.model.RepositoryEntry repositoryEntry, boolean merge)
362 throws SystemException {
363 repositoryEntry = toUnwrappedModel(repositoryEntry);
364
365 boolean isNew = repositoryEntry.isNew();
366
367 RepositoryEntryModelImpl repositoryEntryModelImpl = (RepositoryEntryModelImpl)repositoryEntry;
368
369 if (Validator.isNull(repositoryEntry.getUuid())) {
370 String uuid = PortalUUIDUtil.generate();
371
372 repositoryEntry.setUuid(uuid);
373 }
374
375 Session session = null;
376
377 try {
378 session = openSession();
379
380 BatchSessionUtil.update(session, repositoryEntry, merge);
381
382 repositoryEntry.setNew(false);
383 }
384 catch (Exception e) {
385 throw processException(e);
386 }
387 finally {
388 closeSession(session);
389 }
390
391 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
392
393 if (isNew || !RepositoryEntryModelImpl.COLUMN_BITMASK_ENABLED) {
394 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
395 }
396
397 else {
398 if ((repositoryEntryModelImpl.getColumnBitmask() &
399 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
400 Object[] args = new Object[] {
401 repositoryEntryModelImpl.getOriginalUuid()
402 };
403
404 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
405 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
406 args);
407
408 args = new Object[] { repositoryEntryModelImpl.getUuid() };
409
410 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
411 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
412 args);
413 }
414
415 if ((repositoryEntryModelImpl.getColumnBitmask() &
416 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_REPOSITORYID.getColumnBitmask()) != 0) {
417 Object[] args = new Object[] {
418 Long.valueOf(repositoryEntryModelImpl.getOriginalRepositoryId())
419 };
420
421 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_REPOSITORYID,
422 args);
423 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_REPOSITORYID,
424 args);
425
426 args = new Object[] {
427 Long.valueOf(repositoryEntryModelImpl.getRepositoryId())
428 };
429
430 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_REPOSITORYID,
431 args);
432 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_REPOSITORYID,
433 args);
434 }
435 }
436
437 EntityCacheUtil.putResult(RepositoryEntryModelImpl.ENTITY_CACHE_ENABLED,
438 RepositoryEntryImpl.class, repositoryEntry.getPrimaryKey(),
439 repositoryEntry);
440
441 if (isNew) {
442 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
443 new Object[] {
444 repositoryEntry.getUuid(),
445 Long.valueOf(repositoryEntry.getGroupId())
446 }, repositoryEntry);
447
448 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_R_M,
449 new Object[] {
450 Long.valueOf(repositoryEntry.getRepositoryId()),
451
452 repositoryEntry.getMappedId()
453 }, repositoryEntry);
454 }
455 else {
456 if ((repositoryEntryModelImpl.getColumnBitmask() &
457 FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
458 Object[] args = new Object[] {
459 repositoryEntryModelImpl.getOriginalUuid(),
460 Long.valueOf(repositoryEntryModelImpl.getOriginalGroupId())
461 };
462
463 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
464 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
465
466 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
467 new Object[] {
468 repositoryEntry.getUuid(),
469 Long.valueOf(repositoryEntry.getGroupId())
470 }, repositoryEntry);
471 }
472
473 if ((repositoryEntryModelImpl.getColumnBitmask() &
474 FINDER_PATH_FETCH_BY_R_M.getColumnBitmask()) != 0) {
475 Object[] args = new Object[] {
476 Long.valueOf(repositoryEntryModelImpl.getOriginalRepositoryId()),
477
478 repositoryEntryModelImpl.getOriginalMappedId()
479 };
480
481 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_R_M, args);
482 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_R_M, args);
483
484 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_R_M,
485 new Object[] {
486 Long.valueOf(repositoryEntry.getRepositoryId()),
487
488 repositoryEntry.getMappedId()
489 }, repositoryEntry);
490 }
491 }
492
493 return repositoryEntry;
494 }
495
496 protected RepositoryEntry toUnwrappedModel(RepositoryEntry repositoryEntry) {
497 if (repositoryEntry instanceof RepositoryEntryImpl) {
498 return repositoryEntry;
499 }
500
501 RepositoryEntryImpl repositoryEntryImpl = new RepositoryEntryImpl();
502
503 repositoryEntryImpl.setNew(repositoryEntry.isNew());
504 repositoryEntryImpl.setPrimaryKey(repositoryEntry.getPrimaryKey());
505
506 repositoryEntryImpl.setUuid(repositoryEntry.getUuid());
507 repositoryEntryImpl.setRepositoryEntryId(repositoryEntry.getRepositoryEntryId());
508 repositoryEntryImpl.setGroupId(repositoryEntry.getGroupId());
509 repositoryEntryImpl.setRepositoryId(repositoryEntry.getRepositoryId());
510 repositoryEntryImpl.setMappedId(repositoryEntry.getMappedId());
511
512 return repositoryEntryImpl;
513 }
514
515
523 @Override
524 public RepositoryEntry findByPrimaryKey(Serializable primaryKey)
525 throws NoSuchModelException, SystemException {
526 return findByPrimaryKey(((Long)primaryKey).longValue());
527 }
528
529
537 public RepositoryEntry findByPrimaryKey(long repositoryEntryId)
538 throws NoSuchRepositoryEntryException, SystemException {
539 RepositoryEntry repositoryEntry = fetchByPrimaryKey(repositoryEntryId);
540
541 if (repositoryEntry == null) {
542 if (_log.isWarnEnabled()) {
543 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + repositoryEntryId);
544 }
545
546 throw new NoSuchRepositoryEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
547 repositoryEntryId);
548 }
549
550 return repositoryEntry;
551 }
552
553
560 @Override
561 public RepositoryEntry fetchByPrimaryKey(Serializable primaryKey)
562 throws SystemException {
563 return fetchByPrimaryKey(((Long)primaryKey).longValue());
564 }
565
566
573 public RepositoryEntry fetchByPrimaryKey(long repositoryEntryId)
574 throws SystemException {
575 RepositoryEntry repositoryEntry = (RepositoryEntry)EntityCacheUtil.getResult(RepositoryEntryModelImpl.ENTITY_CACHE_ENABLED,
576 RepositoryEntryImpl.class, repositoryEntryId);
577
578 if (repositoryEntry == _nullRepositoryEntry) {
579 return null;
580 }
581
582 if (repositoryEntry == null) {
583 Session session = null;
584
585 boolean hasException = false;
586
587 try {
588 session = openSession();
589
590 repositoryEntry = (RepositoryEntry)session.get(RepositoryEntryImpl.class,
591 Long.valueOf(repositoryEntryId));
592 }
593 catch (Exception e) {
594 hasException = true;
595
596 throw processException(e);
597 }
598 finally {
599 if (repositoryEntry != null) {
600 cacheResult(repositoryEntry);
601 }
602 else if (!hasException) {
603 EntityCacheUtil.putResult(RepositoryEntryModelImpl.ENTITY_CACHE_ENABLED,
604 RepositoryEntryImpl.class, repositoryEntryId,
605 _nullRepositoryEntry);
606 }
607
608 closeSession(session);
609 }
610 }
611
612 return repositoryEntry;
613 }
614
615
622 public List<RepositoryEntry> findByUuid(String uuid)
623 throws SystemException {
624 return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
625 }
626
627
640 public List<RepositoryEntry> findByUuid(String uuid, int start, int end)
641 throws SystemException {
642 return findByUuid(uuid, start, end, null);
643 }
644
645
659 public List<RepositoryEntry> findByUuid(String uuid, int start, int end,
660 OrderByComparator orderByComparator) throws SystemException {
661 FinderPath finderPath = null;
662 Object[] finderArgs = null;
663
664 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
665 (orderByComparator == null)) {
666 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
667 finderArgs = new Object[] { uuid };
668 }
669 else {
670 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
671 finderArgs = new Object[] { uuid, start, end, orderByComparator };
672 }
673
674 List<RepositoryEntry> list = (List<RepositoryEntry>)FinderCacheUtil.getResult(finderPath,
675 finderArgs, this);
676
677 if (list == null) {
678 StringBundler query = null;
679
680 if (orderByComparator != null) {
681 query = new StringBundler(3 +
682 (orderByComparator.getOrderByFields().length * 3));
683 }
684 else {
685 query = new StringBundler(2);
686 }
687
688 query.append(_SQL_SELECT_REPOSITORYENTRY_WHERE);
689
690 if (uuid == null) {
691 query.append(_FINDER_COLUMN_UUID_UUID_1);
692 }
693 else {
694 if (uuid.equals(StringPool.BLANK)) {
695 query.append(_FINDER_COLUMN_UUID_UUID_3);
696 }
697 else {
698 query.append(_FINDER_COLUMN_UUID_UUID_2);
699 }
700 }
701
702 if (orderByComparator != null) {
703 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
704 orderByComparator);
705 }
706
707 String sql = query.toString();
708
709 Session session = null;
710
711 try {
712 session = openSession();
713
714 Query q = session.createQuery(sql);
715
716 QueryPos qPos = QueryPos.getInstance(q);
717
718 if (uuid != null) {
719 qPos.add(uuid);
720 }
721
722 list = (List<RepositoryEntry>)QueryUtil.list(q, getDialect(),
723 start, end);
724 }
725 catch (Exception e) {
726 throw processException(e);
727 }
728 finally {
729 if (list == null) {
730 FinderCacheUtil.removeResult(finderPath, finderArgs);
731 }
732 else {
733 cacheResult(list);
734
735 FinderCacheUtil.putResult(finderPath, finderArgs, list);
736 }
737
738 closeSession(session);
739 }
740 }
741
742 return list;
743 }
744
745
758 public RepositoryEntry findByUuid_First(String uuid,
759 OrderByComparator orderByComparator)
760 throws NoSuchRepositoryEntryException, SystemException {
761 List<RepositoryEntry> list = findByUuid(uuid, 0, 1, orderByComparator);
762
763 if (list.isEmpty()) {
764 StringBundler msg = new StringBundler(4);
765
766 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
767
768 msg.append("uuid=");
769 msg.append(uuid);
770
771 msg.append(StringPool.CLOSE_CURLY_BRACE);
772
773 throw new NoSuchRepositoryEntryException(msg.toString());
774 }
775 else {
776 return list.get(0);
777 }
778 }
779
780
793 public RepositoryEntry findByUuid_Last(String uuid,
794 OrderByComparator orderByComparator)
795 throws NoSuchRepositoryEntryException, SystemException {
796 int count = countByUuid(uuid);
797
798 List<RepositoryEntry> list = findByUuid(uuid, count - 1, count,
799 orderByComparator);
800
801 if (list.isEmpty()) {
802 StringBundler msg = new StringBundler(4);
803
804 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
805
806 msg.append("uuid=");
807 msg.append(uuid);
808
809 msg.append(StringPool.CLOSE_CURLY_BRACE);
810
811 throw new NoSuchRepositoryEntryException(msg.toString());
812 }
813 else {
814 return list.get(0);
815 }
816 }
817
818
832 public RepositoryEntry[] findByUuid_PrevAndNext(long repositoryEntryId,
833 String uuid, OrderByComparator orderByComparator)
834 throws NoSuchRepositoryEntryException, SystemException {
835 RepositoryEntry repositoryEntry = findByPrimaryKey(repositoryEntryId);
836
837 Session session = null;
838
839 try {
840 session = openSession();
841
842 RepositoryEntry[] array = new RepositoryEntryImpl[3];
843
844 array[0] = getByUuid_PrevAndNext(session, repositoryEntry, uuid,
845 orderByComparator, true);
846
847 array[1] = repositoryEntry;
848
849 array[2] = getByUuid_PrevAndNext(session, repositoryEntry, uuid,
850 orderByComparator, false);
851
852 return array;
853 }
854 catch (Exception e) {
855 throw processException(e);
856 }
857 finally {
858 closeSession(session);
859 }
860 }
861
862 protected RepositoryEntry getByUuid_PrevAndNext(Session session,
863 RepositoryEntry repositoryEntry, String uuid,
864 OrderByComparator orderByComparator, boolean previous) {
865 StringBundler query = null;
866
867 if (orderByComparator != null) {
868 query = new StringBundler(6 +
869 (orderByComparator.getOrderByFields().length * 6));
870 }
871 else {
872 query = new StringBundler(3);
873 }
874
875 query.append(_SQL_SELECT_REPOSITORYENTRY_WHERE);
876
877 if (uuid == null) {
878 query.append(_FINDER_COLUMN_UUID_UUID_1);
879 }
880 else {
881 if (uuid.equals(StringPool.BLANK)) {
882 query.append(_FINDER_COLUMN_UUID_UUID_3);
883 }
884 else {
885 query.append(_FINDER_COLUMN_UUID_UUID_2);
886 }
887 }
888
889 if (orderByComparator != null) {
890 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
891
892 if (orderByConditionFields.length > 0) {
893 query.append(WHERE_AND);
894 }
895
896 for (int i = 0; i < orderByConditionFields.length; i++) {
897 query.append(_ORDER_BY_ENTITY_ALIAS);
898 query.append(orderByConditionFields[i]);
899
900 if ((i + 1) < orderByConditionFields.length) {
901 if (orderByComparator.isAscending() ^ previous) {
902 query.append(WHERE_GREATER_THAN_HAS_NEXT);
903 }
904 else {
905 query.append(WHERE_LESSER_THAN_HAS_NEXT);
906 }
907 }
908 else {
909 if (orderByComparator.isAscending() ^ previous) {
910 query.append(WHERE_GREATER_THAN);
911 }
912 else {
913 query.append(WHERE_LESSER_THAN);
914 }
915 }
916 }
917
918 query.append(ORDER_BY_CLAUSE);
919
920 String[] orderByFields = orderByComparator.getOrderByFields();
921
922 for (int i = 0; i < orderByFields.length; i++) {
923 query.append(_ORDER_BY_ENTITY_ALIAS);
924 query.append(orderByFields[i]);
925
926 if ((i + 1) < orderByFields.length) {
927 if (orderByComparator.isAscending() ^ previous) {
928 query.append(ORDER_BY_ASC_HAS_NEXT);
929 }
930 else {
931 query.append(ORDER_BY_DESC_HAS_NEXT);
932 }
933 }
934 else {
935 if (orderByComparator.isAscending() ^ previous) {
936 query.append(ORDER_BY_ASC);
937 }
938 else {
939 query.append(ORDER_BY_DESC);
940 }
941 }
942 }
943 }
944
945 String sql = query.toString();
946
947 Query q = session.createQuery(sql);
948
949 q.setFirstResult(0);
950 q.setMaxResults(2);
951
952 QueryPos qPos = QueryPos.getInstance(q);
953
954 if (uuid != null) {
955 qPos.add(uuid);
956 }
957
958 if (orderByComparator != null) {
959 Object[] values = orderByComparator.getOrderByConditionValues(repositoryEntry);
960
961 for (Object value : values) {
962 qPos.add(value);
963 }
964 }
965
966 List<RepositoryEntry> list = q.list();
967
968 if (list.size() == 2) {
969 return list.get(1);
970 }
971 else {
972 return null;
973 }
974 }
975
976
985 public RepositoryEntry findByUUID_G(String uuid, long groupId)
986 throws NoSuchRepositoryEntryException, SystemException {
987 RepositoryEntry repositoryEntry = fetchByUUID_G(uuid, groupId);
988
989 if (repositoryEntry == null) {
990 StringBundler msg = new StringBundler(6);
991
992 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
993
994 msg.append("uuid=");
995 msg.append(uuid);
996
997 msg.append(", groupId=");
998 msg.append(groupId);
999
1000 msg.append(StringPool.CLOSE_CURLY_BRACE);
1001
1002 if (_log.isWarnEnabled()) {
1003 _log.warn(msg.toString());
1004 }
1005
1006 throw new NoSuchRepositoryEntryException(msg.toString());
1007 }
1008
1009 return repositoryEntry;
1010 }
1011
1012
1020 public RepositoryEntry fetchByUUID_G(String uuid, long groupId)
1021 throws SystemException {
1022 return fetchByUUID_G(uuid, groupId, true);
1023 }
1024
1025
1034 public RepositoryEntry fetchByUUID_G(String uuid, long groupId,
1035 boolean retrieveFromCache) throws SystemException {
1036 Object[] finderArgs = new Object[] { uuid, groupId };
1037
1038 Object result = null;
1039
1040 if (retrieveFromCache) {
1041 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
1042 finderArgs, this);
1043 }
1044
1045 if (result == null) {
1046 StringBundler query = new StringBundler(3);
1047
1048 query.append(_SQL_SELECT_REPOSITORYENTRY_WHERE);
1049
1050 if (uuid == null) {
1051 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
1052 }
1053 else {
1054 if (uuid.equals(StringPool.BLANK)) {
1055 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
1056 }
1057 else {
1058 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
1059 }
1060 }
1061
1062 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
1063
1064 String sql = query.toString();
1065
1066 Session session = null;
1067
1068 try {
1069 session = openSession();
1070
1071 Query q = session.createQuery(sql);
1072
1073 QueryPos qPos = QueryPos.getInstance(q);
1074
1075 if (uuid != null) {
1076 qPos.add(uuid);
1077 }
1078
1079 qPos.add(groupId);
1080
1081 List<RepositoryEntry> list = q.list();
1082
1083 result = list;
1084
1085 RepositoryEntry repositoryEntry = null;
1086
1087 if (list.isEmpty()) {
1088 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1089 finderArgs, list);
1090 }
1091 else {
1092 repositoryEntry = list.get(0);
1093
1094 cacheResult(repositoryEntry);
1095
1096 if ((repositoryEntry.getUuid() == null) ||
1097 !repositoryEntry.getUuid().equals(uuid) ||
1098 (repositoryEntry.getGroupId() != groupId)) {
1099 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1100 finderArgs, repositoryEntry);
1101 }
1102 }
1103
1104 return repositoryEntry;
1105 }
1106 catch (Exception e) {
1107 throw processException(e);
1108 }
1109 finally {
1110 if (result == null) {
1111 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
1112 finderArgs);
1113 }
1114
1115 closeSession(session);
1116 }
1117 }
1118 else {
1119 if (result instanceof List<?>) {
1120 return null;
1121 }
1122 else {
1123 return (RepositoryEntry)result;
1124 }
1125 }
1126 }
1127
1128
1135 public List<RepositoryEntry> findByRepositoryId(long repositoryId)
1136 throws SystemException {
1137 return findByRepositoryId(repositoryId, QueryUtil.ALL_POS,
1138 QueryUtil.ALL_POS, null);
1139 }
1140
1141
1154 public List<RepositoryEntry> findByRepositoryId(long repositoryId,
1155 int start, int end) throws SystemException {
1156 return findByRepositoryId(repositoryId, start, end, null);
1157 }
1158
1159
1173 public List<RepositoryEntry> findByRepositoryId(long repositoryId,
1174 int start, int end, OrderByComparator orderByComparator)
1175 throws SystemException {
1176 FinderPath finderPath = null;
1177 Object[] finderArgs = null;
1178
1179 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1180 (orderByComparator == null)) {
1181 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_REPOSITORYID;
1182 finderArgs = new Object[] { repositoryId };
1183 }
1184 else {
1185 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_REPOSITORYID;
1186 finderArgs = new Object[] {
1187 repositoryId,
1188
1189 start, end, orderByComparator
1190 };
1191 }
1192
1193 List<RepositoryEntry> list = (List<RepositoryEntry>)FinderCacheUtil.getResult(finderPath,
1194 finderArgs, this);
1195
1196 if (list == null) {
1197 StringBundler query = null;
1198
1199 if (orderByComparator != null) {
1200 query = new StringBundler(3 +
1201 (orderByComparator.getOrderByFields().length * 3));
1202 }
1203 else {
1204 query = new StringBundler(2);
1205 }
1206
1207 query.append(_SQL_SELECT_REPOSITORYENTRY_WHERE);
1208
1209 query.append(_FINDER_COLUMN_REPOSITORYID_REPOSITORYID_2);
1210
1211 if (orderByComparator != null) {
1212 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1213 orderByComparator);
1214 }
1215
1216 String sql = query.toString();
1217
1218 Session session = null;
1219
1220 try {
1221 session = openSession();
1222
1223 Query q = session.createQuery(sql);
1224
1225 QueryPos qPos = QueryPos.getInstance(q);
1226
1227 qPos.add(repositoryId);
1228
1229 list = (List<RepositoryEntry>)QueryUtil.list(q, getDialect(),
1230 start, end);
1231 }
1232 catch (Exception e) {
1233 throw processException(e);
1234 }
1235 finally {
1236 if (list == null) {
1237 FinderCacheUtil.removeResult(finderPath, finderArgs);
1238 }
1239 else {
1240 cacheResult(list);
1241
1242 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1243 }
1244
1245 closeSession(session);
1246 }
1247 }
1248
1249 return list;
1250 }
1251
1252
1265 public RepositoryEntry findByRepositoryId_First(long repositoryId,
1266 OrderByComparator orderByComparator)
1267 throws NoSuchRepositoryEntryException, SystemException {
1268 List<RepositoryEntry> list = findByRepositoryId(repositoryId, 0, 1,
1269 orderByComparator);
1270
1271 if (list.isEmpty()) {
1272 StringBundler msg = new StringBundler(4);
1273
1274 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1275
1276 msg.append("repositoryId=");
1277 msg.append(repositoryId);
1278
1279 msg.append(StringPool.CLOSE_CURLY_BRACE);
1280
1281 throw new NoSuchRepositoryEntryException(msg.toString());
1282 }
1283 else {
1284 return list.get(0);
1285 }
1286 }
1287
1288
1301 public RepositoryEntry findByRepositoryId_Last(long repositoryId,
1302 OrderByComparator orderByComparator)
1303 throws NoSuchRepositoryEntryException, SystemException {
1304 int count = countByRepositoryId(repositoryId);
1305
1306 List<RepositoryEntry> list = findByRepositoryId(repositoryId,
1307 count - 1, count, orderByComparator);
1308
1309 if (list.isEmpty()) {
1310 StringBundler msg = new StringBundler(4);
1311
1312 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1313
1314 msg.append("repositoryId=");
1315 msg.append(repositoryId);
1316
1317 msg.append(StringPool.CLOSE_CURLY_BRACE);
1318
1319 throw new NoSuchRepositoryEntryException(msg.toString());
1320 }
1321 else {
1322 return list.get(0);
1323 }
1324 }
1325
1326
1340 public RepositoryEntry[] findByRepositoryId_PrevAndNext(
1341 long repositoryEntryId, long repositoryId,
1342 OrderByComparator orderByComparator)
1343 throws NoSuchRepositoryEntryException, SystemException {
1344 RepositoryEntry repositoryEntry = findByPrimaryKey(repositoryEntryId);
1345
1346 Session session = null;
1347
1348 try {
1349 session = openSession();
1350
1351 RepositoryEntry[] array = new RepositoryEntryImpl[3];
1352
1353 array[0] = getByRepositoryId_PrevAndNext(session, repositoryEntry,
1354 repositoryId, orderByComparator, true);
1355
1356 array[1] = repositoryEntry;
1357
1358 array[2] = getByRepositoryId_PrevAndNext(session, repositoryEntry,
1359 repositoryId, orderByComparator, false);
1360
1361 return array;
1362 }
1363 catch (Exception e) {
1364 throw processException(e);
1365 }
1366 finally {
1367 closeSession(session);
1368 }
1369 }
1370
1371 protected RepositoryEntry getByRepositoryId_PrevAndNext(Session session,
1372 RepositoryEntry repositoryEntry, long repositoryId,
1373 OrderByComparator orderByComparator, boolean previous) {
1374 StringBundler query = null;
1375
1376 if (orderByComparator != null) {
1377 query = new StringBundler(6 +
1378 (orderByComparator.getOrderByFields().length * 6));
1379 }
1380 else {
1381 query = new StringBundler(3);
1382 }
1383
1384 query.append(_SQL_SELECT_REPOSITORYENTRY_WHERE);
1385
1386 query.append(_FINDER_COLUMN_REPOSITORYID_REPOSITORYID_2);
1387
1388 if (orderByComparator != null) {
1389 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1390
1391 if (orderByConditionFields.length > 0) {
1392 query.append(WHERE_AND);
1393 }
1394
1395 for (int i = 0; i < orderByConditionFields.length; i++) {
1396 query.append(_ORDER_BY_ENTITY_ALIAS);
1397 query.append(orderByConditionFields[i]);
1398
1399 if ((i + 1) < orderByConditionFields.length) {
1400 if (orderByComparator.isAscending() ^ previous) {
1401 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1402 }
1403 else {
1404 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1405 }
1406 }
1407 else {
1408 if (orderByComparator.isAscending() ^ previous) {
1409 query.append(WHERE_GREATER_THAN);
1410 }
1411 else {
1412 query.append(WHERE_LESSER_THAN);
1413 }
1414 }
1415 }
1416
1417 query.append(ORDER_BY_CLAUSE);
1418
1419 String[] orderByFields = orderByComparator.getOrderByFields();
1420
1421 for (int i = 0; i < orderByFields.length; i++) {
1422 query.append(_ORDER_BY_ENTITY_ALIAS);
1423 query.append(orderByFields[i]);
1424
1425 if ((i + 1) < orderByFields.length) {
1426 if (orderByComparator.isAscending() ^ previous) {
1427 query.append(ORDER_BY_ASC_HAS_NEXT);
1428 }
1429 else {
1430 query.append(ORDER_BY_DESC_HAS_NEXT);
1431 }
1432 }
1433 else {
1434 if (orderByComparator.isAscending() ^ previous) {
1435 query.append(ORDER_BY_ASC);
1436 }
1437 else {
1438 query.append(ORDER_BY_DESC);
1439 }
1440 }
1441 }
1442 }
1443
1444 String sql = query.toString();
1445
1446 Query q = session.createQuery(sql);
1447
1448 q.setFirstResult(0);
1449 q.setMaxResults(2);
1450
1451 QueryPos qPos = QueryPos.getInstance(q);
1452
1453 qPos.add(repositoryId);
1454
1455 if (orderByComparator != null) {
1456 Object[] values = orderByComparator.getOrderByConditionValues(repositoryEntry);
1457
1458 for (Object value : values) {
1459 qPos.add(value);
1460 }
1461 }
1462
1463 List<RepositoryEntry> list = q.list();
1464
1465 if (list.size() == 2) {
1466 return list.get(1);
1467 }
1468 else {
1469 return null;
1470 }
1471 }
1472
1473
1482 public RepositoryEntry findByR_M(long repositoryId, String mappedId)
1483 throws NoSuchRepositoryEntryException, SystemException {
1484 RepositoryEntry repositoryEntry = fetchByR_M(repositoryId, mappedId);
1485
1486 if (repositoryEntry == null) {
1487 StringBundler msg = new StringBundler(6);
1488
1489 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1490
1491 msg.append("repositoryId=");
1492 msg.append(repositoryId);
1493
1494 msg.append(", mappedId=");
1495 msg.append(mappedId);
1496
1497 msg.append(StringPool.CLOSE_CURLY_BRACE);
1498
1499 if (_log.isWarnEnabled()) {
1500 _log.warn(msg.toString());
1501 }
1502
1503 throw new NoSuchRepositoryEntryException(msg.toString());
1504 }
1505
1506 return repositoryEntry;
1507 }
1508
1509
1517 public RepositoryEntry fetchByR_M(long repositoryId, String mappedId)
1518 throws SystemException {
1519 return fetchByR_M(repositoryId, mappedId, true);
1520 }
1521
1522
1531 public RepositoryEntry fetchByR_M(long repositoryId, String mappedId,
1532 boolean retrieveFromCache) throws SystemException {
1533 Object[] finderArgs = new Object[] { repositoryId, mappedId };
1534
1535 Object result = null;
1536
1537 if (retrieveFromCache) {
1538 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_R_M,
1539 finderArgs, this);
1540 }
1541
1542 if (result == null) {
1543 StringBundler query = new StringBundler(3);
1544
1545 query.append(_SQL_SELECT_REPOSITORYENTRY_WHERE);
1546
1547 query.append(_FINDER_COLUMN_R_M_REPOSITORYID_2);
1548
1549 if (mappedId == null) {
1550 query.append(_FINDER_COLUMN_R_M_MAPPEDID_1);
1551 }
1552 else {
1553 if (mappedId.equals(StringPool.BLANK)) {
1554 query.append(_FINDER_COLUMN_R_M_MAPPEDID_3);
1555 }
1556 else {
1557 query.append(_FINDER_COLUMN_R_M_MAPPEDID_2);
1558 }
1559 }
1560
1561 String sql = query.toString();
1562
1563 Session session = null;
1564
1565 try {
1566 session = openSession();
1567
1568 Query q = session.createQuery(sql);
1569
1570 QueryPos qPos = QueryPos.getInstance(q);
1571
1572 qPos.add(repositoryId);
1573
1574 if (mappedId != null) {
1575 qPos.add(mappedId);
1576 }
1577
1578 List<RepositoryEntry> list = q.list();
1579
1580 result = list;
1581
1582 RepositoryEntry repositoryEntry = null;
1583
1584 if (list.isEmpty()) {
1585 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_R_M,
1586 finderArgs, list);
1587 }
1588 else {
1589 repositoryEntry = list.get(0);
1590
1591 cacheResult(repositoryEntry);
1592
1593 if ((repositoryEntry.getRepositoryId() != repositoryId) ||
1594 (repositoryEntry.getMappedId() == null) ||
1595 !repositoryEntry.getMappedId().equals(mappedId)) {
1596 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_R_M,
1597 finderArgs, repositoryEntry);
1598 }
1599 }
1600
1601 return repositoryEntry;
1602 }
1603 catch (Exception e) {
1604 throw processException(e);
1605 }
1606 finally {
1607 if (result == null) {
1608 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_R_M,
1609 finderArgs);
1610 }
1611
1612 closeSession(session);
1613 }
1614 }
1615 else {
1616 if (result instanceof List<?>) {
1617 return null;
1618 }
1619 else {
1620 return (RepositoryEntry)result;
1621 }
1622 }
1623 }
1624
1625
1631 public List<RepositoryEntry> findAll() throws SystemException {
1632 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1633 }
1634
1635
1647 public List<RepositoryEntry> findAll(int start, int end)
1648 throws SystemException {
1649 return findAll(start, end, null);
1650 }
1651
1652
1665 public List<RepositoryEntry> findAll(int start, int end,
1666 OrderByComparator orderByComparator) throws SystemException {
1667 FinderPath finderPath = null;
1668 Object[] finderArgs = new Object[] { start, end, orderByComparator };
1669
1670 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1671 (orderByComparator == null)) {
1672 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
1673 finderArgs = FINDER_ARGS_EMPTY;
1674 }
1675 else {
1676 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
1677 finderArgs = new Object[] { start, end, orderByComparator };
1678 }
1679
1680 List<RepositoryEntry> list = (List<RepositoryEntry>)FinderCacheUtil.getResult(finderPath,
1681 finderArgs, this);
1682
1683 if (list == null) {
1684 StringBundler query = null;
1685 String sql = null;
1686
1687 if (orderByComparator != null) {
1688 query = new StringBundler(2 +
1689 (orderByComparator.getOrderByFields().length * 3));
1690
1691 query.append(_SQL_SELECT_REPOSITORYENTRY);
1692
1693 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1694 orderByComparator);
1695
1696 sql = query.toString();
1697 }
1698 else {
1699 sql = _SQL_SELECT_REPOSITORYENTRY;
1700 }
1701
1702 Session session = null;
1703
1704 try {
1705 session = openSession();
1706
1707 Query q = session.createQuery(sql);
1708
1709 if (orderByComparator == null) {
1710 list = (List<RepositoryEntry>)QueryUtil.list(q,
1711 getDialect(), start, end, false);
1712
1713 Collections.sort(list);
1714 }
1715 else {
1716 list = (List<RepositoryEntry>)QueryUtil.list(q,
1717 getDialect(), start, end);
1718 }
1719 }
1720 catch (Exception e) {
1721 throw processException(e);
1722 }
1723 finally {
1724 if (list == null) {
1725 FinderCacheUtil.removeResult(finderPath, finderArgs);
1726 }
1727 else {
1728 cacheResult(list);
1729
1730 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1731 }
1732
1733 closeSession(session);
1734 }
1735 }
1736
1737 return list;
1738 }
1739
1740
1746 public void removeByUuid(String uuid) throws SystemException {
1747 for (RepositoryEntry repositoryEntry : findByUuid(uuid)) {
1748 remove(repositoryEntry);
1749 }
1750 }
1751
1752
1759 public void removeByUUID_G(String uuid, long groupId)
1760 throws NoSuchRepositoryEntryException, SystemException {
1761 RepositoryEntry repositoryEntry = findByUUID_G(uuid, groupId);
1762
1763 remove(repositoryEntry);
1764 }
1765
1766
1772 public void removeByRepositoryId(long repositoryId)
1773 throws SystemException {
1774 for (RepositoryEntry repositoryEntry : findByRepositoryId(repositoryId)) {
1775 remove(repositoryEntry);
1776 }
1777 }
1778
1779
1786 public void removeByR_M(long repositoryId, String mappedId)
1787 throws NoSuchRepositoryEntryException, SystemException {
1788 RepositoryEntry repositoryEntry = findByR_M(repositoryId, mappedId);
1789
1790 remove(repositoryEntry);
1791 }
1792
1793
1798 public void removeAll() throws SystemException {
1799 for (RepositoryEntry repositoryEntry : findAll()) {
1800 remove(repositoryEntry);
1801 }
1802 }
1803
1804
1811 public int countByUuid(String uuid) throws SystemException {
1812 Object[] finderArgs = new Object[] { uuid };
1813
1814 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
1815 finderArgs, this);
1816
1817 if (count == null) {
1818 StringBundler query = new StringBundler(2);
1819
1820 query.append(_SQL_COUNT_REPOSITORYENTRY_WHERE);
1821
1822 if (uuid == null) {
1823 query.append(_FINDER_COLUMN_UUID_UUID_1);
1824 }
1825 else {
1826 if (uuid.equals(StringPool.BLANK)) {
1827 query.append(_FINDER_COLUMN_UUID_UUID_3);
1828 }
1829 else {
1830 query.append(_FINDER_COLUMN_UUID_UUID_2);
1831 }
1832 }
1833
1834 String sql = query.toString();
1835
1836 Session session = null;
1837
1838 try {
1839 session = openSession();
1840
1841 Query q = session.createQuery(sql);
1842
1843 QueryPos qPos = QueryPos.getInstance(q);
1844
1845 if (uuid != null) {
1846 qPos.add(uuid);
1847 }
1848
1849 count = (Long)q.uniqueResult();
1850 }
1851 catch (Exception e) {
1852 throw processException(e);
1853 }
1854 finally {
1855 if (count == null) {
1856 count = Long.valueOf(0);
1857 }
1858
1859 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
1860 finderArgs, count);
1861
1862 closeSession(session);
1863 }
1864 }
1865
1866 return count.intValue();
1867 }
1868
1869
1877 public int countByUUID_G(String uuid, long groupId)
1878 throws SystemException {
1879 Object[] finderArgs = new Object[] { uuid, groupId };
1880
1881 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_G,
1882 finderArgs, this);
1883
1884 if (count == null) {
1885 StringBundler query = new StringBundler(3);
1886
1887 query.append(_SQL_COUNT_REPOSITORYENTRY_WHERE);
1888
1889 if (uuid == null) {
1890 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
1891 }
1892 else {
1893 if (uuid.equals(StringPool.BLANK)) {
1894 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
1895 }
1896 else {
1897 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
1898 }
1899 }
1900
1901 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
1902
1903 String sql = query.toString();
1904
1905 Session session = null;
1906
1907 try {
1908 session = openSession();
1909
1910 Query q = session.createQuery(sql);
1911
1912 QueryPos qPos = QueryPos.getInstance(q);
1913
1914 if (uuid != null) {
1915 qPos.add(uuid);
1916 }
1917
1918 qPos.add(groupId);
1919
1920 count = (Long)q.uniqueResult();
1921 }
1922 catch (Exception e) {
1923 throw processException(e);
1924 }
1925 finally {
1926 if (count == null) {
1927 count = Long.valueOf(0);
1928 }
1929
1930 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G,
1931 finderArgs, count);
1932
1933 closeSession(session);
1934 }
1935 }
1936
1937 return count.intValue();
1938 }
1939
1940
1947 public int countByRepositoryId(long repositoryId) throws SystemException {
1948 Object[] finderArgs = new Object[] { repositoryId };
1949
1950 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_REPOSITORYID,
1951 finderArgs, this);
1952
1953 if (count == null) {
1954 StringBundler query = new StringBundler(2);
1955
1956 query.append(_SQL_COUNT_REPOSITORYENTRY_WHERE);
1957
1958 query.append(_FINDER_COLUMN_REPOSITORYID_REPOSITORYID_2);
1959
1960 String sql = query.toString();
1961
1962 Session session = null;
1963
1964 try {
1965 session = openSession();
1966
1967 Query q = session.createQuery(sql);
1968
1969 QueryPos qPos = QueryPos.getInstance(q);
1970
1971 qPos.add(repositoryId);
1972
1973 count = (Long)q.uniqueResult();
1974 }
1975 catch (Exception e) {
1976 throw processException(e);
1977 }
1978 finally {
1979 if (count == null) {
1980 count = Long.valueOf(0);
1981 }
1982
1983 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_REPOSITORYID,
1984 finderArgs, count);
1985
1986 closeSession(session);
1987 }
1988 }
1989
1990 return count.intValue();
1991 }
1992
1993
2001 public int countByR_M(long repositoryId, String mappedId)
2002 throws SystemException {
2003 Object[] finderArgs = new Object[] { repositoryId, mappedId };
2004
2005 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_R_M,
2006 finderArgs, this);
2007
2008 if (count == null) {
2009 StringBundler query = new StringBundler(3);
2010
2011 query.append(_SQL_COUNT_REPOSITORYENTRY_WHERE);
2012
2013 query.append(_FINDER_COLUMN_R_M_REPOSITORYID_2);
2014
2015 if (mappedId == null) {
2016 query.append(_FINDER_COLUMN_R_M_MAPPEDID_1);
2017 }
2018 else {
2019 if (mappedId.equals(StringPool.BLANK)) {
2020 query.append(_FINDER_COLUMN_R_M_MAPPEDID_3);
2021 }
2022 else {
2023 query.append(_FINDER_COLUMN_R_M_MAPPEDID_2);
2024 }
2025 }
2026
2027 String sql = query.toString();
2028
2029 Session session = null;
2030
2031 try {
2032 session = openSession();
2033
2034 Query q = session.createQuery(sql);
2035
2036 QueryPos qPos = QueryPos.getInstance(q);
2037
2038 qPos.add(repositoryId);
2039
2040 if (mappedId != null) {
2041 qPos.add(mappedId);
2042 }
2043
2044 count = (Long)q.uniqueResult();
2045 }
2046 catch (Exception e) {
2047 throw processException(e);
2048 }
2049 finally {
2050 if (count == null) {
2051 count = Long.valueOf(0);
2052 }
2053
2054 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_R_M, finderArgs,
2055 count);
2056
2057 closeSession(session);
2058 }
2059 }
2060
2061 return count.intValue();
2062 }
2063
2064
2070 public int countAll() throws SystemException {
2071 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
2072 FINDER_ARGS_EMPTY, this);
2073
2074 if (count == null) {
2075 Session session = null;
2076
2077 try {
2078 session = openSession();
2079
2080 Query q = session.createQuery(_SQL_COUNT_REPOSITORYENTRY);
2081
2082 count = (Long)q.uniqueResult();
2083 }
2084 catch (Exception e) {
2085 throw processException(e);
2086 }
2087 finally {
2088 if (count == null) {
2089 count = Long.valueOf(0);
2090 }
2091
2092 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
2093 FINDER_ARGS_EMPTY, count);
2094
2095 closeSession(session);
2096 }
2097 }
2098
2099 return count.intValue();
2100 }
2101
2102
2105 public void afterPropertiesSet() {
2106 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
2107 com.liferay.portal.util.PropsUtil.get(
2108 "value.object.listener.com.liferay.portal.model.RepositoryEntry")));
2109
2110 if (listenerClassNames.length > 0) {
2111 try {
2112 List<ModelListener<RepositoryEntry>> listenersList = new ArrayList<ModelListener<RepositoryEntry>>();
2113
2114 for (String listenerClassName : listenerClassNames) {
2115 listenersList.add((ModelListener<RepositoryEntry>)InstanceFactory.newInstance(
2116 listenerClassName));
2117 }
2118
2119 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
2120 }
2121 catch (Exception e) {
2122 _log.error(e);
2123 }
2124 }
2125 }
2126
2127 public void destroy() {
2128 EntityCacheUtil.removeCache(RepositoryEntryImpl.class.getName());
2129 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
2130 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2131 }
2132
2133 @BeanReference(type = AccountPersistence.class)
2134 protected AccountPersistence accountPersistence;
2135 @BeanReference(type = AddressPersistence.class)
2136 protected AddressPersistence addressPersistence;
2137 @BeanReference(type = BrowserTrackerPersistence.class)
2138 protected BrowserTrackerPersistence browserTrackerPersistence;
2139 @BeanReference(type = ClassNamePersistence.class)
2140 protected ClassNamePersistence classNamePersistence;
2141 @BeanReference(type = ClusterGroupPersistence.class)
2142 protected ClusterGroupPersistence clusterGroupPersistence;
2143 @BeanReference(type = CompanyPersistence.class)
2144 protected CompanyPersistence companyPersistence;
2145 @BeanReference(type = ContactPersistence.class)
2146 protected ContactPersistence contactPersistence;
2147 @BeanReference(type = CountryPersistence.class)
2148 protected CountryPersistence countryPersistence;
2149 @BeanReference(type = EmailAddressPersistence.class)
2150 protected EmailAddressPersistence emailAddressPersistence;
2151 @BeanReference(type = GroupPersistence.class)
2152 protected GroupPersistence groupPersistence;
2153 @BeanReference(type = ImagePersistence.class)
2154 protected ImagePersistence imagePersistence;
2155 @BeanReference(type = LayoutPersistence.class)
2156 protected LayoutPersistence layoutPersistence;
2157 @BeanReference(type = LayoutBranchPersistence.class)
2158 protected LayoutBranchPersistence layoutBranchPersistence;
2159 @BeanReference(type = LayoutPrototypePersistence.class)
2160 protected LayoutPrototypePersistence layoutPrototypePersistence;
2161 @BeanReference(type = LayoutRevisionPersistence.class)
2162 protected LayoutRevisionPersistence layoutRevisionPersistence;
2163 @BeanReference(type = LayoutSetPersistence.class)
2164 protected LayoutSetPersistence layoutSetPersistence;
2165 @BeanReference(type = LayoutSetBranchPersistence.class)
2166 protected LayoutSetBranchPersistence layoutSetBranchPersistence;
2167 @BeanReference(type = LayoutSetPrototypePersistence.class)
2168 protected LayoutSetPrototypePersistence layoutSetPrototypePersistence;
2169 @BeanReference(type = ListTypePersistence.class)
2170 protected ListTypePersistence listTypePersistence;
2171 @BeanReference(type = LockPersistence.class)
2172 protected LockPersistence lockPersistence;
2173 @BeanReference(type = MembershipRequestPersistence.class)
2174 protected MembershipRequestPersistence membershipRequestPersistence;
2175 @BeanReference(type = OrganizationPersistence.class)
2176 protected OrganizationPersistence organizationPersistence;
2177 @BeanReference(type = OrgGroupPermissionPersistence.class)
2178 protected OrgGroupPermissionPersistence orgGroupPermissionPersistence;
2179 @BeanReference(type = OrgGroupRolePersistence.class)
2180 protected OrgGroupRolePersistence orgGroupRolePersistence;
2181 @BeanReference(type = OrgLaborPersistence.class)
2182 protected OrgLaborPersistence orgLaborPersistence;
2183 @BeanReference(type = PasswordPolicyPersistence.class)
2184 protected PasswordPolicyPersistence passwordPolicyPersistence;
2185 @BeanReference(type = PasswordPolicyRelPersistence.class)
2186 protected PasswordPolicyRelPersistence passwordPolicyRelPersistence;
2187 @BeanReference(type = PasswordTrackerPersistence.class)
2188 protected PasswordTrackerPersistence passwordTrackerPersistence;
2189 @BeanReference(type = PermissionPersistence.class)
2190 protected PermissionPersistence permissionPersistence;
2191 @BeanReference(type = PhonePersistence.class)
2192 protected PhonePersistence phonePersistence;
2193 @BeanReference(type = PluginSettingPersistence.class)
2194 protected PluginSettingPersistence pluginSettingPersistence;
2195 @BeanReference(type = PortalPreferencesPersistence.class)
2196 protected PortalPreferencesPersistence portalPreferencesPersistence;
2197 @BeanReference(type = PortletPersistence.class)
2198 protected PortletPersistence portletPersistence;
2199 @BeanReference(type = PortletItemPersistence.class)
2200 protected PortletItemPersistence portletItemPersistence;
2201 @BeanReference(type = PortletPreferencesPersistence.class)
2202 protected PortletPreferencesPersistence portletPreferencesPersistence;
2203 @BeanReference(type = RegionPersistence.class)
2204 protected RegionPersistence regionPersistence;
2205 @BeanReference(type = ReleasePersistence.class)
2206 protected ReleasePersistence releasePersistence;
2207 @BeanReference(type = RepositoryPersistence.class)
2208 protected RepositoryPersistence repositoryPersistence;
2209 @BeanReference(type = RepositoryEntryPersistence.class)
2210 protected RepositoryEntryPersistence repositoryEntryPersistence;
2211 @BeanReference(type = ResourcePersistence.class)
2212 protected ResourcePersistence resourcePersistence;
2213 @BeanReference(type = ResourceActionPersistence.class)
2214 protected ResourceActionPersistence resourceActionPersistence;
2215 @BeanReference(type = ResourceBlockPersistence.class)
2216 protected ResourceBlockPersistence resourceBlockPersistence;
2217 @BeanReference(type = ResourceBlockPermissionPersistence.class)
2218 protected ResourceBlockPermissionPersistence resourceBlockPermissionPersistence;
2219 @BeanReference(type = ResourceCodePersistence.class)
2220 protected ResourceCodePersistence resourceCodePersistence;
2221 @BeanReference(type = ResourcePermissionPersistence.class)
2222 protected ResourcePermissionPersistence resourcePermissionPersistence;
2223 @BeanReference(type = ResourceTypePermissionPersistence.class)
2224 protected ResourceTypePermissionPersistence resourceTypePermissionPersistence;
2225 @BeanReference(type = RolePersistence.class)
2226 protected RolePersistence rolePersistence;
2227 @BeanReference(type = ServiceComponentPersistence.class)
2228 protected ServiceComponentPersistence serviceComponentPersistence;
2229 @BeanReference(type = ShardPersistence.class)
2230 protected ShardPersistence shardPersistence;
2231 @BeanReference(type = SubscriptionPersistence.class)
2232 protected SubscriptionPersistence subscriptionPersistence;
2233 @BeanReference(type = TeamPersistence.class)
2234 protected TeamPersistence teamPersistence;
2235 @BeanReference(type = TicketPersistence.class)
2236 protected TicketPersistence ticketPersistence;
2237 @BeanReference(type = UserPersistence.class)
2238 protected UserPersistence userPersistence;
2239 @BeanReference(type = UserGroupPersistence.class)
2240 protected UserGroupPersistence userGroupPersistence;
2241 @BeanReference(type = UserGroupGroupRolePersistence.class)
2242 protected UserGroupGroupRolePersistence userGroupGroupRolePersistence;
2243 @BeanReference(type = UserGroupRolePersistence.class)
2244 protected UserGroupRolePersistence userGroupRolePersistence;
2245 @BeanReference(type = UserIdMapperPersistence.class)
2246 protected UserIdMapperPersistence userIdMapperPersistence;
2247 @BeanReference(type = UserNotificationEventPersistence.class)
2248 protected UserNotificationEventPersistence userNotificationEventPersistence;
2249 @BeanReference(type = UserTrackerPersistence.class)
2250 protected UserTrackerPersistence userTrackerPersistence;
2251 @BeanReference(type = UserTrackerPathPersistence.class)
2252 protected UserTrackerPathPersistence userTrackerPathPersistence;
2253 @BeanReference(type = VirtualHostPersistence.class)
2254 protected VirtualHostPersistence virtualHostPersistence;
2255 @BeanReference(type = WebDAVPropsPersistence.class)
2256 protected WebDAVPropsPersistence webDAVPropsPersistence;
2257 @BeanReference(type = WebsitePersistence.class)
2258 protected WebsitePersistence websitePersistence;
2259 @BeanReference(type = WorkflowDefinitionLinkPersistence.class)
2260 protected WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
2261 @BeanReference(type = WorkflowInstanceLinkPersistence.class)
2262 protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
2263 private static final String _SQL_SELECT_REPOSITORYENTRY = "SELECT repositoryEntry FROM RepositoryEntry repositoryEntry";
2264 private static final String _SQL_SELECT_REPOSITORYENTRY_WHERE = "SELECT repositoryEntry FROM RepositoryEntry repositoryEntry WHERE ";
2265 private static final String _SQL_COUNT_REPOSITORYENTRY = "SELECT COUNT(repositoryEntry) FROM RepositoryEntry repositoryEntry";
2266 private static final String _SQL_COUNT_REPOSITORYENTRY_WHERE = "SELECT COUNT(repositoryEntry) FROM RepositoryEntry repositoryEntry WHERE ";
2267 private static final String _FINDER_COLUMN_UUID_UUID_1 = "repositoryEntry.uuid IS NULL";
2268 private static final String _FINDER_COLUMN_UUID_UUID_2 = "repositoryEntry.uuid = ?";
2269 private static final String _FINDER_COLUMN_UUID_UUID_3 = "(repositoryEntry.uuid IS NULL OR repositoryEntry.uuid = ?)";
2270 private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "repositoryEntry.uuid IS NULL AND ";
2271 private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "repositoryEntry.uuid = ? AND ";
2272 private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(repositoryEntry.uuid IS NULL OR repositoryEntry.uuid = ?) AND ";
2273 private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "repositoryEntry.groupId = ?";
2274 private static final String _FINDER_COLUMN_REPOSITORYID_REPOSITORYID_2 = "repositoryEntry.repositoryId = ?";
2275 private static final String _FINDER_COLUMN_R_M_REPOSITORYID_2 = "repositoryEntry.repositoryId = ? AND ";
2276 private static final String _FINDER_COLUMN_R_M_MAPPEDID_1 = "repositoryEntry.mappedId IS NULL";
2277 private static final String _FINDER_COLUMN_R_M_MAPPEDID_2 = "repositoryEntry.mappedId = ?";
2278 private static final String _FINDER_COLUMN_R_M_MAPPEDID_3 = "(repositoryEntry.mappedId IS NULL OR repositoryEntry.mappedId = ?)";
2279 private static final String _ORDER_BY_ENTITY_ALIAS = "repositoryEntry.";
2280 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No RepositoryEntry exists with the primary key ";
2281 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No RepositoryEntry exists with the key {";
2282 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
2283 private static Log _log = LogFactoryUtil.getLog(RepositoryEntryPersistenceImpl.class);
2284 private static RepositoryEntry _nullRepositoryEntry = new RepositoryEntryImpl() {
2285 @Override
2286 public Object clone() {
2287 return this;
2288 }
2289
2290 @Override
2291 public CacheModel<RepositoryEntry> toCacheModel() {
2292 return _nullRepositoryEntryCacheModel;
2293 }
2294 };
2295
2296 private static CacheModel<RepositoryEntry> _nullRepositoryEntryCacheModel = new CacheModel<RepositoryEntry>() {
2297 public RepositoryEntry toEntityModel() {
2298 return _nullRepositoryEntry;
2299 }
2300 };
2301 }