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