001    /**
002     * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portal.service.persistence;
016    
017    import com.liferay.portal.NoSuchModelException;
018    import com.liferay.portal.NoSuchWorkflowDefinitionLinkException;
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.WorkflowDefinitionLink;
040    import com.liferay.portal.model.impl.WorkflowDefinitionLinkImpl;
041    import com.liferay.portal.model.impl.WorkflowDefinitionLinkModelImpl;
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 definition 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 WorkflowDefinitionLinkPersistence
059     * @see WorkflowDefinitionLinkUtil
060     * @generated
061     */
062    public class WorkflowDefinitionLinkPersistenceImpl extends BasePersistenceImpl<WorkflowDefinitionLink>
063            implements WorkflowDefinitionLinkPersistence {
064            /*
065             * NOTE FOR DEVELOPERS:
066             *
067             * Never modify or reference this class directly. Always use {@link WorkflowDefinitionLinkUtil} to access the workflow definition link persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
068             */
069            public static final String FINDER_CLASS_NAME_ENTITY = WorkflowDefinitionLinkImpl.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_COMPANYID =
075                    new FinderPath(WorkflowDefinitionLinkModelImpl.ENTITY_CACHE_ENABLED,
076                            WorkflowDefinitionLinkModelImpl.FINDER_CACHE_ENABLED,
077                            WorkflowDefinitionLinkImpl.class,
078                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByCompanyId",
079                            new String[] {
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_COMPANYID =
086                    new FinderPath(WorkflowDefinitionLinkModelImpl.ENTITY_CACHE_ENABLED,
087                            WorkflowDefinitionLinkModelImpl.FINDER_CACHE_ENABLED,
088                            WorkflowDefinitionLinkImpl.class,
089                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCompanyId",
090                            new String[] { Long.class.getName() },
091                            WorkflowDefinitionLinkModelImpl.COMPANYID_COLUMN_BITMASK);
092            public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(WorkflowDefinitionLinkModelImpl.ENTITY_CACHE_ENABLED,
093                            WorkflowDefinitionLinkModelImpl.FINDER_CACHE_ENABLED, Long.class,
094                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCompanyId",
095                            new String[] { Long.class.getName() });
096            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_W_W = new FinderPath(WorkflowDefinitionLinkModelImpl.ENTITY_CACHE_ENABLED,
097                            WorkflowDefinitionLinkModelImpl.FINDER_CACHE_ENABLED,
098                            WorkflowDefinitionLinkImpl.class,
099                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_W_W",
100                            new String[] {
101                                    Long.class.getName(), String.class.getName(),
102                                    Integer.class.getName(),
103                                    
104                            "java.lang.Integer", "java.lang.Integer",
105                                    "com.liferay.portal.kernel.util.OrderByComparator"
106                            });
107            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_W_W = new FinderPath(WorkflowDefinitionLinkModelImpl.ENTITY_CACHE_ENABLED,
108                            WorkflowDefinitionLinkModelImpl.FINDER_CACHE_ENABLED,
109                            WorkflowDefinitionLinkImpl.class,
110                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_W_W",
111                            new String[] {
112                                    Long.class.getName(), String.class.getName(),
113                                    Integer.class.getName()
114                            },
115                            WorkflowDefinitionLinkModelImpl.COMPANYID_COLUMN_BITMASK |
116                            WorkflowDefinitionLinkModelImpl.WORKFLOWDEFINITIONNAME_COLUMN_BITMASK |
117                            WorkflowDefinitionLinkModelImpl.WORKFLOWDEFINITIONVERSION_COLUMN_BITMASK);
118            public static final FinderPath FINDER_PATH_COUNT_BY_C_W_W = new FinderPath(WorkflowDefinitionLinkModelImpl.ENTITY_CACHE_ENABLED,
119                            WorkflowDefinitionLinkModelImpl.FINDER_CACHE_ENABLED, Long.class,
120                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_W_W",
121                            new String[] {
122                                    Long.class.getName(), String.class.getName(),
123                                    Integer.class.getName()
124                            });
125            public static final FinderPath FINDER_PATH_FETCH_BY_G_C_C_C_T = new FinderPath(WorkflowDefinitionLinkModelImpl.ENTITY_CACHE_ENABLED,
126                            WorkflowDefinitionLinkModelImpl.FINDER_CACHE_ENABLED,
127                            WorkflowDefinitionLinkImpl.class, FINDER_CLASS_NAME_ENTITY,
128                            "fetchByG_C_C_C_T",
129                            new String[] {
130                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
131                                    Long.class.getName(), Long.class.getName()
132                            },
133                            WorkflowDefinitionLinkModelImpl.GROUPID_COLUMN_BITMASK |
134                            WorkflowDefinitionLinkModelImpl.COMPANYID_COLUMN_BITMASK |
135                            WorkflowDefinitionLinkModelImpl.CLASSNAMEID_COLUMN_BITMASK |
136                            WorkflowDefinitionLinkModelImpl.CLASSPK_COLUMN_BITMASK |
137                            WorkflowDefinitionLinkModelImpl.TYPEPK_COLUMN_BITMASK);
138            public static final FinderPath FINDER_PATH_COUNT_BY_G_C_C_C_T = new FinderPath(WorkflowDefinitionLinkModelImpl.ENTITY_CACHE_ENABLED,
139                            WorkflowDefinitionLinkModelImpl.FINDER_CACHE_ENABLED, Long.class,
140                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_C_C_C_T",
141                            new String[] {
142                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
143                                    Long.class.getName(), Long.class.getName()
144                            });
145            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(WorkflowDefinitionLinkModelImpl.ENTITY_CACHE_ENABLED,
146                            WorkflowDefinitionLinkModelImpl.FINDER_CACHE_ENABLED,
147                            WorkflowDefinitionLinkImpl.class,
148                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
149            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(WorkflowDefinitionLinkModelImpl.ENTITY_CACHE_ENABLED,
150                            WorkflowDefinitionLinkModelImpl.FINDER_CACHE_ENABLED,
151                            WorkflowDefinitionLinkImpl.class,
152                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
153            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(WorkflowDefinitionLinkModelImpl.ENTITY_CACHE_ENABLED,
154                            WorkflowDefinitionLinkModelImpl.FINDER_CACHE_ENABLED, Long.class,
155                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
156    
157            /**
158             * Caches the workflow definition link in the entity cache if it is enabled.
159             *
160             * @param workflowDefinitionLink the workflow definition link
161             */
162            public void cacheResult(WorkflowDefinitionLink workflowDefinitionLink) {
163                    EntityCacheUtil.putResult(WorkflowDefinitionLinkModelImpl.ENTITY_CACHE_ENABLED,
164                            WorkflowDefinitionLinkImpl.class,
165                            workflowDefinitionLink.getPrimaryKey(), workflowDefinitionLink);
166    
167                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C_C_C_T,
168                            new Object[] {
169                                    Long.valueOf(workflowDefinitionLink.getGroupId()),
170                                    Long.valueOf(workflowDefinitionLink.getCompanyId()),
171                                    Long.valueOf(workflowDefinitionLink.getClassNameId()),
172                                    Long.valueOf(workflowDefinitionLink.getClassPK()),
173                                    Long.valueOf(workflowDefinitionLink.getTypePK())
174                            }, workflowDefinitionLink);
175    
176                    workflowDefinitionLink.resetOriginalValues();
177            }
178    
179            /**
180             * Caches the workflow definition links in the entity cache if it is enabled.
181             *
182             * @param workflowDefinitionLinks the workflow definition links
183             */
184            public void cacheResult(
185                    List<WorkflowDefinitionLink> workflowDefinitionLinks) {
186                    for (WorkflowDefinitionLink workflowDefinitionLink : workflowDefinitionLinks) {
187                            if (EntityCacheUtil.getResult(
188                                                    WorkflowDefinitionLinkModelImpl.ENTITY_CACHE_ENABLED,
189                                                    WorkflowDefinitionLinkImpl.class,
190                                                    workflowDefinitionLink.getPrimaryKey()) == null) {
191                                    cacheResult(workflowDefinitionLink);
192                            }
193                            else {
194                                    workflowDefinitionLink.resetOriginalValues();
195                            }
196                    }
197            }
198    
199            /**
200             * Clears the cache for all workflow definition links.
201             *
202             * <p>
203             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
204             * </p>
205             */
206            @Override
207            public void clearCache() {
208                    if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
209                            CacheRegistryUtil.clear(WorkflowDefinitionLinkImpl.class.getName());
210                    }
211    
212                    EntityCacheUtil.clearCache(WorkflowDefinitionLinkImpl.class.getName());
213    
214                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
215                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
216                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
217            }
218    
219            /**
220             * Clears the cache for the workflow definition link.
221             *
222             * <p>
223             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
224             * </p>
225             */
226            @Override
227            public void clearCache(WorkflowDefinitionLink workflowDefinitionLink) {
228                    EntityCacheUtil.removeResult(WorkflowDefinitionLinkModelImpl.ENTITY_CACHE_ENABLED,
229                            WorkflowDefinitionLinkImpl.class,
230                            workflowDefinitionLink.getPrimaryKey());
231    
232                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
233                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
234    
235                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_C_C_C_T,
236                            new Object[] {
237                                    Long.valueOf(workflowDefinitionLink.getGroupId()),
238                                    Long.valueOf(workflowDefinitionLink.getCompanyId()),
239                                    Long.valueOf(workflowDefinitionLink.getClassNameId()),
240                                    Long.valueOf(workflowDefinitionLink.getClassPK()),
241                                    Long.valueOf(workflowDefinitionLink.getTypePK())
242                            });
243            }
244    
245            /**
246             * Creates a new workflow definition link with the primary key. Does not add the workflow definition link to the database.
247             *
248             * @param workflowDefinitionLinkId the primary key for the new workflow definition link
249             * @return the new workflow definition link
250             */
251            public WorkflowDefinitionLink create(long workflowDefinitionLinkId) {
252                    WorkflowDefinitionLink workflowDefinitionLink = new WorkflowDefinitionLinkImpl();
253    
254                    workflowDefinitionLink.setNew(true);
255                    workflowDefinitionLink.setPrimaryKey(workflowDefinitionLinkId);
256    
257                    return workflowDefinitionLink;
258            }
259    
260            /**
261             * Removes the workflow definition link with the primary key from the database. Also notifies the appropriate model listeners.
262             *
263             * @param primaryKey the primary key of the workflow definition link
264             * @return the workflow definition link that was removed
265             * @throws com.liferay.portal.NoSuchModelException if a workflow definition link with the primary key could not be found
266             * @throws SystemException if a system exception occurred
267             */
268            @Override
269            public WorkflowDefinitionLink remove(Serializable primaryKey)
270                    throws NoSuchModelException, SystemException {
271                    return remove(((Long)primaryKey).longValue());
272            }
273    
274            /**
275             * Removes the workflow definition link with the primary key from the database. Also notifies the appropriate model listeners.
276             *
277             * @param workflowDefinitionLinkId the primary key of the workflow definition link
278             * @return the workflow definition link that was removed
279             * @throws com.liferay.portal.NoSuchWorkflowDefinitionLinkException if a workflow definition link with the primary key could not be found
280             * @throws SystemException if a system exception occurred
281             */
282            public WorkflowDefinitionLink remove(long workflowDefinitionLinkId)
283                    throws NoSuchWorkflowDefinitionLinkException, SystemException {
284                    Session session = null;
285    
286                    try {
287                            session = openSession();
288    
289                            WorkflowDefinitionLink workflowDefinitionLink = (WorkflowDefinitionLink)session.get(WorkflowDefinitionLinkImpl.class,
290                                            Long.valueOf(workflowDefinitionLinkId));
291    
292                            if (workflowDefinitionLink == null) {
293                                    if (_log.isWarnEnabled()) {
294                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
295                                                    workflowDefinitionLinkId);
296                                    }
297    
298                                    throw new NoSuchWorkflowDefinitionLinkException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
299                                            workflowDefinitionLinkId);
300                            }
301    
302                            return workflowDefinitionLinkPersistence.remove(workflowDefinitionLink);
303                    }
304                    catch (NoSuchWorkflowDefinitionLinkException nsee) {
305                            throw nsee;
306                    }
307                    catch (Exception e) {
308                            throw processException(e);
309                    }
310                    finally {
311                            closeSession(session);
312                    }
313            }
314    
315            /**
316             * Removes the workflow definition link from the database. Also notifies the appropriate model listeners.
317             *
318             * @param workflowDefinitionLink the workflow definition link
319             * @return the workflow definition link that was removed
320             * @throws SystemException if a system exception occurred
321             */
322            @Override
323            public WorkflowDefinitionLink remove(
324                    WorkflowDefinitionLink workflowDefinitionLink)
325                    throws SystemException {
326                    return super.remove(workflowDefinitionLink);
327            }
328    
329            @Override
330            protected WorkflowDefinitionLink removeImpl(
331                    WorkflowDefinitionLink workflowDefinitionLink)
332                    throws SystemException {
333                    workflowDefinitionLink = toUnwrappedModel(workflowDefinitionLink);
334    
335                    Session session = null;
336    
337                    try {
338                            session = openSession();
339    
340                            BatchSessionUtil.delete(session, workflowDefinitionLink);
341                    }
342                    catch (Exception e) {
343                            throw processException(e);
344                    }
345                    finally {
346                            closeSession(session);
347                    }
348    
349                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
350                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
351    
352                    WorkflowDefinitionLinkModelImpl workflowDefinitionLinkModelImpl = (WorkflowDefinitionLinkModelImpl)workflowDefinitionLink;
353    
354                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_C_C_C_T,
355                            new Object[] {
356                                    Long.valueOf(workflowDefinitionLinkModelImpl.getGroupId()),
357                                    Long.valueOf(workflowDefinitionLinkModelImpl.getCompanyId()),
358                                    Long.valueOf(workflowDefinitionLinkModelImpl.getClassNameId()),
359                                    Long.valueOf(workflowDefinitionLinkModelImpl.getClassPK()),
360                                    Long.valueOf(workflowDefinitionLinkModelImpl.getTypePK())
361                            });
362    
363                    EntityCacheUtil.removeResult(WorkflowDefinitionLinkModelImpl.ENTITY_CACHE_ENABLED,
364                            WorkflowDefinitionLinkImpl.class,
365                            workflowDefinitionLink.getPrimaryKey());
366    
367                    return workflowDefinitionLink;
368            }
369    
370            @Override
371            public WorkflowDefinitionLink updateImpl(
372                    com.liferay.portal.model.WorkflowDefinitionLink workflowDefinitionLink,
373                    boolean merge) throws SystemException {
374                    workflowDefinitionLink = toUnwrappedModel(workflowDefinitionLink);
375    
376                    boolean isNew = workflowDefinitionLink.isNew();
377    
378                    WorkflowDefinitionLinkModelImpl workflowDefinitionLinkModelImpl = (WorkflowDefinitionLinkModelImpl)workflowDefinitionLink;
379    
380                    Session session = null;
381    
382                    try {
383                            session = openSession();
384    
385                            BatchSessionUtil.update(session, workflowDefinitionLink, merge);
386    
387                            workflowDefinitionLink.setNew(false);
388                    }
389                    catch (Exception e) {
390                            throw processException(e);
391                    }
392                    finally {
393                            closeSession(session);
394                    }
395    
396                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
397    
398                    if (isNew || !WorkflowDefinitionLinkModelImpl.COLUMN_BITMASK_ENABLED) {
399                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
400                    }
401    
402                    else {
403                            if ((workflowDefinitionLinkModelImpl.getColumnBitmask() &
404                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
405                                    Object[] args = new Object[] {
406                                                    Long.valueOf(workflowDefinitionLinkModelImpl.getOriginalCompanyId())
407                                            };
408    
409                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
410                                            args);
411                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
412                                            args);
413    
414                                    args = new Object[] {
415                                                    Long.valueOf(workflowDefinitionLinkModelImpl.getCompanyId())
416                                            };
417    
418                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
419                                            args);
420                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
421                                            args);
422                            }
423    
424                            if ((workflowDefinitionLinkModelImpl.getColumnBitmask() &
425                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_W_W.getColumnBitmask()) != 0) {
426                                    Object[] args = new Object[] {
427                                                    Long.valueOf(workflowDefinitionLinkModelImpl.getOriginalCompanyId()),
428                                                    
429                                                    workflowDefinitionLinkModelImpl.getOriginalWorkflowDefinitionName(),
430                                                    Integer.valueOf(workflowDefinitionLinkModelImpl.getOriginalWorkflowDefinitionVersion())
431                                            };
432    
433                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_W_W, args);
434                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_W_W,
435                                            args);
436    
437                                    args = new Object[] {
438                                                    Long.valueOf(workflowDefinitionLinkModelImpl.getCompanyId()),
439                                                    
440                                                    workflowDefinitionLinkModelImpl.getWorkflowDefinitionName(),
441                                                    Integer.valueOf(workflowDefinitionLinkModelImpl.getWorkflowDefinitionVersion())
442                                            };
443    
444                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_W_W, args);
445                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_W_W,
446                                            args);
447                            }
448                    }
449    
450                    EntityCacheUtil.putResult(WorkflowDefinitionLinkModelImpl.ENTITY_CACHE_ENABLED,
451                            WorkflowDefinitionLinkImpl.class,
452                            workflowDefinitionLink.getPrimaryKey(), workflowDefinitionLink);
453    
454                    if (isNew) {
455                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C_C_C_T,
456                                    new Object[] {
457                                            Long.valueOf(workflowDefinitionLink.getGroupId()),
458                                            Long.valueOf(workflowDefinitionLink.getCompanyId()),
459                                            Long.valueOf(workflowDefinitionLink.getClassNameId()),
460                                            Long.valueOf(workflowDefinitionLink.getClassPK()),
461                                            Long.valueOf(workflowDefinitionLink.getTypePK())
462                                    }, workflowDefinitionLink);
463                    }
464                    else {
465                            if ((workflowDefinitionLinkModelImpl.getColumnBitmask() &
466                                            FINDER_PATH_FETCH_BY_G_C_C_C_T.getColumnBitmask()) != 0) {
467                                    Object[] args = new Object[] {
468                                                    Long.valueOf(workflowDefinitionLinkModelImpl.getOriginalGroupId()),
469                                                    Long.valueOf(workflowDefinitionLinkModelImpl.getOriginalCompanyId()),
470                                                    Long.valueOf(workflowDefinitionLinkModelImpl.getOriginalClassNameId()),
471                                                    Long.valueOf(workflowDefinitionLinkModelImpl.getOriginalClassPK()),
472                                                    Long.valueOf(workflowDefinitionLinkModelImpl.getOriginalTypePK())
473                                            };
474    
475                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_C_C_T,
476                                            args);
477                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_C_C_C_T,
478                                            args);
479    
480                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C_C_C_T,
481                                            new Object[] {
482                                                    Long.valueOf(workflowDefinitionLink.getGroupId()),
483                                                    Long.valueOf(workflowDefinitionLink.getCompanyId()),
484                                                    Long.valueOf(workflowDefinitionLink.getClassNameId()),
485                                                    Long.valueOf(workflowDefinitionLink.getClassPK()),
486                                                    Long.valueOf(workflowDefinitionLink.getTypePK())
487                                            }, workflowDefinitionLink);
488                            }
489                    }
490    
491                    return workflowDefinitionLink;
492            }
493    
494            protected WorkflowDefinitionLink toUnwrappedModel(
495                    WorkflowDefinitionLink workflowDefinitionLink) {
496                    if (workflowDefinitionLink instanceof WorkflowDefinitionLinkImpl) {
497                            return workflowDefinitionLink;
498                    }
499    
500                    WorkflowDefinitionLinkImpl workflowDefinitionLinkImpl = new WorkflowDefinitionLinkImpl();
501    
502                    workflowDefinitionLinkImpl.setNew(workflowDefinitionLink.isNew());
503                    workflowDefinitionLinkImpl.setPrimaryKey(workflowDefinitionLink.getPrimaryKey());
504    
505                    workflowDefinitionLinkImpl.setWorkflowDefinitionLinkId(workflowDefinitionLink.getWorkflowDefinitionLinkId());
506                    workflowDefinitionLinkImpl.setGroupId(workflowDefinitionLink.getGroupId());
507                    workflowDefinitionLinkImpl.setCompanyId(workflowDefinitionLink.getCompanyId());
508                    workflowDefinitionLinkImpl.setUserId(workflowDefinitionLink.getUserId());
509                    workflowDefinitionLinkImpl.setUserName(workflowDefinitionLink.getUserName());
510                    workflowDefinitionLinkImpl.setCreateDate(workflowDefinitionLink.getCreateDate());
511                    workflowDefinitionLinkImpl.setModifiedDate(workflowDefinitionLink.getModifiedDate());
512                    workflowDefinitionLinkImpl.setClassNameId(workflowDefinitionLink.getClassNameId());
513                    workflowDefinitionLinkImpl.setClassPK(workflowDefinitionLink.getClassPK());
514                    workflowDefinitionLinkImpl.setTypePK(workflowDefinitionLink.getTypePK());
515                    workflowDefinitionLinkImpl.setWorkflowDefinitionName(workflowDefinitionLink.getWorkflowDefinitionName());
516                    workflowDefinitionLinkImpl.setWorkflowDefinitionVersion(workflowDefinitionLink.getWorkflowDefinitionVersion());
517    
518                    return workflowDefinitionLinkImpl;
519            }
520    
521            /**
522             * Returns the workflow definition link with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
523             *
524             * @param primaryKey the primary key of the workflow definition link
525             * @return the workflow definition link
526             * @throws com.liferay.portal.NoSuchModelException if a workflow definition link with the primary key could not be found
527             * @throws SystemException if a system exception occurred
528             */
529            @Override
530            public WorkflowDefinitionLink findByPrimaryKey(Serializable primaryKey)
531                    throws NoSuchModelException, SystemException {
532                    return findByPrimaryKey(((Long)primaryKey).longValue());
533            }
534    
535            /**
536             * Returns the workflow definition link with the primary key or throws a {@link com.liferay.portal.NoSuchWorkflowDefinitionLinkException} if it could not be found.
537             *
538             * @param workflowDefinitionLinkId the primary key of the workflow definition link
539             * @return the workflow definition link
540             * @throws com.liferay.portal.NoSuchWorkflowDefinitionLinkException if a workflow definition link with the primary key could not be found
541             * @throws SystemException if a system exception occurred
542             */
543            public WorkflowDefinitionLink findByPrimaryKey(
544                    long workflowDefinitionLinkId)
545                    throws NoSuchWorkflowDefinitionLinkException, SystemException {
546                    WorkflowDefinitionLink workflowDefinitionLink = fetchByPrimaryKey(workflowDefinitionLinkId);
547    
548                    if (workflowDefinitionLink == null) {
549                            if (_log.isWarnEnabled()) {
550                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
551                                            workflowDefinitionLinkId);
552                            }
553    
554                            throw new NoSuchWorkflowDefinitionLinkException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
555                                    workflowDefinitionLinkId);
556                    }
557    
558                    return workflowDefinitionLink;
559            }
560    
561            /**
562             * Returns the workflow definition link with the primary key or returns <code>null</code> if it could not be found.
563             *
564             * @param primaryKey the primary key of the workflow definition link
565             * @return the workflow definition link, or <code>null</code> if a workflow definition link with the primary key could not be found
566             * @throws SystemException if a system exception occurred
567             */
568            @Override
569            public WorkflowDefinitionLink fetchByPrimaryKey(Serializable primaryKey)
570                    throws SystemException {
571                    return fetchByPrimaryKey(((Long)primaryKey).longValue());
572            }
573    
574            /**
575             * Returns the workflow definition link with the primary key or returns <code>null</code> if it could not be found.
576             *
577             * @param workflowDefinitionLinkId the primary key of the workflow definition link
578             * @return the workflow definition link, or <code>null</code> if a workflow definition link with the primary key could not be found
579             * @throws SystemException if a system exception occurred
580             */
581            public WorkflowDefinitionLink fetchByPrimaryKey(
582                    long workflowDefinitionLinkId) throws SystemException {
583                    WorkflowDefinitionLink workflowDefinitionLink = (WorkflowDefinitionLink)EntityCacheUtil.getResult(WorkflowDefinitionLinkModelImpl.ENTITY_CACHE_ENABLED,
584                                    WorkflowDefinitionLinkImpl.class, workflowDefinitionLinkId);
585    
586                    if (workflowDefinitionLink == _nullWorkflowDefinitionLink) {
587                            return null;
588                    }
589    
590                    if (workflowDefinitionLink == null) {
591                            Session session = null;
592    
593                            boolean hasException = false;
594    
595                            try {
596                                    session = openSession();
597    
598                                    workflowDefinitionLink = (WorkflowDefinitionLink)session.get(WorkflowDefinitionLinkImpl.class,
599                                                    Long.valueOf(workflowDefinitionLinkId));
600                            }
601                            catch (Exception e) {
602                                    hasException = true;
603    
604                                    throw processException(e);
605                            }
606                            finally {
607                                    if (workflowDefinitionLink != null) {
608                                            cacheResult(workflowDefinitionLink);
609                                    }
610                                    else if (!hasException) {
611                                            EntityCacheUtil.putResult(WorkflowDefinitionLinkModelImpl.ENTITY_CACHE_ENABLED,
612                                                    WorkflowDefinitionLinkImpl.class,
613                                                    workflowDefinitionLinkId, _nullWorkflowDefinitionLink);
614                                    }
615    
616                                    closeSession(session);
617                            }
618                    }
619    
620                    return workflowDefinitionLink;
621            }
622    
623            /**
624             * Returns all the workflow definition links where companyId = &#63;.
625             *
626             * @param companyId the company ID
627             * @return the matching workflow definition links
628             * @throws SystemException if a system exception occurred
629             */
630            public List<WorkflowDefinitionLink> findByCompanyId(long companyId)
631                    throws SystemException {
632                    return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
633                            null);
634            }
635    
636            /**
637             * Returns a range of all the workflow definition links where companyId = &#63;.
638             *
639             * <p>
640             * 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.
641             * </p>
642             *
643             * @param companyId the company ID
644             * @param start the lower bound of the range of workflow definition links
645             * @param end the upper bound of the range of workflow definition links (not inclusive)
646             * @return the range of matching workflow definition links
647             * @throws SystemException if a system exception occurred
648             */
649            public List<WorkflowDefinitionLink> findByCompanyId(long companyId,
650                    int start, int end) throws SystemException {
651                    return findByCompanyId(companyId, start, end, null);
652            }
653    
654            /**
655             * Returns an ordered range of all the workflow definition links where companyId = &#63;.
656             *
657             * <p>
658             * 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.
659             * </p>
660             *
661             * @param companyId the company ID
662             * @param start the lower bound of the range of workflow definition links
663             * @param end the upper bound of the range of workflow definition links (not inclusive)
664             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
665             * @return the ordered range of matching workflow definition links
666             * @throws SystemException if a system exception occurred
667             */
668            public List<WorkflowDefinitionLink> findByCompanyId(long companyId,
669                    int start, int end, OrderByComparator orderByComparator)
670                    throws SystemException {
671                    FinderPath finderPath = null;
672                    Object[] finderArgs = null;
673    
674                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
675                                    (orderByComparator == null)) {
676                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID;
677                            finderArgs = new Object[] { companyId };
678                    }
679                    else {
680                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID;
681                            finderArgs = new Object[] { companyId, start, end, orderByComparator };
682                    }
683    
684                    List<WorkflowDefinitionLink> list = (List<WorkflowDefinitionLink>)FinderCacheUtil.getResult(finderPath,
685                                    finderArgs, this);
686    
687                    if (list == null) {
688                            StringBundler query = null;
689    
690                            if (orderByComparator != null) {
691                                    query = new StringBundler(3 +
692                                                    (orderByComparator.getOrderByFields().length * 3));
693                            }
694                            else {
695                                    query = new StringBundler(3);
696                            }
697    
698                            query.append(_SQL_SELECT_WORKFLOWDEFINITIONLINK_WHERE);
699    
700                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
701    
702                            if (orderByComparator != null) {
703                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
704                                            orderByComparator);
705                            }
706    
707                            else {
708                                    query.append(WorkflowDefinitionLinkModelImpl.ORDER_BY_JPQL);
709                            }
710    
711                            String sql = query.toString();
712    
713                            Session session = null;
714    
715                            try {
716                                    session = openSession();
717    
718                                    Query q = session.createQuery(sql);
719    
720                                    QueryPos qPos = QueryPos.getInstance(q);
721    
722                                    qPos.add(companyId);
723    
724                                    list = (List<WorkflowDefinitionLink>)QueryUtil.list(q,
725                                                    getDialect(), start, end);
726                            }
727                            catch (Exception e) {
728                                    throw processException(e);
729                            }
730                            finally {
731                                    if (list == null) {
732                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
733                                    }
734                                    else {
735                                            cacheResult(list);
736    
737                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
738                                    }
739    
740                                    closeSession(session);
741                            }
742                    }
743    
744                    return list;
745            }
746    
747            /**
748             * Returns the first workflow definition link in the ordered set where companyId = &#63;.
749             *
750             * <p>
751             * 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.
752             * </p>
753             *
754             * @param companyId the company ID
755             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
756             * @return the first matching workflow definition link
757             * @throws com.liferay.portal.NoSuchWorkflowDefinitionLinkException if a matching workflow definition link could not be found
758             * @throws SystemException if a system exception occurred
759             */
760            public WorkflowDefinitionLink findByCompanyId_First(long companyId,
761                    OrderByComparator orderByComparator)
762                    throws NoSuchWorkflowDefinitionLinkException, SystemException {
763                    List<WorkflowDefinitionLink> list = findByCompanyId(companyId, 0, 1,
764                                    orderByComparator);
765    
766                    if (list.isEmpty()) {
767                            StringBundler msg = new StringBundler(4);
768    
769                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
770    
771                            msg.append("companyId=");
772                            msg.append(companyId);
773    
774                            msg.append(StringPool.CLOSE_CURLY_BRACE);
775    
776                            throw new NoSuchWorkflowDefinitionLinkException(msg.toString());
777                    }
778                    else {
779                            return list.get(0);
780                    }
781            }
782    
783            /**
784             * Returns the last workflow definition link in the ordered set where companyId = &#63;.
785             *
786             * <p>
787             * 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.
788             * </p>
789             *
790             * @param companyId the company ID
791             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
792             * @return the last matching workflow definition link
793             * @throws com.liferay.portal.NoSuchWorkflowDefinitionLinkException if a matching workflow definition link could not be found
794             * @throws SystemException if a system exception occurred
795             */
796            public WorkflowDefinitionLink findByCompanyId_Last(long companyId,
797                    OrderByComparator orderByComparator)
798                    throws NoSuchWorkflowDefinitionLinkException, SystemException {
799                    int count = countByCompanyId(companyId);
800    
801                    List<WorkflowDefinitionLink> list = findByCompanyId(companyId,
802                                    count - 1, count, orderByComparator);
803    
804                    if (list.isEmpty()) {
805                            StringBundler msg = new StringBundler(4);
806    
807                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
808    
809                            msg.append("companyId=");
810                            msg.append(companyId);
811    
812                            msg.append(StringPool.CLOSE_CURLY_BRACE);
813    
814                            throw new NoSuchWorkflowDefinitionLinkException(msg.toString());
815                    }
816                    else {
817                            return list.get(0);
818                    }
819            }
820    
821            /**
822             * Returns the workflow definition links before and after the current workflow definition link in the ordered set where companyId = &#63;.
823             *
824             * <p>
825             * 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.
826             * </p>
827             *
828             * @param workflowDefinitionLinkId the primary key of the current workflow definition link
829             * @param companyId the company ID
830             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
831             * @return the previous, current, and next workflow definition link
832             * @throws com.liferay.portal.NoSuchWorkflowDefinitionLinkException if a workflow definition link with the primary key could not be found
833             * @throws SystemException if a system exception occurred
834             */
835            public WorkflowDefinitionLink[] findByCompanyId_PrevAndNext(
836                    long workflowDefinitionLinkId, long companyId,
837                    OrderByComparator orderByComparator)
838                    throws NoSuchWorkflowDefinitionLinkException, SystemException {
839                    WorkflowDefinitionLink workflowDefinitionLink = findByPrimaryKey(workflowDefinitionLinkId);
840    
841                    Session session = null;
842    
843                    try {
844                            session = openSession();
845    
846                            WorkflowDefinitionLink[] array = new WorkflowDefinitionLinkImpl[3];
847    
848                            array[0] = getByCompanyId_PrevAndNext(session,
849                                            workflowDefinitionLink, companyId, orderByComparator, true);
850    
851                            array[1] = workflowDefinitionLink;
852    
853                            array[2] = getByCompanyId_PrevAndNext(session,
854                                            workflowDefinitionLink, companyId, orderByComparator, false);
855    
856                            return array;
857                    }
858                    catch (Exception e) {
859                            throw processException(e);
860                    }
861                    finally {
862                            closeSession(session);
863                    }
864            }
865    
866            protected WorkflowDefinitionLink getByCompanyId_PrevAndNext(
867                    Session session, WorkflowDefinitionLink workflowDefinitionLink,
868                    long companyId, OrderByComparator orderByComparator, boolean previous) {
869                    StringBundler query = null;
870    
871                    if (orderByComparator != null) {
872                            query = new StringBundler(6 +
873                                            (orderByComparator.getOrderByFields().length * 6));
874                    }
875                    else {
876                            query = new StringBundler(3);
877                    }
878    
879                    query.append(_SQL_SELECT_WORKFLOWDEFINITIONLINK_WHERE);
880    
881                    query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
882    
883                    if (orderByComparator != null) {
884                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
885    
886                            if (orderByConditionFields.length > 0) {
887                                    query.append(WHERE_AND);
888                            }
889    
890                            for (int i = 0; i < orderByConditionFields.length; i++) {
891                                    query.append(_ORDER_BY_ENTITY_ALIAS);
892                                    query.append(orderByConditionFields[i]);
893    
894                                    if ((i + 1) < orderByConditionFields.length) {
895                                            if (orderByComparator.isAscending() ^ previous) {
896                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
897                                            }
898                                            else {
899                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
900                                            }
901                                    }
902                                    else {
903                                            if (orderByComparator.isAscending() ^ previous) {
904                                                    query.append(WHERE_GREATER_THAN);
905                                            }
906                                            else {
907                                                    query.append(WHERE_LESSER_THAN);
908                                            }
909                                    }
910                            }
911    
912                            query.append(ORDER_BY_CLAUSE);
913    
914                            String[] orderByFields = orderByComparator.getOrderByFields();
915    
916                            for (int i = 0; i < orderByFields.length; i++) {
917                                    query.append(_ORDER_BY_ENTITY_ALIAS);
918                                    query.append(orderByFields[i]);
919    
920                                    if ((i + 1) < orderByFields.length) {
921                                            if (orderByComparator.isAscending() ^ previous) {
922                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
923                                            }
924                                            else {
925                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
926                                            }
927                                    }
928                                    else {
929                                            if (orderByComparator.isAscending() ^ previous) {
930                                                    query.append(ORDER_BY_ASC);
931                                            }
932                                            else {
933                                                    query.append(ORDER_BY_DESC);
934                                            }
935                                    }
936                            }
937                    }
938    
939                    else {
940                            query.append(WorkflowDefinitionLinkModelImpl.ORDER_BY_JPQL);
941                    }
942    
943                    String sql = query.toString();
944    
945                    Query q = session.createQuery(sql);
946    
947                    q.setFirstResult(0);
948                    q.setMaxResults(2);
949    
950                    QueryPos qPos = QueryPos.getInstance(q);
951    
952                    qPos.add(companyId);
953    
954                    if (orderByComparator != null) {
955                            Object[] values = orderByComparator.getOrderByConditionValues(workflowDefinitionLink);
956    
957                            for (Object value : values) {
958                                    qPos.add(value);
959                            }
960                    }
961    
962                    List<WorkflowDefinitionLink> list = q.list();
963    
964                    if (list.size() == 2) {
965                            return list.get(1);
966                    }
967                    else {
968                            return null;
969                    }
970            }
971    
972            /**
973             * Returns all the workflow definition links where companyId = &#63; and workflowDefinitionName = &#63; and workflowDefinitionVersion = &#63;.
974             *
975             * @param companyId the company ID
976             * @param workflowDefinitionName the workflow definition name
977             * @param workflowDefinitionVersion the workflow definition version
978             * @return the matching workflow definition links
979             * @throws SystemException if a system exception occurred
980             */
981            public List<WorkflowDefinitionLink> findByC_W_W(long companyId,
982                    String workflowDefinitionName, int workflowDefinitionVersion)
983                    throws SystemException {
984                    return findByC_W_W(companyId, workflowDefinitionName,
985                            workflowDefinitionVersion, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
986                            null);
987            }
988    
989            /**
990             * Returns a range of all the workflow definition links where companyId = &#63; and workflowDefinitionName = &#63; and workflowDefinitionVersion = &#63;.
991             *
992             * <p>
993             * 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.
994             * </p>
995             *
996             * @param companyId the company ID
997             * @param workflowDefinitionName the workflow definition name
998             * @param workflowDefinitionVersion the workflow definition version
999             * @param start the lower bound of the range of workflow definition links
1000             * @param end the upper bound of the range of workflow definition links (not inclusive)
1001             * @return the range of matching workflow definition links
1002             * @throws SystemException if a system exception occurred
1003             */
1004            public List<WorkflowDefinitionLink> findByC_W_W(long companyId,
1005                    String workflowDefinitionName, int workflowDefinitionVersion,
1006                    int start, int end) throws SystemException {
1007                    return findByC_W_W(companyId, workflowDefinitionName,
1008                            workflowDefinitionVersion, start, end, null);
1009            }
1010    
1011            /**
1012             * Returns an ordered range of all the workflow definition links where companyId = &#63; and workflowDefinitionName = &#63; and workflowDefinitionVersion = &#63;.
1013             *
1014             * <p>
1015             * 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.
1016             * </p>
1017             *
1018             * @param companyId the company ID
1019             * @param workflowDefinitionName the workflow definition name
1020             * @param workflowDefinitionVersion the workflow definition version
1021             * @param start the lower bound of the range of workflow definition links
1022             * @param end the upper bound of the range of workflow definition links (not inclusive)
1023             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1024             * @return the ordered range of matching workflow definition links
1025             * @throws SystemException if a system exception occurred
1026             */
1027            public List<WorkflowDefinitionLink> findByC_W_W(long companyId,
1028                    String workflowDefinitionName, int workflowDefinitionVersion,
1029                    int start, int end, OrderByComparator orderByComparator)
1030                    throws SystemException {
1031                    FinderPath finderPath = null;
1032                    Object[] finderArgs = null;
1033    
1034                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1035                                    (orderByComparator == null)) {
1036                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_W_W;
1037                            finderArgs = new Object[] {
1038                                            companyId, workflowDefinitionName, workflowDefinitionVersion
1039                                    };
1040                    }
1041                    else {
1042                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_W_W;
1043                            finderArgs = new Object[] {
1044                                            companyId, workflowDefinitionName, workflowDefinitionVersion,
1045                                            
1046                                            start, end, orderByComparator
1047                                    };
1048                    }
1049    
1050                    List<WorkflowDefinitionLink> list = (List<WorkflowDefinitionLink>)FinderCacheUtil.getResult(finderPath,
1051                                    finderArgs, this);
1052    
1053                    if (list == null) {
1054                            StringBundler query = null;
1055    
1056                            if (orderByComparator != null) {
1057                                    query = new StringBundler(5 +
1058                                                    (orderByComparator.getOrderByFields().length * 3));
1059                            }
1060                            else {
1061                                    query = new StringBundler(5);
1062                            }
1063    
1064                            query.append(_SQL_SELECT_WORKFLOWDEFINITIONLINK_WHERE);
1065    
1066                            query.append(_FINDER_COLUMN_C_W_W_COMPANYID_2);
1067    
1068                            if (workflowDefinitionName == null) {
1069                                    query.append(_FINDER_COLUMN_C_W_W_WORKFLOWDEFINITIONNAME_1);
1070                            }
1071                            else {
1072                                    if (workflowDefinitionName.equals(StringPool.BLANK)) {
1073                                            query.append(_FINDER_COLUMN_C_W_W_WORKFLOWDEFINITIONNAME_3);
1074                                    }
1075                                    else {
1076                                            query.append(_FINDER_COLUMN_C_W_W_WORKFLOWDEFINITIONNAME_2);
1077                                    }
1078                            }
1079    
1080                            query.append(_FINDER_COLUMN_C_W_W_WORKFLOWDEFINITIONVERSION_2);
1081    
1082                            if (orderByComparator != null) {
1083                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1084                                            orderByComparator);
1085                            }
1086    
1087                            else {
1088                                    query.append(WorkflowDefinitionLinkModelImpl.ORDER_BY_JPQL);
1089                            }
1090    
1091                            String sql = query.toString();
1092    
1093                            Session session = null;
1094    
1095                            try {
1096                                    session = openSession();
1097    
1098                                    Query q = session.createQuery(sql);
1099    
1100                                    QueryPos qPos = QueryPos.getInstance(q);
1101    
1102                                    qPos.add(companyId);
1103    
1104                                    if (workflowDefinitionName != null) {
1105                                            qPos.add(workflowDefinitionName);
1106                                    }
1107    
1108                                    qPos.add(workflowDefinitionVersion);
1109    
1110                                    list = (List<WorkflowDefinitionLink>)QueryUtil.list(q,
1111                                                    getDialect(), start, end);
1112                            }
1113                            catch (Exception e) {
1114                                    throw processException(e);
1115                            }
1116                            finally {
1117                                    if (list == null) {
1118                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1119                                    }
1120                                    else {
1121                                            cacheResult(list);
1122    
1123                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1124                                    }
1125    
1126                                    closeSession(session);
1127                            }
1128                    }
1129    
1130                    return list;
1131            }
1132    
1133            /**
1134             * Returns the first workflow definition link in the ordered set where companyId = &#63; and workflowDefinitionName = &#63; and workflowDefinitionVersion = &#63;.
1135             *
1136             * <p>
1137             * 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.
1138             * </p>
1139             *
1140             * @param companyId the company ID
1141             * @param workflowDefinitionName the workflow definition name
1142             * @param workflowDefinitionVersion the workflow definition version
1143             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1144             * @return the first matching workflow definition link
1145             * @throws com.liferay.portal.NoSuchWorkflowDefinitionLinkException if a matching workflow definition link could not be found
1146             * @throws SystemException if a system exception occurred
1147             */
1148            public WorkflowDefinitionLink findByC_W_W_First(long companyId,
1149                    String workflowDefinitionName, int workflowDefinitionVersion,
1150                    OrderByComparator orderByComparator)
1151                    throws NoSuchWorkflowDefinitionLinkException, SystemException {
1152                    List<WorkflowDefinitionLink> list = findByC_W_W(companyId,
1153                                    workflowDefinitionName, workflowDefinitionVersion, 0, 1,
1154                                    orderByComparator);
1155    
1156                    if (list.isEmpty()) {
1157                            StringBundler msg = new StringBundler(8);
1158    
1159                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1160    
1161                            msg.append("companyId=");
1162                            msg.append(companyId);
1163    
1164                            msg.append(", workflowDefinitionName=");
1165                            msg.append(workflowDefinitionName);
1166    
1167                            msg.append(", workflowDefinitionVersion=");
1168                            msg.append(workflowDefinitionVersion);
1169    
1170                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1171    
1172                            throw new NoSuchWorkflowDefinitionLinkException(msg.toString());
1173                    }
1174                    else {
1175                            return list.get(0);
1176                    }
1177            }
1178    
1179            /**
1180             * Returns the last workflow definition link in the ordered set where companyId = &#63; and workflowDefinitionName = &#63; and workflowDefinitionVersion = &#63;.
1181             *
1182             * <p>
1183             * 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.
1184             * </p>
1185             *
1186             * @param companyId the company ID
1187             * @param workflowDefinitionName the workflow definition name
1188             * @param workflowDefinitionVersion the workflow definition version
1189             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1190             * @return the last matching workflow definition link
1191             * @throws com.liferay.portal.NoSuchWorkflowDefinitionLinkException if a matching workflow definition link could not be found
1192             * @throws SystemException if a system exception occurred
1193             */
1194            public WorkflowDefinitionLink findByC_W_W_Last(long companyId,
1195                    String workflowDefinitionName, int workflowDefinitionVersion,
1196                    OrderByComparator orderByComparator)
1197                    throws NoSuchWorkflowDefinitionLinkException, SystemException {
1198                    int count = countByC_W_W(companyId, workflowDefinitionName,
1199                                    workflowDefinitionVersion);
1200    
1201                    List<WorkflowDefinitionLink> list = findByC_W_W(companyId,
1202                                    workflowDefinitionName, workflowDefinitionVersion, count - 1,
1203                                    count, orderByComparator);
1204    
1205                    if (list.isEmpty()) {
1206                            StringBundler msg = new StringBundler(8);
1207    
1208                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1209    
1210                            msg.append("companyId=");
1211                            msg.append(companyId);
1212    
1213                            msg.append(", workflowDefinitionName=");
1214                            msg.append(workflowDefinitionName);
1215    
1216                            msg.append(", workflowDefinitionVersion=");
1217                            msg.append(workflowDefinitionVersion);
1218    
1219                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1220    
1221                            throw new NoSuchWorkflowDefinitionLinkException(msg.toString());
1222                    }
1223                    else {
1224                            return list.get(0);
1225                    }
1226            }
1227    
1228            /**
1229             * Returns the workflow definition links before and after the current workflow definition link in the ordered set where companyId = &#63; and workflowDefinitionName = &#63; and workflowDefinitionVersion = &#63;.
1230             *
1231             * <p>
1232             * 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.
1233             * </p>
1234             *
1235             * @param workflowDefinitionLinkId the primary key of the current workflow definition link
1236             * @param companyId the company ID
1237             * @param workflowDefinitionName the workflow definition name
1238             * @param workflowDefinitionVersion the workflow definition version
1239             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1240             * @return the previous, current, and next workflow definition link
1241             * @throws com.liferay.portal.NoSuchWorkflowDefinitionLinkException if a workflow definition link with the primary key could not be found
1242             * @throws SystemException if a system exception occurred
1243             */
1244            public WorkflowDefinitionLink[] findByC_W_W_PrevAndNext(
1245                    long workflowDefinitionLinkId, long companyId,
1246                    String workflowDefinitionName, int workflowDefinitionVersion,
1247                    OrderByComparator orderByComparator)
1248                    throws NoSuchWorkflowDefinitionLinkException, SystemException {
1249                    WorkflowDefinitionLink workflowDefinitionLink = findByPrimaryKey(workflowDefinitionLinkId);
1250    
1251                    Session session = null;
1252    
1253                    try {
1254                            session = openSession();
1255    
1256                            WorkflowDefinitionLink[] array = new WorkflowDefinitionLinkImpl[3];
1257    
1258                            array[0] = getByC_W_W_PrevAndNext(session, workflowDefinitionLink,
1259                                            companyId, workflowDefinitionName,
1260                                            workflowDefinitionVersion, orderByComparator, true);
1261    
1262                            array[1] = workflowDefinitionLink;
1263    
1264                            array[2] = getByC_W_W_PrevAndNext(session, workflowDefinitionLink,
1265                                            companyId, workflowDefinitionName,
1266                                            workflowDefinitionVersion, orderByComparator, false);
1267    
1268                            return array;
1269                    }
1270                    catch (Exception e) {
1271                            throw processException(e);
1272                    }
1273                    finally {
1274                            closeSession(session);
1275                    }
1276            }
1277    
1278            protected WorkflowDefinitionLink getByC_W_W_PrevAndNext(Session session,
1279                    WorkflowDefinitionLink workflowDefinitionLink, long companyId,
1280                    String workflowDefinitionName, int workflowDefinitionVersion,
1281                    OrderByComparator orderByComparator, boolean previous) {
1282                    StringBundler query = null;
1283    
1284                    if (orderByComparator != null) {
1285                            query = new StringBundler(6 +
1286                                            (orderByComparator.getOrderByFields().length * 6));
1287                    }
1288                    else {
1289                            query = new StringBundler(3);
1290                    }
1291    
1292                    query.append(_SQL_SELECT_WORKFLOWDEFINITIONLINK_WHERE);
1293    
1294                    query.append(_FINDER_COLUMN_C_W_W_COMPANYID_2);
1295    
1296                    if (workflowDefinitionName == null) {
1297                            query.append(_FINDER_COLUMN_C_W_W_WORKFLOWDEFINITIONNAME_1);
1298                    }
1299                    else {
1300                            if (workflowDefinitionName.equals(StringPool.BLANK)) {
1301                                    query.append(_FINDER_COLUMN_C_W_W_WORKFLOWDEFINITIONNAME_3);
1302                            }
1303                            else {
1304                                    query.append(_FINDER_COLUMN_C_W_W_WORKFLOWDEFINITIONNAME_2);
1305                            }
1306                    }
1307    
1308                    query.append(_FINDER_COLUMN_C_W_W_WORKFLOWDEFINITIONVERSION_2);
1309    
1310                    if (orderByComparator != null) {
1311                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1312    
1313                            if (orderByConditionFields.length > 0) {
1314                                    query.append(WHERE_AND);
1315                            }
1316    
1317                            for (int i = 0; i < orderByConditionFields.length; i++) {
1318                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1319                                    query.append(orderByConditionFields[i]);
1320    
1321                                    if ((i + 1) < orderByConditionFields.length) {
1322                                            if (orderByComparator.isAscending() ^ previous) {
1323                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1324                                            }
1325                                            else {
1326                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1327                                            }
1328                                    }
1329                                    else {
1330                                            if (orderByComparator.isAscending() ^ previous) {
1331                                                    query.append(WHERE_GREATER_THAN);
1332                                            }
1333                                            else {
1334                                                    query.append(WHERE_LESSER_THAN);
1335                                            }
1336                                    }
1337                            }
1338    
1339                            query.append(ORDER_BY_CLAUSE);
1340    
1341                            String[] orderByFields = orderByComparator.getOrderByFields();
1342    
1343                            for (int i = 0; i < orderByFields.length; i++) {
1344                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1345                                    query.append(orderByFields[i]);
1346    
1347                                    if ((i + 1) < orderByFields.length) {
1348                                            if (orderByComparator.isAscending() ^ previous) {
1349                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1350                                            }
1351                                            else {
1352                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1353                                            }
1354                                    }
1355                                    else {
1356                                            if (orderByComparator.isAscending() ^ previous) {
1357                                                    query.append(ORDER_BY_ASC);
1358                                            }
1359                                            else {
1360                                                    query.append(ORDER_BY_DESC);
1361                                            }
1362                                    }
1363                            }
1364                    }
1365    
1366                    else {
1367                            query.append(WorkflowDefinitionLinkModelImpl.ORDER_BY_JPQL);
1368                    }
1369    
1370                    String sql = query.toString();
1371    
1372                    Query q = session.createQuery(sql);
1373    
1374                    q.setFirstResult(0);
1375                    q.setMaxResults(2);
1376    
1377                    QueryPos qPos = QueryPos.getInstance(q);
1378    
1379                    qPos.add(companyId);
1380    
1381                    if (workflowDefinitionName != null) {
1382                            qPos.add(workflowDefinitionName);
1383                    }
1384    
1385                    qPos.add(workflowDefinitionVersion);
1386    
1387                    if (orderByComparator != null) {
1388                            Object[] values = orderByComparator.getOrderByConditionValues(workflowDefinitionLink);
1389    
1390                            for (Object value : values) {
1391                                    qPos.add(value);
1392                            }
1393                    }
1394    
1395                    List<WorkflowDefinitionLink> list = q.list();
1396    
1397                    if (list.size() == 2) {
1398                            return list.get(1);
1399                    }
1400                    else {
1401                            return null;
1402                    }
1403            }
1404    
1405            /**
1406             * Returns the workflow definition link where groupId = &#63; and companyId = &#63; and classNameId = &#63; and classPK = &#63; and typePK = &#63; or throws a {@link com.liferay.portal.NoSuchWorkflowDefinitionLinkException} if it could not be found.
1407             *
1408             * @param groupId the group ID
1409             * @param companyId the company ID
1410             * @param classNameId the class name ID
1411             * @param classPK the class p k
1412             * @param typePK the type p k
1413             * @return the matching workflow definition link
1414             * @throws com.liferay.portal.NoSuchWorkflowDefinitionLinkException if a matching workflow definition link could not be found
1415             * @throws SystemException if a system exception occurred
1416             */
1417            public WorkflowDefinitionLink findByG_C_C_C_T(long groupId, long companyId,
1418                    long classNameId, long classPK, long typePK)
1419                    throws NoSuchWorkflowDefinitionLinkException, SystemException {
1420                    WorkflowDefinitionLink workflowDefinitionLink = fetchByG_C_C_C_T(groupId,
1421                                    companyId, classNameId, classPK, typePK);
1422    
1423                    if (workflowDefinitionLink == null) {
1424                            StringBundler msg = new StringBundler(12);
1425    
1426                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1427    
1428                            msg.append("groupId=");
1429                            msg.append(groupId);
1430    
1431                            msg.append(", companyId=");
1432                            msg.append(companyId);
1433    
1434                            msg.append(", classNameId=");
1435                            msg.append(classNameId);
1436    
1437                            msg.append(", classPK=");
1438                            msg.append(classPK);
1439    
1440                            msg.append(", typePK=");
1441                            msg.append(typePK);
1442    
1443                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1444    
1445                            if (_log.isWarnEnabled()) {
1446                                    _log.warn(msg.toString());
1447                            }
1448    
1449                            throw new NoSuchWorkflowDefinitionLinkException(msg.toString());
1450                    }
1451    
1452                    return workflowDefinitionLink;
1453            }
1454    
1455            /**
1456             * Returns the workflow definition link where groupId = &#63; and companyId = &#63; and classNameId = &#63; and classPK = &#63; and typePK = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
1457             *
1458             * @param groupId the group ID
1459             * @param companyId the company ID
1460             * @param classNameId the class name ID
1461             * @param classPK the class p k
1462             * @param typePK the type p k
1463             * @return the matching workflow definition link, or <code>null</code> if a matching workflow definition link could not be found
1464             * @throws SystemException if a system exception occurred
1465             */
1466            public WorkflowDefinitionLink fetchByG_C_C_C_T(long groupId,
1467                    long companyId, long classNameId, long classPK, long typePK)
1468                    throws SystemException {
1469                    return fetchByG_C_C_C_T(groupId, companyId, classNameId, classPK,
1470                            typePK, true);
1471            }
1472    
1473            /**
1474             * Returns the workflow definition link where groupId = &#63; and companyId = &#63; and classNameId = &#63; and classPK = &#63; and typePK = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
1475             *
1476             * @param groupId the group ID
1477             * @param companyId the company ID
1478             * @param classNameId the class name ID
1479             * @param classPK the class p k
1480             * @param typePK the type p k
1481             * @param retrieveFromCache whether to use the finder cache
1482             * @return the matching workflow definition link, or <code>null</code> if a matching workflow definition link could not be found
1483             * @throws SystemException if a system exception occurred
1484             */
1485            public WorkflowDefinitionLink fetchByG_C_C_C_T(long groupId,
1486                    long companyId, long classNameId, long classPK, long typePK,
1487                    boolean retrieveFromCache) throws SystemException {
1488                    Object[] finderArgs = new Object[] {
1489                                    groupId, companyId, classNameId, classPK, typePK
1490                            };
1491    
1492                    Object result = null;
1493    
1494                    if (retrieveFromCache) {
1495                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_C_C_C_T,
1496                                            finderArgs, this);
1497                    }
1498    
1499                    if (result == null) {
1500                            StringBundler query = new StringBundler(7);
1501    
1502                            query.append(_SQL_SELECT_WORKFLOWDEFINITIONLINK_WHERE);
1503    
1504                            query.append(_FINDER_COLUMN_G_C_C_C_T_GROUPID_2);
1505    
1506                            query.append(_FINDER_COLUMN_G_C_C_C_T_COMPANYID_2);
1507    
1508                            query.append(_FINDER_COLUMN_G_C_C_C_T_CLASSNAMEID_2);
1509    
1510                            query.append(_FINDER_COLUMN_G_C_C_C_T_CLASSPK_2);
1511    
1512                            query.append(_FINDER_COLUMN_G_C_C_C_T_TYPEPK_2);
1513    
1514                            query.append(WorkflowDefinitionLinkModelImpl.ORDER_BY_JPQL);
1515    
1516                            String sql = query.toString();
1517    
1518                            Session session = null;
1519    
1520                            try {
1521                                    session = openSession();
1522    
1523                                    Query q = session.createQuery(sql);
1524    
1525                                    QueryPos qPos = QueryPos.getInstance(q);
1526    
1527                                    qPos.add(groupId);
1528    
1529                                    qPos.add(companyId);
1530    
1531                                    qPos.add(classNameId);
1532    
1533                                    qPos.add(classPK);
1534    
1535                                    qPos.add(typePK);
1536    
1537                                    List<WorkflowDefinitionLink> list = q.list();
1538    
1539                                    result = list;
1540    
1541                                    WorkflowDefinitionLink workflowDefinitionLink = null;
1542    
1543                                    if (list.isEmpty()) {
1544                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C_C_C_T,
1545                                                    finderArgs, list);
1546                                    }
1547                                    else {
1548                                            workflowDefinitionLink = list.get(0);
1549    
1550                                            cacheResult(workflowDefinitionLink);
1551    
1552                                            if ((workflowDefinitionLink.getGroupId() != groupId) ||
1553                                                            (workflowDefinitionLink.getCompanyId() != companyId) ||
1554                                                            (workflowDefinitionLink.getClassNameId() != classNameId) ||
1555                                                            (workflowDefinitionLink.getClassPK() != classPK) ||
1556                                                            (workflowDefinitionLink.getTypePK() != typePK)) {
1557                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C_C_C_T,
1558                                                            finderArgs, workflowDefinitionLink);
1559                                            }
1560                                    }
1561    
1562                                    return workflowDefinitionLink;
1563                            }
1564                            catch (Exception e) {
1565                                    throw processException(e);
1566                            }
1567                            finally {
1568                                    if (result == null) {
1569                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_C_C_C_T,
1570                                                    finderArgs);
1571                                    }
1572    
1573                                    closeSession(session);
1574                            }
1575                    }
1576                    else {
1577                            if (result instanceof List<?>) {
1578                                    return null;
1579                            }
1580                            else {
1581                                    return (WorkflowDefinitionLink)result;
1582                            }
1583                    }
1584            }
1585    
1586            /**
1587             * Returns all the workflow definition links.
1588             *
1589             * @return the workflow definition links
1590             * @throws SystemException if a system exception occurred
1591             */
1592            public List<WorkflowDefinitionLink> findAll() throws SystemException {
1593                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1594            }
1595    
1596            /**
1597             * Returns a range of all the workflow definition links.
1598             *
1599             * <p>
1600             * 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.
1601             * </p>
1602             *
1603             * @param start the lower bound of the range of workflow definition links
1604             * @param end the upper bound of the range of workflow definition links (not inclusive)
1605             * @return the range of workflow definition links
1606             * @throws SystemException if a system exception occurred
1607             */
1608            public List<WorkflowDefinitionLink> findAll(int start, int end)
1609                    throws SystemException {
1610                    return findAll(start, end, null);
1611            }
1612    
1613            /**
1614             * Returns an ordered range of all the workflow definition links.
1615             *
1616             * <p>
1617             * 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.
1618             * </p>
1619             *
1620             * @param start the lower bound of the range of workflow definition links
1621             * @param end the upper bound of the range of workflow definition links (not inclusive)
1622             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1623             * @return the ordered range of workflow definition links
1624             * @throws SystemException if a system exception occurred
1625             */
1626            public List<WorkflowDefinitionLink> findAll(int start, int end,
1627                    OrderByComparator orderByComparator) throws SystemException {
1628                    FinderPath finderPath = null;
1629                    Object[] finderArgs = new Object[] { start, end, orderByComparator };
1630    
1631                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1632                                    (orderByComparator == null)) {
1633                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
1634                            finderArgs = FINDER_ARGS_EMPTY;
1635                    }
1636                    else {
1637                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
1638                            finderArgs = new Object[] { start, end, orderByComparator };
1639                    }
1640    
1641                    List<WorkflowDefinitionLink> list = (List<WorkflowDefinitionLink>)FinderCacheUtil.getResult(finderPath,
1642                                    finderArgs, this);
1643    
1644                    if (list == null) {
1645                            StringBundler query = null;
1646                            String sql = null;
1647    
1648                            if (orderByComparator != null) {
1649                                    query = new StringBundler(2 +
1650                                                    (orderByComparator.getOrderByFields().length * 3));
1651    
1652                                    query.append(_SQL_SELECT_WORKFLOWDEFINITIONLINK);
1653    
1654                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1655                                            orderByComparator);
1656    
1657                                    sql = query.toString();
1658                            }
1659                            else {
1660                                    sql = _SQL_SELECT_WORKFLOWDEFINITIONLINK.concat(WorkflowDefinitionLinkModelImpl.ORDER_BY_JPQL);
1661                            }
1662    
1663                            Session session = null;
1664    
1665                            try {
1666                                    session = openSession();
1667    
1668                                    Query q = session.createQuery(sql);
1669    
1670                                    if (orderByComparator == null) {
1671                                            list = (List<WorkflowDefinitionLink>)QueryUtil.list(q,
1672                                                            getDialect(), start, end, false);
1673    
1674                                            Collections.sort(list);
1675                                    }
1676                                    else {
1677                                            list = (List<WorkflowDefinitionLink>)QueryUtil.list(q,
1678                                                            getDialect(), start, end);
1679                                    }
1680                            }
1681                            catch (Exception e) {
1682                                    throw processException(e);
1683                            }
1684                            finally {
1685                                    if (list == null) {
1686                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1687                                    }
1688                                    else {
1689                                            cacheResult(list);
1690    
1691                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1692                                    }
1693    
1694                                    closeSession(session);
1695                            }
1696                    }
1697    
1698                    return list;
1699            }
1700    
1701            /**
1702             * Removes all the workflow definition links where companyId = &#63; from the database.
1703             *
1704             * @param companyId the company ID
1705             * @throws SystemException if a system exception occurred
1706             */
1707            public void removeByCompanyId(long companyId) throws SystemException {
1708                    for (WorkflowDefinitionLink workflowDefinitionLink : findByCompanyId(
1709                                    companyId)) {
1710                            workflowDefinitionLinkPersistence.remove(workflowDefinitionLink);
1711                    }
1712            }
1713    
1714            /**
1715             * Removes all the workflow definition links where companyId = &#63; and workflowDefinitionName = &#63; and workflowDefinitionVersion = &#63; from the database.
1716             *
1717             * @param companyId the company ID
1718             * @param workflowDefinitionName the workflow definition name
1719             * @param workflowDefinitionVersion the workflow definition version
1720             * @throws SystemException if a system exception occurred
1721             */
1722            public void removeByC_W_W(long companyId, String workflowDefinitionName,
1723                    int workflowDefinitionVersion) throws SystemException {
1724                    for (WorkflowDefinitionLink workflowDefinitionLink : findByC_W_W(
1725                                    companyId, workflowDefinitionName, workflowDefinitionVersion)) {
1726                            workflowDefinitionLinkPersistence.remove(workflowDefinitionLink);
1727                    }
1728            }
1729    
1730            /**
1731             * Removes the workflow definition link where groupId = &#63; and companyId = &#63; and classNameId = &#63; and classPK = &#63; and typePK = &#63; from the database.
1732             *
1733             * @param groupId the group ID
1734             * @param companyId the company ID
1735             * @param classNameId the class name ID
1736             * @param classPK the class p k
1737             * @param typePK the type p k
1738             * @throws SystemException if a system exception occurred
1739             */
1740            public void removeByG_C_C_C_T(long groupId, long companyId,
1741                    long classNameId, long classPK, long typePK)
1742                    throws NoSuchWorkflowDefinitionLinkException, SystemException {
1743                    WorkflowDefinitionLink workflowDefinitionLink = findByG_C_C_C_T(groupId,
1744                                    companyId, classNameId, classPK, typePK);
1745    
1746                    workflowDefinitionLinkPersistence.remove(workflowDefinitionLink);
1747            }
1748    
1749            /**
1750             * Removes all the workflow definition links from the database.
1751             *
1752             * @throws SystemException if a system exception occurred
1753             */
1754            public void removeAll() throws SystemException {
1755                    for (WorkflowDefinitionLink workflowDefinitionLink : findAll()) {
1756                            workflowDefinitionLinkPersistence.remove(workflowDefinitionLink);
1757                    }
1758            }
1759    
1760            /**
1761             * Returns the number of workflow definition links where companyId = &#63;.
1762             *
1763             * @param companyId the company ID
1764             * @return the number of matching workflow definition links
1765             * @throws SystemException if a system exception occurred
1766             */
1767            public int countByCompanyId(long companyId) throws SystemException {
1768                    Object[] finderArgs = new Object[] { companyId };
1769    
1770                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
1771                                    finderArgs, this);
1772    
1773                    if (count == null) {
1774                            StringBundler query = new StringBundler(2);
1775    
1776                            query.append(_SQL_COUNT_WORKFLOWDEFINITIONLINK_WHERE);
1777    
1778                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1779    
1780                            String sql = query.toString();
1781    
1782                            Session session = null;
1783    
1784                            try {
1785                                    session = openSession();
1786    
1787                                    Query q = session.createQuery(sql);
1788    
1789                                    QueryPos qPos = QueryPos.getInstance(q);
1790    
1791                                    qPos.add(companyId);
1792    
1793                                    count = (Long)q.uniqueResult();
1794                            }
1795                            catch (Exception e) {
1796                                    throw processException(e);
1797                            }
1798                            finally {
1799                                    if (count == null) {
1800                                            count = Long.valueOf(0);
1801                                    }
1802    
1803                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
1804                                            finderArgs, count);
1805    
1806                                    closeSession(session);
1807                            }
1808                    }
1809    
1810                    return count.intValue();
1811            }
1812    
1813            /**
1814             * Returns the number of workflow definition links where companyId = &#63; and workflowDefinitionName = &#63; and workflowDefinitionVersion = &#63;.
1815             *
1816             * @param companyId the company ID
1817             * @param workflowDefinitionName the workflow definition name
1818             * @param workflowDefinitionVersion the workflow definition version
1819             * @return the number of matching workflow definition links
1820             * @throws SystemException if a system exception occurred
1821             */
1822            public int countByC_W_W(long companyId, String workflowDefinitionName,
1823                    int workflowDefinitionVersion) throws SystemException {
1824                    Object[] finderArgs = new Object[] {
1825                                    companyId, workflowDefinitionName, workflowDefinitionVersion
1826                            };
1827    
1828                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_W_W,
1829                                    finderArgs, this);
1830    
1831                    if (count == null) {
1832                            StringBundler query = new StringBundler(4);
1833    
1834                            query.append(_SQL_COUNT_WORKFLOWDEFINITIONLINK_WHERE);
1835    
1836                            query.append(_FINDER_COLUMN_C_W_W_COMPANYID_2);
1837    
1838                            if (workflowDefinitionName == null) {
1839                                    query.append(_FINDER_COLUMN_C_W_W_WORKFLOWDEFINITIONNAME_1);
1840                            }
1841                            else {
1842                                    if (workflowDefinitionName.equals(StringPool.BLANK)) {
1843                                            query.append(_FINDER_COLUMN_C_W_W_WORKFLOWDEFINITIONNAME_3);
1844                                    }
1845                                    else {
1846                                            query.append(_FINDER_COLUMN_C_W_W_WORKFLOWDEFINITIONNAME_2);
1847                                    }
1848                            }
1849    
1850                            query.append(_FINDER_COLUMN_C_W_W_WORKFLOWDEFINITIONVERSION_2);
1851    
1852                            String sql = query.toString();
1853    
1854                            Session session = null;
1855    
1856                            try {
1857                                    session = openSession();
1858    
1859                                    Query q = session.createQuery(sql);
1860    
1861                                    QueryPos qPos = QueryPos.getInstance(q);
1862    
1863                                    qPos.add(companyId);
1864    
1865                                    if (workflowDefinitionName != null) {
1866                                            qPos.add(workflowDefinitionName);
1867                                    }
1868    
1869                                    qPos.add(workflowDefinitionVersion);
1870    
1871                                    count = (Long)q.uniqueResult();
1872                            }
1873                            catch (Exception e) {
1874                                    throw processException(e);
1875                            }
1876                            finally {
1877                                    if (count == null) {
1878                                            count = Long.valueOf(0);
1879                                    }
1880    
1881                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_W_W,
1882                                            finderArgs, count);
1883    
1884                                    closeSession(session);
1885                            }
1886                    }
1887    
1888                    return count.intValue();
1889            }
1890    
1891            /**
1892             * Returns the number of workflow definition links where groupId = &#63; and companyId = &#63; and classNameId = &#63; and classPK = &#63; and typePK = &#63;.
1893             *
1894             * @param groupId the group ID
1895             * @param companyId the company ID
1896             * @param classNameId the class name ID
1897             * @param classPK the class p k
1898             * @param typePK the type p k
1899             * @return the number of matching workflow definition links
1900             * @throws SystemException if a system exception occurred
1901             */
1902            public int countByG_C_C_C_T(long groupId, long companyId, long classNameId,
1903                    long classPK, long typePK) throws SystemException {
1904                    Object[] finderArgs = new Object[] {
1905                                    groupId, companyId, classNameId, classPK, typePK
1906                            };
1907    
1908                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_C_C_C_T,
1909                                    finderArgs, this);
1910    
1911                    if (count == null) {
1912                            StringBundler query = new StringBundler(6);
1913    
1914                            query.append(_SQL_COUNT_WORKFLOWDEFINITIONLINK_WHERE);
1915    
1916                            query.append(_FINDER_COLUMN_G_C_C_C_T_GROUPID_2);
1917    
1918                            query.append(_FINDER_COLUMN_G_C_C_C_T_COMPANYID_2);
1919    
1920                            query.append(_FINDER_COLUMN_G_C_C_C_T_CLASSNAMEID_2);
1921    
1922                            query.append(_FINDER_COLUMN_G_C_C_C_T_CLASSPK_2);
1923    
1924                            query.append(_FINDER_COLUMN_G_C_C_C_T_TYPEPK_2);
1925    
1926                            String sql = query.toString();
1927    
1928                            Session session = null;
1929    
1930                            try {
1931                                    session = openSession();
1932    
1933                                    Query q = session.createQuery(sql);
1934    
1935                                    QueryPos qPos = QueryPos.getInstance(q);
1936    
1937                                    qPos.add(groupId);
1938    
1939                                    qPos.add(companyId);
1940    
1941                                    qPos.add(classNameId);
1942    
1943                                    qPos.add(classPK);
1944    
1945                                    qPos.add(typePK);
1946    
1947                                    count = (Long)q.uniqueResult();
1948                            }
1949                            catch (Exception e) {
1950                                    throw processException(e);
1951                            }
1952                            finally {
1953                                    if (count == null) {
1954                                            count = Long.valueOf(0);
1955                                    }
1956    
1957                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_C_C_C_T,
1958                                            finderArgs, count);
1959    
1960                                    closeSession(session);
1961                            }
1962                    }
1963    
1964                    return count.intValue();
1965            }
1966    
1967            /**
1968             * Returns the number of workflow definition links.
1969             *
1970             * @return the number of workflow definition links
1971             * @throws SystemException if a system exception occurred
1972             */
1973            public int countAll() throws SystemException {
1974                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1975                                    FINDER_ARGS_EMPTY, this);
1976    
1977                    if (count == null) {
1978                            Session session = null;
1979    
1980                            try {
1981                                    session = openSession();
1982    
1983                                    Query q = session.createQuery(_SQL_COUNT_WORKFLOWDEFINITIONLINK);
1984    
1985                                    count = (Long)q.uniqueResult();
1986                            }
1987                            catch (Exception e) {
1988                                    throw processException(e);
1989                            }
1990                            finally {
1991                                    if (count == null) {
1992                                            count = Long.valueOf(0);
1993                                    }
1994    
1995                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
1996                                            FINDER_ARGS_EMPTY, count);
1997    
1998                                    closeSession(session);
1999                            }
2000                    }
2001    
2002                    return count.intValue();
2003            }
2004    
2005            /**
2006             * Initializes the workflow definition link persistence.
2007             */
2008            public void afterPropertiesSet() {
2009                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
2010                                            com.liferay.portal.util.PropsUtil.get(
2011                                                    "value.object.listener.com.liferay.portal.model.WorkflowDefinitionLink")));
2012    
2013                    if (listenerClassNames.length > 0) {
2014                            try {
2015                                    List<ModelListener<WorkflowDefinitionLink>> listenersList = new ArrayList<ModelListener<WorkflowDefinitionLink>>();
2016    
2017                                    for (String listenerClassName : listenerClassNames) {
2018                                            listenersList.add((ModelListener<WorkflowDefinitionLink>)InstanceFactory.newInstance(
2019                                                            listenerClassName));
2020                                    }
2021    
2022                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
2023                            }
2024                            catch (Exception e) {
2025                                    _log.error(e);
2026                            }
2027                    }
2028            }
2029    
2030            public void destroy() {
2031                    EntityCacheUtil.removeCache(WorkflowDefinitionLinkImpl.class.getName());
2032                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
2033                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2034            }
2035    
2036            @BeanReference(type = AccountPersistence.class)
2037            protected AccountPersistence accountPersistence;
2038            @BeanReference(type = AddressPersistence.class)
2039            protected AddressPersistence addressPersistence;
2040            @BeanReference(type = BrowserTrackerPersistence.class)
2041            protected BrowserTrackerPersistence browserTrackerPersistence;
2042            @BeanReference(type = ClassNamePersistence.class)
2043            protected ClassNamePersistence classNamePersistence;
2044            @BeanReference(type = ClusterGroupPersistence.class)
2045            protected ClusterGroupPersistence clusterGroupPersistence;
2046            @BeanReference(type = CompanyPersistence.class)
2047            protected CompanyPersistence companyPersistence;
2048            @BeanReference(type = ContactPersistence.class)
2049            protected ContactPersistence contactPersistence;
2050            @BeanReference(type = CountryPersistence.class)
2051            protected CountryPersistence countryPersistence;
2052            @BeanReference(type = EmailAddressPersistence.class)
2053            protected EmailAddressPersistence emailAddressPersistence;
2054            @BeanReference(type = GroupPersistence.class)
2055            protected GroupPersistence groupPersistence;
2056            @BeanReference(type = ImagePersistence.class)
2057            protected ImagePersistence imagePersistence;
2058            @BeanReference(type = LayoutPersistence.class)
2059            protected LayoutPersistence layoutPersistence;
2060            @BeanReference(type = LayoutBranchPersistence.class)
2061            protected LayoutBranchPersistence layoutBranchPersistence;
2062            @BeanReference(type = LayoutPrototypePersistence.class)
2063            protected LayoutPrototypePersistence layoutPrototypePersistence;
2064            @BeanReference(type = LayoutRevisionPersistence.class)
2065            protected LayoutRevisionPersistence layoutRevisionPersistence;
2066            @BeanReference(type = LayoutSetPersistence.class)
2067            protected LayoutSetPersistence layoutSetPersistence;
2068            @BeanReference(type = LayoutSetBranchPersistence.class)
2069            protected LayoutSetBranchPersistence layoutSetBranchPersistence;
2070            @BeanReference(type = LayoutSetPrototypePersistence.class)
2071            protected LayoutSetPrototypePersistence layoutSetPrototypePersistence;
2072            @BeanReference(type = ListTypePersistence.class)
2073            protected ListTypePersistence listTypePersistence;
2074            @BeanReference(type = LockPersistence.class)
2075            protected LockPersistence lockPersistence;
2076            @BeanReference(type = MembershipRequestPersistence.class)
2077            protected MembershipRequestPersistence membershipRequestPersistence;
2078            @BeanReference(type = OrganizationPersistence.class)
2079            protected OrganizationPersistence organizationPersistence;
2080            @BeanReference(type = OrgGroupPermissionPersistence.class)
2081            protected OrgGroupPermissionPersistence orgGroupPermissionPersistence;
2082            @BeanReference(type = OrgGroupRolePersistence.class)
2083            protected OrgGroupRolePersistence orgGroupRolePersistence;
2084            @BeanReference(type = OrgLaborPersistence.class)
2085            protected OrgLaborPersistence orgLaborPersistence;
2086            @BeanReference(type = PasswordPolicyPersistence.class)
2087            protected PasswordPolicyPersistence passwordPolicyPersistence;
2088            @BeanReference(type = PasswordPolicyRelPersistence.class)
2089            protected PasswordPolicyRelPersistence passwordPolicyRelPersistence;
2090            @BeanReference(type = PasswordTrackerPersistence.class)
2091            protected PasswordTrackerPersistence passwordTrackerPersistence;
2092            @BeanReference(type = PermissionPersistence.class)
2093            protected PermissionPersistence permissionPersistence;
2094            @BeanReference(type = PhonePersistence.class)
2095            protected PhonePersistence phonePersistence;
2096            @BeanReference(type = PluginSettingPersistence.class)
2097            protected PluginSettingPersistence pluginSettingPersistence;
2098            @BeanReference(type = PortalPreferencesPersistence.class)
2099            protected PortalPreferencesPersistence portalPreferencesPersistence;
2100            @BeanReference(type = PortletPersistence.class)
2101            protected PortletPersistence portletPersistence;
2102            @BeanReference(type = PortletItemPersistence.class)
2103            protected PortletItemPersistence portletItemPersistence;
2104            @BeanReference(type = PortletPreferencesPersistence.class)
2105            protected PortletPreferencesPersistence portletPreferencesPersistence;
2106            @BeanReference(type = RegionPersistence.class)
2107            protected RegionPersistence regionPersistence;
2108            @BeanReference(type = ReleasePersistence.class)
2109            protected ReleasePersistence releasePersistence;
2110            @BeanReference(type = RepositoryPersistence.class)
2111            protected RepositoryPersistence repositoryPersistence;
2112            @BeanReference(type = RepositoryEntryPersistence.class)
2113            protected RepositoryEntryPersistence repositoryEntryPersistence;
2114            @BeanReference(type = ResourcePersistence.class)
2115            protected ResourcePersistence resourcePersistence;
2116            @BeanReference(type = ResourceActionPersistence.class)
2117            protected ResourceActionPersistence resourceActionPersistence;
2118            @BeanReference(type = ResourceBlockPersistence.class)
2119            protected ResourceBlockPersistence resourceBlockPersistence;
2120            @BeanReference(type = ResourceBlockPermissionPersistence.class)
2121            protected ResourceBlockPermissionPersistence resourceBlockPermissionPersistence;
2122            @BeanReference(type = ResourceCodePersistence.class)
2123            protected ResourceCodePersistence resourceCodePersistence;
2124            @BeanReference(type = ResourcePermissionPersistence.class)
2125            protected ResourcePermissionPersistence resourcePermissionPersistence;
2126            @BeanReference(type = ResourceTypePermissionPersistence.class)
2127            protected ResourceTypePermissionPersistence resourceTypePermissionPersistence;
2128            @BeanReference(type = RolePersistence.class)
2129            protected RolePersistence rolePersistence;
2130            @BeanReference(type = ServiceComponentPersistence.class)
2131            protected ServiceComponentPersistence serviceComponentPersistence;
2132            @BeanReference(type = ShardPersistence.class)
2133            protected ShardPersistence shardPersistence;
2134            @BeanReference(type = SubscriptionPersistence.class)
2135            protected SubscriptionPersistence subscriptionPersistence;
2136            @BeanReference(type = TeamPersistence.class)
2137            protected TeamPersistence teamPersistence;
2138            @BeanReference(type = TicketPersistence.class)
2139            protected TicketPersistence ticketPersistence;
2140            @BeanReference(type = UserPersistence.class)
2141            protected UserPersistence userPersistence;
2142            @BeanReference(type = UserGroupPersistence.class)
2143            protected UserGroupPersistence userGroupPersistence;
2144            @BeanReference(type = UserGroupGroupRolePersistence.class)
2145            protected UserGroupGroupRolePersistence userGroupGroupRolePersistence;
2146            @BeanReference(type = UserGroupRolePersistence.class)
2147            protected UserGroupRolePersistence userGroupRolePersistence;
2148            @BeanReference(type = UserIdMapperPersistence.class)
2149            protected UserIdMapperPersistence userIdMapperPersistence;
2150            @BeanReference(type = UserNotificationEventPersistence.class)
2151            protected UserNotificationEventPersistence userNotificationEventPersistence;
2152            @BeanReference(type = UserTrackerPersistence.class)
2153            protected UserTrackerPersistence userTrackerPersistence;
2154            @BeanReference(type = UserTrackerPathPersistence.class)
2155            protected UserTrackerPathPersistence userTrackerPathPersistence;
2156            @BeanReference(type = VirtualHostPersistence.class)
2157            protected VirtualHostPersistence virtualHostPersistence;
2158            @BeanReference(type = WebDAVPropsPersistence.class)
2159            protected WebDAVPropsPersistence webDAVPropsPersistence;
2160            @BeanReference(type = WebsitePersistence.class)
2161            protected WebsitePersistence websitePersistence;
2162            @BeanReference(type = WorkflowDefinitionLinkPersistence.class)
2163            protected WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
2164            @BeanReference(type = WorkflowInstanceLinkPersistence.class)
2165            protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
2166            private static final String _SQL_SELECT_WORKFLOWDEFINITIONLINK = "SELECT workflowDefinitionLink FROM WorkflowDefinitionLink workflowDefinitionLink";
2167            private static final String _SQL_SELECT_WORKFLOWDEFINITIONLINK_WHERE = "SELECT workflowDefinitionLink FROM WorkflowDefinitionLink workflowDefinitionLink WHERE ";
2168            private static final String _SQL_COUNT_WORKFLOWDEFINITIONLINK = "SELECT COUNT(workflowDefinitionLink) FROM WorkflowDefinitionLink workflowDefinitionLink";
2169            private static final String _SQL_COUNT_WORKFLOWDEFINITIONLINK_WHERE = "SELECT COUNT(workflowDefinitionLink) FROM WorkflowDefinitionLink workflowDefinitionLink WHERE ";
2170            private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "workflowDefinitionLink.companyId = ?";
2171            private static final String _FINDER_COLUMN_C_W_W_COMPANYID_2 = "workflowDefinitionLink.companyId = ? AND ";
2172            private static final String _FINDER_COLUMN_C_W_W_WORKFLOWDEFINITIONNAME_1 = "workflowDefinitionLink.workflowDefinitionName IS NULL AND ";
2173            private static final String _FINDER_COLUMN_C_W_W_WORKFLOWDEFINITIONNAME_2 = "workflowDefinitionLink.workflowDefinitionName = ? AND ";
2174            private static final String _FINDER_COLUMN_C_W_W_WORKFLOWDEFINITIONNAME_3 = "(workflowDefinitionLink.workflowDefinitionName IS NULL OR workflowDefinitionLink.workflowDefinitionName = ?) AND ";
2175            private static final String _FINDER_COLUMN_C_W_W_WORKFLOWDEFINITIONVERSION_2 =
2176                    "workflowDefinitionLink.workflowDefinitionVersion = ?";
2177            private static final String _FINDER_COLUMN_G_C_C_C_T_GROUPID_2 = "workflowDefinitionLink.groupId = ? AND ";
2178            private static final String _FINDER_COLUMN_G_C_C_C_T_COMPANYID_2 = "workflowDefinitionLink.companyId = ? AND ";
2179            private static final String _FINDER_COLUMN_G_C_C_C_T_CLASSNAMEID_2 = "workflowDefinitionLink.classNameId = ? AND ";
2180            private static final String _FINDER_COLUMN_G_C_C_C_T_CLASSPK_2 = "workflowDefinitionLink.classPK = ? AND ";
2181            private static final String _FINDER_COLUMN_G_C_C_C_T_TYPEPK_2 = "workflowDefinitionLink.typePK = ?";
2182            private static final String _ORDER_BY_ENTITY_ALIAS = "workflowDefinitionLink.";
2183            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No WorkflowDefinitionLink exists with the primary key ";
2184            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No WorkflowDefinitionLink exists with the key {";
2185            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
2186            private static Log _log = LogFactoryUtil.getLog(WorkflowDefinitionLinkPersistenceImpl.class);
2187            private static WorkflowDefinitionLink _nullWorkflowDefinitionLink = new WorkflowDefinitionLinkImpl() {
2188                            @Override
2189                            public Object clone() {
2190                                    return this;
2191                            }
2192    
2193                            @Override
2194                            public CacheModel<WorkflowDefinitionLink> toCacheModel() {
2195                                    return _nullWorkflowDefinitionLinkCacheModel;
2196                            }
2197                    };
2198    
2199            private static CacheModel<WorkflowDefinitionLink> _nullWorkflowDefinitionLinkCacheModel =
2200                    new CacheModel<WorkflowDefinitionLink>() {
2201                            public WorkflowDefinitionLink toEntityModel() {
2202                                    return _nullWorkflowDefinitionLink;
2203                            }
2204                    };
2205    }