001    /**
002     * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
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    /**
051     * The persistence implementation for the workflow instance link service.
052     *
053     * <p>
054     * Caching information and settings can be found in <code>portal.properties</code>
055     * </p>
056     *
057     * @author Brian Wing Shun Chan
058     * @see WorkflowInstanceLinkPersistence
059     * @see WorkflowInstanceLinkUtil
060     * @generated
061     */
062    public class WorkflowInstanceLinkPersistenceImpl extends BasePersistenceImpl<WorkflowInstanceLink>
063            implements WorkflowInstanceLinkPersistence {
064            /*
065             * NOTE FOR DEVELOPERS:
066             *
067             * Never modify or reference this class directly. Always use {@link WorkflowInstanceLinkUtil} to access the workflow instance link persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
068             */
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_WITHOUT_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_WITH_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            /**
118             * Caches the workflow instance link in the entity cache if it is enabled.
119             *
120             * @param workflowInstanceLink the workflow instance link
121             */
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            /**
131             * Caches the workflow instance links in the entity cache if it is enabled.
132             *
133             * @param workflowInstanceLinks the workflow instance links
134             */
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            /**
150             * Clears the cache for all workflow instance links.
151             *
152             * <p>
153             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
154             * </p>
155             */
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            /**
170             * Clears the cache for the workflow instance link.
171             *
172             * <p>
173             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
174             * </p>
175             */
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            /**
186             * Creates a new workflow instance link with the primary key. Does not add the workflow instance link to the database.
187             *
188             * @param workflowInstanceLinkId the primary key for the new workflow instance link
189             * @return the new workflow instance link
190             */
191            public WorkflowInstanceLink create(long workflowInstanceLinkId) {
192                    WorkflowInstanceLink workflowInstanceLink = new WorkflowInstanceLinkImpl();
193    
194                    workflowInstanceLink.setNew(true);
195                    workflowInstanceLink.setPrimaryKey(workflowInstanceLinkId);
196    
197                    return workflowInstanceLink;
198            }
199    
200            /**
201             * Removes the workflow instance link with the primary key from the database. Also notifies the appropriate model listeners.
202             *
203             * @param primaryKey the primary key of the workflow instance link
204             * @return the workflow instance link that was removed
205             * @throws com.liferay.portal.NoSuchModelException if a workflow instance link with the primary key could not be found
206             * @throws SystemException if a system exception occurred
207             */
208            @Override
209            public WorkflowInstanceLink remove(Serializable primaryKey)
210                    throws NoSuchModelException, SystemException {
211                    return remove(((Long)primaryKey).longValue());
212            }
213    
214            /**
215             * Removes the workflow instance link with the primary key from the database. Also notifies the appropriate model listeners.
216             *
217             * @param workflowInstanceLinkId the primary key of the workflow instance link
218             * @return the workflow instance link that was removed
219             * @throws com.liferay.portal.NoSuchWorkflowInstanceLinkException if a workflow instance link with the primary key could not be found
220             * @throws SystemException if a system exception occurred
221             */
222            public WorkflowInstanceLink remove(long workflowInstanceLinkId)
223                    throws NoSuchWorkflowInstanceLinkException, SystemException {
224                    Session session = null;
225    
226                    try {
227                            session = openSession();
228    
229                            WorkflowInstanceLink workflowInstanceLink = (WorkflowInstanceLink)session.get(WorkflowInstanceLinkImpl.class,
230                                            Long.valueOf(workflowInstanceLinkId));
231    
232                            if (workflowInstanceLink == null) {
233                                    if (_log.isWarnEnabled()) {
234                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
235                                                    workflowInstanceLinkId);
236                                    }
237    
238                                    throw new NoSuchWorkflowInstanceLinkException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
239                                            workflowInstanceLinkId);
240                            }
241    
242                            return workflowInstanceLinkPersistence.remove(workflowInstanceLink);
243                    }
244                    catch (NoSuchWorkflowInstanceLinkException nsee) {
245                            throw nsee;
246                    }
247                    catch (Exception e) {
248                            throw processException(e);
249                    }
250                    finally {
251                            closeSession(session);
252                    }
253            }
254    
255            /**
256             * Removes the workflow instance link from the database. Also notifies the appropriate model listeners.
257             *
258             * @param workflowInstanceLink the workflow instance link
259             * @return the workflow instance link that was removed
260             * @throws SystemException if a system exception occurred
261             */
262            @Override
263            public WorkflowInstanceLink remove(
264                    WorkflowInstanceLink workflowInstanceLink) throws SystemException {
265                    return super.remove(workflowInstanceLink);
266            }
267    
268            @Override
269            protected WorkflowInstanceLink removeImpl(
270                    WorkflowInstanceLink workflowInstanceLink) throws SystemException {
271                    workflowInstanceLink = toUnwrappedModel(workflowInstanceLink);
272    
273                    Session session = null;
274    
275                    try {
276                            session = openSession();
277    
278                            BatchSessionUtil.delete(session, workflowInstanceLink);
279                    }
280                    catch (Exception e) {
281                            throw processException(e);
282                    }
283                    finally {
284                            closeSession(session);
285                    }
286    
287                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
288                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
289    
290                    EntityCacheUtil.removeResult(WorkflowInstanceLinkModelImpl.ENTITY_CACHE_ENABLED,
291                            WorkflowInstanceLinkImpl.class, workflowInstanceLink.getPrimaryKey());
292    
293                    return workflowInstanceLink;
294            }
295    
296            @Override
297            public WorkflowInstanceLink updateImpl(
298                    com.liferay.portal.model.WorkflowInstanceLink workflowInstanceLink,
299                    boolean merge) throws SystemException {
300                    workflowInstanceLink = toUnwrappedModel(workflowInstanceLink);
301    
302                    boolean isNew = workflowInstanceLink.isNew();
303    
304                    WorkflowInstanceLinkModelImpl workflowInstanceLinkModelImpl = (WorkflowInstanceLinkModelImpl)workflowInstanceLink;
305    
306                    Session session = null;
307    
308                    try {
309                            session = openSession();
310    
311                            BatchSessionUtil.update(session, workflowInstanceLink, merge);
312    
313                            workflowInstanceLink.setNew(false);
314                    }
315                    catch (Exception e) {
316                            throw processException(e);
317                    }
318                    finally {
319                            closeSession(session);
320                    }
321    
322                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
323    
324                    if (isNew || !WorkflowInstanceLinkModelImpl.COLUMN_BITMASK_ENABLED) {
325                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
326                    }
327    
328                    else {
329                            if ((workflowInstanceLinkModelImpl.getColumnBitmask() &
330                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C_C.getColumnBitmask()) != 0) {
331                                    Object[] args = new Object[] {
332                                                    Long.valueOf(workflowInstanceLinkModelImpl.getOriginalGroupId()),
333                                                    Long.valueOf(workflowInstanceLinkModelImpl.getOriginalCompanyId()),
334                                                    Long.valueOf(workflowInstanceLinkModelImpl.getOriginalClassNameId()),
335                                                    Long.valueOf(workflowInstanceLinkModelImpl.getOriginalClassPK())
336                                            };
337    
338                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_C_C, args);
339                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C_C,
340                                            args);
341    
342                                    args = new Object[] {
343                                                    Long.valueOf(workflowInstanceLinkModelImpl.getGroupId()),
344                                                    Long.valueOf(workflowInstanceLinkModelImpl.getCompanyId()),
345                                                    Long.valueOf(workflowInstanceLinkModelImpl.getClassNameId()),
346                                                    Long.valueOf(workflowInstanceLinkModelImpl.getClassPK())
347                                            };
348    
349                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_C_C, args);
350                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C_C,
351                                            args);
352                            }
353                    }
354    
355                    EntityCacheUtil.putResult(WorkflowInstanceLinkModelImpl.ENTITY_CACHE_ENABLED,
356                            WorkflowInstanceLinkImpl.class,
357                            workflowInstanceLink.getPrimaryKey(), workflowInstanceLink);
358    
359                    return workflowInstanceLink;
360            }
361    
362            protected WorkflowInstanceLink toUnwrappedModel(
363                    WorkflowInstanceLink workflowInstanceLink) {
364                    if (workflowInstanceLink instanceof WorkflowInstanceLinkImpl) {
365                            return workflowInstanceLink;
366                    }
367    
368                    WorkflowInstanceLinkImpl workflowInstanceLinkImpl = new WorkflowInstanceLinkImpl();
369    
370                    workflowInstanceLinkImpl.setNew(workflowInstanceLink.isNew());
371                    workflowInstanceLinkImpl.setPrimaryKey(workflowInstanceLink.getPrimaryKey());
372    
373                    workflowInstanceLinkImpl.setWorkflowInstanceLinkId(workflowInstanceLink.getWorkflowInstanceLinkId());
374                    workflowInstanceLinkImpl.setGroupId(workflowInstanceLink.getGroupId());
375                    workflowInstanceLinkImpl.setCompanyId(workflowInstanceLink.getCompanyId());
376                    workflowInstanceLinkImpl.setUserId(workflowInstanceLink.getUserId());
377                    workflowInstanceLinkImpl.setUserName(workflowInstanceLink.getUserName());
378                    workflowInstanceLinkImpl.setCreateDate(workflowInstanceLink.getCreateDate());
379                    workflowInstanceLinkImpl.setModifiedDate(workflowInstanceLink.getModifiedDate());
380                    workflowInstanceLinkImpl.setClassNameId(workflowInstanceLink.getClassNameId());
381                    workflowInstanceLinkImpl.setClassPK(workflowInstanceLink.getClassPK());
382                    workflowInstanceLinkImpl.setWorkflowInstanceId(workflowInstanceLink.getWorkflowInstanceId());
383    
384                    return workflowInstanceLinkImpl;
385            }
386    
387            /**
388             * Returns the workflow instance link with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
389             *
390             * @param primaryKey the primary key of the workflow instance link
391             * @return the workflow instance link
392             * @throws com.liferay.portal.NoSuchModelException if a workflow instance link with the primary key could not be found
393             * @throws SystemException if a system exception occurred
394             */
395            @Override
396            public WorkflowInstanceLink findByPrimaryKey(Serializable primaryKey)
397                    throws NoSuchModelException, SystemException {
398                    return findByPrimaryKey(((Long)primaryKey).longValue());
399            }
400    
401            /**
402             * Returns the workflow instance link with the primary key or throws a {@link com.liferay.portal.NoSuchWorkflowInstanceLinkException} if it could not be found.
403             *
404             * @param workflowInstanceLinkId the primary key of the workflow instance link
405             * @return the workflow instance link
406             * @throws com.liferay.portal.NoSuchWorkflowInstanceLinkException if a workflow instance link with the primary key could not be found
407             * @throws SystemException if a system exception occurred
408             */
409            public WorkflowInstanceLink findByPrimaryKey(long workflowInstanceLinkId)
410                    throws NoSuchWorkflowInstanceLinkException, SystemException {
411                    WorkflowInstanceLink workflowInstanceLink = fetchByPrimaryKey(workflowInstanceLinkId);
412    
413                    if (workflowInstanceLink == null) {
414                            if (_log.isWarnEnabled()) {
415                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
416                                            workflowInstanceLinkId);
417                            }
418    
419                            throw new NoSuchWorkflowInstanceLinkException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
420                                    workflowInstanceLinkId);
421                    }
422    
423                    return workflowInstanceLink;
424            }
425    
426            /**
427             * Returns the workflow instance link with the primary key or returns <code>null</code> if it could not be found.
428             *
429             * @param primaryKey the primary key of the workflow instance link
430             * @return the workflow instance link, or <code>null</code> if a workflow instance link with the primary key could not be found
431             * @throws SystemException if a system exception occurred
432             */
433            @Override
434            public WorkflowInstanceLink fetchByPrimaryKey(Serializable primaryKey)
435                    throws SystemException {
436                    return fetchByPrimaryKey(((Long)primaryKey).longValue());
437            }
438    
439            /**
440             * Returns the workflow instance link with the primary key or returns <code>null</code> if it could not be found.
441             *
442             * @param workflowInstanceLinkId the primary key of the workflow instance link
443             * @return the workflow instance link, or <code>null</code> if a workflow instance link with the primary key could not be found
444             * @throws SystemException if a system exception occurred
445             */
446            public WorkflowInstanceLink fetchByPrimaryKey(long workflowInstanceLinkId)
447                    throws SystemException {
448                    WorkflowInstanceLink workflowInstanceLink = (WorkflowInstanceLink)EntityCacheUtil.getResult(WorkflowInstanceLinkModelImpl.ENTITY_CACHE_ENABLED,
449                                    WorkflowInstanceLinkImpl.class, workflowInstanceLinkId);
450    
451                    if (workflowInstanceLink == _nullWorkflowInstanceLink) {
452                            return null;
453                    }
454    
455                    if (workflowInstanceLink == null) {
456                            Session session = null;
457    
458                            boolean hasException = false;
459    
460                            try {
461                                    session = openSession();
462    
463                                    workflowInstanceLink = (WorkflowInstanceLink)session.get(WorkflowInstanceLinkImpl.class,
464                                                    Long.valueOf(workflowInstanceLinkId));
465                            }
466                            catch (Exception e) {
467                                    hasException = true;
468    
469                                    throw processException(e);
470                            }
471                            finally {
472                                    if (workflowInstanceLink != null) {
473                                            cacheResult(workflowInstanceLink);
474                                    }
475                                    else if (!hasException) {
476                                            EntityCacheUtil.putResult(WorkflowInstanceLinkModelImpl.ENTITY_CACHE_ENABLED,
477                                                    WorkflowInstanceLinkImpl.class, workflowInstanceLinkId,
478                                                    _nullWorkflowInstanceLink);
479                                    }
480    
481                                    closeSession(session);
482                            }
483                    }
484    
485                    return workflowInstanceLink;
486            }
487    
488            /**
489             * Returns all the workflow instance links where groupId = &#63; and companyId = &#63; and classNameId = &#63; and classPK = &#63;.
490             *
491             * @param groupId the group ID
492             * @param companyId the company ID
493             * @param classNameId the class name ID
494             * @param classPK the class p k
495             * @return the matching workflow instance links
496             * @throws SystemException if a system exception occurred
497             */
498            public List<WorkflowInstanceLink> findByG_C_C_C(long groupId,
499                    long companyId, long classNameId, long classPK)
500                    throws SystemException {
501                    return findByG_C_C_C(groupId, companyId, classNameId, classPK,
502                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
503            }
504    
505            /**
506             * Returns a range of all the workflow instance links where groupId = &#63; and companyId = &#63; and classNameId = &#63; and classPK = &#63;.
507             *
508             * <p>
509             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
510             * </p>
511             *
512             * @param groupId the group ID
513             * @param companyId the company ID
514             * @param classNameId the class name ID
515             * @param classPK the class p k
516             * @param start the lower bound of the range of workflow instance links
517             * @param end the upper bound of the range of workflow instance links (not inclusive)
518             * @return the range of matching workflow instance links
519             * @throws SystemException if a system exception occurred
520             */
521            public List<WorkflowInstanceLink> findByG_C_C_C(long groupId,
522                    long companyId, long classNameId, long classPK, int start, int end)
523                    throws SystemException {
524                    return findByG_C_C_C(groupId, companyId, classNameId, classPK, start,
525                            end, null);
526            }
527    
528            /**
529             * Returns an ordered range of all the workflow instance links where groupId = &#63; and companyId = &#63; and classNameId = &#63; and classPK = &#63;.
530             *
531             * <p>
532             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
533             * </p>
534             *
535             * @param groupId the group ID
536             * @param companyId the company ID
537             * @param classNameId the class name ID
538             * @param classPK the class p k
539             * @param start the lower bound of the range of workflow instance links
540             * @param end the upper bound of the range of workflow instance links (not inclusive)
541             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
542             * @return the ordered range of matching workflow instance links
543             * @throws SystemException if a system exception occurred
544             */
545            public List<WorkflowInstanceLink> findByG_C_C_C(long groupId,
546                    long companyId, long classNameId, long classPK, int start, int end,
547                    OrderByComparator orderByComparator) throws SystemException {
548                    FinderPath finderPath = null;
549                    Object[] finderArgs = null;
550    
551                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
552                                    (orderByComparator == null)) {
553                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_C_C;
554                            finderArgs = new Object[] { groupId, companyId, classNameId, classPK };
555                    }
556                    else {
557                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_C_C;
558                            finderArgs = new Object[] {
559                                            groupId, companyId, classNameId, classPK,
560                                            
561                                            start, end, orderByComparator
562                                    };
563                    }
564    
565                    List<WorkflowInstanceLink> list = (List<WorkflowInstanceLink>)FinderCacheUtil.getResult(finderPath,
566                                    finderArgs, this);
567    
568                    if (list == null) {
569                            StringBundler query = null;
570    
571                            if (orderByComparator != null) {
572                                    query = new StringBundler(6 +
573                                                    (orderByComparator.getOrderByFields().length * 3));
574                            }
575                            else {
576                                    query = new StringBundler(6);
577                            }
578    
579                            query.append(_SQL_SELECT_WORKFLOWINSTANCELINK_WHERE);
580    
581                            query.append(_FINDER_COLUMN_G_C_C_C_GROUPID_2);
582    
583                            query.append(_FINDER_COLUMN_G_C_C_C_COMPANYID_2);
584    
585                            query.append(_FINDER_COLUMN_G_C_C_C_CLASSNAMEID_2);
586    
587                            query.append(_FINDER_COLUMN_G_C_C_C_CLASSPK_2);
588    
589                            if (orderByComparator != null) {
590                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
591                                            orderByComparator);
592                            }
593    
594                            else {
595                                    query.append(WorkflowInstanceLinkModelImpl.ORDER_BY_JPQL);
596                            }
597    
598                            String sql = query.toString();
599    
600                            Session session = null;
601    
602                            try {
603                                    session = openSession();
604    
605                                    Query q = session.createQuery(sql);
606    
607                                    QueryPos qPos = QueryPos.getInstance(q);
608    
609                                    qPos.add(groupId);
610    
611                                    qPos.add(companyId);
612    
613                                    qPos.add(classNameId);
614    
615                                    qPos.add(classPK);
616    
617                                    list = (List<WorkflowInstanceLink>)QueryUtil.list(q,
618                                                    getDialect(), start, end);
619                            }
620                            catch (Exception e) {
621                                    throw processException(e);
622                            }
623                            finally {
624                                    if (list == null) {
625                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
626                                    }
627                                    else {
628                                            cacheResult(list);
629    
630                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
631                                    }
632    
633                                    closeSession(session);
634                            }
635                    }
636    
637                    return list;
638            }
639    
640            /**
641             * Returns the first workflow instance link in the ordered set where groupId = &#63; and companyId = &#63; and classNameId = &#63; and classPK = &#63;.
642             *
643             * <p>
644             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
645             * </p>
646             *
647             * @param groupId the group ID
648             * @param companyId the company ID
649             * @param classNameId the class name ID
650             * @param classPK the class p k
651             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
652             * @return the first matching workflow instance link
653             * @throws com.liferay.portal.NoSuchWorkflowInstanceLinkException if a matching workflow instance link could not be found
654             * @throws SystemException if a system exception occurred
655             */
656            public WorkflowInstanceLink findByG_C_C_C_First(long groupId,
657                    long companyId, long classNameId, long classPK,
658                    OrderByComparator orderByComparator)
659                    throws NoSuchWorkflowInstanceLinkException, SystemException {
660                    List<WorkflowInstanceLink> list = findByG_C_C_C(groupId, companyId,
661                                    classNameId, classPK, 0, 1, orderByComparator);
662    
663                    if (list.isEmpty()) {
664                            StringBundler msg = new StringBundler(10);
665    
666                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
667    
668                            msg.append("groupId=");
669                            msg.append(groupId);
670    
671                            msg.append(", companyId=");
672                            msg.append(companyId);
673    
674                            msg.append(", classNameId=");
675                            msg.append(classNameId);
676    
677                            msg.append(", classPK=");
678                            msg.append(classPK);
679    
680                            msg.append(StringPool.CLOSE_CURLY_BRACE);
681    
682                            throw new NoSuchWorkflowInstanceLinkException(msg.toString());
683                    }
684                    else {
685                            return list.get(0);
686                    }
687            }
688    
689            /**
690             * Returns the last workflow instance link in the ordered set where groupId = &#63; and companyId = &#63; and classNameId = &#63; and classPK = &#63;.
691             *
692             * <p>
693             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
694             * </p>
695             *
696             * @param groupId the group ID
697             * @param companyId the company ID
698             * @param classNameId the class name ID
699             * @param classPK the class p k
700             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
701             * @return the last matching workflow instance link
702             * @throws com.liferay.portal.NoSuchWorkflowInstanceLinkException if a matching workflow instance link could not be found
703             * @throws SystemException if a system exception occurred
704             */
705            public WorkflowInstanceLink findByG_C_C_C_Last(long groupId,
706                    long companyId, long classNameId, long classPK,
707                    OrderByComparator orderByComparator)
708                    throws NoSuchWorkflowInstanceLinkException, SystemException {
709                    int count = countByG_C_C_C(groupId, companyId, classNameId, classPK);
710    
711                    List<WorkflowInstanceLink> list = findByG_C_C_C(groupId, companyId,
712                                    classNameId, classPK, count - 1, count, orderByComparator);
713    
714                    if (list.isEmpty()) {
715                            StringBundler msg = new StringBundler(10);
716    
717                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
718    
719                            msg.append("groupId=");
720                            msg.append(groupId);
721    
722                            msg.append(", companyId=");
723                            msg.append(companyId);
724    
725                            msg.append(", classNameId=");
726                            msg.append(classNameId);
727    
728                            msg.append(", classPK=");
729                            msg.append(classPK);
730    
731                            msg.append(StringPool.CLOSE_CURLY_BRACE);
732    
733                            throw new NoSuchWorkflowInstanceLinkException(msg.toString());
734                    }
735                    else {
736                            return list.get(0);
737                    }
738            }
739    
740            /**
741             * Returns the workflow instance links before and after the current workflow instance link in the ordered set where groupId = &#63; and companyId = &#63; and classNameId = &#63; and classPK = &#63;.
742             *
743             * <p>
744             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
745             * </p>
746             *
747             * @param workflowInstanceLinkId the primary key of the current workflow instance link
748             * @param groupId the group ID
749             * @param companyId the company ID
750             * @param classNameId the class name ID
751             * @param classPK the class p k
752             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
753             * @return the previous, current, and next workflow instance link
754             * @throws com.liferay.portal.NoSuchWorkflowInstanceLinkException if a workflow instance link with the primary key could not be found
755             * @throws SystemException if a system exception occurred
756             */
757            public WorkflowInstanceLink[] findByG_C_C_C_PrevAndNext(
758                    long workflowInstanceLinkId, long groupId, long companyId,
759                    long classNameId, long classPK, OrderByComparator orderByComparator)
760                    throws NoSuchWorkflowInstanceLinkException, SystemException {
761                    WorkflowInstanceLink workflowInstanceLink = findByPrimaryKey(workflowInstanceLinkId);
762    
763                    Session session = null;
764    
765                    try {
766                            session = openSession();
767    
768                            WorkflowInstanceLink[] array = new WorkflowInstanceLinkImpl[3];
769    
770                            array[0] = getByG_C_C_C_PrevAndNext(session, workflowInstanceLink,
771                                            groupId, companyId, classNameId, classPK,
772                                            orderByComparator, true);
773    
774                            array[1] = workflowInstanceLink;
775    
776                            array[2] = getByG_C_C_C_PrevAndNext(session, workflowInstanceLink,
777                                            groupId, companyId, classNameId, classPK,
778                                            orderByComparator, false);
779    
780                            return array;
781                    }
782                    catch (Exception e) {
783                            throw processException(e);
784                    }
785                    finally {
786                            closeSession(session);
787                    }
788            }
789    
790            protected WorkflowInstanceLink getByG_C_C_C_PrevAndNext(Session session,
791                    WorkflowInstanceLink workflowInstanceLink, long groupId,
792                    long companyId, long classNameId, long classPK,
793                    OrderByComparator orderByComparator, boolean previous) {
794                    StringBundler query = null;
795    
796                    if (orderByComparator != null) {
797                            query = new StringBundler(6 +
798                                            (orderByComparator.getOrderByFields().length * 6));
799                    }
800                    else {
801                            query = new StringBundler(3);
802                    }
803    
804                    query.append(_SQL_SELECT_WORKFLOWINSTANCELINK_WHERE);
805    
806                    query.append(_FINDER_COLUMN_G_C_C_C_GROUPID_2);
807    
808                    query.append(_FINDER_COLUMN_G_C_C_C_COMPANYID_2);
809    
810                    query.append(_FINDER_COLUMN_G_C_C_C_CLASSNAMEID_2);
811    
812                    query.append(_FINDER_COLUMN_G_C_C_C_CLASSPK_2);
813    
814                    if (orderByComparator != null) {
815                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
816    
817                            if (orderByConditionFields.length > 0) {
818                                    query.append(WHERE_AND);
819                            }
820    
821                            for (int i = 0; i < orderByConditionFields.length; i++) {
822                                    query.append(_ORDER_BY_ENTITY_ALIAS);
823                                    query.append(orderByConditionFields[i]);
824    
825                                    if ((i + 1) < orderByConditionFields.length) {
826                                            if (orderByComparator.isAscending() ^ previous) {
827                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
828                                            }
829                                            else {
830                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
831                                            }
832                                    }
833                                    else {
834                                            if (orderByComparator.isAscending() ^ previous) {
835                                                    query.append(WHERE_GREATER_THAN);
836                                            }
837                                            else {
838                                                    query.append(WHERE_LESSER_THAN);
839                                            }
840                                    }
841                            }
842    
843                            query.append(ORDER_BY_CLAUSE);
844    
845                            String[] orderByFields = orderByComparator.getOrderByFields();
846    
847                            for (int i = 0; i < orderByFields.length; i++) {
848                                    query.append(_ORDER_BY_ENTITY_ALIAS);
849                                    query.append(orderByFields[i]);
850    
851                                    if ((i + 1) < orderByFields.length) {
852                                            if (orderByComparator.isAscending() ^ previous) {
853                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
854                                            }
855                                            else {
856                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
857                                            }
858                                    }
859                                    else {
860                                            if (orderByComparator.isAscending() ^ previous) {
861                                                    query.append(ORDER_BY_ASC);
862                                            }
863                                            else {
864                                                    query.append(ORDER_BY_DESC);
865                                            }
866                                    }
867                            }
868                    }
869    
870                    else {
871                            query.append(WorkflowInstanceLinkModelImpl.ORDER_BY_JPQL);
872                    }
873    
874                    String sql = query.toString();
875    
876                    Query q = session.createQuery(sql);
877    
878                    q.setFirstResult(0);
879                    q.setMaxResults(2);
880    
881                    QueryPos qPos = QueryPos.getInstance(q);
882    
883                    qPos.add(groupId);
884    
885                    qPos.add(companyId);
886    
887                    qPos.add(classNameId);
888    
889                    qPos.add(classPK);
890    
891                    if (orderByComparator != null) {
892                            Object[] values = orderByComparator.getOrderByConditionValues(workflowInstanceLink);
893    
894                            for (Object value : values) {
895                                    qPos.add(value);
896                            }
897                    }
898    
899                    List<WorkflowInstanceLink> list = q.list();
900    
901                    if (list.size() == 2) {
902                            return list.get(1);
903                    }
904                    else {
905                            return null;
906                    }
907            }
908    
909            /**
910             * Returns all the workflow instance links.
911             *
912             * @return the workflow instance links
913             * @throws SystemException if a system exception occurred
914             */
915            public List<WorkflowInstanceLink> findAll() throws SystemException {
916                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
917            }
918    
919            /**
920             * Returns a range of all the workflow instance links.
921             *
922             * <p>
923             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
924             * </p>
925             *
926             * @param start the lower bound of the range of workflow instance links
927             * @param end the upper bound of the range of workflow instance links (not inclusive)
928             * @return the range of workflow instance links
929             * @throws SystemException if a system exception occurred
930             */
931            public List<WorkflowInstanceLink> findAll(int start, int end)
932                    throws SystemException {
933                    return findAll(start, end, null);
934            }
935    
936            /**
937             * Returns an ordered range of all the workflow instance links.
938             *
939             * <p>
940             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
941             * </p>
942             *
943             * @param start the lower bound of the range of workflow instance links
944             * @param end the upper bound of the range of workflow instance links (not inclusive)
945             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
946             * @return the ordered range of workflow instance links
947             * @throws SystemException if a system exception occurred
948             */
949            public List<WorkflowInstanceLink> findAll(int start, int end,
950                    OrderByComparator orderByComparator) throws SystemException {
951                    FinderPath finderPath = null;
952                    Object[] finderArgs = new Object[] { start, end, orderByComparator };
953    
954                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
955                                    (orderByComparator == null)) {
956                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
957                            finderArgs = FINDER_ARGS_EMPTY;
958                    }
959                    else {
960                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
961                            finderArgs = new Object[] { start, end, orderByComparator };
962                    }
963    
964                    List<WorkflowInstanceLink> list = (List<WorkflowInstanceLink>)FinderCacheUtil.getResult(finderPath,
965                                    finderArgs, this);
966    
967                    if (list == null) {
968                            StringBundler query = null;
969                            String sql = null;
970    
971                            if (orderByComparator != null) {
972                                    query = new StringBundler(2 +
973                                                    (orderByComparator.getOrderByFields().length * 3));
974    
975                                    query.append(_SQL_SELECT_WORKFLOWINSTANCELINK);
976    
977                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
978                                            orderByComparator);
979    
980                                    sql = query.toString();
981                            }
982                            else {
983                                    sql = _SQL_SELECT_WORKFLOWINSTANCELINK.concat(WorkflowInstanceLinkModelImpl.ORDER_BY_JPQL);
984                            }
985    
986                            Session session = null;
987    
988                            try {
989                                    session = openSession();
990    
991                                    Query q = session.createQuery(sql);
992    
993                                    if (orderByComparator == null) {
994                                            list = (List<WorkflowInstanceLink>)QueryUtil.list(q,
995                                                            getDialect(), start, end, false);
996    
997                                            Collections.sort(list);
998                                    }
999                                    else {
1000                                            list = (List<WorkflowInstanceLink>)QueryUtil.list(q,
1001                                                            getDialect(), start, end);
1002                                    }
1003                            }
1004                            catch (Exception e) {
1005                                    throw processException(e);
1006                            }
1007                            finally {
1008                                    if (list == null) {
1009                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1010                                    }
1011                                    else {
1012                                            cacheResult(list);
1013    
1014                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1015                                    }
1016    
1017                                    closeSession(session);
1018                            }
1019                    }
1020    
1021                    return list;
1022            }
1023    
1024            /**
1025             * Removes all the workflow instance links where groupId = &#63; and companyId = &#63; and classNameId = &#63; and classPK = &#63; from the database.
1026             *
1027             * @param groupId the group ID
1028             * @param companyId the company ID
1029             * @param classNameId the class name ID
1030             * @param classPK the class p k
1031             * @throws SystemException if a system exception occurred
1032             */
1033            public void removeByG_C_C_C(long groupId, long companyId, long classNameId,
1034                    long classPK) throws SystemException {
1035                    for (WorkflowInstanceLink workflowInstanceLink : findByG_C_C_C(
1036                                    groupId, companyId, classNameId, classPK)) {
1037                            workflowInstanceLinkPersistence.remove(workflowInstanceLink);
1038                    }
1039            }
1040    
1041            /**
1042             * Removes all the workflow instance links from the database.
1043             *
1044             * @throws SystemException if a system exception occurred
1045             */
1046            public void removeAll() throws SystemException {
1047                    for (WorkflowInstanceLink workflowInstanceLink : findAll()) {
1048                            workflowInstanceLinkPersistence.remove(workflowInstanceLink);
1049                    }
1050            }
1051    
1052            /**
1053             * Returns the number of workflow instance links where groupId = &#63; and companyId = &#63; and classNameId = &#63; and classPK = &#63;.
1054             *
1055             * @param groupId the group ID
1056             * @param companyId the company ID
1057             * @param classNameId the class name ID
1058             * @param classPK the class p k
1059             * @return the number of matching workflow instance links
1060             * @throws SystemException if a system exception occurred
1061             */
1062            public int countByG_C_C_C(long groupId, long companyId, long classNameId,
1063                    long classPK) throws SystemException {
1064                    Object[] finderArgs = new Object[] {
1065                                    groupId, companyId, classNameId, classPK
1066                            };
1067    
1068                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_C_C_C,
1069                                    finderArgs, this);
1070    
1071                    if (count == null) {
1072                            StringBundler query = new StringBundler(5);
1073    
1074                            query.append(_SQL_COUNT_WORKFLOWINSTANCELINK_WHERE);
1075    
1076                            query.append(_FINDER_COLUMN_G_C_C_C_GROUPID_2);
1077    
1078                            query.append(_FINDER_COLUMN_G_C_C_C_COMPANYID_2);
1079    
1080                            query.append(_FINDER_COLUMN_G_C_C_C_CLASSNAMEID_2);
1081    
1082                            query.append(_FINDER_COLUMN_G_C_C_C_CLASSPK_2);
1083    
1084                            String sql = query.toString();
1085    
1086                            Session session = null;
1087    
1088                            try {
1089                                    session = openSession();
1090    
1091                                    Query q = session.createQuery(sql);
1092    
1093                                    QueryPos qPos = QueryPos.getInstance(q);
1094    
1095                                    qPos.add(groupId);
1096    
1097                                    qPos.add(companyId);
1098    
1099                                    qPos.add(classNameId);
1100    
1101                                    qPos.add(classPK);
1102    
1103                                    count = (Long)q.uniqueResult();
1104                            }
1105                            catch (Exception e) {
1106                                    throw processException(e);
1107                            }
1108                            finally {
1109                                    if (count == null) {
1110                                            count = Long.valueOf(0);
1111                                    }
1112    
1113                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_C_C_C,
1114                                            finderArgs, count);
1115    
1116                                    closeSession(session);
1117                            }
1118                    }
1119    
1120                    return count.intValue();
1121            }
1122    
1123            /**
1124             * Returns the number of workflow instance links.
1125             *
1126             * @return the number of workflow instance links
1127             * @throws SystemException if a system exception occurred
1128             */
1129            public int countAll() throws SystemException {
1130                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1131                                    FINDER_ARGS_EMPTY, this);
1132    
1133                    if (count == null) {
1134                            Session session = null;
1135    
1136                            try {
1137                                    session = openSession();
1138    
1139                                    Query q = session.createQuery(_SQL_COUNT_WORKFLOWINSTANCELINK);
1140    
1141                                    count = (Long)q.uniqueResult();
1142                            }
1143                            catch (Exception e) {
1144                                    throw processException(e);
1145                            }
1146                            finally {
1147                                    if (count == null) {
1148                                            count = Long.valueOf(0);
1149                                    }
1150    
1151                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
1152                                            FINDER_ARGS_EMPTY, count);
1153    
1154                                    closeSession(session);
1155                            }
1156                    }
1157    
1158                    return count.intValue();
1159            }
1160    
1161            /**
1162             * Initializes the workflow instance link persistence.
1163             */
1164            public void afterPropertiesSet() {
1165                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1166                                            com.liferay.portal.util.PropsUtil.get(
1167                                                    "value.object.listener.com.liferay.portal.model.WorkflowInstanceLink")));
1168    
1169                    if (listenerClassNames.length > 0) {
1170                            try {
1171                                    List<ModelListener<WorkflowInstanceLink>> listenersList = new ArrayList<ModelListener<WorkflowInstanceLink>>();
1172    
1173                                    for (String listenerClassName : listenerClassNames) {
1174                                            listenersList.add((ModelListener<WorkflowInstanceLink>)InstanceFactory.newInstance(
1175                                                            listenerClassName));
1176                                    }
1177    
1178                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1179                            }
1180                            catch (Exception e) {
1181                                    _log.error(e);
1182                            }
1183                    }
1184            }
1185    
1186            public void destroy() {
1187                    EntityCacheUtil.removeCache(WorkflowInstanceLinkImpl.class.getName());
1188                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
1189                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
1190            }
1191    
1192            @BeanReference(type = AccountPersistence.class)
1193            protected AccountPersistence accountPersistence;
1194            @BeanReference(type = AddressPersistence.class)
1195            protected AddressPersistence addressPersistence;
1196            @BeanReference(type = BrowserTrackerPersistence.class)
1197            protected BrowserTrackerPersistence browserTrackerPersistence;
1198            @BeanReference(type = ClassNamePersistence.class)
1199            protected ClassNamePersistence classNamePersistence;
1200            @BeanReference(type = ClusterGroupPersistence.class)
1201            protected ClusterGroupPersistence clusterGroupPersistence;
1202            @BeanReference(type = CompanyPersistence.class)
1203            protected CompanyPersistence companyPersistence;
1204            @BeanReference(type = ContactPersistence.class)
1205            protected ContactPersistence contactPersistence;
1206            @BeanReference(type = CountryPersistence.class)
1207            protected CountryPersistence countryPersistence;
1208            @BeanReference(type = EmailAddressPersistence.class)
1209            protected EmailAddressPersistence emailAddressPersistence;
1210            @BeanReference(type = GroupPersistence.class)
1211            protected GroupPersistence groupPersistence;
1212            @BeanReference(type = ImagePersistence.class)
1213            protected ImagePersistence imagePersistence;
1214            @BeanReference(type = LayoutPersistence.class)
1215            protected LayoutPersistence layoutPersistence;
1216            @BeanReference(type = LayoutBranchPersistence.class)
1217            protected LayoutBranchPersistence layoutBranchPersistence;
1218            @BeanReference(type = LayoutPrototypePersistence.class)
1219            protected LayoutPrototypePersistence layoutPrototypePersistence;
1220            @BeanReference(type = LayoutRevisionPersistence.class)
1221            protected LayoutRevisionPersistence layoutRevisionPersistence;
1222            @BeanReference(type = LayoutSetPersistence.class)
1223            protected LayoutSetPersistence layoutSetPersistence;
1224            @BeanReference(type = LayoutSetBranchPersistence.class)
1225            protected LayoutSetBranchPersistence layoutSetBranchPersistence;
1226            @BeanReference(type = LayoutSetPrototypePersistence.class)
1227            protected LayoutSetPrototypePersistence layoutSetPrototypePersistence;
1228            @BeanReference(type = ListTypePersistence.class)
1229            protected ListTypePersistence listTypePersistence;
1230            @BeanReference(type = LockPersistence.class)
1231            protected LockPersistence lockPersistence;
1232            @BeanReference(type = MembershipRequestPersistence.class)
1233            protected MembershipRequestPersistence membershipRequestPersistence;
1234            @BeanReference(type = OrganizationPersistence.class)
1235            protected OrganizationPersistence organizationPersistence;
1236            @BeanReference(type = OrgGroupPermissionPersistence.class)
1237            protected OrgGroupPermissionPersistence orgGroupPermissionPersistence;
1238            @BeanReference(type = OrgGroupRolePersistence.class)
1239            protected OrgGroupRolePersistence orgGroupRolePersistence;
1240            @BeanReference(type = OrgLaborPersistence.class)
1241            protected OrgLaborPersistence orgLaborPersistence;
1242            @BeanReference(type = PasswordPolicyPersistence.class)
1243            protected PasswordPolicyPersistence passwordPolicyPersistence;
1244            @BeanReference(type = PasswordPolicyRelPersistence.class)
1245            protected PasswordPolicyRelPersistence passwordPolicyRelPersistence;
1246            @BeanReference(type = PasswordTrackerPersistence.class)
1247            protected PasswordTrackerPersistence passwordTrackerPersistence;
1248            @BeanReference(type = PermissionPersistence.class)
1249            protected PermissionPersistence permissionPersistence;
1250            @BeanReference(type = PhonePersistence.class)
1251            protected PhonePersistence phonePersistence;
1252            @BeanReference(type = PluginSettingPersistence.class)
1253            protected PluginSettingPersistence pluginSettingPersistence;
1254            @BeanReference(type = PortalPreferencesPersistence.class)
1255            protected PortalPreferencesPersistence portalPreferencesPersistence;
1256            @BeanReference(type = PortletPersistence.class)
1257            protected PortletPersistence portletPersistence;
1258            @BeanReference(type = PortletItemPersistence.class)
1259            protected PortletItemPersistence portletItemPersistence;
1260            @BeanReference(type = PortletPreferencesPersistence.class)
1261            protected PortletPreferencesPersistence portletPreferencesPersistence;
1262            @BeanReference(type = RegionPersistence.class)
1263            protected RegionPersistence regionPersistence;
1264            @BeanReference(type = ReleasePersistence.class)
1265            protected ReleasePersistence releasePersistence;
1266            @BeanReference(type = RepositoryPersistence.class)
1267            protected RepositoryPersistence repositoryPersistence;
1268            @BeanReference(type = RepositoryEntryPersistence.class)
1269            protected RepositoryEntryPersistence repositoryEntryPersistence;
1270            @BeanReference(type = ResourcePersistence.class)
1271            protected ResourcePersistence resourcePersistence;
1272            @BeanReference(type = ResourceActionPersistence.class)
1273            protected ResourceActionPersistence resourceActionPersistence;
1274            @BeanReference(type = ResourceBlockPersistence.class)
1275            protected ResourceBlockPersistence resourceBlockPersistence;
1276            @BeanReference(type = ResourceBlockPermissionPersistence.class)
1277            protected ResourceBlockPermissionPersistence resourceBlockPermissionPersistence;
1278            @BeanReference(type = ResourceCodePersistence.class)
1279            protected ResourceCodePersistence resourceCodePersistence;
1280            @BeanReference(type = ResourcePermissionPersistence.class)
1281            protected ResourcePermissionPersistence resourcePermissionPersistence;
1282            @BeanReference(type = ResourceTypePermissionPersistence.class)
1283            protected ResourceTypePermissionPersistence resourceTypePermissionPersistence;
1284            @BeanReference(type = RolePersistence.class)
1285            protected RolePersistence rolePersistence;
1286            @BeanReference(type = ServiceComponentPersistence.class)
1287            protected ServiceComponentPersistence serviceComponentPersistence;
1288            @BeanReference(type = ShardPersistence.class)
1289            protected ShardPersistence shardPersistence;
1290            @BeanReference(type = SubscriptionPersistence.class)
1291            protected SubscriptionPersistence subscriptionPersistence;
1292            @BeanReference(type = TeamPersistence.class)
1293            protected TeamPersistence teamPersistence;
1294            @BeanReference(type = TicketPersistence.class)
1295            protected TicketPersistence ticketPersistence;
1296            @BeanReference(type = UserPersistence.class)
1297            protected UserPersistence userPersistence;
1298            @BeanReference(type = UserGroupPersistence.class)
1299            protected UserGroupPersistence userGroupPersistence;
1300            @BeanReference(type = UserGroupGroupRolePersistence.class)
1301            protected UserGroupGroupRolePersistence userGroupGroupRolePersistence;
1302            @BeanReference(type = UserGroupRolePersistence.class)
1303            protected UserGroupRolePersistence userGroupRolePersistence;
1304            @BeanReference(type = UserIdMapperPersistence.class)
1305            protected UserIdMapperPersistence userIdMapperPersistence;
1306            @BeanReference(type = UserNotificationEventPersistence.class)
1307            protected UserNotificationEventPersistence userNotificationEventPersistence;
1308            @BeanReference(type = UserTrackerPersistence.class)
1309            protected UserTrackerPersistence userTrackerPersistence;
1310            @BeanReference(type = UserTrackerPathPersistence.class)
1311            protected UserTrackerPathPersistence userTrackerPathPersistence;
1312            @BeanReference(type = VirtualHostPersistence.class)
1313            protected VirtualHostPersistence virtualHostPersistence;
1314            @BeanReference(type = WebDAVPropsPersistence.class)
1315            protected WebDAVPropsPersistence webDAVPropsPersistence;
1316            @BeanReference(type = WebsitePersistence.class)
1317            protected WebsitePersistence websitePersistence;
1318            @BeanReference(type = WorkflowDefinitionLinkPersistence.class)
1319            protected WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
1320            @BeanReference(type = WorkflowInstanceLinkPersistence.class)
1321            protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
1322            private static final String _SQL_SELECT_WORKFLOWINSTANCELINK = "SELECT workflowInstanceLink FROM WorkflowInstanceLink workflowInstanceLink";
1323            private static final String _SQL_SELECT_WORKFLOWINSTANCELINK_WHERE = "SELECT workflowInstanceLink FROM WorkflowInstanceLink workflowInstanceLink WHERE ";
1324            private static final String _SQL_COUNT_WORKFLOWINSTANCELINK = "SELECT COUNT(workflowInstanceLink) FROM WorkflowInstanceLink workflowInstanceLink";
1325            private static final String _SQL_COUNT_WORKFLOWINSTANCELINK_WHERE = "SELECT COUNT(workflowInstanceLink) FROM WorkflowInstanceLink workflowInstanceLink WHERE ";
1326            private static final String _FINDER_COLUMN_G_C_C_C_GROUPID_2 = "workflowInstanceLink.groupId = ? AND ";
1327            private static final String _FINDER_COLUMN_G_C_C_C_COMPANYID_2 = "workflowInstanceLink.companyId = ? AND ";
1328            private static final String _FINDER_COLUMN_G_C_C_C_CLASSNAMEID_2 = "workflowInstanceLink.classNameId = ? AND ";
1329            private static final String _FINDER_COLUMN_G_C_C_C_CLASSPK_2 = "workflowInstanceLink.classPK = ?";
1330            private static final String _ORDER_BY_ENTITY_ALIAS = "workflowInstanceLink.";
1331            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No WorkflowInstanceLink exists with the primary key ";
1332            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No WorkflowInstanceLink exists with the key {";
1333            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
1334            private static Log _log = LogFactoryUtil.getLog(WorkflowInstanceLinkPersistenceImpl.class);
1335            private static WorkflowInstanceLink _nullWorkflowInstanceLink = new WorkflowInstanceLinkImpl() {
1336                            @Override
1337                            public Object clone() {
1338                                    return this;
1339                            }
1340    
1341                            @Override
1342                            public CacheModel<WorkflowInstanceLink> toCacheModel() {
1343                                    return _nullWorkflowInstanceLinkCacheModel;
1344                            }
1345                    };
1346    
1347            private static CacheModel<WorkflowInstanceLink> _nullWorkflowInstanceLinkCacheModel =
1348                    new CacheModel<WorkflowInstanceLink>() {
1349                            public WorkflowInstanceLink toEntityModel() {
1350                                    return _nullWorkflowInstanceLink;
1351                            }
1352                    };
1353    }