001
014
015 package com.liferay.portal.service.persistence;
016
017 import com.liferay.portal.NoSuchModelException;
018 import com.liferay.portal.NoSuchWorkflowInstanceLinkException;
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.model.CacheModel;
038 import com.liferay.portal.model.ModelListener;
039 import com.liferay.portal.model.WorkflowInstanceLink;
040 import com.liferay.portal.model.impl.WorkflowInstanceLinkImpl;
041 import com.liferay.portal.model.impl.WorkflowInstanceLinkModelImpl;
042 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
043
044 import java.io.Serializable;
045
046 import java.util.ArrayList;
047 import java.util.Collections;
048 import java.util.List;
049
050
062 public class WorkflowInstanceLinkPersistenceImpl extends BasePersistenceImpl<WorkflowInstanceLink>
063 implements WorkflowInstanceLinkPersistence {
064
069 public static final String FINDER_CLASS_NAME_ENTITY = WorkflowInstanceLinkImpl.class.getName();
070 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
071 ".List1";
072 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
073 ".List2";
074 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_C_C = new FinderPath(WorkflowInstanceLinkModelImpl.ENTITY_CACHE_ENABLED,
075 WorkflowInstanceLinkModelImpl.FINDER_CACHE_ENABLED,
076 WorkflowInstanceLinkImpl.class,
077 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_C_C_C",
078 new String[] {
079 Long.class.getName(), Long.class.getName(), Long.class.getName(),
080 Long.class.getName(),
081
082 "java.lang.Integer", "java.lang.Integer",
083 "com.liferay.portal.kernel.util.OrderByComparator"
084 });
085 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C_C =
086 new FinderPath(WorkflowInstanceLinkModelImpl.ENTITY_CACHE_ENABLED,
087 WorkflowInstanceLinkModelImpl.FINDER_CACHE_ENABLED,
088 WorkflowInstanceLinkImpl.class,
089 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_C_C_C",
090 new String[] {
091 Long.class.getName(), Long.class.getName(), Long.class.getName(),
092 Long.class.getName()
093 },
094 WorkflowInstanceLinkModelImpl.GROUPID_COLUMN_BITMASK |
095 WorkflowInstanceLinkModelImpl.COMPANYID_COLUMN_BITMASK |
096 WorkflowInstanceLinkModelImpl.CLASSNAMEID_COLUMN_BITMASK |
097 WorkflowInstanceLinkModelImpl.CLASSPK_COLUMN_BITMASK);
098 public static final FinderPath FINDER_PATH_COUNT_BY_G_C_C_C = new FinderPath(WorkflowInstanceLinkModelImpl.ENTITY_CACHE_ENABLED,
099 WorkflowInstanceLinkModelImpl.FINDER_CACHE_ENABLED, Long.class,
100 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_C_C_C",
101 new String[] {
102 Long.class.getName(), Long.class.getName(), Long.class.getName(),
103 Long.class.getName()
104 });
105 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(WorkflowInstanceLinkModelImpl.ENTITY_CACHE_ENABLED,
106 WorkflowInstanceLinkModelImpl.FINDER_CACHE_ENABLED,
107 WorkflowInstanceLinkImpl.class,
108 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
109 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(WorkflowInstanceLinkModelImpl.ENTITY_CACHE_ENABLED,
110 WorkflowInstanceLinkModelImpl.FINDER_CACHE_ENABLED,
111 WorkflowInstanceLinkImpl.class,
112 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
113 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(WorkflowInstanceLinkModelImpl.ENTITY_CACHE_ENABLED,
114 WorkflowInstanceLinkModelImpl.FINDER_CACHE_ENABLED, Long.class,
115 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
116
117
122 public void cacheResult(WorkflowInstanceLink workflowInstanceLink) {
123 EntityCacheUtil.putResult(WorkflowInstanceLinkModelImpl.ENTITY_CACHE_ENABLED,
124 WorkflowInstanceLinkImpl.class,
125 workflowInstanceLink.getPrimaryKey(), workflowInstanceLink);
126
127 workflowInstanceLink.resetOriginalValues();
128 }
129
130
135 public void cacheResult(List<WorkflowInstanceLink> workflowInstanceLinks) {
136 for (WorkflowInstanceLink workflowInstanceLink : workflowInstanceLinks) {
137 if (EntityCacheUtil.getResult(
138 WorkflowInstanceLinkModelImpl.ENTITY_CACHE_ENABLED,
139 WorkflowInstanceLinkImpl.class,
140 workflowInstanceLink.getPrimaryKey()) == null) {
141 cacheResult(workflowInstanceLink);
142 }
143 else {
144 workflowInstanceLink.resetOriginalValues();
145 }
146 }
147 }
148
149
156 @Override
157 public void clearCache() {
158 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
159 CacheRegistryUtil.clear(WorkflowInstanceLinkImpl.class.getName());
160 }
161
162 EntityCacheUtil.clearCache(WorkflowInstanceLinkImpl.class.getName());
163
164 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
165 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
166 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
167 }
168
169
176 @Override
177 public void clearCache(WorkflowInstanceLink workflowInstanceLink) {
178 EntityCacheUtil.removeResult(WorkflowInstanceLinkModelImpl.ENTITY_CACHE_ENABLED,
179 WorkflowInstanceLinkImpl.class, workflowInstanceLink.getPrimaryKey());
180
181 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
182 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
183 }
184
185 @Override
186 public void clearCache(List<WorkflowInstanceLink> workflowInstanceLinks) {
187 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
188 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
189
190 for (WorkflowInstanceLink workflowInstanceLink : workflowInstanceLinks) {
191 EntityCacheUtil.removeResult(WorkflowInstanceLinkModelImpl.ENTITY_CACHE_ENABLED,
192 WorkflowInstanceLinkImpl.class,
193 workflowInstanceLink.getPrimaryKey());
194 }
195 }
196
197
203 public WorkflowInstanceLink create(long workflowInstanceLinkId) {
204 WorkflowInstanceLink workflowInstanceLink = new WorkflowInstanceLinkImpl();
205
206 workflowInstanceLink.setNew(true);
207 workflowInstanceLink.setPrimaryKey(workflowInstanceLinkId);
208
209 return workflowInstanceLink;
210 }
211
212
220 public WorkflowInstanceLink remove(long workflowInstanceLinkId)
221 throws NoSuchWorkflowInstanceLinkException, SystemException {
222 return remove(Long.valueOf(workflowInstanceLinkId));
223 }
224
225
233 @Override
234 public WorkflowInstanceLink remove(Serializable primaryKey)
235 throws NoSuchWorkflowInstanceLinkException, SystemException {
236 Session session = null;
237
238 try {
239 session = openSession();
240
241 WorkflowInstanceLink workflowInstanceLink = (WorkflowInstanceLink)session.get(WorkflowInstanceLinkImpl.class,
242 primaryKey);
243
244 if (workflowInstanceLink == null) {
245 if (_log.isWarnEnabled()) {
246 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
247 }
248
249 throw new NoSuchWorkflowInstanceLinkException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
250 primaryKey);
251 }
252
253 return remove(workflowInstanceLink);
254 }
255 catch (NoSuchWorkflowInstanceLinkException nsee) {
256 throw nsee;
257 }
258 catch (Exception e) {
259 throw processException(e);
260 }
261 finally {
262 closeSession(session);
263 }
264 }
265
266 @Override
267 protected WorkflowInstanceLink removeImpl(
268 WorkflowInstanceLink workflowInstanceLink) throws SystemException {
269 workflowInstanceLink = toUnwrappedModel(workflowInstanceLink);
270
271 Session session = null;
272
273 try {
274 session = openSession();
275
276 if (workflowInstanceLink.isCachedModel()) {
277 workflowInstanceLink = (WorkflowInstanceLink)session.get(WorkflowInstanceLinkImpl.class,
278 workflowInstanceLink.getPrimaryKeyObj());
279 }
280
281 session.delete(workflowInstanceLink);
282 }
283 catch (Exception e) {
284 throw processException(e);
285 }
286 finally {
287 closeSession(session);
288 }
289
290 clearCache(workflowInstanceLink);
291
292 return workflowInstanceLink;
293 }
294
295 @Override
296 public WorkflowInstanceLink updateImpl(
297 com.liferay.portal.model.WorkflowInstanceLink workflowInstanceLink)
298 throws SystemException {
299 workflowInstanceLink = toUnwrappedModel(workflowInstanceLink);
300
301 boolean isNew = workflowInstanceLink.isNew();
302
303 WorkflowInstanceLinkModelImpl workflowInstanceLinkModelImpl = (WorkflowInstanceLinkModelImpl)workflowInstanceLink;
304
305 Session session = null;
306
307 try {
308 session = openSession();
309
310 if (workflowInstanceLink.isNew()) {
311 session.save(workflowInstanceLink);
312
313 workflowInstanceLink.setNew(false);
314 }
315 else {
316 session.merge(workflowInstanceLink);
317 }
318 }
319 catch (Exception e) {
320 throw processException(e);
321 }
322 finally {
323 closeSession(session);
324 }
325
326 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
327
328 if (isNew || !WorkflowInstanceLinkModelImpl.COLUMN_BITMASK_ENABLED) {
329 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
330 }
331
332 else {
333 if ((workflowInstanceLinkModelImpl.getColumnBitmask() &
334 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C_C.getColumnBitmask()) != 0) {
335 Object[] args = new Object[] {
336 Long.valueOf(workflowInstanceLinkModelImpl.getOriginalGroupId()),
337 Long.valueOf(workflowInstanceLinkModelImpl.getOriginalCompanyId()),
338 Long.valueOf(workflowInstanceLinkModelImpl.getOriginalClassNameId()),
339 Long.valueOf(workflowInstanceLinkModelImpl.getOriginalClassPK())
340 };
341
342 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_C_C, args);
343 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C_C,
344 args);
345
346 args = new Object[] {
347 Long.valueOf(workflowInstanceLinkModelImpl.getGroupId()),
348 Long.valueOf(workflowInstanceLinkModelImpl.getCompanyId()),
349 Long.valueOf(workflowInstanceLinkModelImpl.getClassNameId()),
350 Long.valueOf(workflowInstanceLinkModelImpl.getClassPK())
351 };
352
353 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_C_C, args);
354 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C_C,
355 args);
356 }
357 }
358
359 EntityCacheUtil.putResult(WorkflowInstanceLinkModelImpl.ENTITY_CACHE_ENABLED,
360 WorkflowInstanceLinkImpl.class,
361 workflowInstanceLink.getPrimaryKey(), workflowInstanceLink);
362
363 return workflowInstanceLink;
364 }
365
366 protected WorkflowInstanceLink toUnwrappedModel(
367 WorkflowInstanceLink workflowInstanceLink) {
368 if (workflowInstanceLink instanceof WorkflowInstanceLinkImpl) {
369 return workflowInstanceLink;
370 }
371
372 WorkflowInstanceLinkImpl workflowInstanceLinkImpl = new WorkflowInstanceLinkImpl();
373
374 workflowInstanceLinkImpl.setNew(workflowInstanceLink.isNew());
375 workflowInstanceLinkImpl.setPrimaryKey(workflowInstanceLink.getPrimaryKey());
376
377 workflowInstanceLinkImpl.setWorkflowInstanceLinkId(workflowInstanceLink.getWorkflowInstanceLinkId());
378 workflowInstanceLinkImpl.setGroupId(workflowInstanceLink.getGroupId());
379 workflowInstanceLinkImpl.setCompanyId(workflowInstanceLink.getCompanyId());
380 workflowInstanceLinkImpl.setUserId(workflowInstanceLink.getUserId());
381 workflowInstanceLinkImpl.setUserName(workflowInstanceLink.getUserName());
382 workflowInstanceLinkImpl.setCreateDate(workflowInstanceLink.getCreateDate());
383 workflowInstanceLinkImpl.setModifiedDate(workflowInstanceLink.getModifiedDate());
384 workflowInstanceLinkImpl.setClassNameId(workflowInstanceLink.getClassNameId());
385 workflowInstanceLinkImpl.setClassPK(workflowInstanceLink.getClassPK());
386 workflowInstanceLinkImpl.setWorkflowInstanceId(workflowInstanceLink.getWorkflowInstanceId());
387
388 return workflowInstanceLinkImpl;
389 }
390
391
399 @Override
400 public WorkflowInstanceLink findByPrimaryKey(Serializable primaryKey)
401 throws NoSuchModelException, SystemException {
402 return findByPrimaryKey(((Long)primaryKey).longValue());
403 }
404
405
413 public WorkflowInstanceLink findByPrimaryKey(long workflowInstanceLinkId)
414 throws NoSuchWorkflowInstanceLinkException, SystemException {
415 WorkflowInstanceLink workflowInstanceLink = fetchByPrimaryKey(workflowInstanceLinkId);
416
417 if (workflowInstanceLink == null) {
418 if (_log.isWarnEnabled()) {
419 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
420 workflowInstanceLinkId);
421 }
422
423 throw new NoSuchWorkflowInstanceLinkException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
424 workflowInstanceLinkId);
425 }
426
427 return workflowInstanceLink;
428 }
429
430
437 @Override
438 public WorkflowInstanceLink fetchByPrimaryKey(Serializable primaryKey)
439 throws SystemException {
440 return fetchByPrimaryKey(((Long)primaryKey).longValue());
441 }
442
443
450 public WorkflowInstanceLink fetchByPrimaryKey(long workflowInstanceLinkId)
451 throws SystemException {
452 WorkflowInstanceLink workflowInstanceLink = (WorkflowInstanceLink)EntityCacheUtil.getResult(WorkflowInstanceLinkModelImpl.ENTITY_CACHE_ENABLED,
453 WorkflowInstanceLinkImpl.class, workflowInstanceLinkId);
454
455 if (workflowInstanceLink == _nullWorkflowInstanceLink) {
456 return null;
457 }
458
459 if (workflowInstanceLink == null) {
460 Session session = null;
461
462 boolean hasException = false;
463
464 try {
465 session = openSession();
466
467 workflowInstanceLink = (WorkflowInstanceLink)session.get(WorkflowInstanceLinkImpl.class,
468 Long.valueOf(workflowInstanceLinkId));
469 }
470 catch (Exception e) {
471 hasException = true;
472
473 throw processException(e);
474 }
475 finally {
476 if (workflowInstanceLink != null) {
477 cacheResult(workflowInstanceLink);
478 }
479 else if (!hasException) {
480 EntityCacheUtil.putResult(WorkflowInstanceLinkModelImpl.ENTITY_CACHE_ENABLED,
481 WorkflowInstanceLinkImpl.class, workflowInstanceLinkId,
482 _nullWorkflowInstanceLink);
483 }
484
485 closeSession(session);
486 }
487 }
488
489 return workflowInstanceLink;
490 }
491
492
502 public List<WorkflowInstanceLink> findByG_C_C_C(long groupId,
503 long companyId, long classNameId, long classPK)
504 throws SystemException {
505 return findByG_C_C_C(groupId, companyId, classNameId, classPK,
506 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
507 }
508
509
525 public List<WorkflowInstanceLink> findByG_C_C_C(long groupId,
526 long companyId, long classNameId, long classPK, int start, int end)
527 throws SystemException {
528 return findByG_C_C_C(groupId, companyId, classNameId, classPK, start,
529 end, null);
530 }
531
532
549 public List<WorkflowInstanceLink> findByG_C_C_C(long groupId,
550 long companyId, long classNameId, long classPK, int start, int end,
551 OrderByComparator orderByComparator) throws SystemException {
552 FinderPath finderPath = null;
553 Object[] finderArgs = null;
554
555 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
556 (orderByComparator == null)) {
557 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C_C;
558 finderArgs = new Object[] { groupId, companyId, classNameId, classPK };
559 }
560 else {
561 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_C_C;
562 finderArgs = new Object[] {
563 groupId, companyId, classNameId, classPK,
564
565 start, end, orderByComparator
566 };
567 }
568
569 List<WorkflowInstanceLink> list = (List<WorkflowInstanceLink>)FinderCacheUtil.getResult(finderPath,
570 finderArgs, this);
571
572 if ((list != null) && !list.isEmpty()) {
573 for (WorkflowInstanceLink workflowInstanceLink : list) {
574 if ((groupId != workflowInstanceLink.getGroupId()) ||
575 (companyId != workflowInstanceLink.getCompanyId()) ||
576 (classNameId != workflowInstanceLink.getClassNameId()) ||
577 (classPK != workflowInstanceLink.getClassPK())) {
578 list = null;
579
580 break;
581 }
582 }
583 }
584
585 if (list == null) {
586 StringBundler query = null;
587
588 if (orderByComparator != null) {
589 query = new StringBundler(6 +
590 (orderByComparator.getOrderByFields().length * 3));
591 }
592 else {
593 query = new StringBundler(6);
594 }
595
596 query.append(_SQL_SELECT_WORKFLOWINSTANCELINK_WHERE);
597
598 query.append(_FINDER_COLUMN_G_C_C_C_GROUPID_2);
599
600 query.append(_FINDER_COLUMN_G_C_C_C_COMPANYID_2);
601
602 query.append(_FINDER_COLUMN_G_C_C_C_CLASSNAMEID_2);
603
604 query.append(_FINDER_COLUMN_G_C_C_C_CLASSPK_2);
605
606 if (orderByComparator != null) {
607 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
608 orderByComparator);
609 }
610
611 else {
612 query.append(WorkflowInstanceLinkModelImpl.ORDER_BY_JPQL);
613 }
614
615 String sql = query.toString();
616
617 Session session = null;
618
619 try {
620 session = openSession();
621
622 Query q = session.createQuery(sql);
623
624 QueryPos qPos = QueryPos.getInstance(q);
625
626 qPos.add(groupId);
627
628 qPos.add(companyId);
629
630 qPos.add(classNameId);
631
632 qPos.add(classPK);
633
634 list = (List<WorkflowInstanceLink>)QueryUtil.list(q,
635 getDialect(), start, end);
636 }
637 catch (Exception e) {
638 throw processException(e);
639 }
640 finally {
641 if (list == null) {
642 FinderCacheUtil.removeResult(finderPath, finderArgs);
643 }
644 else {
645 cacheResult(list);
646
647 FinderCacheUtil.putResult(finderPath, finderArgs, list);
648 }
649
650 closeSession(session);
651 }
652 }
653
654 return list;
655 }
656
657
669 public WorkflowInstanceLink findByG_C_C_C_First(long groupId,
670 long companyId, long classNameId, long classPK,
671 OrderByComparator orderByComparator)
672 throws NoSuchWorkflowInstanceLinkException, SystemException {
673 WorkflowInstanceLink workflowInstanceLink = fetchByG_C_C_C_First(groupId,
674 companyId, classNameId, classPK, orderByComparator);
675
676 if (workflowInstanceLink != null) {
677 return workflowInstanceLink;
678 }
679
680 StringBundler msg = new StringBundler(10);
681
682 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
683
684 msg.append("groupId=");
685 msg.append(groupId);
686
687 msg.append(", companyId=");
688 msg.append(companyId);
689
690 msg.append(", classNameId=");
691 msg.append(classNameId);
692
693 msg.append(", classPK=");
694 msg.append(classPK);
695
696 msg.append(StringPool.CLOSE_CURLY_BRACE);
697
698 throw new NoSuchWorkflowInstanceLinkException(msg.toString());
699 }
700
701
712 public WorkflowInstanceLink fetchByG_C_C_C_First(long groupId,
713 long companyId, long classNameId, long classPK,
714 OrderByComparator orderByComparator) throws SystemException {
715 List<WorkflowInstanceLink> list = findByG_C_C_C(groupId, companyId,
716 classNameId, classPK, 0, 1, orderByComparator);
717
718 if (!list.isEmpty()) {
719 return list.get(0);
720 }
721
722 return null;
723 }
724
725
737 public WorkflowInstanceLink findByG_C_C_C_Last(long groupId,
738 long companyId, long classNameId, long classPK,
739 OrderByComparator orderByComparator)
740 throws NoSuchWorkflowInstanceLinkException, SystemException {
741 WorkflowInstanceLink workflowInstanceLink = fetchByG_C_C_C_Last(groupId,
742 companyId, classNameId, classPK, orderByComparator);
743
744 if (workflowInstanceLink != null) {
745 return workflowInstanceLink;
746 }
747
748 StringBundler msg = new StringBundler(10);
749
750 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
751
752 msg.append("groupId=");
753 msg.append(groupId);
754
755 msg.append(", companyId=");
756 msg.append(companyId);
757
758 msg.append(", classNameId=");
759 msg.append(classNameId);
760
761 msg.append(", classPK=");
762 msg.append(classPK);
763
764 msg.append(StringPool.CLOSE_CURLY_BRACE);
765
766 throw new NoSuchWorkflowInstanceLinkException(msg.toString());
767 }
768
769
780 public WorkflowInstanceLink fetchByG_C_C_C_Last(long groupId,
781 long companyId, long classNameId, long classPK,
782 OrderByComparator orderByComparator) throws SystemException {
783 int count = countByG_C_C_C(groupId, companyId, classNameId, classPK);
784
785 List<WorkflowInstanceLink> list = findByG_C_C_C(groupId, companyId,
786 classNameId, classPK, count - 1, count, orderByComparator);
787
788 if (!list.isEmpty()) {
789 return list.get(0);
790 }
791
792 return null;
793 }
794
795
808 public WorkflowInstanceLink[] findByG_C_C_C_PrevAndNext(
809 long workflowInstanceLinkId, long groupId, long companyId,
810 long classNameId, long classPK, OrderByComparator orderByComparator)
811 throws NoSuchWorkflowInstanceLinkException, SystemException {
812 WorkflowInstanceLink workflowInstanceLink = findByPrimaryKey(workflowInstanceLinkId);
813
814 Session session = null;
815
816 try {
817 session = openSession();
818
819 WorkflowInstanceLink[] array = new WorkflowInstanceLinkImpl[3];
820
821 array[0] = getByG_C_C_C_PrevAndNext(session, workflowInstanceLink,
822 groupId, companyId, classNameId, classPK,
823 orderByComparator, true);
824
825 array[1] = workflowInstanceLink;
826
827 array[2] = getByG_C_C_C_PrevAndNext(session, workflowInstanceLink,
828 groupId, companyId, classNameId, classPK,
829 orderByComparator, false);
830
831 return array;
832 }
833 catch (Exception e) {
834 throw processException(e);
835 }
836 finally {
837 closeSession(session);
838 }
839 }
840
841 protected WorkflowInstanceLink getByG_C_C_C_PrevAndNext(Session session,
842 WorkflowInstanceLink workflowInstanceLink, long groupId,
843 long companyId, long classNameId, long classPK,
844 OrderByComparator orderByComparator, boolean previous) {
845 StringBundler query = null;
846
847 if (orderByComparator != null) {
848 query = new StringBundler(6 +
849 (orderByComparator.getOrderByFields().length * 6));
850 }
851 else {
852 query = new StringBundler(3);
853 }
854
855 query.append(_SQL_SELECT_WORKFLOWINSTANCELINK_WHERE);
856
857 query.append(_FINDER_COLUMN_G_C_C_C_GROUPID_2);
858
859 query.append(_FINDER_COLUMN_G_C_C_C_COMPANYID_2);
860
861 query.append(_FINDER_COLUMN_G_C_C_C_CLASSNAMEID_2);
862
863 query.append(_FINDER_COLUMN_G_C_C_C_CLASSPK_2);
864
865 if (orderByComparator != null) {
866 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
867
868 if (orderByConditionFields.length > 0) {
869 query.append(WHERE_AND);
870 }
871
872 for (int i = 0; i < orderByConditionFields.length; i++) {
873 query.append(_ORDER_BY_ENTITY_ALIAS);
874 query.append(orderByConditionFields[i]);
875
876 if ((i + 1) < orderByConditionFields.length) {
877 if (orderByComparator.isAscending() ^ previous) {
878 query.append(WHERE_GREATER_THAN_HAS_NEXT);
879 }
880 else {
881 query.append(WHERE_LESSER_THAN_HAS_NEXT);
882 }
883 }
884 else {
885 if (orderByComparator.isAscending() ^ previous) {
886 query.append(WHERE_GREATER_THAN);
887 }
888 else {
889 query.append(WHERE_LESSER_THAN);
890 }
891 }
892 }
893
894 query.append(ORDER_BY_CLAUSE);
895
896 String[] orderByFields = orderByComparator.getOrderByFields();
897
898 for (int i = 0; i < orderByFields.length; i++) {
899 query.append(_ORDER_BY_ENTITY_ALIAS);
900 query.append(orderByFields[i]);
901
902 if ((i + 1) < orderByFields.length) {
903 if (orderByComparator.isAscending() ^ previous) {
904 query.append(ORDER_BY_ASC_HAS_NEXT);
905 }
906 else {
907 query.append(ORDER_BY_DESC_HAS_NEXT);
908 }
909 }
910 else {
911 if (orderByComparator.isAscending() ^ previous) {
912 query.append(ORDER_BY_ASC);
913 }
914 else {
915 query.append(ORDER_BY_DESC);
916 }
917 }
918 }
919 }
920
921 else {
922 query.append(WorkflowInstanceLinkModelImpl.ORDER_BY_JPQL);
923 }
924
925 String sql = query.toString();
926
927 Query q = session.createQuery(sql);
928
929 q.setFirstResult(0);
930 q.setMaxResults(2);
931
932 QueryPos qPos = QueryPos.getInstance(q);
933
934 qPos.add(groupId);
935
936 qPos.add(companyId);
937
938 qPos.add(classNameId);
939
940 qPos.add(classPK);
941
942 if (orderByComparator != null) {
943 Object[] values = orderByComparator.getOrderByConditionValues(workflowInstanceLink);
944
945 for (Object value : values) {
946 qPos.add(value);
947 }
948 }
949
950 List<WorkflowInstanceLink> list = q.list();
951
952 if (list.size() == 2) {
953 return list.get(1);
954 }
955 else {
956 return null;
957 }
958 }
959
960
966 public List<WorkflowInstanceLink> findAll() throws SystemException {
967 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
968 }
969
970
982 public List<WorkflowInstanceLink> findAll(int start, int end)
983 throws SystemException {
984 return findAll(start, end, null);
985 }
986
987
1000 public List<WorkflowInstanceLink> findAll(int start, int end,
1001 OrderByComparator orderByComparator) throws SystemException {
1002 FinderPath finderPath = null;
1003 Object[] finderArgs = new Object[] { start, end, orderByComparator };
1004
1005 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1006 (orderByComparator == null)) {
1007 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
1008 finderArgs = FINDER_ARGS_EMPTY;
1009 }
1010 else {
1011 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
1012 finderArgs = new Object[] { start, end, orderByComparator };
1013 }
1014
1015 List<WorkflowInstanceLink> list = (List<WorkflowInstanceLink>)FinderCacheUtil.getResult(finderPath,
1016 finderArgs, this);
1017
1018 if (list == null) {
1019 StringBundler query = null;
1020 String sql = null;
1021
1022 if (orderByComparator != null) {
1023 query = new StringBundler(2 +
1024 (orderByComparator.getOrderByFields().length * 3));
1025
1026 query.append(_SQL_SELECT_WORKFLOWINSTANCELINK);
1027
1028 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1029 orderByComparator);
1030
1031 sql = query.toString();
1032 }
1033 else {
1034 sql = _SQL_SELECT_WORKFLOWINSTANCELINK.concat(WorkflowInstanceLinkModelImpl.ORDER_BY_JPQL);
1035 }
1036
1037 Session session = null;
1038
1039 try {
1040 session = openSession();
1041
1042 Query q = session.createQuery(sql);
1043
1044 if (orderByComparator == null) {
1045 list = (List<WorkflowInstanceLink>)QueryUtil.list(q,
1046 getDialect(), start, end, false);
1047
1048 Collections.sort(list);
1049 }
1050 else {
1051 list = (List<WorkflowInstanceLink>)QueryUtil.list(q,
1052 getDialect(), start, end);
1053 }
1054 }
1055 catch (Exception e) {
1056 throw processException(e);
1057 }
1058 finally {
1059 if (list == null) {
1060 FinderCacheUtil.removeResult(finderPath, finderArgs);
1061 }
1062 else {
1063 cacheResult(list);
1064
1065 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1066 }
1067
1068 closeSession(session);
1069 }
1070 }
1071
1072 return list;
1073 }
1074
1075
1084 public void removeByG_C_C_C(long groupId, long companyId, long classNameId,
1085 long classPK) throws SystemException {
1086 for (WorkflowInstanceLink workflowInstanceLink : findByG_C_C_C(
1087 groupId, companyId, classNameId, classPK)) {
1088 remove(workflowInstanceLink);
1089 }
1090 }
1091
1092
1097 public void removeAll() throws SystemException {
1098 for (WorkflowInstanceLink workflowInstanceLink : findAll()) {
1099 remove(workflowInstanceLink);
1100 }
1101 }
1102
1103
1113 public int countByG_C_C_C(long groupId, long companyId, long classNameId,
1114 long classPK) throws SystemException {
1115 Object[] finderArgs = new Object[] {
1116 groupId, companyId, classNameId, classPK
1117 };
1118
1119 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_C_C_C,
1120 finderArgs, this);
1121
1122 if (count == null) {
1123 StringBundler query = new StringBundler(5);
1124
1125 query.append(_SQL_COUNT_WORKFLOWINSTANCELINK_WHERE);
1126
1127 query.append(_FINDER_COLUMN_G_C_C_C_GROUPID_2);
1128
1129 query.append(_FINDER_COLUMN_G_C_C_C_COMPANYID_2);
1130
1131 query.append(_FINDER_COLUMN_G_C_C_C_CLASSNAMEID_2);
1132
1133 query.append(_FINDER_COLUMN_G_C_C_C_CLASSPK_2);
1134
1135 String sql = query.toString();
1136
1137 Session session = null;
1138
1139 try {
1140 session = openSession();
1141
1142 Query q = session.createQuery(sql);
1143
1144 QueryPos qPos = QueryPos.getInstance(q);
1145
1146 qPos.add(groupId);
1147
1148 qPos.add(companyId);
1149
1150 qPos.add(classNameId);
1151
1152 qPos.add(classPK);
1153
1154 count = (Long)q.uniqueResult();
1155 }
1156 catch (Exception e) {
1157 throw processException(e);
1158 }
1159 finally {
1160 if (count == null) {
1161 count = Long.valueOf(0);
1162 }
1163
1164 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_C_C_C,
1165 finderArgs, count);
1166
1167 closeSession(session);
1168 }
1169 }
1170
1171 return count.intValue();
1172 }
1173
1174
1180 public int countAll() throws SystemException {
1181 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1182 FINDER_ARGS_EMPTY, this);
1183
1184 if (count == null) {
1185 Session session = null;
1186
1187 try {
1188 session = openSession();
1189
1190 Query q = session.createQuery(_SQL_COUNT_WORKFLOWINSTANCELINK);
1191
1192 count = (Long)q.uniqueResult();
1193 }
1194 catch (Exception e) {
1195 throw processException(e);
1196 }
1197 finally {
1198 if (count == null) {
1199 count = Long.valueOf(0);
1200 }
1201
1202 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
1203 FINDER_ARGS_EMPTY, count);
1204
1205 closeSession(session);
1206 }
1207 }
1208
1209 return count.intValue();
1210 }
1211
1212
1215 public void afterPropertiesSet() {
1216 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1217 com.liferay.portal.util.PropsUtil.get(
1218 "value.object.listener.com.liferay.portal.model.WorkflowInstanceLink")));
1219
1220 if (listenerClassNames.length > 0) {
1221 try {
1222 List<ModelListener<WorkflowInstanceLink>> listenersList = new ArrayList<ModelListener<WorkflowInstanceLink>>();
1223
1224 for (String listenerClassName : listenerClassNames) {
1225 listenersList.add((ModelListener<WorkflowInstanceLink>)InstanceFactory.newInstance(
1226 listenerClassName));
1227 }
1228
1229 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1230 }
1231 catch (Exception e) {
1232 _log.error(e);
1233 }
1234 }
1235 }
1236
1237 public void destroy() {
1238 EntityCacheUtil.removeCache(WorkflowInstanceLinkImpl.class.getName());
1239 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
1240 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1241 }
1242
1243 @BeanReference(type = AccountPersistence.class)
1244 protected AccountPersistence accountPersistence;
1245 @BeanReference(type = AddressPersistence.class)
1246 protected AddressPersistence addressPersistence;
1247 @BeanReference(type = BrowserTrackerPersistence.class)
1248 protected BrowserTrackerPersistence browserTrackerPersistence;
1249 @BeanReference(type = ClassNamePersistence.class)
1250 protected ClassNamePersistence classNamePersistence;
1251 @BeanReference(type = ClusterGroupPersistence.class)
1252 protected ClusterGroupPersistence clusterGroupPersistence;
1253 @BeanReference(type = CompanyPersistence.class)
1254 protected CompanyPersistence companyPersistence;
1255 @BeanReference(type = ContactPersistence.class)
1256 protected ContactPersistence contactPersistence;
1257 @BeanReference(type = CountryPersistence.class)
1258 protected CountryPersistence countryPersistence;
1259 @BeanReference(type = EmailAddressPersistence.class)
1260 protected EmailAddressPersistence emailAddressPersistence;
1261 @BeanReference(type = GroupPersistence.class)
1262 protected GroupPersistence groupPersistence;
1263 @BeanReference(type = ImagePersistence.class)
1264 protected ImagePersistence imagePersistence;
1265 @BeanReference(type = LayoutPersistence.class)
1266 protected LayoutPersistence layoutPersistence;
1267 @BeanReference(type = LayoutBranchPersistence.class)
1268 protected LayoutBranchPersistence layoutBranchPersistence;
1269 @BeanReference(type = LayoutPrototypePersistence.class)
1270 protected LayoutPrototypePersistence layoutPrototypePersistence;
1271 @BeanReference(type = LayoutRevisionPersistence.class)
1272 protected LayoutRevisionPersistence layoutRevisionPersistence;
1273 @BeanReference(type = LayoutSetPersistence.class)
1274 protected LayoutSetPersistence layoutSetPersistence;
1275 @BeanReference(type = LayoutSetBranchPersistence.class)
1276 protected LayoutSetBranchPersistence layoutSetBranchPersistence;
1277 @BeanReference(type = LayoutSetPrototypePersistence.class)
1278 protected LayoutSetPrototypePersistence layoutSetPrototypePersistence;
1279 @BeanReference(type = ListTypePersistence.class)
1280 protected ListTypePersistence listTypePersistence;
1281 @BeanReference(type = LockPersistence.class)
1282 protected LockPersistence lockPersistence;
1283 @BeanReference(type = MembershipRequestPersistence.class)
1284 protected MembershipRequestPersistence membershipRequestPersistence;
1285 @BeanReference(type = OrganizationPersistence.class)
1286 protected OrganizationPersistence organizationPersistence;
1287 @BeanReference(type = OrgGroupRolePersistence.class)
1288 protected OrgGroupRolePersistence orgGroupRolePersistence;
1289 @BeanReference(type = OrgLaborPersistence.class)
1290 protected OrgLaborPersistence orgLaborPersistence;
1291 @BeanReference(type = PasswordPolicyPersistence.class)
1292 protected PasswordPolicyPersistence passwordPolicyPersistence;
1293 @BeanReference(type = PasswordPolicyRelPersistence.class)
1294 protected PasswordPolicyRelPersistence passwordPolicyRelPersistence;
1295 @BeanReference(type = PasswordTrackerPersistence.class)
1296 protected PasswordTrackerPersistence passwordTrackerPersistence;
1297 @BeanReference(type = PhonePersistence.class)
1298 protected PhonePersistence phonePersistence;
1299 @BeanReference(type = PluginSettingPersistence.class)
1300 protected PluginSettingPersistence pluginSettingPersistence;
1301 @BeanReference(type = PortalPreferencesPersistence.class)
1302 protected PortalPreferencesPersistence portalPreferencesPersistence;
1303 @BeanReference(type = PortletPersistence.class)
1304 protected PortletPersistence portletPersistence;
1305 @BeanReference(type = PortletItemPersistence.class)
1306 protected PortletItemPersistence portletItemPersistence;
1307 @BeanReference(type = PortletPreferencesPersistence.class)
1308 protected PortletPreferencesPersistence portletPreferencesPersistence;
1309 @BeanReference(type = RegionPersistence.class)
1310 protected RegionPersistence regionPersistence;
1311 @BeanReference(type = ReleasePersistence.class)
1312 protected ReleasePersistence releasePersistence;
1313 @BeanReference(type = RepositoryPersistence.class)
1314 protected RepositoryPersistence repositoryPersistence;
1315 @BeanReference(type = RepositoryEntryPersistence.class)
1316 protected RepositoryEntryPersistence repositoryEntryPersistence;
1317 @BeanReference(type = ResourceActionPersistence.class)
1318 protected ResourceActionPersistence resourceActionPersistence;
1319 @BeanReference(type = ResourceBlockPersistence.class)
1320 protected ResourceBlockPersistence resourceBlockPersistence;
1321 @BeanReference(type = ResourceBlockPermissionPersistence.class)
1322 protected ResourceBlockPermissionPersistence resourceBlockPermissionPersistence;
1323 @BeanReference(type = ResourcePermissionPersistence.class)
1324 protected ResourcePermissionPersistence resourcePermissionPersistence;
1325 @BeanReference(type = ResourceTypePermissionPersistence.class)
1326 protected ResourceTypePermissionPersistence resourceTypePermissionPersistence;
1327 @BeanReference(type = RolePersistence.class)
1328 protected RolePersistence rolePersistence;
1329 @BeanReference(type = ServiceComponentPersistence.class)
1330 protected ServiceComponentPersistence serviceComponentPersistence;
1331 @BeanReference(type = ShardPersistence.class)
1332 protected ShardPersistence shardPersistence;
1333 @BeanReference(type = SubscriptionPersistence.class)
1334 protected SubscriptionPersistence subscriptionPersistence;
1335 @BeanReference(type = TeamPersistence.class)
1336 protected TeamPersistence teamPersistence;
1337 @BeanReference(type = TicketPersistence.class)
1338 protected TicketPersistence ticketPersistence;
1339 @BeanReference(type = UserPersistence.class)
1340 protected UserPersistence userPersistence;
1341 @BeanReference(type = UserGroupPersistence.class)
1342 protected UserGroupPersistence userGroupPersistence;
1343 @BeanReference(type = UserGroupGroupRolePersistence.class)
1344 protected UserGroupGroupRolePersistence userGroupGroupRolePersistence;
1345 @BeanReference(type = UserGroupRolePersistence.class)
1346 protected UserGroupRolePersistence userGroupRolePersistence;
1347 @BeanReference(type = UserIdMapperPersistence.class)
1348 protected UserIdMapperPersistence userIdMapperPersistence;
1349 @BeanReference(type = UserNotificationEventPersistence.class)
1350 protected UserNotificationEventPersistence userNotificationEventPersistence;
1351 @BeanReference(type = UserTrackerPersistence.class)
1352 protected UserTrackerPersistence userTrackerPersistence;
1353 @BeanReference(type = UserTrackerPathPersistence.class)
1354 protected UserTrackerPathPersistence userTrackerPathPersistence;
1355 @BeanReference(type = VirtualHostPersistence.class)
1356 protected VirtualHostPersistence virtualHostPersistence;
1357 @BeanReference(type = WebDAVPropsPersistence.class)
1358 protected WebDAVPropsPersistence webDAVPropsPersistence;
1359 @BeanReference(type = WebsitePersistence.class)
1360 protected WebsitePersistence websitePersistence;
1361 @BeanReference(type = WorkflowDefinitionLinkPersistence.class)
1362 protected WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
1363 @BeanReference(type = WorkflowInstanceLinkPersistence.class)
1364 protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
1365 private static final String _SQL_SELECT_WORKFLOWINSTANCELINK = "SELECT workflowInstanceLink FROM WorkflowInstanceLink workflowInstanceLink";
1366 private static final String _SQL_SELECT_WORKFLOWINSTANCELINK_WHERE = "SELECT workflowInstanceLink FROM WorkflowInstanceLink workflowInstanceLink WHERE ";
1367 private static final String _SQL_COUNT_WORKFLOWINSTANCELINK = "SELECT COUNT(workflowInstanceLink) FROM WorkflowInstanceLink workflowInstanceLink";
1368 private static final String _SQL_COUNT_WORKFLOWINSTANCELINK_WHERE = "SELECT COUNT(workflowInstanceLink) FROM WorkflowInstanceLink workflowInstanceLink WHERE ";
1369 private static final String _FINDER_COLUMN_G_C_C_C_GROUPID_2 = "workflowInstanceLink.groupId = ? AND ";
1370 private static final String _FINDER_COLUMN_G_C_C_C_COMPANYID_2 = "workflowInstanceLink.companyId = ? AND ";
1371 private static final String _FINDER_COLUMN_G_C_C_C_CLASSNAMEID_2 = "workflowInstanceLink.classNameId = ? AND ";
1372 private static final String _FINDER_COLUMN_G_C_C_C_CLASSPK_2 = "workflowInstanceLink.classPK = ?";
1373 private static final String _ORDER_BY_ENTITY_ALIAS = "workflowInstanceLink.";
1374 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No WorkflowInstanceLink exists with the primary key ";
1375 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No WorkflowInstanceLink exists with the key {";
1376 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
1377 private static Log _log = LogFactoryUtil.getLog(WorkflowInstanceLinkPersistenceImpl.class);
1378 private static WorkflowInstanceLink _nullWorkflowInstanceLink = new WorkflowInstanceLinkImpl() {
1379 @Override
1380 public Object clone() {
1381 return this;
1382 }
1383
1384 @Override
1385 public CacheModel<WorkflowInstanceLink> toCacheModel() {
1386 return _nullWorkflowInstanceLinkCacheModel;
1387 }
1388 };
1389
1390 private static CacheModel<WorkflowInstanceLink> _nullWorkflowInstanceLinkCacheModel =
1391 new CacheModel<WorkflowInstanceLink>() {
1392 public WorkflowInstanceLink toEntityModel() {
1393 return _nullWorkflowInstanceLink;
1394 }
1395 };
1396 }