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