1
14
15 package com.liferay.portal.service.persistence;
16
17 import com.liferay.portal.NoSuchModelException;
18 import com.liferay.portal.NoSuchWorkflowInstanceLinkException;
19 import com.liferay.portal.kernel.annotation.BeanReference;
20 import com.liferay.portal.kernel.cache.CacheRegistry;
21 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
22 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
23 import com.liferay.portal.kernel.dao.orm.FinderPath;
24 import com.liferay.portal.kernel.dao.orm.Query;
25 import com.liferay.portal.kernel.dao.orm.QueryPos;
26 import com.liferay.portal.kernel.dao.orm.QueryUtil;
27 import com.liferay.portal.kernel.dao.orm.Session;
28 import com.liferay.portal.kernel.exception.SystemException;
29 import com.liferay.portal.kernel.log.Log;
30 import com.liferay.portal.kernel.log.LogFactoryUtil;
31 import com.liferay.portal.kernel.util.GetterUtil;
32 import com.liferay.portal.kernel.util.InstanceFactory;
33 import com.liferay.portal.kernel.util.OrderByComparator;
34 import com.liferay.portal.kernel.util.StringBundler;
35 import com.liferay.portal.kernel.util.StringPool;
36 import com.liferay.portal.kernel.util.StringUtil;
37 import com.liferay.portal.model.ModelListener;
38 import com.liferay.portal.model.WorkflowInstanceLink;
39 import com.liferay.portal.model.impl.WorkflowInstanceLinkImpl;
40 import com.liferay.portal.model.impl.WorkflowInstanceLinkModelImpl;
41 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
42
43 import java.io.Serializable;
44
45 import java.util.ArrayList;
46 import java.util.Collections;
47 import java.util.List;
48
49
62 public class WorkflowInstanceLinkPersistenceImpl extends BasePersistenceImpl<WorkflowInstanceLink>
63 implements WorkflowInstanceLinkPersistence {
64 public static final String FINDER_CLASS_NAME_ENTITY = WorkflowInstanceLinkImpl.class.getName();
65 public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
66 ".List";
67 public static final FinderPath FINDER_PATH_FIND_BY_G_C_C_C = new FinderPath(WorkflowInstanceLinkModelImpl.ENTITY_CACHE_ENABLED,
68 WorkflowInstanceLinkModelImpl.FINDER_CACHE_ENABLED,
69 FINDER_CLASS_NAME_LIST, "findByG_C_C_C",
70 new String[] {
71 Long.class.getName(), Long.class.getName(), Long.class.getName(),
72 Long.class.getName(),
73
74 "java.lang.Integer", "java.lang.Integer",
75 "com.liferay.portal.kernel.util.OrderByComparator"
76 });
77 public static final FinderPath FINDER_PATH_COUNT_BY_G_C_C_C = new FinderPath(WorkflowInstanceLinkModelImpl.ENTITY_CACHE_ENABLED,
78 WorkflowInstanceLinkModelImpl.FINDER_CACHE_ENABLED,
79 FINDER_CLASS_NAME_LIST, "countByG_C_C_C",
80 new String[] {
81 Long.class.getName(), Long.class.getName(), Long.class.getName(),
82 Long.class.getName()
83 });
84 public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(WorkflowInstanceLinkModelImpl.ENTITY_CACHE_ENABLED,
85 WorkflowInstanceLinkModelImpl.FINDER_CACHE_ENABLED,
86 FINDER_CLASS_NAME_LIST, "findAll", new String[0]);
87 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(WorkflowInstanceLinkModelImpl.ENTITY_CACHE_ENABLED,
88 WorkflowInstanceLinkModelImpl.FINDER_CACHE_ENABLED,
89 FINDER_CLASS_NAME_LIST, "countAll", new String[0]);
90
91 public void cacheResult(WorkflowInstanceLink workflowInstanceLink) {
92 EntityCacheUtil.putResult(WorkflowInstanceLinkModelImpl.ENTITY_CACHE_ENABLED,
93 WorkflowInstanceLinkImpl.class,
94 workflowInstanceLink.getPrimaryKey(), workflowInstanceLink);
95 }
96
97 public void cacheResult(List<WorkflowInstanceLink> workflowInstanceLinks) {
98 for (WorkflowInstanceLink workflowInstanceLink : workflowInstanceLinks) {
99 if (EntityCacheUtil.getResult(
100 WorkflowInstanceLinkModelImpl.ENTITY_CACHE_ENABLED,
101 WorkflowInstanceLinkImpl.class,
102 workflowInstanceLink.getPrimaryKey(), this) == null) {
103 cacheResult(workflowInstanceLink);
104 }
105 }
106 }
107
108 public void clearCache() {
109 CacheRegistry.clear(WorkflowInstanceLinkImpl.class.getName());
110 EntityCacheUtil.clearCache(WorkflowInstanceLinkImpl.class.getName());
111 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
112 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
113 }
114
115 public void clearCache(WorkflowInstanceLink workflowInstanceLink) {
116 EntityCacheUtil.removeResult(WorkflowInstanceLinkModelImpl.ENTITY_CACHE_ENABLED,
117 WorkflowInstanceLinkImpl.class, workflowInstanceLink.getPrimaryKey());
118 }
119
120 public WorkflowInstanceLink create(long workflowInstanceLinkId) {
121 WorkflowInstanceLink workflowInstanceLink = new WorkflowInstanceLinkImpl();
122
123 workflowInstanceLink.setNew(true);
124 workflowInstanceLink.setPrimaryKey(workflowInstanceLinkId);
125
126 return workflowInstanceLink;
127 }
128
129 public WorkflowInstanceLink remove(Serializable primaryKey)
130 throws NoSuchModelException, SystemException {
131 return remove(((Long)primaryKey).longValue());
132 }
133
134 public WorkflowInstanceLink remove(long workflowInstanceLinkId)
135 throws NoSuchWorkflowInstanceLinkException, SystemException {
136 Session session = null;
137
138 try {
139 session = openSession();
140
141 WorkflowInstanceLink workflowInstanceLink = (WorkflowInstanceLink)session.get(WorkflowInstanceLinkImpl.class,
142 new Long(workflowInstanceLinkId));
143
144 if (workflowInstanceLink == null) {
145 if (_log.isWarnEnabled()) {
146 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
147 workflowInstanceLinkId);
148 }
149
150 throw new NoSuchWorkflowInstanceLinkException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
151 workflowInstanceLinkId);
152 }
153
154 return remove(workflowInstanceLink);
155 }
156 catch (NoSuchWorkflowInstanceLinkException nsee) {
157 throw nsee;
158 }
159 catch (Exception e) {
160 throw processException(e);
161 }
162 finally {
163 closeSession(session);
164 }
165 }
166
167 public WorkflowInstanceLink remove(
168 WorkflowInstanceLink workflowInstanceLink) throws SystemException {
169 for (ModelListener<WorkflowInstanceLink> listener : listeners) {
170 listener.onBeforeRemove(workflowInstanceLink);
171 }
172
173 workflowInstanceLink = removeImpl(workflowInstanceLink);
174
175 for (ModelListener<WorkflowInstanceLink> listener : listeners) {
176 listener.onAfterRemove(workflowInstanceLink);
177 }
178
179 return workflowInstanceLink;
180 }
181
182 protected WorkflowInstanceLink removeImpl(
183 WorkflowInstanceLink workflowInstanceLink) throws SystemException {
184 workflowInstanceLink = toUnwrappedModel(workflowInstanceLink);
185
186 Session session = null;
187
188 try {
189 session = openSession();
190
191 if (workflowInstanceLink.isCachedModel() ||
192 BatchSessionUtil.isEnabled()) {
193 Object staleObject = session.get(WorkflowInstanceLinkImpl.class,
194 workflowInstanceLink.getPrimaryKeyObj());
195
196 if (staleObject != null) {
197 session.evict(staleObject);
198 }
199 }
200
201 session.delete(workflowInstanceLink);
202
203 session.flush();
204 }
205 catch (Exception e) {
206 throw processException(e);
207 }
208 finally {
209 closeSession(session);
210 }
211
212 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
213
214 EntityCacheUtil.removeResult(WorkflowInstanceLinkModelImpl.ENTITY_CACHE_ENABLED,
215 WorkflowInstanceLinkImpl.class, workflowInstanceLink.getPrimaryKey());
216
217 return workflowInstanceLink;
218 }
219
220 public WorkflowInstanceLink updateImpl(
221 com.liferay.portal.model.WorkflowInstanceLink workflowInstanceLink,
222 boolean merge) throws SystemException {
223 workflowInstanceLink = toUnwrappedModel(workflowInstanceLink);
224
225 Session session = null;
226
227 try {
228 session = openSession();
229
230 BatchSessionUtil.update(session, workflowInstanceLink, merge);
231
232 workflowInstanceLink.setNew(false);
233 }
234 catch (Exception e) {
235 throw processException(e);
236 }
237 finally {
238 closeSession(session);
239 }
240
241 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
242
243 EntityCacheUtil.putResult(WorkflowInstanceLinkModelImpl.ENTITY_CACHE_ENABLED,
244 WorkflowInstanceLinkImpl.class,
245 workflowInstanceLink.getPrimaryKey(), workflowInstanceLink);
246
247 return workflowInstanceLink;
248 }
249
250 protected WorkflowInstanceLink toUnwrappedModel(
251 WorkflowInstanceLink workflowInstanceLink) {
252 if (workflowInstanceLink instanceof WorkflowInstanceLinkImpl) {
253 return workflowInstanceLink;
254 }
255
256 WorkflowInstanceLinkImpl workflowInstanceLinkImpl = new WorkflowInstanceLinkImpl();
257
258 workflowInstanceLinkImpl.setNew(workflowInstanceLink.isNew());
259 workflowInstanceLinkImpl.setPrimaryKey(workflowInstanceLink.getPrimaryKey());
260
261 workflowInstanceLinkImpl.setWorkflowInstanceLinkId(workflowInstanceLink.getWorkflowInstanceLinkId());
262 workflowInstanceLinkImpl.setGroupId(workflowInstanceLink.getGroupId());
263 workflowInstanceLinkImpl.setCompanyId(workflowInstanceLink.getCompanyId());
264 workflowInstanceLinkImpl.setUserId(workflowInstanceLink.getUserId());
265 workflowInstanceLinkImpl.setUserName(workflowInstanceLink.getUserName());
266 workflowInstanceLinkImpl.setCreateDate(workflowInstanceLink.getCreateDate());
267 workflowInstanceLinkImpl.setModifiedDate(workflowInstanceLink.getModifiedDate());
268 workflowInstanceLinkImpl.setClassNameId(workflowInstanceLink.getClassNameId());
269 workflowInstanceLinkImpl.setClassPK(workflowInstanceLink.getClassPK());
270 workflowInstanceLinkImpl.setWorkflowInstanceId(workflowInstanceLink.getWorkflowInstanceId());
271
272 return workflowInstanceLinkImpl;
273 }
274
275 public WorkflowInstanceLink findByPrimaryKey(Serializable primaryKey)
276 throws NoSuchModelException, SystemException {
277 return findByPrimaryKey(((Long)primaryKey).longValue());
278 }
279
280 public WorkflowInstanceLink findByPrimaryKey(long workflowInstanceLinkId)
281 throws NoSuchWorkflowInstanceLinkException, SystemException {
282 WorkflowInstanceLink workflowInstanceLink = fetchByPrimaryKey(workflowInstanceLinkId);
283
284 if (workflowInstanceLink == null) {
285 if (_log.isWarnEnabled()) {
286 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
287 workflowInstanceLinkId);
288 }
289
290 throw new NoSuchWorkflowInstanceLinkException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
291 workflowInstanceLinkId);
292 }
293
294 return workflowInstanceLink;
295 }
296
297 public WorkflowInstanceLink fetchByPrimaryKey(Serializable primaryKey)
298 throws SystemException {
299 return fetchByPrimaryKey(((Long)primaryKey).longValue());
300 }
301
302 public WorkflowInstanceLink fetchByPrimaryKey(long workflowInstanceLinkId)
303 throws SystemException {
304 WorkflowInstanceLink workflowInstanceLink = (WorkflowInstanceLink)EntityCacheUtil.getResult(WorkflowInstanceLinkModelImpl.ENTITY_CACHE_ENABLED,
305 WorkflowInstanceLinkImpl.class, workflowInstanceLinkId, this);
306
307 if (workflowInstanceLink == null) {
308 Session session = null;
309
310 try {
311 session = openSession();
312
313 workflowInstanceLink = (WorkflowInstanceLink)session.get(WorkflowInstanceLinkImpl.class,
314 new Long(workflowInstanceLinkId));
315 }
316 catch (Exception e) {
317 throw processException(e);
318 }
319 finally {
320 if (workflowInstanceLink != null) {
321 cacheResult(workflowInstanceLink);
322 }
323
324 closeSession(session);
325 }
326 }
327
328 return workflowInstanceLink;
329 }
330
331 public List<WorkflowInstanceLink> findByG_C_C_C(long groupId,
332 long companyId, long classNameId, long classPK)
333 throws SystemException {
334 return findByG_C_C_C(groupId, companyId, classNameId, classPK,
335 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
336 }
337
338 public List<WorkflowInstanceLink> findByG_C_C_C(long groupId,
339 long companyId, long classNameId, long classPK, int start, int end)
340 throws SystemException {
341 return findByG_C_C_C(groupId, companyId, classNameId, classPK, start,
342 end, null);
343 }
344
345 public List<WorkflowInstanceLink> findByG_C_C_C(long groupId,
346 long companyId, long classNameId, long classPK, int start, int end,
347 OrderByComparator orderByComparator) throws SystemException {
348 Object[] finderArgs = new Object[] {
349 new Long(groupId), new Long(companyId), new Long(classNameId),
350 new Long(classPK),
351
352 String.valueOf(start), String.valueOf(end),
353 String.valueOf(orderByComparator)
354 };
355
356 List<WorkflowInstanceLink> list = (List<WorkflowInstanceLink>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_G_C_C_C,
357 finderArgs, this);
358
359 if (list == null) {
360 Session session = null;
361
362 try {
363 session = openSession();
364
365 StringBundler query = null;
366
367 if (orderByComparator != null) {
368 query = new StringBundler(6 +
369 (orderByComparator.getOrderByFields().length * 3));
370 }
371 else {
372 query = new StringBundler(6);
373 }
374
375 query.append(_SQL_SELECT_WORKFLOWINSTANCELINK_WHERE);
376
377 query.append(_FINDER_COLUMN_G_C_C_C_GROUPID_2);
378
379 query.append(_FINDER_COLUMN_G_C_C_C_COMPANYID_2);
380
381 query.append(_FINDER_COLUMN_G_C_C_C_CLASSNAMEID_2);
382
383 query.append(_FINDER_COLUMN_G_C_C_C_CLASSPK_2);
384
385 if (orderByComparator != null) {
386 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
387 orderByComparator);
388 }
389
390 else {
391 query.append(WorkflowInstanceLinkModelImpl.ORDER_BY_JPQL);
392 }
393
394 String sql = query.toString();
395
396 Query q = session.createQuery(sql);
397
398 QueryPos qPos = QueryPos.getInstance(q);
399
400 qPos.add(groupId);
401
402 qPos.add(companyId);
403
404 qPos.add(classNameId);
405
406 qPos.add(classPK);
407
408 list = (List<WorkflowInstanceLink>)QueryUtil.list(q,
409 getDialect(), start, end);
410 }
411 catch (Exception e) {
412 throw processException(e);
413 }
414 finally {
415 if (list == null) {
416 list = new ArrayList<WorkflowInstanceLink>();
417 }
418
419 cacheResult(list);
420
421 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_G_C_C_C,
422 finderArgs, list);
423
424 closeSession(session);
425 }
426 }
427
428 return list;
429 }
430
431 public WorkflowInstanceLink findByG_C_C_C_First(long groupId,
432 long companyId, long classNameId, long classPK,
433 OrderByComparator orderByComparator)
434 throws NoSuchWorkflowInstanceLinkException, SystemException {
435 List<WorkflowInstanceLink> list = findByG_C_C_C(groupId, companyId,
436 classNameId, classPK, 0, 1, orderByComparator);
437
438 if (list.isEmpty()) {
439 StringBundler msg = new StringBundler(10);
440
441 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
442
443 msg.append("groupId=");
444 msg.append(groupId);
445
446 msg.append(", companyId=");
447 msg.append(companyId);
448
449 msg.append(", classNameId=");
450 msg.append(classNameId);
451
452 msg.append(", classPK=");
453 msg.append(classPK);
454
455 msg.append(StringPool.CLOSE_CURLY_BRACE);
456
457 throw new NoSuchWorkflowInstanceLinkException(msg.toString());
458 }
459 else {
460 return list.get(0);
461 }
462 }
463
464 public WorkflowInstanceLink findByG_C_C_C_Last(long groupId,
465 long companyId, long classNameId, long classPK,
466 OrderByComparator orderByComparator)
467 throws NoSuchWorkflowInstanceLinkException, SystemException {
468 int count = countByG_C_C_C(groupId, companyId, classNameId, classPK);
469
470 List<WorkflowInstanceLink> list = findByG_C_C_C(groupId, companyId,
471 classNameId, classPK, count - 1, count, orderByComparator);
472
473 if (list.isEmpty()) {
474 StringBundler msg = new StringBundler(10);
475
476 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
477
478 msg.append("groupId=");
479 msg.append(groupId);
480
481 msg.append(", companyId=");
482 msg.append(companyId);
483
484 msg.append(", classNameId=");
485 msg.append(classNameId);
486
487 msg.append(", classPK=");
488 msg.append(classPK);
489
490 msg.append(StringPool.CLOSE_CURLY_BRACE);
491
492 throw new NoSuchWorkflowInstanceLinkException(msg.toString());
493 }
494 else {
495 return list.get(0);
496 }
497 }
498
499 public WorkflowInstanceLink[] findByG_C_C_C_PrevAndNext(
500 long workflowInstanceLinkId, long groupId, long companyId,
501 long classNameId, long classPK, OrderByComparator orderByComparator)
502 throws NoSuchWorkflowInstanceLinkException, SystemException {
503 WorkflowInstanceLink workflowInstanceLink = findByPrimaryKey(workflowInstanceLinkId);
504
505 Session session = null;
506
507 try {
508 session = openSession();
509
510 WorkflowInstanceLink[] array = new WorkflowInstanceLinkImpl[3];
511
512 array[0] = getByG_C_C_C_PrevAndNext(session, workflowInstanceLink,
513 groupId, companyId, classNameId, classPK,
514 orderByComparator, true);
515
516 array[1] = workflowInstanceLink;
517
518 array[2] = getByG_C_C_C_PrevAndNext(session, workflowInstanceLink,
519 groupId, companyId, classNameId, classPK,
520 orderByComparator, false);
521
522 return array;
523 }
524 catch (Exception e) {
525 throw processException(e);
526 }
527 finally {
528 closeSession(session);
529 }
530 }
531
532 protected WorkflowInstanceLink getByG_C_C_C_PrevAndNext(Session session,
533 WorkflowInstanceLink workflowInstanceLink, long groupId,
534 long companyId, long classNameId, long classPK,
535 OrderByComparator orderByComparator, boolean previous) {
536 StringBundler query = null;
537
538 if (orderByComparator != null) {
539 query = new StringBundler(6 +
540 (orderByComparator.getOrderByFields().length * 6));
541 }
542 else {
543 query = new StringBundler(3);
544 }
545
546 query.append(_SQL_SELECT_WORKFLOWINSTANCELINK_WHERE);
547
548 query.append(_FINDER_COLUMN_G_C_C_C_GROUPID_2);
549
550 query.append(_FINDER_COLUMN_G_C_C_C_COMPANYID_2);
551
552 query.append(_FINDER_COLUMN_G_C_C_C_CLASSNAMEID_2);
553
554 query.append(_FINDER_COLUMN_G_C_C_C_CLASSPK_2);
555
556 if (orderByComparator != null) {
557 String[] orderByFields = orderByComparator.getOrderByFields();
558
559 if (orderByFields.length > 0) {
560 query.append(WHERE_AND);
561 }
562
563 for (int i = 0; i < orderByFields.length; i++) {
564 query.append(_ORDER_BY_ENTITY_ALIAS);
565 query.append(orderByFields[i]);
566
567 if ((i + 1) < orderByFields.length) {
568 if (orderByComparator.isAscending() ^ previous) {
569 query.append(WHERE_GREATER_THAN_HAS_NEXT);
570 }
571 else {
572 query.append(WHERE_LESSER_THAN_HAS_NEXT);
573 }
574 }
575 else {
576 if (orderByComparator.isAscending() ^ previous) {
577 query.append(WHERE_GREATER_THAN);
578 }
579 else {
580 query.append(WHERE_LESSER_THAN);
581 }
582 }
583 }
584
585 query.append(ORDER_BY_CLAUSE);
586
587 for (int i = 0; i < orderByFields.length; i++) {
588 query.append(_ORDER_BY_ENTITY_ALIAS);
589 query.append(orderByFields[i]);
590
591 if ((i + 1) < orderByFields.length) {
592 if (orderByComparator.isAscending() ^ previous) {
593 query.append(ORDER_BY_ASC_HAS_NEXT);
594 }
595 else {
596 query.append(ORDER_BY_DESC_HAS_NEXT);
597 }
598 }
599 else {
600 if (orderByComparator.isAscending() ^ previous) {
601 query.append(ORDER_BY_ASC);
602 }
603 else {
604 query.append(ORDER_BY_DESC);
605 }
606 }
607 }
608 }
609
610 else {
611 query.append(WorkflowInstanceLinkModelImpl.ORDER_BY_JPQL);
612 }
613
614 String sql = query.toString();
615
616 Query q = session.createQuery(sql);
617
618 q.setFirstResult(0);
619 q.setMaxResults(2);
620
621 QueryPos qPos = QueryPos.getInstance(q);
622
623 qPos.add(groupId);
624
625 qPos.add(companyId);
626
627 qPos.add(classNameId);
628
629 qPos.add(classPK);
630
631 if (orderByComparator != null) {
632 Object[] values = orderByComparator.getOrderByValues(workflowInstanceLink);
633
634 for (Object value : values) {
635 qPos.add(value);
636 }
637 }
638
639 List<WorkflowInstanceLink> list = q.list();
640
641 if (list.size() == 2) {
642 return list.get(1);
643 }
644 else {
645 return null;
646 }
647 }
648
649 public List<WorkflowInstanceLink> findAll() throws SystemException {
650 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
651 }
652
653 public List<WorkflowInstanceLink> findAll(int start, int end)
654 throws SystemException {
655 return findAll(start, end, null);
656 }
657
658 public List<WorkflowInstanceLink> findAll(int start, int end,
659 OrderByComparator orderByComparator) throws SystemException {
660 Object[] finderArgs = new Object[] {
661 String.valueOf(start), String.valueOf(end),
662 String.valueOf(orderByComparator)
663 };
664
665 List<WorkflowInstanceLink> list = (List<WorkflowInstanceLink>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
666 finderArgs, this);
667
668 if (list == null) {
669 Session session = null;
670
671 try {
672 session = openSession();
673
674 StringBundler query = null;
675 String sql = null;
676
677 if (orderByComparator != null) {
678 query = new StringBundler(2 +
679 (orderByComparator.getOrderByFields().length * 3));
680
681 query.append(_SQL_SELECT_WORKFLOWINSTANCELINK);
682
683 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
684 orderByComparator);
685
686 sql = query.toString();
687 }
688
689 else {
690 sql = _SQL_SELECT_WORKFLOWINSTANCELINK.concat(WorkflowInstanceLinkModelImpl.ORDER_BY_JPQL);
691 }
692
693 Query q = session.createQuery(sql);
694
695 if (orderByComparator == null) {
696 list = (List<WorkflowInstanceLink>)QueryUtil.list(q,
697 getDialect(), start, end, false);
698
699 Collections.sort(list);
700 }
701 else {
702 list = (List<WorkflowInstanceLink>)QueryUtil.list(q,
703 getDialect(), start, end);
704 }
705 }
706 catch (Exception e) {
707 throw processException(e);
708 }
709 finally {
710 if (list == null) {
711 list = new ArrayList<WorkflowInstanceLink>();
712 }
713
714 cacheResult(list);
715
716 FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
717
718 closeSession(session);
719 }
720 }
721
722 return list;
723 }
724
725 public void removeByG_C_C_C(long groupId, long companyId, long classNameId,
726 long classPK) throws SystemException {
727 for (WorkflowInstanceLink workflowInstanceLink : findByG_C_C_C(
728 groupId, companyId, classNameId, classPK)) {
729 remove(workflowInstanceLink);
730 }
731 }
732
733 public void removeAll() throws SystemException {
734 for (WorkflowInstanceLink workflowInstanceLink : findAll()) {
735 remove(workflowInstanceLink);
736 }
737 }
738
739 public int countByG_C_C_C(long groupId, long companyId, long classNameId,
740 long classPK) throws SystemException {
741 Object[] finderArgs = new Object[] {
742 new Long(groupId), new Long(companyId), new Long(classNameId),
743 new Long(classPK)
744 };
745
746 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_C_C_C,
747 finderArgs, this);
748
749 if (count == null) {
750 Session session = null;
751
752 try {
753 session = openSession();
754
755 StringBundler query = new StringBundler(5);
756
757 query.append(_SQL_COUNT_WORKFLOWINSTANCELINK_WHERE);
758
759 query.append(_FINDER_COLUMN_G_C_C_C_GROUPID_2);
760
761 query.append(_FINDER_COLUMN_G_C_C_C_COMPANYID_2);
762
763 query.append(_FINDER_COLUMN_G_C_C_C_CLASSNAMEID_2);
764
765 query.append(_FINDER_COLUMN_G_C_C_C_CLASSPK_2);
766
767 String sql = query.toString();
768
769 Query q = session.createQuery(sql);
770
771 QueryPos qPos = QueryPos.getInstance(q);
772
773 qPos.add(groupId);
774
775 qPos.add(companyId);
776
777 qPos.add(classNameId);
778
779 qPos.add(classPK);
780
781 count = (Long)q.uniqueResult();
782 }
783 catch (Exception e) {
784 throw processException(e);
785 }
786 finally {
787 if (count == null) {
788 count = Long.valueOf(0);
789 }
790
791 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_C_C_C,
792 finderArgs, count);
793
794 closeSession(session);
795 }
796 }
797
798 return count.intValue();
799 }
800
801 public int countAll() throws SystemException {
802 Object[] finderArgs = new Object[0];
803
804 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
805 finderArgs, this);
806
807 if (count == null) {
808 Session session = null;
809
810 try {
811 session = openSession();
812
813 Query q = session.createQuery(_SQL_COUNT_WORKFLOWINSTANCELINK);
814
815 count = (Long)q.uniqueResult();
816 }
817 catch (Exception e) {
818 throw processException(e);
819 }
820 finally {
821 if (count == null) {
822 count = Long.valueOf(0);
823 }
824
825 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
826 count);
827
828 closeSession(session);
829 }
830 }
831
832 return count.intValue();
833 }
834
835 public void afterPropertiesSet() {
836 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
837 com.liferay.portal.util.PropsUtil.get(
838 "value.object.listener.com.liferay.portal.model.WorkflowInstanceLink")));
839
840 if (listenerClassNames.length > 0) {
841 try {
842 List<ModelListener<WorkflowInstanceLink>> listenersList = new ArrayList<ModelListener<WorkflowInstanceLink>>();
843
844 for (String listenerClassName : listenerClassNames) {
845 listenersList.add((ModelListener<WorkflowInstanceLink>)InstanceFactory.newInstance(
846 listenerClassName));
847 }
848
849 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
850 }
851 catch (Exception e) {
852 _log.error(e);
853 }
854 }
855 }
856
857 @BeanReference(type = AccountPersistence.class)
858 protected AccountPersistence accountPersistence;
859 @BeanReference(type = AddressPersistence.class)
860 protected AddressPersistence addressPersistence;
861 @BeanReference(type = BrowserTrackerPersistence.class)
862 protected BrowserTrackerPersistence browserTrackerPersistence;
863 @BeanReference(type = ClassNamePersistence.class)
864 protected ClassNamePersistence classNamePersistence;
865 @BeanReference(type = CompanyPersistence.class)
866 protected CompanyPersistence companyPersistence;
867 @BeanReference(type = ContactPersistence.class)
868 protected ContactPersistence contactPersistence;
869 @BeanReference(type = CountryPersistence.class)
870 protected CountryPersistence countryPersistence;
871 @BeanReference(type = EmailAddressPersistence.class)
872 protected EmailAddressPersistence emailAddressPersistence;
873 @BeanReference(type = GroupPersistence.class)
874 protected GroupPersistence groupPersistence;
875 @BeanReference(type = ImagePersistence.class)
876 protected ImagePersistence imagePersistence;
877 @BeanReference(type = LayoutPersistence.class)
878 protected LayoutPersistence layoutPersistence;
879 @BeanReference(type = LayoutPrototypePersistence.class)
880 protected LayoutPrototypePersistence layoutPrototypePersistence;
881 @BeanReference(type = LayoutSetPersistence.class)
882 protected LayoutSetPersistence layoutSetPersistence;
883 @BeanReference(type = LayoutSetPrototypePersistence.class)
884 protected LayoutSetPrototypePersistence layoutSetPrototypePersistence;
885 @BeanReference(type = ListTypePersistence.class)
886 protected ListTypePersistence listTypePersistence;
887 @BeanReference(type = LockPersistence.class)
888 protected LockPersistence lockPersistence;
889 @BeanReference(type = MembershipRequestPersistence.class)
890 protected MembershipRequestPersistence membershipRequestPersistence;
891 @BeanReference(type = OrganizationPersistence.class)
892 protected OrganizationPersistence organizationPersistence;
893 @BeanReference(type = OrgGroupPermissionPersistence.class)
894 protected OrgGroupPermissionPersistence orgGroupPermissionPersistence;
895 @BeanReference(type = OrgGroupRolePersistence.class)
896 protected OrgGroupRolePersistence orgGroupRolePersistence;
897 @BeanReference(type = OrgLaborPersistence.class)
898 protected OrgLaborPersistence orgLaborPersistence;
899 @BeanReference(type = PasswordPolicyPersistence.class)
900 protected PasswordPolicyPersistence passwordPolicyPersistence;
901 @BeanReference(type = PasswordPolicyRelPersistence.class)
902 protected PasswordPolicyRelPersistence passwordPolicyRelPersistence;
903 @BeanReference(type = PasswordTrackerPersistence.class)
904 protected PasswordTrackerPersistence passwordTrackerPersistence;
905 @BeanReference(type = PermissionPersistence.class)
906 protected PermissionPersistence permissionPersistence;
907 @BeanReference(type = PhonePersistence.class)
908 protected PhonePersistence phonePersistence;
909 @BeanReference(type = PluginSettingPersistence.class)
910 protected PluginSettingPersistence pluginSettingPersistence;
911 @BeanReference(type = PortletPersistence.class)
912 protected PortletPersistence portletPersistence;
913 @BeanReference(type = PortletItemPersistence.class)
914 protected PortletItemPersistence portletItemPersistence;
915 @BeanReference(type = PortletPreferencesPersistence.class)
916 protected PortletPreferencesPersistence portletPreferencesPersistence;
917 @BeanReference(type = RegionPersistence.class)
918 protected RegionPersistence regionPersistence;
919 @BeanReference(type = ReleasePersistence.class)
920 protected ReleasePersistence releasePersistence;
921 @BeanReference(type = ResourcePersistence.class)
922 protected ResourcePersistence resourcePersistence;
923 @BeanReference(type = ResourceActionPersistence.class)
924 protected ResourceActionPersistence resourceActionPersistence;
925 @BeanReference(type = ResourceCodePersistence.class)
926 protected ResourceCodePersistence resourceCodePersistence;
927 @BeanReference(type = ResourcePermissionPersistence.class)
928 protected ResourcePermissionPersistence resourcePermissionPersistence;
929 @BeanReference(type = RolePersistence.class)
930 protected RolePersistence rolePersistence;
931 @BeanReference(type = ServiceComponentPersistence.class)
932 protected ServiceComponentPersistence serviceComponentPersistence;
933 @BeanReference(type = ShardPersistence.class)
934 protected ShardPersistence shardPersistence;
935 @BeanReference(type = SubscriptionPersistence.class)
936 protected SubscriptionPersistence subscriptionPersistence;
937 @BeanReference(type = TicketPersistence.class)
938 protected TicketPersistence ticketPersistence;
939 @BeanReference(type = TeamPersistence.class)
940 protected TeamPersistence teamPersistence;
941 @BeanReference(type = UserPersistence.class)
942 protected UserPersistence userPersistence;
943 @BeanReference(type = UserGroupPersistence.class)
944 protected UserGroupPersistence userGroupPersistence;
945 @BeanReference(type = UserGroupGroupRolePersistence.class)
946 protected UserGroupGroupRolePersistence userGroupGroupRolePersistence;
947 @BeanReference(type = UserGroupRolePersistence.class)
948 protected UserGroupRolePersistence userGroupRolePersistence;
949 @BeanReference(type = UserIdMapperPersistence.class)
950 protected UserIdMapperPersistence userIdMapperPersistence;
951 @BeanReference(type = UserTrackerPersistence.class)
952 protected UserTrackerPersistence userTrackerPersistence;
953 @BeanReference(type = UserTrackerPathPersistence.class)
954 protected UserTrackerPathPersistence userTrackerPathPersistence;
955 @BeanReference(type = WebDAVPropsPersistence.class)
956 protected WebDAVPropsPersistence webDAVPropsPersistence;
957 @BeanReference(type = WebsitePersistence.class)
958 protected WebsitePersistence websitePersistence;
959 @BeanReference(type = WorkflowDefinitionLinkPersistence.class)
960 protected WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
961 @BeanReference(type = WorkflowInstanceLinkPersistence.class)
962 protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
963 private static final String _SQL_SELECT_WORKFLOWINSTANCELINK = "SELECT workflowInstanceLink FROM WorkflowInstanceLink workflowInstanceLink";
964 private static final String _SQL_SELECT_WORKFLOWINSTANCELINK_WHERE = "SELECT workflowInstanceLink FROM WorkflowInstanceLink workflowInstanceLink WHERE ";
965 private static final String _SQL_COUNT_WORKFLOWINSTANCELINK = "SELECT COUNT(workflowInstanceLink) FROM WorkflowInstanceLink workflowInstanceLink";
966 private static final String _SQL_COUNT_WORKFLOWINSTANCELINK_WHERE = "SELECT COUNT(workflowInstanceLink) FROM WorkflowInstanceLink workflowInstanceLink WHERE ";
967 private static final String _FINDER_COLUMN_G_C_C_C_GROUPID_2 = "workflowInstanceLink.groupId = ? AND ";
968 private static final String _FINDER_COLUMN_G_C_C_C_COMPANYID_2 = "workflowInstanceLink.companyId = ? AND ";
969 private static final String _FINDER_COLUMN_G_C_C_C_CLASSNAMEID_2 = "workflowInstanceLink.classNameId = ? AND ";
970 private static final String _FINDER_COLUMN_G_C_C_C_CLASSPK_2 = "workflowInstanceLink.classPK = ?";
971 private static final String _ORDER_BY_ENTITY_ALIAS = "workflowInstanceLink.";
972 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No WorkflowInstanceLink exists with the primary key ";
973 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No WorkflowInstanceLink exists with the key {";
974 private static Log _log = LogFactoryUtil.getLog(WorkflowInstanceLinkPersistenceImpl.class);
975 }