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
322 else {
323 if ((workflowInstanceLinkModelImpl.getColumnBitmask() &
324 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C_C.getColumnBitmask()) != 0) {
325 Object[] args = new Object[] {
326 Long.valueOf(workflowInstanceLinkModelImpl.getOriginalGroupId()),
327 Long.valueOf(workflowInstanceLinkModelImpl.getOriginalCompanyId()),
328 Long.valueOf(workflowInstanceLinkModelImpl.getOriginalClassNameId()),
329 Long.valueOf(workflowInstanceLinkModelImpl.getOriginalClassPK())
330 };
331
332 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_C_C, args);
333 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C_C,
334 args);
335
336 args = new Object[] {
337 Long.valueOf(workflowInstanceLinkModelImpl.getGroupId()),
338 Long.valueOf(workflowInstanceLinkModelImpl.getCompanyId()),
339 Long.valueOf(workflowInstanceLinkModelImpl.getClassNameId()),
340 Long.valueOf(workflowInstanceLinkModelImpl.getClassPK())
341 };
342
343 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_C_C, args);
344 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C_C,
345 args);
346 }
347 }
348
349 EntityCacheUtil.putResult(WorkflowInstanceLinkModelImpl.ENTITY_CACHE_ENABLED,
350 WorkflowInstanceLinkImpl.class,
351 workflowInstanceLink.getPrimaryKey(), workflowInstanceLink);
352
353 return workflowInstanceLink;
354 }
355
356 protected WorkflowInstanceLink toUnwrappedModel(
357 WorkflowInstanceLink workflowInstanceLink) {
358 if (workflowInstanceLink instanceof WorkflowInstanceLinkImpl) {
359 return workflowInstanceLink;
360 }
361
362 WorkflowInstanceLinkImpl workflowInstanceLinkImpl = new WorkflowInstanceLinkImpl();
363
364 workflowInstanceLinkImpl.setNew(workflowInstanceLink.isNew());
365 workflowInstanceLinkImpl.setPrimaryKey(workflowInstanceLink.getPrimaryKey());
366
367 workflowInstanceLinkImpl.setWorkflowInstanceLinkId(workflowInstanceLink.getWorkflowInstanceLinkId());
368 workflowInstanceLinkImpl.setGroupId(workflowInstanceLink.getGroupId());
369 workflowInstanceLinkImpl.setCompanyId(workflowInstanceLink.getCompanyId());
370 workflowInstanceLinkImpl.setUserId(workflowInstanceLink.getUserId());
371 workflowInstanceLinkImpl.setUserName(workflowInstanceLink.getUserName());
372 workflowInstanceLinkImpl.setCreateDate(workflowInstanceLink.getCreateDate());
373 workflowInstanceLinkImpl.setModifiedDate(workflowInstanceLink.getModifiedDate());
374 workflowInstanceLinkImpl.setClassNameId(workflowInstanceLink.getClassNameId());
375 workflowInstanceLinkImpl.setClassPK(workflowInstanceLink.getClassPK());
376 workflowInstanceLinkImpl.setWorkflowInstanceId(workflowInstanceLink.getWorkflowInstanceId());
377
378 return workflowInstanceLinkImpl;
379 }
380
381
389 @Override
390 public WorkflowInstanceLink findByPrimaryKey(Serializable primaryKey)
391 throws NoSuchModelException, SystemException {
392 return findByPrimaryKey(((Long)primaryKey).longValue());
393 }
394
395
403 public WorkflowInstanceLink findByPrimaryKey(long workflowInstanceLinkId)
404 throws NoSuchWorkflowInstanceLinkException, SystemException {
405 WorkflowInstanceLink workflowInstanceLink = fetchByPrimaryKey(workflowInstanceLinkId);
406
407 if (workflowInstanceLink == null) {
408 if (_log.isWarnEnabled()) {
409 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
410 workflowInstanceLinkId);
411 }
412
413 throw new NoSuchWorkflowInstanceLinkException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
414 workflowInstanceLinkId);
415 }
416
417 return workflowInstanceLink;
418 }
419
420
427 @Override
428 public WorkflowInstanceLink fetchByPrimaryKey(Serializable primaryKey)
429 throws SystemException {
430 return fetchByPrimaryKey(((Long)primaryKey).longValue());
431 }
432
433
440 public WorkflowInstanceLink fetchByPrimaryKey(long workflowInstanceLinkId)
441 throws SystemException {
442 WorkflowInstanceLink workflowInstanceLink = (WorkflowInstanceLink)EntityCacheUtil.getResult(WorkflowInstanceLinkModelImpl.ENTITY_CACHE_ENABLED,
443 WorkflowInstanceLinkImpl.class, workflowInstanceLinkId);
444
445 if (workflowInstanceLink == _nullWorkflowInstanceLink) {
446 return null;
447 }
448
449 if (workflowInstanceLink == null) {
450 Session session = null;
451
452 boolean hasException = false;
453
454 try {
455 session = openSession();
456
457 workflowInstanceLink = (WorkflowInstanceLink)session.get(WorkflowInstanceLinkImpl.class,
458 Long.valueOf(workflowInstanceLinkId));
459 }
460 catch (Exception e) {
461 hasException = true;
462
463 throw processException(e);
464 }
465 finally {
466 if (workflowInstanceLink != null) {
467 cacheResult(workflowInstanceLink);
468 }
469 else if (!hasException) {
470 EntityCacheUtil.putResult(WorkflowInstanceLinkModelImpl.ENTITY_CACHE_ENABLED,
471 WorkflowInstanceLinkImpl.class, workflowInstanceLinkId,
472 _nullWorkflowInstanceLink);
473 }
474
475 closeSession(session);
476 }
477 }
478
479 return workflowInstanceLink;
480 }
481
482
492 public List<WorkflowInstanceLink> findByG_C_C_C(long groupId,
493 long companyId, long classNameId, long classPK)
494 throws SystemException {
495 return findByG_C_C_C(groupId, companyId, classNameId, classPK,
496 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
497 }
498
499
515 public List<WorkflowInstanceLink> findByG_C_C_C(long groupId,
516 long companyId, long classNameId, long classPK, int start, int end)
517 throws SystemException {
518 return findByG_C_C_C(groupId, companyId, classNameId, classPK, start,
519 end, null);
520 }
521
522
539 public List<WorkflowInstanceLink> findByG_C_C_C(long groupId,
540 long companyId, long classNameId, long classPK, int start, int end,
541 OrderByComparator orderByComparator) throws SystemException {
542 FinderPath finderPath = null;
543 Object[] finderArgs = null;
544
545 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
546 (orderByComparator == null)) {
547 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C_C;
548 finderArgs = new Object[] { groupId, companyId, classNameId, classPK };
549 }
550 else {
551 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_C_C;
552 finderArgs = new Object[] {
553 groupId, companyId, classNameId, classPK,
554
555 start, end, orderByComparator
556 };
557 }
558
559 List<WorkflowInstanceLink> list = (List<WorkflowInstanceLink>)FinderCacheUtil.getResult(finderPath,
560 finderArgs, this);
561
562 if ((list != null) && !list.isEmpty()) {
563 for (WorkflowInstanceLink workflowInstanceLink : list) {
564 if ((groupId != workflowInstanceLink.getGroupId()) ||
565 (companyId != workflowInstanceLink.getCompanyId()) ||
566 (classNameId != workflowInstanceLink.getClassNameId()) ||
567 (classPK != workflowInstanceLink.getClassPK())) {
568 list = null;
569
570 break;
571 }
572 }
573 }
574
575 if (list == null) {
576 StringBundler query = null;
577
578 if (orderByComparator != null) {
579 query = new StringBundler(6 +
580 (orderByComparator.getOrderByFields().length * 3));
581 }
582 else {
583 query = new StringBundler(6);
584 }
585
586 query.append(_SQL_SELECT_WORKFLOWINSTANCELINK_WHERE);
587
588 query.append(_FINDER_COLUMN_G_C_C_C_GROUPID_2);
589
590 query.append(_FINDER_COLUMN_G_C_C_C_COMPANYID_2);
591
592 query.append(_FINDER_COLUMN_G_C_C_C_CLASSNAMEID_2);
593
594 query.append(_FINDER_COLUMN_G_C_C_C_CLASSPK_2);
595
596 if (orderByComparator != null) {
597 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
598 orderByComparator);
599 }
600
601 else {
602 query.append(WorkflowInstanceLinkModelImpl.ORDER_BY_JPQL);
603 }
604
605 String sql = query.toString();
606
607 Session session = null;
608
609 try {
610 session = openSession();
611
612 Query q = session.createQuery(sql);
613
614 QueryPos qPos = QueryPos.getInstance(q);
615
616 qPos.add(groupId);
617
618 qPos.add(companyId);
619
620 qPos.add(classNameId);
621
622 qPos.add(classPK);
623
624 list = (List<WorkflowInstanceLink>)QueryUtil.list(q,
625 getDialect(), start, end);
626 }
627 catch (Exception e) {
628 throw processException(e);
629 }
630 finally {
631 if (list == null) {
632 FinderCacheUtil.removeResult(finderPath, finderArgs);
633 }
634 else {
635 cacheResult(list);
636
637 FinderCacheUtil.putResult(finderPath, finderArgs, list);
638 }
639
640 closeSession(session);
641 }
642 }
643
644 return list;
645 }
646
647
659 public WorkflowInstanceLink findByG_C_C_C_First(long groupId,
660 long companyId, long classNameId, long classPK,
661 OrderByComparator orderByComparator)
662 throws NoSuchWorkflowInstanceLinkException, SystemException {
663 WorkflowInstanceLink workflowInstanceLink = fetchByG_C_C_C_First(groupId,
664 companyId, classNameId, classPK, orderByComparator);
665
666 if (workflowInstanceLink != null) {
667 return workflowInstanceLink;
668 }
669
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
691
702 public WorkflowInstanceLink fetchByG_C_C_C_First(long groupId,
703 long companyId, long classNameId, long classPK,
704 OrderByComparator orderByComparator) throws SystemException {
705 List<WorkflowInstanceLink> list = findByG_C_C_C(groupId, companyId,
706 classNameId, classPK, 0, 1, orderByComparator);
707
708 if (!list.isEmpty()) {
709 return list.get(0);
710 }
711
712 return null;
713 }
714
715
727 public WorkflowInstanceLink findByG_C_C_C_Last(long groupId,
728 long companyId, long classNameId, long classPK,
729 OrderByComparator orderByComparator)
730 throws NoSuchWorkflowInstanceLinkException, SystemException {
731 WorkflowInstanceLink workflowInstanceLink = fetchByG_C_C_C_Last(groupId,
732 companyId, classNameId, classPK, orderByComparator);
733
734 if (workflowInstanceLink != null) {
735 return workflowInstanceLink;
736 }
737
738 StringBundler msg = new StringBundler(10);
739
740 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
741
742 msg.append("groupId=");
743 msg.append(groupId);
744
745 msg.append(", companyId=");
746 msg.append(companyId);
747
748 msg.append(", classNameId=");
749 msg.append(classNameId);
750
751 msg.append(", classPK=");
752 msg.append(classPK);
753
754 msg.append(StringPool.CLOSE_CURLY_BRACE);
755
756 throw new NoSuchWorkflowInstanceLinkException(msg.toString());
757 }
758
759
770 public WorkflowInstanceLink fetchByG_C_C_C_Last(long groupId,
771 long companyId, long classNameId, long classPK,
772 OrderByComparator orderByComparator) throws SystemException {
773 int count = countByG_C_C_C(groupId, companyId, classNameId, classPK);
774
775 List<WorkflowInstanceLink> list = findByG_C_C_C(groupId, companyId,
776 classNameId, classPK, count - 1, count, orderByComparator);
777
778 if (!list.isEmpty()) {
779 return list.get(0);
780 }
781
782 return null;
783 }
784
785
798 public WorkflowInstanceLink[] findByG_C_C_C_PrevAndNext(
799 long workflowInstanceLinkId, long groupId, long companyId,
800 long classNameId, long classPK, OrderByComparator orderByComparator)
801 throws NoSuchWorkflowInstanceLinkException, SystemException {
802 WorkflowInstanceLink workflowInstanceLink = findByPrimaryKey(workflowInstanceLinkId);
803
804 Session session = null;
805
806 try {
807 session = openSession();
808
809 WorkflowInstanceLink[] array = new WorkflowInstanceLinkImpl[3];
810
811 array[0] = getByG_C_C_C_PrevAndNext(session, workflowInstanceLink,
812 groupId, companyId, classNameId, classPK,
813 orderByComparator, true);
814
815 array[1] = workflowInstanceLink;
816
817 array[2] = getByG_C_C_C_PrevAndNext(session, workflowInstanceLink,
818 groupId, companyId, classNameId, classPK,
819 orderByComparator, false);
820
821 return array;
822 }
823 catch (Exception e) {
824 throw processException(e);
825 }
826 finally {
827 closeSession(session);
828 }
829 }
830
831 protected WorkflowInstanceLink getByG_C_C_C_PrevAndNext(Session session,
832 WorkflowInstanceLink workflowInstanceLink, long groupId,
833 long companyId, long classNameId, long classPK,
834 OrderByComparator orderByComparator, boolean previous) {
835 StringBundler query = null;
836
837 if (orderByComparator != null) {
838 query = new StringBundler(6 +
839 (orderByComparator.getOrderByFields().length * 6));
840 }
841 else {
842 query = new StringBundler(3);
843 }
844
845 query.append(_SQL_SELECT_WORKFLOWINSTANCELINK_WHERE);
846
847 query.append(_FINDER_COLUMN_G_C_C_C_GROUPID_2);
848
849 query.append(_FINDER_COLUMN_G_C_C_C_COMPANYID_2);
850
851 query.append(_FINDER_COLUMN_G_C_C_C_CLASSNAMEID_2);
852
853 query.append(_FINDER_COLUMN_G_C_C_C_CLASSPK_2);
854
855 if (orderByComparator != null) {
856 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
857
858 if (orderByConditionFields.length > 0) {
859 query.append(WHERE_AND);
860 }
861
862 for (int i = 0; i < orderByConditionFields.length; i++) {
863 query.append(_ORDER_BY_ENTITY_ALIAS);
864 query.append(orderByConditionFields[i]);
865
866 if ((i + 1) < orderByConditionFields.length) {
867 if (orderByComparator.isAscending() ^ previous) {
868 query.append(WHERE_GREATER_THAN_HAS_NEXT);
869 }
870 else {
871 query.append(WHERE_LESSER_THAN_HAS_NEXT);
872 }
873 }
874 else {
875 if (orderByComparator.isAscending() ^ previous) {
876 query.append(WHERE_GREATER_THAN);
877 }
878 else {
879 query.append(WHERE_LESSER_THAN);
880 }
881 }
882 }
883
884 query.append(ORDER_BY_CLAUSE);
885
886 String[] orderByFields = orderByComparator.getOrderByFields();
887
888 for (int i = 0; i < orderByFields.length; i++) {
889 query.append(_ORDER_BY_ENTITY_ALIAS);
890 query.append(orderByFields[i]);
891
892 if ((i + 1) < orderByFields.length) {
893 if (orderByComparator.isAscending() ^ previous) {
894 query.append(ORDER_BY_ASC_HAS_NEXT);
895 }
896 else {
897 query.append(ORDER_BY_DESC_HAS_NEXT);
898 }
899 }
900 else {
901 if (orderByComparator.isAscending() ^ previous) {
902 query.append(ORDER_BY_ASC);
903 }
904 else {
905 query.append(ORDER_BY_DESC);
906 }
907 }
908 }
909 }
910
911 else {
912 query.append(WorkflowInstanceLinkModelImpl.ORDER_BY_JPQL);
913 }
914
915 String sql = query.toString();
916
917 Query q = session.createQuery(sql);
918
919 q.setFirstResult(0);
920 q.setMaxResults(2);
921
922 QueryPos qPos = QueryPos.getInstance(q);
923
924 qPos.add(groupId);
925
926 qPos.add(companyId);
927
928 qPos.add(classNameId);
929
930 qPos.add(classPK);
931
932 if (orderByComparator != null) {
933 Object[] values = orderByComparator.getOrderByConditionValues(workflowInstanceLink);
934
935 for (Object value : values) {
936 qPos.add(value);
937 }
938 }
939
940 List<WorkflowInstanceLink> list = q.list();
941
942 if (list.size() == 2) {
943 return list.get(1);
944 }
945 else {
946 return null;
947 }
948 }
949
950
956 public List<WorkflowInstanceLink> findAll() throws SystemException {
957 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
958 }
959
960
972 public List<WorkflowInstanceLink> findAll(int start, int end)
973 throws SystemException {
974 return findAll(start, end, null);
975 }
976
977
990 public List<WorkflowInstanceLink> findAll(int start, int end,
991 OrderByComparator orderByComparator) throws SystemException {
992 FinderPath finderPath = null;
993 Object[] finderArgs = new Object[] { start, end, orderByComparator };
994
995 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
996 (orderByComparator == null)) {
997 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
998 finderArgs = FINDER_ARGS_EMPTY;
999 }
1000 else {
1001 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
1002 finderArgs = new Object[] { start, end, orderByComparator };
1003 }
1004
1005 List<WorkflowInstanceLink> list = (List<WorkflowInstanceLink>)FinderCacheUtil.getResult(finderPath,
1006 finderArgs, this);
1007
1008 if (list == null) {
1009 StringBundler query = null;
1010 String sql = null;
1011
1012 if (orderByComparator != null) {
1013 query = new StringBundler(2 +
1014 (orderByComparator.getOrderByFields().length * 3));
1015
1016 query.append(_SQL_SELECT_WORKFLOWINSTANCELINK);
1017
1018 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1019 orderByComparator);
1020
1021 sql = query.toString();
1022 }
1023 else {
1024 sql = _SQL_SELECT_WORKFLOWINSTANCELINK.concat(WorkflowInstanceLinkModelImpl.ORDER_BY_JPQL);
1025 }
1026
1027 Session session = null;
1028
1029 try {
1030 session = openSession();
1031
1032 Query q = session.createQuery(sql);
1033
1034 if (orderByComparator == null) {
1035 list = (List<WorkflowInstanceLink>)QueryUtil.list(q,
1036 getDialect(), start, end, false);
1037
1038 Collections.sort(list);
1039 }
1040 else {
1041 list = (List<WorkflowInstanceLink>)QueryUtil.list(q,
1042 getDialect(), start, end);
1043 }
1044 }
1045 catch (Exception e) {
1046 throw processException(e);
1047 }
1048 finally {
1049 if (list == null) {
1050 FinderCacheUtil.removeResult(finderPath, finderArgs);
1051 }
1052 else {
1053 cacheResult(list);
1054
1055 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1056 }
1057
1058 closeSession(session);
1059 }
1060 }
1061
1062 return list;
1063 }
1064
1065
1074 public void removeByG_C_C_C(long groupId, long companyId, long classNameId,
1075 long classPK) throws SystemException {
1076 for (WorkflowInstanceLink workflowInstanceLink : findByG_C_C_C(
1077 groupId, companyId, classNameId, classPK)) {
1078 remove(workflowInstanceLink);
1079 }
1080 }
1081
1082
1087 public void removeAll() throws SystemException {
1088 for (WorkflowInstanceLink workflowInstanceLink : findAll()) {
1089 remove(workflowInstanceLink);
1090 }
1091 }
1092
1093
1103 public int countByG_C_C_C(long groupId, long companyId, long classNameId,
1104 long classPK) throws SystemException {
1105 Object[] finderArgs = new Object[] {
1106 groupId, companyId, classNameId, classPK
1107 };
1108
1109 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_C_C_C,
1110 finderArgs, this);
1111
1112 if (count == null) {
1113 StringBundler query = new StringBundler(5);
1114
1115 query.append(_SQL_COUNT_WORKFLOWINSTANCELINK_WHERE);
1116
1117 query.append(_FINDER_COLUMN_G_C_C_C_GROUPID_2);
1118
1119 query.append(_FINDER_COLUMN_G_C_C_C_COMPANYID_2);
1120
1121 query.append(_FINDER_COLUMN_G_C_C_C_CLASSNAMEID_2);
1122
1123 query.append(_FINDER_COLUMN_G_C_C_C_CLASSPK_2);
1124
1125 String sql = query.toString();
1126
1127 Session session = null;
1128
1129 try {
1130 session = openSession();
1131
1132 Query q = session.createQuery(sql);
1133
1134 QueryPos qPos = QueryPos.getInstance(q);
1135
1136 qPos.add(groupId);
1137
1138 qPos.add(companyId);
1139
1140 qPos.add(classNameId);
1141
1142 qPos.add(classPK);
1143
1144 count = (Long)q.uniqueResult();
1145 }
1146 catch (Exception e) {
1147 throw processException(e);
1148 }
1149 finally {
1150 if (count == null) {
1151 count = Long.valueOf(0);
1152 }
1153
1154 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_C_C_C,
1155 finderArgs, count);
1156
1157 closeSession(session);
1158 }
1159 }
1160
1161 return count.intValue();
1162 }
1163
1164
1170 public int countAll() throws SystemException {
1171 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1172 FINDER_ARGS_EMPTY, this);
1173
1174 if (count == null) {
1175 Session session = null;
1176
1177 try {
1178 session = openSession();
1179
1180 Query q = session.createQuery(_SQL_COUNT_WORKFLOWINSTANCELINK);
1181
1182 count = (Long)q.uniqueResult();
1183 }
1184 catch (Exception e) {
1185 throw processException(e);
1186 }
1187 finally {
1188 if (count == null) {
1189 count = Long.valueOf(0);
1190 }
1191
1192 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
1193 FINDER_ARGS_EMPTY, count);
1194
1195 closeSession(session);
1196 }
1197 }
1198
1199 return count.intValue();
1200 }
1201
1202
1205 public void afterPropertiesSet() {
1206 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1207 com.liferay.portal.util.PropsUtil.get(
1208 "value.object.listener.com.liferay.portal.model.WorkflowInstanceLink")));
1209
1210 if (listenerClassNames.length > 0) {
1211 try {
1212 List<ModelListener<WorkflowInstanceLink>> listenersList = new ArrayList<ModelListener<WorkflowInstanceLink>>();
1213
1214 for (String listenerClassName : listenerClassNames) {
1215 Class<?> clazz = getClass();
1216
1217 listenersList.add((ModelListener<WorkflowInstanceLink>)InstanceFactory.newInstance(
1218 clazz.getClassLoader(), listenerClassName));
1219 }
1220
1221 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1222 }
1223 catch (Exception e) {
1224 _log.error(e);
1225 }
1226 }
1227 }
1228
1229 public void destroy() {
1230 EntityCacheUtil.removeCache(WorkflowInstanceLinkImpl.class.getName());
1231 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
1232 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1233 }
1234
1235 @BeanReference(type = AccountPersistence.class)
1236 protected AccountPersistence accountPersistence;
1237 @BeanReference(type = AddressPersistence.class)
1238 protected AddressPersistence addressPersistence;
1239 @BeanReference(type = BrowserTrackerPersistence.class)
1240 protected BrowserTrackerPersistence browserTrackerPersistence;
1241 @BeanReference(type = ClassNamePersistence.class)
1242 protected ClassNamePersistence classNamePersistence;
1243 @BeanReference(type = ClusterGroupPersistence.class)
1244 protected ClusterGroupPersistence clusterGroupPersistence;
1245 @BeanReference(type = CompanyPersistence.class)
1246 protected CompanyPersistence companyPersistence;
1247 @BeanReference(type = ContactPersistence.class)
1248 protected ContactPersistence contactPersistence;
1249 @BeanReference(type = CountryPersistence.class)
1250 protected CountryPersistence countryPersistence;
1251 @BeanReference(type = EmailAddressPersistence.class)
1252 protected EmailAddressPersistence emailAddressPersistence;
1253 @BeanReference(type = GroupPersistence.class)
1254 protected GroupPersistence groupPersistence;
1255 @BeanReference(type = ImagePersistence.class)
1256 protected ImagePersistence imagePersistence;
1257 @BeanReference(type = LayoutPersistence.class)
1258 protected LayoutPersistence layoutPersistence;
1259 @BeanReference(type = LayoutBranchPersistence.class)
1260 protected LayoutBranchPersistence layoutBranchPersistence;
1261 @BeanReference(type = LayoutPrototypePersistence.class)
1262 protected LayoutPrototypePersistence layoutPrototypePersistence;
1263 @BeanReference(type = LayoutRevisionPersistence.class)
1264 protected LayoutRevisionPersistence layoutRevisionPersistence;
1265 @BeanReference(type = LayoutSetPersistence.class)
1266 protected LayoutSetPersistence layoutSetPersistence;
1267 @BeanReference(type = LayoutSetBranchPersistence.class)
1268 protected LayoutSetBranchPersistence layoutSetBranchPersistence;
1269 @BeanReference(type = LayoutSetPrototypePersistence.class)
1270 protected LayoutSetPrototypePersistence layoutSetPrototypePersistence;
1271 @BeanReference(type = ListTypePersistence.class)
1272 protected ListTypePersistence listTypePersistence;
1273 @BeanReference(type = LockPersistence.class)
1274 protected LockPersistence lockPersistence;
1275 @BeanReference(type = MembershipRequestPersistence.class)
1276 protected MembershipRequestPersistence membershipRequestPersistence;
1277 @BeanReference(type = OrganizationPersistence.class)
1278 protected OrganizationPersistence organizationPersistence;
1279 @BeanReference(type = OrgGroupPermissionPersistence.class)
1280 protected OrgGroupPermissionPersistence orgGroupPermissionPersistence;
1281 @BeanReference(type = OrgGroupRolePersistence.class)
1282 protected OrgGroupRolePersistence orgGroupRolePersistence;
1283 @BeanReference(type = OrgLaborPersistence.class)
1284 protected OrgLaborPersistence orgLaborPersistence;
1285 @BeanReference(type = PasswordPolicyPersistence.class)
1286 protected PasswordPolicyPersistence passwordPolicyPersistence;
1287 @BeanReference(type = PasswordPolicyRelPersistence.class)
1288 protected PasswordPolicyRelPersistence passwordPolicyRelPersistence;
1289 @BeanReference(type = PasswordTrackerPersistence.class)
1290 protected PasswordTrackerPersistence passwordTrackerPersistence;
1291 @BeanReference(type = PermissionPersistence.class)
1292 protected PermissionPersistence permissionPersistence;
1293 @BeanReference(type = PhonePersistence.class)
1294 protected PhonePersistence phonePersistence;
1295 @BeanReference(type = PluginSettingPersistence.class)
1296 protected PluginSettingPersistence pluginSettingPersistence;
1297 @BeanReference(type = PortalPreferencesPersistence.class)
1298 protected PortalPreferencesPersistence portalPreferencesPersistence;
1299 @BeanReference(type = PortletPersistence.class)
1300 protected PortletPersistence portletPersistence;
1301 @BeanReference(type = PortletItemPersistence.class)
1302 protected PortletItemPersistence portletItemPersistence;
1303 @BeanReference(type = PortletPreferencesPersistence.class)
1304 protected PortletPreferencesPersistence portletPreferencesPersistence;
1305 @BeanReference(type = RegionPersistence.class)
1306 protected RegionPersistence regionPersistence;
1307 @BeanReference(type = ReleasePersistence.class)
1308 protected ReleasePersistence releasePersistence;
1309 @BeanReference(type = RepositoryPersistence.class)
1310 protected RepositoryPersistence repositoryPersistence;
1311 @BeanReference(type = RepositoryEntryPersistence.class)
1312 protected RepositoryEntryPersistence repositoryEntryPersistence;
1313 @BeanReference(type = ResourcePersistence.class)
1314 protected ResourcePersistence resourcePersistence;
1315 @BeanReference(type = ResourceActionPersistence.class)
1316 protected ResourceActionPersistence resourceActionPersistence;
1317 @BeanReference(type = ResourceBlockPersistence.class)
1318 protected ResourceBlockPersistence resourceBlockPersistence;
1319 @BeanReference(type = ResourceBlockPermissionPersistence.class)
1320 protected ResourceBlockPermissionPersistence resourceBlockPermissionPersistence;
1321 @BeanReference(type = ResourceCodePersistence.class)
1322 protected ResourceCodePersistence resourceCodePersistence;
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 }