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