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 BatchSessionUtil.delete(session, workflowInstanceLink);
277 }
278 catch (Exception e) {
279 throw processException(e);
280 }
281 finally {
282 closeSession(session);
283 }
284
285 clearCache(workflowInstanceLink);
286
287 return workflowInstanceLink;
288 }
289
290 @Override
291 public WorkflowInstanceLink updateImpl(
292 com.liferay.portal.model.WorkflowInstanceLink workflowInstanceLink,
293 boolean merge) throws SystemException {
294 workflowInstanceLink = toUnwrappedModel(workflowInstanceLink);
295
296 boolean isNew = workflowInstanceLink.isNew();
297
298 WorkflowInstanceLinkModelImpl workflowInstanceLinkModelImpl = (WorkflowInstanceLinkModelImpl)workflowInstanceLink;
299
300 Session session = null;
301
302 try {
303 session = openSession();
304
305 BatchSessionUtil.update(session, workflowInstanceLink, merge);
306
307 workflowInstanceLink.setNew(false);
308 }
309 catch (Exception e) {
310 throw processException(e);
311 }
312 finally {
313 closeSession(session);
314 }
315
316 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
317
318 if (isNew || !WorkflowInstanceLinkModelImpl.COLUMN_BITMASK_ENABLED) {
319 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
320 }
321 else {
322 if ((workflowInstanceLinkModelImpl.getColumnBitmask() &
323 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C_C.getColumnBitmask()) != 0) {
324 Object[] args = new Object[] {
325 Long.valueOf(workflowInstanceLinkModelImpl.getOriginalGroupId()),
326 Long.valueOf(workflowInstanceLinkModelImpl.getOriginalCompanyId()),
327 Long.valueOf(workflowInstanceLinkModelImpl.getOriginalClassNameId()),
328 Long.valueOf(workflowInstanceLinkModelImpl.getOriginalClassPK())
329 };
330
331 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_C_C, args);
332 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C_C,
333 args);
334
335 args = new Object[] {
336 Long.valueOf(workflowInstanceLinkModelImpl.getGroupId()),
337 Long.valueOf(workflowInstanceLinkModelImpl.getCompanyId()),
338 Long.valueOf(workflowInstanceLinkModelImpl.getClassNameId()),
339 Long.valueOf(workflowInstanceLinkModelImpl.getClassPK())
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 }
347
348 EntityCacheUtil.putResult(WorkflowInstanceLinkModelImpl.ENTITY_CACHE_ENABLED,
349 WorkflowInstanceLinkImpl.class,
350 workflowInstanceLink.getPrimaryKey(), workflowInstanceLink);
351
352 return workflowInstanceLink;
353 }
354
355 protected WorkflowInstanceLink toUnwrappedModel(
356 WorkflowInstanceLink workflowInstanceLink) {
357 if (workflowInstanceLink instanceof WorkflowInstanceLinkImpl) {
358 return workflowInstanceLink;
359 }
360
361 WorkflowInstanceLinkImpl workflowInstanceLinkImpl = new WorkflowInstanceLinkImpl();
362
363 workflowInstanceLinkImpl.setNew(workflowInstanceLink.isNew());
364 workflowInstanceLinkImpl.setPrimaryKey(workflowInstanceLink.getPrimaryKey());
365
366 workflowInstanceLinkImpl.setWorkflowInstanceLinkId(workflowInstanceLink.getWorkflowInstanceLinkId());
367 workflowInstanceLinkImpl.setGroupId(workflowInstanceLink.getGroupId());
368 workflowInstanceLinkImpl.setCompanyId(workflowInstanceLink.getCompanyId());
369 workflowInstanceLinkImpl.setUserId(workflowInstanceLink.getUserId());
370 workflowInstanceLinkImpl.setUserName(workflowInstanceLink.getUserName());
371 workflowInstanceLinkImpl.setCreateDate(workflowInstanceLink.getCreateDate());
372 workflowInstanceLinkImpl.setModifiedDate(workflowInstanceLink.getModifiedDate());
373 workflowInstanceLinkImpl.setClassNameId(workflowInstanceLink.getClassNameId());
374 workflowInstanceLinkImpl.setClassPK(workflowInstanceLink.getClassPK());
375 workflowInstanceLinkImpl.setWorkflowInstanceId(workflowInstanceLink.getWorkflowInstanceId());
376
377 return workflowInstanceLinkImpl;
378 }
379
380
388 @Override
389 public WorkflowInstanceLink findByPrimaryKey(Serializable primaryKey)
390 throws NoSuchModelException, SystemException {
391 return findByPrimaryKey(((Long)primaryKey).longValue());
392 }
393
394
402 public WorkflowInstanceLink findByPrimaryKey(long workflowInstanceLinkId)
403 throws NoSuchWorkflowInstanceLinkException, SystemException {
404 WorkflowInstanceLink workflowInstanceLink = fetchByPrimaryKey(workflowInstanceLinkId);
405
406 if (workflowInstanceLink == null) {
407 if (_log.isWarnEnabled()) {
408 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
409 workflowInstanceLinkId);
410 }
411
412 throw new NoSuchWorkflowInstanceLinkException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
413 workflowInstanceLinkId);
414 }
415
416 return workflowInstanceLink;
417 }
418
419
426 @Override
427 public WorkflowInstanceLink fetchByPrimaryKey(Serializable primaryKey)
428 throws SystemException {
429 return fetchByPrimaryKey(((Long)primaryKey).longValue());
430 }
431
432
439 public WorkflowInstanceLink fetchByPrimaryKey(long workflowInstanceLinkId)
440 throws SystemException {
441 WorkflowInstanceLink workflowInstanceLink = (WorkflowInstanceLink)EntityCacheUtil.getResult(WorkflowInstanceLinkModelImpl.ENTITY_CACHE_ENABLED,
442 WorkflowInstanceLinkImpl.class, workflowInstanceLinkId);
443
444 if (workflowInstanceLink == _nullWorkflowInstanceLink) {
445 return null;
446 }
447
448 if (workflowInstanceLink == null) {
449 Session session = null;
450
451 boolean hasException = false;
452
453 try {
454 session = openSession();
455
456 workflowInstanceLink = (WorkflowInstanceLink)session.get(WorkflowInstanceLinkImpl.class,
457 Long.valueOf(workflowInstanceLinkId));
458 }
459 catch (Exception e) {
460 hasException = true;
461
462 throw processException(e);
463 }
464 finally {
465 if (workflowInstanceLink != null) {
466 cacheResult(workflowInstanceLink);
467 }
468 else if (!hasException) {
469 EntityCacheUtil.putResult(WorkflowInstanceLinkModelImpl.ENTITY_CACHE_ENABLED,
470 WorkflowInstanceLinkImpl.class, workflowInstanceLinkId,
471 _nullWorkflowInstanceLink);
472 }
473
474 closeSession(session);
475 }
476 }
477
478 return workflowInstanceLink;
479 }
480
481
491 public List<WorkflowInstanceLink> findByG_C_C_C(long groupId,
492 long companyId, long classNameId, long classPK)
493 throws SystemException {
494 return findByG_C_C_C(groupId, companyId, classNameId, classPK,
495 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
496 }
497
498
514 public List<WorkflowInstanceLink> findByG_C_C_C(long groupId,
515 long companyId, long classNameId, long classPK, int start, int end)
516 throws SystemException {
517 return findByG_C_C_C(groupId, companyId, classNameId, classPK, start,
518 end, null);
519 }
520
521
538 public List<WorkflowInstanceLink> findByG_C_C_C(long groupId,
539 long companyId, long classNameId, long classPK, int start, int end,
540 OrderByComparator orderByComparator) throws SystemException {
541 FinderPath finderPath = null;
542 Object[] finderArgs = null;
543
544 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
545 (orderByComparator == null)) {
546 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C_C;
547 finderArgs = new Object[] { groupId, companyId, classNameId, classPK };
548 }
549 else {
550 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_C_C;
551 finderArgs = new Object[] {
552 groupId, companyId, classNameId, classPK,
553
554 start, end, orderByComparator
555 };
556 }
557
558 List<WorkflowInstanceLink> list = (List<WorkflowInstanceLink>)FinderCacheUtil.getResult(finderPath,
559 finderArgs, this);
560
561 if ((list != null) && !list.isEmpty()) {
562 for (WorkflowInstanceLink workflowInstanceLink : list) {
563 if ((groupId != workflowInstanceLink.getGroupId()) ||
564 (companyId != workflowInstanceLink.getCompanyId()) ||
565 (classNameId != workflowInstanceLink.getClassNameId()) ||
566 (classPK != workflowInstanceLink.getClassPK())) {
567 list = null;
568
569 break;
570 }
571 }
572 }
573
574 if (list == null) {
575 StringBundler query = null;
576
577 if (orderByComparator != null) {
578 query = new StringBundler(6 +
579 (orderByComparator.getOrderByFields().length * 3));
580 }
581 else {
582 query = new StringBundler(6);
583 }
584
585 query.append(_SQL_SELECT_WORKFLOWINSTANCELINK_WHERE);
586
587 query.append(_FINDER_COLUMN_G_C_C_C_GROUPID_2);
588
589 query.append(_FINDER_COLUMN_G_C_C_C_COMPANYID_2);
590
591 query.append(_FINDER_COLUMN_G_C_C_C_CLASSNAMEID_2);
592
593 query.append(_FINDER_COLUMN_G_C_C_C_CLASSPK_2);
594
595 if (orderByComparator != null) {
596 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
597 orderByComparator);
598 }
599
600 else {
601 query.append(WorkflowInstanceLinkModelImpl.ORDER_BY_JPQL);
602 }
603
604 String sql = query.toString();
605
606 Session session = null;
607
608 try {
609 session = openSession();
610
611 Query q = session.createQuery(sql);
612
613 QueryPos qPos = QueryPos.getInstance(q);
614
615 qPos.add(groupId);
616
617 qPos.add(companyId);
618
619 qPos.add(classNameId);
620
621 qPos.add(classPK);
622
623 list = (List<WorkflowInstanceLink>)QueryUtil.list(q,
624 getDialect(), start, end);
625 }
626 catch (Exception e) {
627 throw processException(e);
628 }
629 finally {
630 if (list == null) {
631 FinderCacheUtil.removeResult(finderPath, finderArgs);
632 }
633 else {
634 cacheResult(list);
635
636 FinderCacheUtil.putResult(finderPath, finderArgs, list);
637 }
638
639 closeSession(session);
640 }
641 }
642
643 return list;
644 }
645
646
662 public WorkflowInstanceLink findByG_C_C_C_First(long groupId,
663 long companyId, long classNameId, long classPK,
664 OrderByComparator orderByComparator)
665 throws NoSuchWorkflowInstanceLinkException, SystemException {
666 List<WorkflowInstanceLink> list = findByG_C_C_C(groupId, companyId,
667 classNameId, classPK, 0, 1, orderByComparator);
668
669 if (list.isEmpty()) {
670 StringBundler msg = new StringBundler(10);
671
672 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
673
674 msg.append("groupId=");
675 msg.append(groupId);
676
677 msg.append(", companyId=");
678 msg.append(companyId);
679
680 msg.append(", classNameId=");
681 msg.append(classNameId);
682
683 msg.append(", classPK=");
684 msg.append(classPK);
685
686 msg.append(StringPool.CLOSE_CURLY_BRACE);
687
688 throw new NoSuchWorkflowInstanceLinkException(msg.toString());
689 }
690 else {
691 return list.get(0);
692 }
693 }
694
695
711 public WorkflowInstanceLink findByG_C_C_C_Last(long groupId,
712 long companyId, long classNameId, long classPK,
713 OrderByComparator orderByComparator)
714 throws NoSuchWorkflowInstanceLinkException, SystemException {
715 int count = countByG_C_C_C(groupId, companyId, classNameId, classPK);
716
717 List<WorkflowInstanceLink> list = findByG_C_C_C(groupId, companyId,
718 classNameId, classPK, count - 1, count, orderByComparator);
719
720 if (list.isEmpty()) {
721 StringBundler msg = new StringBundler(10);
722
723 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
724
725 msg.append("groupId=");
726 msg.append(groupId);
727
728 msg.append(", companyId=");
729 msg.append(companyId);
730
731 msg.append(", classNameId=");
732 msg.append(classNameId);
733
734 msg.append(", classPK=");
735 msg.append(classPK);
736
737 msg.append(StringPool.CLOSE_CURLY_BRACE);
738
739 throw new NoSuchWorkflowInstanceLinkException(msg.toString());
740 }
741 else {
742 return list.get(0);
743 }
744 }
745
746
763 public WorkflowInstanceLink[] findByG_C_C_C_PrevAndNext(
764 long workflowInstanceLinkId, long groupId, long companyId,
765 long classNameId, long classPK, OrderByComparator orderByComparator)
766 throws NoSuchWorkflowInstanceLinkException, SystemException {
767 WorkflowInstanceLink workflowInstanceLink = findByPrimaryKey(workflowInstanceLinkId);
768
769 Session session = null;
770
771 try {
772 session = openSession();
773
774 WorkflowInstanceLink[] array = new WorkflowInstanceLinkImpl[3];
775
776 array[0] = getByG_C_C_C_PrevAndNext(session, workflowInstanceLink,
777 groupId, companyId, classNameId, classPK,
778 orderByComparator, true);
779
780 array[1] = workflowInstanceLink;
781
782 array[2] = getByG_C_C_C_PrevAndNext(session, workflowInstanceLink,
783 groupId, companyId, classNameId, classPK,
784 orderByComparator, false);
785
786 return array;
787 }
788 catch (Exception e) {
789 throw processException(e);
790 }
791 finally {
792 closeSession(session);
793 }
794 }
795
796 protected WorkflowInstanceLink getByG_C_C_C_PrevAndNext(Session session,
797 WorkflowInstanceLink workflowInstanceLink, long groupId,
798 long companyId, long classNameId, long classPK,
799 OrderByComparator orderByComparator, boolean previous) {
800 StringBundler query = null;
801
802 if (orderByComparator != null) {
803 query = new StringBundler(6 +
804 (orderByComparator.getOrderByFields().length * 6));
805 }
806 else {
807 query = new StringBundler(3);
808 }
809
810 query.append(_SQL_SELECT_WORKFLOWINSTANCELINK_WHERE);
811
812 query.append(_FINDER_COLUMN_G_C_C_C_GROUPID_2);
813
814 query.append(_FINDER_COLUMN_G_C_C_C_COMPANYID_2);
815
816 query.append(_FINDER_COLUMN_G_C_C_C_CLASSNAMEID_2);
817
818 query.append(_FINDER_COLUMN_G_C_C_C_CLASSPK_2);
819
820 if (orderByComparator != null) {
821 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
822
823 if (orderByConditionFields.length > 0) {
824 query.append(WHERE_AND);
825 }
826
827 for (int i = 0; i < orderByConditionFields.length; i++) {
828 query.append(_ORDER_BY_ENTITY_ALIAS);
829 query.append(orderByConditionFields[i]);
830
831 if ((i + 1) < orderByConditionFields.length) {
832 if (orderByComparator.isAscending() ^ previous) {
833 query.append(WHERE_GREATER_THAN_HAS_NEXT);
834 }
835 else {
836 query.append(WHERE_LESSER_THAN_HAS_NEXT);
837 }
838 }
839 else {
840 if (orderByComparator.isAscending() ^ previous) {
841 query.append(WHERE_GREATER_THAN);
842 }
843 else {
844 query.append(WHERE_LESSER_THAN);
845 }
846 }
847 }
848
849 query.append(ORDER_BY_CLAUSE);
850
851 String[] orderByFields = orderByComparator.getOrderByFields();
852
853 for (int i = 0; i < orderByFields.length; i++) {
854 query.append(_ORDER_BY_ENTITY_ALIAS);
855 query.append(orderByFields[i]);
856
857 if ((i + 1) < orderByFields.length) {
858 if (orderByComparator.isAscending() ^ previous) {
859 query.append(ORDER_BY_ASC_HAS_NEXT);
860 }
861 else {
862 query.append(ORDER_BY_DESC_HAS_NEXT);
863 }
864 }
865 else {
866 if (orderByComparator.isAscending() ^ previous) {
867 query.append(ORDER_BY_ASC);
868 }
869 else {
870 query.append(ORDER_BY_DESC);
871 }
872 }
873 }
874 }
875
876 else {
877 query.append(WorkflowInstanceLinkModelImpl.ORDER_BY_JPQL);
878 }
879
880 String sql = query.toString();
881
882 Query q = session.createQuery(sql);
883
884 q.setFirstResult(0);
885 q.setMaxResults(2);
886
887 QueryPos qPos = QueryPos.getInstance(q);
888
889 qPos.add(groupId);
890
891 qPos.add(companyId);
892
893 qPos.add(classNameId);
894
895 qPos.add(classPK);
896
897 if (orderByComparator != null) {
898 Object[] values = orderByComparator.getOrderByConditionValues(workflowInstanceLink);
899
900 for (Object value : values) {
901 qPos.add(value);
902 }
903 }
904
905 List<WorkflowInstanceLink> list = q.list();
906
907 if (list.size() == 2) {
908 return list.get(1);
909 }
910 else {
911 return null;
912 }
913 }
914
915
921 public List<WorkflowInstanceLink> findAll() throws SystemException {
922 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
923 }
924
925
937 public List<WorkflowInstanceLink> findAll(int start, int end)
938 throws SystemException {
939 return findAll(start, end, null);
940 }
941
942
955 public List<WorkflowInstanceLink> findAll(int start, int end,
956 OrderByComparator orderByComparator) throws SystemException {
957 FinderPath finderPath = null;
958 Object[] finderArgs = new Object[] { start, end, orderByComparator };
959
960 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
961 (orderByComparator == null)) {
962 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
963 finderArgs = FINDER_ARGS_EMPTY;
964 }
965 else {
966 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
967 finderArgs = new Object[] { start, end, orderByComparator };
968 }
969
970 List<WorkflowInstanceLink> list = (List<WorkflowInstanceLink>)FinderCacheUtil.getResult(finderPath,
971 finderArgs, this);
972
973 if (list == null) {
974 StringBundler query = null;
975 String sql = null;
976
977 if (orderByComparator != null) {
978 query = new StringBundler(2 +
979 (orderByComparator.getOrderByFields().length * 3));
980
981 query.append(_SQL_SELECT_WORKFLOWINSTANCELINK);
982
983 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
984 orderByComparator);
985
986 sql = query.toString();
987 }
988 else {
989 sql = _SQL_SELECT_WORKFLOWINSTANCELINK.concat(WorkflowInstanceLinkModelImpl.ORDER_BY_JPQL);
990 }
991
992 Session session = null;
993
994 try {
995 session = openSession();
996
997 Query q = session.createQuery(sql);
998
999 if (orderByComparator == null) {
1000 list = (List<WorkflowInstanceLink>)QueryUtil.list(q,
1001 getDialect(), start, end, false);
1002
1003 Collections.sort(list);
1004 }
1005 else {
1006 list = (List<WorkflowInstanceLink>)QueryUtil.list(q,
1007 getDialect(), start, end);
1008 }
1009 }
1010 catch (Exception e) {
1011 throw processException(e);
1012 }
1013 finally {
1014 if (list == null) {
1015 FinderCacheUtil.removeResult(finderPath, finderArgs);
1016 }
1017 else {
1018 cacheResult(list);
1019
1020 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1021 }
1022
1023 closeSession(session);
1024 }
1025 }
1026
1027 return list;
1028 }
1029
1030
1039 public void removeByG_C_C_C(long groupId, long companyId, long classNameId,
1040 long classPK) throws SystemException {
1041 for (WorkflowInstanceLink workflowInstanceLink : findByG_C_C_C(
1042 groupId, companyId, classNameId, classPK)) {
1043 remove(workflowInstanceLink);
1044 }
1045 }
1046
1047
1052 public void removeAll() throws SystemException {
1053 for (WorkflowInstanceLink workflowInstanceLink : findAll()) {
1054 remove(workflowInstanceLink);
1055 }
1056 }
1057
1058
1068 public int countByG_C_C_C(long groupId, long companyId, long classNameId,
1069 long classPK) throws SystemException {
1070 Object[] finderArgs = new Object[] {
1071 groupId, companyId, classNameId, classPK
1072 };
1073
1074 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_C_C_C,
1075 finderArgs, this);
1076
1077 if (count == null) {
1078 StringBundler query = new StringBundler(5);
1079
1080 query.append(_SQL_COUNT_WORKFLOWINSTANCELINK_WHERE);
1081
1082 query.append(_FINDER_COLUMN_G_C_C_C_GROUPID_2);
1083
1084 query.append(_FINDER_COLUMN_G_C_C_C_COMPANYID_2);
1085
1086 query.append(_FINDER_COLUMN_G_C_C_C_CLASSNAMEID_2);
1087
1088 query.append(_FINDER_COLUMN_G_C_C_C_CLASSPK_2);
1089
1090 String sql = query.toString();
1091
1092 Session session = null;
1093
1094 try {
1095 session = openSession();
1096
1097 Query q = session.createQuery(sql);
1098
1099 QueryPos qPos = QueryPos.getInstance(q);
1100
1101 qPos.add(groupId);
1102
1103 qPos.add(companyId);
1104
1105 qPos.add(classNameId);
1106
1107 qPos.add(classPK);
1108
1109 count = (Long)q.uniqueResult();
1110 }
1111 catch (Exception e) {
1112 throw processException(e);
1113 }
1114 finally {
1115 if (count == null) {
1116 count = Long.valueOf(0);
1117 }
1118
1119 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_C_C_C,
1120 finderArgs, count);
1121
1122 closeSession(session);
1123 }
1124 }
1125
1126 return count.intValue();
1127 }
1128
1129
1135 public int countAll() throws SystemException {
1136 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1137 FINDER_ARGS_EMPTY, this);
1138
1139 if (count == null) {
1140 Session session = null;
1141
1142 try {
1143 session = openSession();
1144
1145 Query q = session.createQuery(_SQL_COUNT_WORKFLOWINSTANCELINK);
1146
1147 count = (Long)q.uniqueResult();
1148 }
1149 catch (Exception e) {
1150 throw processException(e);
1151 }
1152 finally {
1153 if (count == null) {
1154 count = Long.valueOf(0);
1155 }
1156
1157 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
1158 FINDER_ARGS_EMPTY, count);
1159
1160 closeSession(session);
1161 }
1162 }
1163
1164 return count.intValue();
1165 }
1166
1167
1170 public void afterPropertiesSet() {
1171 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1172 com.liferay.portal.util.PropsUtil.get(
1173 "value.object.listener.com.liferay.portal.model.WorkflowInstanceLink")));
1174
1175 if (listenerClassNames.length > 0) {
1176 try {
1177 List<ModelListener<WorkflowInstanceLink>> listenersList = new ArrayList<ModelListener<WorkflowInstanceLink>>();
1178
1179 for (String listenerClassName : listenerClassNames) {
1180 listenersList.add((ModelListener<WorkflowInstanceLink>)InstanceFactory.newInstance(
1181 listenerClassName));
1182 }
1183
1184 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1185 }
1186 catch (Exception e) {
1187 _log.error(e);
1188 }
1189 }
1190 }
1191
1192 public void destroy() {
1193 EntityCacheUtil.removeCache(WorkflowInstanceLinkImpl.class.getName());
1194 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
1195 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1196 }
1197
1198 @BeanReference(type = AccountPersistence.class)
1199 protected AccountPersistence accountPersistence;
1200 @BeanReference(type = AddressPersistence.class)
1201 protected AddressPersistence addressPersistence;
1202 @BeanReference(type = BrowserTrackerPersistence.class)
1203 protected BrowserTrackerPersistence browserTrackerPersistence;
1204 @BeanReference(type = ClassNamePersistence.class)
1205 protected ClassNamePersistence classNamePersistence;
1206 @BeanReference(type = ClusterGroupPersistence.class)
1207 protected ClusterGroupPersistence clusterGroupPersistence;
1208 @BeanReference(type = CompanyPersistence.class)
1209 protected CompanyPersistence companyPersistence;
1210 @BeanReference(type = ContactPersistence.class)
1211 protected ContactPersistence contactPersistence;
1212 @BeanReference(type = CountryPersistence.class)
1213 protected CountryPersistence countryPersistence;
1214 @BeanReference(type = EmailAddressPersistence.class)
1215 protected EmailAddressPersistence emailAddressPersistence;
1216 @BeanReference(type = GroupPersistence.class)
1217 protected GroupPersistence groupPersistence;
1218 @BeanReference(type = ImagePersistence.class)
1219 protected ImagePersistence imagePersistence;
1220 @BeanReference(type = LayoutPersistence.class)
1221 protected LayoutPersistence layoutPersistence;
1222 @BeanReference(type = LayoutBranchPersistence.class)
1223 protected LayoutBranchPersistence layoutBranchPersistence;
1224 @BeanReference(type = LayoutPrototypePersistence.class)
1225 protected LayoutPrototypePersistence layoutPrototypePersistence;
1226 @BeanReference(type = LayoutRevisionPersistence.class)
1227 protected LayoutRevisionPersistence layoutRevisionPersistence;
1228 @BeanReference(type = LayoutSetPersistence.class)
1229 protected LayoutSetPersistence layoutSetPersistence;
1230 @BeanReference(type = LayoutSetBranchPersistence.class)
1231 protected LayoutSetBranchPersistence layoutSetBranchPersistence;
1232 @BeanReference(type = LayoutSetPrototypePersistence.class)
1233 protected LayoutSetPrototypePersistence layoutSetPrototypePersistence;
1234 @BeanReference(type = ListTypePersistence.class)
1235 protected ListTypePersistence listTypePersistence;
1236 @BeanReference(type = LockPersistence.class)
1237 protected LockPersistence lockPersistence;
1238 @BeanReference(type = MembershipRequestPersistence.class)
1239 protected MembershipRequestPersistence membershipRequestPersistence;
1240 @BeanReference(type = OrganizationPersistence.class)
1241 protected OrganizationPersistence organizationPersistence;
1242 @BeanReference(type = OrgGroupPermissionPersistence.class)
1243 protected OrgGroupPermissionPersistence orgGroupPermissionPersistence;
1244 @BeanReference(type = OrgGroupRolePersistence.class)
1245 protected OrgGroupRolePersistence orgGroupRolePersistence;
1246 @BeanReference(type = OrgLaborPersistence.class)
1247 protected OrgLaborPersistence orgLaborPersistence;
1248 @BeanReference(type = PasswordPolicyPersistence.class)
1249 protected PasswordPolicyPersistence passwordPolicyPersistence;
1250 @BeanReference(type = PasswordPolicyRelPersistence.class)
1251 protected PasswordPolicyRelPersistence passwordPolicyRelPersistence;
1252 @BeanReference(type = PasswordTrackerPersistence.class)
1253 protected PasswordTrackerPersistence passwordTrackerPersistence;
1254 @BeanReference(type = PermissionPersistence.class)
1255 protected PermissionPersistence permissionPersistence;
1256 @BeanReference(type = PhonePersistence.class)
1257 protected PhonePersistence phonePersistence;
1258 @BeanReference(type = PluginSettingPersistence.class)
1259 protected PluginSettingPersistence pluginSettingPersistence;
1260 @BeanReference(type = PortalPreferencesPersistence.class)
1261 protected PortalPreferencesPersistence portalPreferencesPersistence;
1262 @BeanReference(type = PortletPersistence.class)
1263 protected PortletPersistence portletPersistence;
1264 @BeanReference(type = PortletItemPersistence.class)
1265 protected PortletItemPersistence portletItemPersistence;
1266 @BeanReference(type = PortletPreferencesPersistence.class)
1267 protected PortletPreferencesPersistence portletPreferencesPersistence;
1268 @BeanReference(type = RegionPersistence.class)
1269 protected RegionPersistence regionPersistence;
1270 @BeanReference(type = ReleasePersistence.class)
1271 protected ReleasePersistence releasePersistence;
1272 @BeanReference(type = RepositoryPersistence.class)
1273 protected RepositoryPersistence repositoryPersistence;
1274 @BeanReference(type = RepositoryEntryPersistence.class)
1275 protected RepositoryEntryPersistence repositoryEntryPersistence;
1276 @BeanReference(type = ResourcePersistence.class)
1277 protected ResourcePersistence resourcePersistence;
1278 @BeanReference(type = ResourceActionPersistence.class)
1279 protected ResourceActionPersistence resourceActionPersistence;
1280 @BeanReference(type = ResourceBlockPersistence.class)
1281 protected ResourceBlockPersistence resourceBlockPersistence;
1282 @BeanReference(type = ResourceBlockPermissionPersistence.class)
1283 protected ResourceBlockPermissionPersistence resourceBlockPermissionPersistence;
1284 @BeanReference(type = ResourceCodePersistence.class)
1285 protected ResourceCodePersistence resourceCodePersistence;
1286 @BeanReference(type = ResourcePermissionPersistence.class)
1287 protected ResourcePermissionPersistence resourcePermissionPersistence;
1288 @BeanReference(type = ResourceTypePermissionPersistence.class)
1289 protected ResourceTypePermissionPersistence resourceTypePermissionPersistence;
1290 @BeanReference(type = RolePersistence.class)
1291 protected RolePersistence rolePersistence;
1292 @BeanReference(type = ServiceComponentPersistence.class)
1293 protected ServiceComponentPersistence serviceComponentPersistence;
1294 @BeanReference(type = ShardPersistence.class)
1295 protected ShardPersistence shardPersistence;
1296 @BeanReference(type = SubscriptionPersistence.class)
1297 protected SubscriptionPersistence subscriptionPersistence;
1298 @BeanReference(type = TeamPersistence.class)
1299 protected TeamPersistence teamPersistence;
1300 @BeanReference(type = TicketPersistence.class)
1301 protected TicketPersistence ticketPersistence;
1302 @BeanReference(type = UserPersistence.class)
1303 protected UserPersistence userPersistence;
1304 @BeanReference(type = UserGroupPersistence.class)
1305 protected UserGroupPersistence userGroupPersistence;
1306 @BeanReference(type = UserGroupGroupRolePersistence.class)
1307 protected UserGroupGroupRolePersistence userGroupGroupRolePersistence;
1308 @BeanReference(type = UserGroupRolePersistence.class)
1309 protected UserGroupRolePersistence userGroupRolePersistence;
1310 @BeanReference(type = UserIdMapperPersistence.class)
1311 protected UserIdMapperPersistence userIdMapperPersistence;
1312 @BeanReference(type = UserNotificationEventPersistence.class)
1313 protected UserNotificationEventPersistence userNotificationEventPersistence;
1314 @BeanReference(type = UserTrackerPersistence.class)
1315 protected UserTrackerPersistence userTrackerPersistence;
1316 @BeanReference(type = UserTrackerPathPersistence.class)
1317 protected UserTrackerPathPersistence userTrackerPathPersistence;
1318 @BeanReference(type = VirtualHostPersistence.class)
1319 protected VirtualHostPersistence virtualHostPersistence;
1320 @BeanReference(type = WebDAVPropsPersistence.class)
1321 protected WebDAVPropsPersistence webDAVPropsPersistence;
1322 @BeanReference(type = WebsitePersistence.class)
1323 protected WebsitePersistence websitePersistence;
1324 @BeanReference(type = WorkflowDefinitionLinkPersistence.class)
1325 protected WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
1326 @BeanReference(type = WorkflowInstanceLinkPersistence.class)
1327 protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
1328 private static final String _SQL_SELECT_WORKFLOWINSTANCELINK = "SELECT workflowInstanceLink FROM WorkflowInstanceLink workflowInstanceLink";
1329 private static final String _SQL_SELECT_WORKFLOWINSTANCELINK_WHERE = "SELECT workflowInstanceLink FROM WorkflowInstanceLink workflowInstanceLink WHERE ";
1330 private static final String _SQL_COUNT_WORKFLOWINSTANCELINK = "SELECT COUNT(workflowInstanceLink) FROM WorkflowInstanceLink workflowInstanceLink";
1331 private static final String _SQL_COUNT_WORKFLOWINSTANCELINK_WHERE = "SELECT COUNT(workflowInstanceLink) FROM WorkflowInstanceLink workflowInstanceLink WHERE ";
1332 private static final String _FINDER_COLUMN_G_C_C_C_GROUPID_2 = "workflowInstanceLink.groupId = ? AND ";
1333 private static final String _FINDER_COLUMN_G_C_C_C_COMPANYID_2 = "workflowInstanceLink.companyId = ? AND ";
1334 private static final String _FINDER_COLUMN_G_C_C_C_CLASSNAMEID_2 = "workflowInstanceLink.classNameId = ? AND ";
1335 private static final String _FINDER_COLUMN_G_C_C_C_CLASSPK_2 = "workflowInstanceLink.classPK = ?";
1336 private static final String _ORDER_BY_ENTITY_ALIAS = "workflowInstanceLink.";
1337 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No WorkflowInstanceLink exists with the primary key ";
1338 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No WorkflowInstanceLink exists with the key {";
1339 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
1340 private static Log _log = LogFactoryUtil.getLog(WorkflowInstanceLinkPersistenceImpl.class);
1341 private static WorkflowInstanceLink _nullWorkflowInstanceLink = new WorkflowInstanceLinkImpl() {
1342 @Override
1343 public Object clone() {
1344 return this;
1345 }
1346
1347 @Override
1348 public CacheModel<WorkflowInstanceLink> toCacheModel() {
1349 return _nullWorkflowInstanceLinkCacheModel;
1350 }
1351 };
1352
1353 private static CacheModel<WorkflowInstanceLink> _nullWorkflowInstanceLinkCacheModel =
1354 new CacheModel<WorkflowInstanceLink>() {
1355 public WorkflowInstanceLink toEntityModel() {
1356 return _nullWorkflowInstanceLink;
1357 }
1358 };
1359 }