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